@pixelbyte-software/pixcode 1.41.3 → 1.41.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-Bq2twGSW.js → index-CIEN0bZ-.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/server/services/live-view.js +19 -94
- package/dist-server/server/services/live-view.js.map +1 -1
- package/dist-server/server/services/runtime-manager.js +312 -0
- package/dist-server/server/services/runtime-manager.js.map +1 -0
- package/package.json +1 -1
- package/scripts/smoke/live-view-diagnostics.mjs +2 -2
- package/scripts/smoke/live-view-integration.mjs +58 -46
- package/scripts/smoke/runtime-manager.mjs +99 -0
- package/server/services/live-view.js +20 -101
- package/server/services/runtime-manager.js +323 -0
|
@@ -226,7 +226,7 @@ import{j as i,a as L4,R as vf,o as wf,_ as Nj,b as Cj,m as D4,E as Cn,T as O4,P
|
|
|
226
226
|
*
|
|
227
227
|
* This source code is licensed under the ISC license.
|
|
228
228
|
* See the LICENSE file in the root directory of this source tree.
|
|
229
|
-
*/const xD=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],yD=ft("workflow",xD),Tf=oE,xE=i7,Zv=t7,vD=m7,wD=qI,Af=XI,kD=sE,Fr=dE,SD=W7,jf=$7,An=G7,ED=V7,Yr=QI,ta=sE,cd=n7,yE=YI,ND=M7,CD=F7,vE=o7,mt=lE,Dt=lE,Kd=u7,wE=c7,TD=n8,Nn=vR,Ar=kR,nr=D7,ra=R7,kE=UR,cn=C8,AD=mE,jD=mE,dd=N7,Yd=X7,SE=Y7,Zd=uE,rl=rR,Gs=pR,Ht=hR,Pn=DR,Ea=_R,ii=RR,_D=d8,ID=BR,fl=WR,Ml=v8,RD=f7,Pl=T7,LD=$8,DD=Cf,OD=Cf,Wm=o8,EE=MR,MD=AR,PD=I8,FD=x8,zD=QR,NE=i8,Km=Cf,_f=p8,Vt=h8,kr=G8,BD=gR,Na=XR,bt=hE,Ym=hE,Xd=O8,If=w7,$D=y7,Zm=b7,UD=xR,na=cE,GD=cE,HD=V8,CE=W8,gl=j7,TE=eR,Zi=CR,Rf=ER,Fn=FR,AE=uE,Jd=pE,VD=pE,jE=VR,vn=YR,Lf=t8,_E=lR,IE=z8,qD=g8,Df=E8,WD=k8,Rt=aR,KD=UI,RE=dR,Ca=j8,Rs=L8,Of=P8,Hr=sR,Mf=S7,YD=nL,Fl=cL,Pf=gE,ZD=gE,en=qL,Gc=KL,XD=ZL,os=tL,ls=iL,JD=oL,Uo=uL,Ls=mL,Xv=xL,Go=vL,To=EL,QD=CL,LE=FL,Xm=AL,Ii=RL,Ao=_L,Jv=DL,jo=ML,Jm=BL,eO=UL,Qm=HL,Cs=eD,Ho=rD,$a=aD,cs=sD,tO=lD,eh=dD,rO=mD,_o=bD,aa=yD,bl=gL,DE=kL,nO=JL,aO=fD,iO=[{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"}],sO={up:xE,down:Tf,left:wD,right:Af},Io=e=>e.preventDefault(),Qv="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",oO="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",Vu="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 ew({wsRef:e,terminalRef:t,isConnected:r,bottomOffset:n="bottom-0"}){const{t:a}=Me("settings"),[s,o]=h.useState(!1),[l,c]=h.useState(!1),d=h.useCallback(m=>{Pi(e.current,{type:"input",data:m})},[e]),u=h.useCallback(()=>{t.current?.scrollToBottom()},[t]),p=h.useCallback(async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.readText))try{const m=await navigator.clipboard.readText();m.length>0&&d(m)}catch{}},[d]),f=h.useCallback(m=>{let g=m;if(s&&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)},[s,l,d]);return i.jsx("div",{className:`pointer-events-none fixed inset-x-0 ${n} z-20 px-2 md:hidden`,children:i.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:[i.jsx("button",{type:"button",onPointerDown:Io,onClick:()=>{p()},disabled:!r,className:Vu,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:i.jsx(Yd,{className:"h-4 w-4"})}),iO.map(m=>{if(m.type==="modifier"){const g=m.modifier==="ctrl"?s:l,b=m.modifier==="ctrl"?()=>o(x=>!x):()=>c(x=>!x);return i.jsx("button",{type:"button",onPointerDown:Io,onClick:b,disabled:!r,className:g?oO:Qv,children:m.label},m.id)}if(m.type==="arrow"){const g=sO[m.icon];return i.jsx("button",{type:"button",onPointerDown:Io,onClick:()=>d(m.sequence),disabled:!r,className:Vu,children:i.jsx(g,{className:"h-4 w-4"})},m.id)}return i.jsx("button",{type:"button",onPointerDown:Io,onClick:()=>f(m.sequence),disabled:!r,className:Qv,children:m.label},m.id)}),i.jsx("button",{type:"button",onPointerDown:Io,onClick:u,disabled:!r,className:Vu,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:i.jsx(kD,{className:"h-4 w-4"})})]})})}function OE({selectedProject:e=null,selectedSession:t=null,initialCommand:r=null,isPlainShell:n=!1,onProcessComplete:a=null,minimal:s=!1,autoConnect:o=!1,isActive:l=!0}){const{t:c}=Me("chat"),[d,u]=h.useState(!1),[p,f]=h.useState(null),m=h.useRef(null),g=h.useRef(null),{terminalContainerRef:b,terminalRef:x,wsRef:y,isConnected:v,isInitialized:w,isConnecting:S,authUrl:E,authUrlVersion:k,connectToShell:j,disconnectFromShell:_,openAuthUrlInBrowser:A,copyAuthUrlToClipboard:C}=MI({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:n,minimal:s,autoConnect:o,isRestarting:d,onProcessComplete:a,onOutputRef:g}),R=h.useCallback(()=>{const $=x.current;if(!$)return;const F=$.buffer.active,ne=F.baseY+F.cursorY,ee=Math.min(F.baseY+F.length-1,ne+10),ge=Math.max(0,ne-fI),ie=[];for(let xe=ge;xe<=ee;xe++){const Ue=F.getLine(xe);Ue&&ie.push(Ue.translateToString().trimEnd())}let me=-1;for(let xe=ie.length-1;xe>=0;xe--)if(/esc to cancel/i.test(ie[xe])||/enter to select/i.test(ie[xe])){me=xe;break}if(me===-1){f(null);return}const pe=new Map,be=Math.max(0,me-gI);for(let xe=me-1;xe>=be;xe--){const Ue=ie[xe].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(Ue){const M=Ue[1],de=Ue[2].trim();parseInt(M,10)<=bI&&de.length>0&&!pe.has(M)&&pe.set(M,de)}}const Ee=[];for(let xe=1;xe<=pe.size&&pe.has(String(xe));xe++)Ee.push({number:String(xe),label:pe.get(String(xe))});f(Ee.length>=xI?Ee:null)},[x]),T=h.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(R,hI)},[R]);h.useEffect(()=>{g.current=T},[T]),h.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),h.useEffect(()=>{v||(m.current&&(clearTimeout(m.current),m.current=null),f(null))},[v]),h.useEffect(()=>{if(!l||!w||!v)return;const $=()=>{x.current?.focus()},F=window.requestAnimationFrame($),ne=window.setTimeout($,0);return()=>{window.cancelAnimationFrame(F),window.clearTimeout(ne)}},[l,v,w,x]);const I=h.useCallback($=>{Pi(y.current,{type:"input",data:$})},[y]),N=h.useMemo(()=>RI(t),[t]),P=h.useMemo(()=>N?N.slice(0,30):null,[N]),G=h.useMemo(()=>N?N.slice(0,50):null,[N]),z=h.useCallback(()=>{u(!0),window.setTimeout(()=>{u(!1)},pI)},[]);if(!e)return i.jsx(FI,{title:c("shell.selectProject.title"),description:c("shell.selectProject.description")});if(s)return i.jsxs(i.Fragment,{children:[i.jsx(BI,{terminalContainerRef:b,authUrl:E,authUrlVersion:k,initialCommand:r,isConnected:v,openAuthUrlInBrowser:A,copyAuthUrlToClipboard:C}),i.jsx(ew,{wsRef:y,terminalRef:x,isConnected:v,bottomOffset:"bottom-0"})]});const U=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:G}):c("shell.startSession"),V=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName}),O=w?S?"connecting":v?null:"connect":"loading",H=O==="connecting"?V:U;return i.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[i.jsx(zI,{isConnected:v,isInitialized:w,isRestarting:d,hasSession:!!t,sessionDisplayNameShort:P,onDisconnect:_,onRestart:z,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}),i.jsxs("div",{className:"relative flex-1 overflow-hidden p-2",children:[i.jsx("div",{ref:b,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),O&&i.jsx(PI,{mode:O,description:H,loadingLabel:c("shell.loading"),connectLabel:c("shell.actions.connect"),connectTitle:c("shell.actions.connectTitle"),connectingLabel:c("shell.connecting"),onConnect:j}),p&&v&&i.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:$=>$.preventDefault(),children:i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map($=>i.jsxs("button",{type:"button",onClick:()=>{I($.number),f(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:`${$.number}. ${$.label}`,children:[$.number,". ",$.label]},$.number)),i.jsx("button",{type:"button",onClick:()=>{I("\x1B"),f(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"})]})})]}),i.jsx(ew,{wsRef:y,terminalRef:x,isConnected:v})]})}function lO({className:e}){return i.jsx("div",{className:`flex h-full items-center justify-center ${e}`,children:i.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[i.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:i.jsx("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),i.jsx("h3",{className:"mb-2 text-lg font-semibold",children:"No Project Selected"}),i.jsx("p",{children:"A project is required to open a shell"})]})})}function cO({title:e,isCompleted:t,onClose:r=null}){return i.jsx("div",{className:"flex-shrink-0 border-b border-gray-700 bg-gray-800 px-4 py-2",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx("h3",{className:"text-sm font-medium text-gray-200",children:e}),t&&i.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),r&&i.jsx("button",{onClick:r,className:"text-gray-400 hover:text-white",title:"Close",children:i.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}function ME({project:e=null,session:t=null,command:r=null,isPlainShell:n=null,isActive:a=!0,autoConnect:s=!0,onComplete:o=null,onClose:l=null,title:c=null,className:d="",showHeader:u=!0,compact:p=!1,minimal:f=!1}){const[m,g]=h.useState(!1),b=n!==null?n:r!==null,x=h.useCallback(y=>{g(!0),o?.(y)},[o]);return e?i.jsxs("div",{className:`flex h-full w-full flex-col ${d}`,children:[!f&&u&&c&&i.jsx(cO,{title:c,isCompleted:m,onClose:l}),i.jsx("div",{className:"min-h-0 w-full flex-1",children:i.jsx(OE,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:b,isActive:a,onProcessComplete:x,minimal:f,autoConnect:f?!0:s})})]}):i.jsx(lO,{className:d})}const dO=(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"),uO={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 tw({active:e,children:t,onClick:r}){return i.jsx("button",{onClick:r,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 pO({provider:e}){const[t,r]=h.useState(""),[n,a]=h.useState(!1),[s,o]=h.useState("idle"),[l,c]=h.useState(null),d=async()=>{const u=t.trim();if(u){a(!0),c(null),o("idle");try{const p=await ve(`/api/providers/${e}/oauth-paste`,{method:"POST",body:JSON.stringify({callbackUrl:u})}),f=await p.json().catch(()=>({}));if(!p.ok||!f?.success)throw new Error(f?.error||`Request failed (${p.status})`);o("ok"),r("")}catch(p){c(p?.message||"Forward failed"),o("error")}finally{a(!1)}}};return i.jsxs("div",{className:"mt-3 rounded-lg border border-border/60 bg-muted/30 p-3 text-sm",children:[i.jsx("div",{className:"mb-2 font-medium text-foreground",children:"Remote login? Paste the callback URL here"}),i.jsxs("p",{className:"mb-3 text-xs text-muted-foreground",children:["When the CLI shows ",i.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."]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"url",value:t,onChange:u=>r(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()}}),i.jsx("button",{onClick:()=>void d(),disabled:n||!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:n?i.jsx(Dt,{className:"h-3.5 w-3.5 animate-spin"}):"Forward"})]}),s==="ok"&&i.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-emerald-600 dark:text-emerald-400",children:[i.jsx(nr,{className:"h-3.5 w-3.5"})," Forwarded — check the terminal above for the completion message."]}),s==="error"&&l&&i.jsx("div",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:l})]})}function mO({provider:e,onSaved:t}){const r=uO[e],[n,a]=h.useState(""),[s,o]=h.useState(""),[l,c]=h.useState(!1),[d,u]=h.useState("idle"),[p,f]=h.useState(null);h.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await ve("/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=n.trim();if(g){c(!0),f(null),u("idle");try{const b=await ve(`/api/providers/${e}/auth/api-key`,{method:"POST",body:JSON.stringify({apiKey:g,baseUrl:r.supportsBaseUrl&&s.trim()?s.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){f(b?.message||"Save failed"),u("error")}finally{c(!1)}}};return r?i.jsx("div",{className:"flex h-full flex-col overflow-y-auto p-6",children:i.jsxs("div",{className:"mx-auto w-full max-w-lg space-y-5",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-muted",children:i.jsx(VD,{className:"h-5 w-5 text-foreground"})}),i.jsxs("div",{children:[i.jsx("h4",{className:"text-base font-semibold text-foreground",children:r.keyLabel}),i.jsxs("a",{href:r.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 ",r.keyConsoleLabel,i.jsx(Yr,{className:"h-3 w-3"})]})]})]}),r.notes&&i.jsx("div",{className:"rounded-md border border-border/60 bg-muted/40 p-3 text-xs text-muted-foreground",children:r.notes}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{className:"text-xs font-medium text-foreground",children:"API Key"}),i.jsx("input",{type:"password",value:n,onChange:g=>a(g.target.value),placeholder:r.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}),i.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Stored locally at ",i.jsx("code",{className:"rounded bg-muted px-1 font-mono text-[10px]",children:"~/.pixcode/provider-credentials.json"})," with 0600 permissions."]})]}),r.supportsBaseUrl&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-foreground",children:["Base URL ",i.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional — use a custom endpoint)"})]}),i.jsx("input",{type:"url",value:s,onChange:g=>o(g.target.value),placeholder:r.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}),i.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."})]}),i.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[i.jsxs("button",{onClick:()=>void m(),disabled:l||!n.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?i.jsx(Dt,{className:"h-4 w-4 animate-spin"}):i.jsx(nr,{className:"h-4 w-4"}),"Save API Key"]}),d==="ok"&&i.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved — reconnect to pick it up."}),d==="error"&&p&&i.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:p})]})]})}):i.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"This provider uses OAuth only — use the Browser tab to log in."})}function PE({isOpen:e,onClose:t,provider:r="claude",onComplete:n,customCommand:a,isAuthenticated:s=!1}){const{t:o}=Me("common"),l=r!=="cursor",[c,d]=h.useState(l?"apiKey":"browser");h.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,r,l]);const u=h.useMemo(()=>`${hl[r]??r} Login`,[r]);if(!e)return null;const p=dO(r,a),f=m=>n?.(m);return i.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:i.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:[i.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:u}),i.jsx("button",{onClick:t,className:"text-gray-400 transition-colors hover:text-gray-600 dark:hover:text-gray-300","aria-label":"Close login modal",children:i.jsx(bt,{className:"h-6 w-6"})})]}),i.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[i.jsx(tw,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&i.jsx(tw,{active:c==="apiKey",onClick:()=>d("apiKey"),children:"API Key"})]}),i.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:c==="browser"?i.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(ME,{project:X_,command:p,onComplete:f,minimal:!0})}),i.jsx("div",{className:"border-t border-border/40 bg-background/50 px-4 py-3",children:i.jsx(pO,{provider:r})})]}):i.jsx(mO,{provider:r,onSaved:()=>f(0)})})]})})}const hO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),fO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ma();return i.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},gO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ma();return i.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},bO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),xO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ma(),r=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return i.jsx("img",{src:r,alt:"OpenCode",className:e})},yO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function dr({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?i.jsx(gO,{className:t}):e==="codex"?i.jsx(fO,{className:t}):e==="gemini"?i.jsx(bO,{className:t}):e==="qwen"?i.jsx(yO,{className:t}):e==="opencode"?i.jsx(xO,{className:t}):i.jsx(hO,{className:t})}function vO({provider:e,title:t,status:r,connectedClassName:n,iconContainerClassName:a,loginButtonClassName:s,onLogin:o}){const l=r.authenticated?n:"border-border bg-card",c=r.loading?"Checking...":r.authenticated?r.email||"Connected":r.error||"Not connected";return i.jsx("div",{className:`rounded-lg border p-4 transition-colors ${l}`,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-full ${a}`,children:i.jsx(dr,{provider:e,className:"h-5 w-5"})}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 font-medium text-foreground",children:[t,r.authenticated&&i.jsx(nr,{className:"h-4 w-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:c})]})]}),!r.authenticated&&!r.loading&&i.jsx("button",{onClick:o,className:`${s} rounded-lg px-4 py-2 text-sm font-medium text-white transition-colors`,children:"Login"})]})})}const wO=[{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 kO({providerStatuses:e,onOpenProviderLogin:t}){return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"mb-6 text-center",children:[i.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Connect Your AI Agents"}),i.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),i.jsx("div",{className:"space-y-3",children:wO.map(r=>i.jsx(vO,{provider:r.provider,title:r.title,status:e[r.provider],connectedClassName:r.connectedClassName,iconContainerClassName:r.iconContainerClassName,loginButtonClassName:r.loginButtonClassName,onLogin:()=>t(r.provider)},r.provider))}),i.jsx("div",{className:"pt-2 text-center text-sm text-muted-foreground",children:i.jsx("p",{children:"You can configure these later in Settings."})})]})}function SO({gitName:e,gitEmail:t,isSubmitting:r,onGitNameChange:n,onGitEmailChange:a}){return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"mb-8 text-center",children:[i.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:i.jsx(en,{className:"h-8 w-8 text-blue-600 dark:text-blue-400"})}),i.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Git Configuration"}),i.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for commits."})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitName",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[i.jsx(HD,{className:"h-4 w-4"}),"Git Name ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"text",id:"gitName",value:e,onChange:s=>n(s.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:r}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.name`."})]}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitEmail",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[i.jsx(UD,{className:"h-4 w-4"}),"Git Email ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"email",id:"gitEmail",value:t,onChange:s=>a(s.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:r}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.email`."})]})]})]})}const rw=[{title:"Git Configuration",icon:en,required:!0},{title:"Connect Agents",icon:yE,required:!1},{title:"Task System",icon:Ml,required:!1}];function EO({currentStep:e}){return i.jsx("div",{className:"mb-8",children:i.jsx("div",{className:"flex items-center justify-between",children:rw.map((t,r)=>{const n=r<e,a=r===e,s=t.icon;return i.jsxs("div",{className:"contents",children:[i.jsxs("div",{className:"flex flex-1 flex-col items-center",children:[i.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-full border-2 transition-colors duration-200 ${n?"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:n?i.jsx(nr,{className:"h-6 w-6"}):i.jsx(s,{className:"h-6 w-6"})}),i.jsxs("div",{className:"mt-2 text-center",children:[i.jsx("p",{className:`text-sm font-medium ${a?"text-foreground":"text-muted-foreground"}`,children:t.title}),t.required&&i.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),r<rw.length-1&&i.jsx("div",{className:`mx-2 h-0.5 flex-1 transition-colors duration-200 ${n?"bg-green-500":"bg-border"}`})]},t.title)})})})}const NO=e=>e?e.installation?.isInstalled?e.installation.version?`TaskMaster CLI installed (${e.installation.version}).`:"TaskMaster CLI installed.":e.installation?.reason||"TaskMaster CLI is not installed yet.":"Checking TaskMaster installation...";function CO({enabled:e,onEnabledChange:t,onReadyChange:r}){const[n,a]=h.useState(null),[s,o]=h.useState(!0),[l,c]=h.useState(!1),[d,u]=h.useState([]),[p,f]=h.useState(""),m=h.useRef(null),g=!!n?.installation?.isInstalled,b=!!n?.mcpServer?.hasMCPServer,x=h.useMemo(()=>!e||g,[e,g]);h.useEffect(()=>{r(x)},[r,x]);const y=h.useCallback(async()=>{o(!0),f("");try{const w=await ve("/api/taskmaster/installation-status"),S=await w.json();a(S),w.ok||f(S.installation?.reason||"TaskMaster status check failed.")}catch(w){a(null),f(w instanceof Error?w.message:"TaskMaster status check failed.")}finally{o(!1)}},[]);h.useEffect(()=>(y(),()=>{m.current?.close(),m.current=null}),[y]);const v=h.useCallback(async()=>{c(!0),f(""),u([]);try{const w=await ve("/api/taskmaster/install",{method:"POST"}),S=await w.json();if(!w.ok||!S.success||!S.jobId)throw new Error(S.error||S.message||"TaskMaster install could not start.");const E=localStorage.getItem(Wd),k=E?`?token=${encodeURIComponent(E)}`:"",j=new EventSource(`/api/taskmaster/install/${encodeURIComponent(S.jobId)}/stream${k}`);m.current=j,j.addEventListener("log",_=>{const A=JSON.parse(_.data);u(C=>[...C,A].slice(-80))}),j.addEventListener("done",_=>{const A=JSON.parse(_.data);if(j.close(),m.current=null,c(!1),!A.success){f(A.error||A.message||"TaskMaster install failed.");return}y()}),j.onerror=()=>{j.close(),m.current=null,c(!1),f("TaskMaster install stream disconnected.")}}catch(w){c(!1),f(w instanceof Error?w.message:"TaskMaster install could not start.")}},[y]);return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("h2",{className:"text-2xl font-semibold text-foreground",children:"Task System"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Decide whether Pixcode should enable TaskMaster-backed planning, kanban tasks, PRD parsing, and agent task execution from the start."})]}),i.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-lg border border-border bg-background p-4 transition-colors hover:bg-muted/40",children:[i.jsx("input",{type:"checkbox",checked:e,onChange:w=>t(w.target.checked),className:"mt-1 h-4 w-4"}),i.jsxs("span",{className:"min-w-0 space-y-1",children:[i.jsx("span",{className:"block text-sm font-medium text-foreground",children:"Enable TaskMaster features"}),i.jsx("span",{className:"block text-sm leading-6 text-muted-foreground",children:"This keeps the Tasks panel, PRD tools, and orchestration task sync available. You can change it later in Settings."})]})]}),e&&i.jsxs("div",{className:"space-y-4 rounded-lg border border-border bg-card p-4",children:[i.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[g?i.jsx(ra,{className:"h-5 w-5 text-green-600"}):i.jsx(Hr,{className:"h-5 w-5 text-primary"}),i.jsx("h3",{className:"font-medium text-foreground",children:"TaskMaster CLI"})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:NO(n)}),g&&!b&&i.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:"MCP server is not configured yet. Core task files work now; MCP can be connected later from Settings."})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>void y(),disabled:s||l,className:"rounded-md border border-border px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:s?"Checking...":"Refresh"}),!g&&i.jsxs("button",{type:"button",onClick:()=>void v(),disabled:l,className:"inline-flex items-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-60",children:[l&&i.jsx(Dt,{className:"h-4 w-4 animate-spin"}),l?"Installing...":"Install"]})]})]}),p&&i.jsx("div",{className:"rounded-md border border-red-300 bg-red-50 p-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-950/30 dark:text-red-300",children:p}),d.length>0&&i.jsx("pre",{className:"max-h-48 overflow-auto rounded-md bg-black p-3 text-xs leading-5 text-green-200",children:d.map(w=>`${w.stream}> ${w.chunk}`).join("")})]})]})}const nw=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,aw=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function TO({onComplete:e}){const[t,r]=h.useState(0),[n,a]=h.useState(""),[s,o]=h.useState(""),[l,c]=h.useState(!1),[d,u]=h.useState(""),[p,f]=h.useState(null),[m,g]=h.useState(()=>{try{const T=localStorage.getItem("tasks-enabled");return T===null?!0:JSON.parse(T)!==!1}catch{return!0}}),[b,x]=h.useState(!1),{providerAuthStatus:y,checkProviderAuthStatus:v,refreshProviderAuthStatuses:w}=Nf(),S=h.useRef(void 0),E=h.useCallback(async()=>{try{const T=await ve("/api/user/git-config");if(!T.ok)return;const I=await T.json();I.gitName&&a(I.gitName),I.gitEmail&&o(I.gitEmail)}catch(T){console.error("Error loading git config:",T)}},[]);h.useEffect(()=>{E(),w()},[E,w]),h.useEffect(()=>{const T=S.current;S.current=p,T!=null&&p===null&&w()},[p,w]);const k=T=>{f(T)},j=T=>{T===0&&p&&v(p)},_=async()=>{if(u(""),t!==0){r(T=>T+1);return}if(!n.trim()||!s.trim()){u("Both git name and email are required.");return}if(!nw.test(s)){u("Please enter a valid email address.");return}c(!0);try{const T=await ve("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:n,gitEmail:s})});if(!T.ok){const I=await aw(T,"Failed to save git configuration");throw new Error(I)}r(I=>I+1)}catch(T){u(T instanceof Error?T.message:"Failed to save git configuration")}finally{c(!1)}},A=()=>{u(""),r(T=>T-1)},C=async()=>{if(m&&!b){u("Install TaskMaster or disable TaskMaster features to finish setup.");return}c(!0),u("");try{localStorage.setItem("tasks-enabled",JSON.stringify(m));const T=await ve("/api/user/complete-onboarding",{method:"POST"});if(!T.ok){const I=await aw(T,"Failed to complete onboarding");throw new Error(I)}await e?.()}catch(T){u(T instanceof Error?T.message:"Failed to complete onboarding")}finally{c(!1)}},R=t===0?!!(n.trim()&&s.trim()&&nw.test(s)):t===2?!m||b:!0;return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs("div",{className:"w-full max-w-2xl",children:[i.jsx(EO,{currentStep:t}),i.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?i.jsx(SO,{gitName:n,gitEmail:s,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):t===1?i.jsx(kO,{providerStatuses:y,onOpenProviderLogin:k}):i.jsx(CO,{enabled:m,onEnabledChange:g,onReadyChange:x}),d&&i.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:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:d})}),i.jsxs("div",{className:"mt-8 flex items-center justify-between border-t border-border pt-6",children:[i.jsxs("button",{onClick:A,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:[i.jsx(jf,{className:"h-4 w-4"}),"Previous"]}),i.jsx("div",{className:"flex items-center gap-3",children:t<2?i.jsx("button",{onClick:_,disabled:!R||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?i.jsxs(i.Fragment,{children:[i.jsx(Dt,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):i.jsxs(i.Fragment,{children:["Next",i.jsx(An,{className:"h-4 w-4"})]})}):i.jsx("button",{onClick:C,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?i.jsxs(i.Fragment,{children:[i.jsx(Dt,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):i.jsxs(i.Fragment,{children:[i.jsx(nr,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&i.jsx(PE,{isOpen:!!p,onClose:()=>f(null),provider:p,onComplete:j})]})}const AO=["0s","0.1s","0.2s"];function jO(){return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"mb-4 flex justify-center",children:i.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:i.jsx(na,{className:"h-8 w-8 text-primary-foreground"})})}),i.jsx("h1",{className:"mb-2 text-2xl font-bold text-foreground",children:"Pixcode"}),i.jsx("div",{className:"flex items-center justify-center space-x-2",children:AO.map(e=>i.jsx("div",{className:"h-2 w-2 animate-bounce rounded-full bg-blue-500",style:{animationDelay:e}},e))}),i.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading..."})]})})}function FE({errorMessage:e}){return e?i.jsx("div",{className:"rounded-md border border-red-300 bg-red-100 p-3 dark:border-red-800 dark:bg-red-900/20",children:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:e})}):null}function Ri({id:e,label:t,value:r,onChange:n,placeholder:a,isDisabled:s,type:o="text",name:l,autoComplete:c}){return i.jsxs("div",{children:[i.jsx("label",{htmlFor:e,className:"mb-1 block text-sm font-medium text-foreground",children:t}),i.jsx("input",{id:e,type:o,name:l??e,autoComplete:c,value:r,onChange:d=>n(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:s})]})}function zE({title:e,description:t,children:r,footerText:n,logo:a}){return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsx("div",{className:"w-full max-w-md",children:i.jsxs("div",{className:"space-y-6 rounded-lg border border-border bg-card p-8 shadow-lg",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"mb-4 flex justify-center",children:a??i.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:i.jsx(na,{className:"h-8 w-8 text-primary-foreground"})})}),i.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e}),i.jsx("p",{className:"mt-2 text-muted-foreground",children:t})]}),r,i.jsx("div",{className:"text-center",children:i.jsx("p",{className:"text-sm text-muted-foreground",children:n})}),i.jsxs("div",{className:"flex items-center justify-center gap-1.5 pt-2",children:[i.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.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"})}),i.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 _O={username:"",password:""};function IO(){const{t:e}=Me("auth"),{login:t}=Yi(),[r,n]=h.useState(_O),[a,s]=h.useState(""),[o,l]=h.useState(!1),c=h.useCallback((u,p)=>{n(f=>({...f,[u]:p}))},[]),d=h.useCallback(async u=>{if(u.preventDefault(),s(""),!r.username.trim()||!r.password){s(e("login.errors.requiredFields"));return}l(!0);const p=await t(r.username.trim(),r.password);p.success||s(p.error),l(!1)},[r.password,r.username,t,e]);return i.jsx(zE,{title:e("login.title"),description:e("login.description"),footerText:"Enter your credentials to access Pixcode",children:i.jsxs("form",{onSubmit:d,className:"space-y-4",children:[i.jsx(Ri,{id:"username",label:e("login.username"),value:r.username,onChange:u=>c("username",u),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),i.jsx(Ri,{id:"password",label:e("login.password"),value:r.password,onChange:u=>c("password",u),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),i.jsx(FE,{errorMessage:a}),i.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 RO={username:"",password:"",confirmPassword:"",connectionMode:"local",remoteUrl:"",remoteApiKey:""};function LO(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.":e.connectionMode==="remote"&&!e.remoteUrl.trim()?"Remote Pixcode server URL is required.":null}function DO(){const{register:e}=Yi(),[t,r]=h.useState(RO),[n,a]=h.useState(""),[s,o]=h.useState(!1),l=h.useCallback((d,u)=>{r(p=>({...p,[d]:u}))},[]),c=h.useCallback(async d=>{d.preventDefault(),a("");const u=LO(t);if(u){a(u);return}o(!0);const p=await fetch("/api/auth/connection-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:t.connectionMode,remoteUrl:t.connectionMode==="remote"?t.remoteUrl.trim():null,apiKey:t.connectionMode==="remote"?t.remoteApiKey.trim():null})});if(!p.ok){const m=await p.json().catch(()=>null);a(m?.error||"Could not save connection mode."),o(!1);return}const f=await e(t.username.trim(),t.password);f.success||a(f.error),o(!1)},[t,e]);return i.jsx(zE,{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:i.jsx("img",{src:"/logo.svg",alt:"Pixcode",className:"h-16 w-16"}),children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsxs("div",{className:"grid gap-2 rounded-lg border border-border/70 bg-muted/30 p-2 sm:grid-cols-2",children:[i.jsxs("button",{type:"button",onClick:()=>l("connectionMode","local"),disabled:s,className:`rounded-md px-3 py-2 text-left text-sm transition-colors ${t.connectionMode==="local"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60 hover:text-foreground"}`,children:[i.jsx("span",{className:"block font-medium",children:"Use this computer directly"}),i.jsx("span",{className:"block text-xs opacity-80",children:"Run Pixcode and CLIs on this machine."})]}),i.jsxs("button",{type:"button",onClick:()=>l("connectionMode","remote"),disabled:s,className:`rounded-md px-3 py-2 text-left text-sm transition-colors ${t.connectionMode==="remote"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60 hover:text-foreground"}`,children:[i.jsx("span",{className:"block font-medium",children:"Connect to a remote Pixcode server"}),i.jsx("span",{className:"block text-xs opacity-80",children:"Control another always-on Pixcode host by API."})]})]}),t.connectionMode==="remote"&&i.jsxs("div",{className:"space-y-3 rounded-lg border border-border/70 bg-muted/20 p-3",children:[i.jsx(Ri,{id:"remoteUrl",name:"remoteUrl",label:"Remote API URL",value:t.remoteUrl,onChange:d=>l("remoteUrl",d),placeholder:"https://your-server.example.com",isDisabled:s,autoComplete:"url"}),i.jsx(Ri,{id:"remoteApiKey",name:"remoteApiKey",label:"Remote API Key",value:t.remoteApiKey,onChange:d=>l("remoteApiKey",d),placeholder:"px_...",isDisabled:s,type:"password",autoComplete:"off"})]}),i.jsx(Ri,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:s,autoComplete:"username"}),i.jsx(Ri,{id:"password",name:"password",label:"Password",value:t.password,onChange:d=>l("password",d),placeholder:"Enter your password",isDisabled:s,type:"password",autoComplete:"new-password"}),i.jsx(Ri,{id:"confirmPassword",name:"confirmPassword",label:"Confirm Password",value:t.confirmPassword,onChange:d=>l("confirmPassword",d),placeholder:"Confirm your password",isDisabled:s,type:"password",autoComplete:"new-password"}),i.jsx(FE,{errorMessage:n}),i.jsx("button",{type:"submit",disabled:s,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:s?"Setting up...":"Create Account"})]})})}function OO({children:e}){const{user:t,isLoading:r,needsSetup:n,hasCompletedOnboarding:a,refreshOnboardingStatus:s}=Yi();return r?i.jsx(jO,{}):n?i.jsx(DO,{}):t?a?i.jsx(i.Fragment,{children:e}):i.jsx(TO,{onComplete:s}):i.jsx(IO,{})}const BE=h.createContext(null),$E=()=>{const e=h.useContext(BE);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},MO=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},PO=()=>{const e=h.useRef(null),t=h.useRef(!1),r=h.useRef(!1),[n,a]=h.useState(null),[s,o]=h.useState(!1),l=h.useRef(null),{token:c}=Yi(),d=h.useCallback(()=>{if(!t.current)try{const f=MO(c);if(!f)return console.warn("No authentication token found for WebSocket connection");const m=new WebSocket(f);m.onopen=()=>{o(!0),e.current=m,r.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),r.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(f){console.error("Error creating WebSocket connection:",f)}},[c]);h.useEffect(()=>(d(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[d]);const u=h.useCallback(f=>{const m=e.current;m&&m.readyState===WebSocket.OPEN?m.send(JSON.stringify(f)):console.warn("WebSocket not connected")},[]);return h.useMemo(()=>({ws:e.current,sendMessage:u,latestMessage:n,isConnected:s}),[u,n,s])},FO=({children:e})=>{const t=PO();return i.jsx(BE.Provider,{value:t,children:e})},UE=h.createContext(null);function zO(e,t){return{message:t instanceof Error?t.message:`Failed to ${e}`,context:e,timestamp:new Date().toISOString()}}function iw(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 BO(e){return e.find(t=>t.status==="pending"||t.status==="in-progress")??null}function $O(e){return e?.type?e.type.startsWith("taskmaster-"):!1}function no(){const e=h.useContext(UE);if(!e)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return e}function UO({children:e}){const{latestMessage:t}=$E(),{user:r,token:n,isLoading:a}=Yi(),[s,o]=h.useState([]),[l,c]=h.useState(null),[d,u]=h.useState(null),[p,f]=h.useState(null),[m,g]=h.useState([]),[b,x]=h.useState(null),[y,v]=h.useState(!1),[w,S]=h.useState(!1),[E,k]=h.useState(!1),[j,_]=h.useState(null),A=h.useRef(null);h.useEffect(()=>{A.current=l?.name??null},[l?.name]);const C=h.useCallback(()=>{_(null)},[]),R=h.useCallback((z,U)=>{console.error(`TaskMaster ${z} error:`,U),_(zO(z,U))},[]),T=h.useCallback(z=>{const U=z?iw(z):null;c(U),u(U?.taskmaster??null),g([]),x(null)},[]),I=h.useCallback(async()=>{if(!r||!n){o([]),c(null),u(null),g([]),x(null);return}try{v(!0),C();const z=await ot.get("/projects");if(!z.ok)throw new Error(`Failed to fetch projects: ${z.status}`);const U=await z.json(),O=(Array.isArray(U)?U:[]).map(F=>iw(F));o(O);const H=A.current;if(!H)return;const $=O.find(F=>F.name===H)??null;c($),u($?.taskmaster??null)}catch(z){R("load projects",z)}finally{v(!1)}},[C,R,n,r]),N=h.useCallback(async()=>{const z=l?.name;if(!z||!r||!n){g([]),x(null);return}try{S(!0),C();const U=await ot.get(`/taskmaster/tasks/${encodeURIComponent(z)}`);if(!U.ok){const H=await U.json();throw new Error(H.message??"Failed to load tasks")}const V=await U.json(),O=Array.isArray(V.tasks)?V.tasks:[];g(O),x(BO(O))}catch(U){R("load tasks",U),g([]),x(null)}finally{S(!1)}},[C,l?.name,R,n,r]),P=h.useCallback(async()=>{if(!r||!n){f(null);return}try{k(!0),C();const z=await ot.get("/mcp-utils/taskmaster-server");if(!z.ok)throw new Error(`Failed to load MCP status: ${z.status}`);const U=await z.json();f(U)}catch(z){R("check MCP server status",z),f(null)}finally{k(!1)}},[C,R,n,r]);h.useEffect(()=>{!a&&r&&n&&(I(),P())},[a,P,I,n,r]),h.useEffect(()=>{l?.name&&r&&n&&N()},[l?.name,N,n,r]),h.useEffect(()=>{const z=t;if($O(z)){if(z.type==="taskmaster-project-updated"&&z.projectName){I();return}if(z.type==="taskmaster-tasks-updated"&&z.projectName===l?.name){N();return}z.type==="taskmaster-mcp-status-changed"&&P()}},[l?.name,t,P,I,N]);const G=h.useMemo(()=>({projects:s,currentProject:l,projectTaskMaster:d,mcpServerStatus:p,tasks:m,nextTask:b,isLoading:y,isLoadingTasks:w,isLoadingMCP:E,error:j,refreshProjects:I,setCurrentProject:T,refreshTasks:N,refreshMCPStatus:P,clearError:C}),[C,l,j,y,E,w,p,b,d,s,P,I,N,T,m]);return i.jsx(UE.Provider,{value:G,children:e})}const GE=h.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0,refreshTaskMasterInstallation:async()=>{}}),Qd=()=>{const e=h.useContext(GE);if(!e)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return e},GO=({children:e})=>{const{user:t,token:r,isLoading:n}=Yi(),[a,s]=h.useState(()=>{const v=localStorage.getItem("tasks-enabled");return v!==null?JSON.parse(v):!0}),[o,l]=h.useState(null),[c,d]=h.useState(null),[u,p]=h.useState(null),[f,m]=h.useState(!0),g=!!(t&&r);h.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(a))},[a]);const b=h.useCallback(async({signal:v}={})=>{if(!n){if(!g){p(null),l(null),d(null),m(!1);return}m(!0);try{const w=await ot.get("/taskmaster/installation-status");if(v?.aborted)return;if(w.ok){const S=await w.json();if(v?.aborted)return;p(S),l(S.installation?.isInstalled||!1),d(S.isReady||!1);const E=localStorage.getItem("tasks-enabled");!S.installation?.isInstalled&&!E&&s(!1)}else console.error("Failed to check TaskMaster installation status"),l(!1),d(!1)}catch(w){if(v?.aborted)return;console.error("Error checking TaskMaster installation:",w),l(!1),d(!1)}finally{v?.aborted||m(!1)}}},[g,n]);h.useEffect(()=>{const v=new AbortController,w=setTimeout(()=>{b({signal:v.signal})},0);return()=>{v.abort(),clearTimeout(w)}},[b]);const y={tasksEnabled:a,setTasksEnabled:s,toggleTasksEnabled:()=>{s(v=>!v)},isTaskMasterInstalled:o,isTaskMasterReady:c,installationStatus:u,isCheckingInstallation:f,refreshTaskMasterInstallation:b};return i.jsx(GE.Provider,{value:y,children:e})},HE=h.createContext(null);function eu(){const e=h.useContext(HE);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function HO({children:e}){const{user:t,token:r,isLoading:n}=Yi(),[a,s]=h.useState([]),[o,l]=h.useState(!0),[c,d]=h.useState(null),u=!!(t&&r),p=h.useCallback(async()=>{if(!u){s([]),d(null),l(!1);return}l(!0);try{const x=await ve("/api/plugins");if(x.ok){const y=await x.json();s(y.plugins||[]),d(null)}else{let y=`Failed to fetch plugins (${x.status})`;try{const v=await x.json();y=v.details||v.error||y}catch{y=x.statusText||y}d(y)}}catch(x){const y=x instanceof Error?x.message:"Failed to fetch plugins";d(y),console.error("[Plugins] Failed to fetch plugins:",x)}finally{l(!1)}},[u]);h.useEffect(()=>{n||p()},[n,p]);const f=h.useCallback(async x=>{try{const y=await ve("/api/plugins/install",{method:"POST",body:JSON.stringify({url:x})}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Install failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Install failed"}}},[p]),m=h.useCallback(async x=>{try{const y=await ve(`/api/plugins/${encodeURIComponent(x)}`,{method:"DELETE"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Uninstall failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Uninstall failed"}}},[p]),g=h.useCallback(async x=>{try{const y=await ve(`/api/plugins/${encodeURIComponent(x)}/update`,{method:"POST"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Update failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Update failed"}}},[p]),b=h.useCallback(async(x,y)=>{try{const v=await ve(`/api/plugins/${encodeURIComponent(x)}/enable`,{method:"PUT",body:JSON.stringify({enabled:y})});if(!v.ok){let w=`Toggle failed (${v.status})`;try{const S=await v.json();w=S.details||S.error||w}catch{w=v.statusText||w}return{success:!1,error:w}}return await p(),{success:!0,error:null}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Toggle failed"}}},[p]);return i.jsx(HE.Provider,{value:{plugins:a,loading:o,pluginsError:c,refreshPlugins:p,installPlugin:f,uninstallPlugin:m,updatePlugin:g,togglePlugin:b},children:e})}const sw=e=>typeof window>"u"?!1:window.innerWidth<e,ow=()=>{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 Ff(e={}){const{mobileBreakpoint:t=768,trackMobile:r=!0,trackPWA:n=!0}=e,[a,s]=h.useState(()=>r?sw(t):!1),[o,l]=h.useState(()=>n?ow():!1);return h.useEffect(()=>{if(!r||typeof window>"u")return;const c=()=>{s(sw(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,r]),h.useEffect(()=>{if(!n||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),d=()=>{l(ow())};return d(),typeof c.addEventListener=="function"?(c.addEventListener("change",d),()=>{c.removeEventListener("change",d)}):(c.addListener(d),()=>{c.removeListener(d)})},[n]),{isMobile:a,isPWA:o}}const zf="pixcode.updateCheck.preferences",th="pixcode:update-check-settings-changed",Bf=[{value:"30m",label:"Every 30 minutes",intervalMs:1800*1e3},{value:"24h",label:"Daily",intervalMs:1440*60*1e3},{value:"12h",label:"Every 12 hours",intervalMs:720*60*1e3},{value:"6h",label:"Every 6 hours",intervalMs:360*60*1e3},{value:"7d",label:"Weekly",intervalMs:10080*60*1e3},{value:"off",label:"Manual only",intervalMs:null}],rh={frequency:"30m"};function lw(e){return Bf.find(t=>t.value===e.frequency)?.intervalMs??null}function VE(e){if(!e||typeof e!="object")return rh;const t=e.frequency;return Bf.some(r=>r.value===t)?{frequency:t}:rh}function cw(){try{const e=localStorage.getItem(zf);return VE(e?JSON.parse(e):null)}catch{return rh}}function VO(e){const t=VE(e);localStorage.setItem(zf,JSON.stringify(t)),window.dispatchEvent(new CustomEvent(th,{detail:t}))}const qu=(e,t)=>{const r=e.split(".").map(Number),n=t.split(".").map(Number);for(let a=0;a<Math.max(r.length,n.length);a++){const s=r[a]||0,o=n[a]||0;if(s!==o)return s-o}return 0},qO="1.41.3",nh="pixcode:update-available",WO=360*60*1e3,Wu=new Map;function qE(e,t){return`pixcode.updateCheck.cache.${e}.${t}`}function KO(e,t){try{const r=localStorage.getItem(qE(e,t));if(!r)return null;const n=JSON.parse(r);return{fetchedAt:typeof n.fetchedAt=="number"?n.fetchedAt:null,latestVersion:typeof n.latestVersion=="string"?n.latestVersion:null,releaseInfo:n.releaseInfo??null,rateLimitedUntil:typeof n.rateLimitedUntil=="number"?n.rateLimitedUntil:void 0}}catch{return null}}function dw(e,t,r){localStorage.setItem(qE(e,t),JSON.stringify(r))}function YO(e,t){const r=`${e}/${t}`,n=Wu.get(r);if(n)return n;const a=fetch(`https://api.github.com/repos/${e}/${t}/releases/latest`,{cache:"no-store",headers:{Accept:"application/vnd.github+json"}}).then(async s=>({status:s.status,ok:s.ok,data:await s.json().catch(()=>({}))})).finally(()=>{Wu.delete(r)});return Wu.set(r,a),a}const WE=(e,t)=>{const[r,n]=h.useState(!1),[a,s]=h.useState(null),[o,l]=h.useState(null),[c,d]=h.useState("git"),[u,p]=h.useState("idle"),[f,m]=h.useState(null),[g,b]=h.useState(()=>cw()),[x,y]=h.useState(qO),v=h.useRef(null),w=h.useCallback(E=>{VO(E),b(E)},[]);h.useEffect(()=>{const E=()=>b(cw()),k=j=>{j.key===zf&&E()};return window.addEventListener("storage",k),window.addEventListener(th,E),()=>{window.removeEventListener("storage",k),window.removeEventListener(th,E)}},[]),h.useEffect(()=>{let E=!1;const k=async()=>{try{const A=await(await fetch("/health",{cache:"no-store"})).json();if(E)return;(A.installMode==="npm"||A.installMode==="git")&&d(A.installMode),typeof A.version=="string"&&/^\d+\.\d+\.\d+/.test(A.version)&&y(A.version)}catch{}};k();const j=()=>{k()};return window.addEventListener("focus",j),()=>{E=!0,window.removeEventListener("focus",j)}},[]),h.useEffect(()=>{if(!x)return;let E=!1;const k=(T,I,N,P)=>({updateAvailable:!!(T&&qu(T,x)>0),latestVersion:T,releaseInfo:I,currentVersion:x,checkedAt:N,status:P}),j=T=>{!T.updateAvailable||!T.latestVersion||!T.releaseInfo||window.dispatchEvent(new CustomEvent(nh,{detail:T}))},_=(T,I,N,P="success")=>{if(!T||!I)return n(!1),s(null),l(null),m(N),k(null,null,N,P);s(T),n(qu(T,x)>0),l(I),m(N);const G=k(T,I,N,P);return j(G),G},A=async({force:T=!1}={})=>{const I=lw(g),N=KO(e,t),P=Date.now();if(!T&&I===null)return p("idle"),_(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"idle");if(!T&&N?.fetchedAt&&I!==null&&P-N.fetchedAt<I)return p("success"),_(N.latestVersion,N.releaseInfo,N.fetchedAt,"success");if(!T&&N?.rateLimitedUntil&&N.rateLimitedUntil>P)return p("error"),_(N.latestVersion,N.releaseInfo,N.fetchedAt,"error");try{p("checking");const G=await YO(e,t);if(E)return k(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"idle");const z=G.data;if(!G.ok)return G.status===403&&dw(e,t,{fetchedAt:N?.fetchedAt??null,latestVersion:N?.latestVersion??null,releaseInfo:N?.releaseInfo??null,rateLimitedUntil:P+Math.max(I??0,WO)}),p("error"),_(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"error");if(z.tag_name){const U=z.tag_name.replace(/^v/,""),V=qu(U,x)>0,O={title:z.name||z.tag_name,body:z.body||"",htmlUrl:z.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:z.published_at||""};dw(e,t,{fetchedAt:P,latestVersion:U,releaseInfo:O}),s(U),n(V),V&&J4({key:`app-update:${U}`,title:"Pixcode update available",body:`Pixcode ${x} can update to ${U}.`,tag:"pixcode-app-update",data:{type:"app-update",latestVersion:U,installMode:c}}),l(O),p("success"),m(P);const H=k(U,O,P,"success");return j(H),H}else return n(!1),s(null),l(null),p("error"),k(null,null,null,"error")}catch(G){return console.error("Version check failed:",G),n(!1),s(null),l(null),p("error"),k(null,null,null,"error")}};v.current=A,A();const C=lw(g),R=C===null?null:window.setInterval(()=>{A()},C);return()=>{E=!0,R!==null&&window.clearInterval(R)}},[e,t,x,c,g]);const S=h.useCallback(async()=>v.current?await v.current({force:!0}):null,[]);return{updateAvailable:r,latestVersion:a,currentVersion:x,releaseInfo:o,installMode:c,checkStatus:u,lastCheckedAt:f,manualCheck:S,updateCheckPreferences:g,updatePreferences:w}},Li={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,changeAwareness:!1,sidebarVisible:!0,historyView:"flat"},ZO=["flat","grouped"],XO=e=>typeof e=="string"&&ZO.includes(e),ud=Object.keys(Li),JO=new Set(ud),Ku="ui-preferences:sync",QO=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},pd=(e,t,r)=>e==="historyView"?XO(t)?t:r:QO(t,r),e9=(e,t)=>{try{const r=localStorage.getItem(e);if(r===null)return t;const n=JSON.parse(r);return pd(e,n,t)}catch{return t}},t9=e=>{if(typeof window>"u")return Li;try{const t=localStorage.getItem(e);if(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&!Array.isArray(r)){const n=r;return ud.reduce((a,s)=>(a[s]=pd(s,n[s],Li[s]),a),{...Li})}}}catch{}return ud.reduce((t,r)=>(t[r]=e9(r,Li[r]),t),{...Li})};function r9(e,t){switch(t.type){case"set":{const{key:r,value:n}=t;if(!JO.has(r))return e;const a=pd(r,n,e[r]);return e[r]===a?e:{...e,[r]:a}}case"set_many":{const r=t.value||{};let n=!1;const a={...e};for(const s of ud){if(!(s in r))continue;const o=r[s],l=pd(s,o,e[s]);a[s]!==l&&(a[s]=l,n=!0)}return n?a:e}case"reset":return{...Li,...t.value||{}};default:return e}}function $f(e="uiPreferences"){const t=h.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,n]=h.useReducer(r9,e,t9);return h.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(Ku,{detail:{storageKey:e,sourceId:t.current,value:r}})))},[r,e]),h.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||n({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 f=u.detail;!f||f.storageKey!==e||f.sourceId===t.current||l(f.value)};return window.addEventListener("storage",c),window.addEventListener(Ku,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(Ku,d)}},[e]),{preferences:r,setPreference:(l,c)=>{n({type:"set",key:l,value:c})},setPreferences:l=>{n({type:"set_many",value:l})},resetPreferences:l=>{n({type:"reset",value:l})},dispatch:n}}const n9=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},a9=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},i9=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},uw=(e,t)=>`${e}::${t}`,s9=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},o9=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},l9=/(?:^|[\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,c9=e=>{if(!e)return[];const t=new Set,r=new RegExp(l9.source,"gi");let n;for(;(n=r.exec(e))!==null;){const a=n[1],s=a.lastIndexOf(".");if(s>-1){const o=a.slice(s+1).toLowerCase();o&&o.length<=10&&t.add(o)}if(t.size>=3)break}return[...t]},zi=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),d9=(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"),u9=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),p9=(e,t,r)=>{const n=zi(e),a=Math.floor((t.getTime()-n.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:d9(e,r),sessionTime:u9(e),messageCount:Number(e.messageCount||0)}},KE=(e,t)=>{const r=[...e.sessions||[],...t[e.name]||[]].map(g=>({...g,__provider:"claude"})),n=(e.cursorSessions||[]).map(g=>({...g,__provider:"cursor"})),a=(e.codexSessions||[]).map(g=>({...g,__provider:"codex"})),s=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=>!s(g)&&!o(g)).map(g=>({...g,__provider:"gemini"})),d=l.filter(g=>s(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],f=[...(e.opencodeSessions||[]).map(g=>({...g,__provider:"opencode"})),...u],m=new Map;for(const g of[...r,...n,...a,...c,...p,...f])m.has(g.id)||m.set(g.id,g);return[...m.values()].sort((g,b)=>zi(b).getTime()-zi(g).getTime())},pw=(e,t)=>{const r=KE(e,t);return r.length===0?new Date(0):r.reduce((n,a)=>{const s=zi(a);return s>n?s:n},new Date(0))},m9=(e,t,r,n)=>{const a=[...e];return a.sort((s,o)=>{const l=r.has(s.name),c=r.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?pw(o,n).getTime()-pw(s,n).getTime():(s.displayName||s.name).localeCompare(o.displayName||o.name)}),a},h9=(e,t)=>{const r=t.trim().toLowerCase();return r?e.filter(n=>{const a=(n.displayName||n.name).toLowerCase(),s=n.name.toLowerCase();return a.includes(r)||s.includes(r)}):e},f9=(e,t)=>{const r=!!e.taskmaster?.hasTaskmaster,n=!!(t?.hasMCPServer&&t?.isConfigured);return r&&n?"fully-configured":r?"taskmaster-only":n?"mcp-only":"not-configured"},g9=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 b9({projects:e,selectedProject:t,selectedSession:r,isLoading:n,isMobile:a,t:s,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:d,onProjectDelete:u,setCurrentProject:p,setSidebarVisible:f,sidebarVisible:m}){const[g,b]=h.useState(new Set),[x,y]=h.useState(null),[v,w]=h.useState(!1),[S,E]=h.useState(""),[k,j]=h.useState({}),[_,A]=h.useState({}),[C,R]=h.useState(new Set),[T,I]=h.useState(new Date),[N,P]=h.useState("name"),[G,z]=h.useState(!1),[U,V]=h.useState({}),[O,H]=h.useState(null),[$,F]=h.useState(""),[ne,ee]=h.useState(""),[ge,ie]=h.useState(new Set),[me,pe]=h.useState(null),[be,Ee]=h.useState(null),[xe,Ue]=h.useState(!1),[M,de]=h.useState(()=>a9()),[ce,Y]=h.useState(()=>s9()),[W,ae]=h.useState("projects"),[fe,ye]=h.useState(null),[oe,we]=h.useState(!1),[te,X]=h.useState(null),Z=h.useRef(null),le=h.useRef(0),ke=h.useRef(null),Te=!a&&!m;h.useEffect(()=>{const Se=setInterval(()=>{I(new Date)},6e4);return()=>clearInterval(Se)},[]),h.useEffect(()=>{A({}),R(new Set),V({})},[e]),h.useEffect(()=>{t&&b(Se=>{if(Se.has(t.name))return Se;const Ae=new Set(Se);return Ae.add(t.name),Ae})},[r,t]),h.useEffect(()=>{if(e.length>0&&!n){const Se=new Set;e.forEach(Ae=>{Ae.sessions&&Ae.sessions.length>=0&&Se.add(Ae.name)}),R(Se)}},[e,n]),h.useEffect(()=>{const Se=()=>{P(n9())};Se();const Ae=He=>{He.key==="claude-settings"&&Se()},Ye=()=>Se();return window.addEventListener("storage",Ae),window.addEventListener("pixcode:settings-changed",Ye),()=>{window.removeEventListener("storage",Ae),window.removeEventListener("pixcode:settings-changed",Ye)}},[]),h.useEffect(()=>{Z.current&&clearTimeout(Z.current),ke.current&&(ke.current.close(),ke.current=null);const Se=ne.trim();if(W!=="conversations"||Se.length<2){le.current+=1,ye(null),X(null),we(!1);return}we(!0);const Ae=++le.current;return Z.current=setTimeout(()=>{if(Ae!==le.current)return;const Ye=ot.searchConversationsUrl(Se),He=new EventSource(Ye);ke.current=He;const Ve=[];let Ne=0;He.addEventListener("result",$e=>{if(Ae!==le.current){He.close();return}try{const Fe=JSON.parse($e.data);Ve.push(Fe.projectResult),Ne=Fe.totalMatches,ye({results:[...Ve],totalMatches:Ne,query:Se}),X({scannedProjects:Fe.scannedProjects,totalProjects:Fe.totalProjects})}catch{}}),He.addEventListener("progress",$e=>{if(Ae!==le.current){He.close();return}try{const Fe=JSON.parse($e.data);Ne=Fe.totalMatches,X({scannedProjects:Fe.scannedProjects,totalProjects:Fe.totalProjects})}catch{}}),He.addEventListener("done",()=>{if(Ae!==le.current){He.close();return}He.close(),ke.current=null,we(!1),X(null),Ve.length===0&&ye({results:[],totalMatches:0,query:Se})}),He.addEventListener("error",()=>{if(Ae!==le.current){He.close();return}He.close(),ke.current=null,we(!1),X(null),Ve.length===0&&ye({results:[],totalMatches:0,query:Se})})},400),()=>{Z.current&&clearTimeout(Z.current),ke.current&&(ke.current.close(),ke.current=null)}},[ne,W]);const Ke=h.useCallback(Se=>{b(Ae=>{const Ye=new Set;return Ae.has(Se)||Ye.add(Se),Ye})},[]),Qe=h.useCallback((Se,Ae)=>{c({...Se,__projectName:Ae})},[c]),xt=h.useCallback(Se=>{de(Ae=>{const Ye=new Set(Ae);return Ye.has(Se)?Ye.delete(Se):Ye.add(Se),i9(Ye),Ye})},[]),Xe=h.useCallback(Se=>M.has(Se),[M]),At=h.useCallback((Se,Ae)=>{Y(Ye=>{const He=uw(Se,Ae),Ve=new Set(Ye);return Ve.has(He)?Ve.delete(He):Ve.add(He),o9(Ve),Ve})},[]),vt=h.useCallback((Se,Ae)=>ce.has(uw(Se,Ae)),[ce]),st=h.useCallback(Se=>KE(Se,_),[_]),lt=h.useMemo(()=>e.map(Se=>{const Ae=U[Se.name];return Ae===void 0?Se:{...Se,sessionMeta:{...Se.sessionMeta,hasMore:Ae}}}),[U,e]),kt=h.useMemo(()=>m9(lt,N,M,_),[_,N,lt,M]),Pt=h.useMemo(()=>h9(kt,ne),[ne,kt]),jt=h.useCallback(Se=>{y(Se.name),E(Se.displayName)},[]),fr=h.useCallback(()=>{y(null),E("")},[]),Ft=h.useCallback(async Se=>{try{(await ot.renameProject(Se,S)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(Ae){console.error("Error renaming project:",Ae)}finally{y(null),E("")}},[S]),Ut=h.useCallback((Se,Ae,Ye,He="claude")=>{Ee({projectName:Se,sessionId:Ae,sessionTitle:Ye,provider:He})},[]),Br=h.useCallback(async()=>{if(!be)return;const{projectName:Se,sessionId:Ae,provider:Ye}=be;Ee(null);try{let He;if(Ye==="codex"?He=await ot.deleteCodexSession(Ae):Ye==="gemini"?He=await ot.deleteGeminiSession(Ae):Ye==="qwen"?He=await ot.deleteQwenSession(Ae):He=await ot.deleteSession(Se,Ae),He.ok)d?.(Ae);else{const Ve=await He.text();console.error("[Sidebar] Failed to delete session:",{status:He.status,error:Ve}),alert(s("messages.deleteSessionFailed"))}}catch(He){console.error("[Sidebar] Error deleting session:",He),alert(s("messages.deleteSessionError"))}},[d,be,s]),De=h.useCallback(Se=>{pe({project:Se,sessionCount:st(Se).length})},[st]),Je=h.useCallback(async(Se=!1)=>{if(!me)return;const{project:Ae,sessionCount:Ye}=me,He=Ye===0;pe(null),ie(Ve=>new Set([...Ve,Ae.name]));try{const Ve=await ot.deleteProject(Ae.name,!He,Se);if(Ve.ok)u?.(Ae.name);else{const Ne=await Ve.json();alert(Ne.error||s("messages.deleteProjectFailed"))}}catch(Ve){console.error("Error deleting project:",Ve),alert(s("messages.deleteProjectError"))}finally{ie(Ve=>{const Ne=new Set(Ve);return Ne.delete(Ae.name),Ne})}},[me,u,s]),et=h.useCallback(async Se=>{const Ae=U[Se.name];if(!(!(Ae!==void 0?Ae:Se.sessionMeta?.hasMore===!0)||k[Se.name])){j(He=>({...He,[Se.name]:!0}));try{const He=(Se.sessions?.length||0)+(_[Se.name]?.length||0),Ve=await ot.sessions(Se.name,5,He);if(!Ve.ok)return;const Ne=await Ve.json();A($e=>({...$e,[Se.name]:[...$e[Se.name]||[],...Ne.sessions||[]]})),Ne.hasMore===!1&&V($e=>({...$e,[Se.name]:!1}))}catch(He){console.error("Error loading more sessions:",He)}finally{j(He=>({...He,[Se.name]:!1}))}}},[_,k,U]),Nt=h.useCallback(Se=>{l(Se),p(Se)},[l,p]),ze=h.useCallback(async()=>{z(!0);try{await o()}finally{z(!1)}},[o]),Q=h.useCallback(async(Se,Ae,Ye,He)=>{const Ve=Ye.trim();if(!Ve){H(null),F("");return}try{const Ne=await ot.renameSession(Ae,Ve,He);Ne.ok?await o():(console.error("[Sidebar] Failed to rename session:",Ne.status),alert(s("messages.renameSessionFailed")))}catch(Ne){console.error("[Sidebar] Error renaming session:",Ne),alert(s("messages.renameSessionError"))}finally{H(null),F("")}},[o,s]),Le=h.useCallback(()=>{f(!1)},[f]),Oe=h.useCallback(()=>{f(!0)},[f]);return{isSidebarCollapsed:Te,expandedProjects:g,editingProject:x,showNewProject:v,editingName:S,loadingSessions:k,additionalSessions:_,initialSessionsLoaded:C,currentTime:T,projectSortOrder:N,isRefreshing:G,editingSession:O,editingSessionName:$,searchFilter:ne,deletingProjects:ge,deleteConfirmation:me,sessionDeleteConfirmation:be,showVersionModal:xe,starredProjects:M,starredSessions:ce,filteredProjects:Pt,toggleProject:Ke,handleSessionClick:Qe,toggleStarProject:xt,isProjectStarred:Xe,toggleStarSession:At,isSessionStarred:vt,getProjectSessions:st,startEditing:jt,cancelEditing:fr,saveProjectName:Ft,showDeleteSessionConfirmation:Ut,confirmDeleteSession:Br,requestProjectDelete:De,confirmDeleteProject:Je,loadMoreSessions:et,handleProjectSelect:Nt,refreshProjects:ze,updateSessionSummary:Q,collapseSidebar:Le,expandSidebar:Oe,setShowNewProject:w,setEditingName:E,setEditingSession:H,setEditingSessionName:F,searchMode:W,setSearchMode:ae,conversationResults:fe,isSearching:oe,searchProgress:te,clearConversationResults:h.useCallback(()=>{le.current+=1,ke.current&&(ke.current.close(),ke.current=null),we(!1),X(null),ye(null)},[]),setSearchFilter:ee,setDeleteConfirmation:pe,setSessionDeleteConfirmation:Ee,setShowVersionModal:Ue}}const x9="https://discord.gg/buxwujPNRE",y9="https://github.com/alicomert/pixcode/issues/new";function v9({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.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 w9({onExpand:e,onShowSettings:t,updateAvailable:r,onShowVersionModal:n,t:a}){return i.jsxs("div",{className:"flex h-full w-12 flex-col items-center gap-1 bg-background/80 py-3 backdrop-blur-sm",children:[i.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:i.jsx(CD,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("div",{className:"nav-divider my-1 w-6"}),i.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:i.jsx(Rt,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:y9,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:i.jsx(gl,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:x9,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:i.jsx(v9,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),r&&i.jsxs("button",{onClick:n,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:[i.jsx(Ca,{className:"h-4 w-4 text-blue-500"}),i.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]})]})}function YE(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=YE(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function ZE(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=YE(e))&&(n&&(n+=" "),n+=t);return n}const mw=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,hw=ZE,Uf=(e,t)=>r=>{var n;if(t?.variants==null)return hw(e,r?.class,r?.className);const{variants:a,defaultVariants:s}=t,o=Object.keys(a).map(d=>{const u=r?.[d],p=s?.[d];if(u===null)return null;const f=mw(u)||mw(p);return a[d][f]}),l=r&&Object.entries(r).reduce((d,u)=>{let[p,f]=u;return f===void 0||(d[p]=f),d},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((d,u)=>{let{class:p,className:f,...m}=u;return Object.entries(m).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...s,...l}[b]):{...s,...l}[b]===x})?[...d,p,f]:d},[]);return hw(e,o,c,r?.class,r?.className)},Gf="-",k9=e=>{const t=E9(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(Gf);return l[0]===""&&l.length!==1&&l.shift(),XE(l,t)||S9(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},XE=(e,t)=>{if(e.length===0)return t.classGroupId;const r=e[0],n=t.nextPart.get(r),a=n?XE(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const s=e.join(Gf);return t.validators.find(({validator:o})=>o(s))?.classGroupId},fw=/^\[(.+)\]$/,S9=e=>{if(fw.test(e)){const t=fw.exec(e)[1],r=t?.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},E9=e=>{const{theme:t,classGroups:r}=e,n={nextPart:new Map,validators:[]};for(const a in r)ah(r[a],n,a,t);return n},ah=(e,t,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const s=a===""?t:gw(t,a);s.classGroupId=r;return}if(typeof a=="function"){if(N9(a)){ah(a(n),t,r,n);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([s,o])=>{ah(o,gw(t,s),r,n)})})},gw=(e,t)=>{let r=e;return t.split(Gf).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},N9=e=>e.isThemeGetter,C9=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,n=new Map;const a=(s,o)=>{r.set(s,o),t++,t>e&&(t=0,n=r,r=new Map)};return{get(s){let o=r.get(s);if(o!==void 0)return o;if((o=n.get(s))!==void 0)return a(s,o),o},set(s,o){r.has(s)?r.set(s,o):a(s,o)}}},ih="!",sh=":",T9=sh.length,A9=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const s=[];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===sh){s.push(a.slice(c,g)),c=g+T9;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=s.length===0?a:a.substring(c),p=j9(u),f=p!==u,m=d&&d>c?d-c:void 0;return{modifiers:s,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}};if(t){const a=t+sh,s=n;n=o=>o.startsWith(a)?s(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(r){const a=n;n=s=>r({className:s,parseClassName:a})}return n},j9=e=>e.endsWith(ih)?e.substring(0,e.length-1):e.startsWith(ih)?e.substring(1):e,_9=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(n=>[n,!0]));return n=>{if(n.length<=1)return n;const a=[];let s=[];return n.forEach(o=>{o[0]==="["||t[o]?(a.push(...s.sort(),o),s=[]):s.push(o)}),a.push(...s.sort()),a}},I9=e=>({cache:C9(e.cacheSize),parseClassName:A9(e),sortModifiers:_9(e),...k9(e)}),R9=/\s+/,L9=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:s}=t,o=[],l=e.trim().split(R9);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:f,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:b}=r(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,y=n(x?g.substring(0,b):g);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=n(g),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const v=s(f).join(":"),w=m?v+ih: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 j=E[k];o.push(w+j)}c=u+(c.length>0?" "+c:c)}return c};function D9(){let e=0,t,r,n="";for(;e<arguments.length;)(t=arguments[e++])&&(r=JE(t))&&(n&&(n+=" "),n+=r);return n}const JE=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=JE(e[n]))&&(r&&(r+=" "),r+=t);return r};function O9(e,...t){let r,n,a,s=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return r=I9(d),n=r.cache.get,a=r.cache.set,s=l,l(c)}function l(c){const d=n(c);if(d)return d;const u=L9(c,r);return a(c,u),u}return function(){return s(D9.apply(null,arguments))}}const pr=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},QE=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,eN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,M9=/^\d+\/\d+$/,P9=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,F9=/\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$/,z9=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,B9=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$9=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ds=e=>M9.test(e),pt=e=>!!e&&!Number.isNaN(Number(e)),Ua=e=>!!e&&Number.isInteger(Number(e)),Yu=e=>e.endsWith("%")&&pt(e.slice(0,-1)),ma=e=>P9.test(e),U9=()=>!0,G9=e=>F9.test(e)&&!z9.test(e),tN=()=>!1,H9=e=>B9.test(e),V9=e=>$9.test(e),q9=e=>!qe(e)&&!We(e),W9=e=>ao(e,aN,tN),qe=e=>QE.test(e),wi=e=>ao(e,iN,G9),Zu=e=>ao(e,J9,pt),bw=e=>ao(e,rN,tN),K9=e=>ao(e,nN,V9),ic=e=>ao(e,sN,H9),We=e=>eN.test(e),Ro=e=>io(e,iN),Y9=e=>io(e,Q9),xw=e=>io(e,rN),Z9=e=>io(e,aN),X9=e=>io(e,nN),sc=e=>io(e,sN,!0),ao=(e,t,r)=>{const n=QE.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},io=(e,t,r=!1)=>{const n=eN.exec(e);return n?n[1]?t(n[1]):r:!1},rN=e=>e==="position"||e==="percentage",nN=e=>e==="image"||e==="url",aN=e=>e==="length"||e==="size"||e==="bg-size",iN=e=>e==="length",J9=e=>e==="number",Q9=e=>e==="family-name",sN=e=>e==="shadow",eM=()=>{const e=pr("color"),t=pr("font"),r=pr("text"),n=pr("font-weight"),a=pr("tracking"),s=pr("leading"),o=pr("breakpoint"),l=pr("container"),c=pr("spacing"),d=pr("radius"),u=pr("shadow"),p=pr("inset-shadow"),f=pr("text-shadow"),m=pr("drop-shadow"),g=pr("blur"),b=pr("perspective"),x=pr("aspect"),y=pr("ease"),v=pr("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(),We,qe],k=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],_=()=>[We,qe,c],A=()=>[ds,"full","auto",..._()],C=()=>[Ua,"none","subgrid",We,qe],R=()=>["auto",{span:["full",Ua,We,qe]},Ua,We,qe],T=()=>[Ua,"auto",We,qe],I=()=>["auto","min","max","fr",We,qe],N=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],P=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",..._()],z=()=>[ds,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],U=()=>[e,We,qe],V=()=>[...S(),xw,bw,{position:[We,qe]}],O=()=>["no-repeat",{repeat:["","x","y","space","round"]}],H=()=>["auto","cover","contain",Z9,W9,{size:[We,qe]}],$=()=>[Yu,Ro,wi],F=()=>["","none","full",d,We,qe],ne=()=>["",pt,Ro,wi],ee=()=>["solid","dashed","dotted","double"],ge=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ie=()=>[pt,Yu,xw,bw],me=()=>["","none",g,We,qe],pe=()=>["none",pt,We,qe],be=()=>["none",pt,We,qe],Ee=()=>[pt,We,qe],xe=()=>[ds,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ma],breakpoint:[ma],color:[U9],container:[ma],"drop-shadow":[ma],ease:["in","out","in-out"],font:[q9],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ma],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ma],shadow:[ma],spacing:["px",pt],text:[ma],"text-shadow":[ma],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ds,qe,We,x]}],container:["container"],columns:[{columns:[pt,qe,We,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:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[Ua,"auto",We,qe]}],basis:[{basis:[ds,"full","auto",l,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[pt,ds,"auto","initial","none",qe]}],grow:[{grow:["",pt,We,qe]}],shrink:[{shrink:["",pt,We,qe]}],order:[{order:[Ua,"first","last","none",We,qe]}],"grid-cols":[{"grid-cols":C()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":C()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...N(),"normal"]}],"justify-items":[{"justify-items":[...P(),"normal"]}],"justify-self":[{"justify-self":["auto",...P()]}],"align-content":[{content:["normal",...N()]}],"align-items":[{items:[...P(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...P(),{baseline:["","last"]}]}],"place-content":[{"place-content":N()}],"place-items":[{"place-items":[...P(),"baseline"]}],"place-self":[{"place-self":["auto",...P()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],w:[{w:[l,"screen",...z()]}],"min-w":[{"min-w":[l,"screen","none",...z()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",r,Ro,wi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,We,Zu]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Yu,qe]}],"font-family":[{font:[Y9,qe,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,We,qe]}],"line-clamp":[{"line-clamp":[pt,"none",We,Zu]}],leading:[{leading:[s,..._()]}],"list-image":[{"list-image":["none",We,qe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",We,qe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:U()}],"text-color":[{text:U()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:[pt,"from-font","auto",We,wi]}],"text-decoration-color":[{decoration:U()}],"underline-offset":[{"underline-offset":[pt,"auto",We,qe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",We,qe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",We,qe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:V()}],"bg-repeat":[{bg:O()}],"bg-size":[{bg:H()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ua,We,qe],radial:["",We,qe],conic:[Ua,We,qe]},X9,K9]}],"bg-color":[{bg:U()}],"gradient-from-pos":[{from:$()}],"gradient-via-pos":[{via:$()}],"gradient-to-pos":[{to:$()}],"gradient-from":[{from:U()}],"gradient-via":[{via:U()}],"gradient-to":[{to:U()}],rounded:[{rounded:F()}],"rounded-s":[{"rounded-s":F()}],"rounded-e":[{"rounded-e":F()}],"rounded-t":[{"rounded-t":F()}],"rounded-r":[{"rounded-r":F()}],"rounded-b":[{"rounded-b":F()}],"rounded-l":[{"rounded-l":F()}],"rounded-ss":[{"rounded-ss":F()}],"rounded-se":[{"rounded-se":F()}],"rounded-ee":[{"rounded-ee":F()}],"rounded-es":[{"rounded-es":F()}],"rounded-tl":[{"rounded-tl":F()}],"rounded-tr":[{"rounded-tr":F()}],"rounded-br":[{"rounded-br":F()}],"rounded-bl":[{"rounded-bl":F()}],"border-w":[{border:ne()}],"border-w-x":[{"border-x":ne()}],"border-w-y":[{"border-y":ne()}],"border-w-s":[{"border-s":ne()}],"border-w-e":[{"border-e":ne()}],"border-w-t":[{"border-t":ne()}],"border-w-r":[{"border-r":ne()}],"border-w-b":[{"border-b":ne()}],"border-w-l":[{"border-l":ne()}],"divide-x":[{"divide-x":ne()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ne()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ee(),"hidden","none"]}],"divide-style":[{divide:[...ee(),"hidden","none"]}],"border-color":[{border:U()}],"border-color-x":[{"border-x":U()}],"border-color-y":[{"border-y":U()}],"border-color-s":[{"border-s":U()}],"border-color-e":[{"border-e":U()}],"border-color-t":[{"border-t":U()}],"border-color-r":[{"border-r":U()}],"border-color-b":[{"border-b":U()}],"border-color-l":[{"border-l":U()}],"divide-color":[{divide:U()}],"outline-style":[{outline:[...ee(),"none","hidden"]}],"outline-offset":[{"outline-offset":[pt,We,qe]}],"outline-w":[{outline:["",pt,Ro,wi]}],"outline-color":[{outline:U()}],shadow:[{shadow:["","none",u,sc,ic]}],"shadow-color":[{shadow:U()}],"inset-shadow":[{"inset-shadow":["none",p,sc,ic]}],"inset-shadow-color":[{"inset-shadow":U()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:U()}],"ring-offset-w":[{"ring-offset":[pt,wi]}],"ring-offset-color":[{"ring-offset":U()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":U()}],"text-shadow":[{"text-shadow":["none",f,sc,ic]}],"text-shadow-color":[{"text-shadow":U()}],opacity:[{opacity:[pt,We,qe]}],"mix-blend":[{"mix-blend":[...ge(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ge()}],"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":[pt]}],"mask-image-linear-from-pos":[{"mask-linear-from":ie()}],"mask-image-linear-to-pos":[{"mask-linear-to":ie()}],"mask-image-linear-from-color":[{"mask-linear-from":U()}],"mask-image-linear-to-color":[{"mask-linear-to":U()}],"mask-image-t-from-pos":[{"mask-t-from":ie()}],"mask-image-t-to-pos":[{"mask-t-to":ie()}],"mask-image-t-from-color":[{"mask-t-from":U()}],"mask-image-t-to-color":[{"mask-t-to":U()}],"mask-image-r-from-pos":[{"mask-r-from":ie()}],"mask-image-r-to-pos":[{"mask-r-to":ie()}],"mask-image-r-from-color":[{"mask-r-from":U()}],"mask-image-r-to-color":[{"mask-r-to":U()}],"mask-image-b-from-pos":[{"mask-b-from":ie()}],"mask-image-b-to-pos":[{"mask-b-to":ie()}],"mask-image-b-from-color":[{"mask-b-from":U()}],"mask-image-b-to-color":[{"mask-b-to":U()}],"mask-image-l-from-pos":[{"mask-l-from":ie()}],"mask-image-l-to-pos":[{"mask-l-to":ie()}],"mask-image-l-from-color":[{"mask-l-from":U()}],"mask-image-l-to-color":[{"mask-l-to":U()}],"mask-image-x-from-pos":[{"mask-x-from":ie()}],"mask-image-x-to-pos":[{"mask-x-to":ie()}],"mask-image-x-from-color":[{"mask-x-from":U()}],"mask-image-x-to-color":[{"mask-x-to":U()}],"mask-image-y-from-pos":[{"mask-y-from":ie()}],"mask-image-y-to-pos":[{"mask-y-to":ie()}],"mask-image-y-from-color":[{"mask-y-from":U()}],"mask-image-y-to-color":[{"mask-y-to":U()}],"mask-image-radial":[{"mask-radial":[We,qe]}],"mask-image-radial-from-pos":[{"mask-radial-from":ie()}],"mask-image-radial-to-pos":[{"mask-radial-to":ie()}],"mask-image-radial-from-color":[{"mask-radial-from":U()}],"mask-image-radial-to-color":[{"mask-radial-to":U()}],"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":[pt]}],"mask-image-conic-from-pos":[{"mask-conic-from":ie()}],"mask-image-conic-to-pos":[{"mask-conic-to":ie()}],"mask-image-conic-from-color":[{"mask-conic-from":U()}],"mask-image-conic-to-color":[{"mask-conic-to":U()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:V()}],"mask-repeat":[{mask:O()}],"mask-size":[{mask:H()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",We,qe]}],filter:[{filter:["","none",We,qe]}],blur:[{blur:me()}],brightness:[{brightness:[pt,We,qe]}],contrast:[{contrast:[pt,We,qe]}],"drop-shadow":[{"drop-shadow":["","none",m,sc,ic]}],"drop-shadow-color":[{"drop-shadow":U()}],grayscale:[{grayscale:["",pt,We,qe]}],"hue-rotate":[{"hue-rotate":[pt,We,qe]}],invert:[{invert:["",pt,We,qe]}],saturate:[{saturate:[pt,We,qe]}],sepia:[{sepia:["",pt,We,qe]}],"backdrop-filter":[{"backdrop-filter":["","none",We,qe]}],"backdrop-blur":[{"backdrop-blur":me()}],"backdrop-brightness":[{"backdrop-brightness":[pt,We,qe]}],"backdrop-contrast":[{"backdrop-contrast":[pt,We,qe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",pt,We,qe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[pt,We,qe]}],"backdrop-invert":[{"backdrop-invert":["",pt,We,qe]}],"backdrop-opacity":[{"backdrop-opacity":[pt,We,qe]}],"backdrop-saturate":[{"backdrop-saturate":[pt,We,qe]}],"backdrop-sepia":[{"backdrop-sepia":["",pt,We,qe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",We,qe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[pt,"initial",We,qe]}],ease:[{ease:["linear","initial",y,We,qe]}],delay:[{delay:[pt,We,qe]}],animate:[{animate:["none",v,We,qe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,We,qe]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:pe()}],"rotate-x":[{"rotate-x":pe()}],"rotate-y":[{"rotate-y":pe()}],"rotate-z":[{"rotate-z":pe()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:Ee()}],"skew-x":[{"skew-x":Ee()}],"skew-y":[{"skew-y":Ee()}],transform:[{transform:[We,qe,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"translate-none":["translate-none"],accent:[{accent:U()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:U()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",We,qe]}],"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":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",We,qe]}],fill:[{fill:["none",...U()]}],"stroke-w":[{stroke:[pt,Ro,wi,Zu]}],stroke:[{stroke:["none",...U()]}],"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"]}},tM=O9(eM);function ue(...e){return tM(ZE(e))}function rM(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const nM=Uf("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current"}},defaultVariants:{variant:"default"}}),oN=h.forwardRef(({className:e,variant:t,...r},n)=>i.jsx("div",{ref:n,role:"alert","data-slot":"alert",className:ue(nM({variant:t}),e),...r}));oN.displayName="Alert";const aM=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"alert-title",className:ue("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));aM.displayName="AlertTitle";const iM=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"alert-description",className:ue("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));iM.displayName="AlertDescription";const sM=Uf("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 Bt({className:e,variant:t,...r}){return i.jsx("div",{className:ue(sM({variant:t}),e),...r})}const oM=Uf("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"}}),je=h.forwardRef(({className:e,variant:t,size:r,...n},a)=>i.jsx("button",{className:ue(oM({variant:t,size:r,className:e})),ref:a,...n}));je.displayName="Button";const lN=h.createContext(null),cN=()=>{const e=h.useContext(lN);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},dN=({className:e,approval:t="pending",children:r,...n})=>{const a=h.useMemo(()=>({approval:t}),[t]);return i.jsx(lN.Provider,{value:a,children:i.jsx(oN,{className:ue("flex flex-col gap-2",e),...n,children:r})})};dN.displayName="Confirmation";const uN=({className:e,...t})=>i.jsx("div",{"data-slot":"confirmation-title",className:ue("text-muted-foreground inline text-sm",e),...t});uN.displayName="ConfirmationTitle";const pN=({children:e})=>{const{approval:t}=cN();return t!=="pending"?null:i.jsx(i.Fragment,{children:e})};pN.displayName="ConfirmationRequest";const mN=({className:e,...t})=>{const{approval:r}=cN();return r!=="pending"?null:i.jsx("div",{"data-slot":"confirmation-actions",className:ue("flex items-center justify-end gap-2 self-end",e),...t})};mN.displayName="ConfirmationActions";const Hc=({variant:e="default",...t})=>i.jsx(je,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});Hc.displayName="ConfirmationAction";const hN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));hN.displayName="Card";const fN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("flex flex-col space-y-1.5 p-4",e),...t}));fN.displayName="CardHeader";const gN=h.forwardRef(({className:e,...t},r)=>i.jsx("h3",{ref:r,className:ue("font-semibold leading-none tracking-tight",e),...t}));gN.displayName="CardTitle";const lM=h.forwardRef(({className:e,...t},r)=>i.jsx("p",{ref:r,className:ue("text-sm text-muted-foreground",e),...t}));lM.displayName="CardDescription";const bN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("p-4 pt-0",e),...t}));bN.displayName="CardContent";const xN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("flex items-center p-4 pt-0",e),...t}));xN.displayName="CardFooter";const cM=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("ml-auto shrink-0",e),...t}));cM.displayName="CardAction";const yN=h.createContext(null);function vN(){const e=h.useContext(yN);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const si=h.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:r,className:n,children:a,...s},o)=>{const[l,c]=h.useState(e),d=t!==void 0,u=d?t:l,p=h.useCallback(m=>{d||c(m),r?.(m)},[d,r]),f=h.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return i.jsx(yN.Provider,{value:f,children:i.jsx("div",{ref:o,"data-state":u?"open":"closed",className:n,...s,children:a})})});si.displayName="Collapsible";const Ta=h.forwardRef(({onClick:e,children:t,className:r,...n},a)=>{const{open:s,onOpenChange:o}=vN(),l=h.useCallback(c=>{o(!s),e?.(c)},[s,o,e]);return i.jsx("button",{ref:a,type:"button","aria-expanded":s,"data-state":s?"open":"closed",onClick:l,className:r,...n,children:t})});Ta.displayName="CollapsibleTrigger";const oi=h.forwardRef(({className:e,children:t,...r},n)=>{const{open:a}=vN();return i.jsx("div",{ref:n,"data-state":a?"open":"closed",className:ue("grid transition-[grid-template-rows] duration-200 ease-out",a?"grid-rows-[1fr]":"grid-rows-[0fr]",e),...r,children:i.jsx("div",{className:"overflow-hidden",children:t})})});oi.displayName="CollapsibleContent";const wN=h.createContext(null);function Hf(){const e=h.useContext(wN);if(!e)throw new Error("Command components must be used within <Command>");return e}const kN=h.forwardRef(({className:e,children:t,...r},n)=>{const[a,s]=h.useState(""),o=h.useRef(new Map),[l,c]=h.useState(0),d=h.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),u=h.useCallback(v=>{o.current.delete(v),c(w=>w+1)},[]),p=h.useCallback((v,w)=>{const S=o.current.get(v);S&&Object.assign(S,w)},[]),f=h.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=h.useMemo(()=>{const v=[];for(const[,w]of o.current)f.has(w.id)&&v.push(w);return v},[f]),[g,b]=h.useState(null);h.useEffect(()=>{b(m.length>0?m[0].id:null)},[m]);const x=h.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(A=>A.id===g)?.onSelect();return}const S=w.findIndex(_=>_.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=h.useMemo(()=>({search:a,setSearch:s,visibleIds:f,activeId:g,setActiveId:b,register:d,unregister:u,updateEntry:p}),[a,f,g,d,u,p]);return i.jsx(wN.Provider,{value:y,children:i.jsx("div",{ref:n,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:ue("flex flex-col",e),onKeyDown:x,...r,children:t})})});kN.displayName="Command";const SN=h.forwardRef(({className:e,placeholder:t="Search...",...r},n)=>{const{search:a,setSearch:s}=Hf();return i.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[i.jsx(Na,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),i.jsx("input",{ref:n,type:"text",role:"searchbox","aria-autocomplete":"list",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:a,onChange:o=>s(o.target.value),placeholder:t,className:ue("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),...r})]})});SN.displayName="CommandInput";const EN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,role:"listbox",className:ue("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));EN.displayName="CommandList";const NN=h.forwardRef(({className:e,...t},r)=>{const{search:n,visibleIds:a}=Hf();return!n||a.size>0?null:i.jsx("div",{ref:r,className:ue("py-6 text-center text-sm text-muted-foreground",e),...t})});NN.displayName="CommandEmpty";const CN=h.forwardRef(({className:e,heading:t,children:r,...n},a)=>i.jsxs("div",{ref:a,className:ue("overflow-hidden p-1",e),role:"group","aria-label":typeof t=="string"?t:void 0,...n,children:[t&&i.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",role:"presentation",children:t}),r]}));CN.displayName="CommandGroup";const TN=h.forwardRef(({className:e,value:t,onSelect:r,disabled:n,children:a,...s},o)=>{const{visibleIds:l,activeId:c,setActiveId:d,register:u,unregister:p,updateEntry:f}=Hf(),m=h.useId(),g=h.useRef(null),b=t||(typeof a=="string"?a:"");h.useEffect(()=>(u({id:m,value:b.toLowerCase(),onSelect:r||(()=>{}),element:g.current}),()=>p(m)),[m,b,u,p]),h.useEffect(()=>{f(m,{onSelect:r||(()=>{})})},[m,r,f]);const x=h.useCallback(v=>{g.current=v,f(m,{element:v}),typeof o=="function"?o(v):o&&(o.current=v)},[m,f,o]);if(!l.has(m))return null;const y=c===m;return i.jsx("div",{ref:x,role:"option","aria-selected":y,"aria-disabled":n||void 0,"data-active":y||void 0,className:ue("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",n&&"pointer-events-none opacity-50",e),onPointerMove:()=>{!n&&c!==m&&d(m)},onClick:()=>!n&&r?.(),...s,children:a})});TN.displayName="CommandItem";const dM=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("-mx-1 h-px bg-border",e),...t}));dM.displayName="CommandSeparator";function oh({checked:e,onToggle:t,ariaLabel:r="Toggle dark mode"}){const{isDarkMode:n,toggleDarkMode:a}=Ma(),s=typeof e=="boolean"&&typeof t=="function",o=s?e:n,l=()=>{if(s&&t){t(!o);return}a()};return i.jsxs("button",{onClick:l,className:ue("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":r,children:[i.jsx("span",{className:"sr-only",children:r}),i.jsx("span",{className:ue("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?i.jsx(Lf,{className:"h-3 w-3 text-primary"}):i.jsx(Of,{className:"h-3 w-3 text-white dark:text-background"})})]})}const AN=h.createContext(null);function jN(){const e=h.useContext(AN);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const _N=({open:e,onOpenChange:t,defaultOpen:r=!1,children:n})=>{const[a,s]=h.useState(r),o=h.useRef(null),l=e!==void 0,c=l?e:a,d=h.useCallback(p=>{l||s(p),t?.(p)},[l,t]),u=h.useMemo(()=>({open:c,onOpenChange:d,triggerRef:o}),[c,d]);return i.jsx(AN.Provider,{value:u,children:n})},uM=h.forwardRef(({onClick:e,children:t,asChild:r,...n},a)=>{const{onOpenChange:s,triggerRef:o}=jN(),l=h.useCallback(c=>{s(!0),e?.(c)},[s,e]);if(r&&h.isValidElement(t)){const c=t;return h.cloneElement(c,{onClick:d=>{s(!0),c.props.onClick?.(d)},ref:d=>{o.current=d,typeof a=="function"?a(d):a&&(a.current=d)}})}return i.jsx("button",{ref:c=>{o.current=c,typeof a=="function"?a(c):a&&(a.current=c)},type:"button",onClick:l,...n,children:t})});uM.displayName="DialogTrigger";const yw='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',Vf=h.forwardRef(({className:e,children:t,onEscapeKeyDown:r,onPointerDownOutside:n,...a},s)=>{const{open:o,onOpenChange:l,triggerRef:c}=jN(),d=h.useRef(null),u=h.useRef(null);return h.useEffect(()=>{o?u.current=document.activeElement:u.current&&((c.current||u.current)?.focus(),u.current=null)},[o,c]),h.useEffect(()=>{if(!o)return;const p=m=>{if(m.key==="Escape"){m.stopPropagation(),r?.(),l(!1);return}if(m.key==="Tab"&&d.current){const g=Array.from(d.current.querySelectorAll(yw));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 f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p,!0),document.body.style.overflow=f}},[o,l,r]),h.useEffect(()=>{o&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(yw)?.focus()})},[o]),o?Vd.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50",children:[i.jsx("div",{className:"fixed inset-0 animate-dialog-overlay-show bg-black/50 backdrop-blur-sm",onClick:()=>{n?.(),l(!1)},"aria-hidden":!0}),i.jsx("div",{ref:p=>{d.current=p,typeof s=="function"?s(p):s&&(s.current=p)},role:"dialog","aria-modal":"true",className:ue("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});Vf.displayName="DialogContent";const qf=h.forwardRef(({className:e,...t},r)=>i.jsx("h2",{ref:r,className:ue("sr-only",e),...t}));qf.displayName="DialogTitle";const Et=h.forwardRef(({className:e,type:t,...r},n)=>i.jsx("input",{type:t,className:ue("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r}));Et.displayName="Input";const Wf=h.forwardRef(({className:e,contentClassName:t,children:r,...n},a)=>i.jsx("div",{className:ue("relative overflow-hidden",e),...n,children:i.jsx("div",{ref:a,className:ue("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Wf.displayName="ScrollArea";const md=h.memo(({children:e,className:t,as:r="span"})=>i.jsx(r,{className:ue("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}));md.displayName="Shimmer";const IN=h.createContext(null),pM=()=>{const e=h.useContext(IN);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},mM=1e3,hM=1e3,lh=h.memo(({className:e,isStreaming:t=!1,open:r,defaultOpen:n,onOpenChange:a,duration:s,children:o,...l})=>{const c=n??t,d=n===!1,[u,p]=h.useState(c),f=r!==void 0,m=f?r:u,g=h.useCallback(k=>{f||p(k),a?.(k)},[f,a]),[b,x]=h.useState(s),y=h.useRef(t),[v,w]=h.useState(!1),S=h.useRef(null);h.useEffect(()=>{s!==void 0&&x(s)},[s]),h.useEffect(()=>{t?(y.current=!0,S.current===null&&(S.current=Date.now())):S.current!==null&&(x(Math.ceil((Date.now()-S.current)/hM)),S.current=null)},[t]),h.useEffect(()=>{t&&!m&&!d&&g(!0)},[t,m,g,d]),h.useEffect(()=>{if(y.current&&!t&&m&&!v){const k=setTimeout(()=>{g(!1),w(!0)},mM);return()=>clearTimeout(k)}},[t,m,g,v]);const E=h.useMemo(()=>({duration:b,isOpen:m,isStreaming:t,setIsOpen:g}),[b,m,t,g]);return i.jsx(IN.Provider,{value:E,children:i.jsx(si,{open:m,onOpenChange:g,className:ue("not-prose",e),...l,children:o})})});lh.displayName="Reasoning";const fM=(e,t)=>e||t===0?i.jsx(md,{children:"Thinking..."}):t===void 0?i.jsx("p",{children:"Thought for a few seconds"}):i.jsxs("p",{children:["Thought for ",t," seconds"]}),ch=h.memo(({className:e,children:t,getThinkingMessage:r=fM,...n})=>{const{isStreaming:a,isOpen:s,duration:o}=pM();return i.jsx(Ta,{className:ue("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...n,children:t??i.jsxs(i.Fragment,{children:[i.jsx(ZD,{className:"h-4 w-4"}),r(a,o),i.jsx(dE,{className:ue("h-4 w-4 transition-transform",s?"rotate-180":"rotate-0")})]})})});ch.displayName="ReasoningTrigger";const dh=h.memo(({className:e,children:t,...r})=>i.jsx(oi,{className:ue("mt-4 text-sm text-muted-foreground",e),...r,children:t}));dh.displayName="ReasoningContent";function gM(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 Yn({children:e,content:t,position:r="top",className:n="",delay:a=350}){const[s,o]=h.useState(!1),l=h.useRef(null),c=h.useRef(!1),d=h.useRef(null),u=h.useRef(null),[p,f]=h.useState(null),m=h.useCallback(()=>{const w=d.current;if(!w)return;const S=w.getBoundingClientRect(),E=8,k={position:"fixed",zIndex:9999};switch(r){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}f(k)},[r]),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 h.useEffect(()=>()=>{g()},[]),h.useEffect(()=>{if(!s||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)},[s]),h.useEffect(()=>{if(!s){f(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)}},[s,m]),t?i.jsxs("div",{ref:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:y,onTouchEnd:v,onTouchCancel:v,children:[e,s&&typeof document<"u"&&Vd.createPortal(i.jsxs("div",{ref:u,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:ue("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",n),children:[t,i.jsx("div",{className:ue("absolute w-0 h-0 border-4 border-transparent",gM(r))})]}),document.body)]}):i.jsx(i.Fragment,{children:e})}const RN=h.createContext(null),LN=h.forwardRef(({className:e,status:t="ready",children:r,...n},a)=>{const s=h.useMemo(()=>({status:t}),[t]);return i.jsx(RN.Provider,{value:s,children:i.jsx("form",{ref:a,"data-slot":"prompt-input",className:ue("relative overflow-hidden rounded-xl border border-border/70 bg-zinc-50/95 shadow-sm shadow-zinc-950/5 backdrop-blur-sm transition-all duration-200 focus-within:border-primary/40 focus-within:shadow-md focus-within:ring-1 focus-within:ring-primary/20 dark:bg-zinc-950/90",e),...n,children:r})})});LN.displayName="PromptInput";const DN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-header",className:ue("px-3 pt-3",e),...t}));DN.displayName="PromptInputHeader";const ON=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-body",className:ue("relative",e),...t}));ON.displayName="PromptInputBody";const MN=h.forwardRef(({className:e,...t},r)=>i.jsx("textarea",{ref:r,"data-slot":"prompt-input-textarea",className:ue("chat-input-placeholder block max-h-[40vh] w-full resize-none overflow-y-auto bg-transparent px-4 py-2 font-mono text-sm leading-6 text-foreground placeholder-muted-foreground/50 focus:outline-none sm:max-h-[300px]",e),...t}));MN.displayName="PromptInputTextarea";const PN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-footer",className:ue("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));PN.displayName="PromptInputFooter";const FN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-tools",className:ue("flex items-center gap-1",e),...t}));FN.displayName="PromptInputTools";const Vc=h.forwardRef(({className:e,tooltip:t,children:r,...n},a)=>{const s=i.jsx(je,{ref:a,type:"button",variant:"ghost",size:"icon",className:ue("h-8 w-8 [&_svg]:size-4",e),...n,children:r});return t?i.jsx(Yn,{content:t.shortcut?i.jsxs("span",{className:"flex items-center gap-1.5",children:[t.content,i.jsx("kbd",{className:"rounded bg-white/20 px-1 text-[10px]",children:t.shortcut})]}):t.content,position:t.side??"top",children:s}):s});Vc.displayName="PromptInputButton";const zN=h.forwardRef(({className:e,status:t,children:r,...n},a)=>{const s=h.useContext(RN),o=t??s?.status??"ready",l=o==="submitted"||o==="streaming";return i.jsx(je,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:ue("h-8 w-8 rounded-lg",e),...n,children:r??(l?i.jsx(Xd,{className:"h-3.5 w-3.5 fill-current"}):i.jsx(TD,{className:"h-4 w-4"}))})});zN.displayName="PromptInputSubmit";function Kf({children:e,className:t}){return i.jsx("div",{className:ue("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function Yf({isActive:e,onClick:t,children:r,className:n}){return i.jsx("button",{onClick:t,className:ue("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",n),children:r})}const BN=h.createContext(null);function $N(){const e=h.useContext(BN);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const UN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"queue",role:"list",className:ue("space-y-0.5",e),...t}));UN.displayName="Queue";const GN=h.forwardRef(({status:e="pending",className:t,children:r,...n},a)=>{const s=h.useMemo(()=>({status:e}),[e]);return i.jsx(BN.Provider,{value:s,children:i.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:ue("flex items-start gap-2 py-0.5",t),...n,children:r})})});GN.displayName="QueueItem";const HN=h.forwardRef(({className:e,...t},r)=>{const{status:n}=$N();return i.jsxs("div",{ref:r,"data-slot":"queue-item-indicator","aria-hidden":"true",className:ue("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",e),...t,children:[n==="completed"&&i.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:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),n==="in_progress"&&i.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),n==="pending"&&i.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})})]})});HN.displayName="QueueItemIndicator";const VN=h.forwardRef(({className:e,children:t,...r},n)=>{const{status:a}=$N();return i.jsx("div",{ref:n,"data-slot":"queue-item-content",className:ue("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),...r,children:t})});VN.displayName="QueueItemContent";const vw="https://github.com/alicomert/pixcode/issues/new",bM="https://github.com/alicomert/pixcode",ww="https://discord.gg/buxwujPNRE";function kw({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.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 xM({updateAvailable:e,releaseInfo:t,latestVersion:r,currentVersion:n,onShowVersionModal:a,onShowSettings:s,t:o}){return i.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[e&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:i.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:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(Zv,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})}),i.jsx("div",{className:"px-3 py-2 md:hidden",children:i.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:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(Zv,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})})]}),i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:i.jsxs("a",{href:vw,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:[i.jsx(gl,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:o("actions.reportIssue")})]})}),i.jsx("div",{className:"hidden px-2 md:block",children:i.jsxs("a",{href:ww,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:[i.jsx(kw,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:o("actions.joinCommunity")})]})}),i.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:i.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:s,children:[i.jsx(Rt,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),i.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:i.jsxs("a",{href:bM,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",n," – ",o("branding.openSource")]})}),i.jsx("div",{className:"px-3 pt-3 md:hidden",children:i.jsxs("a",{href:vw,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:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(gl,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.reportIssue")})]})}),i.jsx("div",{className:"px-3 pt-2 md:hidden",children:i.jsxs("a",{href:ww,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:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(kw,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.joinCommunity")})]})}),i.jsx("div",{className:"px-3 pb-3 pt-2 md:hidden",children:i.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:s,children:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(Rt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const Sw="PIXCODE_GITHUB_STARS",Ew="PIXCODE_HIDE_GITHUB_STAR",yM=3600*1e3,vM=(e,t)=>{const[r,n]=h.useState(null),[a,s]=h.useState(()=>{try{return localStorage.getItem(Ew)==="true"}catch{return!1}});h.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(Sw);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<yM){n(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"){n(p);try{localStorage.setItem(Sw,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=h.useCallback(()=>{s(!0);try{localStorage.setItem(Ew,"true")}catch{}},[]),l=r!==null?r>=1e3?`${(r/1e3).toFixed(1)}k`:`${r}`:null;return{starCount:r,formattedCount:l,isDismissed:a,dismiss:o}},wM="https://github.com/alicomert/pixcode";function kM({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.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 SM(){const{formattedCount:e,isDismissed:t,dismiss:r}=vM("alicomert","pixcode");return t?null:i.jsxs("div",{className:"group/star relative hidden md:block",children:[i.jsxs("a",{href:wM,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:[i.jsx(kM,{className:"h-3.5 w-3.5"}),i.jsx(Rs,{className:"h-3 w-3"}),i.jsx("span",{className:"font-medium",children:"Star"}),e&&i.jsx("span",{className:"border-l border-border/50 pl-1.5 tabular-nums",children:e})]}),i.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),r()},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:i.jsx(bt,{className:"h-2.5 w-2.5"})})]})}function Nw({value:e,onChange:t,t:r}){const n="flex flex-1 items-center justify-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium transition-all";return i.jsxs("div",{role:"tablist","aria-label":r("tooltips.historyView",{defaultValue:"History view"}),className:"flex rounded-lg bg-muted/40 p-0.5",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":e==="flat",onClick:()=>t("flat"),className:ue(n,e==="flat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewFlat",{defaultValue:"Recent conversations"}),children:[i.jsx(fl,{className:"h-3 w-3"}),r("historyView.flat",{defaultValue:"Recent"})]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":e==="grouped",onClick:()=>t("grouped"),className:ue(n,e==="grouped"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewGrouped",{defaultValue:"Grouped by project"}),children:[i.jsx(RD,{className:"h-3 w-3"}),r("historyView.grouped",{defaultValue:"By project"})]})]})}function EM({isPWA:e,isMobile:t,isLoading:r,projectsCount:n,searchFilter:a,onSearchFilterChange:s,onClearSearchFilter:o,searchMode:l,onSearchModeChange:c,onRefresh:d,isRefreshing:u,onCreateProject:p,onQuickStartSession:f,onCollapseSidebar:m,historyView:g,onHistoryViewChange:b,t:x}){const y=()=>i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("svg",{className:"h-6 w-6 flex-shrink-0",viewBox:"0 0 500 500","aria-hidden":"true",children:i.jsx("g",{transform:"translate(250 250) scale(1.25) translate(-250 -250)",children:i.jsxs("g",{transform:"translate(0 500) scale(0.1 -0.1)",fill:"#5C3FFC",children:[i.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"}),i.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"})]})})}),i.jsx("h1",{className:"truncate text-sm font-semibold tracking-tight text-foreground",children:x("app.title")})]});return i.jsxs("div",{className:"flex-shrink-0",children:[i.jsxs("div",{className:"hidden px-4 pb-3 pt-4 md:block",style:{},children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx(y,{}),i.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[i.jsx(je,{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:i.jsx(mt,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),i.jsx(je,{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:i.jsx(Vt,{className:"h-4 w-4"})}),i.jsx(je,{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:i.jsx(ND,{className:"h-4 w-4"})})]})]}),i.jsx(SM,{}),f&&i.jsxs("button",{type:"button",onClick:()=>{f()},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:[i.jsx(Ca,{className:"h-4 w-4"}),x("sidebar.newChat",{defaultValue:"New chat"})]}),n>0&&!r&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[i.jsx(Nw,{value:g,onChange:b,t:x}),i.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[i.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:ue("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:[i.jsx(Pn,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:ue("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:[i.jsx(na,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Na,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/50"}),i.jsx(Et,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>s(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&&i.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:i.jsx(bt,{className:"h-3 w-3 text-muted-foreground"})})]})]})]}),i.jsx("div",{className:"nav-divider hidden md:block"}),i.jsxs("div",{className:"p-3 pb-2 md:hidden",style:e&&t?{paddingTop:"16px"}:{},children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(y,{}),i.jsxs("div",{className:"flex flex-shrink-0 gap-1.5",children:[i.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:i.jsx(mt,{className:`h-4 w-4 text-muted-foreground ${u?"animate-spin":""}`})}),i.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:i.jsx(ii,{className:"h-4 w-4"})})]})]}),n>0&&!r&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&i.jsx(Nw,{value:g,onChange:b,t:x}),i.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[i.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:ue("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:[i.jsx(Pn,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:ue("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:[i.jsx(na,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Na,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),i.jsx(Et,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>s(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&&i.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:i.jsx(bt,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),i.jsx("div",{className:"nav-divider md:hidden"})]})}const NM=160,Cw=180;function qN({actions:e,className:t,triggerLabel:r}){const[n,a]=h.useState(!1),[s,o]=h.useState(null),l=h.useRef(null),c=h.useRef(null);h.useLayoutEffect(()=>{if(!n||!l.current)return;const u=l.current.getBoundingClientRect();let p=u.right-NM;p<8&&(p=8);let f=u.bottom+4;f+Cw>window.innerHeight&&(f=Math.max(8,u.top-4-Cw)),o({top:f,left:p})},[n]),h.useEffect(()=>{if(!n)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)},f=()=>a(!1);return document.addEventListener("mousedown",u),document.addEventListener("keydown",p),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",p),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[n]);const d=u=>p=>{p.stopPropagation(),p.preventDefault(),a(!1),u.onClick()};return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:l,type:"button","aria-haspopup":"menu","aria-expanded":n,"aria-label":r||"Actions",title:r||"Actions",onClick:u=>{u.stopPropagation(),u.preventDefault(),a(p=>!p)},className:ue("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",n&&"bg-accent text-foreground opacity-100",t),children:i.jsx(BD,{className:"h-3.5 w-3.5"})}),n&&s&&Vd.createPortal(i.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:s.top,left:s.left,zIndex:9999},className:ue("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 f=u.icon,m=e[p-1],g=p>0&&u.danger&&!m?.danger;return i.jsxs("div",{children:[g&&i.jsx("div",{className:"my-1 h-px bg-border/60"}),i.jsxs("button",{type:"button",role:"menuitem",onClick:d(u),className:ue("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:[i.jsx(f,{className:"h-3 w-3"}),u.label]})]},u.id)})}),document.body)]})}const Tw={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},CM={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},TM=e=>e==="fully-configured"?{icon:ra,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:Rt,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:Nn,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:bt,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function AM({status:e="not-configured",size:t="sm",className:r="",showLabel:n=!1}){const a=TM(e),s=a.icon;return n?i.jsxs("div",{className:ue("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",a.backgroundClassName,a.colorClassName,r),title:a.title,children:[i.jsx(s,{className:Tw[t]}),i.jsx("span",{className:"font-medium",children:a.label})]}):i.jsx("div",{className:ue("inline-flex items-center justify-center rounded-full transition-colors",a.backgroundClassName,CM[t],r),title:a.title,children:i.jsx(s,{className:ue(Tw[t],a.colorClassName)})})}const jM=(e,t,r)=>{const n=new Date(e),a=t;if(isNaN(n.getTime()))return r?r("status.unknown"):"Unknown";const s=a.getTime()-n.getTime(),o=Math.floor(s/1e3),l=Math.floor(s/(1e3*60)),c=Math.floor(s/(1e3*60*60)),d=Math.floor(s/(1e3*60*60*24));return o<60?r?r("time.justNow"):"Just now":l===1?r?r("time.oneMinuteAgo"):"1 min ago":l<60?r?r("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?r?r("time.oneHourAgo"):"1 hour ago":c<24?r?r("time.hoursAgo",{count:c}):`${c} hours ago`:d===1?r?r("time.oneDayAgo"):"1 day ago":d<7?r?r("time.daysAgo",{count:d}):`${d} days ago`:n.toLocaleDateString()};function Aw({isStarred:e,canDelete:t,onRename:r,onToggleStar:n,onDelete:a,t:s,className:o}){const l=d=>i.jsx(Rs,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:s("actions.rename"),icon:OD,onClick:r},{id:"star",label:e?s("actions.unstarSession",{defaultValue:"Remove star"}):s("actions.starSession",{defaultValue:"Star"}),icon:l,onClick:n}];return t&&c.push({id:"delete",label:s("actions.delete"),icon:kr,onClick:a,danger:!0}),i.jsx(qN,{actions:c,className:o,triggerLabel:s("tooltips.sessionActions",{defaultValue:"Session actions"})})}const _M={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},jw={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 WN({project:e,session:t,selectedSession:r,currentTime:n,editingSession:a,editingSessionName:s,isStarred:o,compact:l=!1,onEditingSessionNameChange:c,onStartEditingSession:d,onCancelEditingSession:u,onSaveEditingSession:p,onToggleStarSession:f,onProjectSelect:m,onSessionSelect:g,onDeleteSession:b,t:x}){const y=p9(t,n,x),v=r?.id===t.id,w=a===t.id,S=t.__provider,E=_M[S]??S,k=jw[S]??jw.claude,j=c9(y.sessionName),_=()=>{m(e),g(t,e.name)},A=()=>{p(e.name,t.id,s,S)},C=()=>{b(e.name,t.id,y.sessionName,S)},R=()=>d(t.id,y.sessionName),T=()=>f(e.name,t.id),I=i.jsxs("div",{className:"mt-0.5 flex min-w-0 flex-wrap items-center gap-1 text-[10px] leading-tight",children:[i.jsxs("span",{className:ue("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",k),children:[i.jsx(dr,{provider:S,className:"h-2.5 w-2.5"}),E]}),i.jsx("span",{className:"text-muted-foreground/80",children:jM(y.sessionTime,n,x)}),y.isActive&&i.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 dark:text-green-400",children:[i.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-green-500"}),x("status.active",{defaultValue:"Active"})]}),j.slice(0,3).map(z=>i.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:[".",z]},z))]}),N=i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text",value:s,onChange:z=>c(z.target.value),onKeyDown:z=>{z.stopPropagation(),z.key==="Enter"?A():z.key==="Escape"&&u()},onClick:z=>z.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}),i.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:z=>{z.stopPropagation(),A()},title:x("tooltips.save"),children:i.jsx(nr,{className:"h-3 w-3 text-green-600 dark:text-green-400"})}),i.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:z=>{z.stopPropagation(),u()},title:x("tooltips.cancel"),children:i.jsx(bt,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),P=i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:ue("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:_,children:w?i.jsx("div",{className:"flex items-center gap-1",children:N}):i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:ue("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/60"),children:i.jsx(dr,{provider:S,className:"h-3 w-3"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-1",children:[o&&i.jsx("span",{className:"text-yellow-500","aria-hidden":!0,children:"★"}),i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),I]}),i.jsx("div",{className:"flex-shrink-0",onClick:z=>z.stopPropagation(),children:i.jsx(Aw,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:T,onDelete:C,t:x,className:"!opacity-100"})})]})})}),G=i.jsxs("div",{className:ue("group/item relative hidden md:block"),children:[i.jsxs(je,{variant:"ghost",className:ue("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&&i.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&&i.jsx("span",{"aria-hidden":!0,className:"session-item-accent"}),i.jsxs("div",{className:"flex w-full min-w-0 items-start gap-2 pr-6",children:[i.jsx("div",{className:ue("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:i.jsx(dr,{provider:S,className:"h-3 w-3"})}),i.jsx("div",{className:"min-w-0 flex-1",children:w?i.jsx("div",{className:"flex items-center gap-1",children:N}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[o&&i.jsx("span",{className:"flex-shrink-0 text-yellow-500","aria-hidden":!0,children:"★"}),i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),I]})})]})]}),!w&&i.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:z=>z.stopPropagation(),children:i.jsx(Aw,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:T,onDelete:C,t:x,className:"opacity-0 focus-visible:opacity-100 group-hover/item:opacity-100"})})]});return i.jsxs("div",{className:"group relative",children:[P,G]})}const IM=e=>e==="claude-code"?"claude":e==="codex"?"codex":e==="gemini"?"gemini":e==="qwen"?"qwen":e==="opencode"?"opencode":null;function RM(){return i.jsx(i.Fragment,{children:Array.from({length:3}).map((e,t)=>i.jsx("div",{className:"rounded-md p-2",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("div",{className:"mt-0.5 h-3 w-3 animate-pulse rounded-full bg-muted"}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${60+t*15}%`}}),i.jsx("div",{className:"h-2 w-1/2 animate-pulse rounded bg-muted"})]})]})},t))})}function LM({project:e,isExpanded:t,sessions:r,selectedSession:n,initialSessionsLoaded:a,isLoadingSessions:s,currentTime:o,editingSession:l,editingSessionName:c,isSessionStarred:d,onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,onLoadMoreSessions:v,onNewSession:w,onOpenOrchestration:S,t:E}){const[k,j]=h.useState([]);if(h.useEffect(()=>{if(!t)return;let C=!1;const R=async()=>{const I=await ve(`/api/orchestration/workflows/runs?projectId=${encodeURIComponent(e.name)}`);if(!I.ok)return;const N=await I.json();C||j((N.runs??[]).slice(0,5))};R();const T=window.setInterval(()=>{R()},15e3);return()=>{C=!0,window.clearInterval(T)}},[t,e.name]),!t)return null;const _=r.length>0,A=e.sessionMeta?.hasMore===!0;return i.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[i.jsx("div",{className:"px-3 pb-1 pt-1 md:hidden",children:i.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:[i.jsx(Vt,{className:"h-3 w-3"}),E("sessions.newSession")]})}),i.jsxs(je,{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:[i.jsx(Vt,{className:"h-3 w-3"}),E("sessions.newSession")]}),k.length>0&&i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-1 px-3 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[i.jsx(aa,{className:"h-3 w-3"}),E("orchestration.section")]}),k.map(C=>{const R=[...new Set(C.nodeRuns.map(T=>IM(T.adapterId)).filter(Boolean))];return i.jsx("button",{type:"button",onClick:()=>S?.(e,C.id),className:"w-full rounded-lg px-3 py-2 text-left transition-colors hover:bg-accent/60",children:i.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[i.jsx(aa,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-primary"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"truncate text-xs font-medium text-foreground",children:C.input||E("orchestration.fallbackTitle")}),i.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[R.slice(0,4).map(T=>i.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted",children:i.jsx(dr,{provider:T,className:"h-3 w-3"})},T)),i.jsx("span",{className:"text-[10px] text-muted-foreground",children:E(`common:orchestration.status.${C.status}`,{defaultValue:C.status})})]})]})]})},C.id)})]}),a?!_&&!s?i.jsx("div",{className:"px-3 py-2 text-left",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:E("sessions.noSessions")})}):r.map(C=>i.jsx(WN,{project:e,session:C,selectedSession:n,currentTime:o,editingSession:l,editingSessionName:c,isStarred:d(e.name,C.id),onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:E},C.id)):i.jsx(RM,{}),_&&A&&i.jsx(je,{variant:"ghost",size:"sm",className:"mt-2 w-full justify-center gap-2 text-muted-foreground",onClick:()=>v(e),disabled:s,children:s?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),E("sessions.loading")]}):i.jsxs(i.Fragment,{children:[i.jsx(Fr,{className:"h-3 w-3"}),E("sessions.showMore")]})})]})}const DM=(e,t)=>{const r=e.length;return t&&r>=5?`${r}+`:`${r}`};function OM({project:e,selectedProject:t,selectedSession:r,isExpanded:n,isDeleting:a,isStarred:s,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:m,tasksEnabled:g,mcpServerStatus:b,isSessionStarred:x,onEditingNameChange:y,onToggleProject:v,onProjectSelect:w,onToggleStarProject:S,onToggleStarSession:E,onStartEditingProject:k,onCancelEditingProject:j,onSaveProjectName:_,onDeleteProject:A,onSessionSelect:C,onDeleteSession:R,onLoadMoreSessions:T,onNewSession:I,onOpenOrchestration:N,onEditingSessionNameChange:P,onStartEditingSession:G,onCancelEditingSession:z,onSaveEditingSession:U,t:V}){const O=t?.name===e.name,H=o===e.name,$=e.sessionMeta?.hasMore===!0,F=DM(c,$),ne=`${F} session${c.length===1?"":"s"}`,ee=f9(e,b),ge=()=>v(e.name),ie=()=>S(e.name),me=()=>{_(e.name)},pe=()=>{t?.name!==e.name&&w(e),ge()};return i.jsxs("div",{className:ue("md:space-y-1",a&&"opacity-50 pointer-events-none"),children:[i.jsxs("div",{className:"md:group group",children:[i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:ue("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",O&&"bg-primary/5 border-primary/20",s&&!O&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:ge,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[i.jsx("div",{className:ue("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",n?"bg-primary/10":"bg-muted"),children:n?i.jsx(Ea,{className:"h-4 w-4 text-primary"}):i.jsx(Pn,{className:"h-4 w-4 text-muted-foreground"})}),i.jsx("div",{className:"min-w-0 flex-1",children:H?i.jsx("input",{type:"text",value:l,onChange:be=>y(be.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:V("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:be=>be.stopPropagation(),onKeyDown:be=>{be.key==="Enter"&&me(),be.key==="Escape"&&j()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between",children:[i.jsx("h3",{className:"truncate text-sm font-medium text-foreground",children:e.displayName}),g&&i.jsx(AM,{status:ee,size:"xs",className:"ml-2 hidden flex-shrink-0 md:inline-flex"})]}),i.jsx("p",{className:"text-xs text-muted-foreground",children:ne})]})})]}),i.jsx("div",{className:"flex items-center gap-1",children:H?i.jsxs(i.Fragment,{children:[i.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:be=>{be.stopPropagation(),me()},children:i.jsx(nr,{className:"h-4 w-4 text-white"})}),i.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:be=>{be.stopPropagation(),j()},children:i.jsx(bt,{className:"h-4 w-4 text-white"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{className:ue("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",s?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:be=>{be.stopPropagation(),ie()},title:V(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:i.jsx(Rs,{className:ue("w-4 h-4 transition-colors",s?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),i.jsx("button",{className:"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:be=>{be.stopPropagation(),A(e)},children:i.jsx(kr,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),i.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:be=>{be.stopPropagation(),k(e)},children:i.jsx(Wm,{className:"h-4 w-4 text-primary"})}),i.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-muted/30",children:n?i.jsx(Fr,{className:"h-3 w-3 text-muted-foreground"}):i.jsx(An,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),i.jsxs(je,{variant:"ghost",className:ue("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",O&&"bg-accent text-accent-foreground",s&&!O&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:pe,children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[n?i.jsx(Ea,{className:"h-4 w-4 flex-shrink-0 text-primary"}):i.jsx(Pn,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),i.jsx("div",{className:"min-w-0 flex-1 text-left",children:H?i.jsxs("div",{className:"space-y-1",children:[i.jsx("input",{type:"text",value:l,onChange:be=>y(be.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:V("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:be=>{be.key==="Enter"&&me(),be.key==="Escape"&&j()}}),i.jsx("div",{className:"truncate text-xs text-muted-foreground",title:e.fullPath,children:e.fullPath})]}):i.jsxs("div",{children:[i.jsx("div",{className:"truncate text-sm font-semibold text-foreground",title:e.displayName,children:e.displayName}),i.jsxs("div",{className:"text-xs text-muted-foreground",children:[F,e.fullPath!==e.displayName&&i.jsxs("span",{className:"ml-1 opacity-60",title:e.fullPath,children:[" - ",e.fullPath.length>25?`...${e.fullPath.slice(-22)}`:e.fullPath]})]})]})})]}),i.jsx("div",{className:"flex flex-shrink-0 items-center gap-1",children:H?i.jsxs(i.Fragment,{children:[i.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:be=>{be.stopPropagation(),me()},children:i.jsx(nr,{className:"h-3 w-3"})}),i.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:be=>{be.stopPropagation(),j()},children:i.jsx(bt,{className:"h-3 w-3"})})]}):i.jsxs(i.Fragment,{children:[s&&i.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:be=>{be.stopPropagation(),ie()},title:V("tooltips.removeFromFavorites"),children:i.jsx(Rs,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),i.jsx(qN,{triggerLabel:V("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:V("actions.rename"),icon:Wm,onClick:()=>k(e)},{id:"star",label:V(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:Rs,onClick:ie},{id:"delete",label:V("actions.delete",{defaultValue:"Delete"}),icon:kr,onClick:()=>A(e),danger:!0}]}),n?i.jsx(Fr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):i.jsx(An,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),i.jsx(LM,{project:e,isExpanded:n,sessions:c,selectedSession:r,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:m,isSessionStarred:x,onEditingSessionNameChange:P,onStartEditingSession:G,onCancelEditingSession:z,onSaveEditingSession:U,onToggleStarSession:E,onProjectSelect:w,onSessionSelect:C,onDeleteSession:R,onLoadMoreSessions:T,onNewSession:I,onOpenOrchestration:N,t:V})]})}function KN({isLoading:e,loadingProgress:t,projectsCount:r,filteredProjectsCount:n,t:a}){return e?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.loadingProjects")}),t&&t.total>0?i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:i.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${t.current/t.total*100}%`}})}),i.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.current,"/",t.total," ",a("projects.projects")]}),t.currentProject&&i.jsx("p",{className:"mx-auto max-w-[200px] truncate text-xs text-muted-foreground/70",title:t.currentProject,children:t.currentProject.split("-").slice(-2).join("/")})]}):i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.fetchingProjects")})]}):r===0?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx(Pn,{className:"h-6 w-6 text-muted-foreground"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.runClaudeCli")})]}):n===0?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx(Na,{className:"h-6 w-6 text-muted-foreground"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noMatchingProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.tryDifferentSearch")})]}):null}function MM({projects:e,filteredProjects:t,selectedProject:r,selectedSession:n,isLoading:a,loadingProgress:s,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:d,initialSessionsLoaded:u,currentTime:p,editingSession:f,editingSessionName:m,deletingProjects:g,tasksEnabled:b,mcpServerStatus:x,getProjectSessions:y,isProjectStarred:v,isSessionStarred:w,onEditingNameChange:S,onToggleProject:E,onProjectSelect:k,onToggleStarProject:j,onToggleStarSession:_,onStartEditingProject:A,onCancelEditingProject:C,onSaveProjectName:R,onDeleteProject:T,onSessionSelect:I,onDeleteSession:N,onLoadMoreSessions:P,onNewSession:G,onOpenOrchestration:z,onEditingSessionNameChange:U,onStartEditingSession:V,onCancelEditingSession:O,onSaveEditingSession:H,t:$}){const F=i.jsx(KN,{isLoading:a,loadingProgress:s,projectsCount:e.length,filteredProjectsCount:t.length,t:$});h.useEffect(()=>{let pe="Pixcode";const be=r?.displayName?.trim();be&&(pe=`${be} - ${pe}`),document.title=pe},[r]);const ne=!a&&e.length>0&&t.length>0,ee=pe=>pe.source==="history"||pe.autoDiscovered===!0&&pe.isManuallyAdded!==!0,ge=t.filter(pe=>!ee(pe)),ie=t.filter(pe=>ee(pe)),me=pe=>i.jsx(OM,{project:pe,selectedProject:r,selectedSession:n,isExpanded:o.has(pe.name),isDeleting:g.has(pe.name),isStarred:v(pe.name),editingProject:l,editingName:c,sessions:y(pe),initialSessionsLoaded:u.has(pe.name),isLoadingSessions:!!d[pe.name],currentTime:p,editingSession:f,editingSessionName:m,tasksEnabled:b,mcpServerStatus:x,isSessionStarred:w,onEditingNameChange:S,onToggleProject:E,onProjectSelect:k,onToggleStarProject:j,onToggleStarSession:_,onStartEditingProject:A,onCancelEditingProject:C,onSaveProjectName:R,onDeleteProject:T,onSessionSelect:I,onDeleteSession:N,onLoadMoreSessions:P,onNewSession:G,onOpenOrchestration:z,onEditingSessionNameChange:U,onStartEditingSession:V,onCancelEditingSession:O,onSaveEditingSession:H,t:$},pe.name);return i.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:ne?i.jsxs(i.Fragment,{children:[ge.map(pe=>me(pe)),ie.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:$("projects.detectedFromHistory")}),ie.map(pe=>me(pe))]})]}):F})}function fa(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function YN(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}/*!
|
|
229
|
+
*/const xD=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],yD=ft("workflow",xD),Tf=oE,xE=i7,Zv=t7,vD=m7,wD=qI,Af=XI,kD=sE,Fr=dE,SD=W7,jf=$7,An=G7,ED=V7,Yr=QI,ta=sE,cd=n7,yE=YI,ND=M7,CD=F7,vE=o7,mt=lE,Dt=lE,Kd=u7,wE=c7,TD=n8,Nn=vR,Ar=kR,nr=D7,ra=R7,kE=UR,cn=C8,AD=mE,jD=mE,dd=N7,Yd=X7,SE=Y7,Zd=uE,rl=rR,Gs=pR,Ht=hR,Pn=DR,Ea=_R,ii=RR,_D=d8,ID=BR,fl=WR,Ml=v8,RD=f7,Pl=T7,LD=$8,DD=Cf,OD=Cf,Wm=o8,EE=MR,MD=AR,PD=I8,FD=x8,zD=QR,NE=i8,Km=Cf,_f=p8,Vt=h8,kr=G8,BD=gR,Na=XR,bt=hE,Ym=hE,Xd=O8,If=w7,$D=y7,Zm=b7,UD=xR,na=cE,GD=cE,HD=V8,CE=W8,gl=j7,TE=eR,Zi=CR,Rf=ER,Fn=FR,AE=uE,Jd=pE,VD=pE,jE=VR,vn=YR,Lf=t8,_E=lR,IE=z8,qD=g8,Df=E8,WD=k8,Rt=aR,KD=UI,RE=dR,Ca=j8,Rs=L8,Of=P8,Hr=sR,Mf=S7,YD=nL,Fl=cL,Pf=gE,ZD=gE,en=qL,Gc=KL,XD=ZL,os=tL,ls=iL,JD=oL,Uo=uL,Ls=mL,Xv=xL,Go=vL,To=EL,QD=CL,LE=FL,Xm=AL,Ii=RL,Ao=_L,Jv=DL,jo=ML,Jm=BL,eO=UL,Qm=HL,Cs=eD,Ho=rD,$a=aD,cs=sD,tO=lD,eh=dD,rO=mD,_o=bD,aa=yD,bl=gL,DE=kL,nO=JL,aO=fD,iO=[{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"}],sO={up:xE,down:Tf,left:wD,right:Af},Io=e=>e.preventDefault(),Qv="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",oO="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",Vu="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 ew({wsRef:e,terminalRef:t,isConnected:r,bottomOffset:n="bottom-0"}){const{t:a}=Me("settings"),[s,o]=h.useState(!1),[l,c]=h.useState(!1),d=h.useCallback(m=>{Pi(e.current,{type:"input",data:m})},[e]),u=h.useCallback(()=>{t.current?.scrollToBottom()},[t]),p=h.useCallback(async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.readText))try{const m=await navigator.clipboard.readText();m.length>0&&d(m)}catch{}},[d]),f=h.useCallback(m=>{let g=m;if(s&&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)},[s,l,d]);return i.jsx("div",{className:`pointer-events-none fixed inset-x-0 ${n} z-20 px-2 md:hidden`,children:i.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:[i.jsx("button",{type:"button",onPointerDown:Io,onClick:()=>{p()},disabled:!r,className:Vu,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:i.jsx(Yd,{className:"h-4 w-4"})}),iO.map(m=>{if(m.type==="modifier"){const g=m.modifier==="ctrl"?s:l,b=m.modifier==="ctrl"?()=>o(x=>!x):()=>c(x=>!x);return i.jsx("button",{type:"button",onPointerDown:Io,onClick:b,disabled:!r,className:g?oO:Qv,children:m.label},m.id)}if(m.type==="arrow"){const g=sO[m.icon];return i.jsx("button",{type:"button",onPointerDown:Io,onClick:()=>d(m.sequence),disabled:!r,className:Vu,children:i.jsx(g,{className:"h-4 w-4"})},m.id)}return i.jsx("button",{type:"button",onPointerDown:Io,onClick:()=>f(m.sequence),disabled:!r,className:Qv,children:m.label},m.id)}),i.jsx("button",{type:"button",onPointerDown:Io,onClick:u,disabled:!r,className:Vu,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:i.jsx(kD,{className:"h-4 w-4"})})]})})}function OE({selectedProject:e=null,selectedSession:t=null,initialCommand:r=null,isPlainShell:n=!1,onProcessComplete:a=null,minimal:s=!1,autoConnect:o=!1,isActive:l=!0}){const{t:c}=Me("chat"),[d,u]=h.useState(!1),[p,f]=h.useState(null),m=h.useRef(null),g=h.useRef(null),{terminalContainerRef:b,terminalRef:x,wsRef:y,isConnected:v,isInitialized:w,isConnecting:S,authUrl:E,authUrlVersion:k,connectToShell:j,disconnectFromShell:_,openAuthUrlInBrowser:A,copyAuthUrlToClipboard:C}=MI({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:n,minimal:s,autoConnect:o,isRestarting:d,onProcessComplete:a,onOutputRef:g}),R=h.useCallback(()=>{const $=x.current;if(!$)return;const F=$.buffer.active,ne=F.baseY+F.cursorY,ee=Math.min(F.baseY+F.length-1,ne+10),ge=Math.max(0,ne-fI),ie=[];for(let xe=ge;xe<=ee;xe++){const Ue=F.getLine(xe);Ue&&ie.push(Ue.translateToString().trimEnd())}let me=-1;for(let xe=ie.length-1;xe>=0;xe--)if(/esc to cancel/i.test(ie[xe])||/enter to select/i.test(ie[xe])){me=xe;break}if(me===-1){f(null);return}const pe=new Map,be=Math.max(0,me-gI);for(let xe=me-1;xe>=be;xe--){const Ue=ie[xe].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(Ue){const M=Ue[1],de=Ue[2].trim();parseInt(M,10)<=bI&&de.length>0&&!pe.has(M)&&pe.set(M,de)}}const Ee=[];for(let xe=1;xe<=pe.size&&pe.has(String(xe));xe++)Ee.push({number:String(xe),label:pe.get(String(xe))});f(Ee.length>=xI?Ee:null)},[x]),T=h.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(R,hI)},[R]);h.useEffect(()=>{g.current=T},[T]),h.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),h.useEffect(()=>{v||(m.current&&(clearTimeout(m.current),m.current=null),f(null))},[v]),h.useEffect(()=>{if(!l||!w||!v)return;const $=()=>{x.current?.focus()},F=window.requestAnimationFrame($),ne=window.setTimeout($,0);return()=>{window.cancelAnimationFrame(F),window.clearTimeout(ne)}},[l,v,w,x]);const I=h.useCallback($=>{Pi(y.current,{type:"input",data:$})},[y]),N=h.useMemo(()=>RI(t),[t]),P=h.useMemo(()=>N?N.slice(0,30):null,[N]),G=h.useMemo(()=>N?N.slice(0,50):null,[N]),z=h.useCallback(()=>{u(!0),window.setTimeout(()=>{u(!1)},pI)},[]);if(!e)return i.jsx(FI,{title:c("shell.selectProject.title"),description:c("shell.selectProject.description")});if(s)return i.jsxs(i.Fragment,{children:[i.jsx(BI,{terminalContainerRef:b,authUrl:E,authUrlVersion:k,initialCommand:r,isConnected:v,openAuthUrlInBrowser:A,copyAuthUrlToClipboard:C}),i.jsx(ew,{wsRef:y,terminalRef:x,isConnected:v,bottomOffset:"bottom-0"})]});const U=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:G}):c("shell.startSession"),V=n?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName}),O=w?S?"connecting":v?null:"connect":"loading",H=O==="connecting"?V:U;return i.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[i.jsx(zI,{isConnected:v,isInitialized:w,isRestarting:d,hasSession:!!t,sessionDisplayNameShort:P,onDisconnect:_,onRestart:z,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}),i.jsxs("div",{className:"relative flex-1 overflow-hidden p-2",children:[i.jsx("div",{ref:b,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),O&&i.jsx(PI,{mode:O,description:H,loadingLabel:c("shell.loading"),connectLabel:c("shell.actions.connect"),connectTitle:c("shell.actions.connectTitle"),connectingLabel:c("shell.connecting"),onConnect:j}),p&&v&&i.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:$=>$.preventDefault(),children:i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map($=>i.jsxs("button",{type:"button",onClick:()=>{I($.number),f(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:`${$.number}. ${$.label}`,children:[$.number,". ",$.label]},$.number)),i.jsx("button",{type:"button",onClick:()=>{I("\x1B"),f(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"})]})})]}),i.jsx(ew,{wsRef:y,terminalRef:x,isConnected:v})]})}function lO({className:e}){return i.jsx("div",{className:`flex h-full items-center justify-center ${e}`,children:i.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[i.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:i.jsx("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),i.jsx("h3",{className:"mb-2 text-lg font-semibold",children:"No Project Selected"}),i.jsx("p",{children:"A project is required to open a shell"})]})})}function cO({title:e,isCompleted:t,onClose:r=null}){return i.jsx("div",{className:"flex-shrink-0 border-b border-gray-700 bg-gray-800 px-4 py-2",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx("h3",{className:"text-sm font-medium text-gray-200",children:e}),t&&i.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),r&&i.jsx("button",{onClick:r,className:"text-gray-400 hover:text-white",title:"Close",children:i.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}function ME({project:e=null,session:t=null,command:r=null,isPlainShell:n=null,isActive:a=!0,autoConnect:s=!0,onComplete:o=null,onClose:l=null,title:c=null,className:d="",showHeader:u=!0,compact:p=!1,minimal:f=!1}){const[m,g]=h.useState(!1),b=n!==null?n:r!==null,x=h.useCallback(y=>{g(!0),o?.(y)},[o]);return e?i.jsxs("div",{className:`flex h-full w-full flex-col ${d}`,children:[!f&&u&&c&&i.jsx(cO,{title:c,isCompleted:m,onClose:l}),i.jsx("div",{className:"min-h-0 w-full flex-1",children:i.jsx(OE,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:b,isActive:a,onProcessComplete:x,minimal:f,autoConnect:f?!0:s})})]}):i.jsx(lO,{className:d})}const dO=(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"),uO={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 tw({active:e,children:t,onClick:r}){return i.jsx("button",{onClick:r,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 pO({provider:e}){const[t,r]=h.useState(""),[n,a]=h.useState(!1),[s,o]=h.useState("idle"),[l,c]=h.useState(null),d=async()=>{const u=t.trim();if(u){a(!0),c(null),o("idle");try{const p=await ve(`/api/providers/${e}/oauth-paste`,{method:"POST",body:JSON.stringify({callbackUrl:u})}),f=await p.json().catch(()=>({}));if(!p.ok||!f?.success)throw new Error(f?.error||`Request failed (${p.status})`);o("ok"),r("")}catch(p){c(p?.message||"Forward failed"),o("error")}finally{a(!1)}}};return i.jsxs("div",{className:"mt-3 rounded-lg border border-border/60 bg-muted/30 p-3 text-sm",children:[i.jsx("div",{className:"mb-2 font-medium text-foreground",children:"Remote login? Paste the callback URL here"}),i.jsxs("p",{className:"mb-3 text-xs text-muted-foreground",children:["When the CLI shows ",i.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."]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"url",value:t,onChange:u=>r(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()}}),i.jsx("button",{onClick:()=>void d(),disabled:n||!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:n?i.jsx(Dt,{className:"h-3.5 w-3.5 animate-spin"}):"Forward"})]}),s==="ok"&&i.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-emerald-600 dark:text-emerald-400",children:[i.jsx(nr,{className:"h-3.5 w-3.5"})," Forwarded — check the terminal above for the completion message."]}),s==="error"&&l&&i.jsx("div",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:l})]})}function mO({provider:e,onSaved:t}){const r=uO[e],[n,a]=h.useState(""),[s,o]=h.useState(""),[l,c]=h.useState(!1),[d,u]=h.useState("idle"),[p,f]=h.useState(null);h.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await ve("/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=n.trim();if(g){c(!0),f(null),u("idle");try{const b=await ve(`/api/providers/${e}/auth/api-key`,{method:"POST",body:JSON.stringify({apiKey:g,baseUrl:r.supportsBaseUrl&&s.trim()?s.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){f(b?.message||"Save failed"),u("error")}finally{c(!1)}}};return r?i.jsx("div",{className:"flex h-full flex-col overflow-y-auto p-6",children:i.jsxs("div",{className:"mx-auto w-full max-w-lg space-y-5",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-muted",children:i.jsx(VD,{className:"h-5 w-5 text-foreground"})}),i.jsxs("div",{children:[i.jsx("h4",{className:"text-base font-semibold text-foreground",children:r.keyLabel}),i.jsxs("a",{href:r.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 ",r.keyConsoleLabel,i.jsx(Yr,{className:"h-3 w-3"})]})]})]}),r.notes&&i.jsx("div",{className:"rounded-md border border-border/60 bg-muted/40 p-3 text-xs text-muted-foreground",children:r.notes}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{className:"text-xs font-medium text-foreground",children:"API Key"}),i.jsx("input",{type:"password",value:n,onChange:g=>a(g.target.value),placeholder:r.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}),i.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Stored locally at ",i.jsx("code",{className:"rounded bg-muted px-1 font-mono text-[10px]",children:"~/.pixcode/provider-credentials.json"})," with 0600 permissions."]})]}),r.supportsBaseUrl&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-foreground",children:["Base URL ",i.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional — use a custom endpoint)"})]}),i.jsx("input",{type:"url",value:s,onChange:g=>o(g.target.value),placeholder:r.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}),i.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."})]}),i.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[i.jsxs("button",{onClick:()=>void m(),disabled:l||!n.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?i.jsx(Dt,{className:"h-4 w-4 animate-spin"}):i.jsx(nr,{className:"h-4 w-4"}),"Save API Key"]}),d==="ok"&&i.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved — reconnect to pick it up."}),d==="error"&&p&&i.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:p})]})]})}):i.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"This provider uses OAuth only — use the Browser tab to log in."})}function PE({isOpen:e,onClose:t,provider:r="claude",onComplete:n,customCommand:a,isAuthenticated:s=!1}){const{t:o}=Me("common"),l=r!=="cursor",[c,d]=h.useState(l?"apiKey":"browser");h.useEffect(()=>{e&&d(l?"apiKey":"browser")},[e,r,l]);const u=h.useMemo(()=>`${hl[r]??r} Login`,[r]);if(!e)return null;const p=dO(r,a),f=m=>n?.(m);return i.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:i.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:[i.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:u}),i.jsx("button",{onClick:t,className:"text-gray-400 transition-colors hover:text-gray-600 dark:hover:text-gray-300","aria-label":"Close login modal",children:i.jsx(bt,{className:"h-6 w-6"})})]}),i.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[i.jsx(tw,{active:c==="browser",onClick:()=>d("browser"),children:"Browser / OAuth"}),l&&i.jsx(tw,{active:c==="apiKey",onClick:()=>d("apiKey"),children:"API Key"})]}),i.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:c==="browser"?i.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(ME,{project:X_,command:p,onComplete:f,minimal:!0})}),i.jsx("div",{className:"border-t border-border/40 bg-background/50 px-4 py-3",children:i.jsx(pO,{provider:r})})]}):i.jsx(mO,{provider:r,onSaved:()=>f(0)})})]})})}const hO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),fO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ma();return i.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},gO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ma();return i.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},bO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),xO=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ma(),r=t?"/icons/opencode-logo-dark.svg":"/icons/opencode-logo-light.svg";return i.jsx("img",{src:r,alt:"OpenCode",className:e})},yO=({className:e="w-5 h-5"})=>i.jsx("img",{src:"/icons/qwen-logo.svg",alt:"Qwen Code",className:e});function dr({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?i.jsx(gO,{className:t}):e==="codex"?i.jsx(fO,{className:t}):e==="gemini"?i.jsx(bO,{className:t}):e==="qwen"?i.jsx(yO,{className:t}):e==="opencode"?i.jsx(xO,{className:t}):i.jsx(hO,{className:t})}function vO({provider:e,title:t,status:r,connectedClassName:n,iconContainerClassName:a,loginButtonClassName:s,onLogin:o}){const l=r.authenticated?n:"border-border bg-card",c=r.loading?"Checking...":r.authenticated?r.email||"Connected":r.error||"Not connected";return i.jsx("div",{className:`rounded-lg border p-4 transition-colors ${l}`,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-full ${a}`,children:i.jsx(dr,{provider:e,className:"h-5 w-5"})}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 font-medium text-foreground",children:[t,r.authenticated&&i.jsx(nr,{className:"h-4 w-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:c})]})]}),!r.authenticated&&!r.loading&&i.jsx("button",{onClick:o,className:`${s} rounded-lg px-4 py-2 text-sm font-medium text-white transition-colors`,children:"Login"})]})})}const wO=[{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 kO({providerStatuses:e,onOpenProviderLogin:t}){return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"mb-6 text-center",children:[i.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Connect Your AI Agents"}),i.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),i.jsx("div",{className:"space-y-3",children:wO.map(r=>i.jsx(vO,{provider:r.provider,title:r.title,status:e[r.provider],connectedClassName:r.connectedClassName,iconContainerClassName:r.iconContainerClassName,loginButtonClassName:r.loginButtonClassName,onLogin:()=>t(r.provider)},r.provider))}),i.jsx("div",{className:"pt-2 text-center text-sm text-muted-foreground",children:i.jsx("p",{children:"You can configure these later in Settings."})})]})}function SO({gitName:e,gitEmail:t,isSubmitting:r,onGitNameChange:n,onGitEmailChange:a}){return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"mb-8 text-center",children:[i.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:i.jsx(en,{className:"h-8 w-8 text-blue-600 dark:text-blue-400"})}),i.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Git Configuration"}),i.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for commits."})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitName",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[i.jsx(HD,{className:"h-4 w-4"}),"Git Name ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"text",id:"gitName",value:e,onChange:s=>n(s.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:r}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.name`."})]}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitEmail",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[i.jsx(UD,{className:"h-4 w-4"}),"Git Email ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"email",id:"gitEmail",value:t,onChange:s=>a(s.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:r}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.email`."})]})]})]})}const rw=[{title:"Git Configuration",icon:en,required:!0},{title:"Connect Agents",icon:yE,required:!1},{title:"Task System",icon:Ml,required:!1}];function EO({currentStep:e}){return i.jsx("div",{className:"mb-8",children:i.jsx("div",{className:"flex items-center justify-between",children:rw.map((t,r)=>{const n=r<e,a=r===e,s=t.icon;return i.jsxs("div",{className:"contents",children:[i.jsxs("div",{className:"flex flex-1 flex-col items-center",children:[i.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-full border-2 transition-colors duration-200 ${n?"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:n?i.jsx(nr,{className:"h-6 w-6"}):i.jsx(s,{className:"h-6 w-6"})}),i.jsxs("div",{className:"mt-2 text-center",children:[i.jsx("p",{className:`text-sm font-medium ${a?"text-foreground":"text-muted-foreground"}`,children:t.title}),t.required&&i.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),r<rw.length-1&&i.jsx("div",{className:`mx-2 h-0.5 flex-1 transition-colors duration-200 ${n?"bg-green-500":"bg-border"}`})]},t.title)})})})}const NO=e=>e?e.installation?.isInstalled?e.installation.version?`TaskMaster CLI installed (${e.installation.version}).`:"TaskMaster CLI installed.":e.installation?.reason||"TaskMaster CLI is not installed yet.":"Checking TaskMaster installation...";function CO({enabled:e,onEnabledChange:t,onReadyChange:r}){const[n,a]=h.useState(null),[s,o]=h.useState(!0),[l,c]=h.useState(!1),[d,u]=h.useState([]),[p,f]=h.useState(""),m=h.useRef(null),g=!!n?.installation?.isInstalled,b=!!n?.mcpServer?.hasMCPServer,x=h.useMemo(()=>!e||g,[e,g]);h.useEffect(()=>{r(x)},[r,x]);const y=h.useCallback(async()=>{o(!0),f("");try{const w=await ve("/api/taskmaster/installation-status"),S=await w.json();a(S),w.ok||f(S.installation?.reason||"TaskMaster status check failed.")}catch(w){a(null),f(w instanceof Error?w.message:"TaskMaster status check failed.")}finally{o(!1)}},[]);h.useEffect(()=>(y(),()=>{m.current?.close(),m.current=null}),[y]);const v=h.useCallback(async()=>{c(!0),f(""),u([]);try{const w=await ve("/api/taskmaster/install",{method:"POST"}),S=await w.json();if(!w.ok||!S.success||!S.jobId)throw new Error(S.error||S.message||"TaskMaster install could not start.");const E=localStorage.getItem(Wd),k=E?`?token=${encodeURIComponent(E)}`:"",j=new EventSource(`/api/taskmaster/install/${encodeURIComponent(S.jobId)}/stream${k}`);m.current=j,j.addEventListener("log",_=>{const A=JSON.parse(_.data);u(C=>[...C,A].slice(-80))}),j.addEventListener("done",_=>{const A=JSON.parse(_.data);if(j.close(),m.current=null,c(!1),!A.success){f(A.error||A.message||"TaskMaster install failed.");return}y()}),j.onerror=()=>{j.close(),m.current=null,c(!1),f("TaskMaster install stream disconnected.")}}catch(w){c(!1),f(w instanceof Error?w.message:"TaskMaster install could not start.")}},[y]);return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("h2",{className:"text-2xl font-semibold text-foreground",children:"Task System"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Decide whether Pixcode should enable TaskMaster-backed planning, kanban tasks, PRD parsing, and agent task execution from the start."})]}),i.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-lg border border-border bg-background p-4 transition-colors hover:bg-muted/40",children:[i.jsx("input",{type:"checkbox",checked:e,onChange:w=>t(w.target.checked),className:"mt-1 h-4 w-4"}),i.jsxs("span",{className:"min-w-0 space-y-1",children:[i.jsx("span",{className:"block text-sm font-medium text-foreground",children:"Enable TaskMaster features"}),i.jsx("span",{className:"block text-sm leading-6 text-muted-foreground",children:"This keeps the Tasks panel, PRD tools, and orchestration task sync available. You can change it later in Settings."})]})]}),e&&i.jsxs("div",{className:"space-y-4 rounded-lg border border-border bg-card p-4",children:[i.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[g?i.jsx(ra,{className:"h-5 w-5 text-green-600"}):i.jsx(Hr,{className:"h-5 w-5 text-primary"}),i.jsx("h3",{className:"font-medium text-foreground",children:"TaskMaster CLI"})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:NO(n)}),g&&!b&&i.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:"MCP server is not configured yet. Core task files work now; MCP can be connected later from Settings."})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>void y(),disabled:s||l,className:"rounded-md border border-border px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:s?"Checking...":"Refresh"}),!g&&i.jsxs("button",{type:"button",onClick:()=>void v(),disabled:l,className:"inline-flex items-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-60",children:[l&&i.jsx(Dt,{className:"h-4 w-4 animate-spin"}),l?"Installing...":"Install"]})]})]}),p&&i.jsx("div",{className:"rounded-md border border-red-300 bg-red-50 p-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-950/30 dark:text-red-300",children:p}),d.length>0&&i.jsx("pre",{className:"max-h-48 overflow-auto rounded-md bg-black p-3 text-xs leading-5 text-green-200",children:d.map(w=>`${w.stream}> ${w.chunk}`).join("")})]})]})}const nw=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,aw=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function TO({onComplete:e}){const[t,r]=h.useState(0),[n,a]=h.useState(""),[s,o]=h.useState(""),[l,c]=h.useState(!1),[d,u]=h.useState(""),[p,f]=h.useState(null),[m,g]=h.useState(()=>{try{const T=localStorage.getItem("tasks-enabled");return T===null?!0:JSON.parse(T)!==!1}catch{return!0}}),[b,x]=h.useState(!1),{providerAuthStatus:y,checkProviderAuthStatus:v,refreshProviderAuthStatuses:w}=Nf(),S=h.useRef(void 0),E=h.useCallback(async()=>{try{const T=await ve("/api/user/git-config");if(!T.ok)return;const I=await T.json();I.gitName&&a(I.gitName),I.gitEmail&&o(I.gitEmail)}catch(T){console.error("Error loading git config:",T)}},[]);h.useEffect(()=>{E(),w()},[E,w]),h.useEffect(()=>{const T=S.current;S.current=p,T!=null&&p===null&&w()},[p,w]);const k=T=>{f(T)},j=T=>{T===0&&p&&v(p)},_=async()=>{if(u(""),t!==0){r(T=>T+1);return}if(!n.trim()||!s.trim()){u("Both git name and email are required.");return}if(!nw.test(s)){u("Please enter a valid email address.");return}c(!0);try{const T=await ve("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:n,gitEmail:s})});if(!T.ok){const I=await aw(T,"Failed to save git configuration");throw new Error(I)}r(I=>I+1)}catch(T){u(T instanceof Error?T.message:"Failed to save git configuration")}finally{c(!1)}},A=()=>{u(""),r(T=>T-1)},C=async()=>{if(m&&!b){u("Install TaskMaster or disable TaskMaster features to finish setup.");return}c(!0),u("");try{localStorage.setItem("tasks-enabled",JSON.stringify(m));const T=await ve("/api/user/complete-onboarding",{method:"POST"});if(!T.ok){const I=await aw(T,"Failed to complete onboarding");throw new Error(I)}await e?.()}catch(T){u(T instanceof Error?T.message:"Failed to complete onboarding")}finally{c(!1)}},R=t===0?!!(n.trim()&&s.trim()&&nw.test(s)):t===2?!m||b:!0;return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs("div",{className:"w-full max-w-2xl",children:[i.jsx(EO,{currentStep:t}),i.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?i.jsx(SO,{gitName:n,gitEmail:s,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):t===1?i.jsx(kO,{providerStatuses:y,onOpenProviderLogin:k}):i.jsx(CO,{enabled:m,onEnabledChange:g,onReadyChange:x}),d&&i.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:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:d})}),i.jsxs("div",{className:"mt-8 flex items-center justify-between border-t border-border pt-6",children:[i.jsxs("button",{onClick:A,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:[i.jsx(jf,{className:"h-4 w-4"}),"Previous"]}),i.jsx("div",{className:"flex items-center gap-3",children:t<2?i.jsx("button",{onClick:_,disabled:!R||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?i.jsxs(i.Fragment,{children:[i.jsx(Dt,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):i.jsxs(i.Fragment,{children:["Next",i.jsx(An,{className:"h-4 w-4"})]})}):i.jsx("button",{onClick:C,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?i.jsxs(i.Fragment,{children:[i.jsx(Dt,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):i.jsxs(i.Fragment,{children:[i.jsx(nr,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&i.jsx(PE,{isOpen:!!p,onClose:()=>f(null),provider:p,onComplete:j})]})}const AO=["0s","0.1s","0.2s"];function jO(){return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"mb-4 flex justify-center",children:i.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:i.jsx(na,{className:"h-8 w-8 text-primary-foreground"})})}),i.jsx("h1",{className:"mb-2 text-2xl font-bold text-foreground",children:"Pixcode"}),i.jsx("div",{className:"flex items-center justify-center space-x-2",children:AO.map(e=>i.jsx("div",{className:"h-2 w-2 animate-bounce rounded-full bg-blue-500",style:{animationDelay:e}},e))}),i.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading..."})]})})}function FE({errorMessage:e}){return e?i.jsx("div",{className:"rounded-md border border-red-300 bg-red-100 p-3 dark:border-red-800 dark:bg-red-900/20",children:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:e})}):null}function Ri({id:e,label:t,value:r,onChange:n,placeholder:a,isDisabled:s,type:o="text",name:l,autoComplete:c}){return i.jsxs("div",{children:[i.jsx("label",{htmlFor:e,className:"mb-1 block text-sm font-medium text-foreground",children:t}),i.jsx("input",{id:e,type:o,name:l??e,autoComplete:c,value:r,onChange:d=>n(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:s})]})}function zE({title:e,description:t,children:r,footerText:n,logo:a}){return i.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:i.jsx("div",{className:"w-full max-w-md",children:i.jsxs("div",{className:"space-y-6 rounded-lg border border-border bg-card p-8 shadow-lg",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"mb-4 flex justify-center",children:a??i.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:i.jsx(na,{className:"h-8 w-8 text-primary-foreground"})})}),i.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e}),i.jsx("p",{className:"mt-2 text-muted-foreground",children:t})]}),r,i.jsx("div",{className:"text-center",children:i.jsx("p",{className:"text-sm text-muted-foreground",children:n})}),i.jsxs("div",{className:"flex items-center justify-center gap-1.5 pt-2",children:[i.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.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"})}),i.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 _O={username:"",password:""};function IO(){const{t:e}=Me("auth"),{login:t}=Yi(),[r,n]=h.useState(_O),[a,s]=h.useState(""),[o,l]=h.useState(!1),c=h.useCallback((u,p)=>{n(f=>({...f,[u]:p}))},[]),d=h.useCallback(async u=>{if(u.preventDefault(),s(""),!r.username.trim()||!r.password){s(e("login.errors.requiredFields"));return}l(!0);const p=await t(r.username.trim(),r.password);p.success||s(p.error),l(!1)},[r.password,r.username,t,e]);return i.jsx(zE,{title:e("login.title"),description:e("login.description"),footerText:"Enter your credentials to access Pixcode",children:i.jsxs("form",{onSubmit:d,className:"space-y-4",children:[i.jsx(Ri,{id:"username",label:e("login.username"),value:r.username,onChange:u=>c("username",u),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),i.jsx(Ri,{id:"password",label:e("login.password"),value:r.password,onChange:u=>c("password",u),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),i.jsx(FE,{errorMessage:a}),i.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 RO={username:"",password:"",confirmPassword:"",connectionMode:"local",remoteUrl:"",remoteApiKey:""};function LO(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.":e.connectionMode==="remote"&&!e.remoteUrl.trim()?"Remote Pixcode server URL is required.":null}function DO(){const{register:e}=Yi(),[t,r]=h.useState(RO),[n,a]=h.useState(""),[s,o]=h.useState(!1),l=h.useCallback((d,u)=>{r(p=>({...p,[d]:u}))},[]),c=h.useCallback(async d=>{d.preventDefault(),a("");const u=LO(t);if(u){a(u);return}o(!0);const p=await fetch("/api/auth/connection-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:t.connectionMode,remoteUrl:t.connectionMode==="remote"?t.remoteUrl.trim():null,apiKey:t.connectionMode==="remote"?t.remoteApiKey.trim():null})});if(!p.ok){const m=await p.json().catch(()=>null);a(m?.error||"Could not save connection mode."),o(!1);return}const f=await e(t.username.trim(),t.password);f.success||a(f.error),o(!1)},[t,e]);return i.jsx(zE,{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:i.jsx("img",{src:"/logo.svg",alt:"Pixcode",className:"h-16 w-16"}),children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsxs("div",{className:"grid gap-2 rounded-lg border border-border/70 bg-muted/30 p-2 sm:grid-cols-2",children:[i.jsxs("button",{type:"button",onClick:()=>l("connectionMode","local"),disabled:s,className:`rounded-md px-3 py-2 text-left text-sm transition-colors ${t.connectionMode==="local"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60 hover:text-foreground"}`,children:[i.jsx("span",{className:"block font-medium",children:"Use this computer directly"}),i.jsx("span",{className:"block text-xs opacity-80",children:"Run Pixcode and CLIs on this machine."})]}),i.jsxs("button",{type:"button",onClick:()=>l("connectionMode","remote"),disabled:s,className:`rounded-md px-3 py-2 text-left text-sm transition-colors ${t.connectionMode==="remote"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60 hover:text-foreground"}`,children:[i.jsx("span",{className:"block font-medium",children:"Connect to a remote Pixcode server"}),i.jsx("span",{className:"block text-xs opacity-80",children:"Control another always-on Pixcode host by API."})]})]}),t.connectionMode==="remote"&&i.jsxs("div",{className:"space-y-3 rounded-lg border border-border/70 bg-muted/20 p-3",children:[i.jsx(Ri,{id:"remoteUrl",name:"remoteUrl",label:"Remote API URL",value:t.remoteUrl,onChange:d=>l("remoteUrl",d),placeholder:"https://your-server.example.com",isDisabled:s,autoComplete:"url"}),i.jsx(Ri,{id:"remoteApiKey",name:"remoteApiKey",label:"Remote API Key",value:t.remoteApiKey,onChange:d=>l("remoteApiKey",d),placeholder:"px_...",isDisabled:s,type:"password",autoComplete:"off"})]}),i.jsx(Ri,{id:"username",name:"username",label:"Username",value:t.username,onChange:d=>l("username",d),placeholder:"Enter your username",isDisabled:s,autoComplete:"username"}),i.jsx(Ri,{id:"password",name:"password",label:"Password",value:t.password,onChange:d=>l("password",d),placeholder:"Enter your password",isDisabled:s,type:"password",autoComplete:"new-password"}),i.jsx(Ri,{id:"confirmPassword",name:"confirmPassword",label:"Confirm Password",value:t.confirmPassword,onChange:d=>l("confirmPassword",d),placeholder:"Confirm your password",isDisabled:s,type:"password",autoComplete:"new-password"}),i.jsx(FE,{errorMessage:n}),i.jsx("button",{type:"submit",disabled:s,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:s?"Setting up...":"Create Account"})]})})}function OO({children:e}){const{user:t,isLoading:r,needsSetup:n,hasCompletedOnboarding:a,refreshOnboardingStatus:s}=Yi();return r?i.jsx(jO,{}):n?i.jsx(DO,{}):t?a?i.jsx(i.Fragment,{children:e}):i.jsx(TO,{onComplete:s}):i.jsx(IO,{})}const BE=h.createContext(null),$E=()=>{const e=h.useContext(BE);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},MO=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},PO=()=>{const e=h.useRef(null),t=h.useRef(!1),r=h.useRef(!1),[n,a]=h.useState(null),[s,o]=h.useState(!1),l=h.useRef(null),{token:c}=Yi(),d=h.useCallback(()=>{if(!t.current)try{const f=MO(c);if(!f)return console.warn("No authentication token found for WebSocket connection");const m=new WebSocket(f);m.onopen=()=>{o(!0),e.current=m,r.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),r.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(f){console.error("Error creating WebSocket connection:",f)}},[c]);h.useEffect(()=>(d(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[d]);const u=h.useCallback(f=>{const m=e.current;m&&m.readyState===WebSocket.OPEN?m.send(JSON.stringify(f)):console.warn("WebSocket not connected")},[]);return h.useMemo(()=>({ws:e.current,sendMessage:u,latestMessage:n,isConnected:s}),[u,n,s])},FO=({children:e})=>{const t=PO();return i.jsx(BE.Provider,{value:t,children:e})},UE=h.createContext(null);function zO(e,t){return{message:t instanceof Error?t.message:`Failed to ${e}`,context:e,timestamp:new Date().toISOString()}}function iw(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 BO(e){return e.find(t=>t.status==="pending"||t.status==="in-progress")??null}function $O(e){return e?.type?e.type.startsWith("taskmaster-"):!1}function no(){const e=h.useContext(UE);if(!e)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return e}function UO({children:e}){const{latestMessage:t}=$E(),{user:r,token:n,isLoading:a}=Yi(),[s,o]=h.useState([]),[l,c]=h.useState(null),[d,u]=h.useState(null),[p,f]=h.useState(null),[m,g]=h.useState([]),[b,x]=h.useState(null),[y,v]=h.useState(!1),[w,S]=h.useState(!1),[E,k]=h.useState(!1),[j,_]=h.useState(null),A=h.useRef(null);h.useEffect(()=>{A.current=l?.name??null},[l?.name]);const C=h.useCallback(()=>{_(null)},[]),R=h.useCallback((z,U)=>{console.error(`TaskMaster ${z} error:`,U),_(zO(z,U))},[]),T=h.useCallback(z=>{const U=z?iw(z):null;c(U),u(U?.taskmaster??null),g([]),x(null)},[]),I=h.useCallback(async()=>{if(!r||!n){o([]),c(null),u(null),g([]),x(null);return}try{v(!0),C();const z=await ot.get("/projects");if(!z.ok)throw new Error(`Failed to fetch projects: ${z.status}`);const U=await z.json(),O=(Array.isArray(U)?U:[]).map(F=>iw(F));o(O);const H=A.current;if(!H)return;const $=O.find(F=>F.name===H)??null;c($),u($?.taskmaster??null)}catch(z){R("load projects",z)}finally{v(!1)}},[C,R,n,r]),N=h.useCallback(async()=>{const z=l?.name;if(!z||!r||!n){g([]),x(null);return}try{S(!0),C();const U=await ot.get(`/taskmaster/tasks/${encodeURIComponent(z)}`);if(!U.ok){const H=await U.json();throw new Error(H.message??"Failed to load tasks")}const V=await U.json(),O=Array.isArray(V.tasks)?V.tasks:[];g(O),x(BO(O))}catch(U){R("load tasks",U),g([]),x(null)}finally{S(!1)}},[C,l?.name,R,n,r]),P=h.useCallback(async()=>{if(!r||!n){f(null);return}try{k(!0),C();const z=await ot.get("/mcp-utils/taskmaster-server");if(!z.ok)throw new Error(`Failed to load MCP status: ${z.status}`);const U=await z.json();f(U)}catch(z){R("check MCP server status",z),f(null)}finally{k(!1)}},[C,R,n,r]);h.useEffect(()=>{!a&&r&&n&&(I(),P())},[a,P,I,n,r]),h.useEffect(()=>{l?.name&&r&&n&&N()},[l?.name,N,n,r]),h.useEffect(()=>{const z=t;if($O(z)){if(z.type==="taskmaster-project-updated"&&z.projectName){I();return}if(z.type==="taskmaster-tasks-updated"&&z.projectName===l?.name){N();return}z.type==="taskmaster-mcp-status-changed"&&P()}},[l?.name,t,P,I,N]);const G=h.useMemo(()=>({projects:s,currentProject:l,projectTaskMaster:d,mcpServerStatus:p,tasks:m,nextTask:b,isLoading:y,isLoadingTasks:w,isLoadingMCP:E,error:j,refreshProjects:I,setCurrentProject:T,refreshTasks:N,refreshMCPStatus:P,clearError:C}),[C,l,j,y,E,w,p,b,d,s,P,I,N,T,m]);return i.jsx(UE.Provider,{value:G,children:e})}const GE=h.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0,refreshTaskMasterInstallation:async()=>{}}),Qd=()=>{const e=h.useContext(GE);if(!e)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return e},GO=({children:e})=>{const{user:t,token:r,isLoading:n}=Yi(),[a,s]=h.useState(()=>{const v=localStorage.getItem("tasks-enabled");return v!==null?JSON.parse(v):!0}),[o,l]=h.useState(null),[c,d]=h.useState(null),[u,p]=h.useState(null),[f,m]=h.useState(!0),g=!!(t&&r);h.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(a))},[a]);const b=h.useCallback(async({signal:v}={})=>{if(!n){if(!g){p(null),l(null),d(null),m(!1);return}m(!0);try{const w=await ot.get("/taskmaster/installation-status");if(v?.aborted)return;if(w.ok){const S=await w.json();if(v?.aborted)return;p(S),l(S.installation?.isInstalled||!1),d(S.isReady||!1);const E=localStorage.getItem("tasks-enabled");!S.installation?.isInstalled&&!E&&s(!1)}else console.error("Failed to check TaskMaster installation status"),l(!1),d(!1)}catch(w){if(v?.aborted)return;console.error("Error checking TaskMaster installation:",w),l(!1),d(!1)}finally{v?.aborted||m(!1)}}},[g,n]);h.useEffect(()=>{const v=new AbortController,w=setTimeout(()=>{b({signal:v.signal})},0);return()=>{v.abort(),clearTimeout(w)}},[b]);const y={tasksEnabled:a,setTasksEnabled:s,toggleTasksEnabled:()=>{s(v=>!v)},isTaskMasterInstalled:o,isTaskMasterReady:c,installationStatus:u,isCheckingInstallation:f,refreshTaskMasterInstallation:b};return i.jsx(GE.Provider,{value:y,children:e})},HE=h.createContext(null);function eu(){const e=h.useContext(HE);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function HO({children:e}){const{user:t,token:r,isLoading:n}=Yi(),[a,s]=h.useState([]),[o,l]=h.useState(!0),[c,d]=h.useState(null),u=!!(t&&r),p=h.useCallback(async()=>{if(!u){s([]),d(null),l(!1);return}l(!0);try{const x=await ve("/api/plugins");if(x.ok){const y=await x.json();s(y.plugins||[]),d(null)}else{let y=`Failed to fetch plugins (${x.status})`;try{const v=await x.json();y=v.details||v.error||y}catch{y=x.statusText||y}d(y)}}catch(x){const y=x instanceof Error?x.message:"Failed to fetch plugins";d(y),console.error("[Plugins] Failed to fetch plugins:",x)}finally{l(!1)}},[u]);h.useEffect(()=>{n||p()},[n,p]);const f=h.useCallback(async x=>{try{const y=await ve("/api/plugins/install",{method:"POST",body:JSON.stringify({url:x})}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Install failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Install failed"}}},[p]),m=h.useCallback(async x=>{try{const y=await ve(`/api/plugins/${encodeURIComponent(x)}`,{method:"DELETE"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Uninstall failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Uninstall failed"}}},[p]),g=h.useCallback(async x=>{try{const y=await ve(`/api/plugins/${encodeURIComponent(x)}/update`,{method:"POST"}),v=await y.json();return y.ok?(await p(),{success:!0}):{success:!1,error:v.details||v.error||"Update failed"}}catch(y){return{success:!1,error:y instanceof Error?y.message:"Update failed"}}},[p]),b=h.useCallback(async(x,y)=>{try{const v=await ve(`/api/plugins/${encodeURIComponent(x)}/enable`,{method:"PUT",body:JSON.stringify({enabled:y})});if(!v.ok){let w=`Toggle failed (${v.status})`;try{const S=await v.json();w=S.details||S.error||w}catch{w=v.statusText||w}return{success:!1,error:w}}return await p(),{success:!0,error:null}}catch(v){return{success:!1,error:v instanceof Error?v.message:"Toggle failed"}}},[p]);return i.jsx(HE.Provider,{value:{plugins:a,loading:o,pluginsError:c,refreshPlugins:p,installPlugin:f,uninstallPlugin:m,updatePlugin:g,togglePlugin:b},children:e})}const sw=e=>typeof window>"u"?!1:window.innerWidth<e,ow=()=>{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 Ff(e={}){const{mobileBreakpoint:t=768,trackMobile:r=!0,trackPWA:n=!0}=e,[a,s]=h.useState(()=>r?sw(t):!1),[o,l]=h.useState(()=>n?ow():!1);return h.useEffect(()=>{if(!r||typeof window>"u")return;const c=()=>{s(sw(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,r]),h.useEffect(()=>{if(!n||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),d=()=>{l(ow())};return d(),typeof c.addEventListener=="function"?(c.addEventListener("change",d),()=>{c.removeEventListener("change",d)}):(c.addListener(d),()=>{c.removeListener(d)})},[n]),{isMobile:a,isPWA:o}}const zf="pixcode.updateCheck.preferences",th="pixcode:update-check-settings-changed",Bf=[{value:"30m",label:"Every 30 minutes",intervalMs:1800*1e3},{value:"24h",label:"Daily",intervalMs:1440*60*1e3},{value:"12h",label:"Every 12 hours",intervalMs:720*60*1e3},{value:"6h",label:"Every 6 hours",intervalMs:360*60*1e3},{value:"7d",label:"Weekly",intervalMs:10080*60*1e3},{value:"off",label:"Manual only",intervalMs:null}],rh={frequency:"30m"};function lw(e){return Bf.find(t=>t.value===e.frequency)?.intervalMs??null}function VE(e){if(!e||typeof e!="object")return rh;const t=e.frequency;return Bf.some(r=>r.value===t)?{frequency:t}:rh}function cw(){try{const e=localStorage.getItem(zf);return VE(e?JSON.parse(e):null)}catch{return rh}}function VO(e){const t=VE(e);localStorage.setItem(zf,JSON.stringify(t)),window.dispatchEvent(new CustomEvent(th,{detail:t}))}const qu=(e,t)=>{const r=e.split(".").map(Number),n=t.split(".").map(Number);for(let a=0;a<Math.max(r.length,n.length);a++){const s=r[a]||0,o=n[a]||0;if(s!==o)return s-o}return 0},qO="1.41.4",nh="pixcode:update-available",WO=360*60*1e3,Wu=new Map;function qE(e,t){return`pixcode.updateCheck.cache.${e}.${t}`}function KO(e,t){try{const r=localStorage.getItem(qE(e,t));if(!r)return null;const n=JSON.parse(r);return{fetchedAt:typeof n.fetchedAt=="number"?n.fetchedAt:null,latestVersion:typeof n.latestVersion=="string"?n.latestVersion:null,releaseInfo:n.releaseInfo??null,rateLimitedUntil:typeof n.rateLimitedUntil=="number"?n.rateLimitedUntil:void 0}}catch{return null}}function dw(e,t,r){localStorage.setItem(qE(e,t),JSON.stringify(r))}function YO(e,t){const r=`${e}/${t}`,n=Wu.get(r);if(n)return n;const a=fetch(`https://api.github.com/repos/${e}/${t}/releases/latest`,{cache:"no-store",headers:{Accept:"application/vnd.github+json"}}).then(async s=>({status:s.status,ok:s.ok,data:await s.json().catch(()=>({}))})).finally(()=>{Wu.delete(r)});return Wu.set(r,a),a}const WE=(e,t)=>{const[r,n]=h.useState(!1),[a,s]=h.useState(null),[o,l]=h.useState(null),[c,d]=h.useState("git"),[u,p]=h.useState("idle"),[f,m]=h.useState(null),[g,b]=h.useState(()=>cw()),[x,y]=h.useState(qO),v=h.useRef(null),w=h.useCallback(E=>{VO(E),b(E)},[]);h.useEffect(()=>{const E=()=>b(cw()),k=j=>{j.key===zf&&E()};return window.addEventListener("storage",k),window.addEventListener(th,E),()=>{window.removeEventListener("storage",k),window.removeEventListener(th,E)}},[]),h.useEffect(()=>{let E=!1;const k=async()=>{try{const A=await(await fetch("/health",{cache:"no-store"})).json();if(E)return;(A.installMode==="npm"||A.installMode==="git")&&d(A.installMode),typeof A.version=="string"&&/^\d+\.\d+\.\d+/.test(A.version)&&y(A.version)}catch{}};k();const j=()=>{k()};return window.addEventListener("focus",j),()=>{E=!0,window.removeEventListener("focus",j)}},[]),h.useEffect(()=>{if(!x)return;let E=!1;const k=(T,I,N,P)=>({updateAvailable:!!(T&&qu(T,x)>0),latestVersion:T,releaseInfo:I,currentVersion:x,checkedAt:N,status:P}),j=T=>{!T.updateAvailable||!T.latestVersion||!T.releaseInfo||window.dispatchEvent(new CustomEvent(nh,{detail:T}))},_=(T,I,N,P="success")=>{if(!T||!I)return n(!1),s(null),l(null),m(N),k(null,null,N,P);s(T),n(qu(T,x)>0),l(I),m(N);const G=k(T,I,N,P);return j(G),G},A=async({force:T=!1}={})=>{const I=lw(g),N=KO(e,t),P=Date.now();if(!T&&I===null)return p("idle"),_(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"idle");if(!T&&N?.fetchedAt&&I!==null&&P-N.fetchedAt<I)return p("success"),_(N.latestVersion,N.releaseInfo,N.fetchedAt,"success");if(!T&&N?.rateLimitedUntil&&N.rateLimitedUntil>P)return p("error"),_(N.latestVersion,N.releaseInfo,N.fetchedAt,"error");try{p("checking");const G=await YO(e,t);if(E)return k(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"idle");const z=G.data;if(!G.ok)return G.status===403&&dw(e,t,{fetchedAt:N?.fetchedAt??null,latestVersion:N?.latestVersion??null,releaseInfo:N?.releaseInfo??null,rateLimitedUntil:P+Math.max(I??0,WO)}),p("error"),_(N?.latestVersion??null,N?.releaseInfo??null,N?.fetchedAt??null,"error");if(z.tag_name){const U=z.tag_name.replace(/^v/,""),V=qu(U,x)>0,O={title:z.name||z.tag_name,body:z.body||"",htmlUrl:z.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:z.published_at||""};dw(e,t,{fetchedAt:P,latestVersion:U,releaseInfo:O}),s(U),n(V),V&&J4({key:`app-update:${U}`,title:"Pixcode update available",body:`Pixcode ${x} can update to ${U}.`,tag:"pixcode-app-update",data:{type:"app-update",latestVersion:U,installMode:c}}),l(O),p("success"),m(P);const H=k(U,O,P,"success");return j(H),H}else return n(!1),s(null),l(null),p("error"),k(null,null,null,"error")}catch(G){return console.error("Version check failed:",G),n(!1),s(null),l(null),p("error"),k(null,null,null,"error")}};v.current=A,A();const C=lw(g),R=C===null?null:window.setInterval(()=>{A()},C);return()=>{E=!0,R!==null&&window.clearInterval(R)}},[e,t,x,c,g]);const S=h.useCallback(async()=>v.current?await v.current({force:!0}):null,[]);return{updateAvailable:r,latestVersion:a,currentVersion:x,releaseInfo:o,installMode:c,checkStatus:u,lastCheckedAt:f,manualCheck:S,updateCheckPreferences:g,updatePreferences:w}},Li={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,changeAwareness:!1,sidebarVisible:!0,historyView:"flat"},ZO=["flat","grouped"],XO=e=>typeof e=="string"&&ZO.includes(e),ud=Object.keys(Li),JO=new Set(ud),Ku="ui-preferences:sync",QO=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},pd=(e,t,r)=>e==="historyView"?XO(t)?t:r:QO(t,r),e9=(e,t)=>{try{const r=localStorage.getItem(e);if(r===null)return t;const n=JSON.parse(r);return pd(e,n,t)}catch{return t}},t9=e=>{if(typeof window>"u")return Li;try{const t=localStorage.getItem(e);if(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&!Array.isArray(r)){const n=r;return ud.reduce((a,s)=>(a[s]=pd(s,n[s],Li[s]),a),{...Li})}}}catch{}return ud.reduce((t,r)=>(t[r]=e9(r,Li[r]),t),{...Li})};function r9(e,t){switch(t.type){case"set":{const{key:r,value:n}=t;if(!JO.has(r))return e;const a=pd(r,n,e[r]);return e[r]===a?e:{...e,[r]:a}}case"set_many":{const r=t.value||{};let n=!1;const a={...e};for(const s of ud){if(!(s in r))continue;const o=r[s],l=pd(s,o,e[s]);a[s]!==l&&(a[s]=l,n=!0)}return n?a:e}case"reset":return{...Li,...t.value||{}};default:return e}}function $f(e="uiPreferences"){const t=h.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,n]=h.useReducer(r9,e,t9);return h.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(Ku,{detail:{storageKey:e,sourceId:t.current,value:r}})))},[r,e]),h.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||n({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 f=u.detail;!f||f.storageKey!==e||f.sourceId===t.current||l(f.value)};return window.addEventListener("storage",c),window.addEventListener(Ku,d),()=>{window.removeEventListener("storage",c),window.removeEventListener(Ku,d)}},[e]),{preferences:r,setPreference:(l,c)=>{n({type:"set",key:l,value:c})},setPreferences:l=>{n({type:"set_many",value:l})},resetPreferences:l=>{n({type:"reset",value:l})},dispatch:n}}const n9=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},a9=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},i9=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},uw=(e,t)=>`${e}::${t}`,s9=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},o9=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},l9=/(?:^|[\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,c9=e=>{if(!e)return[];const t=new Set,r=new RegExp(l9.source,"gi");let n;for(;(n=r.exec(e))!==null;){const a=n[1],s=a.lastIndexOf(".");if(s>-1){const o=a.slice(s+1).toLowerCase();o&&o.length<=10&&t.add(o)}if(t.size>=3)break}return[...t]},zi=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),d9=(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"),u9=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),p9=(e,t,r)=>{const n=zi(e),a=Math.floor((t.getTime()-n.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:d9(e,r),sessionTime:u9(e),messageCount:Number(e.messageCount||0)}},KE=(e,t)=>{const r=[...e.sessions||[],...t[e.name]||[]].map(g=>({...g,__provider:"claude"})),n=(e.cursorSessions||[]).map(g=>({...g,__provider:"cursor"})),a=(e.codexSessions||[]).map(g=>({...g,__provider:"codex"})),s=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=>!s(g)&&!o(g)).map(g=>({...g,__provider:"gemini"})),d=l.filter(g=>s(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],f=[...(e.opencodeSessions||[]).map(g=>({...g,__provider:"opencode"})),...u],m=new Map;for(const g of[...r,...n,...a,...c,...p,...f])m.has(g.id)||m.set(g.id,g);return[...m.values()].sort((g,b)=>zi(b).getTime()-zi(g).getTime())},pw=(e,t)=>{const r=KE(e,t);return r.length===0?new Date(0):r.reduce((n,a)=>{const s=zi(a);return s>n?s:n},new Date(0))},m9=(e,t,r,n)=>{const a=[...e];return a.sort((s,o)=>{const l=r.has(s.name),c=r.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?pw(o,n).getTime()-pw(s,n).getTime():(s.displayName||s.name).localeCompare(o.displayName||o.name)}),a},h9=(e,t)=>{const r=t.trim().toLowerCase();return r?e.filter(n=>{const a=(n.displayName||n.name).toLowerCase(),s=n.name.toLowerCase();return a.includes(r)||s.includes(r)}):e},f9=(e,t)=>{const r=!!e.taskmaster?.hasTaskmaster,n=!!(t?.hasMCPServer&&t?.isConfigured);return r&&n?"fully-configured":r?"taskmaster-only":n?"mcp-only":"not-configured"},g9=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 b9({projects:e,selectedProject:t,selectedSession:r,isLoading:n,isMobile:a,t:s,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:d,onProjectDelete:u,setCurrentProject:p,setSidebarVisible:f,sidebarVisible:m}){const[g,b]=h.useState(new Set),[x,y]=h.useState(null),[v,w]=h.useState(!1),[S,E]=h.useState(""),[k,j]=h.useState({}),[_,A]=h.useState({}),[C,R]=h.useState(new Set),[T,I]=h.useState(new Date),[N,P]=h.useState("name"),[G,z]=h.useState(!1),[U,V]=h.useState({}),[O,H]=h.useState(null),[$,F]=h.useState(""),[ne,ee]=h.useState(""),[ge,ie]=h.useState(new Set),[me,pe]=h.useState(null),[be,Ee]=h.useState(null),[xe,Ue]=h.useState(!1),[M,de]=h.useState(()=>a9()),[ce,Y]=h.useState(()=>s9()),[W,ae]=h.useState("projects"),[fe,ye]=h.useState(null),[oe,we]=h.useState(!1),[te,X]=h.useState(null),Z=h.useRef(null),le=h.useRef(0),ke=h.useRef(null),Te=!a&&!m;h.useEffect(()=>{const Se=setInterval(()=>{I(new Date)},6e4);return()=>clearInterval(Se)},[]),h.useEffect(()=>{A({}),R(new Set),V({})},[e]),h.useEffect(()=>{t&&b(Se=>{if(Se.has(t.name))return Se;const Ae=new Set(Se);return Ae.add(t.name),Ae})},[r,t]),h.useEffect(()=>{if(e.length>0&&!n){const Se=new Set;e.forEach(Ae=>{Ae.sessions&&Ae.sessions.length>=0&&Se.add(Ae.name)}),R(Se)}},[e,n]),h.useEffect(()=>{const Se=()=>{P(n9())};Se();const Ae=He=>{He.key==="claude-settings"&&Se()},Ye=()=>Se();return window.addEventListener("storage",Ae),window.addEventListener("pixcode:settings-changed",Ye),()=>{window.removeEventListener("storage",Ae),window.removeEventListener("pixcode:settings-changed",Ye)}},[]),h.useEffect(()=>{Z.current&&clearTimeout(Z.current),ke.current&&(ke.current.close(),ke.current=null);const Se=ne.trim();if(W!=="conversations"||Se.length<2){le.current+=1,ye(null),X(null),we(!1);return}we(!0);const Ae=++le.current;return Z.current=setTimeout(()=>{if(Ae!==le.current)return;const Ye=ot.searchConversationsUrl(Se),He=new EventSource(Ye);ke.current=He;const Ve=[];let Ne=0;He.addEventListener("result",$e=>{if(Ae!==le.current){He.close();return}try{const Fe=JSON.parse($e.data);Ve.push(Fe.projectResult),Ne=Fe.totalMatches,ye({results:[...Ve],totalMatches:Ne,query:Se}),X({scannedProjects:Fe.scannedProjects,totalProjects:Fe.totalProjects})}catch{}}),He.addEventListener("progress",$e=>{if(Ae!==le.current){He.close();return}try{const Fe=JSON.parse($e.data);Ne=Fe.totalMatches,X({scannedProjects:Fe.scannedProjects,totalProjects:Fe.totalProjects})}catch{}}),He.addEventListener("done",()=>{if(Ae!==le.current){He.close();return}He.close(),ke.current=null,we(!1),X(null),Ve.length===0&&ye({results:[],totalMatches:0,query:Se})}),He.addEventListener("error",()=>{if(Ae!==le.current){He.close();return}He.close(),ke.current=null,we(!1),X(null),Ve.length===0&&ye({results:[],totalMatches:0,query:Se})})},400),()=>{Z.current&&clearTimeout(Z.current),ke.current&&(ke.current.close(),ke.current=null)}},[ne,W]);const Ke=h.useCallback(Se=>{b(Ae=>{const Ye=new Set;return Ae.has(Se)||Ye.add(Se),Ye})},[]),Qe=h.useCallback((Se,Ae)=>{c({...Se,__projectName:Ae})},[c]),xt=h.useCallback(Se=>{de(Ae=>{const Ye=new Set(Ae);return Ye.has(Se)?Ye.delete(Se):Ye.add(Se),i9(Ye),Ye})},[]),Xe=h.useCallback(Se=>M.has(Se),[M]),At=h.useCallback((Se,Ae)=>{Y(Ye=>{const He=uw(Se,Ae),Ve=new Set(Ye);return Ve.has(He)?Ve.delete(He):Ve.add(He),o9(Ve),Ve})},[]),vt=h.useCallback((Se,Ae)=>ce.has(uw(Se,Ae)),[ce]),st=h.useCallback(Se=>KE(Se,_),[_]),lt=h.useMemo(()=>e.map(Se=>{const Ae=U[Se.name];return Ae===void 0?Se:{...Se,sessionMeta:{...Se.sessionMeta,hasMore:Ae}}}),[U,e]),kt=h.useMemo(()=>m9(lt,N,M,_),[_,N,lt,M]),Pt=h.useMemo(()=>h9(kt,ne),[ne,kt]),jt=h.useCallback(Se=>{y(Se.name),E(Se.displayName)},[]),fr=h.useCallback(()=>{y(null),E("")},[]),Ft=h.useCallback(async Se=>{try{(await ot.renameProject(Se,S)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(Ae){console.error("Error renaming project:",Ae)}finally{y(null),E("")}},[S]),Ut=h.useCallback((Se,Ae,Ye,He="claude")=>{Ee({projectName:Se,sessionId:Ae,sessionTitle:Ye,provider:He})},[]),Br=h.useCallback(async()=>{if(!be)return;const{projectName:Se,sessionId:Ae,provider:Ye}=be;Ee(null);try{let He;if(Ye==="codex"?He=await ot.deleteCodexSession(Ae):Ye==="gemini"?He=await ot.deleteGeminiSession(Ae):Ye==="qwen"?He=await ot.deleteQwenSession(Ae):He=await ot.deleteSession(Se,Ae),He.ok)d?.(Ae);else{const Ve=await He.text();console.error("[Sidebar] Failed to delete session:",{status:He.status,error:Ve}),alert(s("messages.deleteSessionFailed"))}}catch(He){console.error("[Sidebar] Error deleting session:",He),alert(s("messages.deleteSessionError"))}},[d,be,s]),De=h.useCallback(Se=>{pe({project:Se,sessionCount:st(Se).length})},[st]),Je=h.useCallback(async(Se=!1)=>{if(!me)return;const{project:Ae,sessionCount:Ye}=me,He=Ye===0;pe(null),ie(Ve=>new Set([...Ve,Ae.name]));try{const Ve=await ot.deleteProject(Ae.name,!He,Se);if(Ve.ok)u?.(Ae.name);else{const Ne=await Ve.json();alert(Ne.error||s("messages.deleteProjectFailed"))}}catch(Ve){console.error("Error deleting project:",Ve),alert(s("messages.deleteProjectError"))}finally{ie(Ve=>{const Ne=new Set(Ve);return Ne.delete(Ae.name),Ne})}},[me,u,s]),et=h.useCallback(async Se=>{const Ae=U[Se.name];if(!(!(Ae!==void 0?Ae:Se.sessionMeta?.hasMore===!0)||k[Se.name])){j(He=>({...He,[Se.name]:!0}));try{const He=(Se.sessions?.length||0)+(_[Se.name]?.length||0),Ve=await ot.sessions(Se.name,5,He);if(!Ve.ok)return;const Ne=await Ve.json();A($e=>({...$e,[Se.name]:[...$e[Se.name]||[],...Ne.sessions||[]]})),Ne.hasMore===!1&&V($e=>({...$e,[Se.name]:!1}))}catch(He){console.error("Error loading more sessions:",He)}finally{j(He=>({...He,[Se.name]:!1}))}}},[_,k,U]),Nt=h.useCallback(Se=>{l(Se),p(Se)},[l,p]),ze=h.useCallback(async()=>{z(!0);try{await o()}finally{z(!1)}},[o]),Q=h.useCallback(async(Se,Ae,Ye,He)=>{const Ve=Ye.trim();if(!Ve){H(null),F("");return}try{const Ne=await ot.renameSession(Ae,Ve,He);Ne.ok?await o():(console.error("[Sidebar] Failed to rename session:",Ne.status),alert(s("messages.renameSessionFailed")))}catch(Ne){console.error("[Sidebar] Error renaming session:",Ne),alert(s("messages.renameSessionError"))}finally{H(null),F("")}},[o,s]),Le=h.useCallback(()=>{f(!1)},[f]),Oe=h.useCallback(()=>{f(!0)},[f]);return{isSidebarCollapsed:Te,expandedProjects:g,editingProject:x,showNewProject:v,editingName:S,loadingSessions:k,additionalSessions:_,initialSessionsLoaded:C,currentTime:T,projectSortOrder:N,isRefreshing:G,editingSession:O,editingSessionName:$,searchFilter:ne,deletingProjects:ge,deleteConfirmation:me,sessionDeleteConfirmation:be,showVersionModal:xe,starredProjects:M,starredSessions:ce,filteredProjects:Pt,toggleProject:Ke,handleSessionClick:Qe,toggleStarProject:xt,isProjectStarred:Xe,toggleStarSession:At,isSessionStarred:vt,getProjectSessions:st,startEditing:jt,cancelEditing:fr,saveProjectName:Ft,showDeleteSessionConfirmation:Ut,confirmDeleteSession:Br,requestProjectDelete:De,confirmDeleteProject:Je,loadMoreSessions:et,handleProjectSelect:Nt,refreshProjects:ze,updateSessionSummary:Q,collapseSidebar:Le,expandSidebar:Oe,setShowNewProject:w,setEditingName:E,setEditingSession:H,setEditingSessionName:F,searchMode:W,setSearchMode:ae,conversationResults:fe,isSearching:oe,searchProgress:te,clearConversationResults:h.useCallback(()=>{le.current+=1,ke.current&&(ke.current.close(),ke.current=null),we(!1),X(null),ye(null)},[]),setSearchFilter:ee,setDeleteConfirmation:pe,setSessionDeleteConfirmation:Ee,setShowVersionModal:Ue}}const x9="https://discord.gg/buxwujPNRE",y9="https://github.com/alicomert/pixcode/issues/new";function v9({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.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 w9({onExpand:e,onShowSettings:t,updateAvailable:r,onShowVersionModal:n,t:a}){return i.jsxs("div",{className:"flex h-full w-12 flex-col items-center gap-1 bg-background/80 py-3 backdrop-blur-sm",children:[i.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:i.jsx(CD,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("div",{className:"nav-divider my-1 w-6"}),i.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:i.jsx(Rt,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:y9,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:i.jsx(gl,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),i.jsx("a",{href:x9,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:i.jsx(v9,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),r&&i.jsxs("button",{onClick:n,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:[i.jsx(Ca,{className:"h-4 w-4 text-blue-500"}),i.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]})]})}function YE(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=YE(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function ZE(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=YE(e))&&(n&&(n+=" "),n+=t);return n}const mw=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,hw=ZE,Uf=(e,t)=>r=>{var n;if(t?.variants==null)return hw(e,r?.class,r?.className);const{variants:a,defaultVariants:s}=t,o=Object.keys(a).map(d=>{const u=r?.[d],p=s?.[d];if(u===null)return null;const f=mw(u)||mw(p);return a[d][f]}),l=r&&Object.entries(r).reduce((d,u)=>{let[p,f]=u;return f===void 0||(d[p]=f),d},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((d,u)=>{let{class:p,className:f,...m}=u;return Object.entries(m).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...s,...l}[b]):{...s,...l}[b]===x})?[...d,p,f]:d},[]);return hw(e,o,c,r?.class,r?.className)},Gf="-",k9=e=>{const t=E9(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(Gf);return l[0]===""&&l.length!==1&&l.shift(),XE(l,t)||S9(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},XE=(e,t)=>{if(e.length===0)return t.classGroupId;const r=e[0],n=t.nextPart.get(r),a=n?XE(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const s=e.join(Gf);return t.validators.find(({validator:o})=>o(s))?.classGroupId},fw=/^\[(.+)\]$/,S9=e=>{if(fw.test(e)){const t=fw.exec(e)[1],r=t?.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},E9=e=>{const{theme:t,classGroups:r}=e,n={nextPart:new Map,validators:[]};for(const a in r)ah(r[a],n,a,t);return n},ah=(e,t,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const s=a===""?t:gw(t,a);s.classGroupId=r;return}if(typeof a=="function"){if(N9(a)){ah(a(n),t,r,n);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([s,o])=>{ah(o,gw(t,s),r,n)})})},gw=(e,t)=>{let r=e;return t.split(Gf).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},N9=e=>e.isThemeGetter,C9=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,n=new Map;const a=(s,o)=>{r.set(s,o),t++,t>e&&(t=0,n=r,r=new Map)};return{get(s){let o=r.get(s);if(o!==void 0)return o;if((o=n.get(s))!==void 0)return a(s,o),o},set(s,o){r.has(s)?r.set(s,o):a(s,o)}}},ih="!",sh=":",T9=sh.length,A9=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const s=[];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===sh){s.push(a.slice(c,g)),c=g+T9;continue}if(b==="/"){d=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const u=s.length===0?a:a.substring(c),p=j9(u),f=p!==u,m=d&&d>c?d-c:void 0;return{modifiers:s,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}};if(t){const a=t+sh,s=n;n=o=>o.startsWith(a)?s(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(r){const a=n;n=s=>r({className:s,parseClassName:a})}return n},j9=e=>e.endsWith(ih)?e.substring(0,e.length-1):e.startsWith(ih)?e.substring(1):e,_9=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(n=>[n,!0]));return n=>{if(n.length<=1)return n;const a=[];let s=[];return n.forEach(o=>{o[0]==="["||t[o]?(a.push(...s.sort(),o),s=[]):s.push(o)}),a.push(...s.sort()),a}},I9=e=>({cache:C9(e.cacheSize),parseClassName:A9(e),sortModifiers:_9(e),...k9(e)}),R9=/\s+/,L9=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:s}=t,o=[],l=e.trim().split(R9);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:f,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:b}=r(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,y=n(x?g.substring(0,b):g);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=n(g),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const v=s(f).join(":"),w=m?v+ih: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 j=E[k];o.push(w+j)}c=u+(c.length>0?" "+c:c)}return c};function D9(){let e=0,t,r,n="";for(;e<arguments.length;)(t=arguments[e++])&&(r=JE(t))&&(n&&(n+=" "),n+=r);return n}const JE=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=JE(e[n]))&&(r&&(r+=" "),r+=t);return r};function O9(e,...t){let r,n,a,s=o;function o(c){const d=t.reduce((u,p)=>p(u),e());return r=I9(d),n=r.cache.get,a=r.cache.set,s=l,l(c)}function l(c){const d=n(c);if(d)return d;const u=L9(c,r);return a(c,u),u}return function(){return s(D9.apply(null,arguments))}}const pr=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},QE=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,eN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,M9=/^\d+\/\d+$/,P9=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,F9=/\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$/,z9=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,B9=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$9=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ds=e=>M9.test(e),pt=e=>!!e&&!Number.isNaN(Number(e)),Ua=e=>!!e&&Number.isInteger(Number(e)),Yu=e=>e.endsWith("%")&&pt(e.slice(0,-1)),ma=e=>P9.test(e),U9=()=>!0,G9=e=>F9.test(e)&&!z9.test(e),tN=()=>!1,H9=e=>B9.test(e),V9=e=>$9.test(e),q9=e=>!qe(e)&&!We(e),W9=e=>ao(e,aN,tN),qe=e=>QE.test(e),wi=e=>ao(e,iN,G9),Zu=e=>ao(e,J9,pt),bw=e=>ao(e,rN,tN),K9=e=>ao(e,nN,V9),ic=e=>ao(e,sN,H9),We=e=>eN.test(e),Ro=e=>io(e,iN),Y9=e=>io(e,Q9),xw=e=>io(e,rN),Z9=e=>io(e,aN),X9=e=>io(e,nN),sc=e=>io(e,sN,!0),ao=(e,t,r)=>{const n=QE.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},io=(e,t,r=!1)=>{const n=eN.exec(e);return n?n[1]?t(n[1]):r:!1},rN=e=>e==="position"||e==="percentage",nN=e=>e==="image"||e==="url",aN=e=>e==="length"||e==="size"||e==="bg-size",iN=e=>e==="length",J9=e=>e==="number",Q9=e=>e==="family-name",sN=e=>e==="shadow",eM=()=>{const e=pr("color"),t=pr("font"),r=pr("text"),n=pr("font-weight"),a=pr("tracking"),s=pr("leading"),o=pr("breakpoint"),l=pr("container"),c=pr("spacing"),d=pr("radius"),u=pr("shadow"),p=pr("inset-shadow"),f=pr("text-shadow"),m=pr("drop-shadow"),g=pr("blur"),b=pr("perspective"),x=pr("aspect"),y=pr("ease"),v=pr("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(),We,qe],k=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],_=()=>[We,qe,c],A=()=>[ds,"full","auto",..._()],C=()=>[Ua,"none","subgrid",We,qe],R=()=>["auto",{span:["full",Ua,We,qe]},Ua,We,qe],T=()=>[Ua,"auto",We,qe],I=()=>["auto","min","max","fr",We,qe],N=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],P=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",..._()],z=()=>[ds,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],U=()=>[e,We,qe],V=()=>[...S(),xw,bw,{position:[We,qe]}],O=()=>["no-repeat",{repeat:["","x","y","space","round"]}],H=()=>["auto","cover","contain",Z9,W9,{size:[We,qe]}],$=()=>[Yu,Ro,wi],F=()=>["","none","full",d,We,qe],ne=()=>["",pt,Ro,wi],ee=()=>["solid","dashed","dotted","double"],ge=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ie=()=>[pt,Yu,xw,bw],me=()=>["","none",g,We,qe],pe=()=>["none",pt,We,qe],be=()=>["none",pt,We,qe],Ee=()=>[pt,We,qe],xe=()=>[ds,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ma],breakpoint:[ma],color:[U9],container:[ma],"drop-shadow":[ma],ease:["in","out","in-out"],font:[q9],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ma],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ma],shadow:[ma],spacing:["px",pt],text:[ma],"text-shadow":[ma],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ds,qe,We,x]}],container:["container"],columns:[{columns:[pt,qe,We,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:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[Ua,"auto",We,qe]}],basis:[{basis:[ds,"full","auto",l,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[pt,ds,"auto","initial","none",qe]}],grow:[{grow:["",pt,We,qe]}],shrink:[{shrink:["",pt,We,qe]}],order:[{order:[Ua,"first","last","none",We,qe]}],"grid-cols":[{"grid-cols":C()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":C()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...N(),"normal"]}],"justify-items":[{"justify-items":[...P(),"normal"]}],"justify-self":[{"justify-self":["auto",...P()]}],"align-content":[{content:["normal",...N()]}],"align-items":[{items:[...P(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...P(),{baseline:["","last"]}]}],"place-content":[{"place-content":N()}],"place-items":[{"place-items":[...P(),"baseline"]}],"place-self":[{"place-self":["auto",...P()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],w:[{w:[l,"screen",...z()]}],"min-w":[{"min-w":[l,"screen","none",...z()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",r,Ro,wi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,We,Zu]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Yu,qe]}],"font-family":[{font:[Y9,qe,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,We,qe]}],"line-clamp":[{"line-clamp":[pt,"none",We,Zu]}],leading:[{leading:[s,..._()]}],"list-image":[{"list-image":["none",We,qe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",We,qe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:U()}],"text-color":[{text:U()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:[pt,"from-font","auto",We,wi]}],"text-decoration-color":[{decoration:U()}],"underline-offset":[{"underline-offset":[pt,"auto",We,qe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",We,qe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",We,qe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:V()}],"bg-repeat":[{bg:O()}],"bg-size":[{bg:H()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ua,We,qe],radial:["",We,qe],conic:[Ua,We,qe]},X9,K9]}],"bg-color":[{bg:U()}],"gradient-from-pos":[{from:$()}],"gradient-via-pos":[{via:$()}],"gradient-to-pos":[{to:$()}],"gradient-from":[{from:U()}],"gradient-via":[{via:U()}],"gradient-to":[{to:U()}],rounded:[{rounded:F()}],"rounded-s":[{"rounded-s":F()}],"rounded-e":[{"rounded-e":F()}],"rounded-t":[{"rounded-t":F()}],"rounded-r":[{"rounded-r":F()}],"rounded-b":[{"rounded-b":F()}],"rounded-l":[{"rounded-l":F()}],"rounded-ss":[{"rounded-ss":F()}],"rounded-se":[{"rounded-se":F()}],"rounded-ee":[{"rounded-ee":F()}],"rounded-es":[{"rounded-es":F()}],"rounded-tl":[{"rounded-tl":F()}],"rounded-tr":[{"rounded-tr":F()}],"rounded-br":[{"rounded-br":F()}],"rounded-bl":[{"rounded-bl":F()}],"border-w":[{border:ne()}],"border-w-x":[{"border-x":ne()}],"border-w-y":[{"border-y":ne()}],"border-w-s":[{"border-s":ne()}],"border-w-e":[{"border-e":ne()}],"border-w-t":[{"border-t":ne()}],"border-w-r":[{"border-r":ne()}],"border-w-b":[{"border-b":ne()}],"border-w-l":[{"border-l":ne()}],"divide-x":[{"divide-x":ne()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ne()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ee(),"hidden","none"]}],"divide-style":[{divide:[...ee(),"hidden","none"]}],"border-color":[{border:U()}],"border-color-x":[{"border-x":U()}],"border-color-y":[{"border-y":U()}],"border-color-s":[{"border-s":U()}],"border-color-e":[{"border-e":U()}],"border-color-t":[{"border-t":U()}],"border-color-r":[{"border-r":U()}],"border-color-b":[{"border-b":U()}],"border-color-l":[{"border-l":U()}],"divide-color":[{divide:U()}],"outline-style":[{outline:[...ee(),"none","hidden"]}],"outline-offset":[{"outline-offset":[pt,We,qe]}],"outline-w":[{outline:["",pt,Ro,wi]}],"outline-color":[{outline:U()}],shadow:[{shadow:["","none",u,sc,ic]}],"shadow-color":[{shadow:U()}],"inset-shadow":[{"inset-shadow":["none",p,sc,ic]}],"inset-shadow-color":[{"inset-shadow":U()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:U()}],"ring-offset-w":[{"ring-offset":[pt,wi]}],"ring-offset-color":[{"ring-offset":U()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":U()}],"text-shadow":[{"text-shadow":["none",f,sc,ic]}],"text-shadow-color":[{"text-shadow":U()}],opacity:[{opacity:[pt,We,qe]}],"mix-blend":[{"mix-blend":[...ge(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ge()}],"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":[pt]}],"mask-image-linear-from-pos":[{"mask-linear-from":ie()}],"mask-image-linear-to-pos":[{"mask-linear-to":ie()}],"mask-image-linear-from-color":[{"mask-linear-from":U()}],"mask-image-linear-to-color":[{"mask-linear-to":U()}],"mask-image-t-from-pos":[{"mask-t-from":ie()}],"mask-image-t-to-pos":[{"mask-t-to":ie()}],"mask-image-t-from-color":[{"mask-t-from":U()}],"mask-image-t-to-color":[{"mask-t-to":U()}],"mask-image-r-from-pos":[{"mask-r-from":ie()}],"mask-image-r-to-pos":[{"mask-r-to":ie()}],"mask-image-r-from-color":[{"mask-r-from":U()}],"mask-image-r-to-color":[{"mask-r-to":U()}],"mask-image-b-from-pos":[{"mask-b-from":ie()}],"mask-image-b-to-pos":[{"mask-b-to":ie()}],"mask-image-b-from-color":[{"mask-b-from":U()}],"mask-image-b-to-color":[{"mask-b-to":U()}],"mask-image-l-from-pos":[{"mask-l-from":ie()}],"mask-image-l-to-pos":[{"mask-l-to":ie()}],"mask-image-l-from-color":[{"mask-l-from":U()}],"mask-image-l-to-color":[{"mask-l-to":U()}],"mask-image-x-from-pos":[{"mask-x-from":ie()}],"mask-image-x-to-pos":[{"mask-x-to":ie()}],"mask-image-x-from-color":[{"mask-x-from":U()}],"mask-image-x-to-color":[{"mask-x-to":U()}],"mask-image-y-from-pos":[{"mask-y-from":ie()}],"mask-image-y-to-pos":[{"mask-y-to":ie()}],"mask-image-y-from-color":[{"mask-y-from":U()}],"mask-image-y-to-color":[{"mask-y-to":U()}],"mask-image-radial":[{"mask-radial":[We,qe]}],"mask-image-radial-from-pos":[{"mask-radial-from":ie()}],"mask-image-radial-to-pos":[{"mask-radial-to":ie()}],"mask-image-radial-from-color":[{"mask-radial-from":U()}],"mask-image-radial-to-color":[{"mask-radial-to":U()}],"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":[pt]}],"mask-image-conic-from-pos":[{"mask-conic-from":ie()}],"mask-image-conic-to-pos":[{"mask-conic-to":ie()}],"mask-image-conic-from-color":[{"mask-conic-from":U()}],"mask-image-conic-to-color":[{"mask-conic-to":U()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:V()}],"mask-repeat":[{mask:O()}],"mask-size":[{mask:H()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",We,qe]}],filter:[{filter:["","none",We,qe]}],blur:[{blur:me()}],brightness:[{brightness:[pt,We,qe]}],contrast:[{contrast:[pt,We,qe]}],"drop-shadow":[{"drop-shadow":["","none",m,sc,ic]}],"drop-shadow-color":[{"drop-shadow":U()}],grayscale:[{grayscale:["",pt,We,qe]}],"hue-rotate":[{"hue-rotate":[pt,We,qe]}],invert:[{invert:["",pt,We,qe]}],saturate:[{saturate:[pt,We,qe]}],sepia:[{sepia:["",pt,We,qe]}],"backdrop-filter":[{"backdrop-filter":["","none",We,qe]}],"backdrop-blur":[{"backdrop-blur":me()}],"backdrop-brightness":[{"backdrop-brightness":[pt,We,qe]}],"backdrop-contrast":[{"backdrop-contrast":[pt,We,qe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",pt,We,qe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[pt,We,qe]}],"backdrop-invert":[{"backdrop-invert":["",pt,We,qe]}],"backdrop-opacity":[{"backdrop-opacity":[pt,We,qe]}],"backdrop-saturate":[{"backdrop-saturate":[pt,We,qe]}],"backdrop-sepia":[{"backdrop-sepia":["",pt,We,qe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",We,qe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[pt,"initial",We,qe]}],ease:[{ease:["linear","initial",y,We,qe]}],delay:[{delay:[pt,We,qe]}],animate:[{animate:["none",v,We,qe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,We,qe]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:pe()}],"rotate-x":[{"rotate-x":pe()}],"rotate-y":[{"rotate-y":pe()}],"rotate-z":[{"rotate-z":pe()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:Ee()}],"skew-x":[{"skew-x":Ee()}],"skew-y":[{"skew-y":Ee()}],transform:[{transform:[We,qe,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"translate-none":["translate-none"],accent:[{accent:U()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:U()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",We,qe]}],"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":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",We,qe]}],fill:[{fill:["none",...U()]}],"stroke-w":[{stroke:[pt,Ro,wi,Zu]}],stroke:[{stroke:["none",...U()]}],"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"]}},tM=O9(eM);function ue(...e){return tM(ZE(e))}function rM(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const nM=Uf("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current"}},defaultVariants:{variant:"default"}}),oN=h.forwardRef(({className:e,variant:t,...r},n)=>i.jsx("div",{ref:n,role:"alert","data-slot":"alert",className:ue(nM({variant:t}),e),...r}));oN.displayName="Alert";const aM=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"alert-title",className:ue("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));aM.displayName="AlertTitle";const iM=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"alert-description",className:ue("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));iM.displayName="AlertDescription";const sM=Uf("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 Bt({className:e,variant:t,...r}){return i.jsx("div",{className:ue(sM({variant:t}),e),...r})}const oM=Uf("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"}}),je=h.forwardRef(({className:e,variant:t,size:r,...n},a)=>i.jsx("button",{className:ue(oM({variant:t,size:r,className:e})),ref:a,...n}));je.displayName="Button";const lN=h.createContext(null),cN=()=>{const e=h.useContext(lN);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},dN=({className:e,approval:t="pending",children:r,...n})=>{const a=h.useMemo(()=>({approval:t}),[t]);return i.jsx(lN.Provider,{value:a,children:i.jsx(oN,{className:ue("flex flex-col gap-2",e),...n,children:r})})};dN.displayName="Confirmation";const uN=({className:e,...t})=>i.jsx("div",{"data-slot":"confirmation-title",className:ue("text-muted-foreground inline text-sm",e),...t});uN.displayName="ConfirmationTitle";const pN=({children:e})=>{const{approval:t}=cN();return t!=="pending"?null:i.jsx(i.Fragment,{children:e})};pN.displayName="ConfirmationRequest";const mN=({className:e,...t})=>{const{approval:r}=cN();return r!=="pending"?null:i.jsx("div",{"data-slot":"confirmation-actions",className:ue("flex items-center justify-end gap-2 self-end",e),...t})};mN.displayName="ConfirmationActions";const Hc=({variant:e="default",...t})=>i.jsx(je,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});Hc.displayName="ConfirmationAction";const hN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));hN.displayName="Card";const fN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("flex flex-col space-y-1.5 p-4",e),...t}));fN.displayName="CardHeader";const gN=h.forwardRef(({className:e,...t},r)=>i.jsx("h3",{ref:r,className:ue("font-semibold leading-none tracking-tight",e),...t}));gN.displayName="CardTitle";const lM=h.forwardRef(({className:e,...t},r)=>i.jsx("p",{ref:r,className:ue("text-sm text-muted-foreground",e),...t}));lM.displayName="CardDescription";const bN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("p-4 pt-0",e),...t}));bN.displayName="CardContent";const xN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("flex items-center p-4 pt-0",e),...t}));xN.displayName="CardFooter";const cM=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("ml-auto shrink-0",e),...t}));cM.displayName="CardAction";const yN=h.createContext(null);function vN(){const e=h.useContext(yN);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const si=h.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:r,className:n,children:a,...s},o)=>{const[l,c]=h.useState(e),d=t!==void 0,u=d?t:l,p=h.useCallback(m=>{d||c(m),r?.(m)},[d,r]),f=h.useMemo(()=>({open:u,onOpenChange:p}),[u,p]);return i.jsx(yN.Provider,{value:f,children:i.jsx("div",{ref:o,"data-state":u?"open":"closed",className:n,...s,children:a})})});si.displayName="Collapsible";const Ta=h.forwardRef(({onClick:e,children:t,className:r,...n},a)=>{const{open:s,onOpenChange:o}=vN(),l=h.useCallback(c=>{o(!s),e?.(c)},[s,o,e]);return i.jsx("button",{ref:a,type:"button","aria-expanded":s,"data-state":s?"open":"closed",onClick:l,className:r,...n,children:t})});Ta.displayName="CollapsibleTrigger";const oi=h.forwardRef(({className:e,children:t,...r},n)=>{const{open:a}=vN();return i.jsx("div",{ref:n,"data-state":a?"open":"closed",className:ue("grid transition-[grid-template-rows] duration-200 ease-out",a?"grid-rows-[1fr]":"grid-rows-[0fr]",e),...r,children:i.jsx("div",{className:"overflow-hidden",children:t})})});oi.displayName="CollapsibleContent";const wN=h.createContext(null);function Hf(){const e=h.useContext(wN);if(!e)throw new Error("Command components must be used within <Command>");return e}const kN=h.forwardRef(({className:e,children:t,...r},n)=>{const[a,s]=h.useState(""),o=h.useRef(new Map),[l,c]=h.useState(0),d=h.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),u=h.useCallback(v=>{o.current.delete(v),c(w=>w+1)},[]),p=h.useCallback((v,w)=>{const S=o.current.get(v);S&&Object.assign(S,w)},[]),f=h.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=h.useMemo(()=>{const v=[];for(const[,w]of o.current)f.has(w.id)&&v.push(w);return v},[f]),[g,b]=h.useState(null);h.useEffect(()=>{b(m.length>0?m[0].id:null)},[m]);const x=h.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(A=>A.id===g)?.onSelect();return}const S=w.findIndex(_=>_.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=h.useMemo(()=>({search:a,setSearch:s,visibleIds:f,activeId:g,setActiveId:b,register:d,unregister:u,updateEntry:p}),[a,f,g,d,u,p]);return i.jsx(wN.Provider,{value:y,children:i.jsx("div",{ref:n,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:ue("flex flex-col",e),onKeyDown:x,...r,children:t})})});kN.displayName="Command";const SN=h.forwardRef(({className:e,placeholder:t="Search...",...r},n)=>{const{search:a,setSearch:s}=Hf();return i.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[i.jsx(Na,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),i.jsx("input",{ref:n,type:"text",role:"searchbox","aria-autocomplete":"list",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:a,onChange:o=>s(o.target.value),placeholder:t,className:ue("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),...r})]})});SN.displayName="CommandInput";const EN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,role:"listbox",className:ue("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));EN.displayName="CommandList";const NN=h.forwardRef(({className:e,...t},r)=>{const{search:n,visibleIds:a}=Hf();return!n||a.size>0?null:i.jsx("div",{ref:r,className:ue("py-6 text-center text-sm text-muted-foreground",e),...t})});NN.displayName="CommandEmpty";const CN=h.forwardRef(({className:e,heading:t,children:r,...n},a)=>i.jsxs("div",{ref:a,className:ue("overflow-hidden p-1",e),role:"group","aria-label":typeof t=="string"?t:void 0,...n,children:[t&&i.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",role:"presentation",children:t}),r]}));CN.displayName="CommandGroup";const TN=h.forwardRef(({className:e,value:t,onSelect:r,disabled:n,children:a,...s},o)=>{const{visibleIds:l,activeId:c,setActiveId:d,register:u,unregister:p,updateEntry:f}=Hf(),m=h.useId(),g=h.useRef(null),b=t||(typeof a=="string"?a:"");h.useEffect(()=>(u({id:m,value:b.toLowerCase(),onSelect:r||(()=>{}),element:g.current}),()=>p(m)),[m,b,u,p]),h.useEffect(()=>{f(m,{onSelect:r||(()=>{})})},[m,r,f]);const x=h.useCallback(v=>{g.current=v,f(m,{element:v}),typeof o=="function"?o(v):o&&(o.current=v)},[m,f,o]);if(!l.has(m))return null;const y=c===m;return i.jsx("div",{ref:x,role:"option","aria-selected":y,"aria-disabled":n||void 0,"data-active":y||void 0,className:ue("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",n&&"pointer-events-none opacity-50",e),onPointerMove:()=>{!n&&c!==m&&d(m)},onClick:()=>!n&&r?.(),...s,children:a})});TN.displayName="CommandItem";const dM=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:ue("-mx-1 h-px bg-border",e),...t}));dM.displayName="CommandSeparator";function oh({checked:e,onToggle:t,ariaLabel:r="Toggle dark mode"}){const{isDarkMode:n,toggleDarkMode:a}=Ma(),s=typeof e=="boolean"&&typeof t=="function",o=s?e:n,l=()=>{if(s&&t){t(!o);return}a()};return i.jsxs("button",{onClick:l,className:ue("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":r,children:[i.jsx("span",{className:"sr-only",children:r}),i.jsx("span",{className:ue("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?i.jsx(Lf,{className:"h-3 w-3 text-primary"}):i.jsx(Of,{className:"h-3 w-3 text-white dark:text-background"})})]})}const AN=h.createContext(null);function jN(){const e=h.useContext(AN);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const _N=({open:e,onOpenChange:t,defaultOpen:r=!1,children:n})=>{const[a,s]=h.useState(r),o=h.useRef(null),l=e!==void 0,c=l?e:a,d=h.useCallback(p=>{l||s(p),t?.(p)},[l,t]),u=h.useMemo(()=>({open:c,onOpenChange:d,triggerRef:o}),[c,d]);return i.jsx(AN.Provider,{value:u,children:n})},uM=h.forwardRef(({onClick:e,children:t,asChild:r,...n},a)=>{const{onOpenChange:s,triggerRef:o}=jN(),l=h.useCallback(c=>{s(!0),e?.(c)},[s,e]);if(r&&h.isValidElement(t)){const c=t;return h.cloneElement(c,{onClick:d=>{s(!0),c.props.onClick?.(d)},ref:d=>{o.current=d,typeof a=="function"?a(d):a&&(a.current=d)}})}return i.jsx("button",{ref:c=>{o.current=c,typeof a=="function"?a(c):a&&(a.current=c)},type:"button",onClick:l,...n,children:t})});uM.displayName="DialogTrigger";const yw='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',Vf=h.forwardRef(({className:e,children:t,onEscapeKeyDown:r,onPointerDownOutside:n,...a},s)=>{const{open:o,onOpenChange:l,triggerRef:c}=jN(),d=h.useRef(null),u=h.useRef(null);return h.useEffect(()=>{o?u.current=document.activeElement:u.current&&((c.current||u.current)?.focus(),u.current=null)},[o,c]),h.useEffect(()=>{if(!o)return;const p=m=>{if(m.key==="Escape"){m.stopPropagation(),r?.(),l(!1);return}if(m.key==="Tab"&&d.current){const g=Array.from(d.current.querySelectorAll(yw));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 f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p,!0),document.body.style.overflow=f}},[o,l,r]),h.useEffect(()=>{o&&d.current&&requestAnimationFrame(()=>{d.current?.querySelector(yw)?.focus()})},[o]),o?Vd.createPortal(i.jsxs("div",{className:"fixed inset-0 z-50",children:[i.jsx("div",{className:"fixed inset-0 animate-dialog-overlay-show bg-black/50 backdrop-blur-sm",onClick:()=>{n?.(),l(!1)},"aria-hidden":!0}),i.jsx("div",{ref:p=>{d.current=p,typeof s=="function"?s(p):s&&(s.current=p)},role:"dialog","aria-modal":"true",className:ue("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});Vf.displayName="DialogContent";const qf=h.forwardRef(({className:e,...t},r)=>i.jsx("h2",{ref:r,className:ue("sr-only",e),...t}));qf.displayName="DialogTitle";const Et=h.forwardRef(({className:e,type:t,...r},n)=>i.jsx("input",{type:t,className:ue("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r}));Et.displayName="Input";const Wf=h.forwardRef(({className:e,contentClassName:t,children:r,...n},a)=>i.jsx("div",{className:ue("relative overflow-hidden",e),...n,children:i.jsx("div",{ref:a,className:ue("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Wf.displayName="ScrollArea";const md=h.memo(({children:e,className:t,as:r="span"})=>i.jsx(r,{className:ue("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}));md.displayName="Shimmer";const IN=h.createContext(null),pM=()=>{const e=h.useContext(IN);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},mM=1e3,hM=1e3,lh=h.memo(({className:e,isStreaming:t=!1,open:r,defaultOpen:n,onOpenChange:a,duration:s,children:o,...l})=>{const c=n??t,d=n===!1,[u,p]=h.useState(c),f=r!==void 0,m=f?r:u,g=h.useCallback(k=>{f||p(k),a?.(k)},[f,a]),[b,x]=h.useState(s),y=h.useRef(t),[v,w]=h.useState(!1),S=h.useRef(null);h.useEffect(()=>{s!==void 0&&x(s)},[s]),h.useEffect(()=>{t?(y.current=!0,S.current===null&&(S.current=Date.now())):S.current!==null&&(x(Math.ceil((Date.now()-S.current)/hM)),S.current=null)},[t]),h.useEffect(()=>{t&&!m&&!d&&g(!0)},[t,m,g,d]),h.useEffect(()=>{if(y.current&&!t&&m&&!v){const k=setTimeout(()=>{g(!1),w(!0)},mM);return()=>clearTimeout(k)}},[t,m,g,v]);const E=h.useMemo(()=>({duration:b,isOpen:m,isStreaming:t,setIsOpen:g}),[b,m,t,g]);return i.jsx(IN.Provider,{value:E,children:i.jsx(si,{open:m,onOpenChange:g,className:ue("not-prose",e),...l,children:o})})});lh.displayName="Reasoning";const fM=(e,t)=>e||t===0?i.jsx(md,{children:"Thinking..."}):t===void 0?i.jsx("p",{children:"Thought for a few seconds"}):i.jsxs("p",{children:["Thought for ",t," seconds"]}),ch=h.memo(({className:e,children:t,getThinkingMessage:r=fM,...n})=>{const{isStreaming:a,isOpen:s,duration:o}=pM();return i.jsx(Ta,{className:ue("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...n,children:t??i.jsxs(i.Fragment,{children:[i.jsx(ZD,{className:"h-4 w-4"}),r(a,o),i.jsx(dE,{className:ue("h-4 w-4 transition-transform",s?"rotate-180":"rotate-0")})]})})});ch.displayName="ReasoningTrigger";const dh=h.memo(({className:e,children:t,...r})=>i.jsx(oi,{className:ue("mt-4 text-sm text-muted-foreground",e),...r,children:t}));dh.displayName="ReasoningContent";function gM(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 Yn({children:e,content:t,position:r="top",className:n="",delay:a=350}){const[s,o]=h.useState(!1),l=h.useRef(null),c=h.useRef(!1),d=h.useRef(null),u=h.useRef(null),[p,f]=h.useState(null),m=h.useCallback(()=>{const w=d.current;if(!w)return;const S=w.getBoundingClientRect(),E=8,k={position:"fixed",zIndex:9999};switch(r){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}f(k)},[r]),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 h.useEffect(()=>()=>{g()},[]),h.useEffect(()=>{if(!s||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)},[s]),h.useEffect(()=>{if(!s){f(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)}},[s,m]),t?i.jsxs("div",{ref:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:y,onTouchEnd:v,onTouchCancel:v,children:[e,s&&typeof document<"u"&&Vd.createPortal(i.jsxs("div",{ref:u,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:ue("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",n),children:[t,i.jsx("div",{className:ue("absolute w-0 h-0 border-4 border-transparent",gM(r))})]}),document.body)]}):i.jsx(i.Fragment,{children:e})}const RN=h.createContext(null),LN=h.forwardRef(({className:e,status:t="ready",children:r,...n},a)=>{const s=h.useMemo(()=>({status:t}),[t]);return i.jsx(RN.Provider,{value:s,children:i.jsx("form",{ref:a,"data-slot":"prompt-input",className:ue("relative overflow-hidden rounded-xl border border-border/70 bg-zinc-50/95 shadow-sm shadow-zinc-950/5 backdrop-blur-sm transition-all duration-200 focus-within:border-primary/40 focus-within:shadow-md focus-within:ring-1 focus-within:ring-primary/20 dark:bg-zinc-950/90",e),...n,children:r})})});LN.displayName="PromptInput";const DN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-header",className:ue("px-3 pt-3",e),...t}));DN.displayName="PromptInputHeader";const ON=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-body",className:ue("relative",e),...t}));ON.displayName="PromptInputBody";const MN=h.forwardRef(({className:e,...t},r)=>i.jsx("textarea",{ref:r,"data-slot":"prompt-input-textarea",className:ue("chat-input-placeholder block max-h-[40vh] w-full resize-none overflow-y-auto bg-transparent px-4 py-2 font-mono text-sm leading-6 text-foreground placeholder-muted-foreground/50 focus:outline-none sm:max-h-[300px]",e),...t}));MN.displayName="PromptInputTextarea";const PN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-footer",className:ue("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));PN.displayName="PromptInputFooter";const FN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"prompt-input-tools",className:ue("flex items-center gap-1",e),...t}));FN.displayName="PromptInputTools";const Vc=h.forwardRef(({className:e,tooltip:t,children:r,...n},a)=>{const s=i.jsx(je,{ref:a,type:"button",variant:"ghost",size:"icon",className:ue("h-8 w-8 [&_svg]:size-4",e),...n,children:r});return t?i.jsx(Yn,{content:t.shortcut?i.jsxs("span",{className:"flex items-center gap-1.5",children:[t.content,i.jsx("kbd",{className:"rounded bg-white/20 px-1 text-[10px]",children:t.shortcut})]}):t.content,position:t.side??"top",children:s}):s});Vc.displayName="PromptInputButton";const zN=h.forwardRef(({className:e,status:t,children:r,...n},a)=>{const s=h.useContext(RN),o=t??s?.status??"ready",l=o==="submitted"||o==="streaming";return i.jsx(je,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:ue("h-8 w-8 rounded-lg",e),...n,children:r??(l?i.jsx(Xd,{className:"h-3.5 w-3.5 fill-current"}):i.jsx(TD,{className:"h-4 w-4"}))})});zN.displayName="PromptInputSubmit";function Kf({children:e,className:t}){return i.jsx("div",{className:ue("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function Yf({isActive:e,onClick:t,children:r,className:n}){return i.jsx("button",{onClick:t,className:ue("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",n),children:r})}const BN=h.createContext(null);function $N(){const e=h.useContext(BN);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const UN=h.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-slot":"queue",role:"list",className:ue("space-y-0.5",e),...t}));UN.displayName="Queue";const GN=h.forwardRef(({status:e="pending",className:t,children:r,...n},a)=>{const s=h.useMemo(()=>({status:e}),[e]);return i.jsx(BN.Provider,{value:s,children:i.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:ue("flex items-start gap-2 py-0.5",t),...n,children:r})})});GN.displayName="QueueItem";const HN=h.forwardRef(({className:e,...t},r)=>{const{status:n}=$N();return i.jsxs("div",{ref:r,"data-slot":"queue-item-indicator","aria-hidden":"true",className:ue("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",e),...t,children:[n==="completed"&&i.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:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),n==="in_progress"&&i.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),n==="pending"&&i.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})})]})});HN.displayName="QueueItemIndicator";const VN=h.forwardRef(({className:e,children:t,...r},n)=>{const{status:a}=$N();return i.jsx("div",{ref:n,"data-slot":"queue-item-content",className:ue("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),...r,children:t})});VN.displayName="QueueItemContent";const vw="https://github.com/alicomert/pixcode/issues/new",bM="https://github.com/alicomert/pixcode",ww="https://discord.gg/buxwujPNRE";function kw({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.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 xM({updateAvailable:e,releaseInfo:t,latestVersion:r,currentVersion:n,onShowVersionModal:a,onShowSettings:s,t:o}){return i.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[e&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:i.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:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(Zv,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})}),i.jsx("div",{className:"px-3 py-2 md:hidden",children:i.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:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(Zv,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})})]}),i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:i.jsxs("a",{href:vw,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:[i.jsx(gl,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:o("actions.reportIssue")})]})}),i.jsx("div",{className:"hidden px-2 md:block",children:i.jsxs("a",{href:ww,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:[i.jsx(kw,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:o("actions.joinCommunity")})]})}),i.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:i.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:s,children:[i.jsx(Rt,{className:"h-3.5 w-3.5"}),i.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),i.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:i.jsxs("a",{href:bM,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",n," – ",o("branding.openSource")]})}),i.jsx("div",{className:"px-3 pt-3 md:hidden",children:i.jsxs("a",{href:vw,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:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(gl,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.reportIssue")})]})}),i.jsx("div",{className:"px-3 pt-2 md:hidden",children:i.jsxs("a",{href:ww,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:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(kw,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.joinCommunity")})]})}),i.jsx("div",{className:"px-3 pb-3 pt-2 md:hidden",children:i.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:s,children:[i.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:i.jsx(Rt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const Sw="PIXCODE_GITHUB_STARS",Ew="PIXCODE_HIDE_GITHUB_STAR",yM=3600*1e3,vM=(e,t)=>{const[r,n]=h.useState(null),[a,s]=h.useState(()=>{try{return localStorage.getItem(Ew)==="true"}catch{return!1}});h.useEffect(()=>{if(a)return;try{const d=localStorage.getItem(Sw);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<yM){n(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"){n(p);try{localStorage.setItem(Sw,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=h.useCallback(()=>{s(!0);try{localStorage.setItem(Ew,"true")}catch{}},[]),l=r!==null?r>=1e3?`${(r/1e3).toFixed(1)}k`:`${r}`:null;return{starCount:r,formattedCount:l,isDismissed:a,dismiss:o}},wM="https://github.com/alicomert/pixcode";function kM({className:e}){return i.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:i.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 SM(){const{formattedCount:e,isDismissed:t,dismiss:r}=vM("alicomert","pixcode");return t?null:i.jsxs("div",{className:"group/star relative hidden md:block",children:[i.jsxs("a",{href:wM,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:[i.jsx(kM,{className:"h-3.5 w-3.5"}),i.jsx(Rs,{className:"h-3 w-3"}),i.jsx("span",{className:"font-medium",children:"Star"}),e&&i.jsx("span",{className:"border-l border-border/50 pl-1.5 tabular-nums",children:e})]}),i.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),r()},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:i.jsx(bt,{className:"h-2.5 w-2.5"})})]})}function Nw({value:e,onChange:t,t:r}){const n="flex flex-1 items-center justify-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium transition-all";return i.jsxs("div",{role:"tablist","aria-label":r("tooltips.historyView",{defaultValue:"History view"}),className:"flex rounded-lg bg-muted/40 p-0.5",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":e==="flat",onClick:()=>t("flat"),className:ue(n,e==="flat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewFlat",{defaultValue:"Recent conversations"}),children:[i.jsx(fl,{className:"h-3 w-3"}),r("historyView.flat",{defaultValue:"Recent"})]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":e==="grouped",onClick:()=>t("grouped"),className:ue(n,e==="grouped"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:r("tooltips.historyViewGrouped",{defaultValue:"Grouped by project"}),children:[i.jsx(RD,{className:"h-3 w-3"}),r("historyView.grouped",{defaultValue:"By project"})]})]})}function EM({isPWA:e,isMobile:t,isLoading:r,projectsCount:n,searchFilter:a,onSearchFilterChange:s,onClearSearchFilter:o,searchMode:l,onSearchModeChange:c,onRefresh:d,isRefreshing:u,onCreateProject:p,onQuickStartSession:f,onCollapseSidebar:m,historyView:g,onHistoryViewChange:b,t:x}){const y=()=>i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("svg",{className:"h-6 w-6 flex-shrink-0",viewBox:"0 0 500 500","aria-hidden":"true",children:i.jsx("g",{transform:"translate(250 250) scale(1.25) translate(-250 -250)",children:i.jsxs("g",{transform:"translate(0 500) scale(0.1 -0.1)",fill:"#5C3FFC",children:[i.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"}),i.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"})]})})}),i.jsx("h1",{className:"truncate text-sm font-semibold tracking-tight text-foreground",children:x("app.title")})]});return i.jsxs("div",{className:"flex-shrink-0",children:[i.jsxs("div",{className:"hidden px-4 pb-3 pt-4 md:block",style:{},children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx(y,{}),i.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[i.jsx(je,{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:i.jsx(mt,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),i.jsx(je,{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:i.jsx(Vt,{className:"h-4 w-4"})}),i.jsx(je,{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:i.jsx(ND,{className:"h-4 w-4"})})]})]}),i.jsx(SM,{}),f&&i.jsxs("button",{type:"button",onClick:()=>{f()},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:[i.jsx(Ca,{className:"h-4 w-4"}),x("sidebar.newChat",{defaultValue:"New chat"})]}),n>0&&!r&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[i.jsx(Nw,{value:g,onChange:b,t:x}),i.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[i.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:ue("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:[i.jsx(Pn,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:ue("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:[i.jsx(na,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Na,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/50"}),i.jsx(Et,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>s(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&&i.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:i.jsx(bt,{className:"h-3 w-3 text-muted-foreground"})})]})]})]}),i.jsx("div",{className:"nav-divider hidden md:block"}),i.jsxs("div",{className:"p-3 pb-2 md:hidden",style:e&&t?{paddingTop:"16px"}:{},children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(y,{}),i.jsxs("div",{className:"flex flex-shrink-0 gap-1.5",children:[i.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:i.jsx(mt,{className:`h-4 w-4 text-muted-foreground ${u?"animate-spin":""}`})}),i.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:i.jsx(ii,{className:"h-4 w-4"})})]})]}),n>0&&!r&&i.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&i.jsx(Nw,{value:g,onChange:b,t:x}),i.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[i.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:ue("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:[i.jsx(Pn,{className:"h-3 w-3"}),x("search.modeProjects")]}),i.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:ue("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:[i.jsx(na,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Na,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),i.jsx(Et,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>s(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&&i.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:i.jsx(bt,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),i.jsx("div",{className:"nav-divider md:hidden"})]})}const NM=160,Cw=180;function qN({actions:e,className:t,triggerLabel:r}){const[n,a]=h.useState(!1),[s,o]=h.useState(null),l=h.useRef(null),c=h.useRef(null);h.useLayoutEffect(()=>{if(!n||!l.current)return;const u=l.current.getBoundingClientRect();let p=u.right-NM;p<8&&(p=8);let f=u.bottom+4;f+Cw>window.innerHeight&&(f=Math.max(8,u.top-4-Cw)),o({top:f,left:p})},[n]),h.useEffect(()=>{if(!n)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)},f=()=>a(!1);return document.addEventListener("mousedown",u),document.addEventListener("keydown",p),window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",p),window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[n]);const d=u=>p=>{p.stopPropagation(),p.preventDefault(),a(!1),u.onClick()};return i.jsxs(i.Fragment,{children:[i.jsx("button",{ref:l,type:"button","aria-haspopup":"menu","aria-expanded":n,"aria-label":r||"Actions",title:r||"Actions",onClick:u=>{u.stopPropagation(),u.preventDefault(),a(p=>!p)},className:ue("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",n&&"bg-accent text-foreground opacity-100",t),children:i.jsx(BD,{className:"h-3.5 w-3.5"})}),n&&s&&Vd.createPortal(i.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:s.top,left:s.left,zIndex:9999},className:ue("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 f=u.icon,m=e[p-1],g=p>0&&u.danger&&!m?.danger;return i.jsxs("div",{children:[g&&i.jsx("div",{className:"my-1 h-px bg-border/60"}),i.jsxs("button",{type:"button",role:"menuitem",onClick:d(u),className:ue("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:[i.jsx(f,{className:"h-3 w-3"}),u.label]})]},u.id)})}),document.body)]})}const Tw={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},CM={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},TM=e=>e==="fully-configured"?{icon:ra,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:Rt,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:Nn,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:bt,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function AM({status:e="not-configured",size:t="sm",className:r="",showLabel:n=!1}){const a=TM(e),s=a.icon;return n?i.jsxs("div",{className:ue("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",a.backgroundClassName,a.colorClassName,r),title:a.title,children:[i.jsx(s,{className:Tw[t]}),i.jsx("span",{className:"font-medium",children:a.label})]}):i.jsx("div",{className:ue("inline-flex items-center justify-center rounded-full transition-colors",a.backgroundClassName,CM[t],r),title:a.title,children:i.jsx(s,{className:ue(Tw[t],a.colorClassName)})})}const jM=(e,t,r)=>{const n=new Date(e),a=t;if(isNaN(n.getTime()))return r?r("status.unknown"):"Unknown";const s=a.getTime()-n.getTime(),o=Math.floor(s/1e3),l=Math.floor(s/(1e3*60)),c=Math.floor(s/(1e3*60*60)),d=Math.floor(s/(1e3*60*60*24));return o<60?r?r("time.justNow"):"Just now":l===1?r?r("time.oneMinuteAgo"):"1 min ago":l<60?r?r("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?r?r("time.oneHourAgo"):"1 hour ago":c<24?r?r("time.hoursAgo",{count:c}):`${c} hours ago`:d===1?r?r("time.oneDayAgo"):"1 day ago":d<7?r?r("time.daysAgo",{count:d}):`${d} days ago`:n.toLocaleDateString()};function Aw({isStarred:e,canDelete:t,onRename:r,onToggleStar:n,onDelete:a,t:s,className:o}){const l=d=>i.jsx(Rs,{className:`${d.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:s("actions.rename"),icon:OD,onClick:r},{id:"star",label:e?s("actions.unstarSession",{defaultValue:"Remove star"}):s("actions.starSession",{defaultValue:"Star"}),icon:l,onClick:n}];return t&&c.push({id:"delete",label:s("actions.delete"),icon:kr,onClick:a,danger:!0}),i.jsx(qN,{actions:c,className:o,triggerLabel:s("tooltips.sessionActions",{defaultValue:"Session actions"})})}const _M={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code",opencode:"OpenCode"},jw={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 WN({project:e,session:t,selectedSession:r,currentTime:n,editingSession:a,editingSessionName:s,isStarred:o,compact:l=!1,onEditingSessionNameChange:c,onStartEditingSession:d,onCancelEditingSession:u,onSaveEditingSession:p,onToggleStarSession:f,onProjectSelect:m,onSessionSelect:g,onDeleteSession:b,t:x}){const y=p9(t,n,x),v=r?.id===t.id,w=a===t.id,S=t.__provider,E=_M[S]??S,k=jw[S]??jw.claude,j=c9(y.sessionName),_=()=>{m(e),g(t,e.name)},A=()=>{p(e.name,t.id,s,S)},C=()=>{b(e.name,t.id,y.sessionName,S)},R=()=>d(t.id,y.sessionName),T=()=>f(e.name,t.id),I=i.jsxs("div",{className:"mt-0.5 flex min-w-0 flex-wrap items-center gap-1 text-[10px] leading-tight",children:[i.jsxs("span",{className:ue("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",k),children:[i.jsx(dr,{provider:S,className:"h-2.5 w-2.5"}),E]}),i.jsx("span",{className:"text-muted-foreground/80",children:jM(y.sessionTime,n,x)}),y.isActive&&i.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 dark:text-green-400",children:[i.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-green-500"}),x("status.active",{defaultValue:"Active"})]}),j.slice(0,3).map(z=>i.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:[".",z]},z))]}),N=i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text",value:s,onChange:z=>c(z.target.value),onKeyDown:z=>{z.stopPropagation(),z.key==="Enter"?A():z.key==="Escape"&&u()},onClick:z=>z.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}),i.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:z=>{z.stopPropagation(),A()},title:x("tooltips.save"),children:i.jsx(nr,{className:"h-3 w-3 text-green-600 dark:text-green-400"})}),i.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:z=>{z.stopPropagation(),u()},title:x("tooltips.cancel"),children:i.jsx(bt,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),P=i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:ue("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:_,children:w?i.jsx("div",{className:"flex items-center gap-1",children:N}):i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:ue("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/60"),children:i.jsx(dr,{provider:S,className:"h-3 w-3"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-1",children:[o&&i.jsx("span",{className:"text-yellow-500","aria-hidden":!0,children:"★"}),i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),I]}),i.jsx("div",{className:"flex-shrink-0",onClick:z=>z.stopPropagation(),children:i.jsx(Aw,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:T,onDelete:C,t:x,className:"!opacity-100"})})]})})}),G=i.jsxs("div",{className:ue("group/item relative hidden md:block"),children:[i.jsxs(je,{variant:"ghost",className:ue("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&&i.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&&i.jsx("span",{"aria-hidden":!0,className:"session-item-accent"}),i.jsxs("div",{className:"flex w-full min-w-0 items-start gap-2 pr-6",children:[i.jsx("div",{className:ue("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:i.jsx(dr,{provider:S,className:"h-3 w-3"})}),i.jsx("div",{className:"min-w-0 flex-1",children:w?i.jsx("div",{className:"flex items-center gap-1",children:N}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[o&&i.jsx("span",{className:"flex-shrink-0 text-yellow-500","aria-hidden":!0,children:"★"}),i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),I]})})]})]}),!w&&i.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:z=>z.stopPropagation(),children:i.jsx(Aw,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:T,onDelete:C,t:x,className:"opacity-0 focus-visible:opacity-100 group-hover/item:opacity-100"})})]});return i.jsxs("div",{className:"group relative",children:[P,G]})}const IM=e=>e==="claude-code"?"claude":e==="codex"?"codex":e==="gemini"?"gemini":e==="qwen"?"qwen":e==="opencode"?"opencode":null;function RM(){return i.jsx(i.Fragment,{children:Array.from({length:3}).map((e,t)=>i.jsx("div",{className:"rounded-md p-2",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("div",{className:"mt-0.5 h-3 w-3 animate-pulse rounded-full bg-muted"}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${60+t*15}%`}}),i.jsx("div",{className:"h-2 w-1/2 animate-pulse rounded bg-muted"})]})]})},t))})}function LM({project:e,isExpanded:t,sessions:r,selectedSession:n,initialSessionsLoaded:a,isLoadingSessions:s,currentTime:o,editingSession:l,editingSessionName:c,isSessionStarred:d,onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,onLoadMoreSessions:v,onNewSession:w,onOpenOrchestration:S,t:E}){const[k,j]=h.useState([]);if(h.useEffect(()=>{if(!t)return;let C=!1;const R=async()=>{const I=await ve(`/api/orchestration/workflows/runs?projectId=${encodeURIComponent(e.name)}`);if(!I.ok)return;const N=await I.json();C||j((N.runs??[]).slice(0,5))};R();const T=window.setInterval(()=>{R()},15e3);return()=>{C=!0,window.clearInterval(T)}},[t,e.name]),!t)return null;const _=r.length>0,A=e.sessionMeta?.hasMore===!0;return i.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[i.jsx("div",{className:"px-3 pb-1 pt-1 md:hidden",children:i.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:[i.jsx(Vt,{className:"h-3 w-3"}),E("sessions.newSession")]})}),i.jsxs(je,{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:[i.jsx(Vt,{className:"h-3 w-3"}),E("sessions.newSession")]}),k.length>0&&i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-1 px-3 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[i.jsx(aa,{className:"h-3 w-3"}),E("orchestration.section")]}),k.map(C=>{const R=[...new Set(C.nodeRuns.map(T=>IM(T.adapterId)).filter(Boolean))];return i.jsx("button",{type:"button",onClick:()=>S?.(e,C.id),className:"w-full rounded-lg px-3 py-2 text-left transition-colors hover:bg-accent/60",children:i.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[i.jsx(aa,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-primary"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"truncate text-xs font-medium text-foreground",children:C.input||E("orchestration.fallbackTitle")}),i.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[R.slice(0,4).map(T=>i.jsx("span",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted",children:i.jsx(dr,{provider:T,className:"h-3 w-3"})},T)),i.jsx("span",{className:"text-[10px] text-muted-foreground",children:E(`common:orchestration.status.${C.status}`,{defaultValue:C.status})})]})]})]})},C.id)})]}),a?!_&&!s?i.jsx("div",{className:"px-3 py-2 text-left",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:E("sessions.noSessions")})}):r.map(C=>i.jsx(WN,{project:e,session:C,selectedSession:n,currentTime:o,editingSession:l,editingSessionName:c,isStarred:d(e.name,C.id),onEditingSessionNameChange:u,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:E},C.id)):i.jsx(RM,{}),_&&A&&i.jsx(je,{variant:"ghost",size:"sm",className:"mt-2 w-full justify-center gap-2 text-muted-foreground",onClick:()=>v(e),disabled:s,children:s?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),E("sessions.loading")]}):i.jsxs(i.Fragment,{children:[i.jsx(Fr,{className:"h-3 w-3"}),E("sessions.showMore")]})})]})}const DM=(e,t)=>{const r=e.length;return t&&r>=5?`${r}+`:`${r}`};function OM({project:e,selectedProject:t,selectedSession:r,isExpanded:n,isDeleting:a,isStarred:s,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:m,tasksEnabled:g,mcpServerStatus:b,isSessionStarred:x,onEditingNameChange:y,onToggleProject:v,onProjectSelect:w,onToggleStarProject:S,onToggleStarSession:E,onStartEditingProject:k,onCancelEditingProject:j,onSaveProjectName:_,onDeleteProject:A,onSessionSelect:C,onDeleteSession:R,onLoadMoreSessions:T,onNewSession:I,onOpenOrchestration:N,onEditingSessionNameChange:P,onStartEditingSession:G,onCancelEditingSession:z,onSaveEditingSession:U,t:V}){const O=t?.name===e.name,H=o===e.name,$=e.sessionMeta?.hasMore===!0,F=DM(c,$),ne=`${F} session${c.length===1?"":"s"}`,ee=f9(e,b),ge=()=>v(e.name),ie=()=>S(e.name),me=()=>{_(e.name)},pe=()=>{t?.name!==e.name&&w(e),ge()};return i.jsxs("div",{className:ue("md:space-y-1",a&&"opacity-50 pointer-events-none"),children:[i.jsxs("div",{className:"md:group group",children:[i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:ue("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",O&&"bg-primary/5 border-primary/20",s&&!O&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:ge,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[i.jsx("div",{className:ue("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",n?"bg-primary/10":"bg-muted"),children:n?i.jsx(Ea,{className:"h-4 w-4 text-primary"}):i.jsx(Pn,{className:"h-4 w-4 text-muted-foreground"})}),i.jsx("div",{className:"min-w-0 flex-1",children:H?i.jsx("input",{type:"text",value:l,onChange:be=>y(be.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:V("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:be=>be.stopPropagation(),onKeyDown:be=>{be.key==="Enter"&&me(),be.key==="Escape"&&j()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between",children:[i.jsx("h3",{className:"truncate text-sm font-medium text-foreground",children:e.displayName}),g&&i.jsx(AM,{status:ee,size:"xs",className:"ml-2 hidden flex-shrink-0 md:inline-flex"})]}),i.jsx("p",{className:"text-xs text-muted-foreground",children:ne})]})})]}),i.jsx("div",{className:"flex items-center gap-1",children:H?i.jsxs(i.Fragment,{children:[i.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:be=>{be.stopPropagation(),me()},children:i.jsx(nr,{className:"h-4 w-4 text-white"})}),i.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:be=>{be.stopPropagation(),j()},children:i.jsx(bt,{className:"h-4 w-4 text-white"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{className:ue("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",s?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:be=>{be.stopPropagation(),ie()},title:V(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:i.jsx(Rs,{className:ue("w-4 h-4 transition-colors",s?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),i.jsx("button",{className:"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:be=>{be.stopPropagation(),A(e)},children:i.jsx(kr,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),i.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:be=>{be.stopPropagation(),k(e)},children:i.jsx(Wm,{className:"h-4 w-4 text-primary"})}),i.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-muted/30",children:n?i.jsx(Fr,{className:"h-3 w-3 text-muted-foreground"}):i.jsx(An,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),i.jsxs(je,{variant:"ghost",className:ue("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",O&&"bg-accent text-accent-foreground",s&&!O&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:pe,children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[n?i.jsx(Ea,{className:"h-4 w-4 flex-shrink-0 text-primary"}):i.jsx(Pn,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),i.jsx("div",{className:"min-w-0 flex-1 text-left",children:H?i.jsxs("div",{className:"space-y-1",children:[i.jsx("input",{type:"text",value:l,onChange:be=>y(be.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:V("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:be=>{be.key==="Enter"&&me(),be.key==="Escape"&&j()}}),i.jsx("div",{className:"truncate text-xs text-muted-foreground",title:e.fullPath,children:e.fullPath})]}):i.jsxs("div",{children:[i.jsx("div",{className:"truncate text-sm font-semibold text-foreground",title:e.displayName,children:e.displayName}),i.jsxs("div",{className:"text-xs text-muted-foreground",children:[F,e.fullPath!==e.displayName&&i.jsxs("span",{className:"ml-1 opacity-60",title:e.fullPath,children:[" - ",e.fullPath.length>25?`...${e.fullPath.slice(-22)}`:e.fullPath]})]})]})})]}),i.jsx("div",{className:"flex flex-shrink-0 items-center gap-1",children:H?i.jsxs(i.Fragment,{children:[i.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:be=>{be.stopPropagation(),me()},children:i.jsx(nr,{className:"h-3 w-3"})}),i.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:be=>{be.stopPropagation(),j()},children:i.jsx(bt,{className:"h-3 w-3"})})]}):i.jsxs(i.Fragment,{children:[s&&i.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:be=>{be.stopPropagation(),ie()},title:V("tooltips.removeFromFavorites"),children:i.jsx(Rs,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),i.jsx(qN,{triggerLabel:V("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:V("actions.rename"),icon:Wm,onClick:()=>k(e)},{id:"star",label:V(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:Rs,onClick:ie},{id:"delete",label:V("actions.delete",{defaultValue:"Delete"}),icon:kr,onClick:()=>A(e),danger:!0}]}),n?i.jsx(Fr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):i.jsx(An,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),i.jsx(LM,{project:e,isExpanded:n,sessions:c,selectedSession:r,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:p,editingSession:f,editingSessionName:m,isSessionStarred:x,onEditingSessionNameChange:P,onStartEditingSession:G,onCancelEditingSession:z,onSaveEditingSession:U,onToggleStarSession:E,onProjectSelect:w,onSessionSelect:C,onDeleteSession:R,onLoadMoreSessions:T,onNewSession:I,onOpenOrchestration:N,t:V})]})}function KN({isLoading:e,loadingProgress:t,projectsCount:r,filteredProjectsCount:n,t:a}){return e?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.loadingProjects")}),t&&t.total>0?i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:i.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${t.current/t.total*100}%`}})}),i.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.current,"/",t.total," ",a("projects.projects")]}),t.currentProject&&i.jsx("p",{className:"mx-auto max-w-[200px] truncate text-xs text-muted-foreground/70",title:t.currentProject,children:t.currentProject.split("-").slice(-2).join("/")})]}):i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.fetchingProjects")})]}):r===0?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx(Pn,{className:"h-6 w-6 text-muted-foreground"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.runClaudeCli")})]}):n===0?i.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[i.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:i.jsx(Na,{className:"h-6 w-6 text-muted-foreground"})}),i.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noMatchingProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.tryDifferentSearch")})]}):null}function MM({projects:e,filteredProjects:t,selectedProject:r,selectedSession:n,isLoading:a,loadingProgress:s,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:d,initialSessionsLoaded:u,currentTime:p,editingSession:f,editingSessionName:m,deletingProjects:g,tasksEnabled:b,mcpServerStatus:x,getProjectSessions:y,isProjectStarred:v,isSessionStarred:w,onEditingNameChange:S,onToggleProject:E,onProjectSelect:k,onToggleStarProject:j,onToggleStarSession:_,onStartEditingProject:A,onCancelEditingProject:C,onSaveProjectName:R,onDeleteProject:T,onSessionSelect:I,onDeleteSession:N,onLoadMoreSessions:P,onNewSession:G,onOpenOrchestration:z,onEditingSessionNameChange:U,onStartEditingSession:V,onCancelEditingSession:O,onSaveEditingSession:H,t:$}){const F=i.jsx(KN,{isLoading:a,loadingProgress:s,projectsCount:e.length,filteredProjectsCount:t.length,t:$});h.useEffect(()=>{let pe="Pixcode";const be=r?.displayName?.trim();be&&(pe=`${be} - ${pe}`),document.title=pe},[r]);const ne=!a&&e.length>0&&t.length>0,ee=pe=>pe.source==="history"||pe.autoDiscovered===!0&&pe.isManuallyAdded!==!0,ge=t.filter(pe=>!ee(pe)),ie=t.filter(pe=>ee(pe)),me=pe=>i.jsx(OM,{project:pe,selectedProject:r,selectedSession:n,isExpanded:o.has(pe.name),isDeleting:g.has(pe.name),isStarred:v(pe.name),editingProject:l,editingName:c,sessions:y(pe),initialSessionsLoaded:u.has(pe.name),isLoadingSessions:!!d[pe.name],currentTime:p,editingSession:f,editingSessionName:m,tasksEnabled:b,mcpServerStatus:x,isSessionStarred:w,onEditingNameChange:S,onToggleProject:E,onProjectSelect:k,onToggleStarProject:j,onToggleStarSession:_,onStartEditingProject:A,onCancelEditingProject:C,onSaveProjectName:R,onDeleteProject:T,onSessionSelect:I,onDeleteSession:N,onLoadMoreSessions:P,onNewSession:G,onOpenOrchestration:z,onEditingSessionNameChange:U,onStartEditingSession:V,onCancelEditingSession:O,onSaveEditingSession:H,t:$},pe.name);return i.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:ne?i.jsxs(i.Fragment,{children:[ge.map(pe=>me(pe)),ie.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:$("projects.detectedFromHistory")}),ie.map(pe=>me(pe))]})]}):F})}function fa(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function YN(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
|
*
|