@pixelbyte-software/pixcode 1.33.11 → 1.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/assets/{index-oLYHJ2X5.js → index-BvClqlMf.js} +1 -1
  2. package/dist/index.html +1 -1
  3. package/dist-server/server/index.js +4 -0
  4. package/dist-server/server/index.js.map +1 -1
  5. package/dist-server/server/modules/orchestration/a2a/adapter-registry.js +47 -0
  6. package/dist-server/server/modules/orchestration/a2a/adapter-registry.js.map +1 -0
  7. package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js +17 -0
  8. package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js.map +1 -0
  9. package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js +233 -0
  10. package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js.map +1 -0
  11. package/dist-server/server/modules/orchestration/a2a/agent-card.js +50 -0
  12. package/dist-server/server/modules/orchestration/a2a/agent-card.js.map +1 -0
  13. package/dist-server/server/modules/orchestration/a2a/auth.middleware.js +25 -0
  14. package/dist-server/server/modules/orchestration/a2a/auth.middleware.js.map +1 -0
  15. package/dist-server/server/modules/orchestration/a2a/bus.js +34 -0
  16. package/dist-server/server/modules/orchestration/a2a/bus.js.map +1 -0
  17. package/dist-server/server/modules/orchestration/a2a/routes.js +233 -0
  18. package/dist-server/server/modules/orchestration/a2a/routes.js.map +1 -0
  19. package/dist-server/server/modules/orchestration/a2a/types.js +6 -0
  20. package/dist-server/server/modules/orchestration/a2a/types.js.map +1 -0
  21. package/dist-server/server/modules/orchestration/a2a/validator.js +85 -0
  22. package/dist-server/server/modules/orchestration/a2a/validator.js.map +1 -0
  23. package/dist-server/server/modules/orchestration/index.js +10 -0
  24. package/dist-server/server/modules/orchestration/index.js.map +1 -0
  25. package/package.json +1 -1
  26. package/scripts/smoke/a2a-roundtrip.mjs +98 -0
  27. package/server/index.js +9 -0
  28. package/server/modules/orchestration/a2a/adapter-registry.ts +58 -0
  29. package/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.ts +49 -0
  30. package/server/modules/orchestration/a2a/adapters/claude-code.adapter.ts +283 -0
  31. package/server/modules/orchestration/a2a/agent-card.ts +55 -0
  32. package/server/modules/orchestration/a2a/auth.middleware.ts +29 -0
  33. package/server/modules/orchestration/a2a/bus.ts +46 -0
  34. package/server/modules/orchestration/a2a/routes.ts +264 -0
  35. package/server/modules/orchestration/a2a/types.ts +111 -0
  36. package/server/modules/orchestration/a2a/validator.ts +90 -0
  37. package/server/modules/orchestration/index.ts +26 -0
@@ -226,7 +226,7 @@ import{j as s,a as jS,R as Jm,o as Qm,_ as QT,b as eA,m as IS,E as gr,T as RS,P
226
226
  .xterm-screen:focus {
227
227
  outline: none !important;
228
228
  }
229
- `;function ER(){if(typeof document>"u"||document.getElementById(ky))return;const e=document.createElement("style");e.id=ky,e.type="text/css",e.innerText=SR,document.head.appendChild(e)}function NR({terminalContainerRef:e,terminalRef:t,fitAddonRef:n,wsRef:r,selectedProject:a,minimal:i,isRestarting:o,initialCommandRef:l,isPlainShellRef:c,authUrlRef:d,copyAuthUrlToClipboard:u,closeSocket:p}){const[h,m]=f.useState(!1),g=f.useRef(null),b=a?.fullPath||a?.path||"",x=!!a;f.useEffect(()=>{ER()},[]);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 vR.Terminal(cR);t.current=w;const S=new gR.FitAddon;n.current=S,w.loadAddon(S),i||w.loadAddon(new xR.WebLinksAddon);try{w.loadAddon(new yR.WebglAddon)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}w.open(e.current);const E=async()=>{const N=w.getSelection();return N?br(N):!1},k=N=>{if(!w.hasSelection())return;const j=w.getSelection();if(j){if(N.preventDefault(),N.clipboardData){N.clipboardData.setData("text/plain",j);return}br(j)}};e.current.addEventListener("copy",k),w.attachCustomKeyEventHandler(N=>{const j=k5(l.current)?v5:d.current;return N.type==="keydown"&&i&&c.current&&j&&!N.ctrlKey&&!N.metaKey&&!N.altKey&&N.key?.toLowerCase()==="c"?(N.preventDefault(),N.stopPropagation(),u(j),!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(O=>{ui(r.current,{type:"input",data:O})}).catch(()=>{}),!1):!0}),window.setTimeout(()=>{const N=n.current,j=t.current;!N||!j||(N.fit(),ui(r.current,{type:"resize",cols:j.cols,rows:j.rows}))},w5),m(!0);const A=w.onData(N=>{ui(r.current,{type:"input",data:N})}),T=new ResizeObserver(()=>{g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{const N=n.current,j=t.current;!N||!j||(N.fit(),ui(r.current,{type:"resize",cols:j.cols,rows:j.rows}))},rR)});return T.observe(e.current),()=>{e.current?.removeEventListener("copy",k),T.disconnect(),g.current!==null&&(window.clearTimeout(g.current),g.current=null),A.dispose(),p(),v()}},[d,p,u,v,n,l,c,o,i,x,b,e,t,r]),{isInitialized:h,clearTerminalScreen:y,disposeTerminal:v}}function CR({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:r,minimal:a,autoConnect:i,isRestarting:o,onProcessComplete:l,onOutputRef:c}){const d=f.useRef(null),u=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 T=f.useCallback(H=>{k.current=H,g(H),x(L=>L+1)},[]),N=f.useCallback(()=>{const H=h.current;H&&((H.readyState===WebSocket.OPEN||H.readyState===WebSocket.CONNECTING)&&H.close(),h.current=null)},[]),j=f.useCallback((H=k.current)=>{if(!H)return!1;const L=window.open(H,"_blank");if(L){try{L.opener=null}catch{}return!0}return!1},[]),O=f.useCallback(async(H=k.current)=>H?br(H):!1,[]),{isInitialized:_,clearTerminalScreen:R,disposeTerminal:C}=NR({terminalContainerRef:d,terminalRef:u,fitAddonRef:p,wsRef:h,selectedProject:e,minimal:a,isRestarting:o,initialCommandRef:w,isPlainShellRef:S,authUrlRef:k,copyAuthUrlToClipboard:O,closeSocket:N}),{isConnected:F,isConnecting:K,connectToShell:B,disconnectFromShell:W}=fR({wsRef:h,terminalRef:u,fitAddonRef:p,selectedProjectRef:y,selectedSessionRef:v,initialCommandRef:w,isPlainShellRef:S,onProcessCompleteRef:E,isInitialized:_,autoConnect:i,closeSocket:N,clearTerminalScreen:R,setAuthUrl:T,onOutputRef:c});return f.useEffect(()=>{o&&(W(),C())},[W,C,o]),f.useEffect(()=>{e||(W(),C())},[W,C,e]),f.useEffect(()=>{const H=t?.id??null;A.current!==H&&_&&W(),A.current=H},[W,_,t?.id]),{terminalContainerRef:d,terminalRef:u,wsRef:h,isConnected:F,isInitialized:_,isConnecting:K,authUrl:m,authUrlVersion:b,connectToShell:B,disconnectFromShell:W,openAuthUrlInBrowser:j,copyAuthUrlToClipboard:O}}function TR({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 AR({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 _R({isConnected:e,isInitialized:t,isRestarting:n,hasSession:r,sessionDisplayNameShort:a,onDisconnect:i,onRestart:o,statusNewSessionText:l,statusInitializingText:c,statusRestartingText:d,disconnectLabel:u,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:d})]}),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:u})]}),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 jR({terminalContainerRef:e,authUrl:t,authUrlVersion:n,initialCommand:r,isConnected:a,openAuthUrlInBrowser:i,copyAuthUrlToClipboard:o}){const[l,c]=f.useState("idle"),[d,u]=f.useState(!1),p=f.useMemo(()=>wR(r,t),[t,r]);f.useEffect(()=>{c("idle"),u(!1)},[n,p,a]);const h=!!p,m=h&&!d,g=h&&d;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:()=>u(!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:()=>u(!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 IR=[{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"}],RR={up:r5,down:i0,left:nI,right:s0},to=e=>e.preventDefault(),Sy="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",DR="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",Gd="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 Ey({wsRef:e,terminalRef:t,isConnected:n,bottomOffset:r="bottom-0"}){const{t:a}=De("settings"),[i,o]=f.useState(!1),[l,c]=f.useState(!1),d=f.useCallback(m=>{ui(e.current,{type:"input",data:m})},[e]),u=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&&d(m)}catch{}},[d]),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)),d(g)},[i,l,d]);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:to,onClick:()=>{p()},disabled:!n,className:Gd,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:s.jsx(c0,{className:"h-4 w-4"})}),IR.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:to,onClick:b,disabled:!n,className:g?DR:Sy,children:m.label},m.id)}if(m.type==="arrow"){const g=RR[m.icon];return s.jsx("button",{type:"button",onPointerDown:to,onClick:()=>d(m.sequence),disabled:!n,className:Gd,children:s.jsx(g,{className:"h-4 w-4"})},m.id)}return s.jsx("button",{type:"button",onPointerDown:to,onClick:()=>h(m.sequence),disabled:!n,className:Sy,children:m.label},m.id)}),s.jsx("button",{type:"button",onPointerDown:to,onClick:u,disabled:!n,className:Gd,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:s.jsx(rI,{className:"h-4 w-4"})})]})})}function S5({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}=De("chat"),[d,u]=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:T,openAuthUrlInBrowser:N,copyAuthUrlToClipboard:j}=CR({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:r,minimal:i,autoConnect:o,isRestarting:d,onProcessComplete:a,onOutputRef:g}),O=f.useCallback(()=>{const U=x.current;if(!U)return;const P=U.buffer.active,J=P.baseY+P.cursorY,Z=Math.min(P.baseY+P.length-1,J+10),de=Math.max(0,J-iR),le=[];for(let Ae=de;Ae<=Z;Ae++){const Ge=P.getLine(Ae);Ge&&le.push(Ge.translateToString().trimEnd())}let ce=-1;for(let Ae=le.length-1;Ae>=0;Ae--)if(/esc to cancel/i.test(le[Ae])||/enter to select/i.test(le[Ae])){ce=Ae;break}if(ce===-1){h(null);return}const he=new Map,ve=Math.max(0,ce-sR);for(let Ae=ce-1;Ae>=ve;Ae--){const Ge=le[Ae].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(Ge){const M=Ge[1],pe=Ge[2].trim();parseInt(M,10)<=oR&&pe.length>0&&!he.has(M)&&he.set(M,pe)}}const Ce=[];for(let Ae=1;Ae<=he.size&&he.has(String(Ae));Ae++)Ce.push({number:String(Ae),label:he.get(String(Ae))});h(Ce.length>=lR?Ce:null)},[x]),_=f.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(O,aR)},[O]);f.useEffect(()=>{g.current=_},[_]),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 U=()=>{x.current?.focus()},P=window.requestAnimationFrame(U),J=window.setTimeout(U,0);return()=>{window.cancelAnimationFrame(P),window.clearTimeout(J)}},[l,v,w,x]);const R=f.useCallback(U=>{ui(y.current,{type:"input",data:U})},[y]),C=f.useMemo(()=>kR(t),[t]),F=f.useMemo(()=>C?C.slice(0,30):null,[C]),K=f.useMemo(()=>C?C.slice(0,50):null,[C]),B=f.useCallback(()=>{u(!0),window.setTimeout(()=>{u(!1)},nR)},[]);if(!e)return s.jsx(AR,{title:c("shell.selectProject.title"),description:c("shell.selectProject.description")});if(i)return s.jsxs(s.Fragment,{children:[s.jsx(jR,{terminalContainerRef:b,authUrl:E,authUrlVersion:k,initialCommand:n,isConnected:v,openAuthUrlInBrowser:N,copyAuthUrlToClipboard:j}),s.jsx(Ey,{wsRef:y,terminalRef:x,isConnected:v,bottomOffset:"bottom-0"})]});const W=r?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:K}):c("shell.startSession"),H=r?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName}),L=w?S?"connecting":v?null:"connect":"loading",G=L==="connecting"?H:W;return s.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[s.jsx(_R,{isConnected:v,isInitialized:w,isRestarting:d,hasSession:!!t,sessionDisplayNameShort:F,onDisconnect:T,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:d||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"}}),L&&s.jsx(TR,{mode:L,description:G,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:U=>U.preventDefault(),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map(U=>s.jsxs("button",{type:"button",onClick:()=>{R(U.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:`${U.number}. ${U.label}`,children:[U.number,". ",U.label]},U.number)),s.jsx("button",{type:"button",onClick:()=>{R("\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(Ey,{wsRef:y,terminalRef:x,isConnected:v})]})}function OR({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 LR({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 E5({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:d="",showHeader:u=!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 ${d}`,children:[!h&&u&&c&&s.jsx(LR,{title:c,isCompleted:m,onClose:l}),s.jsx("div",{className:"min-h-0 w-full flex-1",children:s.jsx(S5,{selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:b,isActive:a,onProcessComplete:x,minimal:h,autoConnect:h?!0:i})})]}):s.jsx(OR,{className:d})}const MR=(e,t)=>t||(e==="claude"?"claude --dangerously-skip-permissions /login":e==="cursor"?"cursor-agent login":e==="codex"?"codex login":e==="qwen"?"qwen auth":e==="opencode"?"opencode auth login":"gemini"),PR={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."},opencode:{keyLabel:"Anthropic API Key (default backend)",keyExample:"sk-ant-...",supportsBaseUrl:!0,baseUrlExample:"https://api.anthropic.com",keyConsoleUrl:"https://console.anthropic.com/settings/keys",keyConsoleLabel:"Anthropic Console",notes:"OpenCode is multi-provider — this sets the Anthropic credentials. Switch providers via `opencode auth login` or opencode.json."}};function Ny({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 FR({provider:e}){const[t,n]=f.useState(""),[r,a]=f.useState(!1),[i,o]=f.useState("idle"),[l,c]=f.useState(null),d=async()=>{const u=t.trim();if(u){a(!0),c(null),o("idle");try{const p=await ke(`/api/providers/${e}/oauth-paste`,{method:"POST",body:JSON.stringify({callbackUrl:u})}),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:u=>n(u.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:u=>{u.key==="Enter"&&d()}}),s.jsx("button",{onClick:()=>void d(),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(cn,{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(Ht,{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 zR({provider:e,onSaved:t}){const n=PR[e],[r,a]=f.useState(""),[i,o]=f.useState(""),[l,c]=f.useState(!1),[d,u]=f.useState("idle"),[p,h]=f.useState(null);f.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await ke("/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),u("idle");try{const b=await ke(`/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})`);u("ok"),a(""),t()}catch(b){h(b?.message||"Save failed"),u("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(DI,{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(Mr,{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(cn,{className:"h-4 w-4 animate-spin"}):s.jsx(Ht,{className:"h-4 w-4"}),"Save API Key"]}),d==="ok"&&s.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved — reconnect to pick it up."}),d==="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 N5({isOpen:e,onClose:t,provider:n="claude",onComplete:r,customCommand:a,isAuthenticated:i=!1}){const{t:o}=De("common"),l=n!=="cursor",[c,d]=f.useState(l?"apiKey":"browser");f.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,n,l]);const u=f.useMemo(()=>`${wc[n]??n} Login`,[n]);if(!e)return null;const p=MR(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:u}),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(pt,{className:"h-6 w-6"})})]}),s.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[s.jsx(Ny,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&s.jsx(Ny,{active:c==="apiKey",onClick:()=>d("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(E5,{project:y6,command:p,onComplete:h,minimal:!0})}),s.jsx("div",{className:"border-t border-border/40 bg-background/50 px-4 py-3",children:s.jsx(FR,{provider:n})})]}):s.jsx(zR,{provider:n,onSaved:()=>h(0)})})]})})}const BR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),$R=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa();return s.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},UR=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa();return s.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},GR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),HR=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa(),n=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return s.jsx("img",{src:n,alt:"OpenCode",className:e})},qR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function Rn({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?s.jsx(UR,{className:t}):e==="codex"?s.jsx($R,{className:t}):e==="gemini"?s.jsx(GR,{className:t}):e==="qwen"?s.jsx(qR,{className:t}):e==="opencode"?s.jsx(HR,{className:t}):s.jsx(BR,{className:t})}function VR({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(Rn,{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(Ht,{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 WR=[{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 KR({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:WR.map(n=>s.jsx(VR,{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 YR({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(ir,{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(II,{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(_I,{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 Cy=[{title:"Git Configuration",icon:ir,required:!0},{title:"Connect Agents",icon:a5,required:!1}];function ZR({currentStep:e}){return s.jsx("div",{className:"mb-8",children:s.jsx("div",{className:"flex items-center justify-between",children:Cy.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(Ht,{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<Cy.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 Ty=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ay=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function XR({onComplete:e}){const[t,n]=f.useState(0),[r,a]=f.useState(""),[i,o]=f.useState(""),[l,c]=f.useState(!1),[d,u]=f.useState(""),[p,h]=f.useState(null),{providerAuthStatus:m,checkProviderAuthStatus:g,refreshProviderAuthStatuses:b}=g0(),x=f.useRef(void 0),y=f.useCallback(async()=>{try{const T=await ke("/api/user/git-config");if(!T.ok)return;const N=await T.json();N.gitName&&a(N.gitName),N.gitEmail&&o(N.gitEmail)}catch(T){console.error("Error loading git config:",T)}},[]);f.useEffect(()=>{y(),b()},[y,b]),f.useEffect(()=>{const T=x.current;x.current=p,T!=null&&p===null&&b()},[p,b]);const v=T=>{h(T)},w=T=>{T===0&&p&&g(p)},S=async()=>{if(u(""),t!==0){n(T=>T+1);return}if(!r.trim()||!i.trim()){u("Both git name and email are required.");return}if(!Ty.test(i)){u("Please enter a valid email address.");return}c(!0);try{const T=await ke("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:i})});if(!T.ok){const N=await Ay(T,"Failed to save git configuration");throw new Error(N)}n(N=>N+1)}catch(T){u(T instanceof Error?T.message:"Failed to save git configuration")}finally{c(!1)}},E=()=>{u(""),n(T=>T-1)},k=async()=>{c(!0),u("");try{const T=await ke("/api/user/complete-onboarding",{method:"POST"});if(!T.ok){const N=await Ay(T,"Failed to complete onboarding");throw new Error(N)}await e?.()}catch(T){u(T instanceof Error?T.message:"Failed to complete onboarding")}finally{c(!1)}},A=t===0?!!(r.trim()&&i.trim()&&Ty.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(YR,{gitName:r,gitEmail:i,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):s.jsx(KR,{providerStatuses:m,onOpenProviderLogin:v}),d&&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:d})}),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(o0,{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(cn,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:["Next",s.jsx(Nr,{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(cn,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ht,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&s.jsx(N5,{isOpen:!!p,onClose:()=>h(null),provider:p,onComplete:w})]})}const JR=["0s","0.1s","0.2s"];function QR(){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(Si,{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:JR.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 C5({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 To({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:d=>r(d.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 T5({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(Si,{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 e9={username:"",password:""};function t9(){const{t:e}=De("auth"),{login:t}=rl(),[n,r]=f.useState(e9),[a,i]=f.useState(""),[o,l]=f.useState(!1),c=f.useCallback((u,p)=>{r(h=>({...h,[u]:p}))},[]),d=f.useCallback(async u=>{if(u.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(T5,{title:e("login.title"),description:e("login.description"),footerText:"Enter your credentials to access Pixcode",children:s.jsxs("form",{onSubmit:d,className:"space-y-4",children:[s.jsx(To,{id:"username",label:e("login.username"),value:n.username,onChange:u=>c("username",u),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),s.jsx(To,{id:"password",label:e("login.password"),value:n.password,onChange:u=>c("password",u),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),s.jsx(C5,{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 n9={username:"",password:"",confirmPassword:""};function r9(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 a9(){const{register:e}=rl(),[t,n]=f.useState(n9),[r,a]=f.useState(""),[i,o]=f.useState(!1),l=f.useCallback((d,u)=>{n(p=>({...p,[d]:u}))},[]),c=f.useCallback(async d=>{d.preventDefault(),a("");const u=r9(t);if(u){a(u);return}o(!0);const p=await e(t.username.trim(),t.password);p.success||a(p.error),o(!1)},[t,e]);return s.jsx(T5,{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(To,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:i,autoComplete:"username"}),s.jsx(To,{id:"password",name:"password",label:"Password",value:t.password,onChange:d=>l("password",d),placeholder:"Enter your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(To,{id:"confirmPassword",name:"confirmPassword",label:"Confirm Password",value:t.confirmPassword,onChange:d=>l("confirmPassword",d),placeholder:"Confirm your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(C5,{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 i9({children:e}){const{user:t,isLoading:n,needsSetup:r,hasCompletedOnboarding:a,refreshOnboardingStatus:i}=rl();return n?s.jsx(QR,{}):r?s.jsx(a9,{}):t?a?s.jsx(s.Fragment,{children:e}):s.jsx(XR,{onComplete:i}):s.jsx(t9,{})}const A5=f.createContext(null),_5=()=>{const e=f.useContext(A5);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},s9=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},o9=()=>{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}=rl();f.useEffect(()=>(d(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[c]);const d=f.useCallback(()=>{if(!t.current)try{const h=s9(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||d()},3e3)},m.onerror=g=>{console.error("WebSocket error:",g)}}catch(h){console.error("Error creating WebSocket connection:",h)}},[c]),u=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:u,latestMessage:r,isConnected:i}),[u,r,i])},l9=({children:e})=>{const t=o9();return s.jsx(A5.Provider,{value:t,children:e})},j5=f.createContext(null);function c9(e,t){return{message:t instanceof Error?t.message:`Failed to ${e}`,context:e,timestamp:new Date().toISOString()}}function _y(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 d9(e){return e.find(t=>t.status==="pending"||t.status==="in-progress")??null}function u9(e){return e?.type?e.type.startsWith("taskmaster-"):!1}function Os(){const e=f.useContext(j5);if(!e)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return e}function p9({children:e}){const{latestMessage:t}=_5(),{user:n,token:r,isLoading:a}=rl(),[i,o]=f.useState([]),[l,c]=f.useState(null),[d,u]=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,T]=f.useState(null),N=f.useRef(null);f.useEffect(()=>{N.current=l?.name??null},[l?.name]);const j=f.useCallback(()=>{T(null)},[]),O=f.useCallback((B,W)=>{console.error(`TaskMaster ${B} error:`,W),T(c9(B,W))},[]),_=f.useCallback(B=>{const W=B?_y(B):null;c(W),u(W?.taskmaster??null),g([]),x(null)},[]),R=f.useCallback(async()=>{if(!n||!r){o([]),c(null),u(null),g([]),x(null);return}try{v(!0),j();const B=await Qe.get("/projects");if(!B.ok)throw new Error(`Failed to fetch projects: ${B.status}`);const W=await B.json(),L=(Array.isArray(W)?W:[]).map(P=>_y(P));o(L);const G=N.current;if(!G)return;const U=L.find(P=>P.name===G)??null;c(U),u(U?.taskmaster??null)}catch(B){O("load projects",B)}finally{v(!1)}},[j,O,r,n]),C=f.useCallback(async()=>{const B=l?.name;if(!B||!n||!r){g([]),x(null);return}try{S(!0),j();const W=await Qe.get(`/taskmaster/tasks/${encodeURIComponent(B)}`);if(!W.ok){const G=await W.json();throw new Error(G.message??"Failed to load tasks")}const H=await W.json(),L=Array.isArray(H.tasks)?H.tasks:[];g(L),x(d9(L))}catch(W){O("load tasks",W),g([]),x(null)}finally{S(!1)}},[j,l?.name,O,r,n]),F=f.useCallback(async()=>{if(!n||!r){h(null);return}try{k(!0),j();const B=await Qe.get("/mcp-utils/taskmaster-server");if(!B.ok)throw new Error(`Failed to load MCP status: ${B.status}`);const W=await B.json();h(W)}catch(B){O("check MCP server status",B),h(null)}finally{k(!1)}},[j,O,r,n]);f.useEffect(()=>{!a&&n&&r&&(R(),F())},[a,F,R,r,n]),f.useEffect(()=>{l?.name&&n&&r&&C()},[l?.name,C,r,n]),f.useEffect(()=>{const B=t;if(u9(B)){if(B.type==="taskmaster-project-updated"&&B.projectName){R();return}if(B.type==="taskmaster-tasks-updated"&&B.projectName===l?.name){C();return}B.type==="taskmaster-mcp-status-changed"&&F()}},[l?.name,t,F,R,C]);const K=f.useMemo(()=>({projects:i,currentProject:l,projectTaskMaster:d,mcpServerStatus:p,tasks:m,nextTask:b,isLoading:y,isLoadingTasks:w,isLoadingMCP:E,error:A,refreshProjects:R,setCurrentProject:_,refreshTasks:C,refreshMCPStatus:F,clearError:j}),[j,l,A,y,E,w,p,b,d,i,F,R,C,_,m]);return s.jsx(j5.Provider,{value:K,children:e})}const I5=f.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0}),ed=()=>{const e=f.useContext(I5);if(!e)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return e},m9=({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),[d,u]=f.useState(!0);f.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(t))},[t]),f.useEffect(()=>{setTimeout(async()=>{try{const g=await Qe.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{u(!1)}},0)},[]);const h={tasksEnabled:t,setTasksEnabled:n,toggleTasksEnabled:()=>{n(m=>!m)},isTaskMasterInstalled:r,isTaskMasterReady:i,installationStatus:l,isCheckingInstallation:d};return s.jsx(I5.Provider,{value:h,children:e})},R5=f.createContext(null);function td(){const e=f.useContext(R5);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function h9({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 ke("/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 ke("/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]),d=f.useCallback(async h=>{try{const m=await ke(`/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]),u=f.useCallback(async h=>{try{const m=await ke(`/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 ke(`/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(R5.Provider,{value:{plugins:t,loading:r,pluginsError:i,refreshPlugins:l,installPlugin:c,uninstallPlugin:d,updatePlugin:u,togglePlugin:p},children:e})}const jy=e=>typeof window>"u"?!1:window.innerWidth<e,Iy=()=>{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 b0(e={}){const{mobileBreakpoint:t=768,trackMobile:n=!0,trackPWA:r=!0}=e,[a,i]=f.useState(()=>n?jy(t):!1),[o,l]=f.useState(()=>r?Iy():!1);return f.useEffect(()=>{if(!n||typeof window>"u")return;const c=()=>{i(jy(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)"),d=()=>{l(Iy())};return d(),typeof c.addEventListener=="function"?(c.addEventListener("change",d),()=>{c.removeEventListener("change",d)}):(c.addListener(d),()=>{c.removeListener(d)})},[r]),{isMobile:a,isPWA:o}}const f9=(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},g9="1.33.11",D5=(e,t)=>{const[n,r]=f.useState(!1),[a,i]=f.useState(null),[o,l]=f.useState(null),[c,d]=f.useState("git"),[u,p]=f.useState("idle"),[h,m]=f.useState(null),[g,b]=f.useState(g9),x=f.useRef(null);f.useEffect(()=>{let v=!1;const w=async()=>{try{const k=await(await fetch("/health",{cache:"no-store"})).json();if(v)return;(k.installMode==="npm"||k.installMode==="git")&&d(k.installMode),typeof k.version=="string"&&/^\d+\.\d+\.\d+/.test(k.version)&&b(k.version)}catch{}};w();const S=()=>{w()};return window.addEventListener("focus",S),()=>{v=!0,window.removeEventListener("focus",S)}},[]),f.useEffect(()=>{if(!g)return;const v=async()=>{try{p("checking");const k=`?_=${Date.now()}`,T=await(await fetch(`https://api.github.com/repos/${e}/${t}/releases/latest${k}`,{cache:"no-store",headers:{Accept:"application/vnd.github+json"}})).json();if(T.tag_name){const N=T.tag_name.replace(/^v/,"");i(N),r(f9(N,g)>0),l({title:T.name||T.tag_name,body:T.body||"",htmlUrl:T.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:T.published_at}),p("success"),m(Date.now())}else r(!1),i(null),l(null),p("error")}catch(k){console.error("Version check failed:",k),r(!1),i(null),l(null),p("error")}};x.current=v,v();const w=setInterval(v,600*1e3),S=()=>{v()},E=()=>{document.visibilityState==="visible"&&v()};return window.addEventListener("focus",S),document.addEventListener("visibilitychange",E),()=>{clearInterval(w),window.removeEventListener("focus",S),document.removeEventListener("visibilitychange",E)}},[e,t,g]);const y=f.useCallback(async()=>{x.current&&await x.current()},[]);return{updateAvailable:n,latestVersion:a,currentVersion:g,releaseInfo:o,installMode:c,checkStatus:u,lastCheckedAt:h,manualCheck:y}},li={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0,historyView:"flat"},b9=["flat","grouped"],x9=e=>typeof e=="string"&&b9.includes(e),kc=Object.keys(li),y9=new Set(kc),Hd="ui-preferences:sync",v9=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},Sc=(e,t,n)=>e==="historyView"?x9(t)?t:n:v9(t,n),w9=(e,t)=>{try{const n=localStorage.getItem(e);if(n===null)return t;const r=JSON.parse(n);return Sc(e,r,t)}catch{return t}},k9=e=>{if(typeof window>"u")return li;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 kc.reduce((a,i)=>(a[i]=Sc(i,r[i],li[i]),a),{...li})}}}catch{}return kc.reduce((t,n)=>(t[n]=w9(n,li[n]),t),{...li})};function S9(e,t){switch(t.type){case"set":{const{key:n,value:r}=t;if(!y9.has(n))return e;const a=Sc(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 kc){if(!(i in n))continue;const o=n[i],l=Sc(i,o,e[i]);a[i]!==l&&(a[i]=l,r=!0)}return r?a:e}case"reset":return{...li,...t.value||{}};default:return e}}function x0(e="uiPreferences"){const t=f.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[n,r]=f.useReducer(S9,e,k9);return f.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(Hd,{detail:{storageKey:e,sourceId:t.current,value:n}})))},[n,e]),f.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||r({type:"set_many",value:u})},c=u=>{if(!(u.key!==e||u.newValue===null))try{const p=JSON.parse(u.newValue);l(p)}catch{}},d=u=>{const h=u.detail;!h||h.storageKey!==e||h.sourceId===t.current||l(h.value)};return window.addEventListener("storage",c),window.addEventListener(Hd,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(Hd,d)}},[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 E9=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},N9=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},C9=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},Ry=(e,t)=>`${e}::${t}`,T9=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},A9=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},_9=/(?:^|[\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,j9=e=>{if(!e)return[];const t=new Set,n=new RegExp(_9.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]},hi=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),I9=(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.__provider==="opencode"?e.summary||e.name||t("projects.newSession"):e.summary||t("projects.newSession"),R9=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),D9=(e,t,n)=>{const r=hi(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",isOpencodeSession:e.__provider==="opencode",isActive:a<10,sessionName:I9(e,n),sessionTime:R9(e),messageCount:Number(e.messageCount||0)}},O5=(e,t)=>{const n=[...e.sessions||[],...t[e.name]||[]].map(g=>({...g,__provider:"claude"})),r=(e.cursorSessions||[]).map(g=>({...g,__provider:"cursor"})),a=(e.codexSessions||[]).map(g=>({...g,__provider:"codex"})),i=g=>typeof g.id=="string"&&g.id.startsWith("qwen_")||g.provider==="qwen",o=g=>typeof g.id=="string"&&g.id.startsWith("opencode_")||g.provider==="opencode",l=e.geminiSessions||[],c=l.filter(g=>!i(g)&&!o(g)).map(g=>({...g,__provider:"gemini"})),d=l.filter(g=>i(g)).map(g=>({...g,__provider:"qwen"})),u=l.filter(g=>o(g)).map(g=>({...g,__provider:"opencode"})),p=[...(e.qwenSessions||[]).map(g=>({...g,__provider:"qwen"})),...d],h=[...(e.opencodeSessions||[]).map(g=>({...g,__provider:"opencode"})),...u],m=new Map;for(const g of[...n,...r,...a,...c,...p,...h])m.has(g.id)||m.set(g.id,g);return[...m.values()].sort((g,b)=>hi(b).getTime()-hi(g).getTime())},Dy=(e,t)=>{const n=O5(e,t);return n.length===0?new Date(0):n.reduce((r,a)=>{const i=hi(a);return i>r?i:r},new Date(0))},O9=(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"?Dy(o,r).getTime()-Dy(i,r).getTime():(i.displayName||i.name).localeCompare(o.displayName||o.name)}),a},L9=(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},M9=(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"},P9=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 F9({projects:e,selectedProject:t,selectedSession:n,isLoading:r,isMobile:a,t:i,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:d,onProjectDelete:u,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({}),[T,N]=f.useState({}),[j,O]=f.useState(new Set),[_,R]=f.useState(new Date),[C,F]=f.useState("name"),[K,B]=f.useState(!1),[W,H]=f.useState({}),[L,G]=f.useState(null),[U,P]=f.useState(""),[J,Z]=f.useState(""),[de,le]=f.useState(new Set),[ce,he]=f.useState(null),[ve,Ce]=f.useState(null),[Ae,Ge]=f.useState(!1),[M,pe]=f.useState(()=>N9()),[oe,Y]=f.useState(()=>T9()),[q,re]=f.useState("projects"),[be,me]=f.useState(null),[ie,ye]=f.useState(!1),[te,ne]=f.useState(null),X=f.useRef(null),se=f.useRef(0),xe=f.useRef(null),Me=!a&&!m;f.useEffect(()=>{const _e=setInterval(()=>{R(new Date)},6e4);return()=>clearInterval(_e)},[]),f.useEffect(()=>{N({}),O(new Set),H({})},[e]),f.useEffect(()=>{t&&b(_e=>{if(_e.has(t.name))return _e;const ge=new Set(_e);return ge.add(t.name),ge})},[n,t]),f.useEffect(()=>{if(e.length>0&&!r){const _e=new Set;e.forEach(ge=>{ge.sessions&&ge.sessions.length>=0&&_e.add(ge.name)}),O(_e)}},[e,r]),f.useEffect(()=>{const _e=()=>{F(E9())};_e();const ge=we=>{we.key==="claude-settings"&&_e()},Ie=()=>_e();return window.addEventListener("storage",ge),window.addEventListener("pixcode:settings-changed",Ie),()=>{window.removeEventListener("storage",ge),window.removeEventListener("pixcode:settings-changed",Ie)}},[]),f.useEffect(()=>{X.current&&clearTimeout(X.current),xe.current&&(xe.current.close(),xe.current=null);const _e=J.trim();if(q!=="conversations"||_e.length<2){se.current+=1,me(null),ne(null),ye(!1);return}ye(!0);const ge=++se.current;return X.current=setTimeout(()=>{if(ge!==se.current)return;const Ie=Qe.searchConversationsUrl(_e),we=new EventSource(Ie);xe.current=we;const Pe=[];let rt=0;we.addEventListener("result",_t=>{if(ge!==se.current){we.close();return}try{const Xe=JSON.parse(_t.data);Pe.push(Xe.projectResult),rt=Xe.totalMatches,me({results:[...Pe],totalMatches:rt,query:_e}),ne({scannedProjects:Xe.scannedProjects,totalProjects:Xe.totalProjects})}catch{}}),we.addEventListener("progress",_t=>{if(ge!==se.current){we.close();return}try{const Xe=JSON.parse(_t.data);rt=Xe.totalMatches,ne({scannedProjects:Xe.scannedProjects,totalProjects:Xe.totalProjects})}catch{}}),we.addEventListener("done",()=>{if(ge!==se.current){we.close();return}we.close(),xe.current=null,ye(!1),ne(null),Pe.length===0&&me({results:[],totalMatches:0,query:_e})}),we.addEventListener("error",()=>{if(ge!==se.current){we.close();return}we.close(),xe.current=null,ye(!1),ne(null),Pe.length===0&&me({results:[],totalMatches:0,query:_e})})},400),()=>{X.current&&clearTimeout(X.current),xe.current&&(xe.current.close(),xe.current=null)}},[J,q]),f.useCallback(_e=>ge=>{const Ie=ge.target;Ie.closest(".overflow-y-auto")||Ie.closest("[data-scroll-container]")||(ge.preventDefault(),ge.stopPropagation(),_e())},[]);const $e=f.useCallback(_e=>{b(ge=>{const Ie=new Set;return ge.has(_e)||Ie.add(_e),Ie})},[]),lt=f.useCallback((_e,ge)=>{c({..._e,__projectName:ge})},[c]),vt=f.useCallback(_e=>{pe(ge=>{const Ie=new Set(ge);return Ie.has(_e)?Ie.delete(_e):Ie.add(_e),C9(Ie),Ie})},[]),He=f.useCallback(_e=>M.has(_e),[M]),ut=f.useCallback((_e,ge)=>{Y(Ie=>{const we=Ry(_e,ge),Pe=new Set(Ie);return Pe.has(we)?Pe.delete(we):Pe.add(we),A9(Pe),Pe})},[]),Rt=f.useCallback((_e,ge)=>oe.has(Ry(_e,ge)),[oe]),Ye=f.useCallback(_e=>O5(_e,T),[T]),Dt=f.useMemo(()=>e.map(_e=>{const ge=W[_e.name];return ge===void 0?_e:{..._e,sessionMeta:{..._e.sessionMeta,hasMore:ge}}}),[W,e]),bt=f.useMemo(()=>O9(Dt,C,M,T),[T,C,Dt,M]),$n=f.useMemo(()=>L9(bt,J),[J,bt]),Un=f.useCallback(_e=>{y(_e.name),E(_e.displayName)},[]),pn=f.useCallback(()=>{y(null),E("")},[]),qt=f.useCallback(async _e=>{try{(await Qe.renameProject(_e,S)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(ge){console.error("Error renaming project:",ge)}finally{y(null),E("")}},[S]),Re=f.useCallback((_e,ge,Ie,we="claude")=>{Ce({projectName:_e,sessionId:ge,sessionTitle:Ie,provider:we})},[]),nt=f.useCallback(async()=>{if(!ve)return;const{projectName:_e,sessionId:ge,provider:Ie}=ve;Ce(null);try{let we;if(Ie==="codex"?we=await Qe.deleteCodexSession(ge):Ie==="gemini"?we=await Qe.deleteGeminiSession(ge):Ie==="qwen"?we=await Qe.deleteQwenSession(ge):we=await Qe.deleteSession(_e,ge),we.ok)d?.(ge);else{const Pe=await we.text();console.error("[Sidebar] Failed to delete session:",{status:we.status,error:Pe}),alert(i("messages.deleteSessionFailed"))}}catch(we){console.error("[Sidebar] Error deleting session:",we),alert(i("messages.deleteSessionError"))}},[d,ve,i]),Je=f.useCallback(_e=>{he({project:_e,sessionCount:Ye(_e).length})},[Ye]),mt=f.useCallback(async(_e=!1)=>{if(!ce)return;const{project:ge,sessionCount:Ie}=ce,we=Ie===0;he(null),le(Pe=>new Set([...Pe,ge.name]));try{const Pe=await Qe.deleteProject(ge.name,!we,_e);if(Pe.ok)u?.(ge.name);else{const rt=await Pe.json();alert(rt.error||i("messages.deleteProjectFailed"))}}catch(Pe){console.error("Error deleting project:",Pe),alert(i("messages.deleteProjectError"))}finally{le(Pe=>{const rt=new Set(Pe);return rt.delete(ge.name),rt})}},[ce,u,i]),wt=f.useCallback(async _e=>{const ge=W[_e.name];if(!(!(ge!==void 0?ge:_e.sessionMeta?.hasMore===!0)||k[_e.name])){A(we=>({...we,[_e.name]:!0}));try{const we=(_e.sessions?.length||0)+(T[_e.name]?.length||0),Pe=await Qe.sessions(_e.name,5,we);if(!Pe.ok)return;const rt=await Pe.json();N(_t=>({..._t,[_e.name]:[..._t[_e.name]||[],...rt.sessions||[]]})),rt.hasMore===!1&&H(_t=>({..._t,[_e.name]:!1}))}catch(we){console.error("Error loading more sessions:",we)}finally{A(we=>({...we,[_e.name]:!1}))}}},[T,k,W]),At=f.useCallback(_e=>{l(_e),p(_e)},[l,p]),or=f.useCallback(async()=>{B(!0);try{await o()}finally{B(!1)}},[o]),lr=f.useCallback(async(_e,ge,Ie,we)=>{const Pe=Ie.trim();if(!Pe){G(null),P("");return}try{const rt=await Qe.renameSession(ge,Pe,we);rt.ok?await o():(console.error("[Sidebar] Failed to rename session:",rt.status),alert(i("messages.renameSessionFailed")))}catch(rt){console.error("[Sidebar] Error renaming session:",rt),alert(i("messages.renameSessionError"))}finally{G(null),P("")}},[o,i]),cr=f.useCallback(()=>{h(!1)},[h]),ft=f.useCallback(()=>{h(!0)},[h]);return{isSidebarCollapsed:Me,expandedProjects:g,editingProject:x,showNewProject:v,editingName:S,loadingSessions:k,additionalSessions:T,initialSessionsLoaded:j,currentTime:_,projectSortOrder:C,isRefreshing:K,editingSession:L,editingSessionName:U,searchFilter:J,deletingProjects:de,deleteConfirmation:ce,sessionDeleteConfirmation:ve,showVersionModal:Ae,starredProjects:M,starredSessions:oe,filteredProjects:$n,toggleProject:$e,handleSessionClick:lt,toggleStarProject:vt,isProjectStarred:He,toggleStarSession:ut,isSessionStarred:Rt,getProjectSessions:Ye,startEditing:Un,cancelEditing:pn,saveProjectName:qt,showDeleteSessionConfirmation:Re,confirmDeleteSession:nt,requestProjectDelete:Je,confirmDeleteProject:mt,loadMoreSessions:wt,handleProjectSelect:At,refreshProjects:or,updateSessionSummary:lr,collapseSidebar:cr,expandSidebar:ft,setShowNewProject:w,setEditingName:E,setEditingSession:G,setEditingSessionName:P,searchMode:q,setSearchMode:re,conversationResults:be,isSearching:ie,searchProgress:te,clearConversationResults:f.useCallback(()=>{se.current+=1,xe.current&&(xe.current.close(),xe.current=null),ye(!1),ne(null),me(null)},[]),setSearchFilter:Z,setDeleteConfirmation:he,setSessionDeleteConfirmation:Ce,setShowVersionModal:Ge}}const z9="https://discord.gg/buxwujPNRE",B9="https://github.com/alicomert/pixcode/issues/new";function $9({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 U9({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(oI,{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(Et,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:B9,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(Pp,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:z9,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($9,{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(oa,{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 L5(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=L5(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function M5(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=L5(e))&&(r&&(r+=" "),r+=t);return r}const Oy=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ly=M5,y0=(e,t)=>n=>{var r;if(t?.variants==null)return Ly(e,n?.class,n?.className);const{variants:a,defaultVariants:i}=t,o=Object.keys(a).map(d=>{const u=n?.[d],p=i?.[d];if(u===null)return null;const h=Oy(u)||Oy(p);return a[d][h]}),l=n&&Object.entries(n).reduce((d,u)=>{let[p,h]=u;return h===void 0||(d[p]=h),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,u)=>{let{class:p,className:h,...m}=u;return Object.entries(m).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...i,...l}[b]):{...i,...l}[b]===x})?[...d,p,h]:d},[]);return Ly(e,o,c,n?.class,n?.className)},v0="-",G9=e=>{const t=q9(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(v0);return l[0]===""&&l.length!==1&&l.shift(),P5(l,t)||H9(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},P5=(e,t)=>{if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),a=r?P5(e.slice(1),r):void 0;if(a)return a;if(t.validators.length===0)return;const i=e.join(v0);return t.validators.find(({validator:o})=>o(i))?.classGroupId},My=/^\[(.+)\]$/,H9=e=>{if(My.test(e)){const t=My.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},q9=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const a in n)Gp(n[a],r,a,t);return r},Gp=(e,t,n,r)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?t:Py(t,a);i.classGroupId=n;return}if(typeof a=="function"){if(V9(a)){Gp(a(r),t,n,r);return}t.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([i,o])=>{Gp(o,Py(t,i),n,r)})})},Py=(e,t)=>{let n=e;return t.split(v0).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},V9=e=>e.isThemeGetter,W9=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)}}},Hp="!",qp=":",K9=qp.length,Y9=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=a=>{const i=[];let o=0,l=0,c=0,d;for(let g=0;g<a.length;g++){let b=a[g];if(o===0&&l===0){if(b===qp){i.push(a.slice(c,g)),c=g+K9;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=i.length===0?a:a.substring(c),p=Z9(u),h=p!==u,m=d&&d>c?d-c:void 0;return{modifiers:i,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:m}};if(t){const a=t+qp,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(Hp)?e.substring(0,e.length-1):e.startsWith(Hp)?e.substring(1):e,X9=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}},J9=e=>({cache:W9(e.cacheSize),parseClassName:Y9(e),sortModifiers:X9(e),...G9(e)}),Q9=/\s+/,eD=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=t,o=[],l=e.trim().split(Q9);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:h,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:b}=n(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,y=r(x?g.substring(0,b):g);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=r(g),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const v=i(h).join(":"),w=m?v+Hp: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=u+(c.length>0?" "+c:c)}return c};function tD(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=F5(t))&&(r&&(r+=" "),r+=n);return r}const F5=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=F5(e[r]))&&(n&&(n+=" "),n+=t);return n};function nD(e,...t){let n,r,a,i=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return n=J9(d),r=n.cache.get,a=n.cache.set,i=l,l(c)}function l(c){const d=r(c);if(d)return d;const u=eD(c,n);return a(c,u),u}return function(){return i(tD.apply(null,arguments))}}const en=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},z5=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,B5=/^\((?:(\w[\w-]*):)?(.+)\)$/i,rD=/^\d+\/\d+$/,aD=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,iD=/\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$/,sD=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,oD=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,lD=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Gi=e=>rD.test(e),at=e=>!!e&&!Number.isNaN(Number(e)),wa=e=>!!e&&Number.isInteger(Number(e)),qd=e=>e.endsWith("%")&&at(e.slice(0,-1)),Yr=e=>aD.test(e),cD=()=>!0,dD=e=>iD.test(e)&&!sD.test(e),$5=()=>!1,uD=e=>oD.test(e),pD=e=>lD.test(e),mD=e=>!ze(e)&&!Be(e),hD=e=>Ls(e,H5,$5),ze=e=>z5.test(e),ei=e=>Ls(e,q5,dD),Vd=e=>Ls(e,yD,at),Fy=e=>Ls(e,U5,$5),fD=e=>Ls(e,G5,pD),kl=e=>Ls(e,V5,uD),Be=e=>B5.test(e),no=e=>Ms(e,q5),gD=e=>Ms(e,vD),zy=e=>Ms(e,U5),bD=e=>Ms(e,H5),xD=e=>Ms(e,G5),Sl=e=>Ms(e,V5,!0),Ls=(e,t,n)=>{const r=z5.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ms=(e,t,n=!1)=>{const r=B5.exec(e);return r?r[1]?t(r[1]):n:!1},U5=e=>e==="position"||e==="percentage",G5=e=>e==="image"||e==="url",H5=e=>e==="length"||e==="size"||e==="bg-size",q5=e=>e==="length",yD=e=>e==="number",vD=e=>e==="family-name",V5=e=>e==="shadow",wD=()=>{const e=en("color"),t=en("font"),n=en("text"),r=en("font-weight"),a=en("tracking"),i=en("leading"),o=en("breakpoint"),l=en("container"),c=en("spacing"),d=en("radius"),u=en("shadow"),p=en("inset-shadow"),h=en("text-shadow"),m=en("drop-shadow"),g=en("blur"),b=en("perspective"),x=en("aspect"),y=en("ease"),v=en("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(),Be,ze],k=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],T=()=>[Be,ze,c],N=()=>[Gi,"full","auto",...T()],j=()=>[wa,"none","subgrid",Be,ze],O=()=>["auto",{span:["full",wa,Be,ze]},wa,Be,ze],_=()=>[wa,"auto",Be,ze],R=()=>["auto","min","max","fr",Be,ze],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],F=()=>["start","end","center","stretch","center-safe","end-safe"],K=()=>["auto",...T()],B=()=>[Gi,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],W=()=>[e,Be,ze],H=()=>[...S(),zy,Fy,{position:[Be,ze]}],L=()=>["no-repeat",{repeat:["","x","y","space","round"]}],G=()=>["auto","cover","contain",bD,hD,{size:[Be,ze]}],U=()=>[qd,no,ei],P=()=>["","none","full",d,Be,ze],J=()=>["",at,no,ei],Z=()=>["solid","dashed","dotted","double"],de=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>[at,qd,zy,Fy],ce=()=>["","none",g,Be,ze],he=()=>["none",at,Be,ze],ve=()=>["none",at,Be,ze],Ce=()=>[at,Be,ze],Ae=()=>[Gi,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Yr],breakpoint:[Yr],color:[cD],container:[Yr],"drop-shadow":[Yr],ease:["in","out","in-out"],font:[mD],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Yr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Yr],shadow:[Yr],spacing:["px",at],text:[Yr],"text-shadow":[Yr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Gi,ze,Be,x]}],container:["container"],columns:[{columns:[at,ze,Be,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:[wa,"auto",Be,ze]}],basis:[{basis:[Gi,"full","auto",l,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[at,Gi,"auto","initial","none",ze]}],grow:[{grow:["",at,Be,ze]}],shrink:[{shrink:["",at,Be,ze]}],order:[{order:[wa,"first","last","none",Be,ze]}],"grid-cols":[{"grid-cols":j()}],"col-start-end":[{col:O()}],"col-start":[{"col-start":_()}],"col-end":[{"col-end":_()}],"grid-rows":[{"grid-rows":j()}],"row-start-end":[{row:O()}],"row-start":[{"row-start":_()}],"row-end":[{"row-end":_()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...F(),"normal"]}],"justify-self":[{"justify-self":["auto",...F()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...F(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...F(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...F(),"baseline"]}],"place-self":[{"place-self":["auto",...F()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:K()}],mx:[{mx:K()}],my:[{my:K()}],ms:[{ms:K()}],me:[{me:K()}],mt:[{mt:K()}],mr:[{mr:K()}],mb:[{mb:K()}],ml:[{ml:K()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"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,no,ei]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Be,Vd]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",qd,ze]}],"font-family":[{font:[gD,ze,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,Be,ze]}],"line-clamp":[{"line-clamp":[at,"none",Be,Vd]}],leading:[{leading:[i,...T()]}],"list-image":[{"list-image":["none",Be,ze]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Be,ze]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:W()}],"text-color":[{text:W()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Z(),"wavy"]}],"text-decoration-thickness":[{decoration:[at,"from-font","auto",Be,ei]}],"text-decoration-color":[{decoration:W()}],"underline-offset":[{"underline-offset":[at,"auto",Be,ze]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Be,ze]}],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",Be,ze]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:L()}],"bg-size":[{bg:G()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},wa,Be,ze],radial:["",Be,ze],conic:[wa,Be,ze]},xD,fD]}],"bg-color":[{bg:W()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:W()}],"gradient-via":[{via:W()}],"gradient-to":[{to:W()}],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:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Z(),"hidden","none"]}],"divide-style":[{divide:[...Z(),"hidden","none"]}],"border-color":[{border:W()}],"border-color-x":[{"border-x":W()}],"border-color-y":[{"border-y":W()}],"border-color-s":[{"border-s":W()}],"border-color-e":[{"border-e":W()}],"border-color-t":[{"border-t":W()}],"border-color-r":[{"border-r":W()}],"border-color-b":[{"border-b":W()}],"border-color-l":[{"border-l":W()}],"divide-color":[{divide:W()}],"outline-style":[{outline:[...Z(),"none","hidden"]}],"outline-offset":[{"outline-offset":[at,Be,ze]}],"outline-w":[{outline:["",at,no,ei]}],"outline-color":[{outline:W()}],shadow:[{shadow:["","none",u,Sl,kl]}],"shadow-color":[{shadow:W()}],"inset-shadow":[{"inset-shadow":["none",p,Sl,kl]}],"inset-shadow-color":[{"inset-shadow":W()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:W()}],"ring-offset-w":[{"ring-offset":[at,ei]}],"ring-offset-color":[{"ring-offset":W()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":W()}],"text-shadow":[{"text-shadow":["none",h,Sl,kl]}],"text-shadow-color":[{"text-shadow":W()}],opacity:[{opacity:[at,Be,ze]}],"mix-blend":[{"mix-blend":[...de(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":de()}],"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":[at]}],"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":W()}],"mask-image-linear-to-color":[{"mask-linear-to":W()}],"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":W()}],"mask-image-t-to-color":[{"mask-t-to":W()}],"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":W()}],"mask-image-r-to-color":[{"mask-r-to":W()}],"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":W()}],"mask-image-b-to-color":[{"mask-b-to":W()}],"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":W()}],"mask-image-l-to-color":[{"mask-l-to":W()}],"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":W()}],"mask-image-x-to-color":[{"mask-x-to":W()}],"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":W()}],"mask-image-y-to-color":[{"mask-y-to":W()}],"mask-image-radial":[{"mask-radial":[Be,ze]}],"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":W()}],"mask-image-radial-to-color":[{"mask-radial-to":W()}],"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":[at]}],"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":W()}],"mask-image-conic-to-color":[{"mask-conic-to":W()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:L()}],"mask-size":[{mask:G()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Be,ze]}],filter:[{filter:["","none",Be,ze]}],blur:[{blur:ce()}],brightness:[{brightness:[at,Be,ze]}],contrast:[{contrast:[at,Be,ze]}],"drop-shadow":[{"drop-shadow":["","none",m,Sl,kl]}],"drop-shadow-color":[{"drop-shadow":W()}],grayscale:[{grayscale:["",at,Be,ze]}],"hue-rotate":[{"hue-rotate":[at,Be,ze]}],invert:[{invert:["",at,Be,ze]}],saturate:[{saturate:[at,Be,ze]}],sepia:[{sepia:["",at,Be,ze]}],"backdrop-filter":[{"backdrop-filter":["","none",Be,ze]}],"backdrop-blur":[{"backdrop-blur":ce()}],"backdrop-brightness":[{"backdrop-brightness":[at,Be,ze]}],"backdrop-contrast":[{"backdrop-contrast":[at,Be,ze]}],"backdrop-grayscale":[{"backdrop-grayscale":["",at,Be,ze]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[at,Be,ze]}],"backdrop-invert":[{"backdrop-invert":["",at,Be,ze]}],"backdrop-opacity":[{"backdrop-opacity":[at,Be,ze]}],"backdrop-saturate":[{"backdrop-saturate":[at,Be,ze]}],"backdrop-sepia":[{"backdrop-sepia":["",at,Be,ze]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Be,ze]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[at,"initial",Be,ze]}],ease:[{ease:["linear","initial",y,Be,ze]}],delay:[{delay:[at,Be,ze]}],animate:[{animate:["none",v,Be,ze]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Be,ze]}],"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:ve()}],"scale-x":[{"scale-x":ve()}],"scale-y":[{"scale-y":ve()}],"scale-z":[{"scale-z":ve()}],"scale-3d":["scale-3d"],skew:[{skew:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[Be,ze,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ae()}],"translate-x":[{"translate-x":Ae()}],"translate-y":[{"translate-y":Ae()}],"translate-z":[{"translate-z":Ae()}],"translate-none":["translate-none"],accent:[{accent:W()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:W()}],"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",Be,ze]}],"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":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"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",Be,ze]}],fill:[{fill:["none",...W()]}],"stroke-w":[{stroke:[at,no,ei,Vd]}],stroke:[{stroke:["none",...W()]}],"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"]}},kD=nD(wD);function fe(...e){return kD(M5(e))}function SD(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const ED=y0("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"}}),W5=f.forwardRef(({className:e,variant:t,...n},r)=>s.jsx("div",{ref:r,role:"alert","data-slot":"alert",className:fe(ED({variant:t}),e),...n}));W5.displayName="Alert";const ND=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}));ND.displayName="AlertTitle";const CD=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}));CD.displayName="AlertDescription";const TD=y0("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 ps({className:e,variant:t,...n}){return s.jsx("div",{className:fe(TD({variant:t}),e),...n})}const AD=y0("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"}}),Le=f.forwardRef(({className:e,variant:t,size:n,...r},a)=>s.jsx("button",{className:fe(AD({variant:t,size:n,className:e})),ref:a,...r}));Le.displayName="Button";const K5=f.createContext(null),Y5=()=>{const e=f.useContext(K5);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},Z5=({className:e,approval:t="pending",children:n,...r})=>{const a=f.useMemo(()=>({approval:t}),[t]);return s.jsx(K5.Provider,{value:a,children:s.jsx(W5,{className:fe("flex flex-col gap-2",e),...r,children:n})})};Z5.displayName="Confirmation";const X5=({className:e,...t})=>s.jsx("div",{"data-slot":"confirmation-title",className:fe("text-muted-foreground inline text-sm",e),...t});X5.displayName="ConfirmationTitle";const J5=({children:e})=>{const{approval:t}=Y5();return t!=="pending"?null:s.jsx(s.Fragment,{children:e})};J5.displayName="ConfirmationRequest";const Q5=({className:e,...t})=>{const{approval:n}=Y5();return n!=="pending"?null:s.jsx("div",{"data-slot":"confirmation-actions",className:fe("flex items-center justify-end gap-2 self-end",e),...t})};Q5.displayName="ConfirmationActions";const tc=({variant:e="default",...t})=>s.jsx(Le,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});tc.displayName="ConfirmationAction";const e4=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}));e4.displayName="Card";const t4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("flex flex-col space-y-1.5 p-4",e),...t}));t4.displayName="CardHeader";const n4=f.forwardRef(({className:e,...t},n)=>s.jsx("h3",{ref:n,className:fe("font-semibold leading-none tracking-tight",e),...t}));n4.displayName="CardTitle";const _D=f.forwardRef(({className:e,...t},n)=>s.jsx("p",{ref:n,className:fe("text-sm text-muted-foreground",e),...t}));_D.displayName="CardDescription";const r4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("p-4 pt-0",e),...t}));r4.displayName="CardContent";const a4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("flex items-center p-4 pt-0",e),...t}));a4.displayName="CardFooter";const jD=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("ml-auto shrink-0",e),...t}));jD.displayName="CardAction";const i4=f.createContext(null);function s4(){const e=f.useContext(i4);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const Ni=f.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:n,className:r,children:a,...i},o)=>{const[l,c]=f.useState(e),d=t!==void 0,u=d?t:l,p=f.useCallback(m=>{d||c(m),n?.(m)},[d,n]),h=f.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return s.jsx(i4.Provider,{value:h,children:s.jsx("div",{ref:o,"data-state":u?"open":"closed",className:r,...i,children:a})})});Ni.displayName="Collapsible";const Pa=f.forwardRef(({onClick:e,children:t,className:n,...r},a)=>{const{open:i,onOpenChange:o}=s4(),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})});Pa.displayName="CollapsibleTrigger";const Ci=f.forwardRef(({className:e,children:t,...n},r)=>{const{open:a}=s4();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})})});Ci.displayName="CollapsibleContent";const o4=f.createContext(null);function w0(){const e=f.useContext(o4);if(!e)throw new Error("Command components must be used within <Command>");return e}const l4=f.forwardRef(({className:e,children:t,...n},r)=>{const[a,i]=f.useState(""),o=f.useRef(new Map),[l,c]=f.useState(0),d=f.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),u=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(T=>T.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:d,unregister:u,updateEntry:p}),[a,h,g,d,u,p]);return s.jsx(o4.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})})});l4.displayName="Command";const c4=f.forwardRef(({className:e,placeholder:t="Search...",...n},r)=>{const{search:a,setSearch:i}=w0();return s.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[s.jsx(sa,{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})]})});c4.displayName="CommandInput";const d4=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}));d4.displayName="CommandList";const u4=f.forwardRef(({className:e,...t},n)=>{const{search:r,visibleIds:a}=w0();return!r||a.size>0?null:s.jsx("div",{ref:n,className:fe("py-6 text-center text-sm text-muted-foreground",e),...t})});u4.displayName="CommandEmpty";const p4=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]}));p4.displayName="CommandGroup";const m4=f.forwardRef(({className:e,value:t,onSelect:n,disabled:r,children:a,...i},o)=>{const{visibleIds:l,activeId:c,setActiveId:d,register:u,unregister:p,updateEntry:h}=w0(),m=f.useId(),g=f.useRef(null),b=t||(typeof a=="string"?a:"");f.useEffect(()=>(u({id:m,value:b.toLowerCase(),onSelect:n||(()=>{}),element:g.current}),()=>p(m)),[m,b,u,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&&d(m)},onClick:()=>!r&&n?.(),...i,children:a})});m4.displayName="CommandItem";const ID=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("-mx-1 h-px bg-border",e),...t}));ID.displayName="CommandSeparator";function Vp({checked:e,onToggle:t,ariaLabel:n="Toggle dark mode"}){const{isDarkMode:r,toggleDarkMode:a}=qa(),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(p0,{className:"h-3 w-3 text-primary"}):s.jsx(m0,{className:"h-3 w-3 text-white dark:text-background"})})]})}const h4=f.createContext(null);function f4(){const e=f.useContext(h4);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const g4=({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,d=f.useCallback(p=>{l||i(p),t?.(p)},[l,t]),u=f.useMemo(()=>({open:c,onOpenChange:d,triggerRef:o}),[c,d]);return s.jsx(h4.Provider,{value:u,children:r})},RD=f.forwardRef(({onClick:e,children:t,asChild:n,...r},a)=>{const{onOpenChange:i,triggerRef:o}=f4(),l=f.useCallback(c=>{i(!0),e?.(c)},[i,e]);if(n&&f.isValidElement(t)){const c=t;return f.cloneElement(c,{onClick:d=>{i(!0),c.props.onClick?.(d)},ref:d=>{o.current=d,typeof a=="function"?a(d):a&&(a.current=d)}})}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})});RD.displayName="DialogTrigger";const By='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',k0=f.forwardRef(({className:e,children:t,onEscapeKeyDown:n,onPointerDownOutside:r,...a},i)=>{const{open:o,onOpenChange:l,triggerRef:c}=f4(),d=f.useRef(null),u=f.useRef(null);return f.useEffect(()=>{o?u.current=document.activeElement:u.current&&((c.current||u.current)?.focus(),u.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"&&d.current){const g=Array.from(d.current.querySelectorAll(By));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&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(By)?.focus()})},[o]),o?Xc.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=>{d.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});k0.displayName="DialogContent";const S0=f.forwardRef(({className:e,...t},n)=>s.jsx("h2",{ref:n,className:fe("sr-only",e),...t}));S0.displayName="DialogTitle";const xt=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}));xt.displayName="Input";const E0=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})}));E0.displayName="ScrollArea";const Ec=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}));Ec.displayName="Shimmer";const b4=f.createContext(null),DD=()=>{const e=f.useContext(b4);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},OD=1e3,LD=1e3,Wp=f.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:r,onOpenChange:a,duration:i,children:o,...l})=>{const c=r??t,d=r===!1,[u,p]=f.useState(c),h=n!==void 0,m=h?n:u,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)/LD)),S.current=null)},[t]),f.useEffect(()=>{t&&!m&&!d&&g(!0)},[t,m,g,d]),f.useEffect(()=>{if(y.current&&!t&&m&&!v){const k=setTimeout(()=>{g(!1),w(!0)},OD);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(b4.Provider,{value:E,children:s.jsx(Ni,{open:m,onOpenChange:g,className:fe("not-prose",e),...l,children:o})})});Wp.displayName="Reasoning";const MD=(e,t)=>e||t===0?s.jsx(Ec,{children:"Thinking..."}):t===void 0?s.jsx("p",{children:"Thought for a few seconds"}):s.jsxs("p",{children:["Thought for ",t," seconds"]}),Kp=f.memo(({className:e,children:t,getThinkingMessage:n=MD,...r})=>{const{isStreaming:a,isOpen:i,duration:o}=DD();return s.jsx(Pa,{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(zI,{className:"h-4 w-4"}),n(a,o),s.jsx(YS,{className:fe("h-4 w-4 transition-transform",i?"rotate-180":"rotate-0")})]})})});Kp.displayName="ReasoningTrigger";const Yp=f.memo(({className:e,children:t,...n})=>s.jsx(Ci,{className:fe("mt-4 text-sm text-muted-foreground",e),...n,children:t}));Yp.displayName="ReasoningContent";function PD(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 ta({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),d=f.useRef(null),u=f.useRef(null),[p,h]=f.useState(null),m=f.useCallback(()=>{const w=d.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&&d.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:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:y,onTouchEnd:v,onTouchCancel:v,children:[e,i&&typeof document<"u"&&Xc.createPortal(s.jsxs("div",{ref:u,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",PD(n))})]}),document.body)]}):s.jsx(s.Fragment,{children:e})}const x4=f.createContext(null),y4=f.forwardRef(({className:e,status:t="ready",children:n,...r},a)=>{const i=f.useMemo(()=>({status:t}),[t]);return s.jsx(x4.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})})});y4.displayName="PromptInput";const v4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-header",className:fe("px-3 pt-3",e),...t}));v4.displayName="PromptInputHeader";const w4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-body",className:fe("relative",e),...t}));w4.displayName="PromptInputBody";const k4=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}));k4.displayName="PromptInputTextarea";const S4=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}));S4.displayName="PromptInputFooter";const E4=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}));E4.displayName="PromptInputTools";const nc=f.forwardRef(({className:e,tooltip:t,children:n,...r},a)=>{const i=s.jsx(Le,{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(ta,{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});nc.displayName="PromptInputButton";const N4=f.forwardRef(({className:e,status:t,children:n,...r},a)=>{const i=f.useContext(x4),o=t??i?.status??"ready",l=o==="submitted"||o==="streaming";return s.jsx(Le,{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(CI,{className:"h-3.5 w-3.5 fill-current"}):s.jsx(lI,{className:"h-4 w-4"}))})});N4.displayName="PromptInputSubmit";function N0({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 C0({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 C4=f.createContext(null);function T4(){const e=f.useContext(C4);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const A4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"queue",role:"list",className:fe("space-y-0.5",e),...t}));A4.displayName="Queue";const _4=f.forwardRef(({status:e="pending",className:t,children:n,...r},a)=>{const i=f.useMemo(()=>({status:e}),[e]);return s.jsx(C4.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})})});_4.displayName="QueueItem";const j4=f.forwardRef(({className:e,...t},n)=>{const{status:r}=T4();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})})]})});j4.displayName="QueueItemIndicator";const I4=f.forwardRef(({className:e,children:t,...n},r)=>{const{status:a}=T4();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})});I4.displayName="QueueItemContent";const $y="https://github.com/alicomert/pixcode/issues/new",FD="https://github.com/alicomert/pixcode",Uy="https://discord.gg/buxwujPNRE";function Gy({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 zD({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(gy,{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(gy,{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:$y,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(Pp,{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:Uy,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(Gy,{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(Et,{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:FD,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:$y,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(Pp,{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:Uy,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(Gy,{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(Et,{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 Hy="PIXCODE_GITHUB_STARS",qy="PIXCODE_HIDE_GITHUB_STAR",BD=3600*1e3,$D=(e,t)=>{const[n,r]=f.useState(null),[a,i]=f.useState(()=>{try{return localStorage.getItem(qy)==="true"}catch{return!1}});f.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(Hy);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<BD){r(u.count);return}}}catch{}(async()=>{try{const d=await fetch(`https://api.github.com/repos/${e}/${t}`);if(!d.ok)return;const p=(await d.json()).stargazers_count;if(typeof p=="number"){r(p);try{localStorage.setItem(Hy,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=f.useCallback(()=>{i(!0);try{localStorage.setItem(qy,"true")}catch{}},[]),l=n!==null?n>=1e3?`${(n/1e3).toFixed(1)}k`:`${n}`:null;return{starCount:n,formattedCount:l,isDismissed:a,dismiss:o}},UD="https://github.com/alicomert/pixcode";function GD({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 HD(){const{formattedCount:e,isDismissed:t,dismiss:n}=$D("alicomert","pixcode");return t?null:s.jsxs("div",{className:"group/star relative hidden md:block",children:[s.jsxs("a",{href:UD,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(GD,{className:"h-3.5 w-3.5"}),s.jsx(ds,{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(pt,{className:"h-2.5 w-2.5"})})]})}function Vy({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(Fo,{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(hI,{className:"h-3 w-3"}),n("historyView.grouped",{defaultValue:"By project"})]})]})}function qD({isPWA:e,isMobile:t,isLoading:n,projectsCount:r,searchFilter:a,onSearchFilterChange:i,onClearSearchFilter:o,searchMode:l,onSearchModeChange:c,onRefresh:d,isRefreshing:u,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(Le,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:d,disabled:u,title:x("tooltips.refresh"),children:s.jsx(yt,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),s.jsx(Le,{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(Jt,{className:"h-4 w-4"})}),s.jsx(Le,{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(sI,{className:"h-4 w-4"})})]})]}),s.jsx(HD,{}),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(oa,{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:[s.jsx(Vy,{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(Cr,{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(Si,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(sa,{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(xt,{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(pt,{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:d,disabled:u,children:s.jsx(yt,{className:`h-4 w-4 text-muted-foreground ${u?"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(ki,{className:"h-4 w-4"})})]})]}),r>0&&!n&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&s.jsx(Vy,{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(Cr,{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(Si,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(sa,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(xt,{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(pt,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider md:hidden"})]})}const VD=160,Wy=180;function R4({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 u=l.current.getBoundingClientRect();let p=u.right-VD;p<8&&(p=8);let h=u.bottom+4;h+Wy>window.innerHeight&&(h=Math.max(8,u.top-4-Wy)),o({top:h,left:p})},[r]),f.useEffect(()=>{if(!r)return;const u=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",u),document.addEventListener("keydown",p),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",p),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[r]);const d=u=>p=>{p.stopPropagation(),p.preventDefault(),a(!1),u.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:u=>{u.stopPropagation(),u.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(EI,{className:"h-3.5 w-3.5"})}),r&&i&&Xc.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:u=>u.stopPropagation(),onMouseDown:u=>u.stopPropagation(),children:e.map((u,p)=>{const h=u.icon,m=e[p-1],g=p>0&&u.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:d(u),className:fe("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs",u.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"}),u.label]})]},u.id)})}),document.body)]})}const Ky={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},WD={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},KD=e=>e==="fully-configured"?{icon:wi,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:Et,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:na,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:pt,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function YD({status:e="not-configured",size:t="sm",className:n="",showLabel:r=!1}){const a=KD(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:Ky[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,WD[t],n),title:a.title,children:s.jsx(i,{className:fe(Ky[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)),d=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`:d===1?n?n("time.oneDayAgo"):"1 day ago":d<7?n?n("time.daysAgo",{count:d}):`${d} days ago`:r.toLocaleDateString()};function Yy({isStarred:e,canDelete:t,onRename:n,onToggleStar:r,onDelete:a,t:i,className:o}){const l=d=>s.jsx(ds,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:i("actions.rename"),icon:bI,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(R4,{actions:c,className:o,triggerLabel:i("tooltips.sessionActions",{defaultValue:"Session actions"})})}const XD={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},Zy={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",opencode:"bg-teal-500/10 text-teal-600 dark:bg-teal-400/10 dark:text-teal-300 ring-1 ring-teal-500/15"};function D4({project:e,session:t,selectedSession:n,currentTime:r,editingSession:a,editingSessionName:i,isStarred:o,compact:l=!1,onEditingSessionNameChange:c,onStartEditingSession:d,onCancelEditingSession:u,onSaveEditingSession:p,onToggleStarSession:h,onProjectSelect:m,onSessionSelect:g,onDeleteSession:b,t:x}){const y=D9(t,r,x),v=n?.id===t.id,w=a===t.id,S=t.__provider,E=XD[S]??S,k=Zy[S]??Zy.claude,A=j9(y.sessionName),T=()=>{m(e),g(t,e.name)},N=()=>{p(e.name,t.id,i,S)},j=()=>{b(e.name,t.id,y.sessionName,S)},O=()=>d(t.id,y.sessionName),_=()=>h(e.name,t.id),R=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(Rn,{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))]}),C=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"&&u()},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(Ht,{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(),u()},title:x("tooltips.cancel"),children:s.jsx(pt,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),F=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:T,children:w?s.jsx("div",{className:"flex items-center gap-1",children:C}):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(Rn,{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})]}),R]}),s.jsx("div",{className:"flex-shrink-0",onClick:B=>B.stopPropagation(),children:s.jsx(Yy,{isStarred:o,canDelete:!y.isCursorSession,onRename:O,onToggleStar:_,onDelete:j,t:x,className:"!opacity-100"})})]})})}),K=s.jsxs("div",{className:fe("group/item relative hidden md:block"),children:[s.jsxs(Le,{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(Rn,{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:C}):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})]}),R]})})]})]}),!w&&s.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:B=>B.stopPropagation(),children:s.jsx(Yy,{isStarred:o,canDelete:!y.isCursorSession,onRename:O,onToggleStar:_,onDelete:j,t:x,className:"opacity-0 group-hover/item:opacity-100 focus-visible:opacity-100"})})]});return s.jsxs("div",{className:"group relative",children:[F,K]})}function JD(){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 QD({project:e,isExpanded:t,sessions:n,selectedSession:r,initialSessionsLoaded:a,isLoadingSessions:i,currentTime:o,editingSession:l,editingSessionName:c,isSessionStarred:d,onEditingSessionNameChange:u,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(Jt,{className:"h-3 w-3"}),S("sessions.newSession")]})}),s.jsxs(Le,{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(Jt,{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(D4,{project:e,session:A,selectedSession:r,currentTime:o,editingSession:l,editingSessionName:c,isStarred:d(e.name,A.id),onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:h,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:S},A.id)):s.jsx(JD,{}),E&&k&&s.jsx(Le,{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(Pn,{className:"h-3 w-3"}),S("sessions.showMore")]})})]})}const eO=(e,t)=>{const n=e.length;return t&&n>=5?`${n}+`:`${n}`};function tO({project:e,selectedProject:t,selectedSession:n,isExpanded:r,isDeleting:a,isStarred:i,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:d,isLoadingSessions:u,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:T,onDeleteProject:N,onSessionSelect:j,onDeleteSession:O,onLoadMoreSessions:_,onNewSession:R,onEditingSessionNameChange:C,onStartEditingSession:F,onCancelEditingSession:K,onSaveEditingSession:B,t:W}){const H=t?.name===e.name,L=o===e.name,G=e.sessionMeta?.hasMore===!0,U=eO(c,G),P=`${U} session${c.length===1?"":"s"}`,J=M9(e,b),Z=()=>v(e.name),de=()=>S(e.name),le=()=>{T(e.name)},ce=()=>{t?.name!==e.name&&w(e),Z()};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",H&&"bg-primary/5 border-primary/20",i&&!H&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:Z,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(ia,{className:"h-4 w-4 text-primary"}):s.jsx(Cr,{className:"h-4 w-4 text-muted-foreground"})}),s.jsx("div",{className:"min-w-0 flex-1",children:L?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:W("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(YD,{status:J,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:L?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(Ht,{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(pt,{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(),de()},title:W(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:s.jsx(ds,{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(Mp,{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(Pn,{className:"h-3 w-3 text-muted-foreground"}):s.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),s.jsxs(Le,{variant:"ghost",className:fe("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",H&&"bg-accent text-accent-foreground",i&&!H&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:ce,children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r?s.jsx(ia,{className:"h-4 w-4 flex-shrink-0 text-primary"}):s.jsx(Cr,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),s.jsx("div",{className:"min-w-0 flex-1 text-left",children:L?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:W("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:[U,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:L?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(Ht,{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(pt,{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(),de()},title:W("tooltips.removeFromFavorites"),children:s.jsx(ds,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),s.jsx(R4,{triggerLabel:W("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:W("actions.rename"),icon:Mp,onClick:()=>k(e)},{id:"star",label:W(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:ds,onClick:de},{id:"delete",label:W("actions.delete",{defaultValue:"Delete"}),icon:gn,onClick:()=>N(e),danger:!0}]}),r?s.jsx(Pn,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):s.jsx(Nr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),s.jsx(QD,{project:e,isExpanded:r,sessions:c,selectedSession:n,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:h,editingSessionName:m,isSessionStarred:x,onEditingSessionNameChange:C,onStartEditingSession:F,onCancelEditingSession:K,onSaveEditingSession:B,onToggleStarSession:E,onProjectSelect:w,onSessionSelect:j,onDeleteSession:O,onLoadMoreSessions:_,onNewSession:R,t:W})]})}function O4({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(Cr,{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(sa,{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 nO({projects:e,filteredProjects:t,selectedProject:n,selectedSession:r,isLoading:a,loadingProgress:i,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:d,initialSessionsLoaded:u,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:T,onStartEditingProject:N,onCancelEditingProject:j,onSaveProjectName:O,onDeleteProject:_,onSessionSelect:R,onDeleteSession:C,onLoadMoreSessions:F,onNewSession:K,onEditingSessionNameChange:B,onStartEditingSession:W,onCancelEditingSession:H,onSaveEditingSession:L,t:G}){const U=s.jsx(O4,{isLoading:a,loadingProgress:i,projectsCount:e.length,filteredProjectsCount:t.length,t:G});f.useEffect(()=>{let ce="Pixcode";const he=n?.displayName?.trim();he&&(ce=`${he} - ${ce}`),document.title=ce},[n]);const P=!a&&e.length>0&&t.length>0,J=ce=>ce.source==="history"||ce.autoDiscovered===!0&&ce.isManuallyAdded!==!0,Z=t.filter(ce=>!J(ce)),de=t.filter(ce=>J(ce)),le=ce=>s.jsx(tO,{project:ce,selectedProject:n,selectedSession:r,isExpanded:o.has(ce.name),isDeleting:g.has(ce.name),isStarred:v(ce.name),editingProject:l,editingName:c,sessions:y(ce),initialSessionsLoaded:u.has(ce.name),isLoadingSessions:!!d[ce.name],currentTime:p,editingSession:h,editingSessionName:m,tasksEnabled:b,mcpServerStatus:x,isSessionStarred:w,onEditingNameChange:S,onToggleProject:E,onProjectSelect:k,onToggleStarProject:A,onToggleStarSession:T,onStartEditingProject:N,onCancelEditingProject:j,onSaveProjectName:O,onDeleteProject:_,onSessionSelect:R,onDeleteSession:C,onLoadMoreSessions:F,onNewSession:K,onEditingSessionNameChange:B,onStartEditingSession:W,onCancelEditingSession:H,onSaveEditingSession:L,t:G},ce.name);return s.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:P?s.jsxs(s.Fragment,{children:[Z.map(ce=>le(ce)),de.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:G("projects.detectedFromHistory")}),de.map(ce=>le(ce))]})]}):U})}function Xr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function L4(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}/*!
229
+ `;function ER(){if(typeof document>"u"||document.getElementById(ky))return;const e=document.createElement("style");e.id=ky,e.type="text/css",e.innerText=SR,document.head.appendChild(e)}function NR({terminalContainerRef:e,terminalRef:t,fitAddonRef:n,wsRef:r,selectedProject:a,minimal:i,isRestarting:o,initialCommandRef:l,isPlainShellRef:c,authUrlRef:d,copyAuthUrlToClipboard:u,closeSocket:p}){const[h,m]=f.useState(!1),g=f.useRef(null),b=a?.fullPath||a?.path||"",x=!!a;f.useEffect(()=>{ER()},[]);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 vR.Terminal(cR);t.current=w;const S=new gR.FitAddon;n.current=S,w.loadAddon(S),i||w.loadAddon(new xR.WebLinksAddon);try{w.loadAddon(new yR.WebglAddon)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}w.open(e.current);const E=async()=>{const N=w.getSelection();return N?br(N):!1},k=N=>{if(!w.hasSelection())return;const j=w.getSelection();if(j){if(N.preventDefault(),N.clipboardData){N.clipboardData.setData("text/plain",j);return}br(j)}};e.current.addEventListener("copy",k),w.attachCustomKeyEventHandler(N=>{const j=k5(l.current)?v5:d.current;return N.type==="keydown"&&i&&c.current&&j&&!N.ctrlKey&&!N.metaKey&&!N.altKey&&N.key?.toLowerCase()==="c"?(N.preventDefault(),N.stopPropagation(),u(j),!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(O=>{ui(r.current,{type:"input",data:O})}).catch(()=>{}),!1):!0}),window.setTimeout(()=>{const N=n.current,j=t.current;!N||!j||(N.fit(),ui(r.current,{type:"resize",cols:j.cols,rows:j.rows}))},w5),m(!0);const A=w.onData(N=>{ui(r.current,{type:"input",data:N})}),T=new ResizeObserver(()=>{g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{const N=n.current,j=t.current;!N||!j||(N.fit(),ui(r.current,{type:"resize",cols:j.cols,rows:j.rows}))},rR)});return T.observe(e.current),()=>{e.current?.removeEventListener("copy",k),T.disconnect(),g.current!==null&&(window.clearTimeout(g.current),g.current=null),A.dispose(),p(),v()}},[d,p,u,v,n,l,c,o,i,x,b,e,t,r]),{isInitialized:h,clearTerminalScreen:y,disposeTerminal:v}}function CR({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:r,minimal:a,autoConnect:i,isRestarting:o,onProcessComplete:l,onOutputRef:c}){const d=f.useRef(null),u=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 T=f.useCallback(H=>{k.current=H,g(H),x(L=>L+1)},[]),N=f.useCallback(()=>{const H=h.current;H&&((H.readyState===WebSocket.OPEN||H.readyState===WebSocket.CONNECTING)&&H.close(),h.current=null)},[]),j=f.useCallback((H=k.current)=>{if(!H)return!1;const L=window.open(H,"_blank");if(L){try{L.opener=null}catch{}return!0}return!1},[]),O=f.useCallback(async(H=k.current)=>H?br(H):!1,[]),{isInitialized:_,clearTerminalScreen:R,disposeTerminal:C}=NR({terminalContainerRef:d,terminalRef:u,fitAddonRef:p,wsRef:h,selectedProject:e,minimal:a,isRestarting:o,initialCommandRef:w,isPlainShellRef:S,authUrlRef:k,copyAuthUrlToClipboard:O,closeSocket:N}),{isConnected:F,isConnecting:K,connectToShell:B,disconnectFromShell:W}=fR({wsRef:h,terminalRef:u,fitAddonRef:p,selectedProjectRef:y,selectedSessionRef:v,initialCommandRef:w,isPlainShellRef:S,onProcessCompleteRef:E,isInitialized:_,autoConnect:i,closeSocket:N,clearTerminalScreen:R,setAuthUrl:T,onOutputRef:c});return f.useEffect(()=>{o&&(W(),C())},[W,C,o]),f.useEffect(()=>{e||(W(),C())},[W,C,e]),f.useEffect(()=>{const H=t?.id??null;A.current!==H&&_&&W(),A.current=H},[W,_,t?.id]),{terminalContainerRef:d,terminalRef:u,wsRef:h,isConnected:F,isInitialized:_,isConnecting:K,authUrl:m,authUrlVersion:b,connectToShell:B,disconnectFromShell:W,openAuthUrlInBrowser:j,copyAuthUrlToClipboard:O}}function TR({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 AR({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 _R({isConnected:e,isInitialized:t,isRestarting:n,hasSession:r,sessionDisplayNameShort:a,onDisconnect:i,onRestart:o,statusNewSessionText:l,statusInitializingText:c,statusRestartingText:d,disconnectLabel:u,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:d})]}),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:u})]}),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 jR({terminalContainerRef:e,authUrl:t,authUrlVersion:n,initialCommand:r,isConnected:a,openAuthUrlInBrowser:i,copyAuthUrlToClipboard:o}){const[l,c]=f.useState("idle"),[d,u]=f.useState(!1),p=f.useMemo(()=>wR(r,t),[t,r]);f.useEffect(()=>{c("idle"),u(!1)},[n,p,a]);const h=!!p,m=h&&!d,g=h&&d;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:()=>u(!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:()=>u(!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 IR=[{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"}],RR={up:r5,down:i0,left:nI,right:s0},to=e=>e.preventDefault(),Sy="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",DR="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",Gd="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 Ey({wsRef:e,terminalRef:t,isConnected:n,bottomOffset:r="bottom-0"}){const{t:a}=De("settings"),[i,o]=f.useState(!1),[l,c]=f.useState(!1),d=f.useCallback(m=>{ui(e.current,{type:"input",data:m})},[e]),u=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&&d(m)}catch{}},[d]),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)),d(g)},[i,l,d]);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:to,onClick:()=>{p()},disabled:!n,className:Gd,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:s.jsx(c0,{className:"h-4 w-4"})}),IR.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:to,onClick:b,disabled:!n,className:g?DR:Sy,children:m.label},m.id)}if(m.type==="arrow"){const g=RR[m.icon];return s.jsx("button",{type:"button",onPointerDown:to,onClick:()=>d(m.sequence),disabled:!n,className:Gd,children:s.jsx(g,{className:"h-4 w-4"})},m.id)}return s.jsx("button",{type:"button",onPointerDown:to,onClick:()=>h(m.sequence),disabled:!n,className:Sy,children:m.label},m.id)}),s.jsx("button",{type:"button",onPointerDown:to,onClick:u,disabled:!n,className:Gd,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:s.jsx(rI,{className:"h-4 w-4"})})]})})}function S5({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}=De("chat"),[d,u]=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:T,openAuthUrlInBrowser:N,copyAuthUrlToClipboard:j}=CR({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:r,minimal:i,autoConnect:o,isRestarting:d,onProcessComplete:a,onOutputRef:g}),O=f.useCallback(()=>{const U=x.current;if(!U)return;const P=U.buffer.active,J=P.baseY+P.cursorY,Z=Math.min(P.baseY+P.length-1,J+10),de=Math.max(0,J-iR),le=[];for(let Ae=de;Ae<=Z;Ae++){const Ge=P.getLine(Ae);Ge&&le.push(Ge.translateToString().trimEnd())}let ce=-1;for(let Ae=le.length-1;Ae>=0;Ae--)if(/esc to cancel/i.test(le[Ae])||/enter to select/i.test(le[Ae])){ce=Ae;break}if(ce===-1){h(null);return}const he=new Map,ve=Math.max(0,ce-sR);for(let Ae=ce-1;Ae>=ve;Ae--){const Ge=le[Ae].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(Ge){const M=Ge[1],pe=Ge[2].trim();parseInt(M,10)<=oR&&pe.length>0&&!he.has(M)&&he.set(M,pe)}}const Ce=[];for(let Ae=1;Ae<=he.size&&he.has(String(Ae));Ae++)Ce.push({number:String(Ae),label:he.get(String(Ae))});h(Ce.length>=lR?Ce:null)},[x]),_=f.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(O,aR)},[O]);f.useEffect(()=>{g.current=_},[_]),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 U=()=>{x.current?.focus()},P=window.requestAnimationFrame(U),J=window.setTimeout(U,0);return()=>{window.cancelAnimationFrame(P),window.clearTimeout(J)}},[l,v,w,x]);const R=f.useCallback(U=>{ui(y.current,{type:"input",data:U})},[y]),C=f.useMemo(()=>kR(t),[t]),F=f.useMemo(()=>C?C.slice(0,30):null,[C]),K=f.useMemo(()=>C?C.slice(0,50):null,[C]),B=f.useCallback(()=>{u(!0),window.setTimeout(()=>{u(!1)},nR)},[]);if(!e)return s.jsx(AR,{title:c("shell.selectProject.title"),description:c("shell.selectProject.description")});if(i)return s.jsxs(s.Fragment,{children:[s.jsx(jR,{terminalContainerRef:b,authUrl:E,authUrlVersion:k,initialCommand:n,isConnected:v,openAuthUrlInBrowser:N,copyAuthUrlToClipboard:j}),s.jsx(Ey,{wsRef:y,terminalRef:x,isConnected:v,bottomOffset:"bottom-0"})]});const W=r?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:K}):c("shell.startSession"),H=r?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName}),L=w?S?"connecting":v?null:"connect":"loading",G=L==="connecting"?H:W;return s.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[s.jsx(_R,{isConnected:v,isInitialized:w,isRestarting:d,hasSession:!!t,sessionDisplayNameShort:F,onDisconnect:T,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:d||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"}}),L&&s.jsx(TR,{mode:L,description:G,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:U=>U.preventDefault(),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map(U=>s.jsxs("button",{type:"button",onClick:()=>{R(U.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:`${U.number}. ${U.label}`,children:[U.number,". ",U.label]},U.number)),s.jsx("button",{type:"button",onClick:()=>{R("\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(Ey,{wsRef:y,terminalRef:x,isConnected:v})]})}function OR({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 LR({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 E5({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:d="",showHeader:u=!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 ${d}`,children:[!h&&u&&c&&s.jsx(LR,{title:c,isCompleted:m,onClose:l}),s.jsx("div",{className:"min-h-0 w-full flex-1",children:s.jsx(S5,{selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:b,isActive:a,onProcessComplete:x,minimal:h,autoConnect:h?!0:i})})]}):s.jsx(OR,{className:d})}const MR=(e,t)=>t||(e==="claude"?"claude --dangerously-skip-permissions /login":e==="cursor"?"cursor-agent login":e==="codex"?"codex login":e==="qwen"?"qwen auth":e==="opencode"?"opencode auth login":"gemini"),PR={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."},opencode:{keyLabel:"Anthropic API Key (default backend)",keyExample:"sk-ant-...",supportsBaseUrl:!0,baseUrlExample:"https://api.anthropic.com",keyConsoleUrl:"https://console.anthropic.com/settings/keys",keyConsoleLabel:"Anthropic Console",notes:"OpenCode is multi-provider — this sets the Anthropic credentials. Switch providers via `opencode auth login` or opencode.json."}};function Ny({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 FR({provider:e}){const[t,n]=f.useState(""),[r,a]=f.useState(!1),[i,o]=f.useState("idle"),[l,c]=f.useState(null),d=async()=>{const u=t.trim();if(u){a(!0),c(null),o("idle");try{const p=await ke(`/api/providers/${e}/oauth-paste`,{method:"POST",body:JSON.stringify({callbackUrl:u})}),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:u=>n(u.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:u=>{u.key==="Enter"&&d()}}),s.jsx("button",{onClick:()=>void d(),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(cn,{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(Ht,{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 zR({provider:e,onSaved:t}){const n=PR[e],[r,a]=f.useState(""),[i,o]=f.useState(""),[l,c]=f.useState(!1),[d,u]=f.useState("idle"),[p,h]=f.useState(null);f.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await ke("/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),u("idle");try{const b=await ke(`/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})`);u("ok"),a(""),t()}catch(b){h(b?.message||"Save failed"),u("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(DI,{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(Mr,{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(cn,{className:"h-4 w-4 animate-spin"}):s.jsx(Ht,{className:"h-4 w-4"}),"Save API Key"]}),d==="ok"&&s.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved — reconnect to pick it up."}),d==="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 N5({isOpen:e,onClose:t,provider:n="claude",onComplete:r,customCommand:a,isAuthenticated:i=!1}){const{t:o}=De("common"),l=n!=="cursor",[c,d]=f.useState(l?"apiKey":"browser");f.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,n,l]);const u=f.useMemo(()=>`${wc[n]??n} Login`,[n]);if(!e)return null;const p=MR(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:u}),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(pt,{className:"h-6 w-6"})})]}),s.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[s.jsx(Ny,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&s.jsx(Ny,{active:c==="apiKey",onClick:()=>d("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(E5,{project:y6,command:p,onComplete:h,minimal:!0})}),s.jsx("div",{className:"border-t border-border/40 bg-background/50 px-4 py-3",children:s.jsx(FR,{provider:n})})]}):s.jsx(zR,{provider:n,onSaved:()=>h(0)})})]})})}const BR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),$R=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa();return s.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},UR=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa();return s.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},GR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),HR=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=qa(),n=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return s.jsx("img",{src:n,alt:"OpenCode",className:e})},qR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function Rn({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?s.jsx(UR,{className:t}):e==="codex"?s.jsx($R,{className:t}):e==="gemini"?s.jsx(GR,{className:t}):e==="qwen"?s.jsx(qR,{className:t}):e==="opencode"?s.jsx(HR,{className:t}):s.jsx(BR,{className:t})}function VR({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(Rn,{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(Ht,{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 WR=[{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 KR({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:WR.map(n=>s.jsx(VR,{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 YR({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(ir,{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(II,{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(_I,{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 Cy=[{title:"Git Configuration",icon:ir,required:!0},{title:"Connect Agents",icon:a5,required:!1}];function ZR({currentStep:e}){return s.jsx("div",{className:"mb-8",children:s.jsx("div",{className:"flex items-center justify-between",children:Cy.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(Ht,{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<Cy.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 Ty=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ay=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function XR({onComplete:e}){const[t,n]=f.useState(0),[r,a]=f.useState(""),[i,o]=f.useState(""),[l,c]=f.useState(!1),[d,u]=f.useState(""),[p,h]=f.useState(null),{providerAuthStatus:m,checkProviderAuthStatus:g,refreshProviderAuthStatuses:b}=g0(),x=f.useRef(void 0),y=f.useCallback(async()=>{try{const T=await ke("/api/user/git-config");if(!T.ok)return;const N=await T.json();N.gitName&&a(N.gitName),N.gitEmail&&o(N.gitEmail)}catch(T){console.error("Error loading git config:",T)}},[]);f.useEffect(()=>{y(),b()},[y,b]),f.useEffect(()=>{const T=x.current;x.current=p,T!=null&&p===null&&b()},[p,b]);const v=T=>{h(T)},w=T=>{T===0&&p&&g(p)},S=async()=>{if(u(""),t!==0){n(T=>T+1);return}if(!r.trim()||!i.trim()){u("Both git name and email are required.");return}if(!Ty.test(i)){u("Please enter a valid email address.");return}c(!0);try{const T=await ke("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:i})});if(!T.ok){const N=await Ay(T,"Failed to save git configuration");throw new Error(N)}n(N=>N+1)}catch(T){u(T instanceof Error?T.message:"Failed to save git configuration")}finally{c(!1)}},E=()=>{u(""),n(T=>T-1)},k=async()=>{c(!0),u("");try{const T=await ke("/api/user/complete-onboarding",{method:"POST"});if(!T.ok){const N=await Ay(T,"Failed to complete onboarding");throw new Error(N)}await e?.()}catch(T){u(T instanceof Error?T.message:"Failed to complete onboarding")}finally{c(!1)}},A=t===0?!!(r.trim()&&i.trim()&&Ty.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(YR,{gitName:r,gitEmail:i,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):s.jsx(KR,{providerStatuses:m,onOpenProviderLogin:v}),d&&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:d})}),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(o0,{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(cn,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:["Next",s.jsx(Nr,{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(cn,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ht,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&s.jsx(N5,{isOpen:!!p,onClose:()=>h(null),provider:p,onComplete:w})]})}const JR=["0s","0.1s","0.2s"];function QR(){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(Si,{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:JR.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 C5({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 To({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:d=>r(d.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 T5({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(Si,{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 e9={username:"",password:""};function t9(){const{t:e}=De("auth"),{login:t}=rl(),[n,r]=f.useState(e9),[a,i]=f.useState(""),[o,l]=f.useState(!1),c=f.useCallback((u,p)=>{r(h=>({...h,[u]:p}))},[]),d=f.useCallback(async u=>{if(u.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(T5,{title:e("login.title"),description:e("login.description"),footerText:"Enter your credentials to access Pixcode",children:s.jsxs("form",{onSubmit:d,className:"space-y-4",children:[s.jsx(To,{id:"username",label:e("login.username"),value:n.username,onChange:u=>c("username",u),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),s.jsx(To,{id:"password",label:e("login.password"),value:n.password,onChange:u=>c("password",u),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),s.jsx(C5,{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 n9={username:"",password:"",confirmPassword:""};function r9(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 a9(){const{register:e}=rl(),[t,n]=f.useState(n9),[r,a]=f.useState(""),[i,o]=f.useState(!1),l=f.useCallback((d,u)=>{n(p=>({...p,[d]:u}))},[]),c=f.useCallback(async d=>{d.preventDefault(),a("");const u=r9(t);if(u){a(u);return}o(!0);const p=await e(t.username.trim(),t.password);p.success||a(p.error),o(!1)},[t,e]);return s.jsx(T5,{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(To,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:i,autoComplete:"username"}),s.jsx(To,{id:"password",name:"password",label:"Password",value:t.password,onChange:d=>l("password",d),placeholder:"Enter your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(To,{id:"confirmPassword",name:"confirmPassword",label:"Confirm Password",value:t.confirmPassword,onChange:d=>l("confirmPassword",d),placeholder:"Confirm your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(C5,{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 i9({children:e}){const{user:t,isLoading:n,needsSetup:r,hasCompletedOnboarding:a,refreshOnboardingStatus:i}=rl();return n?s.jsx(QR,{}):r?s.jsx(a9,{}):t?a?s.jsx(s.Fragment,{children:e}):s.jsx(XR,{onComplete:i}):s.jsx(t9,{})}const A5=f.createContext(null),_5=()=>{const e=f.useContext(A5);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},s9=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},o9=()=>{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}=rl();f.useEffect(()=>(d(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[c]);const d=f.useCallback(()=>{if(!t.current)try{const h=s9(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||d()},3e3)},m.onerror=g=>{console.error("WebSocket error:",g)}}catch(h){console.error("Error creating WebSocket connection:",h)}},[c]),u=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:u,latestMessage:r,isConnected:i}),[u,r,i])},l9=({children:e})=>{const t=o9();return s.jsx(A5.Provider,{value:t,children:e})},j5=f.createContext(null);function c9(e,t){return{message:t instanceof Error?t.message:`Failed to ${e}`,context:e,timestamp:new Date().toISOString()}}function _y(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 d9(e){return e.find(t=>t.status==="pending"||t.status==="in-progress")??null}function u9(e){return e?.type?e.type.startsWith("taskmaster-"):!1}function Os(){const e=f.useContext(j5);if(!e)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return e}function p9({children:e}){const{latestMessage:t}=_5(),{user:n,token:r,isLoading:a}=rl(),[i,o]=f.useState([]),[l,c]=f.useState(null),[d,u]=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,T]=f.useState(null),N=f.useRef(null);f.useEffect(()=>{N.current=l?.name??null},[l?.name]);const j=f.useCallback(()=>{T(null)},[]),O=f.useCallback((B,W)=>{console.error(`TaskMaster ${B} error:`,W),T(c9(B,W))},[]),_=f.useCallback(B=>{const W=B?_y(B):null;c(W),u(W?.taskmaster??null),g([]),x(null)},[]),R=f.useCallback(async()=>{if(!n||!r){o([]),c(null),u(null),g([]),x(null);return}try{v(!0),j();const B=await Qe.get("/projects");if(!B.ok)throw new Error(`Failed to fetch projects: ${B.status}`);const W=await B.json(),L=(Array.isArray(W)?W:[]).map(P=>_y(P));o(L);const G=N.current;if(!G)return;const U=L.find(P=>P.name===G)??null;c(U),u(U?.taskmaster??null)}catch(B){O("load projects",B)}finally{v(!1)}},[j,O,r,n]),C=f.useCallback(async()=>{const B=l?.name;if(!B||!n||!r){g([]),x(null);return}try{S(!0),j();const W=await Qe.get(`/taskmaster/tasks/${encodeURIComponent(B)}`);if(!W.ok){const G=await W.json();throw new Error(G.message??"Failed to load tasks")}const H=await W.json(),L=Array.isArray(H.tasks)?H.tasks:[];g(L),x(d9(L))}catch(W){O("load tasks",W),g([]),x(null)}finally{S(!1)}},[j,l?.name,O,r,n]),F=f.useCallback(async()=>{if(!n||!r){h(null);return}try{k(!0),j();const B=await Qe.get("/mcp-utils/taskmaster-server");if(!B.ok)throw new Error(`Failed to load MCP status: ${B.status}`);const W=await B.json();h(W)}catch(B){O("check MCP server status",B),h(null)}finally{k(!1)}},[j,O,r,n]);f.useEffect(()=>{!a&&n&&r&&(R(),F())},[a,F,R,r,n]),f.useEffect(()=>{l?.name&&n&&r&&C()},[l?.name,C,r,n]),f.useEffect(()=>{const B=t;if(u9(B)){if(B.type==="taskmaster-project-updated"&&B.projectName){R();return}if(B.type==="taskmaster-tasks-updated"&&B.projectName===l?.name){C();return}B.type==="taskmaster-mcp-status-changed"&&F()}},[l?.name,t,F,R,C]);const K=f.useMemo(()=>({projects:i,currentProject:l,projectTaskMaster:d,mcpServerStatus:p,tasks:m,nextTask:b,isLoading:y,isLoadingTasks:w,isLoadingMCP:E,error:A,refreshProjects:R,setCurrentProject:_,refreshTasks:C,refreshMCPStatus:F,clearError:j}),[j,l,A,y,E,w,p,b,d,i,F,R,C,_,m]);return s.jsx(j5.Provider,{value:K,children:e})}const I5=f.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0}),ed=()=>{const e=f.useContext(I5);if(!e)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return e},m9=({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),[d,u]=f.useState(!0);f.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(t))},[t]),f.useEffect(()=>{setTimeout(async()=>{try{const g=await Qe.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{u(!1)}},0)},[]);const h={tasksEnabled:t,setTasksEnabled:n,toggleTasksEnabled:()=>{n(m=>!m)},isTaskMasterInstalled:r,isTaskMasterReady:i,installationStatus:l,isCheckingInstallation:d};return s.jsx(I5.Provider,{value:h,children:e})},R5=f.createContext(null);function td(){const e=f.useContext(R5);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function h9({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 ke("/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 ke("/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]),d=f.useCallback(async h=>{try{const m=await ke(`/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]),u=f.useCallback(async h=>{try{const m=await ke(`/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 ke(`/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(R5.Provider,{value:{plugins:t,loading:r,pluginsError:i,refreshPlugins:l,installPlugin:c,uninstallPlugin:d,updatePlugin:u,togglePlugin:p},children:e})}const jy=e=>typeof window>"u"?!1:window.innerWidth<e,Iy=()=>{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 b0(e={}){const{mobileBreakpoint:t=768,trackMobile:n=!0,trackPWA:r=!0}=e,[a,i]=f.useState(()=>n?jy(t):!1),[o,l]=f.useState(()=>r?Iy():!1);return f.useEffect(()=>{if(!n||typeof window>"u")return;const c=()=>{i(jy(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)"),d=()=>{l(Iy())};return d(),typeof c.addEventListener=="function"?(c.addEventListener("change",d),()=>{c.removeEventListener("change",d)}):(c.addListener(d),()=>{c.removeListener(d)})},[r]),{isMobile:a,isPWA:o}}const f9=(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},g9="1.34.0",D5=(e,t)=>{const[n,r]=f.useState(!1),[a,i]=f.useState(null),[o,l]=f.useState(null),[c,d]=f.useState("git"),[u,p]=f.useState("idle"),[h,m]=f.useState(null),[g,b]=f.useState(g9),x=f.useRef(null);f.useEffect(()=>{let v=!1;const w=async()=>{try{const k=await(await fetch("/health",{cache:"no-store"})).json();if(v)return;(k.installMode==="npm"||k.installMode==="git")&&d(k.installMode),typeof k.version=="string"&&/^\d+\.\d+\.\d+/.test(k.version)&&b(k.version)}catch{}};w();const S=()=>{w()};return window.addEventListener("focus",S),()=>{v=!0,window.removeEventListener("focus",S)}},[]),f.useEffect(()=>{if(!g)return;const v=async()=>{try{p("checking");const k=`?_=${Date.now()}`,T=await(await fetch(`https://api.github.com/repos/${e}/${t}/releases/latest${k}`,{cache:"no-store",headers:{Accept:"application/vnd.github+json"}})).json();if(T.tag_name){const N=T.tag_name.replace(/^v/,"");i(N),r(f9(N,g)>0),l({title:T.name||T.tag_name,body:T.body||"",htmlUrl:T.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:T.published_at}),p("success"),m(Date.now())}else r(!1),i(null),l(null),p("error")}catch(k){console.error("Version check failed:",k),r(!1),i(null),l(null),p("error")}};x.current=v,v();const w=setInterval(v,600*1e3),S=()=>{v()},E=()=>{document.visibilityState==="visible"&&v()};return window.addEventListener("focus",S),document.addEventListener("visibilitychange",E),()=>{clearInterval(w),window.removeEventListener("focus",S),document.removeEventListener("visibilitychange",E)}},[e,t,g]);const y=f.useCallback(async()=>{x.current&&await x.current()},[]);return{updateAvailable:n,latestVersion:a,currentVersion:g,releaseInfo:o,installMode:c,checkStatus:u,lastCheckedAt:h,manualCheck:y}},li={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0,historyView:"flat"},b9=["flat","grouped"],x9=e=>typeof e=="string"&&b9.includes(e),kc=Object.keys(li),y9=new Set(kc),Hd="ui-preferences:sync",v9=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},Sc=(e,t,n)=>e==="historyView"?x9(t)?t:n:v9(t,n),w9=(e,t)=>{try{const n=localStorage.getItem(e);if(n===null)return t;const r=JSON.parse(n);return Sc(e,r,t)}catch{return t}},k9=e=>{if(typeof window>"u")return li;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 kc.reduce((a,i)=>(a[i]=Sc(i,r[i],li[i]),a),{...li})}}}catch{}return kc.reduce((t,n)=>(t[n]=w9(n,li[n]),t),{...li})};function S9(e,t){switch(t.type){case"set":{const{key:n,value:r}=t;if(!y9.has(n))return e;const a=Sc(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 kc){if(!(i in n))continue;const o=n[i],l=Sc(i,o,e[i]);a[i]!==l&&(a[i]=l,r=!0)}return r?a:e}case"reset":return{...li,...t.value||{}};default:return e}}function x0(e="uiPreferences"){const t=f.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[n,r]=f.useReducer(S9,e,k9);return f.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(Hd,{detail:{storageKey:e,sourceId:t.current,value:n}})))},[n,e]),f.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||r({type:"set_many",value:u})},c=u=>{if(!(u.key!==e||u.newValue===null))try{const p=JSON.parse(u.newValue);l(p)}catch{}},d=u=>{const h=u.detail;!h||h.storageKey!==e||h.sourceId===t.current||l(h.value)};return window.addEventListener("storage",c),window.addEventListener(Hd,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(Hd,d)}},[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 E9=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},N9=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},C9=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},Ry=(e,t)=>`${e}::${t}`,T9=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},A9=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},_9=/(?:^|[\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,j9=e=>{if(!e)return[];const t=new Set,n=new RegExp(_9.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]},hi=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),I9=(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.__provider==="opencode"?e.summary||e.name||t("projects.newSession"):e.summary||t("projects.newSession"),R9=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),D9=(e,t,n)=>{const r=hi(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",isOpencodeSession:e.__provider==="opencode",isActive:a<10,sessionName:I9(e,n),sessionTime:R9(e),messageCount:Number(e.messageCount||0)}},O5=(e,t)=>{const n=[...e.sessions||[],...t[e.name]||[]].map(g=>({...g,__provider:"claude"})),r=(e.cursorSessions||[]).map(g=>({...g,__provider:"cursor"})),a=(e.codexSessions||[]).map(g=>({...g,__provider:"codex"})),i=g=>typeof g.id=="string"&&g.id.startsWith("qwen_")||g.provider==="qwen",o=g=>typeof g.id=="string"&&g.id.startsWith("opencode_")||g.provider==="opencode",l=e.geminiSessions||[],c=l.filter(g=>!i(g)&&!o(g)).map(g=>({...g,__provider:"gemini"})),d=l.filter(g=>i(g)).map(g=>({...g,__provider:"qwen"})),u=l.filter(g=>o(g)).map(g=>({...g,__provider:"opencode"})),p=[...(e.qwenSessions||[]).map(g=>({...g,__provider:"qwen"})),...d],h=[...(e.opencodeSessions||[]).map(g=>({...g,__provider:"opencode"})),...u],m=new Map;for(const g of[...n,...r,...a,...c,...p,...h])m.has(g.id)||m.set(g.id,g);return[...m.values()].sort((g,b)=>hi(b).getTime()-hi(g).getTime())},Dy=(e,t)=>{const n=O5(e,t);return n.length===0?new Date(0):n.reduce((r,a)=>{const i=hi(a);return i>r?i:r},new Date(0))},O9=(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"?Dy(o,r).getTime()-Dy(i,r).getTime():(i.displayName||i.name).localeCompare(o.displayName||o.name)}),a},L9=(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},M9=(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"},P9=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 F9({projects:e,selectedProject:t,selectedSession:n,isLoading:r,isMobile:a,t:i,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:d,onProjectDelete:u,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({}),[T,N]=f.useState({}),[j,O]=f.useState(new Set),[_,R]=f.useState(new Date),[C,F]=f.useState("name"),[K,B]=f.useState(!1),[W,H]=f.useState({}),[L,G]=f.useState(null),[U,P]=f.useState(""),[J,Z]=f.useState(""),[de,le]=f.useState(new Set),[ce,he]=f.useState(null),[ve,Ce]=f.useState(null),[Ae,Ge]=f.useState(!1),[M,pe]=f.useState(()=>N9()),[oe,Y]=f.useState(()=>T9()),[q,re]=f.useState("projects"),[be,me]=f.useState(null),[ie,ye]=f.useState(!1),[te,ne]=f.useState(null),X=f.useRef(null),se=f.useRef(0),xe=f.useRef(null),Me=!a&&!m;f.useEffect(()=>{const _e=setInterval(()=>{R(new Date)},6e4);return()=>clearInterval(_e)},[]),f.useEffect(()=>{N({}),O(new Set),H({})},[e]),f.useEffect(()=>{t&&b(_e=>{if(_e.has(t.name))return _e;const ge=new Set(_e);return ge.add(t.name),ge})},[n,t]),f.useEffect(()=>{if(e.length>0&&!r){const _e=new Set;e.forEach(ge=>{ge.sessions&&ge.sessions.length>=0&&_e.add(ge.name)}),O(_e)}},[e,r]),f.useEffect(()=>{const _e=()=>{F(E9())};_e();const ge=we=>{we.key==="claude-settings"&&_e()},Ie=()=>_e();return window.addEventListener("storage",ge),window.addEventListener("pixcode:settings-changed",Ie),()=>{window.removeEventListener("storage",ge),window.removeEventListener("pixcode:settings-changed",Ie)}},[]),f.useEffect(()=>{X.current&&clearTimeout(X.current),xe.current&&(xe.current.close(),xe.current=null);const _e=J.trim();if(q!=="conversations"||_e.length<2){se.current+=1,me(null),ne(null),ye(!1);return}ye(!0);const ge=++se.current;return X.current=setTimeout(()=>{if(ge!==se.current)return;const Ie=Qe.searchConversationsUrl(_e),we=new EventSource(Ie);xe.current=we;const Pe=[];let rt=0;we.addEventListener("result",_t=>{if(ge!==se.current){we.close();return}try{const Xe=JSON.parse(_t.data);Pe.push(Xe.projectResult),rt=Xe.totalMatches,me({results:[...Pe],totalMatches:rt,query:_e}),ne({scannedProjects:Xe.scannedProjects,totalProjects:Xe.totalProjects})}catch{}}),we.addEventListener("progress",_t=>{if(ge!==se.current){we.close();return}try{const Xe=JSON.parse(_t.data);rt=Xe.totalMatches,ne({scannedProjects:Xe.scannedProjects,totalProjects:Xe.totalProjects})}catch{}}),we.addEventListener("done",()=>{if(ge!==se.current){we.close();return}we.close(),xe.current=null,ye(!1),ne(null),Pe.length===0&&me({results:[],totalMatches:0,query:_e})}),we.addEventListener("error",()=>{if(ge!==se.current){we.close();return}we.close(),xe.current=null,ye(!1),ne(null),Pe.length===0&&me({results:[],totalMatches:0,query:_e})})},400),()=>{X.current&&clearTimeout(X.current),xe.current&&(xe.current.close(),xe.current=null)}},[J,q]),f.useCallback(_e=>ge=>{const Ie=ge.target;Ie.closest(".overflow-y-auto")||Ie.closest("[data-scroll-container]")||(ge.preventDefault(),ge.stopPropagation(),_e())},[]);const $e=f.useCallback(_e=>{b(ge=>{const Ie=new Set;return ge.has(_e)||Ie.add(_e),Ie})},[]),lt=f.useCallback((_e,ge)=>{c({..._e,__projectName:ge})},[c]),vt=f.useCallback(_e=>{pe(ge=>{const Ie=new Set(ge);return Ie.has(_e)?Ie.delete(_e):Ie.add(_e),C9(Ie),Ie})},[]),He=f.useCallback(_e=>M.has(_e),[M]),ut=f.useCallback((_e,ge)=>{Y(Ie=>{const we=Ry(_e,ge),Pe=new Set(Ie);return Pe.has(we)?Pe.delete(we):Pe.add(we),A9(Pe),Pe})},[]),Rt=f.useCallback((_e,ge)=>oe.has(Ry(_e,ge)),[oe]),Ye=f.useCallback(_e=>O5(_e,T),[T]),Dt=f.useMemo(()=>e.map(_e=>{const ge=W[_e.name];return ge===void 0?_e:{..._e,sessionMeta:{..._e.sessionMeta,hasMore:ge}}}),[W,e]),bt=f.useMemo(()=>O9(Dt,C,M,T),[T,C,Dt,M]),$n=f.useMemo(()=>L9(bt,J),[J,bt]),Un=f.useCallback(_e=>{y(_e.name),E(_e.displayName)},[]),pn=f.useCallback(()=>{y(null),E("")},[]),qt=f.useCallback(async _e=>{try{(await Qe.renameProject(_e,S)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(ge){console.error("Error renaming project:",ge)}finally{y(null),E("")}},[S]),Re=f.useCallback((_e,ge,Ie,we="claude")=>{Ce({projectName:_e,sessionId:ge,sessionTitle:Ie,provider:we})},[]),nt=f.useCallback(async()=>{if(!ve)return;const{projectName:_e,sessionId:ge,provider:Ie}=ve;Ce(null);try{let we;if(Ie==="codex"?we=await Qe.deleteCodexSession(ge):Ie==="gemini"?we=await Qe.deleteGeminiSession(ge):Ie==="qwen"?we=await Qe.deleteQwenSession(ge):we=await Qe.deleteSession(_e,ge),we.ok)d?.(ge);else{const Pe=await we.text();console.error("[Sidebar] Failed to delete session:",{status:we.status,error:Pe}),alert(i("messages.deleteSessionFailed"))}}catch(we){console.error("[Sidebar] Error deleting session:",we),alert(i("messages.deleteSessionError"))}},[d,ve,i]),Je=f.useCallback(_e=>{he({project:_e,sessionCount:Ye(_e).length})},[Ye]),mt=f.useCallback(async(_e=!1)=>{if(!ce)return;const{project:ge,sessionCount:Ie}=ce,we=Ie===0;he(null),le(Pe=>new Set([...Pe,ge.name]));try{const Pe=await Qe.deleteProject(ge.name,!we,_e);if(Pe.ok)u?.(ge.name);else{const rt=await Pe.json();alert(rt.error||i("messages.deleteProjectFailed"))}}catch(Pe){console.error("Error deleting project:",Pe),alert(i("messages.deleteProjectError"))}finally{le(Pe=>{const rt=new Set(Pe);return rt.delete(ge.name),rt})}},[ce,u,i]),wt=f.useCallback(async _e=>{const ge=W[_e.name];if(!(!(ge!==void 0?ge:_e.sessionMeta?.hasMore===!0)||k[_e.name])){A(we=>({...we,[_e.name]:!0}));try{const we=(_e.sessions?.length||0)+(T[_e.name]?.length||0),Pe=await Qe.sessions(_e.name,5,we);if(!Pe.ok)return;const rt=await Pe.json();N(_t=>({..._t,[_e.name]:[..._t[_e.name]||[],...rt.sessions||[]]})),rt.hasMore===!1&&H(_t=>({..._t,[_e.name]:!1}))}catch(we){console.error("Error loading more sessions:",we)}finally{A(we=>({...we,[_e.name]:!1}))}}},[T,k,W]),At=f.useCallback(_e=>{l(_e),p(_e)},[l,p]),or=f.useCallback(async()=>{B(!0);try{await o()}finally{B(!1)}},[o]),lr=f.useCallback(async(_e,ge,Ie,we)=>{const Pe=Ie.trim();if(!Pe){G(null),P("");return}try{const rt=await Qe.renameSession(ge,Pe,we);rt.ok?await o():(console.error("[Sidebar] Failed to rename session:",rt.status),alert(i("messages.renameSessionFailed")))}catch(rt){console.error("[Sidebar] Error renaming session:",rt),alert(i("messages.renameSessionError"))}finally{G(null),P("")}},[o,i]),cr=f.useCallback(()=>{h(!1)},[h]),ft=f.useCallback(()=>{h(!0)},[h]);return{isSidebarCollapsed:Me,expandedProjects:g,editingProject:x,showNewProject:v,editingName:S,loadingSessions:k,additionalSessions:T,initialSessionsLoaded:j,currentTime:_,projectSortOrder:C,isRefreshing:K,editingSession:L,editingSessionName:U,searchFilter:J,deletingProjects:de,deleteConfirmation:ce,sessionDeleteConfirmation:ve,showVersionModal:Ae,starredProjects:M,starredSessions:oe,filteredProjects:$n,toggleProject:$e,handleSessionClick:lt,toggleStarProject:vt,isProjectStarred:He,toggleStarSession:ut,isSessionStarred:Rt,getProjectSessions:Ye,startEditing:Un,cancelEditing:pn,saveProjectName:qt,showDeleteSessionConfirmation:Re,confirmDeleteSession:nt,requestProjectDelete:Je,confirmDeleteProject:mt,loadMoreSessions:wt,handleProjectSelect:At,refreshProjects:or,updateSessionSummary:lr,collapseSidebar:cr,expandSidebar:ft,setShowNewProject:w,setEditingName:E,setEditingSession:G,setEditingSessionName:P,searchMode:q,setSearchMode:re,conversationResults:be,isSearching:ie,searchProgress:te,clearConversationResults:f.useCallback(()=>{se.current+=1,xe.current&&(xe.current.close(),xe.current=null),ye(!1),ne(null),me(null)},[]),setSearchFilter:Z,setDeleteConfirmation:he,setSessionDeleteConfirmation:Ce,setShowVersionModal:Ge}}const z9="https://discord.gg/buxwujPNRE",B9="https://github.com/alicomert/pixcode/issues/new";function $9({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 U9({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(oI,{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(Et,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:B9,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(Pp,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:z9,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($9,{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(oa,{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 L5(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=L5(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function M5(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=L5(e))&&(r&&(r+=" "),r+=t);return r}const Oy=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ly=M5,y0=(e,t)=>n=>{var r;if(t?.variants==null)return Ly(e,n?.class,n?.className);const{variants:a,defaultVariants:i}=t,o=Object.keys(a).map(d=>{const u=n?.[d],p=i?.[d];if(u===null)return null;const h=Oy(u)||Oy(p);return a[d][h]}),l=n&&Object.entries(n).reduce((d,u)=>{let[p,h]=u;return h===void 0||(d[p]=h),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,u)=>{let{class:p,className:h,...m}=u;return Object.entries(m).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...i,...l}[b]):{...i,...l}[b]===x})?[...d,p,h]:d},[]);return Ly(e,o,c,n?.class,n?.className)},v0="-",G9=e=>{const t=q9(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(v0);return l[0]===""&&l.length!==1&&l.shift(),P5(l,t)||H9(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},P5=(e,t)=>{if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),a=r?P5(e.slice(1),r):void 0;if(a)return a;if(t.validators.length===0)return;const i=e.join(v0);return t.validators.find(({validator:o})=>o(i))?.classGroupId},My=/^\[(.+)\]$/,H9=e=>{if(My.test(e)){const t=My.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},q9=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const a in n)Gp(n[a],r,a,t);return r},Gp=(e,t,n,r)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?t:Py(t,a);i.classGroupId=n;return}if(typeof a=="function"){if(V9(a)){Gp(a(r),t,n,r);return}t.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([i,o])=>{Gp(o,Py(t,i),n,r)})})},Py=(e,t)=>{let n=e;return t.split(v0).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},V9=e=>e.isThemeGetter,W9=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)}}},Hp="!",qp=":",K9=qp.length,Y9=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=a=>{const i=[];let o=0,l=0,c=0,d;for(let g=0;g<a.length;g++){let b=a[g];if(o===0&&l===0){if(b===qp){i.push(a.slice(c,g)),c=g+K9;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=i.length===0?a:a.substring(c),p=Z9(u),h=p!==u,m=d&&d>c?d-c:void 0;return{modifiers:i,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:m}};if(t){const a=t+qp,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(Hp)?e.substring(0,e.length-1):e.startsWith(Hp)?e.substring(1):e,X9=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}},J9=e=>({cache:W9(e.cacheSize),parseClassName:Y9(e),sortModifiers:X9(e),...G9(e)}),Q9=/\s+/,eD=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=t,o=[],l=e.trim().split(Q9);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:h,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:b}=n(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,y=r(x?g.substring(0,b):g);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=r(g),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const v=i(h).join(":"),w=m?v+Hp: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=u+(c.length>0?" "+c:c)}return c};function tD(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=F5(t))&&(r&&(r+=" "),r+=n);return r}const F5=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=F5(e[r]))&&(n&&(n+=" "),n+=t);return n};function nD(e,...t){let n,r,a,i=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return n=J9(d),r=n.cache.get,a=n.cache.set,i=l,l(c)}function l(c){const d=r(c);if(d)return d;const u=eD(c,n);return a(c,u),u}return function(){return i(tD.apply(null,arguments))}}const en=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},z5=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,B5=/^\((?:(\w[\w-]*):)?(.+)\)$/i,rD=/^\d+\/\d+$/,aD=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,iD=/\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$/,sD=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,oD=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,lD=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Gi=e=>rD.test(e),at=e=>!!e&&!Number.isNaN(Number(e)),wa=e=>!!e&&Number.isInteger(Number(e)),qd=e=>e.endsWith("%")&&at(e.slice(0,-1)),Yr=e=>aD.test(e),cD=()=>!0,dD=e=>iD.test(e)&&!sD.test(e),$5=()=>!1,uD=e=>oD.test(e),pD=e=>lD.test(e),mD=e=>!ze(e)&&!Be(e),hD=e=>Ls(e,H5,$5),ze=e=>z5.test(e),ei=e=>Ls(e,q5,dD),Vd=e=>Ls(e,yD,at),Fy=e=>Ls(e,U5,$5),fD=e=>Ls(e,G5,pD),kl=e=>Ls(e,V5,uD),Be=e=>B5.test(e),no=e=>Ms(e,q5),gD=e=>Ms(e,vD),zy=e=>Ms(e,U5),bD=e=>Ms(e,H5),xD=e=>Ms(e,G5),Sl=e=>Ms(e,V5,!0),Ls=(e,t,n)=>{const r=z5.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ms=(e,t,n=!1)=>{const r=B5.exec(e);return r?r[1]?t(r[1]):n:!1},U5=e=>e==="position"||e==="percentage",G5=e=>e==="image"||e==="url",H5=e=>e==="length"||e==="size"||e==="bg-size",q5=e=>e==="length",yD=e=>e==="number",vD=e=>e==="family-name",V5=e=>e==="shadow",wD=()=>{const e=en("color"),t=en("font"),n=en("text"),r=en("font-weight"),a=en("tracking"),i=en("leading"),o=en("breakpoint"),l=en("container"),c=en("spacing"),d=en("radius"),u=en("shadow"),p=en("inset-shadow"),h=en("text-shadow"),m=en("drop-shadow"),g=en("blur"),b=en("perspective"),x=en("aspect"),y=en("ease"),v=en("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(),Be,ze],k=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],T=()=>[Be,ze,c],N=()=>[Gi,"full","auto",...T()],j=()=>[wa,"none","subgrid",Be,ze],O=()=>["auto",{span:["full",wa,Be,ze]},wa,Be,ze],_=()=>[wa,"auto",Be,ze],R=()=>["auto","min","max","fr",Be,ze],C=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],F=()=>["start","end","center","stretch","center-safe","end-safe"],K=()=>["auto",...T()],B=()=>[Gi,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],W=()=>[e,Be,ze],H=()=>[...S(),zy,Fy,{position:[Be,ze]}],L=()=>["no-repeat",{repeat:["","x","y","space","round"]}],G=()=>["auto","cover","contain",bD,hD,{size:[Be,ze]}],U=()=>[qd,no,ei],P=()=>["","none","full",d,Be,ze],J=()=>["",at,no,ei],Z=()=>["solid","dashed","dotted","double"],de=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>[at,qd,zy,Fy],ce=()=>["","none",g,Be,ze],he=()=>["none",at,Be,ze],ve=()=>["none",at,Be,ze],Ce=()=>[at,Be,ze],Ae=()=>[Gi,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Yr],breakpoint:[Yr],color:[cD],container:[Yr],"drop-shadow":[Yr],ease:["in","out","in-out"],font:[mD],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Yr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Yr],shadow:[Yr],spacing:["px",at],text:[Yr],"text-shadow":[Yr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Gi,ze,Be,x]}],container:["container"],columns:[{columns:[at,ze,Be,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:[wa,"auto",Be,ze]}],basis:[{basis:[Gi,"full","auto",l,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[at,Gi,"auto","initial","none",ze]}],grow:[{grow:["",at,Be,ze]}],shrink:[{shrink:["",at,Be,ze]}],order:[{order:[wa,"first","last","none",Be,ze]}],"grid-cols":[{"grid-cols":j()}],"col-start-end":[{col:O()}],"col-start":[{"col-start":_()}],"col-end":[{"col-end":_()}],"grid-rows":[{"grid-rows":j()}],"row-start-end":[{row:O()}],"row-start":[{"row-start":_()}],"row-end":[{"row-end":_()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...C(),"normal"]}],"justify-items":[{"justify-items":[...F(),"normal"]}],"justify-self":[{"justify-self":["auto",...F()]}],"align-content":[{content:["normal",...C()]}],"align-items":[{items:[...F(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...F(),{baseline:["","last"]}]}],"place-content":[{"place-content":C()}],"place-items":[{"place-items":[...F(),"baseline"]}],"place-self":[{"place-self":["auto",...F()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:K()}],mx:[{mx:K()}],my:[{my:K()}],ms:[{ms:K()}],me:[{me:K()}],mt:[{mt:K()}],mr:[{mr:K()}],mb:[{mb:K()}],ml:[{ml:K()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"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,no,ei]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Be,Vd]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",qd,ze]}],"font-family":[{font:[gD,ze,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,Be,ze]}],"line-clamp":[{"line-clamp":[at,"none",Be,Vd]}],leading:[{leading:[i,...T()]}],"list-image":[{"list-image":["none",Be,ze]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Be,ze]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:W()}],"text-color":[{text:W()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Z(),"wavy"]}],"text-decoration-thickness":[{decoration:[at,"from-font","auto",Be,ei]}],"text-decoration-color":[{decoration:W()}],"underline-offset":[{"underline-offset":[at,"auto",Be,ze]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Be,ze]}],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",Be,ze]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:L()}],"bg-size":[{bg:G()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},wa,Be,ze],radial:["",Be,ze],conic:[wa,Be,ze]},xD,fD]}],"bg-color":[{bg:W()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:W()}],"gradient-via":[{via:W()}],"gradient-to":[{to:W()}],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:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Z(),"hidden","none"]}],"divide-style":[{divide:[...Z(),"hidden","none"]}],"border-color":[{border:W()}],"border-color-x":[{"border-x":W()}],"border-color-y":[{"border-y":W()}],"border-color-s":[{"border-s":W()}],"border-color-e":[{"border-e":W()}],"border-color-t":[{"border-t":W()}],"border-color-r":[{"border-r":W()}],"border-color-b":[{"border-b":W()}],"border-color-l":[{"border-l":W()}],"divide-color":[{divide:W()}],"outline-style":[{outline:[...Z(),"none","hidden"]}],"outline-offset":[{"outline-offset":[at,Be,ze]}],"outline-w":[{outline:["",at,no,ei]}],"outline-color":[{outline:W()}],shadow:[{shadow:["","none",u,Sl,kl]}],"shadow-color":[{shadow:W()}],"inset-shadow":[{"inset-shadow":["none",p,Sl,kl]}],"inset-shadow-color":[{"inset-shadow":W()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:W()}],"ring-offset-w":[{"ring-offset":[at,ei]}],"ring-offset-color":[{"ring-offset":W()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":W()}],"text-shadow":[{"text-shadow":["none",h,Sl,kl]}],"text-shadow-color":[{"text-shadow":W()}],opacity:[{opacity:[at,Be,ze]}],"mix-blend":[{"mix-blend":[...de(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":de()}],"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":[at]}],"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":W()}],"mask-image-linear-to-color":[{"mask-linear-to":W()}],"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":W()}],"mask-image-t-to-color":[{"mask-t-to":W()}],"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":W()}],"mask-image-r-to-color":[{"mask-r-to":W()}],"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":W()}],"mask-image-b-to-color":[{"mask-b-to":W()}],"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":W()}],"mask-image-l-to-color":[{"mask-l-to":W()}],"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":W()}],"mask-image-x-to-color":[{"mask-x-to":W()}],"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":W()}],"mask-image-y-to-color":[{"mask-y-to":W()}],"mask-image-radial":[{"mask-radial":[Be,ze]}],"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":W()}],"mask-image-radial-to-color":[{"mask-radial-to":W()}],"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":[at]}],"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":W()}],"mask-image-conic-to-color":[{"mask-conic-to":W()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:L()}],"mask-size":[{mask:G()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Be,ze]}],filter:[{filter:["","none",Be,ze]}],blur:[{blur:ce()}],brightness:[{brightness:[at,Be,ze]}],contrast:[{contrast:[at,Be,ze]}],"drop-shadow":[{"drop-shadow":["","none",m,Sl,kl]}],"drop-shadow-color":[{"drop-shadow":W()}],grayscale:[{grayscale:["",at,Be,ze]}],"hue-rotate":[{"hue-rotate":[at,Be,ze]}],invert:[{invert:["",at,Be,ze]}],saturate:[{saturate:[at,Be,ze]}],sepia:[{sepia:["",at,Be,ze]}],"backdrop-filter":[{"backdrop-filter":["","none",Be,ze]}],"backdrop-blur":[{"backdrop-blur":ce()}],"backdrop-brightness":[{"backdrop-brightness":[at,Be,ze]}],"backdrop-contrast":[{"backdrop-contrast":[at,Be,ze]}],"backdrop-grayscale":[{"backdrop-grayscale":["",at,Be,ze]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[at,Be,ze]}],"backdrop-invert":[{"backdrop-invert":["",at,Be,ze]}],"backdrop-opacity":[{"backdrop-opacity":[at,Be,ze]}],"backdrop-saturate":[{"backdrop-saturate":[at,Be,ze]}],"backdrop-sepia":[{"backdrop-sepia":["",at,Be,ze]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Be,ze]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[at,"initial",Be,ze]}],ease:[{ease:["linear","initial",y,Be,ze]}],delay:[{delay:[at,Be,ze]}],animate:[{animate:["none",v,Be,ze]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Be,ze]}],"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:ve()}],"scale-x":[{"scale-x":ve()}],"scale-y":[{"scale-y":ve()}],"scale-z":[{"scale-z":ve()}],"scale-3d":["scale-3d"],skew:[{skew:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[Be,ze,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ae()}],"translate-x":[{"translate-x":Ae()}],"translate-y":[{"translate-y":Ae()}],"translate-z":[{"translate-z":Ae()}],"translate-none":["translate-none"],accent:[{accent:W()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:W()}],"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",Be,ze]}],"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":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"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",Be,ze]}],fill:[{fill:["none",...W()]}],"stroke-w":[{stroke:[at,no,ei,Vd]}],stroke:[{stroke:["none",...W()]}],"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"]}},kD=nD(wD);function fe(...e){return kD(M5(e))}function SD(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const ED=y0("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"}}),W5=f.forwardRef(({className:e,variant:t,...n},r)=>s.jsx("div",{ref:r,role:"alert","data-slot":"alert",className:fe(ED({variant:t}),e),...n}));W5.displayName="Alert";const ND=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}));ND.displayName="AlertTitle";const CD=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}));CD.displayName="AlertDescription";const TD=y0("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 ps({className:e,variant:t,...n}){return s.jsx("div",{className:fe(TD({variant:t}),e),...n})}const AD=y0("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"}}),Le=f.forwardRef(({className:e,variant:t,size:n,...r},a)=>s.jsx("button",{className:fe(AD({variant:t,size:n,className:e})),ref:a,...r}));Le.displayName="Button";const K5=f.createContext(null),Y5=()=>{const e=f.useContext(K5);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},Z5=({className:e,approval:t="pending",children:n,...r})=>{const a=f.useMemo(()=>({approval:t}),[t]);return s.jsx(K5.Provider,{value:a,children:s.jsx(W5,{className:fe("flex flex-col gap-2",e),...r,children:n})})};Z5.displayName="Confirmation";const X5=({className:e,...t})=>s.jsx("div",{"data-slot":"confirmation-title",className:fe("text-muted-foreground inline text-sm",e),...t});X5.displayName="ConfirmationTitle";const J5=({children:e})=>{const{approval:t}=Y5();return t!=="pending"?null:s.jsx(s.Fragment,{children:e})};J5.displayName="ConfirmationRequest";const Q5=({className:e,...t})=>{const{approval:n}=Y5();return n!=="pending"?null:s.jsx("div",{"data-slot":"confirmation-actions",className:fe("flex items-center justify-end gap-2 self-end",e),...t})};Q5.displayName="ConfirmationActions";const tc=({variant:e="default",...t})=>s.jsx(Le,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});tc.displayName="ConfirmationAction";const e4=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}));e4.displayName="Card";const t4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("flex flex-col space-y-1.5 p-4",e),...t}));t4.displayName="CardHeader";const n4=f.forwardRef(({className:e,...t},n)=>s.jsx("h3",{ref:n,className:fe("font-semibold leading-none tracking-tight",e),...t}));n4.displayName="CardTitle";const _D=f.forwardRef(({className:e,...t},n)=>s.jsx("p",{ref:n,className:fe("text-sm text-muted-foreground",e),...t}));_D.displayName="CardDescription";const r4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("p-4 pt-0",e),...t}));r4.displayName="CardContent";const a4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("flex items-center p-4 pt-0",e),...t}));a4.displayName="CardFooter";const jD=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("ml-auto shrink-0",e),...t}));jD.displayName="CardAction";const i4=f.createContext(null);function s4(){const e=f.useContext(i4);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const Ni=f.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:n,className:r,children:a,...i},o)=>{const[l,c]=f.useState(e),d=t!==void 0,u=d?t:l,p=f.useCallback(m=>{d||c(m),n?.(m)},[d,n]),h=f.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return s.jsx(i4.Provider,{value:h,children:s.jsx("div",{ref:o,"data-state":u?"open":"closed",className:r,...i,children:a})})});Ni.displayName="Collapsible";const Pa=f.forwardRef(({onClick:e,children:t,className:n,...r},a)=>{const{open:i,onOpenChange:o}=s4(),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})});Pa.displayName="CollapsibleTrigger";const Ci=f.forwardRef(({className:e,children:t,...n},r)=>{const{open:a}=s4();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})})});Ci.displayName="CollapsibleContent";const o4=f.createContext(null);function w0(){const e=f.useContext(o4);if(!e)throw new Error("Command components must be used within <Command>");return e}const l4=f.forwardRef(({className:e,children:t,...n},r)=>{const[a,i]=f.useState(""),o=f.useRef(new Map),[l,c]=f.useState(0),d=f.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),u=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(T=>T.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:d,unregister:u,updateEntry:p}),[a,h,g,d,u,p]);return s.jsx(o4.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})})});l4.displayName="Command";const c4=f.forwardRef(({className:e,placeholder:t="Search...",...n},r)=>{const{search:a,setSearch:i}=w0();return s.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[s.jsx(sa,{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})]})});c4.displayName="CommandInput";const d4=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}));d4.displayName="CommandList";const u4=f.forwardRef(({className:e,...t},n)=>{const{search:r,visibleIds:a}=w0();return!r||a.size>0?null:s.jsx("div",{ref:n,className:fe("py-6 text-center text-sm text-muted-foreground",e),...t})});u4.displayName="CommandEmpty";const p4=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]}));p4.displayName="CommandGroup";const m4=f.forwardRef(({className:e,value:t,onSelect:n,disabled:r,children:a,...i},o)=>{const{visibleIds:l,activeId:c,setActiveId:d,register:u,unregister:p,updateEntry:h}=w0(),m=f.useId(),g=f.useRef(null),b=t||(typeof a=="string"?a:"");f.useEffect(()=>(u({id:m,value:b.toLowerCase(),onSelect:n||(()=>{}),element:g.current}),()=>p(m)),[m,b,u,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&&d(m)},onClick:()=>!r&&n?.(),...i,children:a})});m4.displayName="CommandItem";const ID=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("-mx-1 h-px bg-border",e),...t}));ID.displayName="CommandSeparator";function Vp({checked:e,onToggle:t,ariaLabel:n="Toggle dark mode"}){const{isDarkMode:r,toggleDarkMode:a}=qa(),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(p0,{className:"h-3 w-3 text-primary"}):s.jsx(m0,{className:"h-3 w-3 text-white dark:text-background"})})]})}const h4=f.createContext(null);function f4(){const e=f.useContext(h4);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const g4=({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,d=f.useCallback(p=>{l||i(p),t?.(p)},[l,t]),u=f.useMemo(()=>({open:c,onOpenChange:d,triggerRef:o}),[c,d]);return s.jsx(h4.Provider,{value:u,children:r})},RD=f.forwardRef(({onClick:e,children:t,asChild:n,...r},a)=>{const{onOpenChange:i,triggerRef:o}=f4(),l=f.useCallback(c=>{i(!0),e?.(c)},[i,e]);if(n&&f.isValidElement(t)){const c=t;return f.cloneElement(c,{onClick:d=>{i(!0),c.props.onClick?.(d)},ref:d=>{o.current=d,typeof a=="function"?a(d):a&&(a.current=d)}})}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})});RD.displayName="DialogTrigger";const By='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',k0=f.forwardRef(({className:e,children:t,onEscapeKeyDown:n,onPointerDownOutside:r,...a},i)=>{const{open:o,onOpenChange:l,triggerRef:c}=f4(),d=f.useRef(null),u=f.useRef(null);return f.useEffect(()=>{o?u.current=document.activeElement:u.current&&((c.current||u.current)?.focus(),u.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"&&d.current){const g=Array.from(d.current.querySelectorAll(By));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&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(By)?.focus()})},[o]),o?Xc.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=>{d.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});k0.displayName="DialogContent";const S0=f.forwardRef(({className:e,...t},n)=>s.jsx("h2",{ref:n,className:fe("sr-only",e),...t}));S0.displayName="DialogTitle";const xt=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}));xt.displayName="Input";const E0=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})}));E0.displayName="ScrollArea";const Ec=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}));Ec.displayName="Shimmer";const b4=f.createContext(null),DD=()=>{const e=f.useContext(b4);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},OD=1e3,LD=1e3,Wp=f.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:r,onOpenChange:a,duration:i,children:o,...l})=>{const c=r??t,d=r===!1,[u,p]=f.useState(c),h=n!==void 0,m=h?n:u,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)/LD)),S.current=null)},[t]),f.useEffect(()=>{t&&!m&&!d&&g(!0)},[t,m,g,d]),f.useEffect(()=>{if(y.current&&!t&&m&&!v){const k=setTimeout(()=>{g(!1),w(!0)},OD);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(b4.Provider,{value:E,children:s.jsx(Ni,{open:m,onOpenChange:g,className:fe("not-prose",e),...l,children:o})})});Wp.displayName="Reasoning";const MD=(e,t)=>e||t===0?s.jsx(Ec,{children:"Thinking..."}):t===void 0?s.jsx("p",{children:"Thought for a few seconds"}):s.jsxs("p",{children:["Thought for ",t," seconds"]}),Kp=f.memo(({className:e,children:t,getThinkingMessage:n=MD,...r})=>{const{isStreaming:a,isOpen:i,duration:o}=DD();return s.jsx(Pa,{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(zI,{className:"h-4 w-4"}),n(a,o),s.jsx(YS,{className:fe("h-4 w-4 transition-transform",i?"rotate-180":"rotate-0")})]})})});Kp.displayName="ReasoningTrigger";const Yp=f.memo(({className:e,children:t,...n})=>s.jsx(Ci,{className:fe("mt-4 text-sm text-muted-foreground",e),...n,children:t}));Yp.displayName="ReasoningContent";function PD(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 ta({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),d=f.useRef(null),u=f.useRef(null),[p,h]=f.useState(null),m=f.useCallback(()=>{const w=d.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&&d.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:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:y,onTouchEnd:v,onTouchCancel:v,children:[e,i&&typeof document<"u"&&Xc.createPortal(s.jsxs("div",{ref:u,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",PD(n))})]}),document.body)]}):s.jsx(s.Fragment,{children:e})}const x4=f.createContext(null),y4=f.forwardRef(({className:e,status:t="ready",children:n,...r},a)=>{const i=f.useMemo(()=>({status:t}),[t]);return s.jsx(x4.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})})});y4.displayName="PromptInput";const v4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-header",className:fe("px-3 pt-3",e),...t}));v4.displayName="PromptInputHeader";const w4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-body",className:fe("relative",e),...t}));w4.displayName="PromptInputBody";const k4=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}));k4.displayName="PromptInputTextarea";const S4=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}));S4.displayName="PromptInputFooter";const E4=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}));E4.displayName="PromptInputTools";const nc=f.forwardRef(({className:e,tooltip:t,children:n,...r},a)=>{const i=s.jsx(Le,{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(ta,{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});nc.displayName="PromptInputButton";const N4=f.forwardRef(({className:e,status:t,children:n,...r},a)=>{const i=f.useContext(x4),o=t??i?.status??"ready",l=o==="submitted"||o==="streaming";return s.jsx(Le,{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(CI,{className:"h-3.5 w-3.5 fill-current"}):s.jsx(lI,{className:"h-4 w-4"}))})});N4.displayName="PromptInputSubmit";function N0({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 C0({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 C4=f.createContext(null);function T4(){const e=f.useContext(C4);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const A4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"queue",role:"list",className:fe("space-y-0.5",e),...t}));A4.displayName="Queue";const _4=f.forwardRef(({status:e="pending",className:t,children:n,...r},a)=>{const i=f.useMemo(()=>({status:e}),[e]);return s.jsx(C4.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})})});_4.displayName="QueueItem";const j4=f.forwardRef(({className:e,...t},n)=>{const{status:r}=T4();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})})]})});j4.displayName="QueueItemIndicator";const I4=f.forwardRef(({className:e,children:t,...n},r)=>{const{status:a}=T4();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})});I4.displayName="QueueItemContent";const $y="https://github.com/alicomert/pixcode/issues/new",FD="https://github.com/alicomert/pixcode",Uy="https://discord.gg/buxwujPNRE";function Gy({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 zD({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(gy,{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(gy,{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:$y,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(Pp,{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:Uy,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(Gy,{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(Et,{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:FD,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:$y,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(Pp,{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:Uy,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(Gy,{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(Et,{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 Hy="PIXCODE_GITHUB_STARS",qy="PIXCODE_HIDE_GITHUB_STAR",BD=3600*1e3,$D=(e,t)=>{const[n,r]=f.useState(null),[a,i]=f.useState(()=>{try{return localStorage.getItem(qy)==="true"}catch{return!1}});f.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(Hy);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<BD){r(u.count);return}}}catch{}(async()=>{try{const d=await fetch(`https://api.github.com/repos/${e}/${t}`);if(!d.ok)return;const p=(await d.json()).stargazers_count;if(typeof p=="number"){r(p);try{localStorage.setItem(Hy,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=f.useCallback(()=>{i(!0);try{localStorage.setItem(qy,"true")}catch{}},[]),l=n!==null?n>=1e3?`${(n/1e3).toFixed(1)}k`:`${n}`:null;return{starCount:n,formattedCount:l,isDismissed:a,dismiss:o}},UD="https://github.com/alicomert/pixcode";function GD({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 HD(){const{formattedCount:e,isDismissed:t,dismiss:n}=$D("alicomert","pixcode");return t?null:s.jsxs("div",{className:"group/star relative hidden md:block",children:[s.jsxs("a",{href:UD,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(GD,{className:"h-3.5 w-3.5"}),s.jsx(ds,{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(pt,{className:"h-2.5 w-2.5"})})]})}function Vy({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(Fo,{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(hI,{className:"h-3 w-3"}),n("historyView.grouped",{defaultValue:"By project"})]})]})}function qD({isPWA:e,isMobile:t,isLoading:n,projectsCount:r,searchFilter:a,onSearchFilterChange:i,onClearSearchFilter:o,searchMode:l,onSearchModeChange:c,onRefresh:d,isRefreshing:u,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(Le,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:d,disabled:u,title:x("tooltips.refresh"),children:s.jsx(yt,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),s.jsx(Le,{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(Jt,{className:"h-4 w-4"})}),s.jsx(Le,{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(sI,{className:"h-4 w-4"})})]})]}),s.jsx(HD,{}),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(oa,{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:[s.jsx(Vy,{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(Cr,{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(Si,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(sa,{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(xt,{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(pt,{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:d,disabled:u,children:s.jsx(yt,{className:`h-4 w-4 text-muted-foreground ${u?"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(ki,{className:"h-4 w-4"})})]})]}),r>0&&!n&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&s.jsx(Vy,{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(Cr,{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(Si,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(sa,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(xt,{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(pt,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider md:hidden"})]})}const VD=160,Wy=180;function R4({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 u=l.current.getBoundingClientRect();let p=u.right-VD;p<8&&(p=8);let h=u.bottom+4;h+Wy>window.innerHeight&&(h=Math.max(8,u.top-4-Wy)),o({top:h,left:p})},[r]),f.useEffect(()=>{if(!r)return;const u=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",u),document.addEventListener("keydown",p),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",p),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[r]);const d=u=>p=>{p.stopPropagation(),p.preventDefault(),a(!1),u.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:u=>{u.stopPropagation(),u.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(EI,{className:"h-3.5 w-3.5"})}),r&&i&&Xc.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:u=>u.stopPropagation(),onMouseDown:u=>u.stopPropagation(),children:e.map((u,p)=>{const h=u.icon,m=e[p-1],g=p>0&&u.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:d(u),className:fe("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs",u.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"}),u.label]})]},u.id)})}),document.body)]})}const Ky={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},WD={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},KD=e=>e==="fully-configured"?{icon:wi,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:Et,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:na,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:pt,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function YD({status:e="not-configured",size:t="sm",className:n="",showLabel:r=!1}){const a=KD(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:Ky[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,WD[t],n),title:a.title,children:s.jsx(i,{className:fe(Ky[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)),d=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`:d===1?n?n("time.oneDayAgo"):"1 day ago":d<7?n?n("time.daysAgo",{count:d}):`${d} days ago`:r.toLocaleDateString()};function Yy({isStarred:e,canDelete:t,onRename:n,onToggleStar:r,onDelete:a,t:i,className:o}){const l=d=>s.jsx(ds,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:i("actions.rename"),icon:bI,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(R4,{actions:c,className:o,triggerLabel:i("tooltips.sessionActions",{defaultValue:"Session actions"})})}const XD={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},Zy={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",opencode:"bg-teal-500/10 text-teal-600 dark:bg-teal-400/10 dark:text-teal-300 ring-1 ring-teal-500/15"};function D4({project:e,session:t,selectedSession:n,currentTime:r,editingSession:a,editingSessionName:i,isStarred:o,compact:l=!1,onEditingSessionNameChange:c,onStartEditingSession:d,onCancelEditingSession:u,onSaveEditingSession:p,onToggleStarSession:h,onProjectSelect:m,onSessionSelect:g,onDeleteSession:b,t:x}){const y=D9(t,r,x),v=n?.id===t.id,w=a===t.id,S=t.__provider,E=XD[S]??S,k=Zy[S]??Zy.claude,A=j9(y.sessionName),T=()=>{m(e),g(t,e.name)},N=()=>{p(e.name,t.id,i,S)},j=()=>{b(e.name,t.id,y.sessionName,S)},O=()=>d(t.id,y.sessionName),_=()=>h(e.name,t.id),R=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(Rn,{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))]}),C=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"&&u()},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(Ht,{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(),u()},title:x("tooltips.cancel"),children:s.jsx(pt,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),F=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:T,children:w?s.jsx("div",{className:"flex items-center gap-1",children:C}):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(Rn,{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})]}),R]}),s.jsx("div",{className:"flex-shrink-0",onClick:B=>B.stopPropagation(),children:s.jsx(Yy,{isStarred:o,canDelete:!y.isCursorSession,onRename:O,onToggleStar:_,onDelete:j,t:x,className:"!opacity-100"})})]})})}),K=s.jsxs("div",{className:fe("group/item relative hidden md:block"),children:[s.jsxs(Le,{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(Rn,{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:C}):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})]}),R]})})]})]}),!w&&s.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:B=>B.stopPropagation(),children:s.jsx(Yy,{isStarred:o,canDelete:!y.isCursorSession,onRename:O,onToggleStar:_,onDelete:j,t:x,className:"opacity-0 group-hover/item:opacity-100 focus-visible:opacity-100"})})]});return s.jsxs("div",{className:"group relative",children:[F,K]})}function JD(){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 QD({project:e,isExpanded:t,sessions:n,selectedSession:r,initialSessionsLoaded:a,isLoadingSessions:i,currentTime:o,editingSession:l,editingSessionName:c,isSessionStarred:d,onEditingSessionNameChange:u,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(Jt,{className:"h-3 w-3"}),S("sessions.newSession")]})}),s.jsxs(Le,{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(Jt,{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(D4,{project:e,session:A,selectedSession:r,currentTime:o,editingSession:l,editingSessionName:c,isStarred:d(e.name,A.id),onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:h,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:S},A.id)):s.jsx(JD,{}),E&&k&&s.jsx(Le,{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(Pn,{className:"h-3 w-3"}),S("sessions.showMore")]})})]})}const eO=(e,t)=>{const n=e.length;return t&&n>=5?`${n}+`:`${n}`};function tO({project:e,selectedProject:t,selectedSession:n,isExpanded:r,isDeleting:a,isStarred:i,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:d,isLoadingSessions:u,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:T,onDeleteProject:N,onSessionSelect:j,onDeleteSession:O,onLoadMoreSessions:_,onNewSession:R,onEditingSessionNameChange:C,onStartEditingSession:F,onCancelEditingSession:K,onSaveEditingSession:B,t:W}){const H=t?.name===e.name,L=o===e.name,G=e.sessionMeta?.hasMore===!0,U=eO(c,G),P=`${U} session${c.length===1?"":"s"}`,J=M9(e,b),Z=()=>v(e.name),de=()=>S(e.name),le=()=>{T(e.name)},ce=()=>{t?.name!==e.name&&w(e),Z()};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",H&&"bg-primary/5 border-primary/20",i&&!H&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:Z,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(ia,{className:"h-4 w-4 text-primary"}):s.jsx(Cr,{className:"h-4 w-4 text-muted-foreground"})}),s.jsx("div",{className:"min-w-0 flex-1",children:L?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:W("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(YD,{status:J,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:L?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(Ht,{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(pt,{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(),de()},title:W(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:s.jsx(ds,{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(Mp,{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(Pn,{className:"h-3 w-3 text-muted-foreground"}):s.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),s.jsxs(Le,{variant:"ghost",className:fe("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",H&&"bg-accent text-accent-foreground",i&&!H&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:ce,children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r?s.jsx(ia,{className:"h-4 w-4 flex-shrink-0 text-primary"}):s.jsx(Cr,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),s.jsx("div",{className:"min-w-0 flex-1 text-left",children:L?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:W("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:[U,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:L?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(Ht,{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(pt,{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(),de()},title:W("tooltips.removeFromFavorites"),children:s.jsx(ds,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),s.jsx(R4,{triggerLabel:W("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:W("actions.rename"),icon:Mp,onClick:()=>k(e)},{id:"star",label:W(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:ds,onClick:de},{id:"delete",label:W("actions.delete",{defaultValue:"Delete"}),icon:gn,onClick:()=>N(e),danger:!0}]}),r?s.jsx(Pn,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):s.jsx(Nr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),s.jsx(QD,{project:e,isExpanded:r,sessions:c,selectedSession:n,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:h,editingSessionName:m,isSessionStarred:x,onEditingSessionNameChange:C,onStartEditingSession:F,onCancelEditingSession:K,onSaveEditingSession:B,onToggleStarSession:E,onProjectSelect:w,onSessionSelect:j,onDeleteSession:O,onLoadMoreSessions:_,onNewSession:R,t:W})]})}function O4({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(Cr,{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(sa,{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 nO({projects:e,filteredProjects:t,selectedProject:n,selectedSession:r,isLoading:a,loadingProgress:i,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:d,initialSessionsLoaded:u,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:T,onStartEditingProject:N,onCancelEditingProject:j,onSaveProjectName:O,onDeleteProject:_,onSessionSelect:R,onDeleteSession:C,onLoadMoreSessions:F,onNewSession:K,onEditingSessionNameChange:B,onStartEditingSession:W,onCancelEditingSession:H,onSaveEditingSession:L,t:G}){const U=s.jsx(O4,{isLoading:a,loadingProgress:i,projectsCount:e.length,filteredProjectsCount:t.length,t:G});f.useEffect(()=>{let ce="Pixcode";const he=n?.displayName?.trim();he&&(ce=`${he} - ${ce}`),document.title=ce},[n]);const P=!a&&e.length>0&&t.length>0,J=ce=>ce.source==="history"||ce.autoDiscovered===!0&&ce.isManuallyAdded!==!0,Z=t.filter(ce=>!J(ce)),de=t.filter(ce=>J(ce)),le=ce=>s.jsx(tO,{project:ce,selectedProject:n,selectedSession:r,isExpanded:o.has(ce.name),isDeleting:g.has(ce.name),isStarred:v(ce.name),editingProject:l,editingName:c,sessions:y(ce),initialSessionsLoaded:u.has(ce.name),isLoadingSessions:!!d[ce.name],currentTime:p,editingSession:h,editingSessionName:m,tasksEnabled:b,mcpServerStatus:x,isSessionStarred:w,onEditingNameChange:S,onToggleProject:E,onProjectSelect:k,onToggleStarProject:A,onToggleStarSession:T,onStartEditingProject:N,onCancelEditingProject:j,onSaveProjectName:O,onDeleteProject:_,onSessionSelect:R,onDeleteSession:C,onLoadMoreSessions:F,onNewSession:K,onEditingSessionNameChange:B,onStartEditingSession:W,onCancelEditingSession:H,onSaveEditingSession:L,t:G},ce.name);return s.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:P?s.jsxs(s.Fragment,{children:[Z.map(ce=>le(ce)),de.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:G("projects.detectedFromHistory")}),de.map(ce=>le(ce))]})]}):U})}function Xr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function L4(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
  *