wind-agent-cli 1.38.2 → 1.38.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/assets/{CodeEditor-C6BtLdoC.js → CodeEditor-C9qFO6L8.js} +1 -1
  2. package/dist/assets/{FileTree-CGxNFZda.js → FileTree-0yJEzBi9.js} +1 -1
  3. package/dist/assets/{GitPanel-BV-IAyEC.js → GitPanel-BhbG7yVZ.js} +1 -1
  4. package/dist/assets/{MarkdownPreview-DVoEzpoc.js → MarkdownPreview-C7pAt3xI.js} +1 -1
  5. package/dist/assets/{Shell-CUTO-THd.js → Shell-CrjXAW4f.js} +1 -1
  6. package/dist/assets/{StandaloneShell-BKM1qxUc.js → StandaloneShell-J5BR1g26.js} +1 -1
  7. package/dist/assets/{TaskMasterPanel-DDDCVF6M.js → TaskMasterPanel-B2wpEHWP.js} +2 -2
  8. package/dist/assets/{abnfDiagram-N423BO3Z-Crubtav6.js → abnfDiagram-N423BO3Z-DztbjsU0.js} +1 -1
  9. package/dist/assets/{arc-h9xb7EWA.js → arc-DRGumrCP.js} +1 -1
  10. package/dist/assets/{architectureDiagram-T3A2C74G-BmMQp4MC.js → architectureDiagram-T3A2C74G-DnsczqwM.js} +1 -1
  11. package/dist/assets/{blockDiagram-VBNYF7ZC-BtD-zDnJ.js → blockDiagram-VBNYF7ZC-CPsS5qw5.js} +1 -1
  12. package/dist/assets/{c4Diagram-5PPSVZJV-D18s6J-v.js → c4Diagram-5PPSVZJV-DyjwDxYL.js} +1 -1
  13. package/dist/assets/channel-Dj-iU3BT.js +1 -0
  14. package/dist/assets/{chunk-2GRJ4B5K-BHIcCvB_.js → chunk-2GRJ4B5K-C794q4RK.js} +1 -1
  15. package/dist/assets/{chunk-2Q5K7J3B-DcX4AeRe.js → chunk-2Q5K7J3B-BfK76GMF.js} +1 -1
  16. package/dist/assets/{chunk-5RXB4S5H-CZwYDv9K.js → chunk-5RXB4S5H-Dmwk_KHT.js} +1 -1
  17. package/dist/assets/{chunk-5VM5RSS4-CR-F7R13.js → chunk-5VM5RSS4-DOeUnsxL.js} +1 -1
  18. package/dist/assets/{chunk-6Q2QTUOP-BPP216SB.js → chunk-6Q2QTUOP-BrjdaybI.js} +1 -1
  19. package/dist/assets/{chunk-GF5L2VYU-CcFeSmHe.js → chunk-GF5L2VYU-DCjoLr5D.js} +1 -1
  20. package/dist/assets/{chunk-JWPE2WC7-C5T_9-OI.js → chunk-JWPE2WC7-TEJEfxQK.js} +1 -1
  21. package/dist/assets/{chunk-KBJHAD2P-g5eR5X5h.js → chunk-KBJHAD2P-tbXW-dpx.js} +1 -1
  22. package/dist/assets/{chunk-RYQCIY6F-76WBDsoZ.js → chunk-RYQCIY6F-CX4Zsite.js} +1 -1
  23. package/dist/assets/{chunk-XXDRQBXY-DGuy3LLn.js → chunk-XXDRQBXY-DVJXNcFN.js} +1 -1
  24. package/dist/assets/classDiagram-JCYQIIEL-euwGMP6E.js +1 -0
  25. package/dist/assets/classDiagram-v2-OCEON4UE-euwGMP6E.js +1 -0
  26. package/dist/assets/{cose-bilkent-JH36ORCC-Cg4R1M0H.js → cose-bilkent-JH36ORCC-DLpXc-vJ.js} +1 -1
  27. package/dist/assets/{cynefin-VYW2F7L2-Cbmals-o.js → cynefin-VYW2F7L2-toFyL_eT.js} +1 -1
  28. package/dist/assets/{cynefinDiagram-MW4NZA55-CI79hpHc.js → cynefinDiagram-MW4NZA55-7KnX5nu-.js} +1 -1
  29. package/dist/assets/{dagre-VZM6K2ZE-r3Uz8Fhv.js → dagre-VZM6K2ZE-C-QOFsDs.js} +1 -1
  30. package/dist/assets/{diagram-7IWD3JNH-ClRIkmQw.js → diagram-7IWD3JNH-26OmKaGK.js} +1 -1
  31. package/dist/assets/{diagram-B4RE2ZJO-C71qkNlS.js → diagram-B4RE2ZJO-0o9kK2uO.js} +1 -1
  32. package/dist/assets/{diagram-LBJQPF4R-CC7ShhCC.js → diagram-LBJQPF4R-CAgMu3zd.js} +1 -1
  33. package/dist/assets/{diagram-Q27KOJAE-DPHL4vnP.js → diagram-Q27KOJAE-B0W-AePB.js} +1 -1
  34. package/dist/assets/{diagram-UB23O5K3-CP_My5E9.js → diagram-UB23O5K3-66AXZ7Mk.js} +1 -1
  35. package/dist/assets/{ebnfDiagram-BXEA7PRR-BQe4AU9Z.js → ebnfDiagram-BXEA7PRR-JlixVrAW.js} +1 -1
  36. package/dist/assets/{erDiagram-JOGREHBK-CFidQ-d5.js → erDiagram-JOGREHBK-ZxzuRr4f.js} +1 -1
  37. package/dist/assets/{feature-chat-CHKsDTs-.js → feature-chat-CNYDDkFQ.js} +4 -4
  38. package/dist/assets/feature-workspace-BMlv7Ust.js +39 -0
  39. package/dist/assets/{flowDiagram-UKHOOZJN-X5fPFxbp.js → flowDiagram-UKHOOZJN-u67vU32D.js} +1 -1
  40. package/dist/assets/{ganttDiagram-PKOTCBZU-CILFHjP8.js → ganttDiagram-PKOTCBZU-Crl9IPqX.js} +1 -1
  41. package/dist/assets/{gitGraphDiagram-DS77QQ5N-DCQCtC_g.js → gitGraphDiagram-DS77QQ5N-B2rTRd1W.js} +1 -1
  42. package/dist/assets/{index-Bo9nFrtn.js → index-BTFkWJZe.js} +1 -1
  43. package/dist/assets/{index-D0vbG70l.js → index-CPP7a6gU.js} +1 -1
  44. package/dist/assets/{index-cNARKAN2.js → index-YP8FmBZO.js} +1 -1
  45. package/dist/assets/{index-Bn37f1jp.js → index-uINlYqXe.js} +13 -13
  46. package/dist/assets/{infoDiagram-6WML65LV-Da145n1G.js → infoDiagram-6WML65LV-o9ZSr_ud.js} +1 -1
  47. package/dist/assets/{ishikawaDiagram-WSZJBQD7-DGUP61eq.js → ishikawaDiagram-WSZJBQD7-DnrbX4Ui.js} +1 -1
  48. package/dist/assets/{journeyDiagram-NVQOT4AX-BqfnKWDJ.js → journeyDiagram-NVQOT4AX-CSfWpt5R.js} +1 -1
  49. package/dist/assets/{kanban-definition-27J2QSJJ-US6pQfNy.js → kanban-definition-27J2QSJJ-dj3PZxCQ.js} +1 -1
  50. package/dist/assets/{linear-d91wK5kZ.js → linear-DieERJn8.js} +1 -1
  51. package/dist/assets/{mermaid.core-BsWqrIaW.js → mermaid.core-cq_VDJvZ.js} +4 -4
  52. package/dist/assets/{mindmap-definition-FAOFIHXS-CXWD2UbS.js → mindmap-definition-FAOFIHXS-CHQ8W4LE.js} +1 -1
  53. package/dist/assets/{pegDiagram-VL7TDLO6-BVzfDR-8.js → pegDiagram-VL7TDLO6-CR2rMB3e.js} +1 -1
  54. package/dist/assets/{pieDiagram-7S7Q4E2Y-PNpHZnJ9.js → pieDiagram-7S7Q4E2Y-Cs4NOlmu.js} +1 -1
  55. package/dist/assets/{quadrantDiagram-CIZ2JOQS-DxCI4i3K.js → quadrantDiagram-CIZ2JOQS-CdHqIaj5.js} +1 -1
  56. package/dist/assets/{railroadDiagram-AXF67PYL-BYkvo3om.js → railroadDiagram-AXF67PYL-BNPU0Q8Z.js} +1 -1
  57. package/dist/assets/{requirementDiagram-LRYGKXZP-LUtvOYtV.js → requirementDiagram-LRYGKXZP-DwDQoirA.js} +1 -1
  58. package/dist/assets/{sankeyDiagram-W5VNT64P-CVyI8YeM.js → sankeyDiagram-W5VNT64P-DSDSpLjf.js} +1 -1
  59. package/dist/assets/{sequenceDiagram-SI44F4Z6-1vuRFolM.js → sequenceDiagram-SI44F4Z6-zfhext7x.js} +1 -1
  60. package/dist/assets/{sizeCapture-X5ZJPWSS-o4oVZXe8.js → sizeCapture-X5ZJPWSS-C56q6k2T.js} +1 -1
  61. package/dist/assets/{stateDiagram-OKZ733FA-WedLIlXF.js → stateDiagram-OKZ733FA-D2lhrHPg.js} +1 -1
  62. package/dist/assets/stateDiagram-v2-UEYNNEHI-C3wzBtFn.js +1 -0
  63. package/dist/assets/{swimlanes-SLNWSIFB-CpeXuk67.js → swimlanes-SLNWSIFB-D1HyP0oO.js} +2 -2
  64. package/dist/assets/swimlanesDiagram-ULZ7WXOC-Dts8yQMu.js +8 -0
  65. package/dist/assets/{timeline-definition-Z64GVDOM-DFcPWe47.js → timeline-definition-Z64GVDOM-R1zaf6JI.js} +1 -1
  66. package/dist/assets/{vennDiagram-T6HMQDX7-BH8C1C49.js → vennDiagram-T6HMQDX7-BwlaSNYk.js} +1 -1
  67. package/dist/assets/{wardleyDiagram-T6FBY63Y-K1Ew0uit.js → wardleyDiagram-T6FBY63Y-Dd9-WAib.js} +1 -1
  68. package/dist/assets/{xychartDiagram-ELKLHX3M-CQHlqWY2.js → xychartDiagram-ELKLHX3M-BVn4eBvu.js} +1 -1
  69. package/dist/index.html +3 -3
  70. package/dist/sw.js +1 -1
  71. package/package.json +1 -1
  72. package/dist/assets/channel-CuR3zGvy.js +0 -1
  73. package/dist/assets/classDiagram-JCYQIIEL-BWpl-4NG.js +0 -1
  74. package/dist/assets/classDiagram-v2-OCEON4UE-BWpl-4NG.js +0 -1
  75. package/dist/assets/feature-workspace-BodovOw6.js +0 -39
  76. package/dist/assets/stateDiagram-v2-UEYNNEHI-BqzvLVVB.js +0 -1
  77. package/dist/assets/swimlanesDiagram-ULZ7WXOC-CeI6fByR.js +0 -8
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BsWqrIaW.js","assets/feature-workspace-BodovOw6.js","assets/vendor-react-C2GTiUCy.js","assets/vendor-ui-CAUHSABu.js","assets/vendor-i18n-B6HjLCnN.js","assets/vendor-data-DsEZeNPr.js","assets/vendor-markdown-DkITEES2.js","assets/Shell-CUTO-THd.js","assets/Shell-DrlLKa8f.css"])))=>i.map(i=>d[i]);
2
- import{r as o,j as t,d as er,b as qt}from"./vendor-react-C2GTiUCy.js";import{a as $e,p as Br,b as Qn,c as jr,C as Dt,d as Et,e as Ft,f as Ae,g as Vt,u as Os,_ as Ps,h as Yn,Q as Xn,i as Zn,j as ea,k as ta,l as _s,m as ra,n as sa,S as Nr,o as na,q as aa,B as Qe,r as or,v as Ds,V as qr,L as tr,R as Vr,s as Hr,t as zr,w as Fs,I as Cr,x as jt,D as Sr,y as oa,z as Mr,A as Tr,E as la,F as ia,G as ca,H as da,J as ua,K as Wr,P as Xt,M as ma,N as pa,O as fa,T as xa,U as fr,W as ha,X as ga,Y as ba,Z as ya,$ as ka,a0 as wa,a1 as va,a2 as ja,a3 as Na}from"./feature-workspace-BodovOw6.js";import{V as Ca,t as It,o as Ut,q as Us,$ as Rr,ap as Sa,X as it,aa as Bs,aq as Ma,ar as Ta,as as qs,d as Vs,L as $t,ad as Ea,at as Ia,au as $a,av as La,C as rr,m as Hs,ag as Ra,n as Aa,aw as Oa,ax as zs,U as Ar,h as Bt,ay as Kr,S as Pa,az as _a,ae as Da,a9 as Fa,Z as Ua,aA as Ba,aB as qa,aC as Ws,r as Va,aD as Ha,aE as za,aF as Wa,j as Ks,aG as Ka,F as Ga,a as Or,g as Ja,x as Qa,aj as Ya,A as lr,aH as Xa,T as Za,aI as eo,v as to,aJ as ro,aK as so,aL as no,aM as ao,aN as Gs,aO as Js,aP as oo,aQ as Pr,aR as sr,aS as Qs,aT as lo,aU as io,O as co,b as uo,aV as mo}from"./vendor-ui-CAUHSABu.js";import{y as po,t as fo,a as xo,s as ho,b as go,p as bo,c as yo,m as ko,d as wo,j as vo,e as jo,f as No,g as Co,h as So,i as Mo,k as To,l as Eo,n as Io,o as $o,S as ct,r as Gr,q as Jr,u as Lo,v as Ro,M as Ao,w as Oo,x as Po}from"./vendor-markdown-DkITEES2.js";import{u as We,T as _o}from"./vendor-i18n-B6HjLCnN.js";const Ys=o.createContext(null);function Do(){return o.useContext(Ys)}const rt="default",Qr={claude:["low","medium","high","xhigh","max"],codex:["low","medium","high","xhigh","max","ultra"],opencode:["none","low","medium","high","xhigh","max"]},Fo=e=>e.map(r=>({value:r})),zt={claude:"default",cursor:"gpt-5.3-codex",codex:"gpt-5.4",opencode:"anthropic/claude-sonnet-4-5"},_t=["claude","cursor","codex","opencode"],Uo=()=>{const e=localStorage.getItem("selected-provider");return _t.includes(e)?e:"claude"},Bo={claude:["default","auto","acceptEdits","bypassPermissions","plan"],cursor:["default","acceptEdits","bypassPermissions","plan"],codex:["default","acceptEdits","bypassPermissions"],opencode:["default","acceptEdits","bypassPermissions","plan"]},Wt=(e,r)=>`${e}:${r}`;function qo({selectedSession:e,selectedProject:r}){const[s,a]=o.useState("default"),[n,l]=o.useState([]),[i,c]=o.useState(Uo),[d,u]=o.useState(()=>localStorage.getItem("cursor-model")||zt.cursor),[x,v]=o.useState(()=>localStorage.getItem("claude-model")||zt.claude),[g,b]=o.useState(()=>localStorage.getItem("codex-model")||zt.codex),[N,k]=o.useState(()=>_t.reduce((C,S)=>(C[S]=localStorage.getItem(`${S}-effort`)||rt,C),{})),[E,w]=o.useState(()=>localStorage.getItem("opencode-model")||zt.opencode),[L,f]=o.useState(null),[m,p]=o.useState({}),[h,y]=o.useState(!0),I=o.useRef(0),T=o.useRef(0),j=o.useRef(0),A=o.useRef(0),_=o.useCallback((C,S)=>{if(C==="claude"){v(S),localStorage.setItem("claude-model",S);return}if(C==="cursor"){u(S),localStorage.setItem("cursor-model",S);return}if(C==="codex"){b(S),localStorage.setItem("codex-model",S);return}w(S),localStorage.setItem("opencode-model",S)},[]),H=o.useCallback((C,S)=>{k(F=>F[C]===S?F:{...F,[C]:S}),localStorage.setItem(`${C}-effort`,S)},[]),M=o.useCallback(async()=>{const C=I.current+1;I.current=C,y(!0);try{const S=await Promise.all(_t.map(async q=>{const de=await(await $e(`/api/providers/${q}/models`)).json();return!de.success||!de.data?.models?null:de.data.models}));if(I.current!==C)return;const F={};_t.forEach((q,W)=>{const de=S[W];de&&(F[q]=de)}),p(F)}catch(S){console.error("Error loading provider models:",S)}finally{I.current===C&&y(!1)}},[]);o.useEffect(()=>{M()},[M]),o.useEffect(()=>{let C=!1;return(async()=>{try{const q=await(await $e("/api/providers/capabilities")).json();if(C||!q.success||!Array.isArray(q.data?.providers))return;const W={};for(const de of q.data.providers)W[de.provider]=de;f(W)}catch(F){console.error("Error loading provider capabilities:",F)}})(),()=>{C=!0}},[]);const O=o.useCallback(C=>{const S=L?.[C]?.permissionModes;return S&&S.length>0?S:Bo[C]??["default"]},[L]),$=o.useCallback(C=>{const S=O(C),F=L?.[C]?.defaultPermissionMode;return F&&S.includes(F)?F:S[0]??"default"},[O,L]),P=o.useCallback(C=>{const S=L?.[C]?.supportsEffort;return typeof S=="boolean"?S:!!Qr[C]?.length},[L]),B=(C,S,F)=>{const q=localStorage.getItem(C);return q&&F.OPTIONS.some(W=>W.value===q)?q:S&&F.OPTIONS.some(W=>W.value===S)?S:F.DEFAULT},z=o.useCallback((C,S)=>{const F=m[C];return F?F.OPTIONS.find(q=>q.value===S)??null:null},[m]),U=o.useCallback((C,S)=>{if(!P(C))return[];const F=z(C,S);return F?F.effort?.values??[]:Fo(Qr[C]??[])},[z,P]),ee=o.useCallback((C,S)=>U(C,S).map(F=>F.value),[U]),ie=o.useCallback((C,S,F)=>{const q=ee(C,S);return q.length===0||F===rt||!F?rt:q.includes(F)?F:rt},[ee]),X=o.useMemo(()=>({claude:x,cursor:d,codex:g,opencode:E}),[x,d,g,E]);o.useEffect(()=>{const C=m.claude;if(C){const S=B("claude-model",x,C);S!==x&&v(S),localStorage.getItem("claude-model")!==S&&localStorage.setItem("claude-model",S)}},[m.claude,x]),o.useEffect(()=>{const C=m.cursor;if(C){const S=B("cursor-model",d,C);S!==d&&u(S),localStorage.getItem("cursor-model")!==S&&localStorage.setItem("cursor-model",S)}},[m.cursor,d]),o.useEffect(()=>{const C=m.codex;if(C){const S=B("codex-model",g,C);S!==g&&b(S),localStorage.getItem("codex-model")!==S&&localStorage.setItem("codex-model",S)}},[m.codex,g]),o.useEffect(()=>{const C=m.opencode;if(C){const S=B("opencode-model",E,C);S!==E&&w(S),localStorage.getItem("opencode-model")!==S&&localStorage.setItem("opencode-model",S)}},[m.opencode,E]),o.useEffect(()=>{const C={};let S=!1;for(const F of _t){const q=N[F]??rt,W=ie(F,X[F],q);W!==q&&(C[F]=W,localStorage.setItem(`${F}-effort`,W),S=!0)}S&&k(F=>({...F,...C}))},[N,X,ie]),o.useEffect(()=>{const C=O(i),S=e?.id?localStorage.getItem(`permissionMode-${e.id}`):null,F=localStorage.getItem(`permissionMode-last-${i}`),q=[S,F].find(W=>!!(W&&C.includes(W)));a(q??$(i))},[e?.id,i,$,O]),o.useEffect(()=>{!e?.__provider||e.__provider===i||(c(e.__provider),localStorage.setItem("selected-provider",e.__provider))},[i,e]),o.useEffect(()=>{l(C=>C.filter(S=>!S.sessionId||S.sessionId===e?.id))},[e?.id]);const pe=o.useCallback(C=>{a(C),localStorage.setItem(`permissionMode-last-${i}`,C),e?.id&&localStorage.setItem(`permissionMode-${e.id}`,C)},[i,e?.id]),me=o.useCallback(()=>{const C=O(i),F=(C.indexOf(s)+1)%C.length;pe(C[F])},[s,i,O,pe]),he=o.useMemo(()=>O(i),[O,i]),Y=o.useCallback((C,S)=>O(C).includes(S)?S:$(C),[$,O]),[le,ae]=o.useState(null),K=e?.id?.trim()||null,ce=e?.__provider??i,ge=K?Wt(ce,K):null,fe=o.useRef(ge);fe.current=ge;const be=le&&K&&le.sessionId===K&&le.provider===ce?le:null,oe=be?.model??null;o.useEffect(()=>{const C=T.current+1;if(T.current=C,!K){ae(null);return}let S=!1;const F=ce,q=Wt(F,K);return(async()=>{try{const Ce=await(await $e(`/api/providers/${F}/sessions/${encodeURIComponent(K)}/active-model`)).json();if(S||T.current!==C||fe.current!==q)return;const xe=Ce.data?.model?.trim(),Se=Ce.data?.effort?.trim()||null;ae({provider:F,sessionId:K,model:Ce.success&&xe&&Ce.data?.source!=="default"?xe:null,effort:Ce.success?Se:null})}catch(de){!S&&T.current===C&&fe.current===q&&(console.error("Error loading the session model and reasoning effort:",de),ae({provider:F,sessionId:K,model:null,effort:null}))}})(),()=>{S=!0}},[K,ce]);const ne=o.useCallback(async(C,S,F)=>{_(C,S);const q=typeof F=="string"?F.trim():"";if(!q)return{scope:"default",model:S};T.current+=1;const W=j.current+1;j.current=W;const de=Wt(C,q),Ce=await $e(`/api/providers/${C}/sessions/${encodeURIComponent(q)}/active-model`,{method:"POST",body:JSON.stringify({model:S})}),xe=await Ce.json();if(!Ce.ok||!xe.success)throw new Error("Unable to change the active model for this session.");const Se=xe.data?.model?.trim()||S;return j.current===W&&fe.current===de&&ae(Re=>({provider:C,sessionId:q,model:Se,effort:Re?.provider===C&&Re.sessionId===q?Re.effort:xe.data?.effort?.trim()||null})),{scope:"session",model:Se}},[_]),ve=o.useCallback(async(C,S,F)=>{H(C,S);const q=typeof F=="string"?F.trim():"";if(!q)return{scope:"default",effort:S};T.current+=1;const W=A.current+1;A.current=W;const de=Wt(C,q),Ce=le?.provider===C&&le.sessionId===q?le:null;ae({provider:C,sessionId:q,model:Ce?.model??null,effort:S});try{const xe=await $e(`/api/providers/${C}/sessions/${encodeURIComponent(q)}/active-effort`,{method:"POST",body:JSON.stringify({effort:S})}),Se=await xe.json();if(!xe.ok||!Se.success)throw new Error("Unable to change the reasoning effort for this session.");const Re=Se.data?.effort?.trim()||S;return A.current===W&&fe.current===de&&ae(_e=>({provider:C,sessionId:q,model:_e?.provider===C&&_e.sessionId===q?_e.model:Ce?.model??null,effort:Re})),{scope:"session",effort:Re}}catch(xe){throw A.current===W&&fe.current===de&&ae(Se=>Se?.provider===C&&Se.sessionId===q&&Se.effort===S?Ce:Se),xe}},[le,H]),Ne=oe??X[i],Pe=o.useMemo(()=>U(i,Ne),[Ne,U,i]),nt=o.useMemo(()=>ie(i,Ne,be?.effort??N[i]??rt),[be?.effort,Ne,i,N,ie]),je=o.useMemo(()=>m[i]?.OPTIONS??[],[i,m]),re=o.useCallback((C,S)=>{p(F=>({...F,[C]:S}))},[]),Ee=o.useCallback(async C=>{const S=await C.json();if(!C.ok||!S.success||!S.data?.model||!S.data.models)throw new Error(S.error?.message||"Unable to save this model.");return{model:S.data.model,models:S.data.models}},[]),Ie=o.useCallback(async(C,S)=>{const F=await $e(`/api/providers/${C}/models`,{method:"POST",body:JSON.stringify(S)}),q=await Ee(F);re(C,q.models)},[re,Ee]),ue=o.useCallback(async(C,S,F)=>{if(!S.recordId)throw new Error("This model cannot be edited.");const q=await $e(`/api/providers/${C}/models/${S.recordId}`,{method:"PATCH",body:JSON.stringify(F)}),W=await Ee(q);re(C,W.models),X[C]===S.value&&_(C,W.model.value),i===C&&oe===S.value&&ae(de=>de&&{...de,model:W.model.value})},[re,i,X,Ee,oe,_]),Ye=o.useCallback(async(C,S)=>{if(!S.recordId)throw new Error("This model cannot be deleted.");const F=await $e(`/api/providers/${C}/models/${S.recordId}`,{method:"DELETE"}),q=await Ee(F);re(C,q.models),X[C]===S.value&&_(C,q.models.DEFAULT),i===C&&oe===S.value&&ae(W=>W&&{...W,model:q.models.DEFAULT})},[re,i,X,Ee,oe,_]),Le=o.useMemo(()=>({create:Ie,update:ue,remove:Ye}),[Ie,Ye,ue]);return{provider:i,setProvider:c,cursorModel:d,setCursorModel:u,claudeModel:x,setClaudeModel:v,codexModel:g,setCodexModel:b,currentProviderEffort:nt,currentProviderEffortOptions:Pe,currentProviderModel:Ne,currentProviderModelOptions:je,opencodeModel:E,setOpenCodeModel:w,permissionMode:s,setPermissionMode:a,pendingPermissionRequests:n,setPendingPermissionRequests:l,availablePermissionModes:he,selectPermissionMode:pe,cyclePermissionMode:me,providerModelCatalog:m,providerModelsLoading:h,providerModelActions:Le,selectProviderModel:ne,selectProviderEffort:ve,resolvePermissionModeForProvider:Y}}const gt=20;function Vo(e,r={}){const s=new URLSearchParams;r.limit!==null&&r.limit!==void 0&&(s.set("limit",String(r.limit)),s.set("offset",String(r.offset??0)));const a=s.toString(),n=`/api/providers/sessions/${encodeURIComponent(e)}/messages`;return a?`${n}?${a}`:n}function Yr(e){if(e===void 0)return"";try{return JSON.stringify(e)}catch{return String(e)}}function Xs(e,r){return e.id===r.id?!0:e.provider!==r.provider||e.kind!==r.kind||e.timestamp!==r.timestamp||e.role!==r.role?!1:e.toolId||r.toolId?e.toolId===r.toolId:e.rowid!==void 0||r.rowid!==void 0?e.rowid===r.rowid:e.sequence!==void 0||r.sequence!==void 0?e.sequence===r.sequence:(e.content??"")===(r.content??"")&&(e.text??"")===(r.text??"")&&(e.toolName??"")===(r.toolName??"")&&(e.commandName??"")===(r.commandName??"")&&(e.parentToolUseId??"")===(r.parentToolUseId??"")&&Yr(e.toolInput)===Yr(r.toolInput)}function Zs(e,r){const s=Math.min(e.length,r.length);for(let a=s;a>0;a--){const n=e.length-a;let l=!0;for(let i=0;i<a;i++)if(!Xs(e[n+i],r[i])){l=!1;break}if(l)return a}return 0}function Ho(e,r,s,a,n=0){if(e.length===0||r.length===0||Zs(e,r)>0)return null;const l=Math.max(0,a-s),i=Math.max(0,l-r.length-n),c=n===0?Math.max(1,i+1):gt;return{offset:r.length+n,limit:c}}function zo(e,r){const s=e[e.length-1],a=r[0];if(!s||!a)return!1;const n=Date.parse(s.timestamp),l=Date.parse(a.timestamp);return!Number.isFinite(n)||!Number.isFinite(l)?!1:l<=n}function Xr(e,r){if(e.length===0)return{messages:r,overlapLength:0};if(r.length===0)return{messages:e,overlapLength:0};const s=Zs(e,r);return s===0?{messages:e,overlapLength:0}:{messages:[...e.slice(0,e.length-s),...r],overlapLength:s}}function en(e,r){const s=Math.min(e.length,r.length);let a=0;for(let l=s;l>0;l--){const i=r.length-l;let c=!0;for(let d=0;d<l;d++)if(!Xs(r[i+d],e[d])){c=!1;break}if(c){a=l;break}}const n=r.length-a;return{messages:[...r.slice(0,n),...e],overlapLength:a,prependedCount:n}}function Wo(e,r,s,a){return{offset:r,hasMore:(e===0||s)&&a}}function Ko(e,r){const s=new Set,a=new Map,n=l=>{const i=a.get(l);if(i)return s.add(l),i;const c=(async()=>{try{do if(s.delete(l),await e(l)===!1){s.add(l);break}while(s.has(l)&&r(l))}catch{s.add(l)}})().finally(()=>{a.delete(l)});return a.set(l,c),c};return{request(l,i=!0){return!i||!r(l)?(s.add(l),Promise.resolve()):n(l)},flushPending(l){return!s.has(l)||!r(l)?Promise.resolve():n(l)},discardPending(l){s.delete(l)},hasPending(l){return s.has(l)}}}const Go=(e,r)=>{const s=e.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-cq_VDJvZ.js","assets/feature-workspace-BMlv7Ust.js","assets/vendor-react-C2GTiUCy.js","assets/vendor-ui-CAUHSABu.js","assets/vendor-i18n-B6HjLCnN.js","assets/vendor-data-DsEZeNPr.js","assets/vendor-markdown-DkITEES2.js","assets/Shell-CrjXAW4f.js","assets/Shell-DrlLKa8f.css"])))=>i.map(i=>d[i]);
2
+ import{r as o,j as t,d as er,b as qt}from"./vendor-react-C2GTiUCy.js";import{a as $e,p as Br,b as Qn,c as jr,C as Dt,d as Et,e as Ft,f as Ae,g as Vt,u as Os,_ as Ps,h as Yn,Q as Xn,i as Zn,j as ea,k as ta,l as _s,m as ra,n as sa,S as Nr,o as na,q as aa,B as Qe,r as or,v as Ds,V as qr,L as tr,R as Vr,s as Hr,t as zr,w as Fs,I as Cr,x as jt,D as Sr,y as oa,z as Mr,A as Tr,E as la,F as ia,G as ca,H as da,J as ua,K as Wr,P as Xt,M as ma,N as pa,O as fa,T as xa,U as fr,W as ha,X as ga,Y as ba,Z as ya,$ as ka,a0 as wa,a1 as va,a2 as ja,a3 as Na}from"./feature-workspace-BMlv7Ust.js";import{V as Ca,t as It,o as Ut,q as Us,$ as Rr,ap as Sa,X as it,aa as Bs,aq as Ma,ar as Ta,as as qs,d as Vs,L as $t,ad as Ea,at as Ia,au as $a,av as La,C as rr,m as Hs,ag as Ra,n as Aa,aw as Oa,ax as zs,U as Ar,h as Bt,ay as Kr,S as Pa,az as _a,ae as Da,a9 as Fa,Z as Ua,aA as Ba,aB as qa,aC as Ws,r as Va,aD as Ha,aE as za,aF as Wa,j as Ks,aG as Ka,F as Ga,a as Or,g as Ja,x as Qa,aj as Ya,A as lr,aH as Xa,T as Za,aI as eo,v as to,aJ as ro,aK as so,aL as no,aM as ao,aN as Gs,aO as Js,aP as oo,aQ as Pr,aR as sr,aS as Qs,aT as lo,aU as io,O as co,b as uo,aV as mo}from"./vendor-ui-CAUHSABu.js";import{y as po,t as fo,a as xo,s as ho,b as go,p as bo,c as yo,m as ko,d as wo,j as vo,e as jo,f as No,g as Co,h as So,i as Mo,k as To,l as Eo,n as Io,o as $o,S as ct,r as Gr,q as Jr,u as Lo,v as Ro,M as Ao,w as Oo,x as Po}from"./vendor-markdown-DkITEES2.js";import{u as We,T as _o}from"./vendor-i18n-B6HjLCnN.js";const Ys=o.createContext(null);function Do(){return o.useContext(Ys)}const rt="default",Qr={claude:["low","medium","high","xhigh","max"],codex:["low","medium","high","xhigh","max","ultra"],opencode:["none","low","medium","high","xhigh","max"]},Fo=e=>e.map(r=>({value:r})),zt={claude:"default",cursor:"gpt-5.3-codex",codex:"gpt-5.4",opencode:"anthropic/claude-sonnet-4-5"},_t=["claude","cursor","codex","opencode"],Uo=()=>{const e=localStorage.getItem("selected-provider");return _t.includes(e)?e:"claude"},Bo={claude:["default","auto","acceptEdits","bypassPermissions","plan"],cursor:["default","acceptEdits","bypassPermissions","plan"],codex:["default","acceptEdits","bypassPermissions"],opencode:["default","acceptEdits","bypassPermissions","plan"]},Wt=(e,r)=>`${e}:${r}`;function qo({selectedSession:e,selectedProject:r}){const[s,a]=o.useState("default"),[n,l]=o.useState([]),[i,c]=o.useState(Uo),[d,u]=o.useState(()=>localStorage.getItem("cursor-model")||zt.cursor),[x,v]=o.useState(()=>localStorage.getItem("claude-model")||zt.claude),[g,b]=o.useState(()=>localStorage.getItem("codex-model")||zt.codex),[N,k]=o.useState(()=>_t.reduce((C,S)=>(C[S]=localStorage.getItem(`${S}-effort`)||rt,C),{})),[E,w]=o.useState(()=>localStorage.getItem("opencode-model")||zt.opencode),[L,f]=o.useState(null),[m,p]=o.useState({}),[h,y]=o.useState(!0),I=o.useRef(0),T=o.useRef(0),j=o.useRef(0),A=o.useRef(0),_=o.useCallback((C,S)=>{if(C==="claude"){v(S),localStorage.setItem("claude-model",S);return}if(C==="cursor"){u(S),localStorage.setItem("cursor-model",S);return}if(C==="codex"){b(S),localStorage.setItem("codex-model",S);return}w(S),localStorage.setItem("opencode-model",S)},[]),H=o.useCallback((C,S)=>{k(F=>F[C]===S?F:{...F,[C]:S}),localStorage.setItem(`${C}-effort`,S)},[]),M=o.useCallback(async()=>{const C=I.current+1;I.current=C,y(!0);try{const S=await Promise.all(_t.map(async q=>{const de=await(await $e(`/api/providers/${q}/models`)).json();return!de.success||!de.data?.models?null:de.data.models}));if(I.current!==C)return;const F={};_t.forEach((q,W)=>{const de=S[W];de&&(F[q]=de)}),p(F)}catch(S){console.error("Error loading provider models:",S)}finally{I.current===C&&y(!1)}},[]);o.useEffect(()=>{M()},[M]),o.useEffect(()=>{let C=!1;return(async()=>{try{const q=await(await $e("/api/providers/capabilities")).json();if(C||!q.success||!Array.isArray(q.data?.providers))return;const W={};for(const de of q.data.providers)W[de.provider]=de;f(W)}catch(F){console.error("Error loading provider capabilities:",F)}})(),()=>{C=!0}},[]);const O=o.useCallback(C=>{const S=L?.[C]?.permissionModes;return S&&S.length>0?S:Bo[C]??["default"]},[L]),$=o.useCallback(C=>{const S=O(C),F=L?.[C]?.defaultPermissionMode;return F&&S.includes(F)?F:S[0]??"default"},[O,L]),P=o.useCallback(C=>{const S=L?.[C]?.supportsEffort;return typeof S=="boolean"?S:!!Qr[C]?.length},[L]),B=(C,S,F)=>{const q=localStorage.getItem(C);return q&&F.OPTIONS.some(W=>W.value===q)?q:S&&F.OPTIONS.some(W=>W.value===S)?S:F.DEFAULT},z=o.useCallback((C,S)=>{const F=m[C];return F?F.OPTIONS.find(q=>q.value===S)??null:null},[m]),U=o.useCallback((C,S)=>{if(!P(C))return[];const F=z(C,S);return F?F.effort?.values??[]:Fo(Qr[C]??[])},[z,P]),ee=o.useCallback((C,S)=>U(C,S).map(F=>F.value),[U]),ie=o.useCallback((C,S,F)=>{const q=ee(C,S);return q.length===0||F===rt||!F?rt:q.includes(F)?F:rt},[ee]),X=o.useMemo(()=>({claude:x,cursor:d,codex:g,opencode:E}),[x,d,g,E]);o.useEffect(()=>{const C=m.claude;if(C){const S=B("claude-model",x,C);S!==x&&v(S),localStorage.getItem("claude-model")!==S&&localStorage.setItem("claude-model",S)}},[m.claude,x]),o.useEffect(()=>{const C=m.cursor;if(C){const S=B("cursor-model",d,C);S!==d&&u(S),localStorage.getItem("cursor-model")!==S&&localStorage.setItem("cursor-model",S)}},[m.cursor,d]),o.useEffect(()=>{const C=m.codex;if(C){const S=B("codex-model",g,C);S!==g&&b(S),localStorage.getItem("codex-model")!==S&&localStorage.setItem("codex-model",S)}},[m.codex,g]),o.useEffect(()=>{const C=m.opencode;if(C){const S=B("opencode-model",E,C);S!==E&&w(S),localStorage.getItem("opencode-model")!==S&&localStorage.setItem("opencode-model",S)}},[m.opencode,E]),o.useEffect(()=>{const C={};let S=!1;for(const F of _t){const q=N[F]??rt,W=ie(F,X[F],q);W!==q&&(C[F]=W,localStorage.setItem(`${F}-effort`,W),S=!0)}S&&k(F=>({...F,...C}))},[N,X,ie]),o.useEffect(()=>{const C=O(i),S=e?.id?localStorage.getItem(`permissionMode-${e.id}`):null,F=localStorage.getItem(`permissionMode-last-${i}`),q=[S,F].find(W=>!!(W&&C.includes(W)));a(q??$(i))},[e?.id,i,$,O]),o.useEffect(()=>{!e?.__provider||e.__provider===i||(c(e.__provider),localStorage.setItem("selected-provider",e.__provider))},[i,e]),o.useEffect(()=>{l(C=>C.filter(S=>!S.sessionId||S.sessionId===e?.id))},[e?.id]);const pe=o.useCallback(C=>{a(C),localStorage.setItem(`permissionMode-last-${i}`,C),e?.id&&localStorage.setItem(`permissionMode-${e.id}`,C)},[i,e?.id]),me=o.useCallback(()=>{const C=O(i),F=(C.indexOf(s)+1)%C.length;pe(C[F])},[s,i,O,pe]),he=o.useMemo(()=>O(i),[O,i]),Y=o.useCallback((C,S)=>O(C).includes(S)?S:$(C),[$,O]),[le,ae]=o.useState(null),K=e?.id?.trim()||null,ce=e?.__provider??i,ge=K?Wt(ce,K):null,fe=o.useRef(ge);fe.current=ge;const be=le&&K&&le.sessionId===K&&le.provider===ce?le:null,oe=be?.model??null;o.useEffect(()=>{const C=T.current+1;if(T.current=C,!K){ae(null);return}let S=!1;const F=ce,q=Wt(F,K);return(async()=>{try{const Ce=await(await $e(`/api/providers/${F}/sessions/${encodeURIComponent(K)}/active-model`)).json();if(S||T.current!==C||fe.current!==q)return;const xe=Ce.data?.model?.trim(),Se=Ce.data?.effort?.trim()||null;ae({provider:F,sessionId:K,model:Ce.success&&xe&&Ce.data?.source!=="default"?xe:null,effort:Ce.success?Se:null})}catch(de){!S&&T.current===C&&fe.current===q&&(console.error("Error loading the session model and reasoning effort:",de),ae({provider:F,sessionId:K,model:null,effort:null}))}})(),()=>{S=!0}},[K,ce]);const ne=o.useCallback(async(C,S,F)=>{_(C,S);const q=typeof F=="string"?F.trim():"";if(!q)return{scope:"default",model:S};T.current+=1;const W=j.current+1;j.current=W;const de=Wt(C,q),Ce=await $e(`/api/providers/${C}/sessions/${encodeURIComponent(q)}/active-model`,{method:"POST",body:JSON.stringify({model:S})}),xe=await Ce.json();if(!Ce.ok||!xe.success)throw new Error("Unable to change the active model for this session.");const Se=xe.data?.model?.trim()||S;return j.current===W&&fe.current===de&&ae(Re=>({provider:C,sessionId:q,model:Se,effort:Re?.provider===C&&Re.sessionId===q?Re.effort:xe.data?.effort?.trim()||null})),{scope:"session",model:Se}},[_]),ve=o.useCallback(async(C,S,F)=>{H(C,S);const q=typeof F=="string"?F.trim():"";if(!q)return{scope:"default",effort:S};T.current+=1;const W=A.current+1;A.current=W;const de=Wt(C,q),Ce=le?.provider===C&&le.sessionId===q?le:null;ae({provider:C,sessionId:q,model:Ce?.model??null,effort:S});try{const xe=await $e(`/api/providers/${C}/sessions/${encodeURIComponent(q)}/active-effort`,{method:"POST",body:JSON.stringify({effort:S})}),Se=await xe.json();if(!xe.ok||!Se.success)throw new Error("Unable to change the reasoning effort for this session.");const Re=Se.data?.effort?.trim()||S;return A.current===W&&fe.current===de&&ae(_e=>({provider:C,sessionId:q,model:_e?.provider===C&&_e.sessionId===q?_e.model:Ce?.model??null,effort:Re})),{scope:"session",effort:Re}}catch(xe){throw A.current===W&&fe.current===de&&ae(Se=>Se?.provider===C&&Se.sessionId===q&&Se.effort===S?Ce:Se),xe}},[le,H]),Ne=oe??X[i],Pe=o.useMemo(()=>U(i,Ne),[Ne,U,i]),nt=o.useMemo(()=>ie(i,Ne,be?.effort??N[i]??rt),[be?.effort,Ne,i,N,ie]),je=o.useMemo(()=>m[i]?.OPTIONS??[],[i,m]),re=o.useCallback((C,S)=>{p(F=>({...F,[C]:S}))},[]),Ee=o.useCallback(async C=>{const S=await C.json();if(!C.ok||!S.success||!S.data?.model||!S.data.models)throw new Error(S.error?.message||"Unable to save this model.");return{model:S.data.model,models:S.data.models}},[]),Ie=o.useCallback(async(C,S)=>{const F=await $e(`/api/providers/${C}/models`,{method:"POST",body:JSON.stringify(S)}),q=await Ee(F);re(C,q.models)},[re,Ee]),ue=o.useCallback(async(C,S,F)=>{if(!S.recordId)throw new Error("This model cannot be edited.");const q=await $e(`/api/providers/${C}/models/${S.recordId}`,{method:"PATCH",body:JSON.stringify(F)}),W=await Ee(q);re(C,W.models),X[C]===S.value&&_(C,W.model.value),i===C&&oe===S.value&&ae(de=>de&&{...de,model:W.model.value})},[re,i,X,Ee,oe,_]),Ye=o.useCallback(async(C,S)=>{if(!S.recordId)throw new Error("This model cannot be deleted.");const F=await $e(`/api/providers/${C}/models/${S.recordId}`,{method:"DELETE"}),q=await Ee(F);re(C,q.models),X[C]===S.value&&_(C,q.models.DEFAULT),i===C&&oe===S.value&&ae(W=>W&&{...W,model:q.models.DEFAULT})},[re,i,X,Ee,oe,_]),Le=o.useMemo(()=>({create:Ie,update:ue,remove:Ye}),[Ie,Ye,ue]);return{provider:i,setProvider:c,cursorModel:d,setCursorModel:u,claudeModel:x,setClaudeModel:v,codexModel:g,setCodexModel:b,currentProviderEffort:nt,currentProviderEffortOptions:Pe,currentProviderModel:Ne,currentProviderModelOptions:je,opencodeModel:E,setOpenCodeModel:w,permissionMode:s,setPermissionMode:a,pendingPermissionRequests:n,setPendingPermissionRequests:l,availablePermissionModes:he,selectPermissionMode:pe,cyclePermissionMode:me,providerModelCatalog:m,providerModelsLoading:h,providerModelActions:Le,selectProviderModel:ne,selectProviderEffort:ve,resolvePermissionModeForProvider:Y}}const gt=20;function Vo(e,r={}){const s=new URLSearchParams;r.limit!==null&&r.limit!==void 0&&(s.set("limit",String(r.limit)),s.set("offset",String(r.offset??0)));const a=s.toString(),n=`/api/providers/sessions/${encodeURIComponent(e)}/messages`;return a?`${n}?${a}`:n}function Yr(e){if(e===void 0)return"";try{return JSON.stringify(e)}catch{return String(e)}}function Xs(e,r){return e.id===r.id?!0:e.provider!==r.provider||e.kind!==r.kind||e.timestamp!==r.timestamp||e.role!==r.role?!1:e.toolId||r.toolId?e.toolId===r.toolId:e.rowid!==void 0||r.rowid!==void 0?e.rowid===r.rowid:e.sequence!==void 0||r.sequence!==void 0?e.sequence===r.sequence:(e.content??"")===(r.content??"")&&(e.text??"")===(r.text??"")&&(e.toolName??"")===(r.toolName??"")&&(e.commandName??"")===(r.commandName??"")&&(e.parentToolUseId??"")===(r.parentToolUseId??"")&&Yr(e.toolInput)===Yr(r.toolInput)}function Zs(e,r){const s=Math.min(e.length,r.length);for(let a=s;a>0;a--){const n=e.length-a;let l=!0;for(let i=0;i<a;i++)if(!Xs(e[n+i],r[i])){l=!1;break}if(l)return a}return 0}function Ho(e,r,s,a,n=0){if(e.length===0||r.length===0||Zs(e,r)>0)return null;const l=Math.max(0,a-s),i=Math.max(0,l-r.length-n),c=n===0?Math.max(1,i+1):gt;return{offset:r.length+n,limit:c}}function zo(e,r){const s=e[e.length-1],a=r[0];if(!s||!a)return!1;const n=Date.parse(s.timestamp),l=Date.parse(a.timestamp);return!Number.isFinite(n)||!Number.isFinite(l)?!1:l<=n}function Xr(e,r){if(e.length===0)return{messages:r,overlapLength:0};if(r.length===0)return{messages:e,overlapLength:0};const s=Zs(e,r);return s===0?{messages:e,overlapLength:0}:{messages:[...e.slice(0,e.length-s),...r],overlapLength:s}}function en(e,r){const s=Math.min(e.length,r.length);let a=0;for(let l=s;l>0;l--){const i=r.length-l;let c=!0;for(let d=0;d<l;d++)if(!Xs(r[i+d],e[d])){c=!1;break}if(c){a=l;break}}const n=r.length-a;return{messages:[...r.slice(0,n),...e],overlapLength:a,prependedCount:n}}function Wo(e,r,s,a){return{offset:r,hasMore:(e===0||s)&&a}}function Ko(e,r){const s=new Set,a=new Map,n=l=>{const i=a.get(l);if(i)return s.add(l),i;const c=(async()=>{try{do if(s.delete(l),await e(l)===!1){s.add(l);break}while(s.has(l)&&r(l))}catch{s.add(l)}})().finally(()=>{a.delete(l)});return a.set(l,c),c};return{request(l,i=!0){return!i||!r(l)?(s.add(l),Promise.resolve()):n(l)},flushPending(l){return!s.has(l)||!r(l)?Promise.resolve():n(l)},discardPending(l){s.delete(l)},hasPending(l){return s.has(l)}}}const Go=(e,r)=>{const s=e.split(`
3
3
  `),a=r.split(`
4
4
  `),n=Array.from({length:s.length+1},()=>new Array(a.length+1).fill(0));for(let d=s.length-1;d>=0;d-=1)for(let u=a.length-1;u>=0;u-=1)s[d]===a[u]?n[d][u]=n[d+1][u+1]+1:n[d][u]=Math.max(n[d+1][u],n[d][u+1]);const l=[];let i=0,c=0;for(;i<s.length&&c<a.length;){const d=s[i],u=a[c];if(d===u){i+=1,c+=1;continue}if(n[i+1][c]>=n[i][c+1]){l.push({type:"removed",content:d,lineNum:i+1}),i+=1;continue}l.push({type:"added",content:u,lineNum:c+1}),c+=1}for(;i<s.length;)l.push({type:"removed",content:s[i],lineNum:i+1}),i+=1;for(;c<a.length;)l.push({type:"added",content:a[c],lineNum:c+1}),c+=1;return l},Jo=()=>{const e=new Map;return(r,s)=>{const a=JSON.stringify([r,s]),n=e.get(a);if(n)return n;const l=Go(r,s);if(e.set(a,l),e.size>100){const i=e.keys().next().value;i&&e.delete(i)}return l}};function Qo(e){if(!e||typeof e!="string")return e;try{return e.replace(/```[ \t]*([^\n\r]+?)[ \t]*```/g,"`$1`")}catch{return e}}function tn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yo(e){if(!e||typeof e!="string")return e;const r=/^\s*<proposed_plan>[ \t]*(?:\r?\n)?/i;return r.test(e)?e.replace(r,"").replace(/(?:\r?\n)?[ \t]*<\/proposed_plan>\s*$/i,""):e}function Er(e){try{return typeof e!="string"?e:e.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(r,s)=>{let a=parseInt(s,10);if(!Number.isFinite(a))return r;a<1e12&&(a*=1e3);const n=new Date(a),l=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(n),i=-n.getTimezoneOffset(),c=i>=0?"+":"-",d=Math.abs(i),u=Math.floor(d/60),x=d%60,v=`GMT${c}${u}${x?":"+String(x).padStart(2,"0"):""}`,N=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,L=>L.toUpperCase()),k=N?`${v} (${N})`:v,E=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],w=`${n.getDate()} ${E[n.getMonth()]} ${n.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${l} ${k}** - ${w}`})}catch{return e}}function Zr(e){const r=typeof e=="string"?e:JSON.stringify(e),s=/^<tool_use_error>([\s\S]*)<\/tool_use_error>$/.exec(r.trim());return s?s[1]:r}function Xo(e){if(!e.trimStart().startsWith("<task-notification>"))return null;const r=/<status>([\s\S]*?)<\/status>/.exec(e),s=/<summary>([\s\S]*?)<\/summary>/.exec(e);let a="";const n=e.indexOf("<result>");if(n!==-1){const l=e.slice(n+8),i=l.indexOf("</result>");a=i===-1?l.replace(/<\/task-notification>\s*$/,"").trim():l.slice(0,i).trim()}return{status:r?.[1]?.trim()||"completed",summary:s?.[1]?.trim()||"Background task finished",result:a}}function Zo(e){const r=[],s=new Map,a=new Set;for(const n of e)n.kind==="tool_use"&&n.toolId&&a.add(n.toolId),n.kind==="tool_result"&&n.toolId&&s.set(n.toolId,n);for(const n of e){const l={displayText:n.displayText,commandName:n.commandName,commandMessage:n.commandMessage,commandArgs:n.commandArgs,isLocalCommand:n.isLocalCommand,isLocalCommandStdout:n.isLocalCommandStdout,isCompactSummary:n.isCompactSummary};switch(n.kind){case"text":{const i=n.content||"",c=Array.isArray(n.images)&&n.images.length>0?n.images:void 0,d=Array.isArray(n.files)&&n.files.length>0?n.files:void 0;if(!i.trim()&&!c&&!d)continue;if(n.role==="user"){const u=Xo(i);u?(r.push({type:"assistant",content:u.summary,timestamp:n.timestamp,isTaskNotification:!0,taskStatus:u.status,...l}),u.result&&r.push({type:"assistant",content:Er(u.result),timestamp:n.timestamp,...l})):r.push({type:"user",content:i,timestamp:n.timestamp,images:c,files:d,...l})}else{const u=Er(i);r.push({type:"assistant",content:u,timestamp:n.timestamp,...l})}break}case"tool_use":{const i=n.toolResult||(n.toolId?s.get(n.toolId):null),c=n.toolName==="Task",d=[];if(c&&n.subagentTools&&Array.isArray(n.subagentTools))for(const x of n.subagentTools)d.push({toolId:x.toolId,toolName:x.toolName,toolInput:x.toolInput,toolResult:x.toolResult||null,timestamp:new Date(x.timestamp||Date.now())});const u=i?{content:Zr(i.content),isError:!!i.isError,toolUseResult:i.toolUseResult}:null;r.push({type:"assistant",content:"",timestamp:n.timestamp,isToolUse:!0,toolName:n.toolName,toolInput:typeof n.toolInput=="string"?n.toolInput:JSON.stringify(n.toolInput??"",null,2),toolId:n.toolId,toolResult:u,isSubagentContainer:c,subagentState:c?{childTools:d,currentToolIndex:d.length>0?d.length-1:-1,isComplete:!!u}:void 0,...l});break}case"thinking":n.content?.trim()&&r.push({type:"assistant",content:n.content,timestamp:n.timestamp,isThinking:!0,...l});break;case"error":r.push({type:"error",content:n.content||"Unknown error",timestamp:n.timestamp,...l});break;case"interactive_prompt":r.push({type:"assistant",content:n.content||"",timestamp:n.timestamp,isInteractivePrompt:!0,...l});break;case"task_notification":r.push({type:"assistant",content:n.summary||"Background task update",timestamp:n.timestamp,isTaskNotification:!0,taskStatus:n.status||"completed",...l});break;case"stream_delta":n.content&&r.push({type:"assistant",content:n.content,timestamp:n.timestamp,isStreaming:!0,...l});break;case"stream_end":case"complete":case"status":case"permission_request":case"permission_cancelled":case"session_created":break;case"tool_result":{if(n.toolId&&a.has(n.toolId)||n.toolId)break;const i=Zr(n.content||"");if(!i.trim())break;r.push({type:n.isError?"error":"assistant",content:i,timestamp:n.timestamp,toolId:n.toolId,...l});break}}}return r}const Ot=100,el=[];function es(e){const r=e.getBoundingClientRect(),s=Array.from(e.querySelectorAll(".chat-message")).find(a=>a.getBoundingClientRect().bottom>=r.top)??null;return{height:e.scrollHeight,top:e.scrollTop,anchor:s,anchorOffset:s?s.getBoundingClientRect().top-r.top:null}}function ts(e,r,s){const a=`local_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,n=e.timestamp instanceof Date?e.timestamp.toISOString():typeof e.timestamp=="number"?new Date(e.timestamp).toISOString():String(e.timestamp),l={id:a,sessionId:r,timestamp:n,provider:s};return e.isToolUse?{...l,kind:"tool_use",toolName:e.toolName,toolInput:e.toolInput,toolId:e.toolId||a}:e.isThinking?{...l,kind:"thinking",content:e.content||""}:e.isInteractivePrompt?{...l,kind:"interactive_prompt",content:e.content||""}:e.isTaskNotification?{...l,kind:"task_notification",status:e.taskStatus||"completed",summary:e.content||""}:e.type==="error"?{...l,kind:"error",content:e.content||""}:{...l,kind:"text",role:e.type==="user"?"user":"assistant",content:e.content||"",images:Array.isArray(e.images)&&e.images.length>0?e.images:void 0,files:Array.isArray(e.files)&&e.files.length>0?e.files:void 0}}function tl({isActive:e,selectedProject:r,selectedSession:s,ws:a,sendMessage:n,externalMessageUpdate:l,newSessionTrigger:i,processingSessions:c,onSessionIdle:d,resetStreamingState:u,statusCheckSentAtRef:x,lastSeqRef:v,sessionStore:g}){const[b,N]=o.useState(s?.id||null),[k,E]=o.useState(!1),[w,L]=o.useState(!1),[f,m]=o.useState(!1),[p,h]=o.useState(0),[y,I]=o.useState(!1),[T,j]=o.useState(null),[A,_]=o.useState(Ot),[H,M]=o.useState(!1),[O,$]=o.useState(!1),[P,B]=o.useState(!1),[z,U]=o.useState(!1),[ee,ie]=o.useState(0),X=o.useRef(null),pe=o.useRef(!1),[me,he]=o.useState(null),Y=o.useRef(!1),le=o.useRef(!1),ae=o.useRef(!1),K=o.useRef(!1),ce=o.useRef(null),ge=o.useRef(!0),fe=o.useRef(0),be=o.useRef({height:0,top:0}),oe=o.useRef(null),ne=o.useRef(null),ve=o.useRef(null),Ne=o.useRef(0),Pe=o.useRef(i??0),nt=o.useMemo(()=>Jo(),[]);o.useEffect(()=>{const R=i??0;R!==Pe.current&&(Pe.current=R,u(),N(null),de(null),fe.current=0,m(!1),h(0),j(null),_(Ot),M(!1),ae.current=!1,$(!1),B(!1),U(!1),ie(0),he(null),pe.current=!1,Y.current=!1,K.current=!1,ce.current=null,ge.current=!0,ve.current=null,ne.current&&(clearTimeout(ne.current),ne.current=null),oe.current&&(clearTimeout(oe.current),oe.current=null))},[i,d,u]);const je=s?.id??null,re=je||b||null,Ee=re&&c?.get(re)||null,Ie=Ee!==null,ue=Ie&&Ee.canInterrupt,Ye=o.useRef(c);Ye.current=c;const Le=o.useRef(e),C=o.useRef(re);Le.current=e,C.current=re;const S=o.useRef(async()=>!0);S.current=async R=>{const J=await g.refreshLatestFromServer(R,{limit:gt,canRequest:()=>Le.current&&C.current===R}),Z=J.slot;return Z&&C.current===R&&(m(Z.hasMore),h(Z.total),fe.current=Z.offset,Z.tokenUsage!==void 0&&j(Z.tokenUsage??null)),!J.deferred};const F=o.useRef(null);F.current||(F.current=Ko(R=>S.current(R),R=>Le.current&&C.current===R));const q=o.useCallback((R,J=Le.current)=>F.current?.request(R,J)??Promise.resolve(),[]),[W,de]=o.useState(null),Ce=o.useRef(null),xe=e?re:null,Se=o.useRef(null);xe!==Se.current&&(Se.current=xe,g.setActiveSession(xe)),o.useEffect(()=>{if(!W){Ce.current=null;return}if(!re||Ce.current===W)return;const R=localStorage.getItem("selected-provider")||"claude",J=ts(W,re,R);J&&g.appendRealtime(re,J),Ce.current=W,de(null)},[re,W,g]);const Re=re?g.getMessages(re):el,_e=o.useRef(0);Re.length!==_e.current&&(_e.current=Re.length,ee>0&&ie(0));const Me=o.useMemo(()=>{const R=Zo(Re);return W&&R.length===0?[W]:ee>0&&ee<R.length?R.slice(0,-ee):R},[Re,ee,W]),bt=o.useCallback(R=>{if(!re){de(R);return}const J=localStorage.getItem("selected-provider")||"claude",Z=ts(R,re,J);Z&&g.appendRealtime(re,Z)},[re,g]),dt=o.useCallback(()=>{re&&g.clearRealtime(re)},[re,g]),yt=o.useCallback(R=>ie(R),[]),Ue=o.useCallback(()=>{const R=X.current;R&&(R.scrollTop=R.scrollHeight)},[]),et=o.useCallback(()=>{Ue(),H&&(_(Ot),M(!1),ae.current=!1)},[H,Ue]),Je=o.useCallback(()=>{const R=X.current;if(!R)return!1;const{scrollTop:J,scrollHeight:Z,clientHeight:se}=R;return Z-J-se<50},[]),Be=o.useCallback(async R=>{if(!e||!R||le.current||w||ae.current||!f||!s||!r)return!1;le.current=!0,L(!0);const J=es(R);try{const Z=await g.fetchMore(s.id,{limit:gt,canRequest:()=>Le.current&&C.current===s.id}),{slot:se,prependedCount:ke}=Z;return m(se.hasMore),h(se.total),fe.current=se.offset,se.tokenUsage!==void 0&&j(se.tokenUsage??null),ke===0?(se.hasMore||(ae.current=!0,M(!0),ne.current&&(clearTimeout(ne.current),ne.current=null),U(!1)),!1):(ce.current=J,_(Te=>Te+gt),se.hasMore||(ae.current=!0,M(!0),ne.current&&(clearTimeout(ne.current),ne.current=null),U(!1)),!0)}finally{le.current=!1,L(!1)}},[f,e,w,r,s,g]),G=o.useCallback(async()=>{if(!e)return;const R=X.current;if(!R)return;const J=Je();I(!J),be.current={height:R.scrollHeight,top:R.scrollTop};const Z=R.scrollTop<100;if(Z&&f&&!ae.current?pe.current||(pe.current=!0,ne.current&&clearTimeout(ne.current),U(!0),ne.current=setTimeout(()=>{U(!1),ne.current=null},2500)):Z||(pe.current=!1),!ae.current){if(!Z){K.current=!1;return}if(K.current){R.scrollTop>20&&(K.current=!1);return}await Be(R)&&(K.current=!0)}},[f,e,Je,Be]),Oe=o.useRef(e);o.useLayoutEffect(()=>{const R=e&&!Oe.current;if(Oe.current=e,!e||!X.current)return;const J=X.current;if(ce.current){const{height:Z,top:se,anchor:ke,anchorOffset:Te}=ce.current;if(ke?.isConnected&&Te!==null){const qe=ke.getBoundingClientRect().top-J.getBoundingClientRect().top;J.scrollTop+=qe-Te}else J.scrollTop=se+Math.max(J.scrollHeight-Z,0);ce.current=null;return}R&&(J.scrollTop=y?be.current.top:J.scrollHeight)},[Me.length,e,y]),o.useEffect(()=>{Y.current||(ge.current=!0,_(Ot)),K.current=!1,ce.current=null,pe.current=!1,I(!1)},[r?.projectId,s?.id]),o.useEffect(()=>{if(!e||!ge.current||!X.current||k)return;if(Me.length===0){ge.current=!1;return}if(Y.current){ge.current=!1;return}const R=X.current;let J=0,Z=0,se=0,ke=0;const Te=()=>{!ge.current||!X.current||(R.scrollTop=R.scrollHeight,R.scrollHeight===Z?se++:(se=0,Z=R.scrollHeight),J++,se<3&&J<60?ke=requestAnimationFrame(Te):ge.current=!1)};return ke=requestAnimationFrame(Te),()=>{ke&&cancelAnimationFrame(ke)}},[Me.length,e,k,Ue]),o.useEffect(()=>{!s||!r||!a||(x.current.set(s.id,Date.now()),n({type:"chat.subscribe",sessions:[{sessionId:s.id,lastSeq:v.current.get(s.id)??0}]}))},[v,r,s,n,x,a]),o.useEffect(()=>{if(!je||!r){if(b&&Ye.current?.has(b))return;u(),N(null),fe.current=0,m(!1),h(0),j(null),ve.current=null,Ne.current+=1,E(!1);return}if(!e){E(!1);return}const R=`${je}:${r.projectId}`,J=g.getSessionSlot(je),Z=ve.current===R&&J?.status==="loading",se=ve.current===R&&!!J?.fetchedAt;if(Z)return;if(se){g.isStale(je)&&q(je);return}const ke=b!==null&&b!==je;ke&&u(),fe.current=0,m(!1),h(0),_(Ot),M(!1),ae.current=!1,$(!1),B(!1),U(!1),ie(0),pe.current=!1,ne.current&&clearTimeout(ne.current),oe.current&&clearTimeout(oe.current),ke&&j(null),N(je),ve.current=R;const Te=++Ne.current;E(!0),g.fetchFromServer(je,{limit:gt,offset:0,canRequest:()=>Le.current&&C.current===je}).then(qe=>{Ne.current!==Te||C.current!==je||qe&&(m(qe.hasMore),h(qe.total),fe.current=qe.offset,qe.tokenUsage!==void 0&&j(qe.tokenUsage??null))}).catch(()=>{}).finally(()=>{Ne.current===Te&&C.current===je&&E(!1)})},[e,b,u,q,r,je,g]),o.useEffect(()=>{if(!e||!re)return;const R=g.getSessionSlot(re);if(!R?.fetchedAt||R.status==="loading"){F.current?.discardPending(re);return}F.current?.flushPending(re)},[re,e,g]),o.useEffect(()=>{if(!l||!s||!r)return;(async()=>{try{if(!Ie){const J=Le.current&&Je();await q(s.id),J&&setTimeout(()=>Ue(),200)}}catch(J){console.error("Error reloading messages from external update:",J)}})()},[l,Je,q,Ue,r,s,Ie]),o.useEffect(()=>{const R=s,J=R?.__searchTargetSnippet,Z=R?.__searchTargetTimestamp;typeof J=="string"&&J&&(Y.current=!0,he({snippet:J,timestamp:typeof Z=="string"?Z:void 0}))},[s]),o.useEffect(()=>{if(!e||!me||Me.length===0||k)return;const R=me;he(null),(async()=>{if(!ae.current&&s&&r)try{const se=await g.fetchFromServer(s.id,{limit:null,offset:0,canRequest:()=>Le.current&&C.current===s.id});if(se)m(!1),h(se.total),fe.current=se.offset,_(1/0),M(!0),ae.current=!0,await new Promise(ke=>setTimeout(ke,300));else if(!Le.current){he(R);return}}catch{}_(1/0);const Z=se=>{const ke=X.current;if(!ke)return;let Te=null;if(R.snippet){const mt=R.snippet.replace(/^\.{3}/,"").replace(/\.{3}$/,"").trim().slice(0,80).toLowerCase().trim();if(mt.length>=10){const pt=ke.querySelectorAll(".chat-message");for(const ot of pt)if((ot.textContent||"").toLowerCase().includes(mt)){Te=ot;break}}}if(!Te&&R.timestamp){const qe=new Date(R.timestamp).getTime(),mt=ke.querySelectorAll("[data-message-timestamp]");let pt=1/0;for(const ot of mt){const kt=ot.getAttribute("data-message-timestamp");if(!kt)continue;const D=Math.abs(new Date(kt).getTime()-qe);D<pt&&(pt=D,Te=ot)}}Te?(Te.scrollIntoView({block:"center",behavior:"smooth"}),Te.classList.add("search-highlight-flash"),setTimeout(()=>Te?.classList.remove("search-highlight-flash"),4e3),Y.current=!1):se>0?setTimeout(()=>Z(se-1),200):Y.current=!1};setTimeout(()=>Z(15),150)})()},[Me.length,e,k,me]),o.useEffect(()=>{if(!s?.id){j(null);return}let R=!1;return(async()=>{try{const Z=`/api/providers/sessions/${encodeURIComponent(s.id)}/token-usage`,se=await $e(Z);if(R)return;if(se.ok){const ke=await se.json();if(R)return;j(ke.data??null)}else j(null)}catch(Z){R||console.error("Failed to fetch initial token usage:",Z)}})(),()=>{R=!0}},[s?.id]);const De=o.useMemo(()=>Me.length<=A?Me:Me.slice(-A),[Me,A]);o.useEffect(()=>{if(!e)return;const R=X.current;R&&(be.current={height:R.scrollHeight,top:R.scrollTop})}),o.useEffect(()=>{e&&(!X.current||Me.length===0||le.current||w||ce.current||Y.current||y||setTimeout(()=>Ue(),50))},[Me.length,e,w,y,Ue]),o.useEffect(()=>{const R=X.current;if(R)return R.addEventListener("scroll",G),()=>R.removeEventListener("scroll",G)},[G]);const ut=o.useCallback(async()=>{if(!e||!s||!r||O)return;const R=s.id;ae.current=!0,le.current=!0,$(!0),U(!0),ne.current&&(clearTimeout(ne.current),ne.current=null);const J=X.current,Z=J?es(J):null;try{const se=await g.fetchFromServer(R,{limit:null,offset:0,canRequest:()=>Le.current&&C.current===R});if(b!==R)return;se?(Z&&(ce.current=Z),m(!1),h(se.total),fe.current=se.offset,_(1/0),M(!0),B(!0),oe.current&&clearTimeout(oe.current),oe.current=setTimeout(()=>{B(!1),U(!1),oe.current=null},2500)):(ae.current=!1,U(!1))}catch(se){console.error("Error loading all messages:",se),ae.current=!1,U(!1)}finally{le.current=!1,$(!1)}},[e,s,r,O,b,g]),at=o.useCallback(()=>{_(R=>R+100)},[]);return{chatMessages:Me,addMessage:bt,clearMessages:dt,rewindMessages:yt,sessionActivity:Ee,isProcessing:Ie,canAbortSession:ue,currentSessionId:b,setCurrentSessionId:N,isLoadingSessionMessages:k,isLoadingMoreMessages:w,hasMoreMessages:f,totalMessages:p,isUserScrolledUp:y,setIsUserScrolledUp:I,tokenBudget:T,setTokenBudget:j,visibleMessageCount:A,visibleMessages:De,loadEarlierMessages:at,loadAllMessages:ut,allMessagesLoaded:H,isLoadingAllMessages:O,loadAllJustFinished:P,showLoadAllOverlay:z,createDiff:nt,scrollContainerRef:X,scrollToBottom:Ue,scrollToBottomAndReset:et,isNearBottom:Je,handleScroll:G,requestLatestMessages:q}}const rl="[Done]",sl=2e3;let Ze=null,Lt=!1;const _r=()=>`${rl} `,rn=e=>{const r=_r();return e.startsWith(r)?e.slice(r.length):e},sn=()=>document.visibilityState==="visible"&&document.hasFocus(),nl=()=>{!Lt||typeof window>"u"||(document.removeEventListener("visibilitychange",lt),window.removeEventListener("focus",lt,!0),window.removeEventListener("click",lt,!0),Lt=!1)},al=()=>{Ze!==null&&(window.clearTimeout(Ze),Ze=null),nl(),nn(),document.title.startsWith(_r())&&(document.title=rn(document.title))},nn=()=>{document.removeEventListener("visibilitychange",on)},an=()=>{Ze!==null&&window.clearTimeout(Ze),Ze=window.setTimeout(()=>{al()},sl),nn(),document.addEventListener("visibilitychange",on,{once:!0})};function lt(){sn()&&an()}function on(){document.visibilityState==="hidden"&&(Ze!==null&&(window.clearTimeout(Ze),Ze=null),Lt||(document.addEventListener("visibilitychange",lt),window.addEventListener("focus",lt,!0),window.addEventListener("click",lt,!0),Lt=!0))}const ol=()=>{if(typeof document>"u"||typeof window>"u")return;const e=rn(document.title||"WindCli");if(document.title=`${_r()}${e}`,sn()){an();return}Ze!==null&&(window.clearTimeout(Ze),Ze=null),Lt||(document.addEventListener("visibilitychange",lt),window.addEventListener("focus",lt,!0),window.addEventListener("click",lt,!0),Lt=!0)},ln=e=>e?.toolName!=="ExitPlanMode"&&e?.toolName!=="exit_plan_mode",rs=e=>Array.isArray(e)&&e.some(r=>ln(r));function ll({isActive:e,subscribe:r,provider:s,selectedSession:a,currentSessionId:n,setTokenBudget:l,pendingPermissionRequests:i,setPendingPermissionRequests:c,streamTimerRef:d,accumulatedStreamRef:u,lastSeqRef:x,statusCheckSentAtRef:v,onSessionProcessing:g,onSessionIdle:b,onWebSocketReconnect:N,requestLatestMessages:k,sessionStore:E}){const w=o.useRef(a?.id||n||null);w.current=a?.id||n||null;const L=o.useRef(e);L.current=e;const f=o.useRef(i);o.useEffect(()=>{f.current=i},[i]),o.useEffect(()=>r(p=>{if(!p.kind)return;const h=w.current,y=typeof p.sessionId=="string"&&p.sessionId||h;if(y&&typeof p.seq=="number"){const T=x.current.get(y)??0;p.seq>T&&x.current.set(y,p.seq)}switch(p.kind){case"websocket_reconnected":N?.();return;case"chat_subscribed":{if(!y)return;if(p.isProcessing?g?.(y):b?.(y,{ifStartedBefore:v.current.get(y)}),y===h&&Array.isArray(p.pendingPermissions)){const j=p.pendingPermissions,A=rs(f.current),_=rs(j);f.current=j,c(j),_&&!A&&Br()}return}case"protocol_error":{console.error("[Chat] Protocol error:",p.code,p.error),y&&(b?.(y),E.appendRealtime(y,{id:`protocol_error_${Date.now()}`,sessionId:y,timestamp:new Date().toISOString(),provider:s,kind:"error",content:String(p.error||"Request failed")}));return}case"session_upserted":case"loading_progress":return}if(p.kind==="stream_delta"){const T=p.content||"";if(!T)return;u.current+=T,d.current||(d.current=window.setTimeout(()=>{d.current=null,y&&E.updateStreaming(y,u.current,s)},100)),y&&y!==h&&E.appendRealtime(y,p);return}if(p.kind==="stream_end"){d.current&&(clearTimeout(d.current),d.current=null),y&&(u.current&&E.updateStreaming(y,u.current,s),E.finalizeStreaming(y)),u.current="";return}const I=p.kind!=="complete"&&p.kind!=="status"&&p.kind!=="permission_request"&&p.kind!=="permission_cancelled";switch(y&&I&&E.appendRealtime(y,p),p.kind){case"complete":{if(d.current&&(clearTimeout(d.current),d.current=null),y&&u.current&&(E.updateStreaming(y,u.current,s),E.finalizeStreaming(y)),u.current="",b?.(y),y===h&&(f.current=[],c([])),p.aborted)break;p.success!==!1&&(ol(),Qn()),y&&y===h&&k(y,L.current);break}case"permission_request":{if(!p.requestId)break;if(ln({toolName:p.toolName})&&Br(),y===h){const T=f.current;if(!T.some(j=>j.requestId===p.requestId)){const j=[...T,{requestId:p.requestId,toolName:p.toolName||"UnknownTool",provider:p.provider,input:p.input,context:p.context,sessionId:y||null,receivedAt:new Date}];f.current=j,c(j)}}y&&g?.(y);break}case"permission_cancelled":{if(p.requestId&&y===h){const T=f.current.filter(j=>j.requestId!==p.requestId);f.current=T,c(T)}break}case"status":{p.text==="token_budget"&&p.tokenBudget?l(p.tokenBudget):p.text&&y&&g?.(y,{statusText:p.text,canInterrupt:p.canInterrupt!==!1});break}}}),[r,s,a,n,l,i,c,d,u,x,v,g,b,N,k,E])}const cn="claude-settings",Ge={setItem:(e,r)=>{try{localStorage.setItem(e,r)}catch(s){if(s?.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data"),Object.keys(localStorage).filter(l=>l.startsWith("draft_input_")||l.startsWith("queued_message_")).forEach(l=>{localStorage.removeItem(l)});try{localStorage.setItem(e,r)}catch(l){console.error("Failed to save to localStorage even after cleanup:",l)}}else console.error("localStorage error:",s)}},getItem:e=>{try{return localStorage.getItem(e)}catch(r){return console.error("localStorage getItem error:",r),null}},removeItem:e=>{try{localStorage.removeItem(e)}catch(r){console.error("localStorage removeItem error:",r)}}},Dr=e=>`queued_message_${e}`;function dn(e){const r=Ge.getItem(Dr(e));if(!r)return null;try{const s=JSON.parse(r);if(s&&typeof s=="object"&&typeof s.content=="string"){const{content:a,options:n,images:l,attachments:i}=s,c=Array.isArray(i)?i:Array.isArray(l)?l:[];return a.trim()||c.length>0?{content:a,options:n,attachments:c}:null}}catch{}return r.trim()?{content:r}:null}function ss(e,r){Ge.setItem(Dr(e),JSON.stringify(r))}function ns(e){Ge.removeItem(Dr(e))}function un(){const e=Ge.getItem(cn);if(!e)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const r=JSON.parse(e);return{...r,allowedTools:Array.isArray(r.allowedTools)?r.allowedTools:[],disallowedTools:Array.isArray(r.disallowedTools)?r.disallowedTools:[],skipPermissions:!!r.skipPermissions,projectSortOrder:r.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function as(e,r){if(!e)return null;if(e!=="Bash")return e;let s=r;if(typeof r=="string")try{s=JSON.parse(r)}catch{return e}const a=s&&typeof s=="object"&&"command"in s&&typeof s.command=="string"?s.command.trim():"";if(!a)return e;const n=a.split(/\s+/);return n.length===0?e:n[0]==="git"&&n[1]?`Bash(${n[0]} ${n[1]}:*)`:`Bash(${n[0]}:*)`}function os(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function il(e){if(!e)return{success:!1};const r=un(),s=r.allowedTools.includes(e),a=s?r.allowedTools:[...r.allowedTools,e],n=r.disallowedTools.filter(i=>i!==e),l={...r,allowedTools:a,disallowedTools:n,lastUpdated:new Date().toISOString()};return Ge.setItem(cn,JSON.stringify(l)),{success:!0,alreadyAllowed:s,updatedSettings:l}}const mn=(e,r="")=>{let s=[];return e.forEach(a=>{const n=r?`${r}/${a.name}`:a.name;if(a.type==="directory"&&a.children){s=s.concat(mn(a.children,n));return}a.type==="file"&&s.push({name:a.name,path:n,relativePath:a.path})}),s};function cl({selectedProject:e,input:r,setInput:s,textareaRef:a}){const[n,l]=o.useState([]),[i,c]=o.useState([]),[d,u]=o.useState([]),[x,v]=o.useState(!1),[g,b]=o.useState(-1),[N,k]=o.useState(0),[E,w]=o.useState(-1);o.useEffect(()=>{const T=new AbortController;return(async()=>{const A=e?.projectId;if(l([]),u([]),!!A)try{const _=await jr.getMentionableFiles(A,{signal:T.signal});if(!_.ok)return;const H=await _.json();l(mn(H))}catch(_){if(_?.name==="AbortError")return;console.error("Error fetching files:",_)}})(),()=>{T.abort()}},[e?.projectId]),o.useEffect(()=>{const T=r.slice(0,N),j=T.lastIndexOf("@");if(j===-1){v(!1),w(-1);return}const A=T.slice(j+1);if(A.includes(" ")){v(!1),w(-1);return}w(j),v(!0),b(-1);const _=n.filter(H=>H.name.toLowerCase().includes(A.toLowerCase())||H.path.toLowerCase().includes(A.toLowerCase())).slice(0,10);u(_)},[r,N,n]);const L=o.useMemo(()=>!r||i.length===0?[]:i.filter(T=>r.includes(T)),[i,r]),f=o.useMemo(()=>L.length===0?[]:Array.from(new Set(L)).sort((j,A)=>A.length-j.length),[L]),m=o.useMemo(()=>{if(f.length===0)return null;const T=f.map(tn).join("|");return new RegExp(`(${T})`,"g")},[f]),p=o.useMemo(()=>new Set(f),[f]),h=o.useCallback(T=>T?m?T.split(m).map((A,_)=>p.has(A)?t.jsx("span",{className:"-ml-0.5 rounded-md bg-blue-200/70 box-decoration-clone px-0.5 text-transparent dark:bg-blue-300/40",children:A},`mention-${_}`):t.jsx("span",{children:A},`text-${_}`)):T:"",[m,p]),y=o.useCallback(T=>{const j=r.slice(0,E),A=r.slice(E),_=A.indexOf(" "),H=_!==-1?A.slice(_):"",M=`${j}${T.path} ${H}`,O=j.length+T.path.length+1;a.current&&!a.current.matches(":focus")&&a.current.focus(),s(M),k(O),c($=>$.includes(T.path)?$:[...$,T.path]),v(!1),w(-1),a.current&&requestAnimationFrame(()=>{a.current&&(a.current.setSelectionRange(O,O),a.current.matches(":focus")||a.current.focus())})},[r,E,a,s]),I=o.useCallback(T=>!x||d.length===0?!1:T.key==="ArrowDown"?(T.preventDefault(),b(j=>j<d.length-1?j+1:0),!0):T.key==="ArrowUp"?(T.preventDefault(),b(j=>j>0?j-1:d.length-1),!0):T.key==="Tab"||T.key==="Enter"?(T.preventDefault(),g>=0?y(d[g]):d.length>0&&y(d[0]),!0):T.key==="Escape"?(T.preventDefault(),v(!1),!0):!1,[x,d,g,y]);return{showFileDropdown:x,filteredFiles:d,selectedFileIndex:g,renderInputWithMentions:h,selectFile:y,setCursorPosition:k,handleFileMentionsKeyDown:I}}const dl=150,pn=e=>`command_history_${e}`,xr=e=>{const r=Ge.getItem(pn(e));if(!r)return{};try{return JSON.parse(r)}catch(s){return console.error("Error parsing command history:",s),{}}},ul=(e,r)=>{Ge.setItem(pn(e),JSON.stringify(r))},ml=e=>!!e&&typeof e.then=="function",pl=e=>e.type==="skill"||e.metadata?.type==="skill",ls=e=>pl(e)||e.metadata?.passthrough===!0,fl=e=>{const r=new Set;return e.filter(s=>{const a=s.command;return r.has(a)?!1:(r.add(a),!0)})},xl=e=>({name:e.command,description:e.description,namespace:"skill",path:e.sourcePath,type:"skill",metadata:{type:e.scope,scope:e.scope,sourcePath:e.sourcePath,pluginName:e.pluginName,pluginId:e.pluginId,skillName:e.name}}),hl=(e,r)=>{const s=r.trim().toLowerCase();if(!s)return e;const a=s.startsWith("/")?s:`/${s}`,n=e.filter(i=>i.name.toLowerCase().startsWith(a));if(s.includes(":")||n.length>0)return n;const l=e.filter(i=>i.name.toLowerCase().includes(s));return l.length>0?l:e.filter(i=>i.description?.toLowerCase().includes(s))};function gl({selectedProject:e,provider:r,input:s,setInput:a,textareaRef:n,onExecuteCommand:l}){const[i,c]=o.useState([]),[d,u]=o.useState([]),[x,v]=o.useState(!1),[g,b]=o.useState(""),[N,k]=o.useState(-1),[E,w]=o.useState(-1),L=o.useRef(null),f=o.useCallback(()=>{L.current!==null&&(window.clearTimeout(L.current),L.current=null)},[]),m=o.useCallback(()=>{v(!1),w(-1),b(""),k(-1),f()},[f]);o.useEffect(()=>{let M=!1;return(async()=>{if(!e){c([]),u([]);return}try{const $=e.fullPath||e.path||"",P=await $e("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:$||e.path,provider:r})});if(!P.ok)throw new Error("Failed to fetch commands");const B=await P.json(),z=new URLSearchParams;$&&z.set("workspacePath",$);const U=await $e(`/api/providers/${encodeURIComponent(r)}/skills${z.toString()?`?${z.toString()}`:""}`),ee=U.ok?await U.json():null,ie=fl(ee?.data?.skills||[]).map(xl),X=[...(B.builtIn||[]).map(he=>({...he,type:"built-in"})),...ie,...(B.custom||[]).map(he=>({...he,type:"custom"}))],pe=xr(e.projectId),me=[...X].sort((he,Y)=>{const le=pe[he.name]||0;return(pe[Y.name]||0)-le});M||c(me)}catch($){console.error("Error fetching slash commands:",$),M||c([])}})(),()=>{M=!0}},[e,r]),o.useEffect(()=>{x||k(-1)},[x]),o.useEffect(()=>{u(hl(i,g))},[g,i]);const p=o.useMemo(()=>{if(!e||i.length===0)return[];const M=xr(e.projectId);return i.map(O=>({...O,usageCount:M[O.name]||0})).filter(O=>O.usageCount>0).sort((O,$)=>$.usageCount-O.usageCount).slice(0,5)},[e,i]),h=o.useCallback(M=>{if(!e)return;const O=xr(e.projectId);O[M.name]=(O[M.name]||0)+1,ul(e.projectId,O)},[e]),y=o.useCallback(M=>{const O=n.current,$=E>=0?E:O?.selectionStart??s.length,P=s.slice(0,$),B=s.slice($),z=B.indexOf(" "),U=E>=0&&z!==-1?B.slice(z).trimStart():s.slice(O?.selectionEnd??$),ee=P&&!/\s$/.test(P)?" ":"",ie=`${P}${ee}${M.name}${U?` ${U}`:" "}`;a(ie),m(),window.requestAnimationFrame(()=>{O?.focus();const X=`${P}${ee}${M.name} `.length;O?.setSelectionRange(X,X)})},[s,m,a,E,n]),I=o.useCallback(M=>{const O=l(M);ml(O)?O.then(()=>{m()},()=>{m()}):m()},[l,m]),T=o.useCallback(M=>{if(ls(M)){y(M);return}I(M)},[I,y]),j=o.useCallback((M,O,$)=>{if(!(!M||!e)){if($){k(O);return}if(h(M),ls(M)){y(M);return}I(M)}},[e,h,y,I]),A=o.useCallback(()=>{const M=!x;v(M),b(""),k(-1),M&&u(i),n.current?.focus()},[x,i,n]),_=o.useCallback((M,O)=>{if(!M.trim()){m();return}const $=M.slice(0,O);if(($.match(/```/g)||[]).length%2===1){m();return}const z=/(?:^|\s)(\/\S*)$/,U=$.match(z);if(!U){m();return}const ee=U.index+(U[0].length-U[1].length),ie=U[1].slice(1);w(ee),v(!0),k(-1),f(),L.current=window.setTimeout(()=>{b(ie)},dl)},[m,f]),H=o.useCallback(M=>x?d.length?M.key==="ArrowDown"?(M.preventDefault(),k(O=>O<d.length-1?O+1:0),!0):M.key==="ArrowUp"?(M.preventDefault(),k(O=>O>0?O-1:d.length-1),!0):M.key==="Tab"||M.key==="Enter"?(M.preventDefault(),N>=0?T(d[N]):d.length>0&&T(d[0]),!0):M.key==="Escape"?(M.preventDefault(),m(),!0):!1:M.key==="Escape"?(M.preventDefault(),m(),!0):!1:!1,[x,d,m,T,N]);return o.useEffect(()=>()=>{f()},[f]),{slashCommands:i,slashCommandsCount:i.length,filteredCommands:d,frequentCommands:p,commandQuery:g,showCommandMenu:x,selectedCommandIndex:N,resetCommandMenuState:m,handleCommandSelect:j,handleToggleCommandMenu:A,handleCommandInputChange:_,handleCommandMenuKeyDown:H}}const hr=()=>({preventDefault:()=>{}}),is=10,cs=10*1024*1024,ds=e=>e.mimeType?.startsWith("image/")?!0:/\.(gif|jpe?g|png|svg|webp)$/i.test(e.path||e.name||""),us=async e=>{if(e.length===0)return[];const r=new FormData;e.forEach(n=>{r.append("files",n)});const s=await $e("/api/assets/files",{method:"POST",headers:{},body:r});if(!s.ok){const n=await s.json().catch(()=>null);throw new Error(n?.error||"Failed to upload files")}const a=await s.json();if(!Array.isArray(a.attachments)||a.attachments.length!==e.length)throw new Error("File upload returned an incomplete result");return a.attachments},ms=e=>{const r=dn(e);return r?{content:r.content,attachments:[],uploadedAttachments:r.attachments??r.images,options:r.options}:null},ps=(e,r)=>{const s=e?.summary||e?.name||e?.title;if(typeof s=="string"&&s.trim()){const n=s.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}const a=r.replace(/\s+/g," ").trim();return a?a.length>80?`${a.slice(0,77)}...`:a:null};function bl({selectedProject:e,selectedSession:r,currentSessionId:s,provider:a,permissionMode:n,cyclePermissionMode:l,resolvePermissionModeForProvider:i,currentProviderModel:c,currentProviderEffort:d,isLoading:u,processingSessions:x,canAbortSession:v,tokenBudget:g,sendMessage:b,sendByCtrlEnter:N,onSessionProcessing:k,onSessionEstablished:E,onInputFocusChange:w,onFileOpen:L,onShowSettings:f,scrollToBottom:m,addMessage:p,setIsUserScrolledUp:h,setPendingPermissionRequests:y}){const[I,T]=o.useState(()=>typeof window<"u"&&e&&Ge.getItem(`draft_input_${e.projectId}`)||""),[j,A]=o.useState([]),[_,H]=o.useState(new Map),[M,O]=o.useState(new Map),[$,P]=o.useState(!1),[B,z]=o.useState(null),U=o.useRef(null),ee=o.useRef(null),ie=o.useRef(null),X=o.useRef(null),pe=o.useRef(null),me=o.useRef(I),he=e?.projectId,Y=r?.id||s||null,le=o.useRef(Y),ae=o.useRef(x);le.current=Y,ae.current=x;const[K,ce]=o.useState(()=>typeof window>"u"||!Y?null:ms(Y)),ge=o.useRef(Y),fe=o.useCallback(D=>{const{action:Q,data:V}=D;switch(Q){case"help":z({kind:"help",data:V||{}});break;case"models":z({kind:"models",data:V||{}});break;case"cost":{z({kind:"cost",data:V||{}});break}case"status":{z({kind:"status",data:V||{}});break}case"memory":V.error?p({type:"assistant",content:`Warning: ${V.message}`,timestamp:Date.now()}):(p({type:"assistant",content:`${V.message}
5
5
 
@@ -13,14 +13,14 @@ ${e.prompt}`),e.resume&&s.push(`**Resuming from:** ${e.resume}`),{content:s.join
13
13
  `)||e.plan})},result:{hidden:!0}},Default:{input:{type:"collapsible",title:"Parameters",defaultOpen:!1,contentType:"text",getContentProps:e=>({content:typeof e=="string"?e:JSON.stringify(e,null,2),format:"code"})},result:{type:"collapsible",contentType:"text",getContentProps:e=>{let r=e?.content||"";if(typeof r=="string")try{const s=JSON.parse(r);if(Array.isArray(s)){const a=s.filter(n=>n.type==="text"&&n.text).map(n=>n.text);a.length>0&&(r=a.join(`
14
14
  `))}}catch{}else if(Array.isArray(r)){const s=r.filter(a=>a.type==="text"&&a.text).map(a=>a.text);s.length>0?r=s.join(`
15
15
  `):r=JSON.stringify(r,null,2)}else typeof r=="object"&&r!==null&&(r=JSON.stringify(r,null,2));return{content:String(r),format:"plain"}}}}};function ir(e){return ws[e]||ws.Default}function Pl(e,r){const s=ir(e);return!s.result||r?.isError?!1:!!(s.result.hidden||s.result.hideOnSuccess&&r)}const bn=({title:e,toolName:r,open:s=!1,action:a,badge:n,onTitleClick:l,children:i,className:c=""})=>t.jsxs(Dt,{defaultOpen:s,className:Ae("group/section",c),children:[l?t.jsxs("div",{className:"flex cursor-default select-none items-center gap-1.5 py-0.5 text-xs group-data-[state=open]/section:sticky group-data-[state=open]/section:top-0 group-data-[state=open]/section:z-10 group-data-[state=open]/section:-mx-1 group-data-[state=open]/section:bg-background group-data-[state=open]/section:px-1",children:[t.jsx(Et,{className:"flex flex-shrink-0 items-center p-0.5 text-muted-foreground hover:text-foreground",children:t.jsx("svg",{className:"h-3 w-3 transition-transform duration-150 group-data-[state=open]/section:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),r&&t.jsx("span",{className:"flex-shrink-0 font-medium text-muted-foreground",children:r}),r&&t.jsx("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground/40",children:"/"}),t.jsx("button",{onClick:l,className:"flex-1 truncate text-left font-mono text-primary transition-colors hover:text-primary/80 hover:underline",children:e}),n&&t.jsx("span",{className:"ml-auto flex-shrink-0",children:n}),a&&t.jsx("span",{className:"ml-1 flex-shrink-0",children:a})]}):t.jsxs(Et,{className:"flex w-full select-none items-center gap-1.5 py-0.5 text-xs text-muted-foreground transition-colors hover:text-foreground group-data-[state=open]/section:sticky group-data-[state=open]/section:top-0 group-data-[state=open]/section:z-10 group-data-[state=open]/section:-mx-1 group-data-[state=open]/section:bg-background group-data-[state=open]/section:px-1",children:[t.jsx("svg",{className:"h-3 w-3 flex-shrink-0 transition-transform duration-150 group-data-[state=open]/section:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r&&t.jsx("span",{className:"flex-shrink-0 font-medium",children:r}),r&&t.jsx("span",{className:"flex-shrink-0 text-[10px] text-muted-foreground/40",children:"/"}),t.jsx("span",{className:"flex-1 truncate text-left",children:e}),n&&t.jsx("span",{className:"ml-auto flex-shrink-0",children:n}),a&&t.jsx("span",{className:"ml-1 flex-shrink-0",children:a})]}),t.jsx(Ft,{children:t.jsx("div",{className:"mt-1.5 pl-[18px]",children:i})})]}),_l=({oldContent:e,newContent:r,filePath:s,createDiff:a,onFileClick:n,badge:l="Diff",badgeColor:i="gray"})=>{const c=i==="green"?"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400":"bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400",d=o.useMemo(()=>e===void 0||r===void 0?[]:a(e,r),[a,e,r]);return t.jsxs("div",{className:"overflow-hidden rounded border border-gray-200/60 dark:border-gray-700/50",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200/60 bg-gray-50/80 px-2.5 py-1 dark:border-gray-700/50 dark:bg-gray-800/40",children:[n?t.jsx("button",{onClick:n,className:"cursor-pointer truncate font-mono text-[11px] text-blue-600 transition-colors hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:s}):t.jsx("span",{className:"truncate font-mono text-[11px] text-gray-600 dark:text-gray-400",children:s}),t.jsx("span",{className:`rounded px-1.5 py-px text-[10px] font-medium ${c} ml-2 flex-shrink-0`,children:l})]}),t.jsx("div",{className:"font-mono text-[11px] leading-[18px]",children:d.map((u,x)=>t.jsxs("div",{className:"flex",children:[t.jsx("span",{className:`w-6 flex-shrink-0 select-none text-center ${u.type==="removed"?"bg-red-50 text-red-400 dark:bg-red-950/30 dark:text-red-500":"bg-green-50 text-green-400 dark:bg-green-950/30 dark:text-green-500"}`,children:u.type==="removed"?"-":"+"}),t.jsx("span",{className:`flex-1 whitespace-pre-wrap px-2 ${u.type==="removed"?"bg-red-50/50 text-red-800 dark:bg-red-950/20 dark:text-red-200":"bg-green-50/50 text-green-800 dark:bg-green-950/20 dark:text-green-200"}`,children:u.content})]},x))})]})},Dl={running:{label:"Running",className:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"},completed:{label:"Completed",className:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300"},error:{label:"Error",className:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300"},denied:{label:"Denied",className:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-300"}};function Mt({status:e,className:r}){const s=Dl[e];return t.jsx("span",{className:Ae("inline-flex items-center rounded px-1.5 py-px text-[10px] font-medium",s.className,r),children:s.label})}const Fl=({toolName:e,icon:r,label:s,value:a,secondary:n,action:l="none",onAction:i,style:c,wrapText:d=!1,colorScheme:u={primary:"text-foreground",secondary:"text-muted-foreground",background:"",border:"border-border",icon:"text-muted-foreground"},toolResult:x,toolId:v,status:g})=>{const[b,N]=o.useState(!1),k=c==="terminal",E=async()=>{if(l==="copy"&&a){if(!await Vt(a))return;N(!0),setTimeout(()=>N(!1),2e3)}else i&&i()},w=()=>t.jsx("button",{onClick:E,className:"ml-1 flex-shrink-0 text-muted-foreground/40 opacity-0 transition-all hover:text-muted-foreground group-hover:opacity-100",title:"Copy to clipboard","aria-label":"Copy to clipboard",children:b?t.jsx("svg",{className:"h-3 w-3 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})});if(k)return t.jsxs("div",{className:"group my-1",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("div",{className:"flex flex-shrink-0 items-center gap-1.5 pt-0.5",children:t.jsx("svg",{className:"h-3 w-3 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2",children:[t.jsx("div",{className:"min-w-0 flex-1 rounded bg-gray-900 px-2.5 py-1 dark:bg-black",children:t.jsxs("code",{className:`font-mono text-xs text-green-400 ${d?"whitespace-pre-wrap break-all":"block truncate"}`,children:[t.jsx("span",{className:"select-none text-green-600 dark:text-green-500",children:"$ "}),a]})}),g&&t.jsx(Mt,{status:g,className:"mt-0.5"}),l==="copy"&&w()]})]}),n&&t.jsx("div",{className:"ml-7 mt-1",children:t.jsx("span",{className:"text-[11px] italic text-muted-foreground/60",children:n})})]});if(l==="open-file"){const L=a.split("/").pop()||a;return t.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${u.border} my-0.5 py-0.5 pl-3`,children:[t.jsx("span",{className:"flex-shrink-0 text-xs text-muted-foreground",children:s||e}),t.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"/"}),t.jsx("button",{onClick:E,className:"truncate font-mono text-xs text-primary transition-colors hover:text-primary/80 hover:underline",title:a,children:L}),g&&t.jsx(Mt,{status:g,className:"ml-auto"})]})}return l==="jump-to-results"?t.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${u.border} my-0.5 py-0.5 pl-3`,children:[t.jsx("span",{className:"flex-shrink-0 text-xs text-muted-foreground",children:s||e}),t.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"/"}),t.jsx("span",{className:`min-w-0 flex-1 truncate font-mono text-xs ${u.primary}`,children:a}),n&&t.jsx("span",{className:"flex-shrink-0 text-[11px] italic text-muted-foreground/60",children:n}),g&&t.jsx(Mt,{status:g}),x&&t.jsx("a",{href:`#tool-result-${v}`,className:"flex flex-shrink-0 items-center gap-0.5 text-[11px] text-primary transition-colors hover:text-primary/80",children:t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}):t.jsxs("div",{className:`group flex items-center gap-1.5 ${u.background||""} border-l-2 ${u.border} my-0.5 py-0.5 pl-3`,children:[r&&r!=="terminal"&&t.jsx("span",{className:`${u.icon} flex-shrink-0 text-xs`,children:r}),!r&&(s||e)&&t.jsx("span",{className:"flex-shrink-0 text-xs text-muted-foreground",children:s||e}),(r||s||e)&&t.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"/"}),t.jsx("span",{className:`font-mono text-xs ${d?"whitespace-pre-wrap break-all":"truncate"} min-w-0 flex-1 ${u.primary}`,children:a}),n&&t.jsx("span",{className:`text-[11px] ${u.secondary} flex-shrink-0 italic`,children:n}),g&&t.jsx(Mt,{status:g}),l==="copy"&&w()]})},Ul=({command:e,description:r,output:s,isError:a=!1,status:n,defaultOpen:l=!1})=>{const i=(s||"").replace(/\s+$/,""),c=i.length>0,d=c?i.split(`
16
- `).length:0,u=n==="running",[x,v]=o.useState(!1),[g,b]=o.useState(!1),N=o.useRef(!1);o.useEffect(()=>{!N.current&&c&&l&&(N.current=!0,v(!0))},[c,l]);const k=()=>{c&&v(w=>!w)},E=async w=>{w.stopPropagation(),await Vt(e)&&(b(!0),setTimeout(()=>b(!1),2e3))};return t.jsxs("div",{className:Ae("group/cmd overflow-hidden rounded-lg border bg-muted/40 backdrop-blur-sm transition-all duration-200",a?"border-red-500/30":"border-border/60",c&&!x&&"hover:border-border hover:bg-muted/60",x&&"bg-muted/50 shadow-sm"),children:[t.jsxs("div",{role:c?"button":void 0,tabIndex:c?0:void 0,"aria-expanded":c?x:void 0,onClick:k,onKeyDown:w=>{c&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),k())},className:Ae("flex items-center gap-2 px-2.5 py-1.5 outline-none",c&&"cursor-pointer focus-visible:ring-1 focus-visible:ring-ring"),children:[t.jsx(It,{className:Ae("h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/70 transition-transform duration-200",x&&"rotate-90",!c&&"opacity-0")}),t.jsx("span",{className:"flex-shrink-0 select-none font-mono text-xs font-semibold text-emerald-500 dark:text-emerald-400",children:"$"}),t.jsx("span",{className:Ae("min-w-0 flex-1 font-mono text-xs text-foreground",x?"whitespace-pre-wrap break-all":"truncate"),children:e}),u&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 animate-spin rounded-full border-[1.5px] border-muted-foreground/30 border-t-emerald-400"}),n&&n!=="running"&&t.jsx(Mt,{status:n,className:"flex-shrink-0"}),!x&&c&&!u&&t.jsxs("span",{className:"flex-shrink-0 text-[10px] tabular-nums text-muted-foreground/70 transition-opacity group-hover/cmd:opacity-0",children:[d," ",d===1?"line":"lines"]}),t.jsx("button",{onClick:E,onKeyDown:w=>w.stopPropagation(),className:"flex-shrink-0 rounded p-0.5 text-muted-foreground/60 opacity-0 transition-all hover:bg-foreground/10 hover:text-foreground focus:opacity-100 group-hover/cmd:opacity-100",title:"Copy command","aria-label":"Copy command",children:g?t.jsx(Ut,{className:"h-3.5 w-3.5 text-emerald-500"}):t.jsx(Us,{className:"h-3.5 w-3.5"})})]}),r&&!x&&t.jsx("div",{className:"truncate px-2.5 pb-1.5 pl-[2.4rem] text-[11px] italic text-muted-foreground/70",children:r}),x&&c&&t.jsxs("div",{className:"settings-content-enter border-t border-border/50 bg-background/50",children:[r&&t.jsx("div",{className:"px-3 pt-2 text-[11px] italic text-muted-foreground/70",children:r}),t.jsx("pre",{className:Ae("max-h-80 overflow-auto whitespace-pre-wrap break-all px-3 py-2 font-mono text-xs leading-relaxed",a?"text-red-600 dark:text-red-400":"text-muted-foreground"),children:i})]})]})},Bl={bash:$o,cpp:Io,csharp:Eo,css:To,diff:Mo,go:So,java:Co,javascript:No,json:jo,jsx:vo,markdown:wo,markup:ko,powershell:yo,python:bo,rust:go,sql:ho,tsx:xo,typescript:fo,yaml:po};Object.entries(Bl).forEach(([e,r])=>{ct.registerLanguage(e,r)});ct.alias("bash",["shell","sh"]);ct.alias("javascript","js");ct.alias("markup",["html","xml"]);ct.alias("powershell","ps1");ct.alias("python","py");ct.alias("typescript","ts");ct.alias("yaml","yml");let vs=null;const ql=()=>(vs??=Ps(()=>import("./mermaid.core-BsWqrIaW.js").then(e=>e.bo),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>e.default),vs);function Vl({code:e}){const{isDarkMode:r}=Os(),s=o.useId(),[a,n]=o.useState(null);return o.useEffect(()=>{let l=!1;const i=`mermaid-${s.replace(/[^a-zA-Z0-9]/g,"")}`;return ql().then(c=>(c.initialize({startOnLoad:!1,securityLevel:"strict",theme:r?"dark":"default",suppressErrorRendering:!0}),c.render(i,e.trim()))).then(c=>{l||n(c.svg)}).catch(()=>{l||n(null),document.getElementById(`d${i}`)?.remove()}),()=>{l=!0}},[e,r,s]),a?t.jsx("div",{className:"my-3 flex justify-center overflow-x-auto rounded-xl border border-border bg-white p-4 dark:bg-zinc-900 [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:a}}):t.jsx("pre",{className:"my-3 overflow-x-auto rounded-xl border border-border bg-muted/50 p-4 font-mono text-[0.8125rem] leading-relaxed text-muted-foreground dark:bg-zinc-900",children:e.trim()})}const Hl=e=>!!e&&(/^(https?:|mailto:|tel:|data:)/i.test(e)||e.startsWith("#")),yn=e=>e.replace(/:\d+(?::\d+)?$/,""),js=e=>{if(!e)return!1;const r=yn(e.trim());return!r||r==="#"?!1:/[\\/]/.test(r)||/\.[a-z0-9]+$/i.test(r)},Ir=e=>typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ir).join(""):er.isValidElement(e)?Ir(e.props.children):"",br=({node:e,className:r,children:s,forceBlock:a,...n})=>{const{t:l}=We("chat"),{isDarkMode:i}=Os(),[c,d]=o.useState(!1),u=(Array.isArray(s)?s.join(""):String(s??"")).replace(/\n$/,"");if(!a&&!/[\r\n]/.test(u))return t.jsx("code",{className:`whitespace-pre-wrap break-words rounded-md border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[0.875em] text-foreground ${r||""}`,...n,children:s});const v=/language-(\w+)/.exec(r||""),g=v?v[1]:"text",b=g.charAt(0).toUpperCase()+g.slice(1);return g==="mermaid"?t.jsx(Vl,{code:u}):t.jsxs("div",{className:"group my-3 overflow-hidden rounded-xl border border-border bg-muted/50 shadow-sm dark:bg-zinc-900",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 pt-2",children:[t.jsx("span",{className:"select-none text-xs text-muted-foreground",children:b}),t.jsx("button",{type:"button",onClick:()=>Vt(u).then(N=>{N&&(d(!0),setTimeout(()=>d(!1),2e3))}),className:`rounded-md p-1 transition-opacity focus-visible:opacity-100 ${c?"text-green-600 opacity-100 dark:text-green-500":"text-muted-foreground opacity-0 hover:text-foreground group-hover:opacity-100"}`,title:l(c?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":l(c?"codeBlock.copied":"codeBlock.copyCode"),children:c?t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):t.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),t.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})]}),t.jsx(ct,{language:g,style:i?Oo:Po,customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:1.6,padding:"0.5rem 1rem 1rem",background:"transparent"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',background:"transparent"}},children:u})]})},zl={code:br,pre:({children:e})=>{const r=Array.isArray(e)?e.find(er.isValidElement):e;return er.isValidElement(r)&&r.type===br?t.jsx(br,{...r.props,forceBlock:!0}):t.jsx(t.Fragment,{children:e})},blockquote:({children:e})=>t.jsx("blockquote",{className:"my-3 border-l-2 border-primary/50 pl-4 italic text-muted-foreground",children:e}),hr:()=>t.jsx("hr",{className:"my-4 border-t border-border"}),p:({children:e})=>t.jsx("div",{className:"mb-2 last:mb-0",children:e}),ul:({children:e})=>t.jsx("ul",{className:"mb-2 list-outside list-disc space-y-1 pl-5 marker:text-current last:mb-0",children:e}),ol:({children:e})=>t.jsx("ol",{className:"mb-2 list-outside list-decimal space-y-1 pl-5 marker:text-current last:mb-0",children:e}),li:({children:e})=>t.jsx("li",{className:"[&>div:last-child]:mb-0 [&>div]:mb-1",children:e}),table:({children:e})=>t.jsx("div",{className:"my-3 overflow-x-auto rounded-lg border border-border",children:t.jsx("table",{className:"my-0 min-w-full border-collapse text-sm",children:e})}),thead:({children:e})=>t.jsx("thead",{className:"bg-muted/60",children:e}),tr:({children:e})=>t.jsx("tr",{className:"[&:last-child>td]:border-b-0",children:e}),th:({children:e})=>t.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-semibold text-foreground",children:e}),td:({children:e})=>t.jsx("td",{className:"border-b border-border/60 px-3 py-2 align-top",children:e})};function Tt({children:e,className:r,breaks:s=!1}){const a=Qo(String(e??"")),n=o.useMemo(()=>s?[Gr,[Jr,{singleDollarTextMath:!1}],Lo]:[Gr,[Jr,{singleDollarTextMath:!1}]],[s]),l=o.useMemo(()=>[Ro],[]),{openFileInEditor:i}=Yn(),c=o.useMemo(()=>({...zl,a:({href:d,children:u})=>{const x=Ir(u),v=js(d)?d:js(x)?x:void 0;return v&&!Hl(d)?t.jsx("a",{href:d||v,className:"cursor-pointer text-blue-600 hover:underline dark:text-blue-400",onClick:g=>{g.preventDefault(),i(yn(v))},children:u}):t.jsx("a",{href:d,className:"text-blue-600 hover:underline dark:text-blue-400",target:"_blank",rel:"noopener noreferrer",children:u})}}),[i]);return t.jsx("div",{className:r,children:t.jsx(Ao,{remarkPlugins:n,rehypePlugins:l,components:c,children:a})})}const Wl=({content:e,label:r})=>{const s=e.trim(),a=s.length>0,[n,l]=o.useState(!1),i=()=>{a&&l(c=>!c)};return t.jsxs("div",{className:Ae("mt-2 overflow-hidden rounded-lg border border-red-500/30 bg-red-50/50 transition-all duration-200 dark:bg-red-950/10",n&&"shadow-sm"),children:[t.jsxs("div",{role:a?"button":void 0,tabIndex:a?0:void 0,"aria-expanded":a?n:void 0,onClick:i,onKeyDown:c=>{a&&(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i())},className:Ae("flex items-center gap-2 px-2.5 py-1.5 outline-none",a&&"cursor-pointer focus-visible:ring-1 focus-visible:ring-ring"),children:[t.jsx(It,{className:Ae("h-3.5 w-3.5 flex-shrink-0 text-red-500/70 transition-transform duration-200 dark:text-red-400/70",n&&"rotate-90",!a&&"opacity-0")}),t.jsx("svg",{className:"h-3.5 w-3.5 flex-shrink-0 text-red-500 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),t.jsx("span",{className:"flex-shrink-0 text-xs font-medium text-red-700 dark:text-red-300",children:r}),!n&&a&&t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-red-900/70 dark:text-red-100/70",children:s})]}),n&&a&&t.jsx("div",{className:"settings-content-enter border-t border-red-500/20 px-3 py-2 text-sm text-red-900 dark:text-red-100",children:t.jsx(Tt,{className:"prose prose-sm prose-red max-w-none font-serif dark:prose-invert",children:s})})]})},Ns={edit:"border-l-amber-500 dark:border-l-amber-400",search:"border-l-muted-foreground/40",bash:"border-l-green-500 dark:border-l-green-400",todo:"border-l-violet-500 dark:border-l-violet-400",task:"border-l-violet-500 dark:border-l-violet-400",agent:"border-l-purple-500 dark:border-l-purple-400",plan:"border-l-indigo-500 dark:border-l-indigo-400",question:"border-l-blue-500 dark:border-l-blue-400",default:"border-l-border"},Kl=({toolName:e,title:r,defaultOpen:s=!1,action:a,badge:n,onTitleClick:l,children:i,showRawParameters:c=!1,rawContent:d,className:u="",toolCategory:x})=>{const v=Ns[x||"default"]||Ns.default;return t.jsx("div",{className:`border-l-2 ${v} my-1 py-0.5 pl-3 ${u}`,children:t.jsxs(bn,{title:r,toolName:e,open:s,action:a,badge:n,onTitleClick:l,children:[i,c&&d&&t.jsxs(Dt,{className:"mt-2",children:[t.jsxs(Et,{className:"flex items-center gap-1.5 py-0.5 text-[11px] text-muted-foreground hover:text-foreground",children:[t.jsx("svg",{className:"h-2.5 w-2.5 flex-shrink-0 transition-transform duration-150 data-[state=open]:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"raw params"]}),t.jsx(Ft,{children:t.jsx("pre",{className:"mt-1 overflow-hidden whitespace-pre-wrap break-words rounded border border-border/40 bg-muted p-2 font-mono text-[11px] text-muted-foreground",children:d})})]})]})})},Jt=(e,r)=>{const s=typeof r=="string"?(()=>{try{return JSON.parse(r)}catch{return{}}})():r||{};switch(e){case"Read":case"Write":case"Edit":case"ApplyPatch":return s.file_path?.split("/").pop()||s.file_path||"";case"Grep":case"Glob":return s.pattern||"";case"Bash":const a=s.command||"";return a.length>40?`${a.slice(0,40)}...`:a;case"Task":return s.description||s.subagent_type||"";case"WebFetch":case"WebSearch":return s.url||s.query||"";default:return""}},Gl=({toolInput:e,toolResult:r,subagentState:s})=>{const a=typeof e=="string"?(()=>{try{return JSON.parse(e)}catch{return{}}})():e||{},n=a?.subagent_type||"Agent",l=a?.description||"Running task",i=a?.prompt||"",{childTools:c,currentToolIndex:d,isComplete:u}=s,x=d>=0?c[d]:null,v=`Subagent / ${n}: ${l}`;return t.jsx("div",{className:"my-1 border-l-2 border-l-purple-500 py-0.5 pl-3 dark:border-l-purple-400",children:t.jsxs(bn,{title:v,toolName:"Task",open:!1,children:[i&&t.jsx("div",{className:"mb-2 line-clamp-4 whitespace-pre-wrap break-words text-xs text-muted-foreground",children:i}),x&&!u&&t.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 animate-pulse rounded-full bg-purple-500 dark:bg-purple-400"}),t.jsx("span",{className:"text-muted-foreground/60",children:"Currently:"}),t.jsx("span",{className:"font-medium text-foreground",children:x.toolName}),Jt(x.toolName,x.toolInput)&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-muted-foreground/40",children:"/"}),t.jsx("span",{className:"truncate font-mono text-muted-foreground",children:Jt(x.toolName,x.toolInput)})]})]}),u&&t.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[t.jsx("svg",{className:"h-3 w-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),t.jsxs("span",{children:["Completed (",c.length," ",c.length===1?"tool":"tools",")"]})]}),c.length>0&&t.jsxs(Dt,{className:"mt-2",children:[t.jsxs(Et,{className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[t.jsx("svg",{className:"h-2.5 w-2.5 flex-shrink-0 transition-transform duration-150 data-[state=open]:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),t.jsxs("span",{children:["View tool history (",c.length,")"]})]}),t.jsx(Ft,{children:t.jsx("div",{className:"mt-1 space-y-0.5 border-l border-border pl-3",children:c.map((g,b)=>t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[t.jsxs("span",{className:"w-4 flex-shrink-0 text-right text-muted-foreground/60",children:[b+1,"."]}),t.jsx("span",{className:"font-medium text-foreground",children:g.toolName}),Jt(g.toolName,g.toolInput)&&t.jsx("span",{className:"truncate font-mono text-muted-foreground/70",children:Jt(g.toolName,g.toolInput)}),g.toolResult?.isError&&t.jsx("span",{className:"flex-shrink-0 text-red-500",children:"(error)"})]},g.toolId))})})]}),u&&r&&t.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:(()=>{let g=r.content;if(typeof g=="string")try{const b=JSON.parse(g);if(Array.isArray(b)){const N=b.filter(k=>k.type==="text"&&k.text).map(k=>k.text);N.length>0&&(g=N.join(`
16
+ `).length:0,u=n==="running",[x,v]=o.useState(!1),[g,b]=o.useState(!1),N=o.useRef(!1);o.useEffect(()=>{!N.current&&c&&l&&(N.current=!0,v(!0))},[c,l]);const k=()=>{c&&v(w=>!w)},E=async w=>{w.stopPropagation(),await Vt(e)&&(b(!0),setTimeout(()=>b(!1),2e3))};return t.jsxs("div",{className:Ae("group/cmd overflow-hidden rounded-lg border bg-muted/40 backdrop-blur-sm transition-all duration-200",a?"border-red-500/30":"border-border/60",c&&!x&&"hover:border-border hover:bg-muted/60",x&&"bg-muted/50 shadow-sm"),children:[t.jsxs("div",{role:c?"button":void 0,tabIndex:c?0:void 0,"aria-expanded":c?x:void 0,onClick:k,onKeyDown:w=>{c&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),k())},className:Ae("flex items-center gap-2 px-2.5 py-1.5 outline-none",c&&"cursor-pointer focus-visible:ring-1 focus-visible:ring-ring"),children:[t.jsx(It,{className:Ae("h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/70 transition-transform duration-200",x&&"rotate-90",!c&&"opacity-0")}),t.jsx("span",{className:"flex-shrink-0 select-none font-mono text-xs font-semibold text-emerald-500 dark:text-emerald-400",children:"$"}),t.jsx("span",{className:Ae("min-w-0 flex-1 font-mono text-xs text-foreground",x?"whitespace-pre-wrap break-all":"truncate"),children:e}),u&&t.jsx("span",{className:"h-2.5 w-2.5 flex-shrink-0 animate-spin rounded-full border-[1.5px] border-muted-foreground/30 border-t-emerald-400"}),n&&n!=="running"&&t.jsx(Mt,{status:n,className:"flex-shrink-0"}),!x&&c&&!u&&t.jsxs("span",{className:"flex-shrink-0 text-[10px] tabular-nums text-muted-foreground/70 transition-opacity group-hover/cmd:opacity-0",children:[d," ",d===1?"line":"lines"]}),t.jsx("button",{onClick:E,onKeyDown:w=>w.stopPropagation(),className:"flex-shrink-0 rounded p-0.5 text-muted-foreground/60 opacity-0 transition-all hover:bg-foreground/10 hover:text-foreground focus:opacity-100 group-hover/cmd:opacity-100",title:"Copy command","aria-label":"Copy command",children:g?t.jsx(Ut,{className:"h-3.5 w-3.5 text-emerald-500"}):t.jsx(Us,{className:"h-3.5 w-3.5"})})]}),r&&!x&&t.jsx("div",{className:"truncate px-2.5 pb-1.5 pl-[2.4rem] text-[11px] italic text-muted-foreground/70",children:r}),x&&c&&t.jsxs("div",{className:"settings-content-enter border-t border-border/50 bg-background/50",children:[r&&t.jsx("div",{className:"px-3 pt-2 text-[11px] italic text-muted-foreground/70",children:r}),t.jsx("pre",{className:Ae("max-h-80 overflow-auto whitespace-pre-wrap break-all px-3 py-2 font-mono text-xs leading-relaxed",a?"text-red-600 dark:text-red-400":"text-muted-foreground"),children:i})]})]})},Bl={bash:$o,cpp:Io,csharp:Eo,css:To,diff:Mo,go:So,java:Co,javascript:No,json:jo,jsx:vo,markdown:wo,markup:ko,powershell:yo,python:bo,rust:go,sql:ho,tsx:xo,typescript:fo,yaml:po};Object.entries(Bl).forEach(([e,r])=>{ct.registerLanguage(e,r)});ct.alias("bash",["shell","sh"]);ct.alias("javascript","js");ct.alias("markup",["html","xml"]);ct.alias("powershell","ps1");ct.alias("python","py");ct.alias("typescript","ts");ct.alias("yaml","yml");let vs=null;const ql=()=>(vs??=Ps(()=>import("./mermaid.core-cq_VDJvZ.js").then(e=>e.bo),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>e.default),vs);function Vl({code:e}){const{isDarkMode:r}=Os(),s=o.useId(),[a,n]=o.useState(null);return o.useEffect(()=>{let l=!1;const i=`mermaid-${s.replace(/[^a-zA-Z0-9]/g,"")}`;return ql().then(c=>(c.initialize({startOnLoad:!1,securityLevel:"strict",theme:r?"dark":"default",suppressErrorRendering:!0}),c.render(i,e.trim()))).then(c=>{l||n(c.svg)}).catch(()=>{l||n(null),document.getElementById(`d${i}`)?.remove()}),()=>{l=!0}},[e,r,s]),a?t.jsx("div",{className:"my-3 flex justify-center overflow-x-auto rounded-xl border border-border bg-white p-4 dark:bg-zinc-900 [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:a}}):t.jsx("pre",{className:"my-3 overflow-x-auto rounded-xl border border-border bg-muted/50 p-4 font-mono text-[0.8125rem] leading-relaxed text-muted-foreground dark:bg-zinc-900",children:e.trim()})}const Hl=e=>!!e&&(/^(https?:|mailto:|tel:|data:)/i.test(e)||e.startsWith("#")),yn=e=>e.replace(/:\d+(?::\d+)?$/,""),js=e=>{if(!e)return!1;const r=yn(e.trim());return!r||r==="#"?!1:/[\\/]/.test(r)||/\.[a-z0-9]+$/i.test(r)},Ir=e=>typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ir).join(""):er.isValidElement(e)?Ir(e.props.children):"",br=({node:e,className:r,children:s,forceBlock:a,...n})=>{const{t:l}=We("chat"),{isDarkMode:i}=Os(),[c,d]=o.useState(!1),u=(Array.isArray(s)?s.join(""):String(s??"")).replace(/\n$/,"");if(!a&&!/[\r\n]/.test(u))return t.jsx("code",{className:`whitespace-pre-wrap break-words rounded-md border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[0.875em] text-foreground ${r||""}`,...n,children:s});const v=/language-(\w+)/.exec(r||""),g=v?v[1]:"text",b=g.charAt(0).toUpperCase()+g.slice(1);return g==="mermaid"?t.jsx(Vl,{code:u}):t.jsxs("div",{className:"group my-3 overflow-hidden rounded-xl border border-border bg-muted/50 shadow-sm dark:bg-zinc-900",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 pt-2",children:[t.jsx("span",{className:"select-none text-xs text-muted-foreground",children:b}),t.jsx("button",{type:"button",onClick:()=>Vt(u).then(N=>{N&&(d(!0),setTimeout(()=>d(!1),2e3))}),className:`rounded-md p-1 transition-opacity focus-visible:opacity-100 ${c?"text-green-600 opacity-100 dark:text-green-500":"text-muted-foreground opacity-0 hover:text-foreground group-hover:opacity-100"}`,title:l(c?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":l(c?"codeBlock.copied":"codeBlock.copyCode"),children:c?t.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):t.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),t.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})]}),t.jsx(ct,{language:g,style:i?Oo:Po,customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:1.6,padding:"0.5rem 1rem 1rem",background:"transparent"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',background:"transparent"}},children:u})]})},zl={code:br,pre:({children:e})=>{const r=Array.isArray(e)?e.find(er.isValidElement):e;return er.isValidElement(r)&&r.type===br?t.jsx(br,{...r.props,forceBlock:!0}):t.jsx(t.Fragment,{children:e})},blockquote:({children:e})=>t.jsx("blockquote",{className:"my-3 border-l-2 border-primary/50 pl-4 italic text-muted-foreground",children:e}),hr:()=>t.jsx("hr",{className:"my-4 border-t border-border"}),p:({children:e})=>t.jsx("div",{className:"mb-2 last:mb-0",children:e}),ul:({children:e})=>t.jsx("ul",{className:"mb-2 list-outside list-disc space-y-1 pl-5 marker:text-current last:mb-0",children:e}),ol:({children:e})=>t.jsx("ol",{className:"mb-2 list-outside list-decimal space-y-1 pl-5 marker:text-current last:mb-0",children:e}),li:({children:e})=>t.jsx("li",{className:"[&>div:last-child]:mb-0 [&>div]:mb-1",children:e}),table:({children:e})=>t.jsx("div",{className:"my-3 overflow-x-auto rounded-lg border border-border",children:t.jsx("table",{className:"my-0 min-w-full border-collapse text-sm",children:e})}),thead:({children:e})=>t.jsx("thead",{className:"bg-muted/60",children:e}),tr:({children:e})=>t.jsx("tr",{className:"[&:last-child>td]:border-b-0",children:e}),th:({children:e})=>t.jsx("th",{className:"border-b border-border px-3 py-2 text-left font-semibold text-foreground",children:e}),td:({children:e})=>t.jsx("td",{className:"border-b border-border/60 px-3 py-2 align-top",children:e})};function Tt({children:e,className:r,breaks:s=!1}){const a=Qo(String(e??"")),n=o.useMemo(()=>s?[Gr,[Jr,{singleDollarTextMath:!1}],Lo]:[Gr,[Jr,{singleDollarTextMath:!1}]],[s]),l=o.useMemo(()=>[Ro],[]),{openFileInEditor:i}=Yn(),c=o.useMemo(()=>({...zl,a:({href:d,children:u})=>{const x=Ir(u),v=js(d)?d:js(x)?x:void 0;return v&&!Hl(d)?t.jsx("a",{href:d||v,className:"cursor-pointer text-blue-600 hover:underline dark:text-blue-400",onClick:g=>{g.preventDefault(),i(yn(v))},children:u}):t.jsx("a",{href:d,className:"text-blue-600 hover:underline dark:text-blue-400",target:"_blank",rel:"noopener noreferrer",children:u})}}),[i]);return t.jsx("div",{className:r,children:t.jsx(Ao,{remarkPlugins:n,rehypePlugins:l,components:c,children:a})})}const Wl=({content:e,label:r})=>{const s=e.trim(),a=s.length>0,[n,l]=o.useState(!1),i=()=>{a&&l(c=>!c)};return t.jsxs("div",{className:Ae("mt-2 overflow-hidden rounded-lg border border-red-500/30 bg-red-50/50 transition-all duration-200 dark:bg-red-950/10",n&&"shadow-sm"),children:[t.jsxs("div",{role:a?"button":void 0,tabIndex:a?0:void 0,"aria-expanded":a?n:void 0,onClick:i,onKeyDown:c=>{a&&(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i())},className:Ae("flex items-center gap-2 px-2.5 py-1.5 outline-none",a&&"cursor-pointer focus-visible:ring-1 focus-visible:ring-ring"),children:[t.jsx(It,{className:Ae("h-3.5 w-3.5 flex-shrink-0 text-red-500/70 transition-transform duration-200 dark:text-red-400/70",n&&"rotate-90",!a&&"opacity-0")}),t.jsx("svg",{className:"h-3.5 w-3.5 flex-shrink-0 text-red-500 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),t.jsx("span",{className:"flex-shrink-0 text-xs font-medium text-red-700 dark:text-red-300",children:r}),!n&&a&&t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-red-900/70 dark:text-red-100/70",children:s})]}),n&&a&&t.jsx("div",{className:"settings-content-enter border-t border-red-500/20 px-3 py-2 text-sm text-red-900 dark:text-red-100",children:t.jsx(Tt,{className:"prose prose-sm prose-red max-w-none font-serif dark:prose-invert",children:s})})]})},Ns={edit:"border-l-amber-500 dark:border-l-amber-400",search:"border-l-muted-foreground/40",bash:"border-l-green-500 dark:border-l-green-400",todo:"border-l-violet-500 dark:border-l-violet-400",task:"border-l-violet-500 dark:border-l-violet-400",agent:"border-l-purple-500 dark:border-l-purple-400",plan:"border-l-indigo-500 dark:border-l-indigo-400",question:"border-l-blue-500 dark:border-l-blue-400",default:"border-l-border"},Kl=({toolName:e,title:r,defaultOpen:s=!1,action:a,badge:n,onTitleClick:l,children:i,showRawParameters:c=!1,rawContent:d,className:u="",toolCategory:x})=>{const v=Ns[x||"default"]||Ns.default;return t.jsx("div",{className:`border-l-2 ${v} my-1 py-0.5 pl-3 ${u}`,children:t.jsxs(bn,{title:r,toolName:e,open:s,action:a,badge:n,onTitleClick:l,children:[i,c&&d&&t.jsxs(Dt,{className:"mt-2",children:[t.jsxs(Et,{className:"flex items-center gap-1.5 py-0.5 text-[11px] text-muted-foreground hover:text-foreground",children:[t.jsx("svg",{className:"h-2.5 w-2.5 flex-shrink-0 transition-transform duration-150 data-[state=open]:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"raw params"]}),t.jsx(Ft,{children:t.jsx("pre",{className:"mt-1 overflow-hidden whitespace-pre-wrap break-words rounded border border-border/40 bg-muted p-2 font-mono text-[11px] text-muted-foreground",children:d})})]})]})})},Jt=(e,r)=>{const s=typeof r=="string"?(()=>{try{return JSON.parse(r)}catch{return{}}})():r||{};switch(e){case"Read":case"Write":case"Edit":case"ApplyPatch":return s.file_path?.split("/").pop()||s.file_path||"";case"Grep":case"Glob":return s.pattern||"";case"Bash":const a=s.command||"";return a.length>40?`${a.slice(0,40)}...`:a;case"Task":return s.description||s.subagent_type||"";case"WebFetch":case"WebSearch":return s.url||s.query||"";default:return""}},Gl=({toolInput:e,toolResult:r,subagentState:s})=>{const a=typeof e=="string"?(()=>{try{return JSON.parse(e)}catch{return{}}})():e||{},n=a?.subagent_type||"Agent",l=a?.description||"Running task",i=a?.prompt||"",{childTools:c,currentToolIndex:d,isComplete:u}=s,x=d>=0?c[d]:null,v=`Subagent / ${n}: ${l}`;return t.jsx("div",{className:"my-1 border-l-2 border-l-purple-500 py-0.5 pl-3 dark:border-l-purple-400",children:t.jsxs(bn,{title:v,toolName:"Task",open:!1,children:[i&&t.jsx("div",{className:"mb-2 line-clamp-4 whitespace-pre-wrap break-words text-xs text-muted-foreground",children:i}),x&&!u&&t.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx("span",{className:"h-1.5 w-1.5 flex-shrink-0 animate-pulse rounded-full bg-purple-500 dark:bg-purple-400"}),t.jsx("span",{className:"text-muted-foreground/60",children:"Currently:"}),t.jsx("span",{className:"font-medium text-foreground",children:x.toolName}),Jt(x.toolName,x.toolInput)&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-muted-foreground/40",children:"/"}),t.jsx("span",{className:"truncate font-mono text-muted-foreground",children:Jt(x.toolName,x.toolInput)})]})]}),u&&t.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[t.jsx("svg",{className:"h-3 w-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),t.jsxs("span",{children:["Completed (",c.length," ",c.length===1?"tool":"tools",")"]})]}),c.length>0&&t.jsxs(Dt,{className:"mt-2",children:[t.jsxs(Et,{className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[t.jsx("svg",{className:"h-2.5 w-2.5 flex-shrink-0 transition-transform duration-150 data-[state=open]:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),t.jsxs("span",{children:["View tool history (",c.length,")"]})]}),t.jsx(Ft,{children:t.jsx("div",{className:"mt-1 space-y-0.5 border-l border-border pl-3",children:c.map((g,b)=>t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[t.jsxs("span",{className:"w-4 flex-shrink-0 text-right text-muted-foreground/60",children:[b+1,"."]}),t.jsx("span",{className:"font-medium text-foreground",children:g.toolName}),Jt(g.toolName,g.toolInput)&&t.jsx("span",{className:"truncate font-mono text-muted-foreground/70",children:Jt(g.toolName,g.toolInput)}),g.toolResult?.isError&&t.jsx("span",{className:"flex-shrink-0 text-red-500",children:"(error)"})]},g.toolId))})})]}),u&&r&&t.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:(()=>{let g=r.content;if(typeof g=="string")try{const b=JSON.parse(g);if(Array.isArray(b)){const N=b.filter(k=>k.type==="text"&&k.text).map(k=>k.text);N.length>0&&(g=N.join(`
17
17
  `))}}catch{}else if(Array.isArray(g)){const b=g.filter(N=>N.type==="text"&&N.text).map(N=>N.text);b.length>0&&(g=b.join(`
18
18
  `))}return typeof g=="string"?t.jsx("div",{className:"line-clamp-6 whitespace-pre-wrap break-words",children:g}):g?t.jsx("pre",{className:"line-clamp-6 whitespace-pre-wrap break-words font-mono text-[11px]",children:JSON.stringify(g,null,2)}):null})()})]})})},kn=({content:e,className:r="mt-1 prose prose-sm max-w-none dark:prose-invert"})=>t.jsx(Tt,{className:r,children:e}),Jl=({files:e,onFileClick:r,title:s})=>t.jsxs("div",{children:[s&&t.jsx("div",{className:"mb-1 text-[11px] text-gray-500 dark:text-gray-400",children:s}),t.jsx("div",{className:"flex max-h-48 flex-wrap gap-x-1 gap-y-0.5 overflow-y-auto",children:e.map((a,n)=>{const l=typeof a=="string"?a:a.path,i=l.split("/").pop()||l,c=typeof a=="string"?()=>r?.(a):a.onClick;return t.jsxs("span",{className:"inline-flex items-center",children:[t.jsx("button",{onClick:c,className:"font-mono text-[11px] text-blue-600 transition-colors hover:text-blue-700 hover:underline dark:text-blue-400 dark:hover:text-blue-300",title:l,children:i}),n<e.length-1&&t.jsx("span",{className:"ml-1 text-[10px] text-gray-300 dark:text-gray-600",children:","})]},n)})})]}),Ql=e=>e==="completed"?"completed":e==="in_progress"?"in_progress":"pending",wn=o.memo(({todos:e,isResult:r=!1})=>{const s=o.useMemo(()=>e.map(a=>({...a,queueStatus:Ql(a.status)})),[e]);return s.length===0?null:t.jsxs("div",{children:[r&&t.jsxs("div",{className:"mb-1.5 text-xs font-medium text-muted-foreground",children:["Todo List (",s.length," ",s.length===1?"item":"items",")"]}),t.jsx(Xn,{children:s.map((a,n)=>t.jsxs(Zn,{status:a.queueStatus,children:[t.jsx(ea,{}),t.jsx(ta,{children:a.content})]},a.id??`${a.content}-${n}`))})]})});wn.displayName="TodoList";const Yl=e=>{if(typeof e!="object"||e===null)return!1;const r=e;return typeof r.content=="string"&&typeof r.status=="string"},Xl=o.memo(({todos:e,isResult:r=!1})=>{const s=o.useMemo(()=>Array.isArray(e)?e.filter(Yl):[],[e]);return s.length===0?null:t.jsx(wn,{todos:s,isResult:r})});function Zl(e){const r=[],s=e.split(`
19
19
  `);for(const a of s){const n=a.match(/#(\d+)\.?\s*(?:\[(\w+)\]\s*)?(.+?)(?:\s*\((?:owner:\s*\w+)?\))?$/);if(n){const[,l,i,c]=n,d=a.match(/blockedBy:\s*\[([^\]]*)\]/);r.push({id:l,subject:c.trim(),status:i||"pending",blockedBy:d?d[1].split(",").map(u=>u.trim()).filter(Boolean):void 0})}}return r}const Cs={completed:{icon:t.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:t.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"})}),textClass:"line-through text-gray-400 dark:text-gray-500",badgeClass:"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300 border-green-200 dark:border-green-800"},in_progress:{icon:t.jsx("svg",{className:"h-3.5 w-3.5 text-blue-500 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),textClass:"text-gray-900 dark:text-gray-100",badgeClass:"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-800"},pending:{icon:t.jsx("svg",{className:"h-3.5 w-3.5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})}),textClass:"text-gray-700 dark:text-gray-300",badgeClass:"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},ei=({content:e})=>{const r=Zl(e);if(r.length===0)return t.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-gray-600 dark:text-gray-400",children:e});const s=r.filter(n=>n.status==="completed").length,a=r.length;return t.jsxs("div",{children:[t.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[t.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[s,"/",a," completed"]}),t.jsx("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:t.jsx("div",{className:"h-full rounded-full bg-green-500 transition-all dark:bg-green-400",style:{width:`${a>0?s/a*100:0}%`}})})]}),t.jsx("div",{className:"space-y-px",children:r.map(n=>{const l=Cs[n.status]||Cs.pending;return t.jsxs("div",{className:"group flex items-center gap-1.5 py-0.5",children:[t.jsx("span",{className:"flex-shrink-0",children:l.icon}),t.jsxs("span",{className:"flex-shrink-0 font-mono text-[11px] text-gray-400 dark:text-gray-500",children:["#",n.id]}),t.jsx("span",{className:`flex-1 truncate text-xs ${l.textClass}`,children:n.subject}),t.jsx("span",{className:`flex-shrink-0 rounded border px-1 py-px text-[10px] ${l.badgeClass}`,children:n.status.replace("_"," ")})]},n.id)})})]})},ti=({content:e,format:r="plain",className:s=""})=>{if(r==="json"){let a=e;try{const n=JSON.parse(e);a=JSON.stringify(n,null,2)}catch(n){console.warn("Failed to parse JSON content:",n)}return t.jsx("pre",{className:`mt-1 overflow-x-auto rounded bg-gray-900 p-2.5 font-mono text-xs text-gray-100 dark:bg-gray-950 ${s}`,children:a})}return r==="code"?t.jsx("pre",{className:`mt-1 overflow-hidden whitespace-pre-wrap break-words rounded border border-gray-200/50 bg-gray-50 p-2 font-mono text-xs text-gray-700 dark:border-gray-700/50 dark:bg-gray-800/50 dark:text-gray-300 ${s}`,children:e}):t.jsx("div",{className:`mt-1 whitespace-pre-wrap text-sm text-gray-700 dark:text-gray-300 ${s}`,children:e})},ri=({questions:e,answers:r,className:s=""})=>{const[a,n]=o.useState(null);if(!Array.isArray(e)||e.length===0)return null;const l=Object.keys(r||{}).length>0,i=e.length;return t.jsxs("div",{className:`space-y-2 ${s}`,children:[e.map((c,d)=>{if(!c||typeof c!="object"||typeof c.question!="string")return null;const u=c,x=r?.[u.question],v=typeof x=="string"?x.split(", "):[],g=!x,b=a===d,N=Array.isArray(u.options)?u.options.filter(k=>k&&typeof k=="object"&&typeof k.label=="string"):[];return t.jsxs("div",{className:"border-gray-150 overflow-hidden rounded-lg border bg-gray-50/50 dark:border-gray-700/50 dark:bg-gray-800/30",children:[t.jsxs("button",{type:"button",onClick:()=>n(b?null:d),className:"flex w-full items-start gap-2.5 px-3 py-2 text-left transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[t.jsx("div",{className:`mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full ${v.length>0?"bg-blue-100 dark:bg-blue-900/40":"bg-gray-100 dark:bg-gray-800"}`,children:v.length>0?t.jsx("svg",{className:"h-2.5 w-2.5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):t.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-gray-300 dark:bg-gray-600"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u.header&&t.jsx("span",{className:"inline-flex items-center rounded border border-blue-100/80 bg-blue-50 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wider text-blue-600 dark:border-blue-800/40 dark:bg-blue-900/30 dark:text-blue-400",children:u.header}),i>1&&t.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500",children:[d+1,"/",i]})]}),t.jsx("div",{className:"mt-0.5 text-xs leading-snug text-gray-600 dark:text-gray-400",children:u.question}),!b&&v.length>0&&t.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:v.map(k=>{const E=!N.some(w=>w.label===k);return t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-blue-50 px-1.5 py-0.5 text-[11px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-300",children:[k,E&&t.jsx("span",{className:"text-[9px] font-normal text-blue-400 dark:text-blue-500",children:"(custom)"})]},k)})}),!b&&g&&l&&t.jsx("span",{className:"mt-1 inline-block text-[10px] italic text-gray-400 dark:text-gray-500",children:"Skipped"})]}),t.jsx("svg",{className:`mt-0.5 h-3.5 w-3.5 flex-shrink-0 text-gray-400 transition-transform duration-200 dark:text-gray-500 ${b?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),b&&t.jsx("div",{className:"border-t border-gray-100 px-3 pb-2.5 pt-0.5 dark:border-gray-700/40",children:t.jsxs("div",{className:"ml-6.5 space-y-1",children:[N.map(k=>{const E=v.includes(k.label);return t.jsxs("div",{className:`flex items-start gap-2 rounded-lg px-2.5 py-1.5 text-[12px] ${E?"border border-blue-200/60 bg-blue-50/80 dark:border-blue-800/40 dark:bg-blue-900/20":"text-gray-400 dark:text-gray-500"}`,children:[t.jsx("div",{className:`mt-0.5 h-3.5 w-3.5 flex-shrink-0 ${u.multiSelect?"rounded-[3px]":"rounded-full"} flex items-center justify-center border-[1.5px] ${E?"border-blue-500 bg-blue-500 dark:border-blue-400 dark:bg-blue-500":"border-gray-300 dark:border-gray-600"}`,children:E&&t.jsx("svg",{className:"h-2 w-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:E?"font-medium text-gray-900 dark:text-gray-100":"",children:k.label}),k.description&&t.jsx("span",{className:`mt-0.5 block text-[11px] ${E?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-600"}`,children:k.description})]})]},k.label)}),v.filter(k=>!N.some(E=>E.label===k)).map(k=>t.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-blue-200/60 bg-blue-50/80 px-2.5 py-1.5 text-[12px] dark:border-blue-800/40 dark:bg-blue-900/20",children:[t.jsx("div",{className:`mt-0.5 h-3.5 w-3.5 flex-shrink-0 ${u.multiSelect?"rounded-[3px]":"rounded-full"} flex items-center justify-center border-[1.5px] border-blue-500 bg-blue-500 dark:border-blue-400 dark:bg-blue-500`,children:t.jsx("svg",{className:"h-2 w-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:k}),t.jsx("span",{className:"ml-1 text-[10px] text-blue-500 dark:text-blue-400",children:"(custom)"})]})]},k)),g&&l&&t.jsx("div",{className:"px-2.5 py-1 text-[11px] italic text-gray-400 dark:text-gray-500",children:"No answer provided"})]})})]},d)}),!l&&i===1&&t.jsx("div",{className:"text-[11px] italic text-gray-400 dark:text-gray-500",children:"Skipped"})]})},si={claude:"Claude",codex:"Codex",cursor:"Cursor",opencode:"OpenCode"};function ni(e){return si[e||"claude"]}function ai(e,r){const s={};return e.forEach(({question:a,values:n})=>{if(n.length===0){r==="codex"&&a.id&&(s[a.id]={answers:[]});return}if(r==="codex"){s[a.id||a.question]={answers:n};return}s[a.question]=n.join(", ")}),s}const oi=({request:e,onDecision:r})=>{const s=e.input,a=o.useMemo(()=>s?.questions||[],[s?.questions]),[n,l]=o.useState(0),[i,c]=o.useState(()=>new Map),[d,u]=o.useState(()=>new Map),[x,v]=o.useState(()=>new Map),[g,b]=o.useState(!1),N=o.useRef(null),k=o.useRef(null);o.useEffect(()=>{requestAnimationFrame(()=>b(!0))},[]),o.useEffect(()=>{x.get(n)||N.current?.focus()},[n,x]),o.useEffect(()=>{x.get(n)&&k.current?.focus()},[x,n]);const E=o.useCallback(($,P,B)=>{c(z=>{const U=new Map(z),ee=new Set(U.get($)||[]);return B?ee.has(P)?ee.delete(P):ee.add(P):(ee.clear(),ee.add(P),v(ie=>{const X=new Map(ie);return X.set($,!1),X})),U.set($,ee),U})},[]),w=o.useCallback(($,P)=>{v(B=>{const z=new Map(B),U=z.get($)||!1;return z.set($,!U),!P&&!U&&c(ee=>{const ie=new Map(ee);return ie.set($,new Set),ie}),z})},[]),L=o.useCallback(($,P)=>{u(B=>{const z=new Map(B);return z.set($,P),z})},[]),f=o.useCallback(()=>{const $=a.map((P,B)=>{const z=Array.from(i.get(B)||[]),U=x.get(B)||!1,ee=(d.get(B)||"").trim();return U&&ee&&z.push(ee),{question:P,values:z}});return ai($,e.provider)},[a,i,x,d,e.provider]),m=o.useCallback(()=>{r(e.requestId,{allow:!0,updatedInput:{...s,answers:f()}})},[r,e.requestId,s,f]),p=o.useCallback(()=>{r(e.requestId,{allow:!0,updatedInput:{...s,answers:{}}})},[r,e.requestId,s]),h=o.useCallback($=>{if($.target instanceof HTMLInputElement)return;const P=a[n];if(!P)return;const B=P.multiSelect||!1,z=P.options.length,U=parseInt($.key);if(!isNaN(U)&&U>=1&&U<=z){$.preventDefault(),E(n,P.options[U-1].label,B);return}if($.key==="0"){$.preventDefault(),w(n,B);return}if($.key==="Enter"){$.preventDefault(),n===a.length-1?m():l(ie=>ie+1);return}if($.key==="Escape"){$.preventDefault(),p();return}},[n,a,E,w,m,p]);if(a.length===0)return null;const y=a.length,I=y===1,T=a[n],j=T.multiSelect||!1,A=i.get(n)||new Set,_=x.get(n)||!1,H=n===y-1,M=n===0,O=A.size>0||_&&(d.get(n)||"").trim().length>0;return t.jsx("div",{ref:N,tabIndex:-1,onKeyDown:h,className:`w-full outline-none transition-all duration-500 ease-out ${g?"translate-y-0 opacity-100":"translate-y-3 opacity-0"}`,children:t.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-gray-200/80 bg-white shadow-lg dark:border-gray-700/50 dark:bg-gray-800/90 dark:shadow-2xl",children:[t.jsx("div",{className:"absolute left-0 right-0 top-0 h-[2px] bg-gradient-to-r from-blue-500 via-cyan-400 to-teal-400"}),t.jsxs("div",{className:"px-4 pb-2 pt-3.5",children:[t.jsxs("div",{className:"mb-1.5 flex items-center gap-2.5",children:[t.jsxs("div",{className:"relative flex-shrink-0",children:[t.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-lg bg-gradient-to-br from-blue-500/10 to-cyan-500/10 dark:from-blue-400/15 dark:to-cyan-400/15",children:t.jsx("svg",{className:"h-3.5 w-3.5 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.75,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827m0 3h.01"})})}),t.jsx("div",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 animate-pulse rounded-full bg-cyan-400 dark:bg-cyan-500"})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsxs("span",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400 dark:text-gray-500",children:[ni(e.provider)," needs your input"]}),T.header&&t.jsx("span",{className:"inline-flex items-center rounded border border-blue-100 bg-blue-50 px-1.5 py-px text-[9px] font-semibold uppercase tracking-wider text-blue-600 dark:border-blue-800/50 dark:bg-blue-900/30 dark:text-blue-400",children:T.header})]}),!I&&t.jsxs("span",{className:"flex-shrink-0 text-[10px] tabular-nums text-gray-400 dark:text-gray-500",children:[n+1,"/",y]})]}),!I&&t.jsx("div",{className:"mb-2 flex items-center gap-1",children:a.map(($,P)=>t.jsx("button",{type:"button",onClick:()=>l(P),className:`h-[3px] rounded-full transition-all duration-300 ${P===n?"w-5 bg-blue-500 dark:bg-blue-400":P<n?"w-2.5 bg-blue-300 dark:bg-blue-600":"w-2.5 bg-gray-200 dark:bg-gray-700"}`},P))}),t.jsx("p",{className:"text-[14px] font-medium leading-snug text-gray-900 dark:text-gray-100",children:T.question}),j&&t.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500",children:"Select all that apply"})]}),t.jsx("div",{className:"scrollbar-thin max-h-48 overflow-y-auto px-4 pb-2",role:j?"group":"radiogroup","aria-label":T.question,children:t.jsxs("div",{className:"space-y-1",children:[T.options.map(($,P)=>{const B=A.has($.label);return t.jsxs("button",{type:"button",onClick:()=>E(n,$.label,j),className:`group flex w-full items-center gap-2.5 rounded-lg border px-3 py-2 text-left transition-all duration-150 ${B?"border-blue-300 bg-blue-50/80 ring-1 ring-blue-200/50 dark:border-blue-600 dark:bg-blue-900/25 dark:ring-blue-700/30":"border-gray-200 hover:border-gray-300 hover:bg-gray-50/60 dark:border-gray-700/60 dark:hover:border-gray-600 dark:hover:bg-gray-700/40"}`,children:[t.jsx("kbd",{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded font-mono text-[10px] transition-all duration-150 ${B?"bg-blue-500 font-semibold text-white dark:bg-blue-500":"border border-gray-200 bg-gray-100 text-gray-400 group-hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-500 dark:group-hover:border-gray-600"}`,children:P+1}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:`text-[13px] leading-tight transition-colors duration-150 ${B?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:$.label}),$.description&&t.jsx("div",{className:`text-[11px] leading-snug transition-colors duration-150 ${B?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-500"}`,children:$.description})]}),B&&t.jsx("svg",{className:"h-4 w-4 flex-shrink-0 text-blue-500 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]},$.label)}),t.jsxs("button",{type:"button",onClick:()=>w(n,j),className:`group flex w-full items-center gap-2.5 rounded-lg border px-3 py-2 text-left transition-all duration-150 ${_?"border-blue-300 bg-blue-50/80 ring-1 ring-blue-200/50 dark:border-blue-600 dark:bg-blue-900/25 dark:ring-blue-700/30":"border-dashed border-gray-200 hover:border-gray-300 hover:bg-gray-50/60 dark:border-gray-700/60 dark:hover:border-gray-600 dark:hover:bg-gray-700/40"}`,children:[t.jsx("kbd",{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded font-mono text-[10px] transition-all duration-150 ${_?"bg-blue-500 font-semibold text-white dark:bg-blue-500":"border border-gray-200 bg-gray-100 text-gray-400 group-hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-500 dark:group-hover:border-gray-600"}`,children:"0"}),t.jsx("span",{className:`text-[13px] leading-tight transition-colors ${_?"font-medium text-gray-900 dark:text-gray-100":"text-gray-500 dark:text-gray-400"}`,children:"Other..."}),_&&t.jsx("svg",{className:"ml-auto h-4 w-4 flex-shrink-0 text-blue-500 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]}),_&&t.jsx("div",{className:"pl-[30px] pr-0.5",children:t.jsxs("div",{className:"relative",children:[t.jsx("input",{ref:k,type:"text",value:d.get(n)||"",onChange:$=>L(n,$.target.value),onKeyDown:$=>{$.key==="Enter"&&($.preventDefault(),H?m():l(P=>P+1)),$.stopPropagation()},placeholder:"Type your answer...",className:"w-full rounded-lg border-0 bg-gray-50 px-3 py-1.5 text-[13px] text-gray-900 outline-none ring-1 ring-gray-200 transition-shadow duration-200 placeholder:text-gray-400 focus:ring-2 focus:ring-blue-400 dark:bg-gray-900/60 dark:text-gray-100 dark:ring-gray-700 dark:placeholder:text-gray-600 dark:focus:ring-blue-500"}),t.jsx("kbd",{className:"absolute right-2 top-1/2 -translate-y-1/2 rounded border border-gray-200 bg-gray-100 px-1 py-0.5 font-mono text-[9px] text-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-600",children:"Enter"})]})})]})}),t.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-gray-100 bg-gray-50/50 px-4 py-2 dark:border-gray-700/50 dark:bg-gray-800/50",children:[t.jsxs("button",{type:"button",onClick:p,className:"text-[11px] text-gray-400 transition-colors hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",children:[I?"Skip":"Skip all",t.jsx("span",{className:"ml-1 text-[9px] text-gray-300 dark:text-gray-600",children:"Esc"})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[!I&&!M&&t.jsxs("button",{type:"button",onClick:()=>l($=>$-1),className:"inline-flex items-center gap-0.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium text-gray-600 transition-all duration-150 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700/60",children:[t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),"Back"]}),H?t.jsxs("button",{type:"button",onClick:m,disabled:!O&&!Object.keys(f()).length,className:"inline-flex items-center gap-1 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 px-3.5 py-1.5 text-[11px] font-semibold text-white shadow-sm transition-all duration-200 hover:shadow-md disabled:cursor-not-allowed disabled:opacity-30 disabled:shadow-none dark:from-blue-500 dark:to-blue-600",children:["Submit",t.jsx("span",{className:"ml-0.5 font-mono text-[9px] opacity-70",children:"Enter"})]}):t.jsxs("button",{type:"button",onClick:()=>l($=>$+1),className:"inline-flex items-center gap-1 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 px-3.5 py-1.5 text-[11px] font-semibold text-white shadow-sm transition-all duration-200 hover:shadow-md dark:from-blue-500 dark:to-blue-600",children:["Next",t.jsx("span",{className:"ml-0.5 font-mono text-[9px] opacity-70",children:"Enter"})]})]})]})]})})},li=({title:e,content:r,defaultOpen:s=!1,isStreaming:a=!1,showRawParameters:n=!1,rawContent:l,toolName:i})=>{const c=Do(),d=c?.pendingPermissionRequests.find(v=>v.toolName==="ExitPlanMode"||v.toolName==="exit_plan_mode"),u=()=>{d&&c&&c.handlePermissionDecision(d.requestId,{allow:!0})},x=()=>{d&&c&&c.handlePermissionDecision(d.requestId,{allow:!1,message:"User asked to revise the plan"})};return t.jsx(Dt,{defaultOpen:s,children:t.jsxs(_s,{className:"my-1 flex flex-col shadow-none",children:[t.jsxs(ra,{className:"flex flex-row items-start justify-between space-y-0 px-4 pb-0 pt-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Rr,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),t.jsx(sa,{className:"text-sm font-semibold",children:a?t.jsx(Nr,{children:e}):e})]}),t.jsxs(Et,{className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:[t.jsx(Sa,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Toggle plan"})]})]}),t.jsx(Ft,{children:t.jsxs(na,{className:"px-4 pb-4 pt-3",children:[r?t.jsx(kn,{content:r,className:"prose prose-sm max-w-none dark:prose-invert"}):a?t.jsx("div",{className:"py-2",children:t.jsx(Nr,{children:"Generating plan..."})}):null,n&&l&&t.jsxs(Dt,{className:"mt-3",children:[t.jsxs(Et,{className:"flex items-center gap-1.5 py-0.5 text-[11px] text-muted-foreground hover:text-foreground",children:[t.jsx("svg",{className:"h-2.5 w-2.5 flex-shrink-0 transition-transform duration-150 data-[state=open]:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"raw params"]}),t.jsx(Ft,{children:t.jsx("pre",{className:"mt-1 overflow-hidden whitespace-pre-wrap break-words rounded border border-border/40 bg-muted p-2 font-mono text-[11px] text-muted-foreground",children:l})})]})]})}),d&&t.jsxs(aa,{className:"justify-end gap-2 border-t border-border/40 px-4 pb-3 pt-3",children:[t.jsx(Qe,{variant:"ghost",size:"sm",onClick:x,className:"text-muted-foreground",children:"Revise"}),t.jsxs(Qe,{size:"sm",onClick:u,children:["Build"," ",t.jsx("kbd",{className:"ml-1 rounded bg-primary-foreground/20 px-1 py-0.5 font-mono text-[10px]",children:"⌘↩"})]})]})]})})};function ii(e){return["Edit","Write","ApplyPatch"].includes(e)?"edit":["Grep","Glob"].includes(e)?"search":e==="Bash"?"bash":["TodoWrite","TodoRead"].includes(e)?"todo":["TaskCreate","TaskUpdate","TaskList","TaskGet"].includes(e)?"task":e==="Task"?"agent":e==="exit_plan_mode"||e==="ExitPlanMode"?"plan":e==="AskUserQuestion"?"question":"default"}const ci=["user denied tool use","tool disallowed by settings","permission request timed out","permission request cancelled"];function di(e){if(!e)return"running";if(e.isError){const r=String(e.content||"").toLowerCase().trim();return ci.some(s=>r.includes(s))?"denied":"error"}return"completed"}const $r=o.memo(({toolName:e,toolInput:r,toolResult:s,toolId:a,mode:n,onFileOpen:l,createDiff:i,selectedProject:c,showRawParameters:d=!1,rawToolInput:u,isSubagentContainer:x,subagentState:v})=>{const g=ir(e),b=n==="input"?g.input:g.result,N=o.useMemo(()=>{try{const w=n==="input"?r:s;return typeof w=="string"?JSON.parse(w):w}catch{return n==="input"?r:s}},[n,r,s]),k=o.useMemo(()=>n==="input"?di(s):void 0,[n,s]),E=o.useCallback(()=>{if(b?.action==="open-file"&&l){const w=b.getValue?.(N)||"";l(w)}},[b,N,l]);if(x&&v)return n==="result"?null:t.jsx(Gl,{toolInput:r,toolResult:s,subagentState:v});if(!b)return null;if(e==="Bash"&&n==="input"){const w=typeof N=="object"&&N!==null&&"command"in N?String(N.command||""):typeof r=="string"?r:typeof u=="string"?u:"",L=typeof N=="object"&&N!==null&&"description"in N?String(N.description||""):void 0,f=typeof s?.content=="string"?s.content:s?.content!=null?String(s.content):"";return t.jsx(Ul,{command:w,description:L,output:f,isError:!!s?.isError,status:k!=="completed"?k:void 0,defaultOpen:!1})}if(b.type==="one-line"){const w=b.getValue?.(N)||"",L=b.getSecondary?.(N);return t.jsx(Fl,{toolName:e,toolResult:s,toolId:a,icon:b.icon,label:b.label,value:w,secondary:L,action:b.action,onAction:E,style:b.style,wrapText:b.wrapText,colorScheme:b.colorScheme,resultId:n==="input"?`tool-result-${a}`:void 0,status:k!=="completed"?k:void 0})}if(b.type==="plan"){const w=typeof b.title=="function"?b.title(N):b.title||"Plan",L=b.getContentProps?.(N,{selectedProject:c,createDiff:i,onFileOpen:l})||{},f=n==="input"&&!s;return t.jsx(li,{title:w,content:L.content||"",defaultOpen:b.defaultOpen??!1,isStreaming:f,showRawParameters:n==="input"&&d,rawContent:u,toolName:e,toolId:a})}if(b.type==="collapsible"){const w=typeof b.title=="function"?b.title(N):b.title||"Details",L=b.defaultOpen!==void 0?b.defaultOpen:!1,f=b.getContentProps?.(N,{selectedProject:c,createDiff:i,onFileOpen:l})||{};let m=null;switch(b.contentType){case"diff":i&&(m=t.jsx(_l,{...f,createDiff:i,onFileClick:()=>l?.(f.filePath)}));break;case"markdown":m=t.jsx(kn,{content:f.content||""});break;case"file-list":m=t.jsx(Jl,{files:f.files||[],onFileClick:l,title:f.title});break;case"todo-list":f.todos?.length>0&&(m=t.jsx(Xl,{todos:f.todos,isResult:f.isResult}));break;case"task":m=t.jsx(ei,{content:f.content||""});break;case"question-answer":m=t.jsx(ri,{questions:f.questions||[],answers:f.answers||{}});break;case"text":m=t.jsx(ti,{content:f.content||"",format:f.format||"plain"});break;case"success-message":{const y=b.getMessage?.(N)||"Success";m=t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[t.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),y]});break}}const p=(e==="Edit"||e==="Write"||e==="ApplyPatch")&&f.filePath&&l?()=>l(f.filePath,{old_string:f.oldContent,new_string:f.newContent}):void 0,h=k&&k!=="completed"?t.jsx(Mt,{status:k}):void 0;return t.jsx(Kl,{toolName:e,toolId:a,title:w,defaultOpen:L,onTitleClick:p,badge:h,showRawParameters:n==="input"&&d,rawContent:u,toolCategory:ii(e),children:m})}return null});$r.displayName="ToolRenderer";function ui(e,r){const[s,a]=o.useState(e.data||null),[n,l]=o.useState(!1);return o.useEffect(()=>{if(e.data){a(e.data),l(!1);return}const i=e.path;if(!i){a(null),l(!0);return}const c=i.split(/[\\/]/).pop()||"",d=[`/api/assets/images/${encodeURIComponent(c)}`,...r?[`/api/file-tree/projects/${r}/files/content?path=${encodeURIComponent(i)}`]:[]];let u=null;const x=new AbortController;return(async()=>{l(!1);for(const g of d)try{const b=await $e(g,{signal:x.signal});if(!b.ok)continue;const N=await b.blob();u=URL.createObjectURL(N),a(u);return}catch(b){if(b instanceof Error&&b.name==="AbortError")return}a(null),l(!0)})(),()=>{x.abort(),u&&URL.revokeObjectURL(u)}},[e.data,e.path,r]),{src:s,failed:n}}function vn({src:e,alt:r,onClose:s}){return o.useEffect(()=>{const a=n=>{n.key==="Escape"&&(n.stopPropagation(),s())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[s]),qt.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:s,role:"dialog","aria-modal":"true","aria-label":r,children:[t.jsx("button",{type:"button",onClick:s,"aria-label":"Close image preview",className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20",children:t.jsx(it,{className:"h-5 w-5"})}),t.jsx("img",{src:e,alt:r,onClick:a=>a.stopPropagation(),className:"max-h-[90vh] max-w-[92vw] rounded-lg object-contain shadow-2xl"})]}),document.body)}function mi({image:e,projectId:r}){const{src:s,failed:a}=ui(e,r),[n,l]=o.useState(!1),i=e.name||"Attached image";return a?t.jsx("div",{className:"flex h-28 w-28 items-center justify-center rounded-xl border border-border/50 bg-muted px-2 text-center text-[10px] text-muted-foreground",children:i}):s?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>l(!0),"aria-label":`Expand ${i}`,className:"block overflow-hidden rounded-xl border border-border/50 shadow-sm focus:outline-none focus:ring-2 focus:ring-primary/60",children:t.jsx("img",{src:s,alt:i,className:"h-28 w-28 cursor-zoom-in object-cover transition-transform duration-200 hover:scale-105"})}),n&&t.jsx(vn,{src:s,alt:i,onClose:()=>l(!1)})]}):t.jsx("div",{className:"h-28 w-28 animate-pulse rounded-xl border border-border/50 bg-muted"})}function pi({images:e,projectId:r}){return!e||e.length===0?null:t.jsx("div",{className:"flex flex-wrap justify-end gap-2",children:e.map((s,a)=>t.jsx(mi,{image:s,projectId:r},s.path||s.name||a))})}const fi=e=>typeof e!="number"?null:e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,xi=e=>{const r=(e.name||e.path||"").toLowerCase();return(e.mimeType||"").startsWith("text/")||/\.(md|txt|pdf|docx?)$/.test(r)?Rr:/\.(zip|rar|7z|tar|gz)$/.test(r)?Ma:/\.(js|jsx|ts|tsx|py|rb|go|rs|java|c|cpp|css|html|json|ya?ml)$/.test(r)?Ta:qs};function hi({file:e}){const[r,s]=o.useState(!1),a=e.name||e.path?.split(/[\\/]/).pop()||"Attached file",n=xi(e),l=fi(e.size),i=async()=>{if(!e.path||r)return;const c=e.path.split(/[\\/]/).pop();if(c){s(!0);try{const d=await $e(`/api/assets/files/${encodeURIComponent(c)}`);if(!d.ok)return;const u=URL.createObjectURL(await d.blob()),x=document.createElement("a");x.href=u,x.download=a,x.click(),window.setTimeout(()=>URL.revokeObjectURL(u),0)}catch(d){console.error(`Failed to download attachment "${a}":`,d)}finally{s(!1)}}};return t.jsxs("button",{type:"button",onClick:()=>{i()},disabled:!e.path||r,className:"group/file flex w-64 max-w-full items-center gap-3 rounded-xl border border-border/50 bg-card px-3 py-2.5 text-left shadow-sm transition-colors hover:bg-accent/60 disabled:cursor-default disabled:hover:bg-card","aria-label":`Download ${a}`,children:[t.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:t.jsx(n,{className:"h-5 w-5","aria-hidden":!0})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:a,children:a}),t.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:l||"File attachment"})]}),t.jsx(Bs,{className:`h-4 w-4 shrink-0 text-muted-foreground transition-colors group-hover/file:text-foreground ${r?"animate-pulse":""}`,"aria-hidden":!0})]})}function gi({files:e}){return e?.length?t.jsx("div",{className:"flex max-w-full flex-wrap justify-end gap-2",children:e.map((r,s)=>t.jsx(hi,{file:r},r.path||r.name||s))}):null}const bi=2e3,yi=e=>{let r=e.replace(/\r\n/g,`
20
20
  `);const s=[];return r=r.replace(/```[\w-]*\n([\s\S]*?)```/g,(a,n)=>{const l=`@@CODEBLOCK${s.length}@@`;return s.push(n.replace(/\n$/,"")),l}),r=r.replace(/`([^`]+)`/g,"$1"),r=r.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,"$1"),r=r.replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1"),r=r.replace(/^>\s?/gm,""),r=r.replace(/^#{1,6}\s+/gm,""),r=r.replace(/^[-*+]\s+/gm,""),r=r.replace(/^\d+\.\s+/gm,""),r=r.replace(/(\*\*|__)(.*?)\1/g,"$2"),r=r.replace(/(\*|_)(.*?)\1/g,"$2"),r=r.replace(/~~(.*?)~~/g,"$1"),r=r.replace(/<\/?[^>]+(>|$)/g,""),r=r.replace(/\n{3,}/g,`
21
21
 
22
22
  `),r=r.replace(/@@CODEBLOCK(\d+)@@/g,(a,n)=>s[Number(n)]??""),r.trim()},yr=({content:e,messageType:r})=>{const{t:s}=We("chat"),a=r==="assistant",n=a?"markdown":"text",[l,i]=o.useState(n),[c,d]=o.useState(!1),[u,x]=o.useState(!1),[v,g]=o.useState({}),b=o.useRef(null),N=o.useRef(null),k=o.useRef(null),E=o.useRef(null),w=()=>{const j=N.current?.getBoundingClientRect();if(j){const _=j.bottom+84+8>window.innerHeight;g({position:"fixed",right:Math.max(8,window.innerWidth-j.right),zIndex:1e3,..._?{bottom:window.innerHeight-j.top+4}:{top:j.bottom+4}})}x(!0)},L=o.useMemo(()=>[{format:"markdown",label:s("copyMessage.copyAsMarkdown",{defaultValue:"Copy as markdown"})},{format:"text",label:s("copyMessage.copyAsText",{defaultValue:"Copy as text"})}],[s]),f=l==="markdown"?s("copyMessage.markdownShort",{defaultValue:"MD"}):s("copyMessage.textShort",{defaultValue:"TXT"}),m=o.useMemo(()=>l==="markdown"?e:yi(e),[e,l]);o.useEffect(()=>{i(n),x(!1)},[n]),o.useEffect(()=>{if(!u)return;const j=_=>{const H=_.target;b.current?.contains(H)||k.current?.contains(H)||x(!1)},A=()=>x(!1);return window.addEventListener("mousedown",j),window.addEventListener("scroll",A,!0),window.addEventListener("resize",A),()=>{window.removeEventListener("mousedown",j),window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A)}},[u]),o.useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]);const p=async()=>{!m.trim()||!await Vt(m)||(d(!0),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{d(!1)},bi))},h=j=>{i(j),x(!1)},y=r==="user"?"text-muted-foreground hover:text-foreground":"text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",I=s(c?"copyMessage.copied":"copyMessage.copy"),T=a?"relative flex min-w-0 flex-1 items-center gap-0.5 sm:min-w-max sm:flex-none sm:w-auto":"relative flex items-center gap-0.5";return t.jsxs("div",{ref:b,className:T,children:[t.jsxs("button",{type:"button",onClick:p,title:I,"aria-label":I,className:`inline-flex items-center gap-1 rounded px-1 py-0.5 transition-colors ${y}`,children:[c?t.jsx("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):t.jsxs("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),t.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide",children:f})]}),a&&t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:N,type:"button",onClick:()=>u?x(!1):w(),className:`rounded px-1 py-0.5 transition-colors ${y}`,"aria-label":s("copyMessage.selectFormat",{defaultValue:"Select copy format"}),title:s("copyMessage.selectFormat",{defaultValue:"Select copy format"}),children:t.jsx("svg",{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),u&&qt.createPortal(t.jsx("div",{ref:k,style:v,className:"min-w-36 rounded-md border border-border bg-popover p-1 shadow-lg",children:L.map(j=>{const A=j.format===l;return t.jsx("button",{type:"button",onClick:()=>h(j.format),className:`block w-full rounded px-2 py-1.5 text-left transition-colors ${A?"bg-accent text-foreground":"text-foreground hover:bg-accent"}`,children:t.jsx("span",{className:"block text-xs font-medium",children:j.label})},j.format)})}),document.body)]})]})};function jn(e,r){return`${e.replace(/\/$/,"")}${r}`}function ki(){return JSON.stringify(or())}function wi(e,r){const s=or(),a=new FormData;return s.baseUrl.trim()?(a.append("file",e,r),a.append("model",s.sttModel||"whisper-1"),fetch(jn(s.baseUrl.trim(),"/audio/transcriptions"),{method:"POST",headers:s.apiKey?{Authorization:`Bearer ${s.apiKey}`}:{},body:a})):(a.append("audio",e,r),$e("/api/voice/transcribe",{method:"POST",headers:Ds(),body:a}))}function vi(e,r){const s=or();return s.baseUrl.trim()?fetch(jn(s.baseUrl.trim(),"/audio/speech"),{method:"POST",headers:{"Content-Type":"application/json",...s.apiKey?{Authorization:`Bearer ${s.apiKey}`}:{}},body:JSON.stringify({model:s.ttsModel||"tts-1",voice:s.ttsVoice||"alloy",input:e,...s.ttsFormat.trim()?{response_format:s.ttsFormat.trim()}:{}}),signal:r}):$e("/api/voice/tts",{method:"POST",body:JSON.stringify({text:e}),headers:Ds(),signal:r})}const ji={state:"idle",error:null},Ni=24,Ci=33e4;function Nn(e,r=ki()){const s=JSON.stringify([e,r]);let a=5381;for(let n=0;n<s.length;n++)a=(a<<5)+a+s.charCodeAt(n)|0;return(a>>>0).toString(36)}class Si{audio=null;unlocked=!1;cache=new Map;currentId=null;state="idle";errorId=null;errorMsg=null;token=0;activeController=null;errorTimer=null;listeners=new Set;subscribe(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}emit(){this.listeners.forEach(r=>r())}getSnapshot(r){const s=this.currentId===r?this.state:"idle",a=this.errorId===r?this.errorMsg:null;return s==="idle"&&a===null?ji:{state:s,error:a}}ensureAudio(){if(!this.audio){const r=new Audio;r.addEventListener("ended",()=>this.onEnded()),r.addEventListener("error",()=>{this.state==="playing"&&this.onEnded()}),this.audio=r}return this.audio}unlock(){if(this.unlocked)return;const r=this.ensureAudio();try{const s=r.play();s&&typeof s.catch=="function"&&s.catch(()=>{}),r.pause()}catch{}this.unlocked=!0}toggle(r){const s=Nn(r);if(this.currentId===s&&(this.state==="playing"||this.state==="loading")){this.stop();return}this.play(s,r)}stop(){this.token++,this.abortActive(),this.audio&&this.audio.pause(),this.state="idle",this.currentId=null,this.emit()}abortActive(){this.activeController&&(this.activeController.abort(),this.activeController=null)}onEnded(){this.state="idle",this.currentId=null,this.emit()}setError(r,s){this.state="idle",this.currentId=r,this.errorId=r,this.errorMsg=s,this.emit(),this.errorTimer&&clearTimeout(this.errorTimer),this.errorTimer=setTimeout(()=>{this.errorId===r&&(this.errorId=null,this.errorMsg=null,this.currentId===r&&(this.currentId=null),this.emit())},6e3)}async play(r,s){const a=this.ensureAudio();a.pause(),this.currentId=r,this.errorId=null,this.errorMsg=null,this.state="loading",this.emit();const n=++this.token;this.abortActive();try{let l=this.cache.get(r);if(!l){const i=new AbortController;this.activeController=i;const c=setTimeout(()=>i.abort(),Ci),d=await vi(s,i.signal).finally(()=>{clearTimeout(c),this.activeController===i&&(this.activeController=null)});if(n!==this.token)return;if(!d.ok){let x=`Read-aloud failed (${d.status})`;try{const v=await d.json();v?.error&&(x=String(v.error))}catch{}throw new Error(x)}const u=await d.blob();if(n!==this.token)return;l=URL.createObjectURL(u),this.cacheSet(r,l)}if(n!==this.token||(a.src=l,a.load(),await a.play(),n!==this.token))return;this.state="playing",this.emit()}catch(l){if(n!==this.token)return;const i=l instanceof Error&&l.name==="AbortError";this.setError(r,i?"Read-aloud timed out.":l instanceof Error?l.message:"Read-aloud failed")}}cacheSet(r,s){for(this.cache.set(r,s);this.cache.size>Ni;){const a=this.cache.keys().next().value;if(a===void 0)break;const n=this.cache.get(a);this.cache.delete(a),n&&n!==this.audio?.src&&URL.revokeObjectURL(n)}}}const Pt=new Si;function Mi(e){const r=e(),s=Nn(r),[a,n]=o.useState(()=>Pt.getSnapshot(s));o.useEffect(()=>{const i=()=>n(c=>{const d=Pt.getSnapshot(s);return c.state===d.state&&c.error===d.error?c:d});return i(),Pt.subscribe(i)},[s]);const l=o.useCallback(()=>{Pt.unlock(),Pt.toggle(r)},[r]);return{state:a.state,toggle:l,error:a.error}}const Ti="uiPreferences",Ss="ui-preferences:sync";let Qt=null;function Ei(){if(Qt)return Qt;const e=$e("/api/voice/health").then(async r=>{if(!r.ok)throw new Error(`Voice health check failed (${r.status})`);return(await r.json())?.configured===!0}).finally(()=>{Qt=null});return Qt=e,e}function Ms(){try{const e=localStorage.getItem(Ti);if(!e)return!1;const r=JSON.parse(e);return r?.voiceEnabled===!0||r?.voiceEnabled==="true"}catch{return!1}}function Cn(){const[e,r]=o.useState(()=>typeof window>"u"?!1:Ms()),[s,a]=o.useState(!1);return o.useEffect(()=>{const n=()=>r(Ms());return window.addEventListener("storage",n),window.addEventListener(Ss,n),()=>{window.removeEventListener("storage",n),window.removeEventListener(Ss,n)}},[]),o.useEffect(()=>{let n=!0,l=0;const i=async()=>{if(!e){a(!1);return}if(or().baseUrl.trim()){a(!0);return}const c=++l;try{const d=await Ei();n&&c===l&&a(d)}catch{n&&c===l&&a(!1)}};return i(),window.addEventListener(qr,i),()=>{n=!1,window.removeEventListener(qr,i)}},[e]),e&&s}const Ii=({content:e})=>{const{t:r}=We("chat"),s=Cn(),{state:a,toggle:n,error:l}=Mi(()=>e);if(!s)return null;const i=r(a==="playing"?"voice.stopSpeaking":a==="loading"?"voice.loading":"voice.speak");return t.jsxs("span",{className:"relative inline-flex",children:[l&&t.jsx("span",{className:"absolute bottom-full left-1/2 z-10 mb-1 max-w-[240px] -translate-x-1/2 whitespace-normal rounded bg-red-600 px-2 py-1 text-center text-xs text-white shadow-lg",children:l}),t.jsx("button",{type:"button",onClick:n,title:i,"aria-label":i,className:"inline-flex items-center gap-1 rounded px-1 py-0.5 text-gray-400 transition-colors hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",children:a==="playing"?t.jsx(Vs,{className:"h-3.5 w-3.5"}):a==="loading"?t.jsx($t,{className:"h-3.5 w-3.5 animate-spin"}):t.jsx(Ea,{className:"h-3.5 w-3.5"})})]})},$i=new Set(["Bash","Edit","Write","ApplyPatch"]),Sn=o.memo(({message:e,prevMessage:r,createDiff:s,onFileOpen:a,showRawParameters:n,showThinking:l,selectedProject:i,provider:c})=>{const{t:d}=We("chat"),u=r&&r.type===e.type&&(r.type==="assistant"||r.type==="user"||r.type==="tool"||r.type==="error"),x=o.useRef(null),v=String(e.content||""),g=o.useMemo(()=>{const f=Er(String(e.content||""));return c==="codex"&&e.type==="assistant"&&!e.isThinking?Yo(f):f},[e.content,e.isThinking,e.type,c]),b=e.isToolUse?String(e.displayText||e.content||""):g,N=!!(e.isToolUse&&$i.has(String(e.toolName||""))),k=e.type==="user"&&v.trim().length>0,E=e.type==="assistant"&&b.trim().length>0&&!N&&!e.isThinking,w=o.useMemo(()=>new Date(e.timestamp).toLocaleTimeString(),[e.timestamp]);return e.isThinking&&!l?null:t.jsx("div",{ref:x,"data-message-timestamp":e.timestamp||void 0,className:`chat-message ${e.type} ${u?"grouped":""} ${e.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:e.type==="user"?t.jsxs("div",{className:"flex w-full items-end space-x-0 sm:w-auto sm:max-w-[85%] sm:space-x-3 md:max-w-md lg:max-w-lg xl:max-w-xl",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col items-end gap-2 sm:flex-initial",children:[e.images&&e.images.length>0&&t.jsx(pi,{images:e.images,projectId:i?.projectId}),e.files&&e.files.length>0&&t.jsx(gi,{files:e.files}),v.trim().length>0||!e.images?.length&&!e.files?.length?t.jsxs("div",{className:"group max-w-full rounded-2xl rounded-br-md border border-border/60 bg-muted/60 px-3 py-2 text-foreground shadow-sm dark:bg-gray-800/60 sm:px-4",children:[t.jsx("div",{dir:"auto",className:"break-words font-serif text-sm",children:t.jsx(Tt,{breaks:!0,className:"prose prose-sm max-w-none font-serif dark:prose-invert",children:e.content})}),t.jsxs("div",{className:"mt-1 flex items-center justify-end gap-1 text-xs text-muted-foreground",children:[k&&t.jsx(yr,{content:v,messageType:"user"}),t.jsx("span",{children:w})]})]}):t.jsx("div",{className:"flex items-center justify-end gap-1 text-xs text-muted-foreground",children:t.jsx("span",{children:w})})]}),!u&&t.jsx("div",{className:"hidden h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-blue-600 text-sm text-white sm:flex",children:"U"})]}):e.isTaskNotification?t.jsx("div",{className:"w-full",children:t.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[t.jsx("span",{className:`inline-block h-1.5 w-1.5 flex-shrink-0 rounded-full ${e.taskStatus==="completed"?"bg-green-400 dark:bg-green-500":"bg-amber-400 dark:bg-amber-500"}`}),t.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.content})]})}):t.jsxs("div",{className:"w-full",children:[!u&&t.jsxs("div",{className:"mb-2 flex items-center space-x-3",children:[e.type==="error"?t.jsx("div",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-red-600 text-sm text-white",children:"!"}):e.type==="tool"?t.jsx("div",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-gray-600 text-sm text-white dark:bg-gray-700",children:"🔧"}):t.jsx("div",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full p-1 text-sm text-foreground",children:t.jsx(tr,{provider:c,className:"h-full w-full"})}),t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.type==="error"?d("messageTypes.error"):e.type==="tool"?d("messageTypes.tool"):c==="cursor"?d("messageTypes.cursor"):c==="codex"?d("messageTypes.codex"):c==="opencode"?d("messageTypes.opencode",{defaultValue:"OpenCode"}):d("messageTypes.claude")})]}),t.jsxs("div",{className:"w-full",children:[e.isToolUse?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex flex-col",children:t.jsx("div",{className:"flex flex-col",children:t.jsx(Tt,{className:"prose prose-sm max-w-none font-serif dark:prose-invert",children:String(e.displayText||"")})})}),e.toolInput&&t.jsx($r,{toolName:e.toolName||"UnknownTool",toolInput:e.toolInput,toolResult:e.toolResult,toolId:e.toolId,mode:"input",onFileOpen:a,createDiff:s,selectedProject:i,showRawParameters:n,rawToolInput:typeof e.toolInput=="string"?e.toolInput:void 0,isSubagentContainer:e.isSubagentContainer,subagentState:e.subagentState}),e.toolResult&&e.toolName!=="Bash"&&!Pl(e.toolName||"UnknownTool",e.toolResult)&&(e.toolResult.isError?t.jsx("div",{id:`tool-result-${e.toolId}`,className:"scroll-mt-4",children:t.jsx(Wl,{label:d("messageTypes.error"),content:String(e.toolResult.content||"")})}):t.jsx("div",{id:`tool-result-${e.toolId}`,className:"scroll-mt-4",children:t.jsx($r,{toolName:e.toolName||"UnknownTool",toolInput:e.toolInput,toolResult:e.toolResult,toolId:e.toolId,mode:"result",onFileOpen:a,createDiff:s,selectedProject:i})}))]}):e.isInteractivePrompt?t.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-900/20",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"mt-0.5 flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-amber-500",children:t.jsx("svg",{className:"h-5 w-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h4",{className:"mb-3 text-base font-semibold text-amber-900 dark:text-amber-100",children:d("interactive.title")}),(()=>{const f=(e.content||"").split(`
23
- `).filter(h=>h.trim()),m=f.find(h=>h.includes("?"))||f[0]||"",p=[];return f.forEach(h=>{const y=h.match(/[❯\s]*(\d+)\.\s+(.+)/);if(y){const I=h.includes("❯");p.push({number:y[1],text:y[2].trim(),isSelected:I})}}),t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mb-4 text-sm text-amber-800 dark:text-amber-200",children:m}),t.jsx("div",{className:"mb-4 space-y-2",children:p.map(h=>t.jsx("button",{className:`w-full rounded-lg border-2 px-4 py-3 text-left transition-all ${h.isSelected?"border-amber-600 bg-amber-600 text-white shadow-md dark:border-amber-700 dark:bg-amber-700":"border-amber-300 bg-white text-amber-900 dark:border-amber-700 dark:bg-gray-800 dark:text-amber-100"} cursor-not-allowed opacity-75`,disabled:!0,children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full text-sm font-bold ${h.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:h.number}),t.jsx("span",{className:"flex-1 text-sm font-medium sm:text-base",children:h.text}),h.isSelected&&t.jsx("span",{className:"text-lg",children:"❯"})]})},h.number))}),t.jsxs("div",{className:"rounded-lg bg-amber-100 p-3 dark:bg-amber-800/30",children:[t.jsx("p",{className:"mb-1 text-sm font-medium text-amber-900 dark:text-amber-100",children:d("interactive.waiting")}),t.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-200",children:d("interactive.instruction")})]})]})})()]})]})}):e.isThinking?t.jsxs(Vr,{defaultOpen:!1,children:[t.jsx(Hr,{}),t.jsxs(zr,{children:[t.jsx(Tt,{className:"prose prose-sm prose-gray max-w-none font-serif dark:prose-invert",children:e.content}),t.jsx("div",{className:"mt-3 flex items-center text-[11px]",children:t.jsx(yr,{content:String(e.content||""),messageType:"assistant"})})]})]}):t.jsxs("div",{dir:"auto",className:"text-sm text-gray-700 dark:text-gray-300",children:[l&&e.reasoning&&t.jsxs(Vr,{className:"mb-3",defaultOpen:!1,children:[t.jsx(Hr,{}),t.jsx(zr,{children:t.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const f=g,m=f.trim();if((m.startsWith("{")||m.startsWith("["))&&(m.endsWith("}")||m.endsWith("]")))try{const p=JSON.parse(m),h=JSON.stringify(p,null,2);return t.jsxs("div",{className:"my-2",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),t.jsx("span",{className:"font-medium",children:d("json.response")})]}),t.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-muted",children:t.jsx("pre",{className:"overflow-x-auto p-4",children:t.jsx("code",{className:"block whitespace-pre font-mono text-sm text-foreground",children:h})})})]})}catch{}return e.type==="assistant"?t.jsx(Tt,{className:"prose prose-sm prose-gray max-w-none font-serif dark:prose-invert",children:f}):t.jsx("div",{className:"whitespace-pre-wrap",children:f})})()]}),(E||!u)&&t.jsxs("div",{className:"mt-1 flex w-full items-center gap-2 text-[11px] text-gray-400 dark:text-gray-500",children:[E&&t.jsx(yr,{content:b,messageType:"assistant"}),E&&t.jsx(Ii,{content:b}),!u&&t.jsx("span",{children:w})]})]})]})})}),Li=[{value:"pending",label:"Pending"},{value:"in-progress",label:"In Progress"},{value:"review",label:"Review"},{value:"done",label:"Done"},{value:"deferred",label:"Deferred"},{value:"cancelled",label:"Cancelled"}];function Ri(e){return e==="done"?Hs:e==="in-progress"?Ra:e==="review"?Aa:e==="deferred"?Oa:e==="cancelled"?it:zs}function Ai(e){return e==="high"?"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950":e==="medium"?"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-950":e==="low"?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950":"text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800"}function Oi({task:e,isOpen:r=!0,className:s="",onClose:a,onEdit:n=null,onStatusChange:l=null,onTaskClick:i=null}){const{currentProject:c,refreshTasks:d}=Fs(),[u,x]=o.useState(!1),[v,g]=o.useState(!1),[b,N]=o.useState(!1),[k,E]=o.useState(!1),[w,L]=o.useState(e);o.useEffect(()=>{L(e),x(!1)},[e]);const f=o.useMemo(()=>Ri(e?.status),[e?.status]);if(!r||!e||!w)return null;const m=async()=>{if(!c?.name)return;const h={};if(w.title!==e.title&&(h.title=w.title),w.description!==e.description&&(h.description=w.description??""),w.details!==e.details&&(h.details=w.details??""),Object.keys(h).length===0){x(!1);return}g(!0);try{const y=await jr.taskmaster.updateTask(c.name,e.id,h);if(!y.ok){const I=await y.json();throw new Error(I.message??"Failed to update task")}x(!1),await d(),n?.(w)}catch(y){console.error("Failed to save task changes:",y),alert(y instanceof Error?y.message:"Failed to update task")}finally{g(!1)}},p=async h=>{if(!(!c?.name||h===e.status))try{const y=await jr.taskmaster.updateTask(c.name,e.id,{status:h});if(!y.ok){const I=await y.json();throw new Error(I.message??"Failed to update task status")}await d(),l?.(e.id,h)}catch(y){console.error("Failed to update task status:",y),alert(y instanceof Error?y.message:"Failed to update task status")}};return t.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 md:p-4",children:t.jsxs("div",{className:Ae("w-full md:max-w-4xl h-full md:h-[90vh] bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 md:rounded-lg shadow-xl flex flex-col",s),children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700 md:p-6",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t.jsx(f,{className:"h-6 w-6 text-blue-600 dark:text-blue-400"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("button",{onClick:()=>Vt(String(e.id)),className:"mb-2 inline-flex items-center gap-1 rounded bg-gray-100 px-2 py-1 text-xs text-gray-600 hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700",title:"Copy task ID",children:[t.jsxs("span",{children:["Task ",e.id]}),t.jsx(Us,{className:"h-3 w-3"})]}),u?t.jsx("input",{type:"text",value:w.title,onChange:h=>L({...w,title:h.target.value}),className:"w-full border-b-2 border-blue-500 bg-transparent text-lg font-semibold text-gray-900 focus:outline-none dark:text-white"}):t.jsx("h1",{className:"line-clamp-2 text-lg font-semibold text-gray-900 dark:text-white md:text-xl",children:e.title})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[u?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:m,disabled:v,className:"rounded-md p-2 text-green-600 hover:bg-green-50 disabled:opacity-50 dark:hover:bg-green-950",title:"Save",children:t.jsx(Ia,{className:Ae("w-5 h-5",v&&"animate-spin")})}),t.jsx("button",{onClick:()=>{L(e),x(!1)},disabled:v,className:"rounded-md p-2 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",title:"Cancel editing",children:t.jsx(it,{className:"h-5 w-5"})})]}):t.jsx("button",{onClick:()=>x(!0),className:"rounded-md p-2 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",title:"Edit task",children:t.jsx($a,{className:"h-5 w-5"})}),t.jsx("button",{onClick:a,className:"rounded-md p-2 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",title:"Close",children:t.jsx(it,{className:"h-5 w-5"})})]})]}),t.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4 md:p-6",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"}),t.jsx("select",{value:e.status??"pending",onChange:h=>{p(h.target.value)},className:"w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-gray-900 dark:border-gray-600 dark:bg-gray-800 dark:text-white",children:Li.map(h=>t.jsx("option",{value:h.value,children:h.label},h.value))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Priority"}),t.jsx("div",{className:Ae("px-3 py-2 rounded-md text-sm font-medium capitalize",Ai(e.priority)),children:e.priority??"Not set"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Dependencies"}),Array.isArray(e.dependencies)&&e.dependencies.length>0?t.jsx("div",{className:"flex flex-wrap gap-1",children:e.dependencies.map(h=>t.jsxs("button",{onClick:()=>i?.({id:h}),className:"rounded bg-blue-100 px-2 py-1 text-sm text-blue-700 hover:bg-blue-200 dark:bg-blue-900 dark:text-blue-300 dark:hover:bg-blue-800",children:[t.jsx(La,{className:"mr-1 inline h-3 w-3"}),h]},String(h)))}):t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No dependencies"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Description"}),u?t.jsx("textarea",{rows:4,value:w.description??"",onChange:h=>L({...w,description:h.target.value}),className:"w-full rounded-md border border-gray-300 bg-white px-3 py-2 dark:border-gray-600 dark:bg-gray-800"}):t.jsx("p",{className:"whitespace-pre-wrap text-gray-700 dark:text-gray-300",children:e.description||"No description provided"})]}),e.details&&t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-700",children:[t.jsxs("button",{onClick:()=>N(h=>!h),className:"flex w-full items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Implementation Details"}),b?t.jsx(rr,{className:"h-4 w-4"}):t.jsx(It,{className:"h-4 w-4"})]}),b&&t.jsx("div",{className:"border-t border-gray-200 p-4 dark:border-gray-700",children:t.jsx("p",{className:"whitespace-pre-wrap text-gray-700 dark:text-gray-300",children:e.details})})]}),e.testStrategy&&t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-700",children:[t.jsxs("button",{onClick:()=>E(h=>!h),className:"flex w-full items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Test Strategy"}),k?t.jsx(rr,{className:"h-4 w-4"}):t.jsx(It,{className:"h-4 w-4"})]}),k&&t.jsx("div",{className:"border-t border-gray-200 bg-blue-50 p-4 dark:border-gray-700 dark:bg-blue-950/30",children:t.jsx("p",{className:"whitespace-pre-wrap text-gray-700 dark:text-gray-300",children:e.testStrategy})})]})]})]})})}const Pi=o.lazy(()=>Ps(()=>import("./Shell-CUTO-THd.js").then(e=>e.a),__vite__mapDeps([7,2,1,3,4,5,6,8])));function _i({isOpen:e,project:r,onClose:s,onAfterClose:a=null}){const{t:n}=We("tasks"),[l,i]=o.useState(!1);if(!e||!r)return null;const c=()=>{s(),i(!1),window.setTimeout(()=>{a?.()},800)};return t.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/50 p-4 pt-16 backdrop-blur-sm",children:t.jsxs("div",{className:"flex h-[600px] w-full max-w-4xl flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-blue-100 dark:bg-blue-900/50",children:t.jsx(Ar,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:n("setupModal.title")}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:n("setupModal.subtitle",{projectName:r.displayName})})]})]}),t.jsx("button",{onClick:c,className:"rounded-md p-2 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:"Close",children:t.jsx(Bt,{className:"h-5 w-5 rotate-45"})})]}),t.jsx("div",{className:"flex-1 p-4",children:t.jsx("div",{className:"h-full overflow-hidden rounded-lg bg-black",children:t.jsx(o.Suspense,{fallback:t.jsx("div",{className:"h-full bg-black",role:"status","aria-label":"Loading terminal"}),children:t.jsx(Pi,{selectedProject:r,selectedSession:null,initialCommand:"npx task-master init",isPlainShell:!0,isActive:!0,onProcessComplete:d=>{d===0&&i(!0)}})})})}),t.jsx("div",{className:"border-t border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:l?t.jsxs("span",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[t.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"}),n("setupModal.completed")]}):n("setupModal.willStart")}),t.jsx("button",{onClick:c,className:Ae("px-4 py-2 text-sm font-medium rounded-md transition-colors",l?"bg-green-600 hover:bg-green-700 text-white":"text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600"),children:n(l?"setupModal.closeContinueButton":"setupModal.closeButton")})]})})]})})}function Di({priority:e}){return e==="high"?t.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-red-100 dark:bg-red-900/50",title:"High Priority",children:t.jsx(Ua,{className:"h-2.5 w-2.5 text-red-600 dark:text-red-400"})}):e==="medium"?t.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-amber-100 dark:bg-amber-900/50",title:"Medium Priority",children:t.jsx(Ba,{className:"h-2.5 w-2.5 text-amber-600 dark:text-amber-400"})}):t.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-gray-100 dark:bg-gray-800",title:"Low Priority",children:t.jsx(zs,{className:"h-2.5 w-2.5 text-gray-400 dark:text-gray-500"})})}function Ts({onShowAllTasks:e=null,onStartTask:r=null,className:s=""}){const{nextTask:a,tasks:n,currentProject:l,isLoadingTasks:i,projectTaskMaster:c,refreshTasks:d,refreshProjectTaskMaster:u}=Fs(),[x,v]=o.useState(!1),[g,b]=o.useState(!1),[N,k]=o.useState(!1);if(!l||i)return null;const E=Array.isArray(n)&&n.length>0,w=!!(c?.hasTaskmaster||l.taskmaster?.hasTaskmaster),L=()=>{u(),d()};if(!E&&!w)return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Ae("bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-lg p-3 mb-4",s),children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Kr,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"TaskMaster AI is not configured"})]}),t.jsxs("button",{onClick:()=>b(!0),className:"flex items-center gap-1 rounded bg-blue-600 px-2 py-1 text-xs text-white transition-colors hover:bg-blue-700",children:[t.jsx(Ar,{className:"h-3 w-3"}),"Initialize"]})]}),t.jsxs("button",{onClick:()=>k(f=>!f),className:"mt-2 flex items-center gap-1 text-xs text-blue-700 hover:underline dark:text-blue-300",children:[t.jsx(Pa,{className:"h-3 w-3"}),N?"Hide details":"What is TaskMaster?"]}),N&&t.jsxs("div",{className:"mt-3 space-y-1 text-xs text-blue-900 dark:text-blue-100",children:[t.jsx("p",{children:"- AI-powered task management with dependencies and subtasks."}),t.jsx("p",{children:"- PRD-driven task generation for faster project bootstrapping."}),t.jsx("p",{children:"- Kanban and list views for day-to-day execution."})]})]}),t.jsx(_i,{isOpen:g,project:l,onClose:()=>b(!1),onAfterClose:L})]});if(a)return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Ae("bg-slate-50 dark:bg-slate-900/30 border border-slate-200 dark:border-slate-700 rounded-lg p-3 mb-4",s),children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[t.jsx("div",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/50",children:t.jsx(_a,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"})}),t.jsxs("span",{className:"text-xs font-medium text-slate-600 dark:text-slate-400",children:["Task ",a.id]}),t.jsx(Di,{priority:a.priority})]}),t.jsx("p",{className:"line-clamp-1 text-sm font-medium text-slate-900 dark:text-slate-100",children:a.title})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[t.jsxs("button",{onClick:()=>r?.(),className:"flex items-center gap-1 rounded-md bg-blue-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-blue-700",children:[t.jsx(Da,{className:"h-3 w-3"}),"Start Task"]}),t.jsx("button",{onClick:()=>v(!0),className:"rounded-md border border-slate-300 px-2 py-1.5 text-xs text-slate-600 hover:bg-slate-100 dark:border-slate-600 dark:text-slate-300 dark:hover:bg-slate-800",title:"View task details",children:t.jsx(Fa,{className:"h-3 w-3"})}),e&&t.jsx("button",{onClick:e,className:"rounded-md border border-slate-300 px-2 py-1.5 text-xs text-slate-600 hover:bg-slate-100 dark:border-slate-600 dark:text-slate-300 dark:hover:bg-slate-800",title:"View all tasks",children:t.jsx(Kr,{className:"h-3 w-3"})})]})]})}),t.jsx(Oi,{task:a,isOpen:x,onClose:()=>v(!1),onStatusChange:()=>{d()}})]});if(E){const f=n.filter(m=>m.status==="done").length;return t.jsx("div",{className:Ae("bg-purple-50 dark:bg-purple-950 border border-purple-200 dark:border-purple-800 rounded-lg p-3 mb-4",s),children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Hs,{className:"h-4 w-4 text-purple-600 dark:text-purple-400"}),t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:f===n.length?"All tasks complete":"No pending tasks"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[f,"/",n.length]}),e&&t.jsx("button",{onClick:e,className:"rounded bg-purple-600 px-2 py-1 text-xs text-white transition-colors hover:bg-purple-700",children:"Review"})]})]})})}return null}const Es=[{id:"claude",label:"Claude"},{id:"codex",label:"Codex"},{id:"cursor",label:"Cursor"},{id:"opencode",label:"OpenCode"}];function Mn({initialProvider:e,providerModelCatalog:r,actions:s,onDone:a}){const[n,l]=o.useState(e),[i,c]=o.useState(null),[d,u]=o.useState(""),[x,v]=o.useState(""),[g,b]=o.useState(!1),[N,k]=o.useState(null),[E,w]=o.useState(null),[L,f]=o.useState(null),[m,p]=o.useState(null);o.useEffect(()=>{l(e)},[e]);const h=o.useMemo(()=>r[n]?.OPTIONS??[],[r,n]),y=o.useMemo(()=>h.filter(M=>M.isCustom),[h]),I=o.useMemo(()=>h.filter(M=>!M.isCustom),[h]),T=()=>{c(null),u(""),v(""),f(null)},j=M=>{l(M),w(null),p(null),T()},A=M=>{c(M),u(M.label),v(M.value),w(null),p(null),f(null)},_=async M=>{M.preventDefault();const O=d.trim(),$=x.trim();if(!O||!$){f("Enter both a model name and model ID.");return}if(/\s/.test($)){f("Model IDs cannot contain spaces.");return}b(!0),f(null),p(null);try{i?(await s.update(n,i,{model:O,id:$}),p(`${O} was updated.`)):(await s.create(n,{model:O,id:$}),p(`${O} was added.`)),T()}catch(P){f(P instanceof Error?P.message:"Unable to save this model.")}finally{b(!1)}},H=async M=>{if(M.recordId){k(M.recordId),f(null),p(null);try{await s.remove(n,M),i?.recordId===M.recordId&&T(),w(null),p(`${M.label} was deleted.`)}catch(O){f(O instanceof Error?O.message:"Unable to delete this model.")}finally{k(null)}}};return t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-4",children:[t.jsxs("div",{className:"flex shrink-0 flex-col gap-3 border-b border-border/70 pb-4 sm:flex-row sm:items-start sm:justify-between",children:[t.jsx("div",{className:"min-w-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-xl border border-primary/25 bg-primary/10 text-primary",children:t.jsx(Bt,{className:"h-4 w-4"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-base font-semibold tracking-tight text-foreground",children:"Model library"}),t.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Add model IDs supported by your provider. Built-in models stay locked."})]})]})}),a&&t.jsxs(Qe,{type:"button",variant:"outline",size:"sm",onClick:a,className:"shrink-0 rounded-xl",children:[t.jsx(qa,{className:"h-3.5 w-3.5"}),"Back to models"]})]}),t.jsx("div",{className:"scrollbar-thin flex shrink-0 gap-1 overflow-x-auto rounded-xl border border-border/70 bg-muted/25 p-1",children:Es.map(M=>{const O=M.id===n;return t.jsxs("button",{type:"button",onClick:()=>j(M.id),"aria-pressed":O,className:`flex min-w-fit flex-1 items-center justify-center gap-2 rounded-lg px-3 py-2 text-xs font-semibold transition-all ${O?"bg-background text-foreground shadow-sm ring-1 ring-border/70":"text-muted-foreground hover:bg-background/60 hover:text-foreground"}`,children:[t.jsx(tr,{provider:M.id,className:"h-4 w-4"}),M.label]},M.id)})}),t.jsxs("div",{className:"scrollbar-thin grid min-h-0 flex-1 items-start gap-4 overflow-y-auto pr-1 lg:grid-cols-[minmax(16rem,0.8fr)_minmax(20rem,1.2fr)]",children:[t.jsxs("form",{onSubmit:_,className:"h-fit rounded-2xl border border-border/70 bg-muted/20 p-4 shadow-sm",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-semibold text-foreground",children:i?"Edit custom model":"Add a custom model"}),t.jsxs("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:["The ID is sent to ",Es.find(M=>M.id===n)?.label," exactly as written."]})]}),i&&t.jsx(Qe,{type:"button",variant:"ghost",size:"icon",onClick:T,className:"h-8 w-8 rounded-lg","aria-label":"Cancel editing",children:t.jsx(it,{className:"h-4 w-4"})})]}),t.jsx("label",{className:"mt-4 block text-xs font-semibold text-foreground",htmlFor:"custom-model-name",children:"Model name"}),t.jsx(Cr,{id:"custom-model-name",value:d,onChange:M=>u(M.target.value),maxLength:80,placeholder:"e.g. GPT-5.5 Pro",autoComplete:"off",className:"mt-1.5 h-10 rounded-xl bg-background"}),t.jsx("label",{className:"mt-4 block text-xs font-semibold text-foreground",htmlFor:"custom-model-id",children:"Model ID"}),t.jsx(Cr,{id:"custom-model-id",value:x,onChange:M=>v(M.target.value),maxLength:200,placeholder:"e.g. gpt-5.5-pro",autoComplete:"off",spellCheck:!1,className:"mt-1.5 h-10 rounded-xl bg-background font-mono"}),t.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Use the exact identifier accepted by the provider CLI. IDs cannot contain spaces."}),L&&t.jsx("div",{role:"alert",className:"mt-3 rounded-xl border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:L}),m&&!L&&t.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-xl border border-emerald-500/25 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-700 dark:text-emerald-300",children:[t.jsx(Ut,{className:"h-3.5 w-3.5"}),m]}),t.jsxs(Qe,{type:"submit",disabled:g,className:"mt-4 w-full rounded-xl",children:[g?t.jsx($t,{className:"h-4 w-4 animate-spin"}):i?t.jsx(Ut,{className:"h-4 w-4"}):t.jsx(Bt,{className:"h-4 w-4"}),g?"Saving…":i?"Save changes":"Add model"]})]}),t.jsxs("div",{className:"min-h-0 space-y-4",children:[t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3 px-1",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-foreground",children:"Your models"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Editable and stored in auth.db"})]}),t.jsx(jt,{variant:"secondary",className:"rounded-full text-[10px]",children:y.length})]}),y.length===0?t.jsxs("div",{className:"rounded-2xl border border-dashed border-border bg-background/60 px-4 py-7 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"No custom models yet"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Add one with the form and it will appear in every model picker."})]}):t.jsx("div",{className:"space-y-2",children:y.map(M=>{const O=E===M.recordId,$=N===M.recordId;return t.jsxs("div",{className:"rounded-2xl border border-primary/20 bg-primary/[0.04] p-3",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("p",{className:"truncate text-sm font-semibold text-foreground",children:M.label}),t.jsx(jt,{className:"rounded-full px-2 py-0 text-[9px]",children:"Custom"})]}),t.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground",children:M.value})]}),!O&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Qe,{type:"button",variant:"ghost",size:"icon",onClick:()=>A(M),className:"h-8 w-8 rounded-lg","aria-label":`Edit ${M.label}`,children:t.jsx(Ws,{className:"h-3.5 w-3.5"})}),t.jsx(Qe,{type:"button",variant:"ghost",size:"icon",onClick:()=>w(M.recordId??null),className:"h-8 w-8 rounded-lg text-muted-foreground hover:bg-destructive/10 hover:text-destructive","aria-label":`Delete ${M.label}`,children:t.jsx(Va,{className:"h-3.5 w-3.5"})})]})]}),O&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 border-t border-border/60 pt-3",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Delete this model from all pickers?"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Qe,{type:"button",variant:"ghost",size:"sm",onClick:()=>w(null),className:"h-8 rounded-lg",children:"Cancel"}),t.jsxs(Qe,{type:"button",variant:"destructive",size:"sm",disabled:$,onClick:()=>{H(M)},className:"h-8 rounded-lg",children:[$&&t.jsx($t,{className:"h-3.5 w-3.5 animate-spin"}),"Delete"]})]})]})]},M.recordId??M.value)})})]}),t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3 px-1",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-foreground",children:"Built-in models"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Maintained by WindCli and read-only"})]}),t.jsx(jt,{variant:"secondary",className:"rounded-full text-[10px]",children:I.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-background/70",children:I.map(M=>t.jsxs("div",{className:"flex items-center gap-3 border-b border-border/60 px-3 py-2.5 last:border-b-0",children:[t.jsx(Ha,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-xs font-medium text-foreground",children:M.label}),t.jsx("p",{className:"truncate font-mono text-[10px] text-muted-foreground",children:M.value})]})]},M.recordId??M.value))})]})]})]})]})}const Fi=[{id:"claude",name:"Anthropic"},{id:"codex",name:"OpenAI"},{id:"cursor",name:"Cursor"},{id:"opencode",name:"OpenCode"}],Ui=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl";function Bi(e,r){const s=e.toLowerCase();return r.toLowerCase().split(/\s+/).filter(Boolean).every(n=>s.includes(n))?1:0}function qi(e,r){return r[e]??{OPTIONS:[],DEFAULT:""}}function Vi(e,r,s,a,n){return e==="claude"?r:e==="codex"?a:e==="opencode"?n:s}function Hi(e){return e==="claude"?"Claude":e==="cursor"?"Cursor":e==="codex"?"Codex":e==="opencode"?"OpenCode":"Claude"}function zi({selectedSession:e,currentSessionId:r,provider:s,setProvider:a,textareaRef:n,claudeModel:l,setClaudeModel:i,cursorModel:c,setCursorModel:d,codexModel:u,setCodexModel:x,opencodeModel:v,setOpenCodeModel:g,providerModelCatalog:b,providerModelActions:N,providerModelsLoading:k,tasksEnabled:E,isTaskMasterInstalled:w,onShowAllTasks:L,setInput:f}){const{t:m}=We("chat"),[p,h]=o.useState(!1),[y,I]=o.useState(!1),T=o.useMemo(()=>Fi.map(P=>({id:P.id,name:P.name,models:b[P.id]?.OPTIONS??[]})),[b]),j=m("tasks.nextTaskPrompt",{defaultValue:"Start the next task"}),A=Vi(s,l,c,u,v),_=o.useMemo(()=>qi(s,b).OPTIONS.find(z=>z.value===A)?.label||A,[s,A,b]),H=o.useCallback((P,B)=>{P==="claude"?(i(B),localStorage.setItem("claude-model",B)):P==="codex"?(x(B),localStorage.setItem("codex-model",B)):P==="opencode"?(g(B),localStorage.setItem("opencode-model",B)):(d(B),localStorage.setItem("cursor-model",B))},[i,d,x,g]),M=o.useCallback((P,B)=>{a(P),localStorage.setItem("selected-provider",P),H(P,B),h(!1),setTimeout(()=>n.current?.focus(),100)},[a,H,n]),O=()=>{h(!1),I(!0)},$=()=>{I(!1),h(!0)};return!e&&!r?t.jsx("div",{className:"flex h-full items-center justify-center px-4",children:t.jsxs("div",{className:"w-full max-w-[34.25rem]",children:[t.jsxs("div",{className:"mb-8 text-center",children:[t.jsx("h2",{className:"text-lg font-semibold tracking-tight text-foreground sm:text-xl",children:m("providerSelection.title")}),t.jsx("p",{className:"mt-1 text-[13px] text-muted-foreground",children:m("providerSelection.description")})]}),t.jsxs(Sr,{open:p,onOpenChange:h,children:[t.jsx(oa,{asChild:!0,children:t.jsx(_s,{className:"group mx-auto max-w-xs cursor-pointer border-border/60 transition-all duration-150 hover:border-border hover:shadow-md active:scale-[0.99]",role:"button",tabIndex:0,children:t.jsxs("div",{className:"flex items-center gap-2 p-3",children:[t.jsx(tr,{provider:s,className:"h-5 w-5 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-xs font-semibold text-foreground",children:Hi(s)}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),t.jsx("span",{className:"truncate text-xs text-foreground",children:_})]}),t.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:m("providerSelection.clickToChange",{defaultValue:"Click to change model"})})]}),t.jsx(rr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform group-hover:translate-y-0.5"})]})})}),t.jsxs(Mr,{className:"max-w-md overflow-hidden p-0",children:[t.jsx(Tr,{children:"Model Selector"}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/60 bg-muted/20 px-4 py-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-semibold text-foreground",children:m("providerSelection.chooseModel",{defaultValue:"Choose a model"})}),t.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:m("providerSelection.chooseModelDescription",{defaultValue:"Built-in and custom models in one list"})})]}),t.jsxs(Qe,{type:"button",variant:"ghost",size:"sm",onClick:O,className:"h-8 shrink-0 rounded-lg px-2.5 text-xs",children:[t.jsx(Bt,{className:"h-3.5 w-3.5"}),m("providerSelection.addModel",{defaultValue:"Add model"})]})]}),t.jsxs(la,{filter:Bi,children:[t.jsx(ia,{placeholder:m("providerSelection.searchModels",{defaultValue:"Search models..."})}),t.jsxs(ca,{className:"max-h-[350px]",children:[t.jsx(da,{children:m("providerSelection.noModelsFound",{defaultValue:"No models found."})}),T.map((P,B)=>t.jsxs(ua,{className:B>0?"border-t border-border/40 [&_[cmdk-group-heading]]:mt-1 [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider":"[&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider",heading:t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(tr,{provider:P.id,className:"h-3.5 w-3.5 shrink-0"}),P.name]}),children:[P.models.length===0&&k?t.jsx(Wr,{disabled:!0,className:"ml-4 border-l border-border/40 pl-4 text-muted-foreground",children:m("providerSelection.loadingModels",{defaultValue:"Loading models…"})}):null,P.models.map(z=>{const U=s===P.id&&A===z.value;return t.jsxs(Wr,{value:`${P.name} ${z.label} ${z.description||""}`,onSelect:()=>M(P.id,z.value),className:"ml-4 border-l border-border/40 pl-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"truncate",children:z.label}),z.isCustom&&t.jsx(jt,{className:"h-4 shrink-0 rounded-full px-1.5 text-[8px]",children:"Custom"})]}),z.label!==z.value&&t.jsx("div",{className:"truncate font-mono text-[10px] text-muted-foreground",children:z.value})]}),U&&t.jsx(Ut,{className:"ml-auto h-4 w-4 shrink-0 text-primary"})]},`${P.id}-${z.value}`)})]},P.id))]})]})]})]}),t.jsx(Sr,{open:y,onOpenChange:P=>{P?I(!0):$()},children:t.jsxs(Mr,{className:"flex h-[min(90dvh,46rem)] w-[calc(100vw-1rem)] max-w-4xl flex-col overflow-hidden rounded-3xl p-4 sm:p-5",children:[t.jsx(Tr,{children:m("providerSelection.manageModels",{defaultValue:"Manage models"})}),t.jsx(Mn,{initialProvider:s,providerModelCatalog:b,actions:N,onDone:$})]})}),t.jsx("p",{className:"mt-4 text-center text-sm text-muted-foreground/70",children:{claude:m("providerSelection.readyPrompt.claude",{model:l}),cursor:m("providerSelection.readyPrompt.cursor",{model:c}),codex:m("providerSelection.readyPrompt.codex",{model:u}),opencode:m("providerSelection.readyPrompt.opencode",{model:v,defaultValue:"Ready with OpenCode {{model}}"})}[s]}),t.jsx("p",{className:"mt-3 flex items-center justify-center gap-1.5 text-center text-xs text-muted-foreground/60",children:t.jsx(_o,{ns:"chat",i18nKey:"providerSelection.pressToSearch",values:{shortcut:Ui==="⌘"?"⌘K":"Ctrl+K"},components:{kbd:t.jsx("kbd",{className:"inline-flex items-center gap-0.5 rounded border border-border/60 bg-muted/40 px-1.5 py-0.5 font-mono text-[10px]"})}})}),s&&E&&w&&t.jsx("div",{className:"mt-5",children:t.jsx(Ts,{onStartTask:()=>f(j),onShowAllTasks:L})})]})}):e?t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"max-w-[34.25rem] px-6 text-center",children:[t.jsx("p",{className:"mb-1.5 text-lg font-semibold text-foreground",children:m("session.continue.title")}),t.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:m("session.continue.description")}),E&&w&&t.jsx("div",{className:"mt-5",children:t.jsx(Ts,{onStartTask:()=>f(j),onShowAllTasks:L})})]})}):null}function Wi(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function Ki(e){const r=ir(e.toolName||"UnknownTool").input,s=Wi(e.toolInput),a=typeof r.title=="function"?r.title(s):r.title,n=r.getValue?.(s);return String(n||a||e.displayText||e.content||"").trim()}function Gi(e,r){return e==="terminal"?"$":e||r.slice(0,1).toUpperCase()}function Ji({group:e,prevMessage:r,createDiff:s,getMessageKey:a,onFileOpen:n,onShowSettings:l,onGrantToolPermission:i,showRawParameters:c,showThinking:d,selectedProject:u,provider:x}){const[v,g]=o.useState(!1),b=ir(e.toolName).input,N=b.label||e.toolName,k=b.colorScheme?.border||"border-border",E=b.colorScheme?.icon||"text-muted-foreground",w=Gi(b.icon,e.toolName),L=o.useMemo(()=>{const f=e.messages.slice(0,2).map(Ki).filter(Boolean),m=e.messages.length-f.length,p=f.join(", ");return p?m>0?`${p}, +${m} more`:p:m>0?`+${m} more`:""},[e.messages]);return t.jsxs("div",{className:"chat-message tool px-3 sm:px-0","data-message-timestamp":e.timestamp||void 0,children:[t.jsxs("button",{type:"button",className:`group flex w-full items-center gap-2 border-l-2 ${k} rounded-r-md bg-muted/25 px-3 py-2 text-left transition-colors hover:bg-muted/40 dark:bg-muted/10 dark:hover:bg-muted/20`,onClick:()=>g(f=>!f),"aria-expanded":v,children:[t.jsx(It,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground transition-transform ${v?"rotate-90":""}`,"aria-hidden":!0}),t.jsx("span",{className:`${E} flex h-5 w-5 flex-shrink-0 items-center justify-center rounded bg-background/80 text-xs font-medium`,children:w}),t.jsx("span",{className:"min-w-0 flex-shrink-0 text-xs font-medium text-foreground",children:N}),t.jsxs("span",{className:"flex-shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:["x",e.messages.length]}),L&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"/"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",children:L})]})]}),v&&t.jsx("div",{className:"mt-2 space-y-3 sm:space-y-4",children:e.messages.map((f,m)=>t.jsx(Sn,{message:f,prevMessage:m>0?e.messages[m-1]:r,createDiff:s,onFileOpen:n,onShowSettings:l,onGrantToolPermission:i,showRawParameters:c,showThinking:d,selectedProject:u,provider:x},a(f)))})]})}const Qi=`
23
+ `).filter(h=>h.trim()),m=f.find(h=>h.includes("?"))||f[0]||"",p=[];return f.forEach(h=>{const y=h.match(/[❯\s]*(\d+)\.\s+(.+)/);if(y){const I=h.includes("❯");p.push({number:y[1],text:y[2].trim(),isSelected:I})}}),t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mb-4 text-sm text-amber-800 dark:text-amber-200",children:m}),t.jsx("div",{className:"mb-4 space-y-2",children:p.map(h=>t.jsx("button",{className:`w-full rounded-lg border-2 px-4 py-3 text-left transition-all ${h.isSelected?"border-amber-600 bg-amber-600 text-white shadow-md dark:border-amber-700 dark:bg-amber-700":"border-amber-300 bg-white text-amber-900 dark:border-amber-700 dark:bg-gray-800 dark:text-amber-100"} cursor-not-allowed opacity-75`,disabled:!0,children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full text-sm font-bold ${h.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:h.number}),t.jsx("span",{className:"flex-1 text-sm font-medium sm:text-base",children:h.text}),h.isSelected&&t.jsx("span",{className:"text-lg",children:"❯"})]})},h.number))}),t.jsxs("div",{className:"rounded-lg bg-amber-100 p-3 dark:bg-amber-800/30",children:[t.jsx("p",{className:"mb-1 text-sm font-medium text-amber-900 dark:text-amber-100",children:d("interactive.waiting")}),t.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-200",children:d("interactive.instruction")})]})]})})()]})]})}):e.isThinking?t.jsxs(Vr,{defaultOpen:!1,children:[t.jsx(Hr,{}),t.jsxs(zr,{children:[t.jsx(Tt,{className:"prose prose-sm prose-gray max-w-none font-serif dark:prose-invert",children:e.content}),t.jsx("div",{className:"mt-3 flex items-center text-[11px]",children:t.jsx(yr,{content:String(e.content||""),messageType:"assistant"})})]})]}):t.jsxs("div",{dir:"auto",className:"text-sm text-gray-700 dark:text-gray-300",children:[l&&e.reasoning&&t.jsxs(Vr,{className:"mb-3",defaultOpen:!1,children:[t.jsx(Hr,{}),t.jsx(zr,{children:t.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const f=g,m=f.trim();if((m.startsWith("{")||m.startsWith("["))&&(m.endsWith("}")||m.endsWith("]")))try{const p=JSON.parse(m),h=JSON.stringify(p,null,2);return t.jsxs("div",{className:"my-2",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),t.jsx("span",{className:"font-medium",children:d("json.response")})]}),t.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-muted",children:t.jsx("pre",{className:"overflow-x-auto p-4",children:t.jsx("code",{className:"block whitespace-pre font-mono text-sm text-foreground",children:h})})})]})}catch{}return e.type==="assistant"?t.jsx(Tt,{className:"prose prose-sm prose-gray max-w-none font-serif dark:prose-invert",children:f}):t.jsx("div",{className:"whitespace-pre-wrap",children:f})})()]}),(E||!u)&&t.jsxs("div",{className:"mt-1 flex w-full items-center gap-2 text-[11px] text-gray-400 dark:text-gray-500",children:[E&&t.jsx(yr,{content:b,messageType:"assistant"}),E&&t.jsx(Ii,{content:b}),!u&&t.jsx("span",{children:w})]})]})]})})}),Li=[{value:"pending",label:"Pending"},{value:"in-progress",label:"In Progress"},{value:"review",label:"Review"},{value:"done",label:"Done"},{value:"deferred",label:"Deferred"},{value:"cancelled",label:"Cancelled"}];function Ri(e){return e==="done"?Hs:e==="in-progress"?Ra:e==="review"?Aa:e==="deferred"?Oa:e==="cancelled"?it:zs}function Ai(e){return e==="high"?"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950":e==="medium"?"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-950":e==="low"?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950":"text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800"}function Oi({task:e,isOpen:r=!0,className:s="",onClose:a,onEdit:n=null,onStatusChange:l=null,onTaskClick:i=null}){const{currentProject:c,refreshTasks:d}=Fs(),[u,x]=o.useState(!1),[v,g]=o.useState(!1),[b,N]=o.useState(!1),[k,E]=o.useState(!1),[w,L]=o.useState(e);o.useEffect(()=>{L(e),x(!1)},[e]);const f=o.useMemo(()=>Ri(e?.status),[e?.status]);if(!r||!e||!w)return null;const m=async()=>{if(!c?.name)return;const h={};if(w.title!==e.title&&(h.title=w.title),w.description!==e.description&&(h.description=w.description??""),w.details!==e.details&&(h.details=w.details??""),Object.keys(h).length===0){x(!1);return}g(!0);try{const y=await jr.taskmaster.updateTask(c.name,e.id,h);if(!y.ok){const I=await y.json();throw new Error(I.message??"Failed to update task")}x(!1),await d(),n?.(w)}catch(y){console.error("Failed to save task changes:",y),alert(y instanceof Error?y.message:"Failed to update task")}finally{g(!1)}},p=async h=>{if(!(!c?.name||h===e.status))try{const y=await jr.taskmaster.updateTask(c.name,e.id,{status:h});if(!y.ok){const I=await y.json();throw new Error(I.message??"Failed to update task status")}await d(),l?.(e.id,h)}catch(y){console.error("Failed to update task status:",y),alert(y instanceof Error?y.message:"Failed to update task status")}};return t.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 md:p-4",children:t.jsxs("div",{className:Ae("w-full md:max-w-4xl h-full md:h-[90vh] bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 md:rounded-lg shadow-xl flex flex-col",s),children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700 md:p-6",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t.jsx(f,{className:"h-6 w-6 text-blue-600 dark:text-blue-400"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("button",{onClick:()=>Vt(String(e.id)),className:"mb-2 inline-flex items-center gap-1 rounded bg-gray-100 px-2 py-1 text-xs text-gray-600 hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700",title:"Copy task ID",children:[t.jsxs("span",{children:["Task ",e.id]}),t.jsx(Us,{className:"h-3 w-3"})]}),u?t.jsx("input",{type:"text",value:w.title,onChange:h=>L({...w,title:h.target.value}),className:"w-full border-b-2 border-blue-500 bg-transparent text-lg font-semibold text-gray-900 focus:outline-none dark:text-white"}):t.jsx("h1",{className:"line-clamp-2 text-lg font-semibold text-gray-900 dark:text-white md:text-xl",children:e.title})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[u?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:m,disabled:v,className:"rounded-md p-2 text-green-600 hover:bg-green-50 disabled:opacity-50 dark:hover:bg-green-950",title:"Save",children:t.jsx(Ia,{className:Ae("w-5 h-5",v&&"animate-spin")})}),t.jsx("button",{onClick:()=>{L(e),x(!1)},disabled:v,className:"rounded-md p-2 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",title:"Cancel editing",children:t.jsx(it,{className:"h-5 w-5"})})]}):t.jsx("button",{onClick:()=>x(!0),className:"rounded-md p-2 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",title:"Edit task",children:t.jsx($a,{className:"h-5 w-5"})}),t.jsx("button",{onClick:a,className:"rounded-md p-2 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",title:"Close",children:t.jsx(it,{className:"h-5 w-5"})})]})]}),t.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4 md:p-6",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"}),t.jsx("select",{value:e.status??"pending",onChange:h=>{p(h.target.value)},className:"w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-gray-900 dark:border-gray-600 dark:bg-gray-800 dark:text-white",children:Li.map(h=>t.jsx("option",{value:h.value,children:h.label},h.value))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Priority"}),t.jsx("div",{className:Ae("px-3 py-2 rounded-md text-sm font-medium capitalize",Ai(e.priority)),children:e.priority??"Not set"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Dependencies"}),Array.isArray(e.dependencies)&&e.dependencies.length>0?t.jsx("div",{className:"flex flex-wrap gap-1",children:e.dependencies.map(h=>t.jsxs("button",{onClick:()=>i?.({id:h}),className:"rounded bg-blue-100 px-2 py-1 text-sm text-blue-700 hover:bg-blue-200 dark:bg-blue-900 dark:text-blue-300 dark:hover:bg-blue-800",children:[t.jsx(La,{className:"mr-1 inline h-3 w-3"}),h]},String(h)))}):t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No dependencies"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Description"}),u?t.jsx("textarea",{rows:4,value:w.description??"",onChange:h=>L({...w,description:h.target.value}),className:"w-full rounded-md border border-gray-300 bg-white px-3 py-2 dark:border-gray-600 dark:bg-gray-800"}):t.jsx("p",{className:"whitespace-pre-wrap text-gray-700 dark:text-gray-300",children:e.description||"No description provided"})]}),e.details&&t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-700",children:[t.jsxs("button",{onClick:()=>N(h=>!h),className:"flex w-full items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Implementation Details"}),b?t.jsx(rr,{className:"h-4 w-4"}):t.jsx(It,{className:"h-4 w-4"})]}),b&&t.jsx("div",{className:"border-t border-gray-200 p-4 dark:border-gray-700",children:t.jsx("p",{className:"whitespace-pre-wrap text-gray-700 dark:text-gray-300",children:e.details})})]}),e.testStrategy&&t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-700",children:[t.jsxs("button",{onClick:()=>E(h=>!h),className:"flex w-full items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Test Strategy"}),k?t.jsx(rr,{className:"h-4 w-4"}):t.jsx(It,{className:"h-4 w-4"})]}),k&&t.jsx("div",{className:"border-t border-gray-200 bg-blue-50 p-4 dark:border-gray-700 dark:bg-blue-950/30",children:t.jsx("p",{className:"whitespace-pre-wrap text-gray-700 dark:text-gray-300",children:e.testStrategy})})]})]})]})})}const Pi=o.lazy(()=>Ps(()=>import("./Shell-CrjXAW4f.js").then(e=>e.a),__vite__mapDeps([7,2,1,3,4,5,6,8])));function _i({isOpen:e,project:r,onClose:s,onAfterClose:a=null}){const{t:n}=We("tasks"),[l,i]=o.useState(!1);if(!e||!r)return null;const c=()=>{s(),i(!1),window.setTimeout(()=>{a?.()},800)};return t.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/50 p-4 pt-16 backdrop-blur-sm",children:t.jsxs("div",{className:"flex h-[600px] w-full max-w-4xl flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-blue-100 dark:bg-blue-900/50",children:t.jsx(Ar,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:n("setupModal.title")}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:n("setupModal.subtitle",{projectName:r.displayName})})]})]}),t.jsx("button",{onClick:c,className:"rounded-md p-2 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:"Close",children:t.jsx(Bt,{className:"h-5 w-5 rotate-45"})})]}),t.jsx("div",{className:"flex-1 p-4",children:t.jsx("div",{className:"h-full overflow-hidden rounded-lg bg-black",children:t.jsx(o.Suspense,{fallback:t.jsx("div",{className:"h-full bg-black",role:"status","aria-label":"Loading terminal"}),children:t.jsx(Pi,{selectedProject:r,selectedSession:null,initialCommand:"npx task-master init",isPlainShell:!0,isActive:!0,onProcessComplete:d=>{d===0&&i(!0)}})})})}),t.jsx("div",{className:"border-t border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:l?t.jsxs("span",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[t.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"}),n("setupModal.completed")]}):n("setupModal.willStart")}),t.jsx("button",{onClick:c,className:Ae("px-4 py-2 text-sm font-medium rounded-md transition-colors",l?"bg-green-600 hover:bg-green-700 text-white":"text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600"),children:n(l?"setupModal.closeContinueButton":"setupModal.closeButton")})]})})]})})}function Di({priority:e}){return e==="high"?t.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-red-100 dark:bg-red-900/50",title:"High Priority",children:t.jsx(Ua,{className:"h-2.5 w-2.5 text-red-600 dark:text-red-400"})}):e==="medium"?t.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-amber-100 dark:bg-amber-900/50",title:"Medium Priority",children:t.jsx(Ba,{className:"h-2.5 w-2.5 text-amber-600 dark:text-amber-400"})}):t.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-gray-100 dark:bg-gray-800",title:"Low Priority",children:t.jsx(zs,{className:"h-2.5 w-2.5 text-gray-400 dark:text-gray-500"})})}function Ts({onShowAllTasks:e=null,onStartTask:r=null,className:s=""}){const{nextTask:a,tasks:n,currentProject:l,isLoadingTasks:i,projectTaskMaster:c,refreshTasks:d,refreshProjectTaskMaster:u}=Fs(),[x,v]=o.useState(!1),[g,b]=o.useState(!1),[N,k]=o.useState(!1);if(!l||i)return null;const E=Array.isArray(n)&&n.length>0,w=!!(c?.hasTaskmaster||l.taskmaster?.hasTaskmaster),L=()=>{u(),d()};if(!E&&!w)return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Ae("bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-lg p-3 mb-4",s),children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Kr,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"TaskMaster AI is not configured"})]}),t.jsxs("button",{onClick:()=>b(!0),className:"flex items-center gap-1 rounded bg-blue-600 px-2 py-1 text-xs text-white transition-colors hover:bg-blue-700",children:[t.jsx(Ar,{className:"h-3 w-3"}),"Initialize"]})]}),t.jsxs("button",{onClick:()=>k(f=>!f),className:"mt-2 flex items-center gap-1 text-xs text-blue-700 hover:underline dark:text-blue-300",children:[t.jsx(Pa,{className:"h-3 w-3"}),N?"Hide details":"What is TaskMaster?"]}),N&&t.jsxs("div",{className:"mt-3 space-y-1 text-xs text-blue-900 dark:text-blue-100",children:[t.jsx("p",{children:"- AI-powered task management with dependencies and subtasks."}),t.jsx("p",{children:"- PRD-driven task generation for faster project bootstrapping."}),t.jsx("p",{children:"- Kanban and list views for day-to-day execution."})]})]}),t.jsx(_i,{isOpen:g,project:l,onClose:()=>b(!1),onAfterClose:L})]});if(a)return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Ae("bg-slate-50 dark:bg-slate-900/30 border border-slate-200 dark:border-slate-700 rounded-lg p-3 mb-4",s),children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[t.jsx("div",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/50",children:t.jsx(_a,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"})}),t.jsxs("span",{className:"text-xs font-medium text-slate-600 dark:text-slate-400",children:["Task ",a.id]}),t.jsx(Di,{priority:a.priority})]}),t.jsx("p",{className:"line-clamp-1 text-sm font-medium text-slate-900 dark:text-slate-100",children:a.title})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[t.jsxs("button",{onClick:()=>r?.(),className:"flex items-center gap-1 rounded-md bg-blue-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-blue-700",children:[t.jsx(Da,{className:"h-3 w-3"}),"Start Task"]}),t.jsx("button",{onClick:()=>v(!0),className:"rounded-md border border-slate-300 px-2 py-1.5 text-xs text-slate-600 hover:bg-slate-100 dark:border-slate-600 dark:text-slate-300 dark:hover:bg-slate-800",title:"View task details",children:t.jsx(Fa,{className:"h-3 w-3"})}),e&&t.jsx("button",{onClick:e,className:"rounded-md border border-slate-300 px-2 py-1.5 text-xs text-slate-600 hover:bg-slate-100 dark:border-slate-600 dark:text-slate-300 dark:hover:bg-slate-800",title:"View all tasks",children:t.jsx(Kr,{className:"h-3 w-3"})})]})]})}),t.jsx(Oi,{task:a,isOpen:x,onClose:()=>v(!1),onStatusChange:()=>{d()}})]});if(E){const f=n.filter(m=>m.status==="done").length;return t.jsx("div",{className:Ae("bg-purple-50 dark:bg-purple-950 border border-purple-200 dark:border-purple-800 rounded-lg p-3 mb-4",s),children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Hs,{className:"h-4 w-4 text-purple-600 dark:text-purple-400"}),t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:f===n.length?"All tasks complete":"No pending tasks"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[f,"/",n.length]}),e&&t.jsx("button",{onClick:e,className:"rounded bg-purple-600 px-2 py-1 text-xs text-white transition-colors hover:bg-purple-700",children:"Review"})]})]})})}return null}const Es=[{id:"claude",label:"Claude"},{id:"codex",label:"Codex"},{id:"cursor",label:"Cursor"},{id:"opencode",label:"OpenCode"}];function Mn({initialProvider:e,providerModelCatalog:r,actions:s,onDone:a}){const[n,l]=o.useState(e),[i,c]=o.useState(null),[d,u]=o.useState(""),[x,v]=o.useState(""),[g,b]=o.useState(!1),[N,k]=o.useState(null),[E,w]=o.useState(null),[L,f]=o.useState(null),[m,p]=o.useState(null);o.useEffect(()=>{l(e)},[e]);const h=o.useMemo(()=>r[n]?.OPTIONS??[],[r,n]),y=o.useMemo(()=>h.filter(M=>M.isCustom),[h]),I=o.useMemo(()=>h.filter(M=>!M.isCustom),[h]),T=()=>{c(null),u(""),v(""),f(null)},j=M=>{l(M),w(null),p(null),T()},A=M=>{c(M),u(M.label),v(M.value),w(null),p(null),f(null)},_=async M=>{M.preventDefault();const O=d.trim(),$=x.trim();if(!O||!$){f("Enter both a model name and model ID.");return}if(/\s/.test($)){f("Model IDs cannot contain spaces.");return}b(!0),f(null),p(null);try{i?(await s.update(n,i,{model:O,id:$}),p(`${O} was updated.`)):(await s.create(n,{model:O,id:$}),p(`${O} was added.`)),T()}catch(P){f(P instanceof Error?P.message:"Unable to save this model.")}finally{b(!1)}},H=async M=>{if(M.recordId){k(M.recordId),f(null),p(null);try{await s.remove(n,M),i?.recordId===M.recordId&&T(),w(null),p(`${M.label} was deleted.`)}catch(O){f(O instanceof Error?O.message:"Unable to delete this model.")}finally{k(null)}}};return t.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-4",children:[t.jsxs("div",{className:"flex shrink-0 flex-col gap-3 border-b border-border/70 pb-4 sm:flex-row sm:items-start sm:justify-between",children:[t.jsx("div",{className:"min-w-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-xl border border-primary/25 bg-primary/10 text-primary",children:t.jsx(Bt,{className:"h-4 w-4"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-base font-semibold tracking-tight text-foreground",children:"Model library"}),t.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Add model IDs supported by your provider. Built-in models stay locked."})]})]})}),a&&t.jsxs(Qe,{type:"button",variant:"outline",size:"sm",onClick:a,className:"shrink-0 rounded-xl",children:[t.jsx(qa,{className:"h-3.5 w-3.5"}),"Back to models"]})]}),t.jsx("div",{className:"scrollbar-thin flex shrink-0 gap-1 overflow-x-auto rounded-xl border border-border/70 bg-muted/25 p-1",children:Es.map(M=>{const O=M.id===n;return t.jsxs("button",{type:"button",onClick:()=>j(M.id),"aria-pressed":O,className:`flex min-w-fit flex-1 items-center justify-center gap-2 rounded-lg px-3 py-2 text-xs font-semibold transition-all ${O?"bg-background text-foreground shadow-sm ring-1 ring-border/70":"text-muted-foreground hover:bg-background/60 hover:text-foreground"}`,children:[t.jsx(tr,{provider:M.id,className:"h-4 w-4"}),M.label]},M.id)})}),t.jsxs("div",{className:"scrollbar-thin grid min-h-0 flex-1 items-start gap-4 overflow-y-auto pr-1 lg:grid-cols-[minmax(16rem,0.8fr)_minmax(20rem,1.2fr)]",children:[t.jsxs("form",{onSubmit:_,className:"h-fit rounded-2xl border border-border/70 bg-muted/20 p-4 shadow-sm",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-semibold text-foreground",children:i?"Edit custom model":"Add a custom model"}),t.jsxs("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:["The ID is sent to ",Es.find(M=>M.id===n)?.label," exactly as written."]})]}),i&&t.jsx(Qe,{type:"button",variant:"ghost",size:"icon",onClick:T,className:"h-8 w-8 rounded-lg","aria-label":"Cancel editing",children:t.jsx(it,{className:"h-4 w-4"})})]}),t.jsx("label",{className:"mt-4 block text-xs font-semibold text-foreground",htmlFor:"custom-model-name",children:"Model name"}),t.jsx(Cr,{id:"custom-model-name",value:d,onChange:M=>u(M.target.value),maxLength:80,placeholder:"e.g. GPT-5.5 Pro",autoComplete:"off",className:"mt-1.5 h-10 rounded-xl bg-background"}),t.jsx("label",{className:"mt-4 block text-xs font-semibold text-foreground",htmlFor:"custom-model-id",children:"Model ID"}),t.jsx(Cr,{id:"custom-model-id",value:x,onChange:M=>v(M.target.value),maxLength:200,placeholder:"e.g. gpt-5.5-pro",autoComplete:"off",spellCheck:!1,className:"mt-1.5 h-10 rounded-xl bg-background font-mono"}),t.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Use the exact identifier accepted by the provider CLI. IDs cannot contain spaces."}),L&&t.jsx("div",{role:"alert",className:"mt-3 rounded-xl border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:L}),m&&!L&&t.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-xl border border-emerald-500/25 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-700 dark:text-emerald-300",children:[t.jsx(Ut,{className:"h-3.5 w-3.5"}),m]}),t.jsxs(Qe,{type:"submit",disabled:g,className:"mt-4 w-full rounded-xl",children:[g?t.jsx($t,{className:"h-4 w-4 animate-spin"}):i?t.jsx(Ut,{className:"h-4 w-4"}):t.jsx(Bt,{className:"h-4 w-4"}),g?"Saving…":i?"Save changes":"Add model"]})]}),t.jsxs("div",{className:"min-h-0 space-y-4",children:[t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3 px-1",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-foreground",children:"Your models"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Editable and stored in auth.db"})]}),t.jsx(jt,{variant:"secondary",className:"rounded-full text-[10px]",children:y.length})]}),y.length===0?t.jsxs("div",{className:"rounded-2xl border border-dashed border-border bg-background/60 px-4 py-7 text-center",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"No custom models yet"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Add one with the form and it will appear in every model picker."})]}):t.jsx("div",{className:"space-y-2",children:y.map(M=>{const O=E===M.recordId,$=N===M.recordId;return t.jsxs("div",{className:"rounded-2xl border border-primary/20 bg-primary/[0.04] p-3",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("p",{className:"truncate text-sm font-semibold text-foreground",children:M.label}),t.jsx(jt,{className:"rounded-full px-2 py-0 text-[9px]",children:"Custom"})]}),t.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground",children:M.value})]}),!O&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Qe,{type:"button",variant:"ghost",size:"icon",onClick:()=>A(M),className:"h-8 w-8 rounded-lg","aria-label":`Edit ${M.label}`,children:t.jsx(Ws,{className:"h-3.5 w-3.5"})}),t.jsx(Qe,{type:"button",variant:"ghost",size:"icon",onClick:()=>w(M.recordId??null),className:"h-8 w-8 rounded-lg text-muted-foreground hover:bg-destructive/10 hover:text-destructive","aria-label":`Delete ${M.label}`,children:t.jsx(Va,{className:"h-3.5 w-3.5"})})]})]}),O&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 border-t border-border/60 pt-3",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Delete this model from all pickers?"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Qe,{type:"button",variant:"ghost",size:"sm",onClick:()=>w(null),className:"h-8 rounded-lg",children:"Cancel"}),t.jsxs(Qe,{type:"button",variant:"destructive",size:"sm",disabled:$,onClick:()=>{H(M)},className:"h-8 rounded-lg",children:[$&&t.jsx($t,{className:"h-3.5 w-3.5 animate-spin"}),"Delete"]})]})]})]},M.recordId??M.value)})})]}),t.jsxs("section",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3 px-1",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-foreground",children:"Built-in models"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Maintained by WindCli and read-only"})]}),t.jsx(jt,{variant:"secondary",className:"rounded-full text-[10px]",children:I.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-background/70",children:I.map(M=>t.jsxs("div",{className:"flex items-center gap-3 border-b border-border/60 px-3 py-2.5 last:border-b-0",children:[t.jsx(Ha,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-xs font-medium text-foreground",children:M.label}),t.jsx("p",{className:"truncate font-mono text-[10px] text-muted-foreground",children:M.value})]})]},M.recordId??M.value))})]})]})]})]})}const Fi=[{id:"claude",name:"Anthropic"},{id:"codex",name:"OpenAI"},{id:"cursor",name:"Cursor"},{id:"opencode",name:"OpenCode"}],Ui=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl";function Bi(e,r){const s=e.toLowerCase();return r.toLowerCase().split(/\s+/).filter(Boolean).every(n=>s.includes(n))?1:0}function qi(e,r){return r[e]??{OPTIONS:[],DEFAULT:""}}function Vi(e,r,s,a,n){return e==="claude"?r:e==="codex"?a:e==="opencode"?n:s}function Hi(e){return e==="claude"?"Claude":e==="cursor"?"Cursor":e==="codex"?"Codex":e==="opencode"?"OpenCode":"Claude"}function zi({selectedSession:e,currentSessionId:r,provider:s,setProvider:a,textareaRef:n,claudeModel:l,setClaudeModel:i,cursorModel:c,setCursorModel:d,codexModel:u,setCodexModel:x,opencodeModel:v,setOpenCodeModel:g,providerModelCatalog:b,providerModelActions:N,providerModelsLoading:k,tasksEnabled:E,isTaskMasterInstalled:w,onShowAllTasks:L,setInput:f}){const{t:m}=We("chat"),[p,h]=o.useState(!1),[y,I]=o.useState(!1),T=o.useMemo(()=>Fi.map(P=>({id:P.id,name:P.name,models:b[P.id]?.OPTIONS??[]})),[b]),j=m("tasks.nextTaskPrompt",{defaultValue:"Start the next task"}),A=Vi(s,l,c,u,v),_=o.useMemo(()=>qi(s,b).OPTIONS.find(z=>z.value===A)?.label||A,[s,A,b]),H=o.useCallback((P,B)=>{P==="claude"?(i(B),localStorage.setItem("claude-model",B)):P==="codex"?(x(B),localStorage.setItem("codex-model",B)):P==="opencode"?(g(B),localStorage.setItem("opencode-model",B)):(d(B),localStorage.setItem("cursor-model",B))},[i,d,x,g]),M=o.useCallback((P,B)=>{a(P),localStorage.setItem("selected-provider",P),H(P,B),h(!1),setTimeout(()=>n.current?.focus(),100)},[a,H,n]),O=()=>{h(!1),I(!0)},$=()=>{I(!1),h(!0)};return!e&&!r?t.jsx("div",{className:"flex h-full items-center justify-center px-4",children:t.jsxs("div",{className:"w-full max-w-[34.25rem]",children:[t.jsxs("div",{className:"mb-8 text-center",children:[t.jsx("h2",{className:"text-lg font-semibold tracking-tight text-foreground sm:text-xl",children:m("providerSelection.title")}),t.jsx("p",{className:"mt-1 text-[13px] text-muted-foreground",children:m("providerSelection.description")})]}),t.jsxs(Sr,{open:p,onOpenChange:h,children:[t.jsx(oa,{asChild:!0,children:t.jsx(_s,{className:"group mx-auto max-w-xs cursor-pointer border-border/60 transition-all duration-150 hover:border-border hover:shadow-md active:scale-[0.99]",role:"button",tabIndex:0,children:t.jsxs("div",{className:"flex items-center gap-2 p-3",children:[t.jsx(tr,{provider:s,className:"h-5 w-5 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-xs font-semibold text-foreground",children:Hi(s)}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),t.jsx("span",{className:"truncate text-xs text-foreground",children:_})]}),t.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:m("providerSelection.clickToChange",{defaultValue:"Click to change model"})})]}),t.jsx(rr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform group-hover:translate-y-0.5"})]})})}),t.jsxs(Mr,{className:"max-w-md overflow-hidden p-0",children:[t.jsx(Tr,{children:"Model Selector"}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/60 bg-muted/20 px-4 py-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-semibold text-foreground",children:m("providerSelection.chooseModel",{defaultValue:"Choose a model"})}),t.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:m("providerSelection.chooseModelDescription",{defaultValue:"Built-in and custom models in one list"})})]}),t.jsxs(Qe,{type:"button",variant:"ghost",size:"sm",onClick:O,className:"h-8 shrink-0 rounded-lg px-2.5 text-xs",children:[t.jsx(Bt,{className:"h-3.5 w-3.5"}),m("providerSelection.addModel",{defaultValue:"Add model"})]})]}),t.jsxs(la,{filter:Bi,children:[t.jsx(ia,{placeholder:m("providerSelection.searchModels",{defaultValue:"Search models..."})}),t.jsxs(ca,{className:"max-h-[350px]",children:[t.jsx(da,{children:m("providerSelection.noModelsFound",{defaultValue:"No models found."})}),T.map((P,B)=>t.jsxs(ua,{className:B>0?"border-t border-border/40 [&_[cmdk-group-heading]]:mt-1 [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider":"[&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider",heading:t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(tr,{provider:P.id,className:"h-3.5 w-3.5 shrink-0"}),P.name]}),children:[P.models.length===0&&k?t.jsx(Wr,{disabled:!0,className:"ml-4 border-l border-border/40 pl-4 text-muted-foreground",children:m("providerSelection.loadingModels",{defaultValue:"Loading models…"})}):null,P.models.map(z=>{const U=s===P.id&&A===z.value;return t.jsxs(Wr,{value:`${P.name} ${z.label} ${z.description||""}`,onSelect:()=>M(P.id,z.value),className:"ml-4 border-l border-border/40 pl-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"truncate",children:z.label}),z.isCustom&&t.jsx(jt,{className:"h-4 shrink-0 rounded-full px-1.5 text-[8px]",children:"Custom"})]}),z.label!==z.value&&t.jsx("div",{className:"truncate font-mono text-[10px] text-muted-foreground",children:z.value})]}),U&&t.jsx(Ut,{className:"ml-auto h-4 w-4 shrink-0 text-primary"})]},`${P.id}-${z.value}`)})]},P.id))]})]})]})]}),t.jsx(Sr,{open:y,onOpenChange:P=>{P?I(!0):$()},children:t.jsxs(Mr,{className:"flex h-[min(90dvh,46rem)] w-[calc(100vw-1rem)] max-w-4xl flex-col overflow-hidden rounded-3xl p-4 sm:p-5",children:[t.jsx(Tr,{children:m("providerSelection.manageModels",{defaultValue:"Manage models"})}),t.jsx(Mn,{initialProvider:s,providerModelCatalog:b,actions:N,onDone:$})]})}),t.jsx("p",{className:"mt-4 text-center text-sm text-muted-foreground/70",children:{claude:m("providerSelection.readyPrompt.claude",{model:l}),cursor:m("providerSelection.readyPrompt.cursor",{model:c}),codex:m("providerSelection.readyPrompt.codex",{model:u}),opencode:m("providerSelection.readyPrompt.opencode",{model:v,defaultValue:"Ready with OpenCode {{model}}"})}[s]}),t.jsx("p",{className:"mt-3 flex items-center justify-center gap-1.5 text-center text-xs text-muted-foreground/60",children:t.jsx(_o,{ns:"chat",i18nKey:"providerSelection.pressToSearch",values:{shortcut:Ui==="⌘"?"⌘K":"Ctrl+K"},components:{kbd:t.jsx("kbd",{className:"inline-flex items-center gap-0.5 rounded border border-border/60 bg-muted/40 px-1.5 py-0.5 font-mono text-[10px]"})}})}),s&&E&&w&&t.jsx("div",{className:"mt-5",children:t.jsx(Ts,{onStartTask:()=>f(j),onShowAllTasks:L})})]})}):e?t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"max-w-[34.25rem] px-6 text-center",children:[t.jsx("p",{className:"mb-1.5 text-lg font-semibold text-foreground",children:m("session.continue.title")}),t.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:m("session.continue.description")}),E&&w&&t.jsx("div",{className:"mt-5",children:t.jsx(Ts,{onStartTask:()=>f(j),onShowAllTasks:L})})]})}):null}function Wi(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function Ki(e){const r=ir(e.toolName||"UnknownTool").input,s=Wi(e.toolInput),a=typeof r.title=="function"?r.title(s):r.title,n=r.getValue?.(s);return String(n||a||e.displayText||e.content||"").trim()}function Gi(e,r){return e==="terminal"?"$":e||r.slice(0,1).toUpperCase()}function Ji({group:e,prevMessage:r,createDiff:s,getMessageKey:a,onFileOpen:n,onShowSettings:l,onGrantToolPermission:i,showRawParameters:c,showThinking:d,selectedProject:u,provider:x}){const[v,g]=o.useState(!1),b=ir(e.toolName).input,N=b.label||e.toolName,k=b.colorScheme?.border||"border-border",E=b.colorScheme?.icon||"text-muted-foreground",w=Gi(b.icon,e.toolName),L=o.useMemo(()=>{const f=e.messages.slice(0,2).map(Ki).filter(Boolean),m=e.messages.length-f.length,p=f.join(", ");return p?m>0?`${p}, +${m} more`:p:m>0?`+${m} more`:""},[e.messages]);return t.jsxs("div",{className:"chat-message tool px-3 sm:px-0","data-message-timestamp":e.timestamp||void 0,children:[t.jsxs("button",{type:"button",className:`group flex w-full items-center gap-2 border-l-2 ${k} rounded-r-md bg-muted/25 px-3 py-2 text-left transition-colors hover:bg-muted/40 dark:bg-muted/10 dark:hover:bg-muted/20`,onClick:()=>g(f=>!f),"aria-expanded":v,children:[t.jsx(It,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground transition-transform ${v?"rotate-90":""}`,"aria-hidden":!0}),t.jsx("span",{className:`${E} flex h-5 w-5 flex-shrink-0 items-center justify-center rounded bg-background/80 text-xs font-medium`,children:w}),t.jsx("span",{className:"min-w-0 flex-shrink-0 text-xs font-medium text-foreground",children:N}),t.jsxs("span",{className:"flex-shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:["x",e.messages.length]}),L&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"/"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",children:L})]})]}),v&&t.jsx("div",{className:"mt-2 space-y-3 sm:space-y-4",children:e.messages.map((f,m)=>t.jsx(Sn,{message:f,prevMessage:m>0?e.messages[m-1]:r,createDiff:s,onFileOpen:n,onShowSettings:l,onGrantToolPermission:i,showRawParameters:c,showThinking:d,selectedProject:u,provider:x},a(f)))})]})}const Qi=`
24
24
  @keyframes loadAllOverlayAutoFade {
25
25
  0%, 80% { opacity: 1; }
26
26
  100% { opacity: 0; }