upfynai-code 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/client/dist/assets/AppContent-DTZ2FbvM.js +513 -0
  2. package/client/dist/assets/CanvasPanel-DlTW6Jh6.js +6 -0
  3. package/client/dist/assets/LoginModal-CWoFm0au.js +19 -0
  4. package/client/dist/assets/MarkdownPreview-CYdvwJaV.js +1 -0
  5. package/client/dist/assets/{Onboarding-Coxo6mFA.js → Onboarding-CtIoXiTp.js} +1 -1
  6. package/client/dist/assets/{SetupForm-BzYOsbji.js → SetupForm-B4p8im5O.js} +1 -1
  7. package/client/dist/assets/{ar-SA-G6X2FPQ2-Bmw2-hDt.js → ar-SA-G6X2FPQ2-2gfmdvHk.js} +1 -1
  8. package/client/dist/assets/{arc-BMqY7_Ci.js → arc-DCZSHhoJ.js} +1 -1
  9. package/client/dist/assets/{az-AZ-76LH7QW2-Dh1le_qs.js → az-AZ-76LH7QW2-CDdeucRZ.js} +1 -1
  10. package/client/dist/assets/{bg-BG-XCXSNQG7-Cbav8Z9z.js → bg-BG-XCXSNQG7-D6__XtOK.js} +1 -1
  11. package/client/dist/assets/{blockDiagram-38ab4fdb-ChHJxsXw.js → blockDiagram-38ab4fdb-Cfbaeyp6.js} +3 -3
  12. package/client/dist/assets/{bn-BD-2XOGV67Q-DCNjOaWz.js → bn-BD-2XOGV67Q-DHNJw3OG.js} +1 -1
  13. package/client/dist/assets/{c4Diagram-3d4e48cf-b8Xue4Z6.js → c4Diagram-3d4e48cf-BBCnjOTy.js} +1 -1
  14. package/client/dist/assets/{ca-ES-6MX7JW3Y-Dl_vM7NS.js → ca-ES-6MX7JW3Y-r5g4o3zQ.js} +1 -1
  15. package/client/dist/assets/channel-O3ovC0x9.js +1 -0
  16. package/client/dist/assets/{classDiagram-70f12bd4-BheP7Ggo.js → classDiagram-70f12bd4-D0lhAcxU.js} +1 -1
  17. package/client/dist/assets/classDiagram-v2-f2320105-BuwUsF3F.js +2 -0
  18. package/client/dist/assets/clone-BG9u7vLi.js +1 -0
  19. package/client/dist/assets/{createText-2e5e7dd3-_n4jI_fO.js → createText-2e5e7dd3-B8jCDmF_.js} +1 -1
  20. package/client/dist/assets/{cs-CZ-2BRQDIVT-ftsKDdz4.js → cs-CZ-2BRQDIVT-p08jRLRC.js} +1 -1
  21. package/client/dist/assets/{da-DK-5WZEPLOC-DAjdwGRO.js → da-DK-5WZEPLOC-CnhOImFf.js} +1 -1
  22. package/client/dist/assets/{de-DE-XR44H4JA-BJXczHGT.js → de-DE-XR44H4JA-BunSXZ-Y.js} +1 -1
  23. package/client/dist/assets/{edges-e0da2a9e-CfPZr4YM.js → edges-e0da2a9e-CGBBhG8k.js} +2 -2
  24. package/client/dist/assets/{el-GR-BZB4AONW-DW2p_uy7.js → el-GR-BZB4AONW-D4wv1oIz.js} +1 -1
  25. package/client/dist/assets/{erDiagram-9861fffd-CF33V-Of.js → erDiagram-9861fffd-CYaF3q1I.js} +1 -1
  26. package/client/dist/assets/{es-ES-U4NZUMDT-DLOIGnrl.js → es-ES-U4NZUMDT-CGeTKXgd.js} +1 -1
  27. package/client/dist/assets/{eu-ES-A7QVB2H4-LJXbf89m.js → eu-ES-A7QVB2H4-Cayx1TxR.js} +1 -1
  28. package/client/dist/assets/{fa-IR-HGAKTJCU-Dvx65fgW.js → fa-IR-HGAKTJCU-CmUg8pmw.js} +1 -1
  29. package/client/dist/assets/{fi-FI-Z5N7JZ37-EoL65BQh.js → fi-FI-Z5N7JZ37-xvHcPhsU.js} +1 -1
  30. package/client/dist/assets/{flowDb-956e92f1-HgoXVy2H.js → flowDb-956e92f1-C-_LFz70.js} +3 -3
  31. package/client/dist/assets/flowDiagram-66a62f08-C1sHdSjn.js +4 -0
  32. package/client/dist/assets/flowDiagram-v2-96b9c2cf-Cd0Iascd.js +1 -0
  33. package/client/dist/assets/{flowchart-elk-definition-4a651766-DJbI2dpv.js → flowchart-elk-definition-4a651766-CNGfpudb.js} +7 -7
  34. package/client/dist/assets/{fr-FR-RHASNOE6-DNk_jdDs.js → fr-FR-RHASNOE6-DBoHEcNj.js} +1 -1
  35. package/client/dist/assets/{ganttDiagram-c361ad54-2XX670FU.js → ganttDiagram-c361ad54-B8HJQqjt.js} +1 -1
  36. package/client/dist/assets/{gitGraphDiagram-72cf32ee-CcUfruAo.js → gitGraphDiagram-72cf32ee-DojCDvlS.js} +1 -1
  37. package/client/dist/assets/{gl-ES-HMX3MZ6V-dxzFjZlG.js → gl-ES-HMX3MZ6V-p6hrn2cN.js} +1 -1
  38. package/client/dist/assets/{graph-BSbiMSBC.js → graph-DXM7lcy1.js} +1 -1
  39. package/client/dist/assets/{he-IL-6SHJWFNN-Cogsfdt1.js → he-IL-6SHJWFNN-y2jEX6-0.js} +1 -1
  40. package/client/dist/assets/{hi-IN-IWLTKZ5I-L6wbgi4F.js → hi-IN-IWLTKZ5I-99pNfyWr.js} +1 -1
  41. package/client/dist/assets/{hu-HU-A5ZG7DT2-DSA6ZDsH.js → hu-HU-A5ZG7DT2-hygceGMS.js} +1 -1
  42. package/client/dist/assets/{id-ID-SAP4L64H-BK_vGGS6.js → id-ID-SAP4L64H-CyIqi1hv.js} +1 -1
  43. package/client/dist/assets/{image-blob-reduce.esm-BLtmMM_J.js → image-blob-reduce.esm-D6s-rqMO.js} +6 -1
  44. package/client/dist/assets/{index-3862675e-Bv32HUgT.js → index-3862675e-4idOQN2N.js} +1 -1
  45. package/client/dist/assets/{index-BPwf8Fw3.js → index-BGmwbRlb.js} +6 -6
  46. package/client/dist/assets/index-BHZfFT_V.js +97 -0
  47. package/client/dist/assets/{infoDiagram-f8f76790-w4mR4pxn.js → infoDiagram-f8f76790-CFLrHqtc.js} +1 -1
  48. package/client/dist/assets/{it-IT-JPQ66NNP-BLdHYMhn.js → it-IT-JPQ66NNP-DzVvVdQI.js} +1 -1
  49. package/client/dist/assets/{ja-JP-DBVTYXUO-B_vmexl_.js → ja-JP-DBVTYXUO-BI4fPexV.js} +1 -1
  50. package/client/dist/assets/{journeyDiagram-49397b02-D9nmO17e.js → journeyDiagram-49397b02-C3CFDo8z.js} +1 -1
  51. package/client/dist/assets/{kaa-6HZHGXH3-5s-3jl6F.js → kaa-6HZHGXH3-fwOleoQB.js} +1 -1
  52. package/client/dist/assets/{kab-KAB-ZGHBKWFO-2QaVDuSf.js → kab-KAB-ZGHBKWFO-DBI_ri48.js} +1 -1
  53. package/client/dist/assets/{kk-KZ-P5N5QNE5-CTC52Vbi.js → kk-KZ-P5N5QNE5-zpl7uvyF.js} +1 -1
  54. package/client/dist/assets/{km-KH-HSX4SM5Z-DxawH8UZ.js → km-KH-HSX4SM5Z-DOMFSres.js} +1 -1
  55. package/client/dist/assets/{ko-KR-MTYHY66A-CmosEM8_.js → ko-KR-MTYHY66A-tb08hXzd.js} +1 -1
  56. package/client/dist/assets/{ku-TR-6OUDTVRD-DbiLen4y.js → ku-TR-6OUDTVRD-DlIQCCY4.js} +1 -1
  57. package/client/dist/assets/{layout-jmt3H9tA.js → layout-B_11mCXA.js} +1 -1
  58. package/client/dist/assets/{line-JTlRayUJ.js → line-B-qmK_vI.js} +1 -1
  59. package/client/dist/assets/{linear-DJeB5p7x.js → linear-Ph6uuYcX.js} +1 -1
  60. package/client/dist/assets/{lt-LT-XHIRWOB4-CH15wrjA.js → lt-LT-XHIRWOB4--qWy24_Z.js} +1 -1
  61. package/client/dist/assets/{lv-LV-5QDEKY6T-dhgfPuCQ.js → lv-LV-5QDEKY6T-Bnd_1GDb.js} +1 -1
  62. package/client/dist/assets/mindmap-definition-fc14e90a-Do79tIc0.js +425 -0
  63. package/client/dist/assets/{mr-IN-CRQNXWMA-3Gi6iq7A.js → mr-IN-CRQNXWMA-BsV6HaD9.js} +1 -1
  64. package/client/dist/assets/{my-MM-5M5IBNSE-CpH4rdJj.js → my-MM-5M5IBNSE-kZQURVIi.js} +1 -1
  65. package/client/dist/assets/{nb-NO-T6EIAALU-Du6iiGql.js → nb-NO-T6EIAALU-Cvf9FdSF.js} +1 -1
  66. package/client/dist/assets/{nl-NL-IS3SIHDZ-BGvsd1MT.js → nl-NL-IS3SIHDZ-DA1yqpXw.js} +1 -1
  67. package/client/dist/assets/{nn-NO-6E72VCQL-B-odvJZW.js → nn-NO-6E72VCQL-89lm3vku.js} +1 -1
  68. package/client/dist/assets/{oc-FR-POXYY2M6-COC8xNjo.js → oc-FR-POXYY2M6-BsrjTJQh.js} +1 -1
  69. package/client/dist/assets/{pa-IN-N4M65BXN-CE21PUQH.js → pa-IN-N4M65BXN-CczefYaj.js} +1 -1
  70. package/client/dist/assets/pdf-CE_K4jFx.js +12 -0
  71. package/client/dist/assets/percentages-BXMCSKIN-Be6p9phi.js +207 -0
  72. package/client/dist/assets/pica-CQIY57Tf.js +7 -0
  73. package/client/dist/assets/{pieDiagram-8a3498a8-Cvfh7Qr5.js → pieDiagram-8a3498a8-CfblQHdm.js} +2 -2
  74. package/client/dist/assets/{pl-PL-T2D74RX3-D4xFVSoT.js → pl-PL-T2D74RX3-DdhH-zcK.js} +1 -1
  75. package/client/dist/assets/{pt-BR-5N22H2LF-CCq257gA.js → pt-BR-5N22H2LF-gpwlheL6.js} +1 -1
  76. package/client/dist/assets/{pt-PT-UZXXM6DQ-1l8gt5vA.js → pt-PT-UZXXM6DQ-Cs87vICi.js} +1 -1
  77. package/client/dist/assets/{quadrantDiagram-120e2f19-BA0js1aD.js → quadrantDiagram-120e2f19-CRMSamSP.js} +1 -1
  78. package/client/dist/assets/{requirementDiagram-deff3bca-B0QNFfIn.js → requirementDiagram-deff3bca-D3LBN016.js} +1 -1
  79. package/client/dist/assets/{ro-RO-JPDTUUEW-yosBW01E.js → ro-RO-JPDTUUEW-CWTSJ1Dt.js} +1 -1
  80. package/client/dist/assets/roundRect-0PYZxl1G.js +1 -0
  81. package/client/dist/assets/{ru-RU-B4JR7IUQ-8LkEJUix.js → ru-RU-B4JR7IUQ-Bq7aN2ep.js} +1 -1
  82. package/client/dist/assets/{sankeyDiagram-04a897e0-D4T9eCXn.js → sankeyDiagram-04a897e0-CsFqOQZN.js} +3 -3
  83. package/client/dist/assets/{sequenceDiagram-704730f1-CfBUTCrO.js → sequenceDiagram-704730f1-BRYXVDGX.js} +1 -1
  84. package/client/dist/assets/{si-LK-N5RQ5JYF-D8rjbqtd.js → si-LK-N5RQ5JYF-BBjcNYQh.js} +1 -1
  85. package/client/dist/assets/{sk-SK-C5VTKIMK-Bg14sAzN.js → sk-SK-C5VTKIMK-ByjKQzUb.js} +1 -1
  86. package/client/dist/assets/{sl-SI-NN7IZMDC-CMTib6Zs.js → sl-SI-NN7IZMDC-B8WCyMBU.js} +1 -1
  87. package/client/dist/assets/{stateDiagram-587899a1-BGgvmVSZ.js → stateDiagram-587899a1-BHoy9LtD.js} +1 -1
  88. package/client/dist/assets/{stateDiagram-v2-d93cdb3a-Qn3DpYuO.js → stateDiagram-v2-d93cdb3a-BvMUA6bS.js} +1 -1
  89. package/client/dist/assets/{styles-6aaf32cf-IdVZLPrD.js → styles-6aaf32cf-Dr-lfIOW.js} +2 -2
  90. package/client/dist/assets/{styles-9a916d00-BAC3L45X.js → styles-9a916d00-DS4wRpL7.js} +1 -1
  91. package/client/dist/assets/{styles-c10674c1-COhXxX8c.js → styles-c10674c1-nKRF6NrH.js} +1 -1
  92. package/client/dist/assets/{subset-shared.chunk-BWHnFai4.js → subset-shared.chunk-KT79s7KG.js} +64 -2
  93. package/client/dist/assets/subset-worker.chunk-BMx1eyv3.js +1 -0
  94. package/client/dist/assets/{sv-SE-XGPEYMSR-C1425rOF.js → sv-SE-XGPEYMSR-BiIPUVbv.js} +1 -1
  95. package/client/dist/assets/{svgDrawCommon-08f97a94-Cfk-fgnN.js → svgDrawCommon-08f97a94-C3uP9PYr.js} +1 -1
  96. package/client/dist/assets/{ta-IN-2NMHFXQM-BHHo1zpF.js → ta-IN-2NMHFXQM-Cidadso2.js} +1 -1
  97. package/client/dist/assets/{th-TH-HPSO5L25-CZVzm_WT.js → th-TH-HPSO5L25-CFNnJwSv.js} +1 -1
  98. package/client/dist/assets/{timeline-definition-85554ec2-VAvuJith.js → timeline-definition-85554ec2-BSsLsIgF.js} +1 -1
  99. package/client/dist/assets/{tr-TR-DEFEU3FU-DE1lclCq.js → tr-TR-DEFEU3FU-DaFcI-KL.js} +1 -1
  100. package/client/dist/assets/{uk-UA-QMV73CPH-D4lJZ85O.js → uk-UA-QMV73CPH-DkBW36St.js} +1 -1
  101. package/client/dist/assets/vendor-codemirror-langs-BH1ZcKHY.js +20 -0
  102. package/client/dist/assets/vendor-codemirror-rix45NST.js +16 -0
  103. package/client/dist/assets/vendor-i18n-DCFGyhQR.js +1 -0
  104. package/client/dist/assets/vendor-icons-Dh9m_Ydt.js +596 -0
  105. package/client/dist/assets/{vendor-markdown-CIVH08vJ.js → vendor-markdown-BXEi_H3G.js} +3 -3
  106. package/client/dist/assets/vendor-react-9mUTKBHH.js +67 -0
  107. package/client/dist/assets/{vendor-syntax-Djb62v3a.js → vendor-syntax-DnmwQQJF.js} +14 -7
  108. package/client/dist/assets/vendor-xterm-CZq1hqo1.js +66 -0
  109. package/client/dist/assets/vendor-xterm-qxJ8_QYu.css +32 -0
  110. package/client/dist/assets/{vi-VN-M7AON7JQ-Dgc_SShk.js → vi-VN-M7AON7JQ-KrtfxOzl.js} +1 -1
  111. package/client/dist/assets/{xychartDiagram-e933f94c-BeyVBJhb.js → xychartDiagram-e933f94c-CgNgZ4pp.js} +1 -1
  112. package/client/dist/assets/{zh-CN-LNUGB5OW-MH4Yh8in.js → zh-CN-LNUGB5OW-BQu12RoD.js} +1 -1
  113. package/client/dist/assets/{zh-HK-E62DVLB3-D4XHehjx.js → zh-HK-E62DVLB3-zx9CvERq.js} +1 -1
  114. package/client/dist/assets/{zh-TW-RAJ6MFWO--efj3evj.js → zh-TW-RAJ6MFWO-ffJWgVxn.js} +1 -1
  115. package/client/dist/index.html +128 -66
  116. package/client/dist/manifest.json +61 -15
  117. package/client/dist/sw.js +19 -55
  118. package/commands/upfynai-connect.md +31 -18
  119. package/commands/upfynai.md +45 -26
  120. package/package.json +1 -1
  121. package/server/cli-ui.js +320 -169
  122. package/server/cli.js +194 -21
  123. package/server/index.js +159 -107
  124. package/server/middleware/auth.js +9 -5
  125. package/server/openrouter.js +137 -0
  126. package/server/relay-client.js +104 -17
  127. package/server/routes/agent.js +54 -19
  128. package/server/routes/auth.js +23 -12
  129. package/server/routes/settings.js +91 -0
  130. package/shared/modelConstants.js +29 -0
  131. package/client/dist/assets/AppContent-CTSHQdyq.js +0 -513
  132. package/client/dist/assets/CanvasPanel-Cig0Mo9s.js +0 -6
  133. package/client/dist/assets/LoginModal-silya-zP.js +0 -11
  134. package/client/dist/assets/MarkdownPreview-B3c7OEj6.js +0 -1
  135. package/client/dist/assets/channel-CSnvHe_M.js +0 -1
  136. package/client/dist/assets/classDiagram-v2-f2320105-xtym7GEZ.js +0 -2
  137. package/client/dist/assets/clone-B75abXxS.js +0 -1
  138. package/client/dist/assets/flowDiagram-66a62f08-tffoET0H.js +0 -4
  139. package/client/dist/assets/flowDiagram-v2-96b9c2cf-Byc3JCHh.js +0 -1
  140. package/client/dist/assets/index-BnXuHrpJ.js +0 -523
  141. package/client/dist/assets/index-BwxNox94.css +0 -1
  142. package/client/dist/assets/index-D1urGMYu.js +0 -95
  143. package/client/dist/assets/mindmap-definition-fc14e90a-BOOrexmz.js +0 -415
  144. package/client/dist/assets/pdf-TYrZqVzP.js +0 -12
  145. package/client/dist/assets/percentages-BXMCSKIN-C9GT0OD3.js +0 -199
  146. package/client/dist/assets/pica-VkdyTzi8.js +0 -2
  147. package/client/dist/assets/roundRect-mAH3dD0p.js +0 -1
  148. package/client/dist/assets/subset-worker.chunk-C8QUSruZ.js +0 -1
  149. package/client/dist/assets/vendor-codemirror-BARtJV1V.js +0 -16
  150. package/client/dist/assets/vendor-codemirror-langs-52_y1wip.js +0 -20
  151. package/client/dist/assets/vendor-i18n-ByAl-gdx.js +0 -1
  152. package/client/dist/assets/vendor-icons-D33IkSIf.js +0 -1
  153. package/client/dist/assets/vendor-react-CHoMc7ka.js +0 -8
  154. package/client/dist/assets/vendor-xterm-DBb3RXlu.js +0 -66
  155. package/client/dist/assets/vendor-xterm-DrlLKa8f.css +0 -1
  156. package/client/dist/llms.txt +0 -40
  157. package/client/dist/robots.txt +0 -11
  158. package/client/dist/sitemap.xml +0 -45
@@ -1,513 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-B3c7OEj6.js","assets/vendor-react-CHoMc7ka.js","assets/vendor-markdown-CIVH08vJ.js","assets/vendor-syntax-Djb62v3a.js","assets/CanvasPanel-Cig0Mo9s.js","assets/vendor-icons-D33IkSIf.js","assets/CanvasPanel-q4HEqNtV.css"])))=>i.map(i=>d[i]);
2
- import{r as l,j as e,v as Et,e as Kr,g as Jn,u as xi,f as gi}from"./vendor-react-CHoMc7ka.js";import{d as Ge,e as ba,a as we,f as Or,l as _a,c as ya,h as yr,i as hi}from"./index-BPwf8Fw3.js";import{P as fi,f as Ve,d as Ft,g as Ra,R as Pt,h as tt,i as bi,j as sr,X as qe,k as as,l as ks,m as Br,n as Lr,T as ut,C as vt,o as yi,p as ft,q as Kt,r as Vt,s as za,t as _r,c as At,W as Yn,G as $t,K as va,b as mr,a as Qn,E as ar,u as Xn,v as ka,w as Oa,x as vi,L as ki,y as Lt,z as Tt,B as js,D as at,H as Rr,Z as ja,I as Zn,J as Ys,N as Qs,O as ji,Q as wi,V as wa,Y as ws,_ as eo,$ as ns,F as et,a0 as xr,a1 as Ni,a2 as is,a3 as Ci,a4 as to,a5 as Na,a6 as ro,a7 as ls,a8 as Si,a9 as Ei,aa as Ti,ab as Ii,ac as Gt,ad as Ar,ae as Xs,af as Zs,ag as ea,ah as Mr,ai as pr,aj as ta,ak as gr,al as ra,am as Pr,an as so,ao as lr,ap as cr,aq as Nr,ar as Cr,as as dr,at as Di,au as Bt,av as Ba,aw as Ai,ax as Wa,ay as Sr,az as Er,aA as Mi,aB as Pi,aC as Tr,aD as Ua,aE as Fi,aF as $i,aG as os,aH as Vr,aI as cs,aJ as Ha,aK as Ls,aL as Li,e as Ca,aM as _i,aN as ao,aO as no,aP as Ri,aQ as zi,aR as Oi,aS as Bi,aT as Wi,aU as Ui,aV as Hi,aW as Gi,aX as Ga,aY as qi}from"./vendor-icons-D33IkSIf.js";import{a as Ki,b as Vi,C as Ji,u as Ue,L as Yi,S as oo,c as Qi}from"./LoginModal-silya-zP.js";import{h as Xi,p as Zi,b as io}from"./vendor-syntax-Djb62v3a.js";import{a as el,b as tl,d as rl,M as sl}from"./vendor-markdown-CIVH08vJ.js";import{F as lo,E as qt,S as al,V as Sa,y as hr,z as nl,A as ol,B as il,D as ll,G as cl,H as dl,I as ul,J as ml,K as pl,M as _s,N as xl,R as co,O as uo,Q as gl,T as hl}from"./vendor-codemirror-BARtJV1V.js";import{d as qa,h as Ka,m as mo,j as fl,e as bl,f as yl,p as vl,g as kl}from"./vendor-codemirror-langs-52_y1wip.js";const Va=t=>typeof window>"u"?!1:window.innerWidth<t,Ja=()=>{if(typeof window>"u")return!1;const t=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!t.standalone||document.referrer.includes("android-app://")};function Ea(t={}){const{mobileBreakpoint:r=768,trackMobile:s=!0,trackPWA:a=!0}=t,[n,o]=l.useState(()=>s?Va(r):!1),[i,c]=l.useState(()=>a?Ja():!1);return l.useEffect(()=>{if(!s||typeof window>"u")return;const u=()=>{o(Va(r))};return u(),window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}},[r,s]),l.useEffect(()=>{if(!a||typeof window>"u")return;const u=window.matchMedia("(display-mode: standalone)"),d=()=>{c(Ja())};return d(),typeof u.addEventListener=="function"?(u.addEventListener("change",d),()=>{u.removeEventListener("change",d)}):(u.addListener(d),()=>{u.removeListener(d)})},[a]),{isMobile:n,isPWA:i}}const Ya="2.0.0",jl=(t,r)=>{const s=t.split(".").map(Number),a=r.split(".").map(Number);for(let n=0;n<Math.max(s.length,a.length);n++){const o=s[n]||0,i=a[n]||0;if(o!==i)return o-i}return 0},po=(t,r)=>{const[s,a]=l.useState(!1),[n,o]=l.useState(null),[i,c]=l.useState(null);return l.useEffect(()=>{const u=async()=>{try{const p=await(await fetch(`https://api.github.com/repos/${t}/${r}/releases/latest`)).json();if(p.tag_name){const x=p.tag_name.replace(/^v/,"");o(x),a(jl(x,Ya)>0),c({title:p.name||p.tag_name,body:p.body||"",htmlUrl:p.html_url||`https://github.com/${t}/${r}/releases/latest`,publishedAt:p.published_at})}else a(!1),o(null),c(null)}catch(m){console.error("Version check failed:",m),a(!1),o(null),c(null)}};u();const d=setInterval(u,300*1e3);return()=>clearInterval(d)},[t,r]),{updateAvailable:s,latestVersion:n,currentVersion:Ya,releaseInfo:i}},er={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0},ds=Object.keys(er),wl=new Set(ds),Rs="ui-preferences:sync",us=(t,r)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return r},Nl=(t,r)=>{try{const s=localStorage.getItem(t);if(s===null)return r;const a=JSON.parse(s);return us(a,r)}catch{return r}},Cl=t=>{if(typeof window>"u")return er;try{const r=localStorage.getItem(t);if(r){const s=JSON.parse(r);if(s&&typeof s=="object"&&!Array.isArray(s)){const a=s;return ds.reduce((n,o)=>(n[o]=us(a[o],er[o]),n),{...er})}}}catch{}return ds.reduce((r,s)=>(r[s]=Nl(s,er[s]),r),{...er})};function Sl(t,r){switch(r.type){case"set":{const{key:s,value:a}=r;if(!wl.has(s))return t;const n=us(a,t[s]);return t[s]===n?t:{...t,[s]:n}}case"set_many":{const s=r.value||{};let a=!1;const n={...t};for(const o of ds){if(!(o in s))continue;const i=s[o],c=us(i,t[o]);n[o]!==c&&(n[o]=c,a=!0)}return a?n:t}case"reset":return{...er,...r.value||{}};default:return t}}function Ta(t="uiPreferences"){const r=l.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[s,a]=l.useReducer(Sl,t,Cl);return l.useEffect(()=>{typeof window>"u"||(localStorage.setItem(t,JSON.stringify(s)),window.dispatchEvent(new CustomEvent(Rs,{detail:{storageKey:t,sourceId:r.current,value:s}})))},[s,t]),l.useEffect(()=>{if(typeof window>"u")return;const c=m=>{!m||typeof m!="object"||Array.isArray(m)||a({type:"set_many",value:m})},u=m=>{if(!(m.key!==t||m.newValue===null))try{const p=JSON.parse(m.newValue);c(p)}catch{}},d=m=>{const x=m.detail;!x||x.storageKey!==t||x.sourceId===r.current||c(x.value)};return window.addEventListener("storage",u),window.addEventListener(Rs,d),()=>{window.removeEventListener("storage",u),window.removeEventListener(Rs,d)}},[t]),{preferences:s,setPreference:(c,u)=>{a({type:"set",key:c,value:u})},setPreferences:c=>{a({type:"set_many",value:c})},resetPreferences:c=>{a({type:"reset",value:c})},dispatch:a}}const El=()=>{try{const t=localStorage.getItem("claude-settings");return t&&JSON.parse(t).projectSortOrder==="date"?"date":"name"}catch{return"name"}},Tl=()=>{try{const t=localStorage.getItem("starredProjects");return t?new Set(JSON.parse(t)):new Set}catch{return new Set}},Il=t=>{try{localStorage.setItem("starredProjects",JSON.stringify([...t]))}catch{}},ms=t=>t.__provider==="cursor"?new Date(t.createdAt||0):t.__provider==="codex"?new Date(t.createdAt||t.lastActivity||0):new Date(t.lastActivity||0),Dl=(t,r)=>t.__provider==="cursor"?t.name||r("projects.untitledSession"):t.__provider==="codex"?t.summary||t.name||r("projects.codexSession"):t.summary||r("projects.newSession"),Al=t=>t.__provider==="cursor"?String(t.createdAt||""):t.__provider==="codex"?String(t.createdAt||t.lastActivity||""):String(t.lastActivity||""),Ml=(t,r,s)=>{const a=ms(t),n=Math.floor((r.getTime()-a.getTime())/(1e3*60));return{isCursorSession:t.__provider==="cursor",isCodexSession:t.__provider==="codex",isActive:n<10,sessionName:Dl(t,s),sessionTime:Al(t),messageCount:Number(t.messageCount||0)}},xo=(t,r)=>{const s=[...t.sessions||[],...r[t.name]||[]].map(o=>({...o,__provider:"claude"})),a=(t.cursorSessions||[]).map(o=>({...o,__provider:"cursor"})),n=(t.codexSessions||[]).map(o=>({...o,__provider:"codex"}));return[...s,...a,...n].sort((o,i)=>ms(i).getTime()-ms(o).getTime())},Qa=(t,r)=>{const s=xo(t,r);return s.length===0?new Date(0):s.reduce((a,n)=>{const o=ms(n);return o>a?o:a},new Date(0))},Pl=(t,r,s,a)=>{const n=[...t];return n.sort((o,i)=>{const c=s.has(o.name),u=s.has(i.name);return c&&!u?-1:!c&&u?1:r==="date"?Qa(i,a).getTime()-Qa(o,a).getTime():(o.displayName||o.name).localeCompare(i.displayName||i.name)}),n},Fl=(t,r)=>{const s=r.trim().toLowerCase();return s?t.filter(a=>{const n=(a.displayName||a.name).toLowerCase(),o=a.name.toLowerCase();return n.includes(s)||o.includes(s)}):t},$l=(t,r)=>{const s=!!t.taskmaster?.hasTaskmaster,a=!!(r?.hasMCPServer&&r?.isConfigured);return s&&a?"fully-configured":s?"taskmaster-only":a?"mcp-only":"not-configured"},Ll=t=>{const r=typeof t.fullPath=="string"&&t.fullPath.length>0?t.fullPath:typeof t.path=="string"?t.path:"";return{name:t.name,displayName:typeof t.displayName=="string"&&t.displayName.trim().length>0?t.displayName:t.name,fullPath:r,path:typeof t.path=="string"&&t.path.length>0?t.path:r}};function _l({projects:t,selectedProject:r,selectedSession:s,isLoading:a,isMobile:n,t:o,onRefresh:i,onProjectSelect:c,onSessionSelect:u,onSessionDelete:d,onProjectDelete:m,setCurrentProject:p,setSidebarVisible:x,sidebarVisible:h}){const[f,g]=l.useState(new Set),[k,w]=l.useState(null),[S,y]=l.useState(!1),[v,T]=l.useState(""),[z,I]=l.useState({}),[F,B]=l.useState({}),[D,H]=l.useState(new Set),[$,R]=l.useState(new Date),[E,U]=l.useState("name"),[j,_]=l.useState(!1),[V,ee]=l.useState({}),[M,G]=l.useState(null),[C,b]=l.useState(""),[N,W]=l.useState(""),[A,O]=l.useState(new Set),[q,Z]=l.useState(null),[J,Q]=l.useState(null),[le,ae]=l.useState(!1),[fe,Ee]=l.useState(()=>Tl()),Pe=!n&&!h;l.useEffect(()=>{const re=setInterval(()=>{R(new Date)},6e4);return()=>clearInterval(re)},[]),l.useEffect(()=>{B({}),H(new Set),ee({})},[t]),l.useEffect(()=>{r&&g(re=>{if(re.has(r.name))return re;const ce=new Set(re);return ce.add(r.name),ce})},[s,r]),l.useEffect(()=>{if(t.length>0&&!a){const re=new Set;t.forEach(ce=>{ce.sessions&&ce.sessions.length>=0&&re.add(ce.name)}),H(re)}},[t,a]),l.useEffect(()=>{const re=()=>{U(El())};re();const ce=Oe=>{Oe.key==="claude-settings"&&re()};window.addEventListener("storage",ce);const Le=setInterval(()=>{document.hasFocus()&&re()},1e3);return()=>{window.removeEventListener("storage",ce),clearInterval(Le)}},[]);const He=l.useCallback(re=>ce=>{const Le=ce.target;Le.closest(".overflow-y-auto")||Le.closest("[data-scroll-container]")||(ce.preventDefault(),ce.stopPropagation(),re())},[]),Te=l.useCallback(re=>{g(ce=>{const Le=new Set;return ce.has(re)||Le.add(re),Le})},[]),be=l.useCallback((re,ce)=>{u({...re,__projectName:ce})},[u]),Ae=l.useCallback(re=>{Ee(ce=>{const Le=new Set(ce);return Le.has(re)?Le.delete(re):Le.add(re),Il(Le),Le})},[]),Re=l.useCallback(re=>fe.has(re),[fe]),X=l.useCallback(re=>xo(re,F),[F]),Ce=l.useMemo(()=>t.map(re=>{const ce=V[re.name];return ce===void 0?re:{...re,sessionMeta:{...re.sessionMeta,hasMore:ce}}}),[V,t]),xe=l.useMemo(()=>Pl(Ce,E,fe,F),[F,E,Ce,fe]),te=l.useMemo(()=>Fl(xe,N),[N,xe]),se=l.useCallback(re=>{w(re.name),T(re.displayName)},[]),ke=l.useCallback(()=>{w(null),T("")},[]),Ne=l.useCallback(async re=>{try{(await Ge.renameProject(re,v)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(ce){console.error("Error renaming project:",ce)}finally{w(null),T("")}},[v]),Ie=l.useCallback((re,ce,Le,Oe="claude")=>{Q({projectName:re,sessionId:ce,sessionTitle:Le,provider:Oe})},[]),Ke=l.useCallback(async()=>{if(!J)return;const{projectName:re,sessionId:ce,provider:Le}=J;Q(null);try{const Oe=Le==="codex"?await Ge.deleteCodexSession(ce):await Ge.deleteSession(re,ce);if(Oe.ok)d?.(ce);else{const st=await Oe.text();console.error("[Sidebar] Failed to delete session:",{status:Oe.status,error:st}),alert(o("messages.deleteSessionFailed"))}}catch(Oe){console.error("[Sidebar] Error deleting session:",Oe),alert(o("messages.deleteSessionError"))}},[d,J,o]),Be=l.useCallback(re=>{Z({project:re,sessionCount:X(re).length})},[X]),rt=l.useCallback(async()=>{if(!q)return;const{project:re,sessionCount:ce}=q,Le=ce===0;Z(null),O(Oe=>new Set([...Oe,re.name]));try{const Oe=await Ge.deleteProject(re.name,!Le);if(Oe.ok)m?.(re.name);else{const st=await Oe.json();alert(st.error||o("messages.deleteProjectFailed"))}}catch(Oe){console.error("Error deleting project:",Oe),alert(o("messages.deleteProjectError"))}finally{O(Oe=>{const st=new Set(Oe);return st.delete(re.name),st})}},[q,m,o]),ue=l.useCallback(async re=>{const ce=V[re.name];if(!(!(ce!==void 0?ce:re.sessionMeta?.hasMore===!0)||z[re.name])){I(Oe=>({...Oe,[re.name]:!0}));try{const Oe=(re.sessions?.length||0)+(F[re.name]?.length||0),st=await Ge.sessions(re.name,5,Oe);if(!st.ok)return;const kt=await st.json();B(bt=>({...bt,[re.name]:[...bt[re.name]||[],...kt.sessions||[]]})),kt.hasMore===!1&&ee(bt=>({...bt,[re.name]:!1}))}catch(Oe){console.error("Error loading more sessions:",Oe)}finally{I(Oe=>({...Oe,[re.name]:!1}))}}},[F,z,V]),De=l.useCallback(re=>{c(re),p(re)},[c,p]),je=l.useCallback(async()=>{_(!0);try{await i()}finally{_(!1)}},[i]),$e=l.useCallback(async(re,ce,Le)=>{G(null),b("")},[]),ze=l.useCallback(()=>{x(!1)},[x]),Fe=l.useCallback(()=>{x(!0)},[x]);return{isSidebarCollapsed:Pe,expandedProjects:f,editingProject:k,showNewProject:S,editingName:v,loadingSessions:z,additionalSessions:F,initialSessionsLoaded:D,currentTime:$,projectSortOrder:E,isRefreshing:j,editingSession:M,editingSessionName:C,searchFilter:N,deletingProjects:A,deleteConfirmation:q,sessionDeleteConfirmation:J,showVersionModal:le,starredProjects:fe,filteredProjects:te,handleTouchClick:He,toggleProject:Te,handleSessionClick:be,toggleStarProject:Ae,isProjectStarred:Re,getProjectSessions:X,startEditing:se,cancelEditing:ke,saveProjectName:Ne,showDeleteSessionConfirmation:Ie,confirmDeleteSession:Ke,requestProjectDelete:Be,confirmDeleteProject:rt,loadMoreSessions:ue,handleProjectSelect:De,refreshProjects:je,updateSessionSummary:$e,collapseSidebar:ze,expandSidebar:Fe,setShowNewProject:y,setEditingName:T,setEditingSession:G,setEditingSessionName:b,setSearchFilter:W,setDeleteConfirmation:Z,setSessionDeleteConfirmation:Q,setShowVersionModal:ae}}function Rl({onExpand:t,onShowSettings:r,updateAvailable:s,onShowVersionModal:a,t:n}){return e.jsxs("div",{className:"h-full flex flex-col items-center py-3 gap-1 bg-background/80 backdrop-blur-sm w-12",children:[e.jsx("button",{onClick:t,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("common:versionUpdate.ariaLabels.showSidebar"),title:n("common:versionUpdate.ariaLabels.showSidebar"),children:e.jsx(fi,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),e.jsx("div",{className:"nav-divider w-6 my-1"}),e.jsx("button",{onClick:r,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("actions.settings"),title:n("actions.settings"),children:e.jsx(Ve,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),s&&e.jsxs("button",{onClick:a,className:"relative w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors","aria-label":n("common:versionUpdate.ariaLabels.updateAvailable"),title:n("common:versionUpdate.ariaLabels.updateAvailable"),children:[e.jsx(Ft,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]})]})}function go(t){var r,s,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(r=0;r<n;r++)t[r]&&(s=go(t[r]))&&(a&&(a+=" "),a+=s)}else for(s in t)t[s]&&(a&&(a+=" "),a+=s);return a}function ho(){for(var t,r,s=0,a="",n=arguments.length;s<n;s++)(t=arguments[s])&&(r=go(t))&&(a&&(a+=" "),a+=r);return a}const zl=(t,r)=>{const s=new Array(t.length+r.length);for(let a=0;a<t.length;a++)s[a]=t[a];for(let a=0;a<r.length;a++)s[t.length+a]=r[a];return s},Ol=(t,r)=>({classGroupId:t,validator:r}),fo=(t=new Map,r=null,s)=>({nextPart:t,validators:r,classGroupId:s}),ps="-",Xa=[],Bl="arbitrary..",Wl=t=>{const r=Hl(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Ul(i);const c=i.split(ps),u=c[0]===""&&c.length>1?1:0;return bo(c,u,r)},getConflictingClassGroupIds:(i,c)=>{if(c){const u=a[i],d=s[i];return u?d?zl(d,u):u:d||Xa}return s[i]||Xa}}},bo=(t,r,s)=>{if(t.length-r===0)return s.classGroupId;const n=t[r],o=s.nextPart.get(n);if(o){const d=bo(t,r+1,o);if(d)return d}const i=s.validators;if(i===null)return;const c=r===0?t.join(ps):t.slice(r).join(ps),u=i.length;for(let d=0;d<u;d++){const m=i[d];if(m.validator(c))return m.classGroupId}},Ul=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=t.slice(1,-1),s=r.indexOf(":"),a=r.slice(0,s);return a?Bl+a:void 0})(),Hl=t=>{const{theme:r,classGroups:s}=t;return Gl(s,r)},Gl=(t,r)=>{const s=fo();for(const a in t){const n=t[a];Ia(n,s,a,r)}return s},Ia=(t,r,s,a)=>{const n=t.length;for(let o=0;o<n;o++){const i=t[o];ql(i,r,s,a)}},ql=(t,r,s,a)=>{if(typeof t=="string"){Kl(t,r,s);return}if(typeof t=="function"){Vl(t,r,s,a);return}Jl(t,r,s,a)},Kl=(t,r,s)=>{const a=t===""?r:yo(r,t);a.classGroupId=s},Vl=(t,r,s,a)=>{if(Yl(t)){Ia(t(a),r,s,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Ol(s,t))},Jl=(t,r,s,a)=>{const n=Object.entries(t),o=n.length;for(let i=0;i<o;i++){const[c,u]=n[i];Ia(u,yo(r,c),s,a)}},yo=(t,r)=>{let s=t;const a=r.split(ps),n=a.length;for(let o=0;o<n;o++){const i=a[o];let c=s.nextPart.get(i);c||(c=fo(),s.nextPart.set(i,c)),s=c}return s},Yl=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,Ql=t=>{if(t<1)return{get:()=>{},set:()=>{}};let r=0,s=Object.create(null),a=Object.create(null);const n=(o,i)=>{s[o]=i,r++,r>t&&(r=0,a=s,s=Object.create(null))};return{get(o){let i=s[o];if(i!==void 0)return i;if((i=a[o])!==void 0)return n(o,i),i},set(o,i){o in s?s[o]=i:n(o,i)}}},sa="!",Za=":",Xl=[],en=(t,r,s,a,n)=>({modifiers:t,hasImportantModifier:r,baseClassName:s,maybePostfixModifierPosition:a,isExternal:n}),Zl=t=>{const{prefix:r,experimentalParseClassName:s}=t;let a=n=>{const o=[];let i=0,c=0,u=0,d;const m=n.length;for(let g=0;g<m;g++){const k=n[g];if(i===0&&c===0){if(k===Za){o.push(n.slice(u,g)),u=g+1;continue}if(k==="/"){d=g;continue}}k==="["?i++:k==="]"?i--:k==="("?c++:k===")"&&c--}const p=o.length===0?n:n.slice(u);let x=p,h=!1;p.endsWith(sa)?(x=p.slice(0,-1),h=!0):p.startsWith(sa)&&(x=p.slice(1),h=!0);const f=d&&d>u?d-u:void 0;return en(o,h,x,f)};if(r){const n=r+Za,o=a;a=i=>i.startsWith(n)?o(i.slice(n.length)):en(Xl,!1,i,void 0,!0)}if(s){const n=a;a=o=>s({className:o,parseClassName:n})}return a},ec=t=>{const r=new Map;return t.orderSensitiveModifiers.forEach((s,a)=>{r.set(s,1e6+a)}),s=>{const a=[];let n=[];for(let o=0;o<s.length;o++){const i=s[o],c=i[0]==="[",u=r.has(i);c||u?(n.length>0&&(n.sort(),a.push(...n),n=[]),a.push(i)):n.push(i)}return n.length>0&&(n.sort(),a.push(...n)),a}},tc=t=>({cache:Ql(t.cacheSize),parseClassName:Zl(t),sortModifiers:ec(t),...Wl(t)}),rc=/\s+/,sc=(t,r)=>{const{parseClassName:s,getClassGroupId:a,getConflictingClassGroupIds:n,sortModifiers:o}=r,i=[],c=t.trim().split(rc);let u="";for(let d=c.length-1;d>=0;d-=1){const m=c[d],{isExternal:p,modifiers:x,hasImportantModifier:h,baseClassName:f,maybePostfixModifierPosition:g}=s(m);if(p){u=m+(u.length>0?" "+u:u);continue}let k=!!g,w=a(k?f.substring(0,g):f);if(!w){if(!k){u=m+(u.length>0?" "+u:u);continue}if(w=a(f),!w){u=m+(u.length>0?" "+u:u);continue}k=!1}const S=x.length===0?"":x.length===1?x[0]:o(x).join(":"),y=h?S+sa:S,v=y+w;if(i.indexOf(v)>-1)continue;i.push(v);const T=n(w,k);for(let z=0;z<T.length;++z){const I=T[z];i.push(y+I)}u=m+(u.length>0?" "+u:u)}return u},ac=(...t)=>{let r=0,s,a,n="";for(;r<t.length;)(s=t[r++])&&(a=vo(s))&&(n&&(n+=" "),n+=a);return n},vo=t=>{if(typeof t=="string")return t;let r,s="";for(let a=0;a<t.length;a++)t[a]&&(r=vo(t[a]))&&(s&&(s+=" "),s+=r);return s},nc=(t,...r)=>{let s,a,n,o;const i=u=>{const d=r.reduce((m,p)=>p(m),t());return s=tc(d),a=s.cache.get,n=s.cache.set,o=c,c(u)},c=u=>{const d=a(u);if(d)return d;const m=sc(u,s);return n(u,m),m};return o=i,(...u)=>o(ac(...u))},oc=[],Ze=t=>{const r=s=>s[t]||oc;return r.isThemeGetter=!0,r},ko=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,jo=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ic=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,lc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,cc=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,dc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,uc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,mc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Wt=t=>ic.test(t),_e=t=>!!t&&!Number.isNaN(Number(t)),Ut=t=>!!t&&Number.isInteger(Number(t)),zs=t=>t.endsWith("%")&&_e(t.slice(0,-1)),Mt=t=>lc.test(t),wo=()=>!0,pc=t=>cc.test(t)&&!dc.test(t),Da=()=>!1,xc=t=>uc.test(t),gc=t=>mc.test(t),hc=t=>!pe(t)&&!ge(t),fc=t=>Jt(t,So,Da),pe=t=>ko.test(t),Zt=t=>Jt(t,Eo,pc),tn=t=>Jt(t,Cc,_e),bc=t=>Jt(t,Io,wo),yc=t=>Jt(t,To,Da),rn=t=>Jt(t,No,Da),vc=t=>Jt(t,Co,gc),Jr=t=>Jt(t,Do,xc),ge=t=>jo.test(t),Ir=t=>nr(t,Eo),kc=t=>nr(t,To),sn=t=>nr(t,No),jc=t=>nr(t,So),wc=t=>nr(t,Co),Yr=t=>nr(t,Do,!0),Nc=t=>nr(t,Io,!0),Jt=(t,r,s)=>{const a=ko.exec(t);return a?a[1]?r(a[1]):s(a[2]):!1},nr=(t,r,s=!1)=>{const a=jo.exec(t);return a?a[1]?r(a[1]):s:!1},No=t=>t==="position"||t==="percentage",Co=t=>t==="image"||t==="url",So=t=>t==="length"||t==="size"||t==="bg-size",Eo=t=>t==="length",Cc=t=>t==="number",To=t=>t==="family-name",Io=t=>t==="number"||t==="weight",Do=t=>t==="shadow",Sc=()=>{const t=Ze("color"),r=Ze("font"),s=Ze("text"),a=Ze("font-weight"),n=Ze("tracking"),o=Ze("leading"),i=Ze("breakpoint"),c=Ze("container"),u=Ze("spacing"),d=Ze("radius"),m=Ze("shadow"),p=Ze("inset-shadow"),x=Ze("text-shadow"),h=Ze("drop-shadow"),f=Ze("blur"),g=Ze("perspective"),k=Ze("aspect"),w=Ze("ease"),S=Ze("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],T=()=>[...v(),ge,pe],z=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto","contain","none"],F=()=>[ge,pe,u],B=()=>[Wt,"full","auto",...F()],D=()=>[Ut,"none","subgrid",ge,pe],H=()=>["auto",{span:["full",Ut,ge,pe]},Ut,ge,pe],$=()=>[Ut,"auto",ge,pe],R=()=>["auto","min","max","fr",ge,pe],E=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],U=()=>["start","end","center","stretch","center-safe","end-safe"],j=()=>["auto",...F()],_=()=>[Wt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...F()],V=()=>[Wt,"screen","full","dvw","lvw","svw","min","max","fit",...F()],ee=()=>[Wt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...F()],M=()=>[t,ge,pe],G=()=>[...v(),sn,rn,{position:[ge,pe]}],C=()=>["no-repeat",{repeat:["","x","y","space","round"]}],b=()=>["auto","cover","contain",jc,fc,{size:[ge,pe]}],N=()=>[zs,Ir,Zt],W=()=>["","none","full",d,ge,pe],A=()=>["",_e,Ir,Zt],O=()=>["solid","dashed","dotted","double"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Z=()=>[_e,zs,sn,rn],J=()=>["","none",f,ge,pe],Q=()=>["none",_e,ge,pe],le=()=>["none",_e,ge,pe],ae=()=>[_e,ge,pe],fe=()=>[Wt,"full",...F()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Mt],breakpoint:[Mt],color:[wo],container:[Mt],"drop-shadow":[Mt],ease:["in","out","in-out"],font:[hc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Mt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Mt],shadow:[Mt],spacing:["px",_e],text:[Mt],"text-shadow":[Mt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Wt,pe,ge,k]}],container:["container"],columns:[{columns:[_e,pe,ge,c]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:T()}],overflow:[{overflow:z()}],"overflow-x":[{"overflow-x":z()}],"overflow-y":[{"overflow-y":z()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:B()}],"inset-x":[{"inset-x":B()}],"inset-y":[{"inset-y":B()}],start:[{"inset-s":B(),start:B()}],end:[{"inset-e":B(),end:B()}],"inset-bs":[{"inset-bs":B()}],"inset-be":[{"inset-be":B()}],top:[{top:B()}],right:[{right:B()}],bottom:[{bottom:B()}],left:[{left:B()}],visibility:["visible","invisible","collapse"],z:[{z:[Ut,"auto",ge,pe]}],basis:[{basis:[Wt,"full","auto",c,...F()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[_e,Wt,"auto","initial","none",pe]}],grow:[{grow:["",_e,ge,pe]}],shrink:[{shrink:["",_e,ge,pe]}],order:[{order:[Ut,"first","last","none",ge,pe]}],"grid-cols":[{"grid-cols":D()}],"col-start-end":[{col:H()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":D()}],"row-start-end":[{row:H()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:F()}],"gap-x":[{"gap-x":F()}],"gap-y":[{"gap-y":F()}],"justify-content":[{justify:[...E(),"normal"]}],"justify-items":[{"justify-items":[...U(),"normal"]}],"justify-self":[{"justify-self":["auto",...U()]}],"align-content":[{content:["normal",...E()]}],"align-items":[{items:[...U(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...U(),{baseline:["","last"]}]}],"place-content":[{"place-content":E()}],"place-items":[{"place-items":[...U(),"baseline"]}],"place-self":[{"place-self":["auto",...U()]}],p:[{p:F()}],px:[{px:F()}],py:[{py:F()}],ps:[{ps:F()}],pe:[{pe:F()}],pbs:[{pbs:F()}],pbe:[{pbe:F()}],pt:[{pt:F()}],pr:[{pr:F()}],pb:[{pb:F()}],pl:[{pl:F()}],m:[{m:j()}],mx:[{mx:j()}],my:[{my:j()}],ms:[{ms:j()}],me:[{me:j()}],mbs:[{mbs:j()}],mbe:[{mbe:j()}],mt:[{mt:j()}],mr:[{mr:j()}],mb:[{mb:j()}],ml:[{ml:j()}],"space-x":[{"space-x":F()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":F()}],"space-y-reverse":["space-y-reverse"],size:[{size:_()}],"inline-size":[{inline:["auto",...V()]}],"min-inline-size":[{"min-inline":["auto",...V()]}],"max-inline-size":[{"max-inline":["none",...V()]}],"block-size":[{block:["auto",...ee()]}],"min-block-size":[{"min-block":["auto",...ee()]}],"max-block-size":[{"max-block":["none",...ee()]}],w:[{w:[c,"screen",..._()]}],"min-w":[{"min-w":[c,"screen","none",..._()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},..._()]}],h:[{h:["screen","lh",..._()]}],"min-h":[{"min-h":["screen","lh","none",..._()]}],"max-h":[{"max-h":["screen","lh",..._()]}],"font-size":[{text:["base",s,Ir,Zt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Nc,bc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",zs,pe]}],"font-family":[{font:[kc,yc,r]}],"font-features":[{"font-features":[pe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,ge,pe]}],"line-clamp":[{"line-clamp":[_e,"none",ge,tn]}],leading:[{leading:[o,...F()]}],"list-image":[{"list-image":["none",ge,pe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ge,pe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...O(),"wavy"]}],"text-decoration-thickness":[{decoration:[_e,"from-font","auto",ge,Zt]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[_e,"auto",ge,pe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ge,pe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ge,pe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:G()}],"bg-repeat":[{bg:C()}],"bg-size":[{bg:b()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ut,ge,pe],radial:["",ge,pe],conic:[Ut,ge,pe]},wc,vc]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:N()}],"gradient-via-pos":[{via:N()}],"gradient-to-pos":[{to:N()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:W()}],"rounded-s":[{"rounded-s":W()}],"rounded-e":[{"rounded-e":W()}],"rounded-t":[{"rounded-t":W()}],"rounded-r":[{"rounded-r":W()}],"rounded-b":[{"rounded-b":W()}],"rounded-l":[{"rounded-l":W()}],"rounded-ss":[{"rounded-ss":W()}],"rounded-se":[{"rounded-se":W()}],"rounded-ee":[{"rounded-ee":W()}],"rounded-es":[{"rounded-es":W()}],"rounded-tl":[{"rounded-tl":W()}],"rounded-tr":[{"rounded-tr":W()}],"rounded-br":[{"rounded-br":W()}],"rounded-bl":[{"rounded-bl":W()}],"border-w":[{border:A()}],"border-w-x":[{"border-x":A()}],"border-w-y":[{"border-y":A()}],"border-w-s":[{"border-s":A()}],"border-w-e":[{"border-e":A()}],"border-w-bs":[{"border-bs":A()}],"border-w-be":[{"border-be":A()}],"border-w-t":[{"border-t":A()}],"border-w-r":[{"border-r":A()}],"border-w-b":[{"border-b":A()}],"border-w-l":[{"border-l":A()}],"divide-x":[{"divide-x":A()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":A()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...O(),"hidden","none"]}],"divide-style":[{divide:[...O(),"hidden","none"]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...O(),"none","hidden"]}],"outline-offset":[{"outline-offset":[_e,ge,pe]}],"outline-w":[{outline:["",_e,Ir,Zt]}],"outline-color":[{outline:M()}],shadow:[{shadow:["","none",m,Yr,Jr]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":["none",p,Yr,Jr]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:A()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[_e,Zt]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":A()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":["none",x,Yr,Jr]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[_e,ge,pe]}],"mix-blend":[{"mix-blend":[...q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":q()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[_e]}],"mask-image-linear-from-pos":[{"mask-linear-from":Z()}],"mask-image-linear-to-pos":[{"mask-linear-to":Z()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":Z()}],"mask-image-t-to-pos":[{"mask-t-to":Z()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":Z()}],"mask-image-r-to-pos":[{"mask-r-to":Z()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":Z()}],"mask-image-b-to-pos":[{"mask-b-to":Z()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":Z()}],"mask-image-l-to-pos":[{"mask-l-to":Z()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":Z()}],"mask-image-x-to-pos":[{"mask-x-to":Z()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":Z()}],"mask-image-y-to-pos":[{"mask-y-to":Z()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[ge,pe]}],"mask-image-radial-from-pos":[{"mask-radial-from":Z()}],"mask-image-radial-to-pos":[{"mask-radial-to":Z()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[_e]}],"mask-image-conic-from-pos":[{"mask-conic-from":Z()}],"mask-image-conic-to-pos":[{"mask-conic-to":Z()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:G()}],"mask-repeat":[{mask:C()}],"mask-size":[{mask:b()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ge,pe]}],filter:[{filter:["","none",ge,pe]}],blur:[{blur:J()}],brightness:[{brightness:[_e,ge,pe]}],contrast:[{contrast:[_e,ge,pe]}],"drop-shadow":[{"drop-shadow":["","none",h,Yr,Jr]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:["",_e,ge,pe]}],"hue-rotate":[{"hue-rotate":[_e,ge,pe]}],invert:[{invert:["",_e,ge,pe]}],saturate:[{saturate:[_e,ge,pe]}],sepia:[{sepia:["",_e,ge,pe]}],"backdrop-filter":[{"backdrop-filter":["","none",ge,pe]}],"backdrop-blur":[{"backdrop-blur":J()}],"backdrop-brightness":[{"backdrop-brightness":[_e,ge,pe]}],"backdrop-contrast":[{"backdrop-contrast":[_e,ge,pe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",_e,ge,pe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[_e,ge,pe]}],"backdrop-invert":[{"backdrop-invert":["",_e,ge,pe]}],"backdrop-opacity":[{"backdrop-opacity":[_e,ge,pe]}],"backdrop-saturate":[{"backdrop-saturate":[_e,ge,pe]}],"backdrop-sepia":[{"backdrop-sepia":["",_e,ge,pe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":F()}],"border-spacing-x":[{"border-spacing-x":F()}],"border-spacing-y":[{"border-spacing-y":F()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ge,pe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[_e,"initial",ge,pe]}],ease:[{ease:["linear","initial",w,ge,pe]}],delay:[{delay:[_e,ge,pe]}],animate:[{animate:["none",S,ge,pe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,ge,pe]}],"perspective-origin":[{"perspective-origin":T()}],rotate:[{rotate:Q()}],"rotate-x":[{"rotate-x":Q()}],"rotate-y":[{"rotate-y":Q()}],"rotate-z":[{"rotate-z":Q()}],scale:[{scale:le()}],"scale-x":[{"scale-x":le()}],"scale-y":[{"scale-y":le()}],"scale-z":[{"scale-z":le()}],"scale-3d":["scale-3d"],skew:[{skew:ae()}],"skew-x":[{"skew-x":ae()}],"skew-y":[{"skew-y":ae()}],transform:[{transform:[ge,pe,"","none","gpu","cpu"]}],"transform-origin":[{origin:T()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:fe()}],"translate-x":[{"translate-x":fe()}],"translate-y":[{"translate-y":fe()}],"translate-z":[{"translate-z":fe()}],"translate-none":["translate-none"],accent:[{accent:M()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:M()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ge,pe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mbs":[{"scroll-mbs":F()}],"scroll-mbe":[{"scroll-mbe":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pbs":[{"scroll-pbs":F()}],"scroll-pbe":[{"scroll-pbe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ge,pe]}],fill:[{fill:["none",...M()]}],"stroke-w":[{stroke:[_e,Ir,Zt,tn]}],stroke:[{stroke:["none",...M()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Ec=nc(Sc);function he(...t){return Ec(ho(t))}function Tc(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Aa=l.forwardRef(({className:t,children:r,...s},a)=>e.jsx("div",{className:he(t,"relative overflow-hidden"),...s,children:e.jsx("div",{ref:a,className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Aa.displayName="ScrollArea";function Ic({updateAvailable:t,releaseInfo:r,latestVersion:s,onShowVersionModal:a,onShowSettings:n,t:o}){return e.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-left hover:bg-blue-50/80 dark:hover:bg-blue-900/15 transition-colors group",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Ra,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:r?.title||`v${s}`}),e.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})}),e.jsx("div",{className:"md:hidden px-3 py-2",children:e.jsxs("button",{className:"w-full h-11 bg-blue-50/80 dark:bg-blue-900/15 border border-blue-200/60 dark:border-blue-700/40 rounded-xl flex items-center gap-3 px-3.5 active:scale-[0.98] transition-all",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Ra,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:r?.title||`v${s}`}),e.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})})]}),e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors",onClick:n,children:[e.jsx(Ve,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),e.jsx("div",{className:"md:hidden p-3 pb-20",children:e.jsxs("button",{className:"w-full h-12 bg-muted/40 hover:bg-muted/60 rounded-xl flex items-center gap-3.5 px-4 active:scale-[0.98] transition-all",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-background/80 flex items-center justify-center",children:e.jsx(Ve,{className:"w-4.5 h-4.5 text-muted-foreground"})}),e.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const an=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,nn=ho,Ao=(t,r)=>s=>{var a;if(r?.variants==null)return nn(t,s?.class,s?.className);const{variants:n,defaultVariants:o}=r,i=Object.keys(n).map(d=>{const m=s?.[d],p=o?.[d];if(m===null)return null;const x=an(m)||an(p);return n[d][x]}),c=s&&Object.entries(s).reduce((d,m)=>{let[p,x]=m;return x===void 0||(d[p]=x),d},{}),u=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((d,m)=>{let{class:p,className:x,...h}=m;return Object.entries(h).every(f=>{let[g,k]=f;return Array.isArray(k)?k.includes({...o,...c}[g]):{...o,...c}[g]===k})?[...d,p,x]:d},[]);return nn(t,i,u,s?.class,s?.className)},Dc=Ao("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),me=l.forwardRef(({className:t,variant:r,size:s,...a},n)=>e.jsx("button",{className:he(Dc({variant:r,size:s,className:t})),ref:n,...a}));me.displayName="Button";const Qe=l.forwardRef(({className:t,type:r,...s},a)=>e.jsx("input",{type:r,className:he("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),ref:a,...s}));Qe.displayName="Input";function Ac({isPWA:t,isMobile:r,isLoading:s,projectsCount:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,t:p}){const x=()=>e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("div",{className:"w-7 h-7 bg-primary/90 rounded-lg flex items-center justify-center shadow-sm flex-shrink-0",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-primary-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),e.jsx("h1",{className:"text-sm font-semibold text-foreground tracking-tight truncate",children:p("app.title")})]});return e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"hidden md:block px-3 pt-3 pb-2",style:{},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(x,{}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(me,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:c,disabled:u,title:p("tooltips.refresh"),children:e.jsx(Pt,{className:`w-3.5 h-3.5 ${u?"animate-spin":""}`})}),e.jsx(me,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:d,title:p("tooltips.createProject"),children:e.jsx(tt,{className:"w-3.5 h-3.5"})}),e.jsx(me,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:m,title:p("tooltips.hideSidebar"),children:e.jsx(bi,{className:"w-3.5 h-3.5"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(sr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground/50 pointer-events-none"}),e.jsx(Qe,{type:"text",placeholder:p("projects.searchPlaceholder"),value:n,onChange:h=>o(h.target.value),className:"nav-search-input pl-9 pr-8 h-9 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-accent rounded-md",children:e.jsx(qe,{className:"w-3 h-3 text-muted-foreground"})})]})]}),e.jsx("div",{className:"hidden md:block nav-divider"}),e.jsxs("div",{className:"md:hidden p-3 pb-2",style:t&&r?{paddingTop:"16px"}:{},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{}),e.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-muted/50 flex items-center justify-center active:scale-95 transition-all",onClick:c,disabled:u,children:e.jsx(Pt,{className:`w-4 h-4 text-muted-foreground ${u?"animate-spin":""}`})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/90 text-primary-foreground flex items-center justify-center active:scale-95 transition-all",onClick:d,children:e.jsx(as,{className:"w-4 h-4"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(sr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 pointer-events-none"}),e.jsx(Qe,{type:"text",placeholder:p("projects.searchPlaceholder"),value:n,onChange:h=>o(h.target.value),className:"nav-search-input pl-10 pr-9 h-10 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 hover:bg-accent rounded-md",children:e.jsx(qe,{className:"w-3.5 h-3.5 text-muted-foreground"})})]})]}),e.jsx("div",{className:"md:hidden nav-divider"})]})}const Mc=({status:t="not-configured",size:r="sm",className:s="",showLabel:a=!1})=>{const o=(()=>{switch(t){case"fully-configured":return{icon:Br,color:"text-green-500 dark:text-green-400",bgColor:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"};case"taskmaster-only":return{icon:Ve,color:"text-blue-500 dark:text-blue-400",bgColor:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"};case"mcp-only":return{icon:ks,color:"text-amber-500 dark:text-amber-400",bgColor:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"};default:return{icon:qe,color:"text-gray-400 dark:text-gray-500",bgColor:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"}}})(),i=o.icon,c={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},u={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"};return a?e.jsxs("div",{className:he("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",o.bgColor,o.color,s),title:o.title,children:[e.jsx(i,{className:c[r]}),e.jsx("span",{className:"font-medium",children:o.label})]}):e.jsx("div",{className:he("inline-flex items-center justify-center rounded-full transition-colors",o.bgColor,u[r],s),title:o.title,children:e.jsx(i,{className:he(c[r],o.color)})})},Pc=Ao("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function wt({className:t,variant:r,...s}){return e.jsx("div",{className:he(Pc({variant:r}),t),...s})}const on=(t,r,s)=>{const a=new Date(t),n=r;if(isNaN(a.getTime()))return s?s("status.unknown"):"Unknown";const o=n.getTime()-a.getTime(),i=Math.floor(o/1e3),c=Math.floor(o/(1e3*60)),u=Math.floor(o/(1e3*60*60)),d=Math.floor(o/(1e3*60*60*24));return i<60?s?s("time.justNow"):"Just now":c===1?s?s("time.oneMinuteAgo"):"1 min ago":c<60?s?s("time.minutesAgo",{count:c}):`${c} mins ago`:u===1?s?s("time.oneHourAgo"):"1 hour ago":u<24?s?s("time.hoursAgo",{count:u}):`${u} hours ago`:d===1?s?s("time.oneDayAgo"):"1 day ago":d<7?s?s("time.daysAgo",{count:d}):`${d} days ago`:a.toLocaleDateString()};function jt({provider:t="claude",className:r="w-5 h-5"}){return t==="cursor"?e.jsx(Ki,{className:r}):t==="codex"?e.jsx(Vi,{className:r}):e.jsx(Ji,{className:r})}function Fc({project:t,session:r,selectedSession:s,currentTime:a,editingSession:n,editingSessionName:o,onEditingSessionNameChange:i,onStartEditingSession:c,onCancelEditingSession:u,onSaveEditingSession:d,onProjectSelect:m,onSessionSelect:p,onDeleteSession:x,touchHandlerFactory:h,t:f}){const g=Ml(r,a,f),k=s?.id===r.id,w=()=>{m(t),p(r,t.name)},S=()=>{d(t.name,r.id,o)},y=()=>{x(t.name,r.id,g.sessionName,r.__provider)};return e.jsxs("div",{className:"group relative",children:[g.isActive&&e.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:he("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",k?"bg-primary/5 border-primary/20":"",!k&&g.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:w,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:he("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",k?"bg-primary/10":"bg-muted/50"),children:e.jsx(jt,{provider:r.__provider,className:"w-3 h-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:g.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Lr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:on(g.sessionTime,a,f)}),g.messageCount>0&&e.jsx(wt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:g.messageCount}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(jt,{provider:r.__provider,className:"w-3 h-3"})})]})]}),!g.isCursorSession&&e.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:v=>{v.stopPropagation(),y()},children:e.jsx(ut,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(me,{variant:"ghost",className:he("w-full justify-start p-2 h-auto font-normal text-left hover:bg-accent/50 transition-colors duration-200",k&&"bg-accent text-accent-foreground"),onClick:()=>p(r,t.name),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full",children:[e.jsx(jt,{provider:r.__provider,className:"w-3 h-3 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:g.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Lr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:on(g.sessionTime,a,f)}),g.messageCount>0&&e.jsx(wt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto group-hover:opacity-0 transition-opacity",children:g.messageCount}),e.jsx("span",{className:"ml-1 opacity-70 group-hover:opacity-0 transition-opacity",children:e.jsx(jt,{provider:r.__provider,className:"w-3 h-3"})})]})]})]})}),!g.isCursorSession&&e.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-all duration-200",children:n===r.id&&!g.isCodexSession?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:o,onChange:v=>i(v.target.value),onKeyDown:v=>{v.stopPropagation(),v.key==="Enter"?S():v.key==="Escape"&&u()},onClick:v=>v.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:v=>{v.stopPropagation(),S()},title:f("tooltips.save"),children:e.jsx(vt,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:v=>{v.stopPropagation(),u()},title:f("tooltips.cancel"),children:e.jsx(qe,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):e.jsxs(e.Fragment,{children:[!g.isCodexSession&&e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:v=>{v.stopPropagation(),c(r.id,r.summary||f("projects.newSession"))},title:f("tooltips.editSessionName"),children:e.jsx(yi,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-6 h-6 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:v=>{v.stopPropagation(),y()},title:f("tooltips.deleteSession"),children:e.jsx(ut,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]})}function $c(){return e.jsx(e.Fragment,{children:Array.from({length:3}).map((t,r)=>e.jsx("div",{className:"p-2 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+r*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},r))})}function Lc({project:t,isExpanded:r,sessions:s,selectedSession:a,initialSessionsLoaded:n,isLoadingSessions:o,currentTime:i,editingSession:c,editingSessionName:u,onEditingSessionNameChange:d,onStartEditingSession:m,onCancelEditingSession:p,onSaveEditingSession:x,onProjectSelect:h,onSessionSelect:f,onDeleteSession:g,onLoadMoreSessions:k,onNewSession:w,touchHandlerFactory:S,t:y}){if(!r)return null;const v=s.length>0,T=t.sessionMeta?.hasMore===!0;return e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[n?!v&&!o?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:y("sessions.noSessions")})}):s.map(z=>e.jsx(Fc,{project:t,session:z,selectedSession:a,currentTime:i,editingSession:c,editingSessionName:u,onEditingSessionNameChange:d,onStartEditingSession:m,onCancelEditingSession:p,onSaveEditingSession:x,onProjectSelect:h,onSessionSelect:f,onDeleteSession:g,touchHandlerFactory:S,t:y},z.id)):e.jsx($c,{}),v&&T&&e.jsx(me,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>k(t),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),y("sessions.loading")]}):e.jsxs(e.Fragment,{children:[e.jsx(ft,{className:"w-3 h-3"}),y("sessions.showMore")]})}),e.jsx("div",{className:"md:hidden px-3 pb-2",children:e.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{h(t),w(t)},children:[e.jsx(tt,{className:"w-3 h-3"}),y("sessions.newSession")]})}),e.jsxs(me,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>w(t),children:[e.jsx(tt,{className:"w-3 h-3"}),y("sessions.newSession")]})]})}const _c=(t,r)=>{const s=t.length;return r&&s>=5?`${s}+`:`${s}`};function Rc({project:t,selectedProject:r,selectedSession:s,isExpanded:a,isDeleting:n,isStarred:o,editingProject:i,editingName:c,sessions:u,initialSessionsLoaded:d,isLoadingSessions:m,currentTime:p,editingSession:x,editingSessionName:h,tasksEnabled:f,mcpServerStatus:g,onEditingNameChange:k,onToggleProject:w,onProjectSelect:S,onToggleStarProject:y,onStartEditingProject:v,onCancelEditingProject:T,onSaveProjectName:z,onDeleteProject:I,onSessionSelect:F,onDeleteSession:B,onLoadMoreSessions:D,onNewSession:H,onEditingSessionNameChange:$,onStartEditingSession:R,onCancelEditingSession:E,onSaveEditingSession:U,touchHandlerFactory:j,t:_}){const V=r?.name===t.name,ee=i===t.name,M=t.sessionMeta?.hasMore===!0,G=_c(u,M),C=`${G} session${u.length===1?"":"s"}`,b=$l(t,g),N=()=>w(t.name),W=()=>y(t.name),A=()=>{z(t.name)},O=()=>{r?.name!==t.name&&S(t),N()};return e.jsxs("div",{className:he("md:space-y-1",n&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"group md:group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:he("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",V&&"bg-primary/5 border-primary/20",o&&!V&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:N,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:he("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",a?"bg-primary/10":"bg-muted"),children:a?e.jsx(Kt,{className:"w-4 h-4 text-primary"}):e.jsx(Vt,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:ee?e.jsx("input",{type:"text",value:c,onChange:q=>k(q.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:_("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:q=>q.stopPropagation(),onKeyDown:q=>{q.key==="Enter"&&A(),q.key==="Escape"&&T()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between min-w-0 flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:t.displayName}),f&&e.jsx(Mc,{status:b,size:"xs",className:"hidden md:inline-flex flex-shrink-0 ml-2"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:ee?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:q=>{q.stopPropagation(),A()},children:e.jsx(vt,{className:"w-4 h-4 text-white"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:q=>{q.stopPropagation(),T()},children:e.jsx(qe,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:he("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",o?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:q=>{q.stopPropagation(),W()},title:_(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(za,{className:he("w-4 h-4 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:q=>{q.stopPropagation(),I(t)},children:e.jsx(ut,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:q=>{q.stopPropagation(),v(t)},children:e.jsx(_r,{className:"w-4 h-4 text-primary"})}),e.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:a?e.jsx(ft,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(At,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(me,{variant:"ghost",className:he("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",V&&"bg-accent text-accent-foreground",o&&!V&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:O,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a?e.jsx(Kt,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(Vt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:ee?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:c,onChange:q=>k(q.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:_("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:q=>{q.key==="Enter"&&A(),q.key==="Escape"&&T()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:t.fullPath,children:t.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:t.displayName,children:t.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[G,t.fullPath!==t.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:t.fullPath,children:[" - ",t.fullPath.length>25?`...${t.fullPath.slice(-22)}`:t.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:ee?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:q=>{q.stopPropagation(),A()},children:e.jsx(vt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:q=>{q.stopPropagation(),T()},children:e.jsx(qe,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:he("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",o?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:q=>{q.stopPropagation(),W()},title:_(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(za,{className:he("w-3 h-3 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:q=>{q.stopPropagation(),v(t)},title:_("tooltips.renameProject"),children:e.jsx(_r,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:q=>{q.stopPropagation(),I(t)},title:_("tooltips.deleteProject"),children:e.jsx(ut,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),a?e.jsx(ft,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(At,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),e.jsx(Lc,{project:t,isExpanded:a,sessions:u,selectedSession:s,initialSessionsLoaded:d,isLoadingSessions:m,currentTime:p,editingSession:x,editingSessionName:h,onEditingSessionNameChange:$,onStartEditingSession:R,onCancelEditingSession:E,onSaveEditingSession:U,onProjectSelect:S,onSessionSelect:F,onDeleteSession:B,onLoadMoreSessions:D,onNewSession:H,touchHandlerFactory:j,t:_})]})}function zc({isLoading:t,loadingProgress:r,projectsCount:s,filteredProjectsCount:a,t:n}){const{isRelayConnected:o}=ba();return t?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.loadingProjects")}),r&&r.total>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full transition-all duration-300 ease-out",style:{width:`${r.current/r.total*100}%`}})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.current,"/",r.total," ",n("projects.projects")]}),r.currentProject&&e.jsx("p",{className:"text-xs text-muted-foreground/70 truncate max-w-[200px] mx-auto",title:r.currentProject,children:r.currentProject.split("-").slice(-2).join("/")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.fetchingProjects")})]}):s===0?o?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(Vt,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.runClaudeCli")})]}):e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(Yn,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"No machine connected"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your machine to see projects"})]}):a===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(sr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noMatchingProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.tryDifferentSearch")})]}):null}function Oc({projects:t,filteredProjects:r,selectedProject:s,selectedSession:a,isLoading:n,loadingProgress:o,expandedProjects:i,editingProject:c,editingName:u,loadingSessions:d,initialSessionsLoaded:m,currentTime:p,editingSession:x,editingSessionName:h,deletingProjects:f,tasksEnabled:g,mcpServerStatus:k,getProjectSessions:w,isProjectStarred:S,onEditingNameChange:y,onToggleProject:v,onProjectSelect:T,onToggleStarProject:z,onStartEditingProject:I,onCancelEditingProject:F,onSaveProjectName:B,onDeleteProject:D,onSessionSelect:H,onDeleteSession:$,onLoadMoreSessions:R,onNewSession:E,onEditingSessionNameChange:U,onStartEditingSession:j,onCancelEditingSession:_,onSaveEditingSession:V,touchHandlerFactory:ee,t:M}){const G=e.jsx(zc,{isLoading:n,loadingProgress:o,projectsCount:t.length,filteredProjectsCount:r.length,t:M}),C=!n&&t.length>0&&r.length>0;return e.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:C?r.map(b=>e.jsx(Rc,{project:b,selectedProject:s,selectedSession:a,isExpanded:i.has(b.name),isDeleting:f.has(b.name),isStarred:S(b.name),editingProject:c,editingName:u,sessions:w(b),initialSessionsLoaded:m.has(b.name),isLoadingSessions:!!d[b.name],currentTime:p,editingSession:x,editingSessionName:h,tasksEnabled:g,mcpServerStatus:k,onEditingNameChange:y,onToggleProject:v,onProjectSelect:T,onToggleStarProject:z,onStartEditingProject:I,onCancelEditingProject:F,onSaveProjectName:B,onDeleteProject:D,onSessionSelect:H,onDeleteSession:$,onLoadMoreSessions:R,onNewSession:E,onEditingSessionNameChange:U,onStartEditingSession:j,onCancelEditingSession:_,onSaveEditingSession:V,touchHandlerFactory:ee,t:M},b.name)):G})}function Bc({isPWA:t,isMobile:r,isLoading:s,projects:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,updateAvailable:p,releaseInfo:x,latestVersion:h,onShowVersionModal:f,onShowSettings:g,projectListProps:k,t:w}){return e.jsxs("div",{className:"h-full flex flex-col bg-background/80 backdrop-blur-sm md:select-none md:w-72",style:{},children:[e.jsx(Ac,{isPWA:t,isMobile:r,isLoading:s,projectsCount:a.length,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,t:w}),e.jsx(Aa,{className:"flex-1 md:px-1.5 md:py-2 overflow-y-auto overscroll-contain",children:e.jsx(Oc,{...k})}),e.jsx(Ic,{updateAvailable:p,releaseInfo:x,latestVersion:h,onShowVersionModal:f,onShowSettings:g,t:w})]})}const Wc=({onClose:t,onProjectCreated:r})=>{const{t:s}=Ue(),[a,n]=l.useState(1),[o,i]=l.useState("existing"),[c,u]=l.useState(""),[d,m]=l.useState(""),[p,x]=l.useState(""),[h,f]=l.useState("stored"),[g,k]=l.useState(""),[w,S]=l.useState(!1),[y,v]=l.useState(null),[T,z]=l.useState([]),[I,F]=l.useState(!1),[B,D]=l.useState([]),[H,$]=l.useState(!1),[R,E]=l.useState(!1),[U,j]=l.useState("~"),[_,V]=l.useState([]),[ee,M]=l.useState(!1),[G,C]=l.useState(!1),[b,N]=l.useState(!1),[W,A]=l.useState(""),[O,q]=l.useState(!1),[Z,J]=l.useState("");l.useEffect(()=>{a===2&&o==="new"&&d&&Q()},[a,o,d]),l.useEffect(()=>{c.length>2?le(c):(D([]),$(!1))},[c]);const Q=async()=>{try{F(!0);const xe=((await(await Ge.get("/settings/credentials?type=github_token")).json()).credentials||[]).filter(te=>te.is_active);z(xe),xe.length>0&&!p&&x(xe[0].id.toString())}catch(X){console.error("Error loading GitHub tokens:",X)}finally{F(!1)}},le=async X=>{try{const Ce=X.lastIndexOf("/"),xe=Ce>0?X.substring(0,Ce):"~",se=await(await Ge.browseFilesystem(xe)).json();if(se.suggestions){const ke=se.suggestions.filter(Ne=>Ne.path.toLowerCase().startsWith(X.toLowerCase())&&Ne.path.toLowerCase()!==X.toLowerCase());D(ke.slice(0,5)),$(ke.length>0)}}catch(Ce){console.error("Error loading path suggestions:",Ce)}},ae=()=>{if(v(null),a===1){if(!o){v(s("projectWizard.errors.selectType"));return}n(2)}else if(a===2){if(!c.trim()){v(s("projectWizard.errors.providePath"));return}n(3)}},fe=()=>{v(null),n(a-1)},Ee=async()=>{S(!0),v(null),J("");try{if(o==="new"&&d){const te=new URLSearchParams({path:c.trim(),githubUrl:d.trim()});h==="stored"&&p?te.append("githubTokenId",p):h==="new"&&g&&te.append("newGithubToken",g.trim());const se=`/api/projects/clone-progress?${te}`;await new Promise((ke,Ne)=>{const Ie=new EventSource(se);Ie.onmessage=Ke=>{try{const Be=JSON.parse(Ke.data);Be.type==="progress"?J(Be.message):Be.type==="complete"?(Ie.close(),r&&r(Be.project),t(),ke()):Be.type==="error"&&(Ie.close(),Ne(new Error(Be.message)))}catch(Be){console.error("Error parsing SSE event:",Be)}},Ie.onerror=()=>{Ie.close(),Ne(new Error("Connection lost during clone"))}});return}const X={workspaceType:o,path:c.trim()},Ce=await Ge.createWorkspace(X),xe=await Ce.json();if(!Ce.ok)throw new Error(xe.details||xe.error||s("projectWizard.errors.failedToCreate"));r&&r(xe.project),t()}catch(X){console.error("Error creating workspace:",X),v(X.message||s("projectWizard.errors.failedToCreate"))}finally{S(!1)}},Pe=X=>{u(X.path),$(!1)},He=async()=>{E(!0),await Te("~")},Te=async X=>{try{M(!0);const xe=await(await Ge.browseFilesystem(X)).json();j(xe.path||X),V(xe.suggestions||[])}catch(Ce){console.error("Error loading folders:",Ce)}finally{M(!1)}},be=(X,Ce=!1)=>{u(X),E(!1),Ce&&n(3)},Ae=async X=>{await Te(X)},Re=async()=>{if(W.trim()){q(!0),v(null);try{const X=U.includes("\\")?"\\":"/",Ce=`${U}${X}${W.trim()}`,xe=await Ge.createFolder(Ce),te=await xe.json();if(!xe.ok)throw new Error(te.error||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"));A(""),N(!1),await Te(te.path||Ce)}catch(X){console.error("Error creating folder:",X),v(X.message||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{q(!1)}}};return e.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(as,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s("projectWizard.title")})]}),e.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:w,children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"px-6 pt-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(X=>e.jsxs(Et.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${X<a?"bg-green-500 text-white":X===a?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:X<a?e.jsx(vt,{className:"w-4 h-4"}):X}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:s(X===1?"projectWizard.steps.type":X===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),X<3&&e.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${X<a?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},X))})}),e.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[y&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(ks,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:y})})]}),a===1&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:s("projectWizard.step1.question")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("button",{onClick:()=>i("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="existing"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(as,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.existing.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.existing.description")})]})]})}),e.jsx("button",{onClick:()=>i("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="new"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx($t,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.new.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.new.description")})]})]})})]})]})}),a===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s(o==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),e.jsxs("div",{className:"relative flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Qe,{type:"text",value:c,onChange:X=>u(X.target.value),placeholder:o==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),H&&B.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:B.map((X,Ce)=>e.jsxs("button",{onClick:()=>Pe(X),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:X.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:X.path})]},Ce))})]}),e.jsx(me,{type:"button",variant:"outline",onClick:He,className:"px-3",title:"Browse folders",children:e.jsx(Kt,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s(o==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]}),o==="new"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.githubUrl")}),e.jsx(Qe,{type:"text",value:d,onChange:X=>m(X.target.value),placeholder:"https://github.com/username/repository",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.githubHelp")})]}),d&&!d.startsWith("git@")&&!d.startsWith("ssh://")&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(va,{className:"w-5 h-5 text-gray-600 dark:text-gray-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-medium text-gray-900 dark:text-white mb-1",children:s("projectWizard.step2.githubAuth")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step2.githubAuthHelp")})]})]}),I?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(mr,{className:"w-4 h-4 animate-spin"}),s("projectWizard.step2.loadingTokens")]}):T.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsx("button",{onClick:()=>f("stored"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${h==="stored"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.storedToken")}),e.jsx("button",{onClick:()=>f("new"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${h==="new"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.newToken")}),e.jsx("button",{onClick:()=>{f("none"),x(""),k("")},className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${h==="none"?"bg-green-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.nonePublic")})]}),h==="stored"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.selectToken")}),e.jsxs("select",{value:p,onChange:X=>x(X.target.value),className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:s("projectWizard.step2.selectTokenPlaceholder")}),T.map(X=>e.jsx("option",{value:X.id,children:X.credential_name},X.id))]})]}):h==="new"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.newToken")}),e.jsx(Qe,{type:"password",value:g,onChange:X=>k(X.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.tokenHelp")})]}):null]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s("projectWizard.step2.publicRepoInfo")})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.optionalTokenPublic")}),e.jsx(Qe,{type:"password",value:g,onChange:X=>k(X.target.value),placeholder:s("projectWizard.step2.tokenPublicPlaceholder"),className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.noTokensHelp")})]})]})]})]})]}),a===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:s("projectWizard.step3.reviewConfig")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.workspaceType")}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:s(o==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.path")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]}),o==="new"&&d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.cloneFrom")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:d})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.authentication")}),e.jsx("span",{className:"text-xs text-gray-900 dark:text-white",children:h==="stored"&&p?`${s("projectWizard.step3.usingStoredToken")} ${T.find(X=>X.id.toString()===p)?.credential_name||"Unknown"}`:h==="new"&&g?s("projectWizard.step3.usingProvidedToken"):d.startsWith("git@")||d.startsWith("ssh://")?s("projectWizard.step3.sshKey","SSH Key"):s("projectWizard.step3.noAuthentication")})]})]})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:w&&Z?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:s("projectWizard.step3.cloningRepository","Cloning repository...")}),e.jsx("code",{className:"block text-xs font-mono text-blue-700 dark:text-blue-300 whitespace-pre-wrap break-all",children:Z})]}):e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s(o==="existing"?"projectWizard.step3.existingInfo":d?"projectWizard.step3.newWithClone":"projectWizard.step3.newEmpty")})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(me,{variant:"outline",onClick:a===1?t:fe,disabled:w,children:a===1?s("projectWizard.buttons.cancel"):e.jsxs(e.Fragment,{children:[e.jsx(Qn,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.back")]})}),e.jsx(me,{onClick:a===3?Ee:ae,disabled:w||a===1&&!o,children:w?e.jsxs(e.Fragment,{children:[e.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}),d?s("projectWizard.buttons.cloning","Cloning..."):s("projectWizard.buttons.creating")]}):a===3?e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.createProject")]}):e.jsxs(e.Fragment,{children:[s("projectWizard.buttons.next"),e.jsx(At,{className:"w-4 h-4 ml-1"})]})})]})]}),R&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Kt,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>C(!G),className:`p-2 rounded-md transition-colors ${G?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:G?"Hide hidden folders":"Show hidden folders",children:G?e.jsx(ar,{className:"w-5 h-5"}):e.jsx(Xn,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>N(!b),className:`p-2 rounded-md transition-colors ${b?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:e.jsx(tt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>E(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(qe,{className:"w-5 h-5"})})]})]}),b&&e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-blue-50 dark:bg-blue-900/20",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qe,{type:"text",value:W,onChange:X=>A(X.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:X=>{X.key==="Enter"&&Re(),X.key==="Escape"&&(N(!1),A(""))},autoFocus:!0}),e.jsx(me,{size:"sm",onClick:Re,disabled:!W.trim()||O,children:O?e.jsx(mr,{className:"w-4 h-4 animate-spin"}):"Create"}),e.jsx(me,{size:"sm",variant:"ghost",onClick:()=>{N(!1),A("")},children:"Cancel"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:ee?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(mr,{className:"w-6 h-6 animate-spin text-gray-400"})}):e.jsxs("div",{className:"space-y-1",children:[U!=="~"&&U!=="/"&&!/^[A-Za-z]:\\?$/.test(U)&&e.jsxs("button",{onClick:()=>{const X=Math.max(U.lastIndexOf("/"),U.lastIndexOf("\\"));let Ce;X<=0?Ce="/":X===2&&/^[A-Za-z]:/.test(U)?Ce=U.substring(0,3):Ce=U.substring(0,X),Ae(Ce)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(Kt,{className:"w-5 h-5 text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),_.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):_.filter(X=>G||!X.name.startsWith(".")).sort((X,Ce)=>X.name.toLowerCase().localeCompare(Ce.name.toLowerCase())).map((X,Ce)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Ae(X.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(as,{className:"w-5 h-5 text-blue-500"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:X.name})]}),e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>be(X.path,o==="existing"),className:"text-xs px-3",children:"Select"})]},Ce))]})}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),e.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:U})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[e.jsx(me,{variant:"outline",onClick:()=>{E(!1),N(!1),A("")},children:"Cancel"}),e.jsx(me,{variant:"outline",onClick:()=>be(U,o==="existing"),children:"Use this folder"})]})]})]})})]})},Uc="2.0.0";function Hc(){const{t}=Ue("settings"),[r,s]=l.useState([]),[a,n]=l.useState([]),[o,i]=l.useState(!0),[c,u]=l.useState(!1),[d,m]=l.useState(!1),[p,x]=l.useState(""),[h,f]=l.useState(""),[g,k]=l.useState(""),[w,S]=l.useState(""),[y,v]=l.useState({}),[T,z]=l.useState(null),[I,F]=l.useState(null),{updateAvailable:B,latestVersion:D,releaseInfo:H}=po("thinqmesh","upfynai-code");l.useEffect(()=>{$()},[]);const $=async()=>{try{i(!0);const G=await(await we("/api/settings/api-keys")).json();s(G.apiKeys||[]);const b=await(await we("/api/settings/credentials?type=github_token")).json();n(b.credentials||[])}catch(M){console.error("Error fetching settings:",M)}finally{i(!1)}},R=async()=>{if(p.trim())try{const G=await(await we("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:p})})).json();G.success&&(F(G.apiKey),x(""),u(!1),$())}catch(M){console.error("Error creating API key:",M)}},E=async M=>{if(confirm(t("apiKeys.confirmDelete")))try{await we(`/api/settings/api-keys/${M}`,{method:"DELETE"}),$()}catch(G){console.error("Error deleting API key:",G)}},U=async(M,G)=>{try{await we(`/api/settings/api-keys/${M}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!G})}),$()}catch(C){console.error("Error toggling API key:",C)}},j=async()=>{if(!(!h.trim()||!g.trim()))try{(await(await we("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:h,credentialType:"github_token",credentialValue:g,description:w})})).json()).success&&(f(""),k(""),S(""),m(!1),$())}catch(M){console.error("Error creating GitHub credential:",M)}},_=async M=>{if(confirm(t("apiKeys.github.confirmDelete")))try{await we(`/api/settings/credentials/${M}`,{method:"DELETE"}),$()}catch(G){console.error("Error deleting GitHub credential:",G)}},V=async(M,G)=>{try{await we(`/api/settings/credentials/${M}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!G})}),$()}catch(C){console.error("Error toggling GitHub credential:",C)}},ee=(M,G)=>{navigator.clipboard.writeText(M),z(G),setTimeout(()=>z(null),2e3)};return o?e.jsx("div",{className:"text-muted-foreground",children:t("apiKeys.loading")}):e.jsxs("div",{className:"space-y-8",children:[I&&e.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[e.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:t("apiKeys.newKey.alertTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t("apiKeys.newKey.alertMessage")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:I.apiKey}),e.jsx(me,{size:"sm",variant:"outline",onClick:()=>ee(I.apiKey,"new"),children:T==="new"?e.jsx(vt,{className:"h-4 w-4"}):e.jsx(ka,{className:"h-4 w-4"})})]}),e.jsx(me,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>F(null),children:t("apiKeys.newKey.iveSavedIt")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(va,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.title")})]}),e.jsxs(me,{size:"sm",onClick:()=>u(!c),children:[e.jsx(tt,{className:"h-4 w-4 mr-1"}),t("apiKeys.newButton")]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:t("apiKeys.description")}),e.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[t("apiKeys.apiDocsLink"),e.jsx(Oa,{className:"h-3 w-3"})]})]}),c&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[e.jsx(Qe,{placeholder:t("apiKeys.form.placeholder"),value:p,onChange:M=>x(M.target.value),className:"mb-2"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(me,{onClick:R,children:t("apiKeys.form.createButton")}),e.jsx(me,{variant:"outline",onClick:()=>u(!1),children:t("apiKeys.form.cancelButton")})]})]}),e.jsx("div",{className:"space-y-2",children:r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.empty")}):r.map(M=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:M.key_name}),e.jsx("code",{className:"text-xs text-muted-foreground",children:M.api_key}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.list.created")," ",new Date(M.created_at).toLocaleDateString(),M.last_used&&` • ${t("apiKeys.list.lastUsed")} ${new Date(M.last_used).toLocaleDateString()}`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{size:"sm",variant:M.is_active?"outline":"secondary",onClick:()=>U(M.id,M.is_active),children:M.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(me,{size:"sm",variant:"ghost",onClick:()=>E(M.id),children:e.jsx(ut,{className:"h-4 w-4"})})]})]},M.id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vi,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.github.title")})]}),e.jsxs(me,{size:"sm",onClick:()=>m(!d),children:[e.jsx(tt,{className:"h-4 w-4 mr-1"}),t("apiKeys.github.addButton")]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("apiKeys.github.descriptionAlt")}),d&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[e.jsx(Qe,{placeholder:t("apiKeys.github.form.namePlaceholder"),value:h,onChange:M=>f(M.target.value)}),e.jsxs("div",{className:"relative",children:[e.jsx(Qe,{type:y.new?"text":"password",placeholder:t("apiKeys.github.form.tokenPlaceholder"),value:g,onChange:M=>k(M.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>v({...y,new:!y.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:y.new?e.jsx(Xn,{className:"h-4 w-4"}):e.jsx(ar,{className:"h-4 w-4"})})]}),e.jsx(Qe,{placeholder:t("apiKeys.github.form.descriptionPlaceholder"),value:w,onChange:M=>S(M.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(me,{onClick:j,children:t("apiKeys.github.form.addButton")}),e.jsx(me,{variant:"outline",onClick:()=>{m(!1),f(""),k(""),S("")},children:t("apiKeys.github.form.cancelButton")})]}),e.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:t("apiKeys.github.form.howToCreate")})]}),e.jsx("div",{className:"space-y-2",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.github.empty")}):a.map(M=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:M.credential_name}),M.description&&e.jsx("div",{className:"text-xs text-muted-foreground",children:M.description}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.github.added")," ",new Date(M.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{size:"sm",variant:M.is_active?"outline":"secondary",onClick:()=>V(M.id,M.is_active),children:M.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(me,{size:"sm",variant:"ghost",onClick:()=>_(M.id),children:e.jsx(ut,{className:"h-4 w-4"})})]})]},M.id))})]}),e.jsx("div",{className:"pt-6 border-t border-border/50",children:e.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[e.jsxs("a",{href:H?.htmlUrl||"https://github.com/thinqmesh/upfynai-code/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Uc]}),B&&D&&e.jsxs("a",{href:H?.htmlUrl||"https://github.com/thinqmesh/upfynai-code/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[e.jsx("span",{className:"text-[10px]",children:t("apiKeys.version.updateAvailable",{version:D})}),e.jsx(Oa,{className:"h-2.5 w-2.5"})]})]})})]})}function Gc(){const{t}=Ue("settings"),[r,s]=l.useState(""),[a,n]=l.useState(""),[o,i]=l.useState(!1),[c,u]=l.useState(!1),[d,m]=l.useState(null);l.useEffect(()=>{p()},[]);const p=async()=>{try{i(!0);const h=await we("/api/user/git-config");if(h.ok){const f=await h.json();s(f.gitName||""),n(f.gitEmail||"")}}catch(h){console.error("Error loading git config:",h)}finally{i(!1)}},x=async()=>{try{u(!0);const h=await we("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:a})});if(h.ok)m("success"),setTimeout(()=>m(null),3e3);else{const f=await h.json();m("error"),console.error("Failed to save git config:",f.error)}}catch(h){console.error("Error saving git config:",h),m("error")}finally{u(!1)}};return e.jsx("div",{className:"space-y-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx($t,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("git.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("git.description")}),e.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:t("git.name.label")}),e.jsx(Qe,{id:"settings-git-name",type:"text",value:r,onChange:h=>s(h.target.value),placeholder:"John Doe",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.name.help")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:t("git.email.label")}),e.jsx(Qe,{id:"settings-git-email",type:"email",value:a,onChange:h=>n(h.target.value),placeholder:"john@example.com",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.email.help")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{onClick:x,disabled:c||!r||!a,children:t(c?"git.actions.saving":"git.actions.save")}),d==="success"&&e.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[e.jsx(vt,{className:"w-4 h-4"}),t("git.status.success")]})]})]})]})})}function qc(){const{t}=Ue("settings"),{tasksEnabled:r,setTasksEnabled:s,isTaskMasterInstalled:a,isCheckingInstallation:n}=Or();return e.jsx("div",{className:"space-y-8",children:n?e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("tasks.checking")})]})}):e.jsxs(e.Fragment,{children:[!a&&e.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-orange-100 dark:bg-orange-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:t("tasks.notInstalled.title")}),e.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[e.jsx("p",{children:t("tasks.notInstalled.description")}),e.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:e.jsx("code",{children:t("tasks.notInstalled.installCommand")})}),e.jsx("div",{children:e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),t("tasks.notInstalled.viewOnGitHub"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:t("tasks.notInstalled.afterInstallation")}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[e.jsx("li",{children:t("tasks.notInstalled.steps.restart")}),e.jsx("li",{children:t("tasks.notInstalled.steps.autoAvailable")}),e.jsx("li",{children:t("tasks.notInstalled.steps.initCommand")})]})]})]})]})]})}),a&&e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:t("tasks.settings.enableLabel")}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:t("tasks.settings.enableDescription")})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:o=>s(o.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]})})})]})})}const Kc={claude:{name:"Claude",color:"blue"},cursor:{name:"Cursor",color:"purple"},codex:{name:"Codex",color:"gray"}},Vc={blue:{border:"border-l-blue-500 md:border-l-blue-500",borderBottom:"border-b-blue-500",bg:"bg-blue-50 dark:bg-blue-900/20",dot:"bg-blue-500"},purple:{border:"border-l-purple-500 md:border-l-purple-500",borderBottom:"border-b-purple-500",bg:"bg-purple-50 dark:bg-purple-900/20",dot:"bg-purple-500"},gray:{border:"border-l-gray-700 dark:border-l-gray-300",borderBottom:"border-b-gray-700 dark:border-b-gray-300",bg:"bg-gray-100 dark:bg-gray-800/50",dot:"bg-gray-700 dark:bg-gray-300"}};function ur({agentId:t,authStatus:r,isSelected:s,onClick:a,isMobile:n=!1}){const{t:o}=Ue("settings"),i=Kc[t],c=Vc[i.color];return n?e.jsx("button",{onClick:a,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${s?`${c.borderBottom} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(jt,{provider:t,className:"w-5 h-5"}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:i.name}),r?.authenticated&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`})]})}):e.jsxs("button",{onClick:a,className:`w-full text-left p-3 border-l-4 transition-colors ${s?`${c.border} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(jt,{provider:t,className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:i.name})]}),e.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:r?.loading?e.jsx("span",{className:"text-gray-400",children:o("agents.authStatus.checking")}):r?.authenticated?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`}),e.jsx("span",{className:"truncate max-w-[120px]",title:r.email,children:r.email||o("agents.authStatus.connected")})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),e.jsx("span",{children:o("agents.authStatus.notConnected")})]})})]})}const Jc={claude:{name:"Claude",description:"Anthropic Claude AI assistant",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800",textClass:"text-blue-900 dark:text-blue-100",subtextClass:"text-blue-700 dark:text-blue-300",buttonClass:"bg-blue-600 hover:bg-blue-700"},cursor:{name:"Cursor",description:"Cursor AI-powered code editor",bgClass:"bg-purple-50 dark:bg-purple-900/20",borderClass:"border-purple-200 dark:border-purple-800",textClass:"text-purple-900 dark:text-purple-100",subtextClass:"text-purple-700 dark:text-purple-300",buttonClass:"bg-purple-600 hover:bg-purple-700"},codex:{name:"Codex",description:"OpenAI Codex AI assistant",bgClass:"bg-gray-100 dark:bg-gray-800/50",borderClass:"border-gray-300 dark:border-gray-600",textClass:"text-gray-900 dark:text-gray-100",subtextClass:"text-gray-700 dark:text-gray-300",buttonClass:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"}};function Yc({agent:t,authStatus:r,onLogin:s}){const{t:a}=Ue("settings"),n=Jc[t];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(jt,{provider:t,className:"w-6 h-6"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a(`agents.account.${t}.description`)})]})]}),e.jsx("div",{className:`${n.bgClass} border ${n.borderClass} rounded-lg p-4`,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:a("agents.connectionStatus")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r?.loading?a("agents.authStatus.checkingAuth"):r?.authenticated?a("agents.authStatus.loggedInAs",{email:r.email||a("agents.authStatus.authenticatedUser")}):a("agents.authStatus.notConnected")})]}),e.jsx("div",{children:r?.loading?e.jsx(wt,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:a("agents.authStatus.checking")}):r?.authenticated?e.jsx(wt,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:a("agents.authStatus.connected")}):e.jsx(wt,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:a("agents.authStatus.disconnected")})})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:r?.authenticated?a("agents.login.reAuthenticate"):a("agents.login.title")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r?.authenticated?a("agents.login.reAuthDescription"):a("agents.login.description",{agent:n.name})})]}),e.jsxs(me,{onClick:s,className:`${n.buttonClass} text-white`,size:"sm",children:[e.jsx(ki,{className:"w-4 h-4 mr-2"}),r?.authenticated?a("agents.login.reLoginButton"):a("agents.login.button")]})]})}),r?.error&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:a("agents.error",{error:r.error})})})]})})]})}const Qc=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],Xc=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function Zc({skipPermissions:t,setSkipPermissions:r,allowedTools:s,setAllowedTools:a,disallowedTools:n,setDisallowedTools:o,newAllowedTool:i,setNewAllowedTool:c,newDisallowedTool:u,setNewDisallowedTool:d}){const{t:m}=Ue("settings"),p=g=>{g&&!s.includes(g)&&(a([...s,g]),c(""))},x=g=>{a(s.filter(k=>k!==g))},h=g=>{g&&!n.includes(g)&&(o([...n,g]),d(""))},f=g=>{o(n.filter(k=>k!==g))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Lt,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:g=>r(g.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.claudeDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Tt,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Qe,{value:i,onChange:g=>c(g.target.value),placeholder:m("permissions.allowedTools.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),p(i))},className:"flex-1 h-10"}),e.jsxs(me,{onClick:()=>p(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(tt,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedTools.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Qc.map(g=>e.jsx(me,{variant:"outline",size:"sm",onClick:()=>p(g),disabled:s.includes(g),className:"text-xs h-8",children:g},g))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(g=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>x(g),className:"text-green-600 hover:text-green-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},g)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedTools.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Lt,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Qe,{value:u,onChange:g=>d(g.target.value),placeholder:m("permissions.blockedTools.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),h(u))},className:"flex-1 h-10"}),e.jsxs(me,{onClick:()=>h(u),disabled:!u,size:"sm",className:"h-10 px-4",children:[e.jsx(tt,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(g=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>f(g),className:"text-red-600 hover:text-red-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},g)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedTools.empty")})]})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:m("permissions.toolExamples.title")}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," ",m("permissions.toolExamples.bashGitLog")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," ",m("permissions.toolExamples.bashGitDiff")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," ",m("permissions.toolExamples.write")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," ",m("permissions.toolExamples.bashRm")]})]})]})]})}function ed({skipPermissions:t,setSkipPermissions:r,allowedCommands:s,setAllowedCommands:a,disallowedCommands:n,setDisallowedCommands:o,newAllowedCommand:i,setNewAllowedCommand:c,newDisallowedCommand:u,setNewDisallowedCommand:d}){const{t:m}=Ue("settings"),p=g=>{g&&!s.includes(g)&&(a([...s,g]),c(""))},x=g=>{a(s.filter(k=>k!==g))},h=g=>{g&&!n.includes(g)&&(o([...n,g]),d(""))},f=g=>{o(n.filter(k=>k!==g))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Lt,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:g=>r(g.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.cursorDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Tt,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Qe,{value:i,onChange:g=>c(g.target.value),placeholder:m("permissions.allowedCommands.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),p(i))},className:"flex-1 h-10"}),e.jsxs(me,{onClick:()=>p(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(tt,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedCommands.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Xc.map(g=>e.jsx(me,{variant:"outline",size:"sm",onClick:()=>p(g),disabled:s.includes(g),className:"text-xs h-8",children:g},g))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(g=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>x(g),className:"text-green-600 hover:text-green-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},g)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedCommands.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Lt,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Qe,{value:u,onChange:g=>d(g.target.value),placeholder:m("permissions.blockedCommands.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),h(u))},className:"flex-1 h-10"}),e.jsxs(me,{onClick:()=>h(u),disabled:!u,size:"sm",className:"h-10 px-4",children:[e.jsx(tt,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(g=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>f(g),className:"text-red-600 hover:text-red-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},g)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedCommands.empty")})]})]}),e.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:m("permissions.shellExamples.title")}),e.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," ",m("permissions.shellExamples.ls")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," ",m("permissions.shellExamples.gitStatus")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," ",m("permissions.shellExamples.npmInstall")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," ",m("permissions.shellExamples.rmRf")]})]})]})]})}function td({permissionMode:t,setPermissionMode:r}){const{t:s}=Ue("settings");return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Tt,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:s("permissions.codex.permissionMode")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("permissions.codex.description")}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("default"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="default",onChange:()=>r("default"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:s("permissions.codex.modes.default.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("permissions.codex.modes.default.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("acceptEdits"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="acceptEdits",onChange:()=>r("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:s("permissions.codex.modes.acceptEdits.title")}),e.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:s("permissions.codex.modes.acceptEdits.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("bypassPermissions"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="bypassPermissions",onChange:()=>r("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:[s("permissions.codex.modes.bypassPermissions.title"),e.jsx(Lt,{className:"w-4 h-4"})]}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:s("permissions.codex.modes.bypassPermissions.description")})]})]})}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:s("permissions.codex.technicalDetails")}),e.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.default.title"),":"]})," ",s("permissions.codex.technicalInfo.default")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.acceptEdits.title"),":"]})," ",s("permissions.codex.technicalInfo.acceptEdits")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.bypassPermissions.title"),":"]})," ",s("permissions.codex.technicalInfo.bypassPermissions")]}),e.jsx("p",{className:"text-xs opacity-75",children:s("permissions.codex.technicalInfo.overrideNote")})]})]})]})})}function Os({agent:t,...r}){return t==="claude"?e.jsx(Zc,{...r}):t==="cursor"?e.jsx(ed,{...r}):t==="codex"?e.jsx(td,{...r}):null}const rd=t=>{switch(t){case"stdio":return e.jsx(at,{className:"w-4 h-4"});case"sse":return e.jsx(ja,{className:"w-4 h-4"});case"http":return e.jsx(Rr,{className:"w-4 h-4"});default:return e.jsx(js,{className:"w-4 h-4"})}};function sd({servers:t,onAdd:r,onEdit:s,onDelete:a,onTest:n,onDiscoverTools:o,testResults:i,serverTools:c,toolsLoading:u}){const{t:d}=Ue("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(js,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d("mcpServers.description.claude")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(me,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(tt,{className:"w-4 h-4 mr-2"}),d("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(m=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[rd(m.type),e.jsx("span",{className:"font-medium text-foreground",children:m.name}),e.jsx(wt,{variant:"outline",className:"text-xs",children:m.type}),e.jsx(wt,{variant:"outline",className:"text-xs",children:m.scope==="local"?d("mcpServers.scope.local"):m.scope==="user"?d("mcpServers.scope.user"):m.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[m.type==="stdio"&&m.config?.command&&e.jsxs("div",{children:[d("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.command})]}),(m.type==="sse"||m.type==="http")&&m.config?.url&&e.jsxs("div",{children:[d("mcpServers.config.url"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.url})]}),m.config?.args&&m.config.args.length>0&&e.jsxs("div",{children:[d("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.args.join(" ")})]})]}),i?.[m.id]&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[m.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:e.jsx("div",{className:"font-medium",children:i[m.id].message})}),c?.[m.id]&&c[m.id].tools?.length>0&&e.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[e.jsxs("div",{className:"font-medium",children:[d("mcpServers.tools.title")," ",d("mcpServers.tools.count",{count:c[m.id].tools.length})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[c[m.id].tools.slice(0,5).map((p,x)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:p.name},x)),c[m.id].tools.length>5&&e.jsx("span",{className:"text-xs opacity-75",children:d("mcpServers.tools.more",{count:c[m.id].tools.length-5})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(me,{onClick:()=>s(m),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:d("mcpServers.actions.edit"),children:e.jsx(_r,{className:"w-4 h-4"})}),e.jsx(me,{onClick:()=>a(m.id,m.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:d("mcpServers.actions.delete"),children:e.jsx(ut,{className:"w-4 h-4"})})]})]})},m.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:d("mcpServers.empty")})]})]})}function ad({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=Ue("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(js,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.cursor")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(me,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(tt,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(at,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(wt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:o.config?.command&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(me,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(_r,{className:"w-4 h-4"})}),e.jsx(me,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(ut,{className:"w-4 h-4"})})]})]})},o.name||o.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]})]})}function nd({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=Ue("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(js,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.codex")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(me,{onClick:r,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(tt,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(at,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(wt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[o.config?.command&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]}),o.config?.args&&o.config.args.length>0&&e.jsxs("div",{children:[n("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.args.join(" ")})]}),o.config?.env&&Object.keys(o.config.env).length>0&&e.jsxs("div",{children:[n("mcpServers.config.environment"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(o.config.env).map(([i,c])=>`${i}=${c}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(me,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(_r,{className:"w-4 h-4"})}),e.jsx(me,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(ut,{className:"w-4 h-4"})})]})]})},o.name)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]}),e.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:n("mcpServers.help.title")}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:n("mcpServers.help.description")})]})]})}function Bs({agent:t,...r}){return t==="claude"?e.jsx(sd,{...r}):t==="cursor"?e.jsx(ad,{...r}):t==="codex"?e.jsx(nd,{...r}):null}function Mo({compact:t=!1}){const{i18n:r,t:s}=Ue("settings"),a=n=>{const o=n.target.value;r.changeLanguage(o)};return t?e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(Zn,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),s("account.language")]}),e.jsx("select",{value:r.language,onChange:a,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400",children:_a.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:s("account.languageLabel")}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("account.languageDescription")})]}),e.jsx("select",{value:r.language,onChange:a,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-36",children:_a.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]})})}function od({isOpen:t,onClose:r,projects:s=[],initialTab:a="agents"}){const{isDarkMode:n,toggleDarkMode:o}=ya(),{t:i}=Ue("settings"),[c,u]=l.useState([]),[d,m]=l.useState([]),[p,x]=l.useState(""),[h,f]=l.useState(""),[g,k]=l.useState(!1),[w,S]=l.useState(!1),[y,v]=l.useState(null),[T,z]=l.useState("name"),[I,F]=l.useState([]),[B,D]=l.useState(!1),[H,$]=l.useState(null),[R,E]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[U,j]=l.useState(!1),[_,V]=l.useState({}),[ee,M]=l.useState({}),[G,C]=l.useState({}),[b,N]=l.useState(a),[W,A]=l.useState(""),[O,q]=l.useState("claude"),[Z,J]=l.useState("account"),[Q,le]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[ae,fe]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Ee,Pe]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[He,Te]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[be,Ae]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[Re,X]=l.useState([]),[Ce,xe]=l.useState([]),[te,se]=l.useState(!1),[ke,Ne]=l.useState(""),[Ie,Ke]=l.useState(""),[Be,rt]=l.useState([]),[ue,De]=l.useState([]),[je,$e]=l.useState("default"),[ze,Fe]=l.useState(!1),[re,ce]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[Le,Oe]=l.useState(null),[st,kt]=l.useState(!1),[bt,Nt]=l.useState(!1),[it,ie]=l.useState(""),[ve,oe]=l.useState(null),[ye,L]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[K,de]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[We,ot]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),Xe=async()=>{try{const P=await we("/api/cursor/mcp");if(P.ok){const Y=await P.json();rt(Y.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(P){console.error("Error fetching Cursor MCP servers:",P)}},yt=async()=>{try{const P=await we("/api/codex/mcp/config/read");if(P.ok){const ne=await P.json();if(ne.success&&ne.servers){De(ne.servers);return}}const Y=await we("/api/codex/mcp/cli/list");if(Y.ok){const ne=await Y.json();if(ne.success&&ne.servers){const Me=ne.servers.map(ct=>({id:ct.name,name:ct.name,type:ct.type||"stdio",scope:"user",config:{command:ct.command||"",args:ct.args||[],env:ct.env||{}}}));De(Me)}}}catch(P){console.error("Error fetching Codex MCP servers:",P)}},nt=async()=>{try{const P=await we("/api/mcp/config/read");if(P.ok){const Me=await P.json();if(Me.success&&Me.servers){F(Me.servers);return}}const Y=await we("/api/mcp/cli/list");if(Y.ok){const Me=await Y.json();if(Me.success&&Me.servers){const ct=Me.servers.map(Ot=>({id:Ot.name,name:Ot.name,type:Ot.type,scope:"user",config:{command:Ot.command||"",args:Ot.args||[],env:Ot.env||{},url:Ot.url||"",headers:Ot.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));F(ct);return}}const ne=await we("/api/mcp/servers?scope=user");if(ne.ok){const Me=await ne.json();F(Me.servers||[])}else console.error("Failed to fetch MCP servers")}catch(P){console.error("Error fetching MCP servers:",P)}},lt=async P=>{try{H&&await Qt(H.id,"user");const Y=await we("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath,command:P.config?.command,args:P.config?.args||[],url:P.config?.url,headers:P.config?.headers||{},env:P.config?.env||{}})});if(Y.ok){const ne=await Y.json();if(ne.success)return await nt(),!0;throw new Error(ne.error||"Failed to save server via Claude CLI")}else{const ne=await Y.json();throw new Error(ne.error||"Failed to save server")}}catch(Y){throw console.error("Error saving MCP server:",Y),Y}},Qt=async(P,Y="user")=>{try{const ne=await we(`/api/mcp/cli/remove/${P}?scope=${Y}`,{method:"DELETE"});if(ne.ok){const Me=await ne.json();if(Me.success)return await nt(),!0;throw new Error(Me.error||"Failed to delete server via Claude CLI")}else{const Me=await ne.json();throw new Error(Me.error||"Failed to delete server")}}catch(ne){throw console.error("Error deleting MCP server:",ne),ne}},kr=async(P,Y="user")=>{try{const ne=await we(`/api/mcp/servers/${P}/test?scope=${Y}`,{method:"POST"});if(ne.ok)return(await ne.json()).testResult;{const Me=await ne.json();throw new Error(Me.error||"Failed to test server")}}catch(ne){throw console.error("Error testing MCP server:",ne),ne}},Ss=async(P,Y="user")=>{try{const ne=await we(`/api/mcp/servers/${P}/tools?scope=${Y}`,{method:"POST"});if(ne.ok)return(await ne.json()).toolsResult;{const Me=await ne.json();throw new Error(Me.error||"Failed to discover tools")}}catch(ne){throw console.error("Error discovering MCP tools:",ne),ne}},Es=async P=>{try{Le&&await jr(Le.id);const Y=await we("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,command:P.config?.command,args:P.config?.args||[],env:P.config?.env||{}})});if(Y.ok){const ne=await Y.json();if(ne.success)return await yt(),!0;throw new Error(ne.error||"Failed to save Codex MCP server")}else{const ne=await Y.json();throw new Error(ne.error||"Failed to save server")}}catch(Y){throw console.error("Error saving Codex MCP server:",Y),Y}},jr=async P=>{try{const Y=await we(`/api/codex/mcp/cli/remove/${P}`,{method:"DELETE"});if(Y.ok){const ne=await Y.json();if(ne.success)return await yt(),!0;throw new Error(ne.error||"Failed to delete Codex MCP server")}else{const ne=await Y.json();throw new Error(ne.error||"Failed to delete server")}}catch(Y){throw console.error("Error deleting Codex MCP server:",Y),Y}},ir=()=>{ce({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),Oe(null),Fe(!1)},Wr=(P=null)=>{P?(Oe(P),ce({name:P.name,type:P.type||"stdio",config:{command:P.config?.command||"",args:P.config?.args||[],env:P.config?.env||{}}})):ir(),Fe(!0)},Ts=async P=>{P.preventDefault(),kt(!0);try{Le&&await jr(Le.name),await Es(re),ir(),v("success")}catch(Y){alert(`Error: ${Y.message}`),v("error")}finally{kt(!1)}},Is=async P=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await jr(P),v("success")}catch(Y){alert(`Error: ${Y.message}`),v("error")}};l.useEffect(()=>{t&&(Ds(),Ur(),Hr(),Gr(),N(a))},[t,a]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",Q),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Q]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",ae.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ae]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Ee.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ee]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",He.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[He]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",be),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[be]);const Ds=async()=>{try{const P=localStorage.getItem("claude-settings");if(P){const Me=JSON.parse(P);u(Me.allowedTools||[]),m(Me.disallowedTools||[]),k(Me.skipPermissions||!1),z(Me.projectSortOrder||"name")}else u([]),m([]),k(!1),z("name");const Y=localStorage.getItem("cursor-tools-settings");if(Y){const Me=JSON.parse(Y);X(Me.allowedCommands||[]),xe(Me.disallowedCommands||[]),se(Me.skipPermissions||!1)}else X([]),xe([]),se(!1);const ne=localStorage.getItem("codex-settings");if(ne){const Me=JSON.parse(ne);$e(Me.permissionMode||"default")}else $e("default");await nt(),await Xe(),await yt()}catch(P){console.error("Error loading tool settings:",P),u([]),m([]),k(!1),z("name")}},Ur=async()=>{try{const P=await we("/api/cli/claude/status");if(P.ok){const Y=await P.json();L({authenticated:Y.authenticated,email:Y.email,loading:!1,error:Y.error||null})}else L({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Claude auth status:",P),L({authenticated:!1,email:null,loading:!1,error:P.message})}},Hr=async()=>{try{const P=await we("/api/cli/cursor/status");if(P.ok){const Y=await P.json();de({authenticated:Y.authenticated,email:Y.email,loading:!1,error:Y.error||null})}else de({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Cursor auth status:",P),de({authenticated:!1,email:null,loading:!1,error:P.message})}},Gr=async()=>{try{const P=await we("/api/cli/codex/status");if(P.ok){const Y=await P.json();ot({authenticated:Y.authenticated,email:Y.email,loading:!1,error:Y.error||null})}else ot({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Codex auth status:",P),ot({authenticated:!1,email:null,loading:!1,error:P.message})}},As=()=>{ie("claude"),oe(s?.[0]||{name:"default",fullPath:process.cwd()}),Nt(!0)},Ms=()=>{ie("cursor"),oe(s?.[0]||{name:"default",fullPath:process.cwd()}),Nt(!0)},wr=()=>{ie("codex"),oe(s?.[0]||{name:"default",fullPath:process.cwd()}),Nt(!0)},Ps=P=>{P===0&&(v("success"),it==="claude"?Ur():it==="cursor"?Hr():it==="codex"&&Gr())},Fs=()=>{S(!0),v(null);try{const P={allowedTools:c,disallowedTools:d,skipPermissions:g,projectSortOrder:T,lastUpdated:new Date().toISOString()},Y={allowedCommands:Re,disallowedCommands:Ce,skipPermissions:te,lastUpdated:new Date().toISOString()},ne={permissionMode:je,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(P)),localStorage.setItem("cursor-tools-settings",JSON.stringify(Y)),localStorage.setItem("codex-settings",JSON.stringify(ne)),v("success"),setTimeout(()=>{r()},1e3)}catch(P){console.error("Error saving tool settings:",P),v("error")}finally{S(!1)}},Rt=()=>{E({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),$(null),D(!1),A("")},qr=(P=null)=>{P?($(P),E({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath||"",config:{...P.config},raw:P.raw,importMode:"form",jsonInput:""})):Rt(),D(!0)},$s=async P=>{P.preventDefault(),j(!0);try{if(R.importMode==="json"){const Y=await we("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:R.name,jsonConfig:R.jsonInput,scope:R.scope,projectPath:R.projectPath})});if(Y.ok){const ne=await Y.json();if(ne.success)await nt(),Rt(),v("success");else throw new Error(ne.error||"Failed to add server via JSON")}else{const ne=await Y.json();throw new Error(ne.error||"Failed to add server")}}else await lt(R),Rt(),v("success")}catch(Y){alert(`Error: ${Y.message}`),v("error")}finally{j(!1)}},xt=async(P,Y)=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await Qt(P,Y),v("success")}catch(ne){alert(`Error: ${ne.message}`),v("error")}},zt=async(P,Y)=>{try{V({..._,[P]:{loading:!0}});const ne=await kr(P,Y);V({..._,[P]:ne})}catch(ne){V({..._,[P]:{success:!1,message:ne.message,details:[]}})}},La=async(P,Y)=>{try{C({...G,[P]:!0});const ne=await Ss(P,Y);M({...ee,[P]:ne})}catch{M({...ee,[P]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{C({...G,[P]:!1})}},Xt=(P,Y)=>{E(ne=>({...ne,config:{...ne.config,[P]:Y}}))};return t?e.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[e.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ve,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),e.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:i("title")})]}),e.jsx(me,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"border-b border-border",children:e.jsxs("div",{className:"flex px-4 md:px-6",children:[e.jsx("button",{onClick:()=>N("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${b==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.agents")}),e.jsx("button",{onClick:()=>N("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${b==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),e.jsxs("button",{onClick:()=>N("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${b==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx($t,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.git")]}),e.jsxs("button",{onClick:()=>N("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${b==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(va,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]}),e.jsx("button",{onClick:()=>N("tasks"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${b==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.tasks")})]})}),e.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[b==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:b==="appearance"&&e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.darkMode.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.darkMode.description")})]}),e.jsxs("button",{onClick:o,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":n,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${n?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:n?e.jsx(Ys,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Qs,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),e.jsx("div",{className:"space-y-4",children:e.jsx(Mo,{})}),e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.projectSorting.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.projectSorting.description")})]}),e.jsxs("select",{value:T,onChange:P=>z(P.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[e.jsx("option",{value:"name",children:i("appearanceSettings.projectSorting.alphabetical")}),e.jsx("option",{value:"date",children:i("appearanceSettings.projectSorting.recentActivity")})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:i("appearanceSettings.codeEditor.title")}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.theme.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.theme.description")})]}),e.jsxs("button",{onClick:()=>le(Q==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Q==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${Q==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:Q==="dark"?e.jsx(Ys,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Qs,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.wordWrap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.wordWrap.description")})]}),e.jsxs("button",{onClick:()=>fe(!ae),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ae,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${ae?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.showMinimap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.showMinimap.description")})]}),e.jsxs("button",{onClick:()=>Pe(!Ee),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ee,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${Ee?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.description")})]}),e.jsxs("button",{onClick:()=>Te(!He),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":He,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${He?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.fontSize.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.fontSize.description")})]}),e.jsxs("select",{value:be,onChange:P=>Ae(P.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[e.jsx("option",{value:"10",children:"10px"}),e.jsx("option",{value:"11",children:"11px"}),e.jsx("option",{value:"12",children:"12px"}),e.jsx("option",{value:"13",children:"13px"}),e.jsx("option",{value:"14",children:"14px"}),e.jsx("option",{value:"15",children:"15px"}),e.jsx("option",{value:"16",children:"16px"}),e.jsx("option",{value:"18",children:"18px"}),e.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),b==="git"&&e.jsx(Gc,{}),b==="agents"&&e.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[e.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex",children:[e.jsx(ur,{agentId:"claude",authStatus:ye,isSelected:O==="claude",onClick:()=>q("claude"),isMobile:!0}),e.jsx(ur,{agentId:"cursor",authStatus:K,isSelected:O==="cursor",onClick:()=>q("cursor"),isMobile:!0}),e.jsx(ur,{agentId:"codex",authStatus:We,isSelected:O==="codex",onClick:()=>q("codex"),isMobile:!0})]})}),e.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"p-2",children:[e.jsx(ur,{agentId:"claude",authStatus:ye,isSelected:O==="claude",onClick:()=>q("claude")}),e.jsx(ur,{agentId:"cursor",authStatus:K,isSelected:O==="cursor",onClick:()=>q("cursor")}),e.jsx(ur,{agentId:"codex",authStatus:We,isSelected:O==="codex",onClick:()=>q("codex")})]})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[e.jsx("button",{onClick:()=>J("account"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${Z==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.account")}),e.jsx("button",{onClick:()=>J("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${Z==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.permissions")}),e.jsx("button",{onClick:()=>J("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${Z==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.mcpServers")})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[Z==="account"&&e.jsx(Yc,{agent:O,authStatus:O==="claude"?ye:O==="cursor"?K:We,onLogin:O==="claude"?As:O==="cursor"?Ms:wr}),Z==="permissions"&&O==="claude"&&e.jsx(Os,{agent:"claude",skipPermissions:g,setSkipPermissions:k,allowedTools:c,setAllowedTools:u,disallowedTools:d,setDisallowedTools:m,newAllowedTool:p,setNewAllowedTool:x,newDisallowedTool:h,setNewDisallowedTool:f}),Z==="permissions"&&O==="cursor"&&e.jsx(Os,{agent:"cursor",skipPermissions:te,setSkipPermissions:se,allowedCommands:Re,setAllowedCommands:X,disallowedCommands:Ce,setDisallowedCommands:xe,newAllowedCommand:ke,setNewAllowedCommand:Ne,newDisallowedCommand:Ie,setNewDisallowedCommand:Ke}),Z==="permissions"&&O==="codex"&&e.jsx(Os,{agent:"codex",permissionMode:je,setPermissionMode:$e}),Z==="mcp"&&O==="claude"&&e.jsx(Bs,{agent:"claude",servers:I,onAdd:()=>qr(),onEdit:P=>qr(P),onDelete:(P,Y)=>xt(P,Y),onTest:(P,Y)=>zt(P,Y),onDiscoverTools:(P,Y)=>La(P,Y),testResults:_,serverTools:ee,toolsLoading:G}),Z==="mcp"&&O==="cursor"&&e.jsx(Bs,{agent:"cursor",servers:Be,onAdd:()=>{},onEdit:P=>{},onDelete:P=>{}}),Z==="mcp"&&O==="codex"&&e.jsx(Bs,{agent:"codex",servers:ue,onAdd:()=>Wr(),onEdit:P=>Wr(P),onDelete:P=>Is(P)})]})]})]}),B&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(H?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(me,{variant:"ghost",size:"sm",onClick:Rt,children:e.jsx(qe,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:$s,className:"p-4 space-y-4",children:[!H&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>E(P=>({...P,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${R.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.form")}),e.jsx("button",{type:"button",onClick:()=>E(P=>({...P,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${R.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.json")})]}),R.importMode==="form"&&H&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.scope.label")}),e.jsxs("div",{className:"flex items-center gap-2",children:[R.scope==="user"?e.jsx(Rr,{className:"w-4 h-4"}):e.jsx(Kt,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:R.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),R.scope==="local"&&R.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",R.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),R.importMode==="form"&&!H&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.scope.label")," *"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>E(P=>({...P,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${R.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(Rr,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),e.jsx("button",{type:"button",onClick:()=>E(P=>({...P,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${R.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(Kt,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.projectLocal")})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:R.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),R.scope==="local"&&!H&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.selectProject")," *"]}),e.jsxs("select",{value:R.projectPath,onChange:P=>E(Y=>({...Y,projectPath:P.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:R.scope==="local",children:[e.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),s.map(P=>e.jsx("option",{value:P.path||P.fullPath,children:P.displayName||P.name},P.name))]}),R.projectPath&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:R.projectPath})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:R.importMode==="json"?"md:col-span-2":"",children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),e.jsx(Qe,{value:R.name,onChange:P=>{E(Y=>({...Y,name:P.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),R.importMode==="form"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.transportType")," *"]}),e.jsxs("select",{value:R.type,onChange:P=>{E(Y=>({...Y,type:P.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"sse",children:"SSE"}),e.jsx("option",{value:"http",children:"HTTP"})]})]})]}),H&&R.raw&&R.importMode==="form"&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:i("mcpForm.configDetails",{configFile:H.scope==="global"?"~/.claude.json":"project config"})}),e.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(R.raw,null,2)})]}),R.importMode==="json"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.jsonConfig")," *"]}),e.jsx("textarea",{value:R.jsonInput,onChange:P=>{E(Y=>({...Y,jsonInput:P.target.value}));try{if(P.target.value.trim()){const Y=JSON.parse(P.target.value);Y.type?Y.type==="stdio"&&!Y.command?A(i("mcpForm.validation.stdioRequiresCommand")):(Y.type==="http"||Y.type==="sse")&&!Y.url?A(i("mcpForm.validation.httpRequiresUrl",{type:Y.type})):A(""):A(i("mcpForm.validation.missingType"))}}catch{P.target.value.trim()?A(i("mcpForm.validation.invalidJson")):A("")}},className:`w-full px-3 py-2 border ${W?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
3
- "type": "stdio",
4
- "command": "/path/to/server",
5
- "args": ["--api-key", "abc123"],
6
- "env": {
7
- "CACHE_DIR": "/tmp"
8
- }
9
- }`,required:!0}),W&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:W}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[i("mcpForm.validation.jsonHelp"),e.jsx("br",{}),"• stdio: ",'{"type":"stdio","command":"npx","args":["@upstash/context7-mcp"]}',e.jsx("br",{}),"• http/sse: ",'{"type":"http","url":"https://api.example.com/mcp"}']})]})}),R.importMode==="form"&&R.type==="stdio"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),e.jsx(Qe,{value:R.config.command,onChange:P=>Xt("command",P.target.value),placeholder:"/path/to/mcp-server",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),e.jsx("textarea",{value:Array.isArray(R.config.args)?R.config.args.join(`
10
- `):"",onChange:P=>Xt("args",P.target.value.split(`
11
- `).filter(Y=>Y.trim())),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`--api-key
12
- abc123`})]})]}),R.importMode==="form"&&(R.type==="sse"||R.type==="http")&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.url")," *"]}),e.jsx(Qe,{value:R.config.url,onChange:P=>Xt("url",P.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),R.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),e.jsx("textarea",{value:Object.entries(R.config.env||{}).map(([P,Y])=>`${P}=${Y}`).join(`
13
- `),onChange:P=>{const Y={};P.target.value.split(`
14
- `).forEach(ne=>{const[Me,...ct]=ne.split("=");Me&&Me.trim()&&(Y[Me.trim()]=ct.join("=").trim())}),Xt("env",Y)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`API_KEY=your-key
15
- DEBUG=true`})]}),R.importMode==="form"&&(R.type==="sse"||R.type==="http")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.headers")}),e.jsx("textarea",{value:Object.entries(R.config.headers||{}).map(([P,Y])=>`${P}=${Y}`).join(`
16
- `),onChange:P=>{const Y={};P.target.value.split(`
17
- `).forEach(ne=>{const[Me,...ct]=ne.split("=");Me&&Me.trim()&&(Y[Me.trim()]=ct.join("=").trim())}),Xt("headers",Y)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`Authorization=Bearer token
18
- X-API-Key=your-key`})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(me,{type:"button",variant:"outline",onClick:Rt,children:i("mcpForm.actions.cancel")}),e.jsx(me,{type:"submit",disabled:U,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:i(U?"mcpForm.actions.saving":H?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),ze&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(Le?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(me,{variant:"ghost",size:"sm",onClick:ir,children:e.jsx(qe,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:Ts,className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),e.jsx(Qe,{value:re.name,onChange:P=>ce(Y=>({...Y,name:P.target.value})),placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),e.jsx(Qe,{value:re.config?.command||"",onChange:P=>ce(Y=>({...Y,config:{...Y.config,command:P.target.value}})),placeholder:"npx @my-org/mcp-server",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),e.jsx("textarea",{value:(re.config?.args||[]).join(`
19
- `),onChange:P=>ce(Y=>({...Y,config:{...Y.config,args:P.target.value.split(`
20
- `).filter(ne=>ne.trim())}})),placeholder:`--port
21
- 3000`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),e.jsx("textarea",{value:Object.entries(re.config?.env||{}).map(([P,Y])=>`${P}=${Y}`).join(`
22
- `),onChange:P=>{const Y={};P.target.value.split(`
23
- `).forEach(ne=>{const[Me,...ct]=ne.split("=");Me&&ct.length>0&&(Y[Me.trim()]=ct.join("=").trim())}),ce(ne=>({...ne,config:{...ne.config,env:Y}}))},placeholder:`API_KEY=xxx
24
- DEBUG=true`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[e.jsx(me,{type:"button",variant:"outline",onClick:ir,children:i("mcpForm.actions.cancel")}),e.jsx(me,{type:"submit",disabled:st||!re.name||!re.config?.command,className:"bg-green-600 hover:bg-green-700 text-white",children:i(st?"mcpForm.actions.saving":Le?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),b==="tasks"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(qc,{})}),b==="api"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(Hc,{})})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[e.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[y==="success"&&e.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.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"})}),i("saveStatus.success")]}),y==="error"&&e.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),i("saveStatus.error")]})]}),e.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[e.jsx(me,{variant:"outline",onClick:r,disabled:w,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),e.jsx(me,{onClick:Fs,disabled:w,className:"flex-1 sm:flex-none h-10 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 touch-manipulation",children:w?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),i("saveStatus.saving")]}):i("footerActions.save")})]})]})]}),e.jsx(Yi,{isOpen:bt,onClose:()=>Nt(!1),provider:it,project:ve,onComplete:Ps,isAuthenticated:it==="claude"?ye.authenticated:it==="cursor"?K.authenticated:it==="codex"?We.authenticated:!1},it)]}):null}function id({isOpen:t,onClose:r,releaseInfo:s,currentVersion:a,latestVersion:n}){const{t:o}=Ue("common"),[i,c]=l.useState(!1),[u,d]=l.useState(""),[m,p]=l.useState(""),x=l.useCallback(async()=>{c(!0),d(`Starting update...
25
- `),p("");try{const h=await we("/api/system/update",{method:"POST"}),f=await h.json();h.ok?(d(g=>g+f.output+`
26
- `),d(g=>g+`
27
- ✅ Update completed successfully!
28
- `),d(g=>g+`Please restart the server to apply changes.
29
- `)):(p(f.error||"Update failed"),d(g=>g+`
30
- ❌ Update failed: `+(f.error||"Unknown error")+`
31
- `))}catch(h){p(h.message),d(f=>f+`
32
- ❌ Update failed: `+h.message+`
33
- `)}finally{c(!1)}},[]);return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:r,"aria-label":o("versionUpdate.ariaLabels.closeModal")}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-2xl mx-4 p-6 space-y-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-lg flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:o("versionUpdate.title")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s?.title||o("versionUpdate.newVersionReady")})]})]}),e.jsx("button",{onClick:r,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:o("versionUpdate.currentVersion")}),e.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:a})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-700",children:[e.jsx("span",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:o("versionUpdate.latestVersion")}),e.jsx("span",{className:"text-sm text-blue-900 dark:text-blue-100 font-mono",children:n})]})]}),s?.body&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:o("versionUpdate.whatsNew")}),s?.htmlUrl&&e.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline flex items-center gap-1",children:[o("versionUpdate.viewFullRelease"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4 border border-gray-200 dark:border-gray-600 max-h-64 overflow-y-auto",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap prose prose-sm dark:prose-invert max-w-none",children:ld(s.body)})})]}),(u||m)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:o("versionUpdate.updateProgress")}),e.jsx("div",{className:"bg-gray-900 dark:bg-gray-950 rounded-lg p-4 border border-gray-700 max-h-48 overflow-y-auto",children:e.jsx("pre",{className:"text-xs text-green-400 font-mono whitespace-pre-wrap",children:u})}),m&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900/40 dark:bg-red-900/20 dark:text-red-200",children:m})]}),!i&&!u&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:o("versionUpdate.manualUpgrade")}),e.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border",children:e.jsx("code",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono",children:"git checkout main && git pull && npm install"})}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:o("versionUpdate.manualUpgradeHint")})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx("button",{onClick:r,className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors",children:o(u?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!u&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{navigator.clipboard.writeText("git checkout main && git pull && npm install")},className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors",children:o("versionUpdate.buttons.copyCommand")}),e.jsx("button",{onClick:x,disabled:i,className:"flex-1 px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 disabled:cursor-not-allowed rounded-md transition-colors flex items-center justify-center gap-2",children:i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),o("versionUpdate.buttons.updating")]}):o("versionUpdate.buttons.updateNow")})]})]})]})]}):null}const ld=t=>t?t.replace(/\b[0-9a-f]{40}\b/gi,"").replace(/(?:^|\s|-)([0-9a-f]{7,10})\b/gi,"").replace(/\*\*Full Changelog\*\*:.*$/gim,"").replace(/https?:\/\/github\.com\/[^\/]+\/[^\/]+\/compare\/[^\s)]+/gi,"").replace(/\n\s*\n\s*\n/g,`
34
-
35
- `).trim():"",cd=od;function dd(t){return e.jsx(cd,{...t})}function ud({projects:t,showSettings:r,settingsInitialTab:s,onCloseSettings:a,showNewProject:n,onCloseNewProject:o,onProjectCreated:i,deleteConfirmation:c,onCancelDeleteProject:u,onConfirmDeleteProject:d,sessionDeleteConfirmation:m,onCancelDeleteSession:p,onConfirmDeleteSession:x,showVersionModal:h,onCloseVersionModal:f,releaseInfo:g,currentVersion:k,latestVersion:w,t:S}){const y=l.useMemo(()=>t.map(Ll),[t]);return e.jsxs(e.Fragment,{children:[n&&Kr.createPortal(e.jsx(Wc,{onClose:o,onProjectCreated:i}),document.body),r&&Kr.createPortal(e.jsx(dd,{isOpen:r,onClose:a,projects:y,initialTab:s}),document.body),c&&Kr.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx(Lt,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:S("deleteConfirmation.deleteProject")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[S("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:c.project.displayName||c.project.name}),"?"]}),c.sessionCount>0&&e.jsxs("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:S("deleteConfirmation.sessionCount",{count:c.sessionCount})}),e.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:S("deleteConfirmation.allConversationsDeleted")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:S("deleteConfirmation.cannotUndo")})]})]})}),e.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[e.jsx(me,{variant:"outline",className:"flex-1",onClick:u,children:S("actions.cancel")}),e.jsxs(me,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:d,children:[e.jsx(ut,{className:"w-4 h-4 mr-2"}),S("actions.delete")]})]})]})}),document.body),m&&Kr.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx(Lt,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:S("deleteConfirmation.deleteSession")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[S("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:m.sessionTitle||S("sessions.unnamed")}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:S("deleteConfirmation.cannotUndo")})]})]})}),e.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[e.jsx(me,{variant:"outline",className:"flex-1",onClick:p,children:S("actions.cancel")}),e.jsxs(me,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:x,children:[e.jsx(ut,{className:"w-4 h-4 mr-2"}),S("actions.delete")]})]})]})}),document.body),e.jsx(id,{isOpen:h,onClose:f,releaseInfo:g,currentVersion:k,latestVersion:w})]})}function ln({projects:t,selectedProject:r,selectedSession:s,onProjectSelect:a,onSessionSelect:n,onNewSession:o,onSessionDelete:i,onProjectDelete:c,isLoading:u,loadingProgress:d,onRefresh:m,onShowSettings:p,showSettings:x,settingsInitialTab:h,onCloseSettings:f,isMobile:g}){const{t:k}=Ue(["sidebar","common"]),{isPWA:w}=Ea({trackMobile:!1}),{updateAvailable:S,latestVersion:y,currentVersion:v,releaseInfo:T}=po("thinqmesh","upfynai-code"),{preferences:z,setPreference:I}=Ta(),{sidebarVisible:F}=z,{setCurrentProject:B,mcpServerStatus:D}=yr(),{tasksEnabled:H}=Or(),{isSidebarCollapsed:$,expandedProjects:R,editingProject:E,showNewProject:U,editingName:j,loadingSessions:_,initialSessionsLoaded:V,currentTime:ee,isRefreshing:M,editingSession:G,editingSessionName:C,searchFilter:b,deletingProjects:N,deleteConfirmation:W,sessionDeleteConfirmation:A,showVersionModal:O,filteredProjects:q,handleTouchClick:Z,toggleProject:J,handleSessionClick:Q,toggleStarProject:le,isProjectStarred:ae,getProjectSessions:fe,startEditing:Ee,cancelEditing:Pe,saveProjectName:He,showDeleteSessionConfirmation:Te,confirmDeleteSession:be,requestProjectDelete:Ae,confirmDeleteProject:Re,loadMoreSessions:X,handleProjectSelect:Ce,refreshProjects:xe,updateSessionSummary:te,collapseSidebar:se,expandSidebar:ke,setShowNewProject:Ne,setEditingName:Ie,setEditingSession:Ke,setEditingSessionName:Be,setSearchFilter:rt,setDeleteConfirmation:ue,setSessionDeleteConfirmation:De,setShowVersionModal:je}=_l({projects:t,selectedProject:r,selectedSession:s,isLoading:u,isMobile:g,t:k,onRefresh:m,onProjectSelect:a,onSessionSelect:n,onSessionDelete:i,onProjectDelete:c,setCurrentProject:B,setSidebarVisible:Fe=>I("sidebarVisible",Fe),sidebarVisible:F});l.useEffect(()=>{typeof document>"u"||(document.documentElement.classList.toggle("pwa-mode",w),document.body.classList.toggle("pwa-mode",w))},[w]);const $e=()=>{if(window.refreshProjects){window.refreshProjects();return}window.location.reload()},ze={projects:t,filteredProjects:q,selectedProject:r,selectedSession:s,isLoading:u,loadingProgress:d,expandedProjects:R,editingProject:E,editingName:j,loadingSessions:_,initialSessionsLoaded:V,currentTime:ee,editingSession:G,editingSessionName:C,deletingProjects:N,tasksEnabled:H,mcpServerStatus:D,getProjectSessions:fe,isProjectStarred:ae,onEditingNameChange:Ie,onToggleProject:J,onProjectSelect:Ce,onToggleStarProject:le,onStartEditingProject:Ee,onCancelEditingProject:Pe,onSaveProjectName:Fe=>{He(Fe)},onDeleteProject:Ae,onSessionSelect:Q,onDeleteSession:Te,onLoadMoreSessions:Fe=>{X(Fe)},onNewSession:o,onEditingSessionNameChange:Be,onStartEditingSession:(Fe,re)=>{Ke(Fe),Be(re)},onCancelEditingSession:()=>{Ke(null),Be("")},onSaveEditingSession:(Fe,re,ce)=>{te(Fe,re,ce)},touchHandlerFactory:Z,t:k};return e.jsxs(e.Fragment,{children:[e.jsx(ud,{projects:t,showSettings:x,settingsInitialTab:h,onCloseSettings:f,showNewProject:U,onCloseNewProject:()=>Ne(!1),onProjectCreated:$e,deleteConfirmation:W,onCancelDeleteProject:()=>ue(null),onConfirmDeleteProject:Re,sessionDeleteConfirmation:A,onCancelDeleteSession:()=>De(null),onConfirmDeleteSession:be,showVersionModal:O,onCloseVersionModal:()=>je(!1),releaseInfo:T,currentVersion:v,latestVersion:y,t:k}),$?e.jsx(Rl,{onExpand:ke,onShowSettings:p,updateAvailable:S,onShowVersionModal:()=>je(!0),t:k}):e.jsx(e.Fragment,{children:e.jsx(Bc,{isPWA:w,isMobile:g,isLoading:u,projects:t,searchFilter:b,onSearchFilterChange:rt,onClearSearchFilter:()=>rt(""),onRefresh:()=>{xe()},isRefreshing:M,onCreateProject:()=>Ne(!0),onCollapseSidebar:se,updateAvailable:S,releaseInfo:T,latestVersion:y,onShowVersionModal:()=>je(!0),onShowSettings:p,projectListProps:ze,t:k})})]})}function md(){const{isDarkMode:t,toggleDarkMode:r}=ya();return e.jsxs("button",{onClick:r,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":t,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${t?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:t?e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})}):e.jsx("svg",{className:"w-3.5 h-3.5 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})})]})}const pd=()=>{const{t}=Ue("settings"),[r,s]=l.useState(!1),[a,n]=l.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:o}=ya(),{isMobile:i}=Ea({trackPWA:!1}),{preferences:c,setPreference:u}=Ta(),{autoExpandTools:d,showRawParameters:m,showThinking:p,autoScrollToBottom:x,sendByCtrlEnter:h}=c,[f,g]=l.useState(()=>{const j=localStorage.getItem("quickSettingsHandlePosition");if(j)try{return JSON.parse(j).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[k,w]=l.useState(!1),[S,y]=l.useState(0),[v,T]=l.useState(0),[z,I]=l.useState(!1),F=l.useRef(null),B=l.useRef({min:10,max:90}),D=5;l.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:f}))},[f]);const H=l.useCallback(()=>i?{bottom:`${window.innerHeight*f/100}px`}:{top:`${f}%`,transform:"translateY(-50%)"},[f,i]),$=l.useCallback(j=>{j.stopPropagation();const _=j.type.includes("touch")?j.touches[0].clientY:j.clientY;y(_),T(f),I(!1),w(!1)},[f]),R=l.useCallback(j=>{if(S===0)return;const _=j.type.includes("touch")?j.touches[0].clientY:j.clientY,V=Math.abs(_-S);if(!k&&V>D&&(w(!0),I(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",j.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!k)return;j.type.includes("touch")&&j.preventDefault();const ee=_-S;let M;i?M=-(ee/window.innerHeight)*100:M=ee/window.innerHeight*100;let G=v+M;G=Math.max(B.current.min,Math.min(B.current.max,G)),g(G)},[k,S,v,i,D]),E=l.useCallback(()=>{w(!1),y(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);l.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),l.useEffect(()=>{if(S!==0){const j=M=>R(M),_=()=>E(),V=M=>R(M),ee=()=>E();return document.addEventListener("mousemove",j),document.addEventListener("mouseup",_),document.addEventListener("touchmove",V,{passive:!1}),document.addEventListener("touchend",ee),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",V),document.removeEventListener("touchend",ee)}}},[S,R,E]);const U=j=>{if(z){j.preventDefault(),I(!1);return}s(_=>!_)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:F,onClick:U,onMouseDown:j=>{$(j)},onTouchStart:j=>{$(j)},className:`fixed ${r?"right-64":"right-0"} z-50 ${k?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${k?"border-blue-500 dark:border-blue-400":"border-gray-200 dark:border-gray-700"} rounded-l-md p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shadow-lg ${k?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...H(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":t(k?"quickSettings.dragHandle.dragging":r?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:t(k?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:k?e.jsx(ji,{className:"h-5 w-5 text-blue-500 dark:text-blue-400"}):r?e.jsx(At,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(Qn,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${r?"translate-x-0":"translate-x-full"} ${i?"h-screen":""}`,children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(wi,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),t("quickSettings.title")]})}),e.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${i?"pb-mobile-nav":""}`,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.appearance")}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[o?e.jsx(Ys,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):e.jsx(Qs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.darkMode")]}),e.jsx(md,{})]}),e.jsx("div",{children:e.jsx(Mo,{compact:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.toolDisplay")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(wa,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoExpandTools")]}),e.jsx("input",{type:"checkbox",checked:d,onChange:j=>u("autoExpandTools",j.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ar,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showRawParameters")]}),e.jsx("input",{type:"checkbox",checked:m,onChange:j=>u("showRawParameters",j.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ws,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showThinking")]}),e.jsx("input",{type:"checkbox",checked:p,onChange:j=>u("showThinking",j.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.viewOptions")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(eo,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoScrollToBottom")]}),e.jsx("input",{type:"checkbox",checked:x,onChange:j=>u("autoScrollToBottom",j.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.inputSettings")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(Zn,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.sendByCtrlEnter")]}),e.jsx("input",{type:"checkbox",checked:h,onChange:j=>u("sendByCtrlEnter",j.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:t("quickSettings.sendByCtrlEnterDescription")})]}),e.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.whisperDictation")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:a==="default",onChange:()=>{n("default"),localStorage.setItem("whisperMode","default"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(ns,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.default")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.defaultDescription")})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:a==="prompt",onChange:()=>{n("prompt"),localStorage.setItem("whisperMode","prompt"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(Ft,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.prompt")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.promptDescription")})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:a==="vibe"||a==="instructions"||a==="architect",onChange:()=>{n("vibe"),localStorage.setItem("whisperMode","vibe"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(et,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.vibe")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.vibeDescription")})]})]})]})]})]})]})}),r&&e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:U})]})};function It(t){return t&&t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function xd(t){if(!t||typeof t!="string")return t;try{return t.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return t}}function Qr(t){if(!t||typeof t!="string")return t;const r=[],s="__MATH_BLOCK_",a="__";let n=t.replace(/\$\$([\s\S]*?)\$\$|\$([^\$\n]+?)\$/g,o=>{const i=r.length;return r.push(o),`${s}${i}${a}`});return n=n.replace(/\\n/g,`
36
- `).replace(/\\t/g," ").replace(/\\r/g,"\r"),n=n.replace(new RegExp(`${s}(\\d+)${a}`,"g"),(o,i)=>r[parseInt(i,10)]),n}function Po(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function aa(t){try{return typeof t!="string"?t:t.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),o=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(n),i=-n.getTimezoneOffset(),c=i>=0?"+":"-",u=Math.abs(i),d=Math.floor(u/60),m=u%60,p=`GMT${c}${d}${m?":"+String(m).padStart(2,"0"):""}`,f=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,S=>S.toUpperCase()),g=f?`${p} (${f})`:p,k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],w=`${n.getDate()} ${k[n.getMonth()]} ${n.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${o} ${g}** - ${w}`})}catch{return t}}const gd=({node:t,inline:r,className:s,children:a,...n})=>{const{t:o}=Ue("chat"),[i,c]=l.useState(!1),u=Array.isArray(a)?a.join(""):String(a??""),d=/[\r\n]/.test(u);if(r||t&&t.type==="inlineCode"||!d)return e.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${s||""}`,...n,children:a});const x=/language-(\w+)/.exec(s||""),h=x?x[1]:"text",f=u,g=()=>{const k=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(f).then(k).catch(()=>{const w=document.createElement("textarea");w.value=f,w.style.position="fixed",w.style.opacity="0",document.body.appendChild(w),w.select();try{document.execCommand("copy")}catch{}document.body.removeChild(w),k()});else{const w=document.createElement("textarea");w.value=f,w.style.position="fixed",w.style.opacity="0",document.body.appendChild(w),w.select();try{document.execCommand("copy")}catch{}document.body.removeChild(w),k()}}catch{}};return e.jsxs("div",{className:"relative group my-2",children:[h&&h!=="text"&&e.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:h}),e.jsx("button",{type:"button",onClick:g,className:"absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 focus:opacity-100 active:opacity-100 transition-opacity text-xs px-2 py-1 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",title:o(i?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":o(i?"codeBlock.copied":"codeBlock.copyCode"),children:i?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.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"})}),o("codeBlock.copied")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),o("codeBlock.copy")]})}),e.jsx(Xi,{language:h,style:Zi,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:h&&h!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:u})]})},hd={code:gd,blockquote:({children:t})=>e.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:t}),a:({href:t,children:r})=>e.jsx("a",{href:t,className:"text-blue-600 dark:text-blue-400 hover:underline",target:"_blank",rel:"noopener noreferrer",children:r}),p:({children:t})=>e.jsx("div",{className:"mb-2 last:mb-0",children:t}),table:({children:t})=>e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:t})}),thead:({children:t})=>e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:t}),th:({children:t})=>e.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:t}),td:({children:t})=>e.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:t})};function Fr({children:t,className:r}){const s=xd(String(t??"")),a=l.useMemo(()=>[el,tl],[]),n=l.useMemo(()=>[rl],[]);return e.jsx("div",{className:r,children:e.jsx(sl,{remarkPlugins:a,rehypePlugins:n,components:hd,children:s})})}const Fo="claude-settings",dt={setItem:(t,r)=>{try{if(t.startsWith("chat_messages_")&&typeof r=="string")try{const s=JSON.parse(r);if(Array.isArray(s)&&s.length>50){const a=s.slice(-50);r=JSON.stringify(a)}}catch(s){console.warn("Could not parse chat messages for truncation:",s)}localStorage.setItem(t,r)}catch(s){if(s?.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const a=Object.keys(localStorage),n=a.filter(i=>i.startsWith("chat_messages_")).sort();n.length>3&&n.slice(0,n.length-3).forEach(i=>{localStorage.removeItem(i)}),a.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(t,r)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),t.startsWith("chat_messages_")&&typeof r=="string")try{const c=JSON.parse(r);if(Array.isArray(c)&&c.length>10){const u=c.slice(-10);localStorage.setItem(t,JSON.stringify(u))}}catch(c){console.error("Final save attempt failed:",c)}}}else console.error("localStorage error:",s)}},getItem:t=>{try{return localStorage.getItem(t)}catch(r){return console.error("localStorage getItem error:",r),null}},removeItem:t=>{try{localStorage.removeItem(t)}catch(r){console.error("localStorage removeItem error:",r)}}};function Ma(){const t=dt.getItem(Fo);if(!t)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const r=JSON.parse(t);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 na(t,r){if(!t)return null;if(t!=="Bash")return t;const s=Tc(r),a=typeof s?.command=="string"?s.command.trim():"";if(!a)return t;const n=a.split(/\s+/);return n.length===0?t:n[0]==="git"&&n[1]?`Bash(${n[0]} ${n[1]}:*)`:`Bash(${n[0]}:*)`}function cn(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function fd(t,r){if(r!=="claude"||!t?.toolResult?.isError)return null;const s=t?.toolName,a=na(s,t.toolInput);if(!a)return null;const o=Ma().allowedTools.includes(a);return{toolName:s||"UnknownTool",entry:a,isAllowed:o}}function bd(t){if(!t)return{success:!1};const r=Ma(),s=r.allowedTools.includes(t),a=s?r.allowedTools:[...r.allowedTools,t],n=r.disallowedTools.filter(i=>i!==t),o={...r,allowedTools:a,disallowedTools:n,lastUpdated:new Date().toISOString()};return dt.setItem(Fo,JSON.stringify(o)),{success:!0,alreadyAllowed:s,updatedSettings:o}}const dn={Bash:{input:{type:"one-line",icon:"terminal",getValue:t=>t.command,getSecondary:t=>t.description,action:"copy",style:"terminal",wrapText:!0,colorScheme:{primary:"text-green-400 font-mono",secondary:"text-gray-400",background:"",border:"border-green-500 dark:border-green-400",icon:"text-green-500 dark:text-green-400"}},result:{hideOnSuccess:!0,type:"special"}},Read:{input:{type:"one-line",label:"Read",getValue:t=>t.file_path||"",action:"open-file",colorScheme:{primary:"text-gray-700 dark:text-gray-300",background:"",border:"border-gray-300 dark:border-gray-600",icon:"text-gray-500 dark:text-gray-400"}},result:{hidden:!0}},Edit:{input:{type:"collapsible",title:t=>`${t.file_path?.split("/").pop()||t.file_path||"file"}`,defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:t.old_string,newContent:t.new_string,filePath:t.file_path,badge:"Edit",badgeColor:"gray"})},result:{hideOnSuccess:!0}},Write:{input:{type:"collapsible",title:t=>`${t.file_path?.split("/").pop()||t.file_path||"file"}`,defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:"",newContent:t.content,filePath:t.file_path,badge:"New",badgeColor:"green"})},result:{hideOnSuccess:!0}},ApplyPatch:{input:{type:"collapsible",title:t=>`${t.file_path?.split("/").pop()||t.file_path||"file"}`,defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:t.old_string,newContent:t.new_string,filePath:t.file_path,badge:"Patch",badgeColor:"gray"})},result:{hideOnSuccess:!0}},Grep:{input:{type:"one-line",label:"Grep",getValue:t=>t.pattern,getSecondary:t=>t.path?`in ${t.path}`:void 0,action:"jump-to-results",colorScheme:{primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-400 dark:border-gray-500",icon:"text-gray-500 dark:text-gray-400"}},result:{type:"collapsible",defaultOpen:!1,title:t=>{const r=t.toolUseResult||{},s=r.numFiles||r.filenames?.length||0;return`Found ${s} ${s===1?"file":"files"}`},contentType:"file-list",getContentProps:t=>({files:(t.toolUseResult||{}).filenames||[]})}},Glob:{input:{type:"one-line",label:"Glob",getValue:t=>t.pattern,getSecondary:t=>t.path?`in ${t.path}`:void 0,action:"jump-to-results",colorScheme:{primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-400 dark:border-gray-500",icon:"text-gray-500 dark:text-gray-400"}},result:{type:"collapsible",defaultOpen:!1,title:t=>{const r=t.toolUseResult||{},s=r.numFiles||r.filenames?.length||0;return`Found ${s} ${s===1?"file":"files"}`},contentType:"file-list",getContentProps:t=>({files:(t.toolUseResult||{}).filenames||[]})}},TodoWrite:{input:{type:"collapsible",title:"Updating todo list",defaultOpen:!1,contentType:"todo-list",getContentProps:t=>({todos:t.todos})},result:{type:"collapsible",contentType:"success-message",getMessage:()=>"Todo list updated"}},TodoRead:{input:{type:"one-line",label:"TodoRead",getValue:()=>"reading list",action:"none",colorScheme:{primary:"text-gray-500 dark:text-gray-400",border:"border-violet-400 dark:border-violet-500"}},result:{type:"collapsible",contentType:"todo-list",getContentProps:t=>{try{const r=String(t.content||"");let s=null;return r.startsWith("[")&&(s=JSON.parse(r)),{todos:s,isResult:!0}}catch{return{todos:[],isResult:!0}}}}},TaskCreate:{input:{type:"one-line",label:"Task",getValue:t=>t.subject||"Creating task",getSecondary:t=>t.status||void 0,action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{hideOnSuccess:!0}},TaskUpdate:{input:{type:"one-line",label:"Task",getValue:t=>{const r=[];return t.taskId&&r.push(`#${t.taskId}`),t.status&&r.push(t.status),t.subject&&r.push(`"${t.subject}"`),r.join(" → ")||"updating"},action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{hideOnSuccess:!0}},TaskList:{input:{type:"one-line",label:"Tasks",getValue:()=>"listing tasks",action:"none",colorScheme:{primary:"text-gray-500 dark:text-gray-400",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{type:"collapsible",defaultOpen:!0,title:"Task list",contentType:"task",getContentProps:t=>({content:String(t?.content||"")})}},TaskGet:{input:{type:"one-line",label:"Task",getValue:t=>t.taskId?`#${t.taskId}`:"fetching",action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{type:"collapsible",defaultOpen:!0,title:"Task details",contentType:"task",getContentProps:t=>({content:String(t?.content||"")})}},Task:{input:{type:"collapsible",title:t=>{const r=t.subagent_type||"Agent",s=t.description||"Running task";return`Subagent / ${r}: ${s}`},defaultOpen:!1,contentType:"markdown",getContentProps:t=>{if(t.prompt&&!t.model&&!t.resume)return{content:t.prompt||""};const s=[];return t.model&&s.push(`**Model:** ${t.model}`),t.prompt&&s.push(`**Prompt:**
37
- ${t.prompt}`),t.resume&&s.push(`**Resuming from:** ${t.resume}`),{content:s.join(`
38
-
39
- `)}},colorScheme:{border:"border-purple-500 dark:border-purple-400",icon:"text-purple-500 dark:text-purple-400"}},result:{type:"collapsible",title:"Subagent result",defaultOpen:!1,contentType:"markdown",getContentProps:t=>{if(t&&t.content){let r=t.content;if(typeof r=="string")try{const s=JSON.parse(r);Array.isArray(s)&&(r=s)}catch{return{content:r}}return Array.isArray(r)?{content:r.filter(a=>a.type==="text").map(a=>a.text).join(`
40
-
41
- `)||"No response text"}:{content:String(r)}}return{content:String(t||"No response")}}}},AskUserQuestion:{input:{type:"collapsible",title:t=>{const r=t.questions?.length||0,s=t.answers&&Object.keys(t.answers).length>0;if(r===1){const a=t.questions[0]?.header||"Question";return s?`${a} — answered`:a}return s?`${r} questions — answered`:`${r} questions`},defaultOpen:!0,contentType:"question-answer",getContentProps:t=>({questions:t.questions||[],answers:t.answers||{}})},result:{hideOnSuccess:!0}},exit_plan_mode:{input:{type:"collapsible",title:"Implementation plan",defaultOpen:!0,contentType:"markdown",getContentProps:t=>({content:t.plan?.replace(/\\n/g,`
42
- `)||t.plan})},result:{type:"collapsible",contentType:"markdown",getContentProps:t=>{try{let r=t.content;return typeof r=="string"&&(r=JSON.parse(r)),{content:r.plan?.replace(/\\n/g,`
43
- `)||r.plan}}catch{return{content:""}}}}},ExitPlanMode:{input:{type:"collapsible",title:"Implementation plan",defaultOpen:!0,contentType:"markdown",getContentProps:t=>({content:t.plan?.replace(/\\n/g,`
44
- `)||t.plan})},result:{type:"collapsible",contentType:"markdown",getContentProps:t=>{try{let r=t.content;return typeof r=="string"&&(r=JSON.parse(r)),{content:r.plan?.replace(/\\n/g,`
45
- `)||r.plan}}catch{return{content:""}}}}},Default:{input:{type:"collapsible",title:"Parameters",defaultOpen:!1,contentType:"text",getContentProps:t=>({content:typeof t=="string"?t:JSON.stringify(t,null,2),format:"code"})},result:{type:"collapsible",contentType:"text",getContentProps:t=>({content:String(t?.content||""),format:"plain"})}}};function $o(t){return dn[t]||dn.Default}function yd(t,r){const s=$o(t);return s.result?!!(s.result.hidden||s.result.hideOnSuccess&&r&&!r.isError):!1}const Lo=({title:t,toolName:r,open:s=!1,action:a,onTitleClick:n,children:o,className:i=""})=>e.jsxs("details",{className:`relative group/details ${i}`,open:s,children:[e.jsxs("summary",{className:"flex items-center gap-1.5 text-xs cursor-pointer py-0.5 select-none group-open/details:sticky group-open/details:top-0 group-open/details:z-10 group-open/details:bg-background group-open/details:-mx-1 group-open/details:px-1",children:[e.jsx("svg",{className:"w-3 h-3 text-gray-400 dark:text-gray-500 transition-transform duration-150 group-open/details:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r&&e.jsx("span",{className:"font-medium text-gray-500 dark:text-gray-400 flex-shrink-0",children:r}),r&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px] flex-shrink-0",children:"/"}),n?e.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),n()},className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono hover:underline truncate flex-1 text-left transition-colors",children:t}):e.jsx("span",{className:"text-gray-600 dark:text-gray-400 truncate flex-1",children:t}),a&&e.jsx("span",{className:"flex-shrink-0 ml-1",children:a})]}),e.jsx("div",{className:"mt-1.5 pl-[18px]",children:o})]}),vd=({oldContent:t,newContent:r,filePath:s,createDiff:a,onFileClick:n,badge:o="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",u=l.useMemo(()=>a(t,r),[a,t,r]);return e.jsxs("div",{className:"border border-gray-200/60 dark:border-gray-700/50 rounded overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1 bg-gray-50/80 dark:bg-gray-800/40 border-b border-gray-200/60 dark:border-gray-700/50",children:[n?e.jsx("button",{onClick:n,className:"text-[11px] font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 truncate cursor-pointer transition-colors",children:s}):e.jsx("span",{className:"text-[11px] font-mono text-gray-600 dark:text-gray-400 truncate",children:s}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-px rounded ${c} flex-shrink-0 ml-2`,children:o})]}),e.jsx("div",{className:"text-[11px] font-mono leading-[18px]",children:u.map((d,m)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-6 text-center select-none flex-shrink-0 ${d.type==="removed"?"bg-red-50 dark:bg-red-950/30 text-red-400 dark:text-red-500":"bg-green-50 dark:bg-green-950/30 text-green-400 dark:text-green-500"}`,children:d.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 flex-1 whitespace-pre-wrap ${d.type==="removed"?"bg-red-50/50 dark:bg-red-950/20 text-red-800 dark:text-red-200":"bg-green-50/50 dark:bg-green-950/20 text-green-800 dark:text-green-200"}`,children:d.content})]},m))})]})},kd=t=>{if(typeof document>"u"||!document.body)return!1;const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.left="-9999px",document.body.appendChild(r),r.select(),r.setSelectionRange(0,t.length);let s=!1;try{s=document.execCommand("copy")}catch{s=!1}finally{document.body.removeChild(r)}return s},jd=async t=>{if(typeof navigator<"u"&&typeof window<"u"&&window.isSecureContext&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(t),!0}catch{}return kd(t)},wd=({toolName:t,icon:r,label:s,value:a,secondary:n,action:o="none",onAction:i,style:c,wrapText:u=!1,colorScheme:d={primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-300 dark:border-gray-600",icon:"text-gray-500 dark:text-gray-400"},resultId:m,toolResult:p,toolId:x})=>{const[h,f]=l.useState(!1),g=c==="terminal",k=async()=>{if(o==="copy"&&a){if(!await jd(a))return;f(!0),setTimeout(()=>f(!1),2e3)}else i&&i()},w=()=>e.jsx("button",{onClick:k,className:"opacity-0 group-hover:opacity-100 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-all ml-1 flex-shrink-0",title:"Copy to clipboard","aria-label":"Copy to clipboard",children:h?e.jsx("svg",{className:"w-3 h-3 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"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(g)return e.jsxs("div",{className:"group my-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"flex items-center gap-1.5 flex-shrink-0 pt-0.5",children:e.jsx("svg",{className:"w-3 h-3 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-start gap-2",children:[e.jsx("div",{className:"bg-gray-900 dark:bg-black rounded px-2.5 py-1 flex-1 min-w-0",children:e.jsxs("code",{className:`text-xs text-green-400 font-mono ${u?"whitespace-pre-wrap break-all":"block truncate"}`,children:[e.jsx("span",{className:"text-green-600 dark:text-green-500 select-none",children:"$ "}),a]})}),o==="copy"&&w()]})]}),n&&e.jsx("div",{className:"ml-7 mt-1",children:e.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:n})})]});if(o==="open-file"){const S=a.split("/").pop()||a;return e.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("button",{onClick:k,className:"text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono hover:underline transition-colors truncate",title:a,children:S})]})}return o==="jump-to-results"?e.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("span",{className:`text-xs font-mono truncate flex-1 min-w-0 ${d.primary}`,children:a}),n&&e.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic flex-shrink-0",children:n}),p&&e.jsx("a",{href:`#tool-result-${x}`,className:"flex-shrink-0 text-[11px] text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors flex items-center gap-0.5",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}):e.jsxs("div",{className:`group flex items-center gap-1.5 ${d.background||""} border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[r&&r!=="terminal"&&e.jsx("span",{className:`${d.icon} flex-shrink-0 text-xs`,children:r}),!r&&(s||t)&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),(r||s||t)&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("span",{className:`text-xs font-mono ${u?"whitespace-pre-wrap break-all":"truncate"} flex-1 min-w-0 ${d.primary}`,children:a}),n&&e.jsx("span",{className:`text-[11px] ${d.secondary} italic flex-shrink-0`,children:n}),o==="copy"&&w()]})},un={edit:"border-l-amber-500 dark:border-l-amber-400",search:"border-l-gray-400 dark:border-l-gray-500",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-gray-300 dark:border-l-gray-600"},Nd=({toolName:t,title:r,defaultOpen:s=!1,action:a,onTitleClick:n,children:o,showRawParameters:i=!1,rawContent:c,className:u="",toolCategory:d})=>{const m=un[d||"default"]||un.default;return e.jsx("div",{className:`border-l-2 ${m} pl-3 py-0.5 my-1 ${u}`,children:e.jsxs(Lo,{title:r,toolName:t,open:s,action:a,onTitleClick:n,children:[o,i&&c&&e.jsxs("details",{className:"relative mt-2 group/raw",children:[e.jsxs("summary",{className:"flex items-center gap-1.5 text-[11px] text-gray-400 dark:text-gray-500 cursor-pointer hover:text-gray-600 dark:hover:text-gray-300 py-0.5",children:[e.jsx("svg",{className:"w-2.5 h-2.5 transition-transform duration-150 group-open/raw:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"raw params"]}),e.jsx("pre",{className:"mt-1 text-[11px] bg-gray-50 dark:bg-gray-900/50 border border-gray-200/40 dark:border-gray-700/40 p-2 rounded whitespace-pre-wrap break-words overflow-hidden text-gray-600 dark:text-gray-400 font-mono",children:c})]})]})})},Xr=(t,r)=>{const s=typeof r=="string"?(()=>{try{return JSON.parse(r)}catch{return{}}})():r||{};switch(t){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""}},Cd=({toolInput:t,toolResult:r,subagentState:s})=>{const a=typeof t=="string"?(()=>{try{return JSON.parse(t)}catch{return{}}})():t||{},n=a?.subagent_type||"Agent",o=a?.description||"Running task",i=a?.prompt||"",{childTools:c,currentToolIndex:u,isComplete:d}=s,m=u>=0?c[u]:null,p=`Subagent / ${n}: ${o}`;return e.jsx("div",{className:"border-l-2 border-l-purple-500 dark:border-l-purple-400 pl-3 py-0.5 my-1",children:e.jsxs(Lo,{title:p,toolName:"Task",open:!1,children:[i&&e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mb-2 whitespace-pre-wrap break-words line-clamp-4",children:i}),m&&!d&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mt-1",children:[e.jsx("span",{className:"animate-pulse w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 flex-shrink-0"}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Currently:"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:m.toolName}),Xr(m.toolName,m.toolInput)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"/"}),e.jsx("span",{className:"font-mono truncate text-gray-500 dark:text-gray-400",children:Xr(m.toolName,m.toolInput)})]})]}),d&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400 mt-1",children:[e.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsxs("span",{children:["Completed (",c.length," ",c.length===1?"tool":"tools",")"]})]}),c.length>0&&e.jsxs("details",{className:"mt-2 group/history",children:[e.jsxs("summary",{className:"cursor-pointer text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 flex items-center gap-1",children:[e.jsx("svg",{className:"w-2.5 h-2.5 transition-transform duration-150 group-open/history:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsxs("span",{children:["View tool history (",c.length,")"]})]}),e.jsx("div",{className:"mt-1 pl-3 border-l border-gray-200 dark:border-gray-700 space-y-0.5",children:c.map((x,h)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{className:"text-gray-400 dark:text-gray-500 w-4 text-right flex-shrink-0",children:[h+1,"."]}),e.jsx("span",{className:"font-medium",children:x.toolName}),Xr(x.toolName,x.toolInput)&&e.jsx("span",{className:"font-mono truncate text-gray-400 dark:text-gray-500",children:Xr(x.toolName,x.toolInput)}),x.toolResult?.isError&&e.jsx("span",{className:"text-red-500 flex-shrink-0",children:"(error)"})]},x.toolId))})]}),d&&r&&e.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:(()=>{let x=r.content;if(typeof x=="string")try{const h=JSON.parse(x);if(Array.isArray(h)){const f=h.filter(g=>g.type==="text"&&g.text).map(g=>g.text);f.length>0&&(x=f.join(`
46
- `))}}catch{}else if(Array.isArray(x)){const h=x.filter(f=>f.type==="text"&&f.text).map(f=>f.text);h.length>0&&(x=h.join(`
47
- `))}return typeof x=="string"?e.jsx("div",{className:"whitespace-pre-wrap break-words line-clamp-6",children:x}):x?e.jsx("pre",{className:"whitespace-pre-wrap break-words line-clamp-6 font-mono text-[11px]",children:JSON.stringify(x,null,2)}):null})()})]})})},Sd=({content:t,className:r="mt-1 prose prose-sm max-w-none dark:prose-invert"})=>e.jsx(Fr,{className:r,children:t}),Ed=({files:t,onFileClick:r,title:s})=>e.jsxs("div",{children:[s&&e.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400 mb-1",children:s}),e.jsx("div",{className:"flex flex-wrap gap-x-1 gap-y-0.5 max-h-48 overflow-y-auto",children:t.map((a,n)=>{const o=typeof a=="string"?a:a.path,i=o.split("/").pop()||o,c=typeof a=="string"?()=>r?.(a):a.onClick;return e.jsxs("span",{className:"inline-flex items-center",children:[e.jsx("button",{onClick:c,className:"text-[11px] font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline transition-colors",title:o,children:i}),n<t.length-1&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px] ml-1",children:","})]},n)})})]}),Td=({todos:t,isResult:r=!1})=>{if(!t||!Array.isArray(t))return null;const s=o=>{switch(o){case"completed":return e.jsx(Ni,{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(Lr,{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400"});default:return e.jsx(xr,{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500"})}},a=o=>{switch(o){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 border-green-200 dark:border-green-800";case"in_progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-200 border-blue-200 dark:border-blue-800";default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},n=o=>{switch(o){case"high":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800";case"medium":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800";default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}};return e.jsxs("div",{className:"space-y-1.5",children:[r&&e.jsxs("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1.5",children:["Todo List (",t.length," ",t.length===1?"item":"items",")"]}),t.map((o,i)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:s(o.status)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-0.5",children:[e.jsx("p",{className:`text-xs font-medium ${o.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:o.content}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(wt,{variant:"outline",className:`text-[10px] px-1.5 py-px ${n(o.priority)}`,children:o.priority}),e.jsx(wt,{variant:"outline",className:`text-[10px] px-1.5 py-px ${a(o.status)}`,children:o.status.replace("_"," ")})]})]})})]},o.id||`todo-${i}`))]})},Id=({todos:t,isResult:r=!1})=>e.jsx(Td,{todos:t,isResult:r});function Dd(t){const r=[],s=t.split(`
48
- `);for(const a of s){const n=a.match(/#(\d+)\.?\s*(?:\[(\w+)\]\s*)?(.+?)(?:\s*\((?:owner:\s*\w+)?\))?$/);if(n){const[,o,i,c]=n,u=a.match(/blockedBy:\s*\[([^\]]*)\]/);r.push({id:o,subject:c.trim(),status:i||"pending",blockedBy:u?u[1].split(",").map(d=>d.trim()).filter(Boolean):void 0})}}return r}const mn={completed:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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:e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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:e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"}},Ad=({content:t})=>{const r=Dd(t);if(r.length===0)return e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap",children:t});const s=r.filter(n=>n.status==="completed").length,a=r.length;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[s,"/",a," completed"]}),e.jsx("div",{className:"flex-1 h-1 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 dark:bg-green-400 rounded-full transition-all",style:{width:`${a>0?s/a*100:0}%`}})})]}),e.jsx("div",{className:"space-y-px",children:r.map(n=>{const o=mn[n.status]||mn.pending;return e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 group",children:[e.jsx("span",{className:"flex-shrink-0",children:o.icon}),e.jsxs("span",{className:"text-[11px] font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:["#",n.id]}),e.jsx("span",{className:`text-xs truncate flex-1 ${o.textClass}`,children:n.subject}),e.jsx("span",{className:`text-[10px] px-1 py-px rounded border flex-shrink-0 ${o.badgeClass}`,children:n.status.replace("_"," ")})]},n.id)})})]})},Md=({content:t,format:r="plain",className:s=""})=>{if(r==="json"){let a=t;try{const n=JSON.parse(t);a=JSON.stringify(n,null,2)}catch{}return e.jsx("pre",{className:`mt-1 text-xs bg-gray-900 dark:bg-gray-950 text-gray-100 p-2.5 rounded overflow-x-auto font-mono ${s}`,children:a})}return r==="code"?e.jsx("pre",{className:`mt-1 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/50 dark:border-gray-700/50 p-2 rounded whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono ${s}`,children:t}):e.jsx("div",{className:`mt-1 text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap ${s}`,children:t})},Pd=({questions:t,answers:r,className:s=""})=>{const[a,n]=l.useState(null);if(!t||t.length===0)return null;const o=Object.keys(r||{}).length>0,i=t.length;return e.jsxs("div",{className:`space-y-2 ${s}`,children:[t.map((c,u)=>{const d=r?.[c.question],m=d?d.split(", "):[],p=!d,x=a===u;return e.jsxs("div",{className:"rounded-lg border border-gray-150 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/30 overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>n(x?null:u),className:"w-full text-left px-3 py-2 flex items-start gap-2.5 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-4 h-4 rounded-full flex items-center justify-center ${m.length>0?"bg-blue-100 dark:bg-blue-900/40":"bg-gray-100 dark:bg-gray-800"}`,children:m.length>0?e.jsx("svg",{className:"w-2.5 h-2.5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-300 dark:bg-gray-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.header&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100/80 dark:border-blue-800/40",children:c.header}),i>1&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500",children:[u+1,"/",i]})]}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5 leading-snug",children:c.question}),!x&&m.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:m.map(h=>{const f=!c.options.some(g=>g.label===h);return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded-md bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium",children:[h,f&&e.jsx("span",{className:"text-[9px] text-blue-400 dark:text-blue-500 font-normal",children:"(custom)"})]},h)})}),!x&&p&&o&&e.jsx("span",{className:"inline-block mt-1 text-[10px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]}),e.jsx("svg",{className:`w-3.5 h-3.5 mt-0.5 text-gray-400 dark:text-gray-500 flex-shrink-0 transition-transform duration-200 ${x?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),x&&e.jsx("div",{className:"px-3 pb-2.5 pt-0.5 border-t border-gray-100 dark:border-gray-700/40",children:e.jsxs("div",{className:"space-y-1 ml-6.5",children:[c.options.map(h=>{const f=m.includes(h.label);return e.jsxs("div",{className:`flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] ${f?"bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40":"text-gray-400 dark:text-gray-500"}`,children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${c.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] flex items-center justify-center ${f?"border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500":"border-gray-300 dark:border-gray-600"}`,children:f&&e.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:f?"text-gray-900 dark:text-gray-100 font-medium":"",children:h.label}),h.description&&e.jsx("span",{className:`block text-[11px] mt-0.5 ${f?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-600"}`,children:h.description})]})]},h.label)}),m.filter(h=>!c.options.some(f=>f.label===h)).map(h=>e.jsxs("div",{className:"flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${c.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500 flex items-center justify-center`,children:e.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium",children:h}),e.jsx("span",{className:"text-[10px] text-blue-500 dark:text-blue-400 ml-1",children:"(custom)"})]})]},h)),p&&o&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic px-2.5 py-1",children:"No answer provided"})]})})]},u)}),!o&&i===1&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]})},Fd=({request:t,onDecision:r})=>{const s=t.input,a=s?.questions||[],[n,o]=l.useState(0),[i,c]=l.useState(()=>new Map),[u,d]=l.useState(()=>new Map),[m,p]=l.useState(()=>new Map),[x,h]=l.useState(!1),f=l.useRef(null),g=l.useRef(null);l.useEffect(()=>{requestAnimationFrame(()=>h(!0))},[]),l.useEffect(()=>{m.get(n)||f.current?.focus()},[n,m]),l.useEffect(()=>{m.get(n)&&g.current?.focus()},[m,n]);const k=l.useCallback((j,_,V)=>{c(ee=>{const M=new Map(ee),G=new Set(M.get(j)||[]);return V?G.has(_)?G.delete(_):G.add(_):(G.clear(),G.add(_),p(C=>{const b=new Map(C);return b.set(j,!1),b})),M.set(j,G),M})},[]),w=l.useCallback((j,_)=>{p(V=>{const ee=new Map(V),M=ee.get(j)||!1;return ee.set(j,!M),!_&&!M&&c(G=>{const C=new Map(G);return C.set(j,new Set),C}),ee})},[]),S=l.useCallback((j,_)=>{d(V=>{const ee=new Map(V);return ee.set(j,_),ee})},[]),y=l.useCallback(()=>{const j={};return a.forEach((_,V)=>{const ee=Array.from(i.get(V)||[]),M=m.get(V)||!1,G=(u.get(V)||"").trim();M&&G&&ee.push(G),ee.length>0&&(j[_.question]=ee.join(", "))}),j},[a,i,m,u]),v=l.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:y()}})},[r,t.requestId,s,y]),T=l.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:{}}})},[r,t.requestId,s]),z=l.useCallback(j=>{if(j.target instanceof HTMLInputElement)return;const _=a[n];if(!_)return;const V=_.multiSelect||!1,ee=_.options.length,M=parseInt(j.key);if(!isNaN(M)&&M>=1&&M<=ee){j.preventDefault(),k(n,_.options[M-1].label,V);return}if(j.key==="0"){j.preventDefault(),w(n,V);return}if(j.key==="Enter"){j.preventDefault(),n===a.length-1?v():o(C=>C+1);return}if(j.key==="Escape"){j.preventDefault(),T();return}},[n,a,k,w,v,T]);if(a.length===0)return null;const I=a.length,F=I===1,B=a[n],D=B.multiSelect||!1,H=i.get(n)||new Set,$=m.get(n)||!1,R=n===I-1,E=n===0,U=H.size>0||$&&(u.get(n)||"").trim().length>0;return e.jsx("div",{ref:f,tabIndex:-1,onKeyDown:z,className:`w-full outline-none transition-all duration-500 ease-out ${x?"opacity-100 translate-y-0":"opacity-0 translate-y-3"}`,children:e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-gray-200/80 dark:border-gray-700/50 bg-white dark:bg-gray-800/90 shadow-lg dark:shadow-2xl",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-blue-500 via-cyan-400 to-teal-400"}),e.jsxs("div",{className:"px-4 pt-3.5 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"w-6 h-6 rounded-lg bg-gradient-to-br from-blue-500/10 to-cyan-500/10 dark:from-blue-400/15 dark:to-cyan-400/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.75,stroke:"currentColor",children:e.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"})})}),e.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-cyan-400 dark:bg-cyan-500 animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"text-[10px] font-medium tracking-wide uppercase text-gray-400 dark:text-gray-500",children:"Claude needs your input"}),B.header&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-px rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100 dark:border-blue-800/50",children:B.header})]}),!F&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500 flex-shrink-0",children:[n+1,"/",I]})]}),!F&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:a.map((j,_)=>e.jsx("button",{type:"button",onClick:()=>o(_),className:`h-[3px] rounded-full transition-all duration-300 ${_===n?"w-5 bg-blue-500 dark:bg-blue-400":_<n?"w-2.5 bg-blue-300 dark:bg-blue-600":"w-2.5 bg-gray-200 dark:bg-gray-700"}`},_))}),e.jsx("p",{className:"text-[14px] leading-snug font-medium text-gray-900 dark:text-gray-100",children:B.question}),D&&e.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500",children:"Select all that apply"})]}),e.jsx("div",{className:"px-4 pb-2 max-h-48 overflow-y-auto scrollbar-thin",role:D?"group":"radiogroup","aria-label":B.question,children:e.jsxs("div",{className:"space-y-1",children:[B.options.map((j,_)=>{const V=H.has(j.label);return e.jsxs("button",{type:"button",onClick:()=>k(n,j.label,D),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${V?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[e.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${V?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:_+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-[13px] leading-tight transition-colors duration-150 ${V?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-700 dark:text-gray-300"}`,children:j.label}),j.description&&e.jsx("div",{className:`text-[11px] leading-snug transition-colors duration-150 ${V?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-500"}`,children:j.description})]}),V&&e.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]},j.label)}),e.jsxs("button",{type:"button",onClick:()=>w(n,D),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${$?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-dashed border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[e.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${$?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:"0"}),e.jsx("span",{className:`text-[13px] leading-tight transition-colors ${$?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-500 dark:text-gray-400"}`,children:"Other..."}),$&&e.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]}),$&&e.jsx("div",{className:"pl-[30px] pr-0.5",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:g,type:"text",value:u.get(n)||"",onChange:j=>S(n,j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),R?v():o(_=>_+1)),j.stopPropagation()},placeholder:"Type your answer...",className:"w-full text-[13px] rounded-lg border-0 bg-gray-50 dark:bg-gray-900/60 text-gray-900 dark:text-gray-100 px-3 py-1.5 outline-none ring-1 ring-gray-200 dark:ring-gray-700 focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 placeholder:text-gray-400 dark:placeholder:text-gray-600 transition-shadow duration-200"}),e.jsx("kbd",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[9px] font-mono text-gray-300 dark:text-gray-600 bg-gray-100 dark:bg-gray-800 px-1 py-0.5 rounded border border-gray-200 dark:border-gray-700",children:"Enter"})]})})]})}),e.jsxs("div",{className:"px-4 py-2 border-t border-gray-100 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/50 flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:T,className:"text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:[F?"Skip":"Skip all",e.jsx("span",{className:"ml-1 text-[9px] text-gray-300 dark:text-gray-600",children:"Esc"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[!F&&!E&&e.jsxs("button",{type:"button",onClick:()=>o(j=>j-1),className:"inline-flex items-center gap-0.5 text-[11px] font-medium px-2.5 py-1.5 rounded-lg text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700/60 transition-all duration-150",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),"Back"]}),R?e.jsxs("button",{type:"button",onClick:v,disabled:!U&&!Object.keys(y()).length,className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md disabled:opacity-30 disabled:cursor-not-allowed disabled:shadow-none transition-all duration-200",children:["Submit",e.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]}):e.jsxs("button",{type:"button",onClick:()=>o(j=>j+1),className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md transition-all duration-200",children:["Next",e.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]})]})]})]})})};function $d(t){return["Edit","Write","ApplyPatch"].includes(t)?"edit":["Grep","Glob"].includes(t)?"search":t==="Bash"?"bash":["TodoWrite","TodoRead"].includes(t)?"todo":["TaskCreate","TaskUpdate","TaskList","TaskGet"].includes(t)?"task":t==="Task"?"agent":t==="exit_plan_mode"||t==="ExitPlanMode"?"plan":t==="AskUserQuestion"?"question":"default"}const oa=l.memo(({toolName:t,toolInput:r,toolResult:s,toolId:a,mode:n,onFileOpen:o,createDiff:i,selectedProject:c,autoExpandTools:u=!1,showRawParameters:d=!1,rawToolInput:m,isSubagentContainer:p,subagentState:x})=>{if(p&&x)return n==="result"?null:e.jsx(Cd,{toolInput:r,toolResult:s,subagentState:x});const h=$o(t),f=n==="input"?h.input:h.result,g=l.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=l.useCallback(()=>{if(f?.action==="open-file"&&o){const w=f.getValue?.(g)||"";o(w)}},[f,g,o]);if(!f)return null;if(f.type==="one-line"){const w=f.getValue?.(g)||"",S=f.getSecondary?.(g);return e.jsx(wd,{toolName:t,toolResult:s,toolId:a,icon:f.icon,label:f.label,value:w,secondary:S,action:f.action,onAction:k,style:f.style,wrapText:f.wrapText,colorScheme:f.colorScheme,resultId:n==="input"?`tool-result-${a}`:void 0})}if(f.type==="collapsible"){const w=typeof f.title=="function"?f.title(g):f.title||"Details",S=f.defaultOpen!==void 0?f.defaultOpen:u,y=f.getContentProps?.(g,{selectedProject:c,createDiff:i,onFileOpen:o})||{};let v=null;switch(f.contentType){case"diff":i&&(v=e.jsx(vd,{...y,createDiff:i,onFileClick:()=>o?.(y.filePath)}));break;case"markdown":v=e.jsx(Sd,{content:y.content||""});break;case"file-list":v=e.jsx(Ed,{files:y.files||[],onFileClick:o,title:y.title});break;case"todo-list":y.todos?.length>0&&(v=e.jsx(Id,{todos:y.todos,isResult:y.isResult}));break;case"task":v=e.jsx(Ad,{content:y.content||""});break;case"question-answer":v=e.jsx(Pd,{questions:y.questions||[],answers:y.answers||{}});break;case"text":v=e.jsx(Md,{content:y.content||"",format:y.format||"plain"});break;case"success-message":{const z=f.getMessage?.(g)||"Success";v=e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),z]});break}}const T=(t==="Edit"||t==="Write"||t==="ApplyPatch")&&y.filePath&&o?()=>o(y.filePath,{old_string:y.oldContent,new_string:y.newContent}):void 0;return e.jsx(Nd,{toolName:t,toolId:a,title:w,defaultOpen:S,onTitleClick:T,showRawParameters:n==="input"&&d,rawContent:m,toolCategory:$d(t),children:v})}return null});oa.displayName="ToolRenderer";const Ld=l.memo(({message:t,index:r,prevMessage:s,createDiff:a,onFileOpen:n,onShowSettings:o,onGrantToolPermission:i,autoExpandTools:c,showRawParameters:u,showThinking:d,selectedProject:m,provider:p})=>{const{t:x}=Ue("chat"),h=s&&s.type===t.type&&(s.type==="assistant"||s.type==="user"||s.type==="tool"||s.type==="error"),f=Et.useRef(null),[g,k]=Et.useState(!1),w=fd(t,p),[S,y]=Et.useState("idle");Et.useEffect(()=>{y("idle")},[w?.entry,t.toolId]),Et.useEffect(()=>{const z=f.current;if(!c||!z||!t.isToolUse)return;const I=new IntersectionObserver(F=>{F.forEach(B=>{B.isIntersecting&&!g&&(k(!0),z.querySelectorAll("details").forEach(H=>{H.open=!0}))})},{threshold:.1});return I.observe(z),()=>{I.unobserve(z)}},[c,g,t.isToolUse]);const v=l.useMemo(()=>new Date(t.timestamp).toLocaleTimeString(),[t.timestamp]);return t.isThinking&&!d?null:e.jsx("div",{ref:f,className:`chat-message ${t.type} ${h?"grouped":""} ${t.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:t.type==="user"?e.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[e.jsxs("div",{className:"bg-blue-600 text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[e.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:t.content}),t.images&&t.images.length>0&&e.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:t.images.map((z,I)=>e.jsx("img",{src:z.data,alt:z.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(z.data,"_blank")},z.name||I))}),e.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:v})]}),!h&&e.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-blue-600 rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):t.isTaskNotification?e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${t.taskStatus==="completed"?"bg-green-400 dark:bg-green-500":"bg-amber-400 dark:bg-amber-500"}`}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:t.content})]})}):e.jsxs("div",{className:"w-full",children:[!h&&e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[t.type==="error"?e.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):t.type==="tool"?e.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:e.jsx(jt,{provider:p,className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.type==="error"?x("messageTypes.error"):t.type==="tool"?x("messageTypes.tool"):x(p==="cursor"?"messageTypes.cursor":p==="codex"?"messageTypes.codex":"messageTypes.claude")})]}),e.jsxs("div",{className:"w-full",children:[t.isToolUse?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(Fr,{className:"prose prose-sm max-w-none dark:prose-invert",children:String(t.displayText||"")})})}),t.toolInput&&e.jsx(oa,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"input",onFileOpen:n,createDiff:a,selectedProject:m,autoExpandTools:c,showRawParameters:u,rawToolInput:typeof t.toolInput=="string"?t.toolInput:void 0,isSubagentContainer:t.isSubagentContainer,subagentState:t.subagentState}),t.toolResult&&!yd(t.toolName||"UnknownTool",t.toolResult)&&(t.toolResult.isError?e.jsxs("div",{id:`tool-result-${t.toolId}`,className:"relative mt-2 p-3 rounded border scroll-mt-4 bg-red-50/50 dark:bg-red-950/10 border-red-200/60 dark:border-red-800/40",children:[e.jsxs("div",{className:"relative flex items-center gap-1.5 mb-2",children:[e.jsx("svg",{className:"w-4 h-4 text-red-500 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"text-xs font-medium text-red-700 dark:text-red-300",children:x("messageTypes.error")})]}),e.jsxs("div",{className:"relative text-sm text-red-900 dark:text-red-100",children:[e.jsx(Fr,{className:"prose prose-sm max-w-none prose-red dark:prose-invert",children:String(t.toolResult.content||"")}),w&&e.jsxs("div",{className:"mt-4 border-t border-red-200/60 dark:border-red-800/60 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{if(!i)return;i(w)?.success?y("granted"):y("error")},disabled:w.isAllowed||S==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${w.isAllowed||S==="granted"?"bg-green-100 dark:bg-green-900/30 border-green-300/70 dark:border-green-800/60 text-green-800 dark:text-green-200 cursor-default":"bg-white/80 dark:bg-gray-900/40 border-red-300/70 dark:border-red-800/60 text-red-700 dark:text-red-200 hover:bg-white dark:hover:bg-gray-900/70"}`,children:w.isAllowed||S==="granted"?x("permissions.added"):x("permissions.grant",{tool:w.toolName})}),o&&e.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),o()},className:"text-xs text-red-700 dark:text-red-200 underline hover:text-red-800 dark:hover:text-red-100",children:x("permissions.openSettings")})]}),e.jsx("div",{className:"mt-2 text-xs text-red-700/90 dark:text-red-200/80",children:x("permissions.addTo",{entry:w.entry})}),S==="error"&&e.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:x("permissions.error")}),(w.isAllowed||S==="granted")&&e.jsx("div",{className:"mt-2 text-xs text-green-700 dark:text-green-200",children:x("permissions.retry")})]})]})]}):e.jsx("div",{id:`tool-result-${t.toolId}`,className:"scroll-mt-4",children:e.jsx(oa,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"result",onFileOpen:n,createDiff:a,selectedProject:m,autoExpandTools:c})}))]}):t.isInteractivePrompt?e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-amber-900 dark:text-amber-100 text-base mb-3",children:x("interactive.title")}),(()=>{const z=(t.content||"").split(`
49
- `).filter(B=>B.trim()),I=z.find(B=>B.includes("?"))||z[0]||"",F=[];return z.forEach(B=>{const D=B.match(/[❯\s]*(\d+)\.\s+(.+)/);if(D){const H=B.includes("❯");F.push({number:D[1],text:D[2].trim(),isSelected:H})}}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:I}),e.jsx("div",{className:"space-y-2 mb-4",children:F.map(B=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${B.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${B.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:B.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:B.text}),B.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},B.number))}),e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:x("interactive.waiting")}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:x("interactive.instruction")})]})]})})()]})]})}):t.isThinking?e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("span",{children:x("thinking.emoji")})]}),e.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:e.jsx(Fr,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:t.content})})]})}):e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[d&&t.reasoning&&e.jsxs("details",{className:"mb-3",children:[e.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:x("thinking.emoji")}),e.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:e.jsx("div",{className:"whitespace-pre-wrap",children:t.reasoning})})]}),(()=>{const z=aa(String(t.content||"")),I=z.trim();if((I.startsWith("{")||I.startsWith("["))&&(I.endsWith("}")||I.endsWith("]")))try{const F=JSON.parse(I),B=JSON.stringify(F,null,2);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"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"})}),e.jsx("span",{className:"font-medium",children:x("json.response")})]}),e.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("pre",{className:"p-4 overflow-x-auto",children:e.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:B})})})]})}catch{}return t.type==="assistant"?e.jsx(Fr,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:z}):e.jsx("div",{className:"whitespace-pre-wrap",children:z})})()]}),!h&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 mt-1",children:v})]})]})})}),_o=({task:t,onClose:r,onEdit:s,onStatusChange:a,onTaskClick:n,isOpen:o=!0,className:i=""})=>{const[c,u]=l.useState(!1),[d,m]=l.useState(t||{}),[p,x]=l.useState(!1),[h,f]=l.useState(!1),[g,k]=l.useState(!1),{currentProject:w,refreshTasks:S}=yr();if(!o||!t)return null;const y=async()=>{if(w){x(!0);try{const D={};if(d.title!==t.title&&(D.title=d.title),d.description!==t.description&&(D.description=d.description),d.details!==t.details&&(D.details=d.details),Object.keys(D).length>0){const H=await Ge.taskmaster.updateTask(w.name,t.id,D);if(H.ok)S?.(),s?.(d),u(!1);else{const $=await H.json();console.error("Failed to update task:",$),alert(`Failed to update task: ${$.message}`)}}else u(!1)}catch(D){console.error("Error updating task:",D),alert("Error updating task. Please try again.")}finally{x(!1)}}},v=()=>{navigator.clipboard.writeText(t.id.toString())},T=D=>{switch(D){case"done":return{icon:Br,color:"text-green-600 dark:text-green-400",bg:"bg-green-50 dark:bg-green-950"};case"in-progress":return{icon:Lr,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-50 dark:bg-blue-950"};case"review":return{icon:ks,color:"text-amber-600 dark:text-amber-400",bg:"bg-amber-50 dark:bg-amber-950"};case"deferred":return{icon:ro,color:"text-gray-500 dark:text-gray-400",bg:"bg-gray-50 dark:bg-gray-800"};case"cancelled":return{icon:qe,color:"text-red-600 dark:text-red-400",bg:"bg-red-50 dark:bg-red-950"};default:return{icon:xr,color:"text-slate-500 dark:text-slate-400",bg:"bg-slate-50 dark:bg-slate-800"}}},z=T(t.status),I=z.icon,F=D=>{switch(D){case"high":return"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950";case"medium":return"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-950";case"low":return"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950";default:return"text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800"}},B=[{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"}];return e.jsx("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[100] md:p-4 bg-black/50",children:e.jsxs("div",{className:he("bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 md:rounded-lg shadow-xl","w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",i),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx(I,{className:he("w-6 h-6",z.color)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("button",{onClick:v,className:"flex items-center gap-1 px-2 py-1 text-xs bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",title:"Click to copy task ID",children:[e.jsxs("span",{children:["Task ",t.id]}),e.jsx(ka,{className:"w-3 h-3"})]}),t.parentId&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Subtask of Task ",t.parentId]})]}),c?e.jsx("input",{type:"text",value:d.title||"",onChange:D=>m({...d,title:D.target.value}),className:"w-full text-lg font-semibold bg-transparent border-b-2 border-blue-500 focus:outline-none text-gray-900 dark:text-white",placeholder:"Task title"}):e.jsx("h1",{className:"text-lg md:text-xl font-semibold text-gray-900 dark:text-white line-clamp-2",children:t.title})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:y,disabled:p,className:"p-2 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:p?"Saving...":"Save changes",children:e.jsx(is,{className:he("w-5 h-5",p&&"animate-spin")})}),e.jsx("button",{onClick:()=>{u(!1),m(t)},disabled:p,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Cancel editing",children:e.jsx(qe,{className:"w-5 h-5"})})]}):e.jsx("button",{onClick:()=>u(!0),className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Edit task",children:e.jsx(Ci,{className:"w-5 h-5"})}),e.jsx("button",{onClick:r,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Close",children:e.jsx(qe,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 md:p-6 space-y-6 min-h-0",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"}),e.jsx("div",{className:he("w-full px-3 py-2 rounded-md border border-gray-300 dark:border-gray-600",z.bg,z.color),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium capitalize",children:B.find(D=>D.value===t.status)?.label||t.status})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Priority"}),e.jsxs("div",{className:he("px-3 py-2 rounded-md text-sm font-medium capitalize",F(t.priority)),children:[e.jsx(to,{className:"w-4 h-4 inline mr-2"}),t.priority||"Not set"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Dependencies"}),t.dependencies&&t.dependencies.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:t.dependencies.map(D=>e.jsxs("button",{onClick:()=>n&&n({id:D}),className:"px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 rounded text-sm hover:bg-blue-200 dark:hover:bg-blue-800 transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50",disabled:!n,title:n?`Click to view Task ${D}`:`Task ${D}`,children:[e.jsx(Na,{className:"w-3 h-3 inline mr-1"}),D]},D))}):e.jsx("span",{className:"text-gray-500 dark:text-gray-400 text-sm",children:"No dependencies"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Description"}),c?e.jsx("textarea",{value:d.description||"",onChange:D=>m({...d,description:D.target.value}),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Task description"}):e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.description||"No description provided"})]}),t.details&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("button",{onClick:()=>f(!h),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Implementation Details"}),h?e.jsx(ft,{className:"w-4 h-4 text-gray-500"}):e.jsx(At,{className:"w-4 h-4 text-gray-500"})]}),h&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:c?e.jsx("textarea",{value:d.details||"",onChange:D=>m({...d,details:D.target.value}),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Implementation details"}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-4",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.details})})})]}),t.testStrategy&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("button",{onClick:()=>k(!g),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Test Strategy"}),g?e.jsx(ft,{className:"w-4 h-4 text-gray-500"}):e.jsx(At,{className:"w-4 h-4 text-gray-500"})]}),g&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:e.jsx("div",{className:"bg-blue-50 dark:bg-blue-950 rounded-md p-4",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.testStrategy})})})]}),t.subtasks&&t.subtasks.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Subtasks (",t.subtasks.length,")"]}),e.jsx("div",{className:"space-y-2",children:t.subtasks.map(D=>{const H=T(D.status),$=H.icon;return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx($,{className:he("w-4 h-4",H.color)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white truncate",children:D.title}),D.description&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 truncate",children:D.description})]}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:D.id})]},D.id)})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Task ID: ",t.id]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:r,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Close"})})]})]})})},pn=({onShowAllTasks:t,onStartTask:r,className:s=""})=>{const{nextTask:a,tasks:n,currentProject:o,isLoadingTasks:i,projectTaskMaster:c,refreshTasks:u,refreshProjects:d}=yr(),[m,p]=l.useState(!1),[x,h]=l.useState(!1),[f,g]=l.useState(!1),[k,w]=l.useState(!1),[S,y]=l.useState(!1),[v,T]=l.useState(!1),[z,I]=l.useState(!1),F=()=>{g(!0),h(!1)},B=()=>{w(!0),h(!1)};if(!o||i)return null;let D;if((!n||n.length===0)&&!c?.hasTaskmaster)D=e.jsxs("div",{className:he("bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-lg p-3 mb-4",s),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ls,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"TaskMaster AI is not configured"}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5"})]})]}),e.jsx("div",{className:"flex items-center gap-1",children:e.jsxs("button",{onClick:()=>h(!x),className:"text-xs px-2 py-1 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors flex items-center gap-1",children:[e.jsx(Ve,{className:"w-3 h-3"}),"Initialize TaskMaster AI"]})})]}),x&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-blue-200 dark:border-blue-800",children:[!c?.hasTaskmaster&&e.jsxs("div",{className:"mb-3 p-3 bg-blue-50 dark:bg-blue-900/50 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-2",children:"🎯 What is TaskMaster?"}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("p",{children:["• ",e.jsx("strong",{children:"AI-Powered Task Management:"})," Break complex projects into manageable subtasks"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"PRD Templates:"})," Generate tasks from Product Requirements Documents"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Dependency Tracking:"})," Understand task relationships and execution order"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Progress Visualization:"})," Kanban boards and detailed task analytics"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"CLI Integration:"})," Use taskmaster commands for advanced workflows"]})]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:c?.hasTaskmaster?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 p-2 bg-green-50 dark:bg-green-900/30 rounded text-xs text-green-800 dark:text-green-200",children:[e.jsx("strong",{children:"Add more tasks:"})," Create additional tasks manually or generate them from a PRD template"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-green-100 dark:bg-green-900 hover:bg-green-200 dark:hover:bg-green-800 text-green-800 dark:text-green-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:F,disabled:z,children:[e.jsx(tt,{className:"w-3 h-3"}),"Create a new task manually"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-purple-100 dark:bg-purple-900 hover:bg-purple-200 dark:hover:bg-purple-800 text-purple-800 dark:text-purple-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:B,disabled:z,children:[e.jsx(et,{className:"w-3 h-3"}),z?"Parsing...":"Generate tasks from PRD template"]})]}):e.jsxs("button",{className:"text-xs px-3 py-2 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 rounded transition-colors text-left flex items-center gap-2",onClick:()=>y(!0),children:[e.jsx(at,{className:"w-3 h-3"}),"Initialize TaskMaster"]})})]})]});else if(a)D=e.jsx("div",{className:he("bg-slate-50 dark:bg-slate-900/30 border border-slate-200 dark:border-slate-700 rounded-lg p-3 mb-4",s),children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-5 h-5 bg-blue-100 dark:bg-blue-900/50 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx(Si,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})}),e.jsxs("span",{className:"text-xs text-slate-600 dark:text-slate-400 font-medium",children:["Task ",a.id]}),a.priority==="high"&&e.jsx("div",{className:"w-4 h-4 rounded bg-red-100 dark:bg-red-900/50 flex items-center justify-center",title:"High Priority",children:e.jsx(ja,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})}),a.priority==="medium"&&e.jsx("div",{className:"w-4 h-4 rounded bg-amber-100 dark:bg-amber-900/50 flex items-center justify-center",title:"Medium Priority",children:e.jsx(to,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})}),a.priority==="low"&&e.jsx("div",{className:"w-4 h-4 rounded bg-gray-100 dark:bg-gray-800 flex items-center justify-center",title:"Low Priority",children:e.jsx(xr,{className:"w-2.5 h-2.5 text-gray-400 dark:text-gray-500"})})]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-1",children:a.title})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>r?.(),className:"text-xs px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium transition-colors shadow-sm flex items-center gap-1",children:[e.jsx(Ei,{className:"w-3 h-3"}),"Start Task"]}),e.jsx("button",{onClick:()=>T(!0),className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View task details",children:e.jsx(ar,{className:"w-3 h-3"})}),t&&e.jsx("button",{onClick:t,className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View all tasks",children:e.jsx(ls,{className:"w-3 h-3"})})]})]})});else if(n&&n.length>0){const H=n.filter(R=>R.status==="done").length,$=n.length;D=e.jsx("div",{className:he("bg-purple-50 dark:bg-purple-950 border border-purple-200 dark:border-purple-800 rounded-lg p-3 mb-4",s),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:H===$?"All done! 🎉":"No pending tasks"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[H,"/",$]}),e.jsx("button",{onClick:t,className:"text-xs px-2 py-1 bg-purple-600 hover:bg-purple-700 text-white rounded transition-colors",children:"Review"})]})]})})}else D=null;return e.jsxs(e.Fragment,{children:[D,f&&e.jsx(_d,{currentProject:o,onClose:()=>g(!1),onTaskCreated:()=>{u(),g(!1)}}),k&&e.jsx(Rd,{currentProject:o,onClose:()=>w(!1),onTemplateApplied:()=>{u(),w(!1)}}),S&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(at,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"TaskMaster Setup"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Interactive CLI for ",o?.displayName]})]})]}),e.jsx("button",{onClick:()=>y(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",children:e.jsx(oo,{selectedProject:o,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0})})}),e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"TaskMaster initialization will start automatically"}),e.jsx("button",{onClick:()=>y(!1),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Close"})]})})]})}),v&&a&&e.jsx(_o,{task:a,isOpen:v,onClose:()=>T(!1),onStatusChange:()=>u?.(),onTaskClick:null})]})},_d=({currentProject:t,onClose:r,onTaskCreated:s})=>{const[a,n]=l.useState({title:"",description:"",priority:"medium",useAI:!1,prompt:""}),[o,i]=l.useState(!1),c=async u=>{if(u.preventDefault(),!!t){i(!0);try{const d=a.useAI?{prompt:a.prompt,priority:a.priority}:{title:a.title,description:a.description,priority:a.priority},m=await Ge.taskmaster.addTask(t.name,d);if(m.ok)s();else{const p=await m.json();console.error("Failed to create task:",p),alert(`Failed to create task: ${p.message}`)}}catch(d){console.error("Error creating task:",d),alert("Error creating task. Please try again.")}finally{i(!1)}}};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create New Task"}),e.jsx("button",{onClick:r,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:e.jsx(qe,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:c,className:"space-y-4",children:[e.jsx("div",{children:e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[e.jsx("input",{type:"checkbox",checked:a.useAI,onChange:u=>n(d=>({...d,useAI:u.target.checked}))}),"Use AI to generate task details"]})}),a.useAI?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Description (AI will generate details)"}),e.jsx("textarea",{value:a.prompt,onChange:u=>n(d=>({...d,prompt:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe what you want to accomplish...",required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Title"}),e.jsx("input",{type:"text",value:a.title,onChange:u=>n(d=>({...d,title:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter task title...",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Description"}),e.jsx("textarea",{value:a.description,onChange:u=>n(d=>({...d,description:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe the task...",required:!0})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Priority"}),e.jsxs("select",{value:a.priority,onChange:u=>n(d=>({...d,priority:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx("button",{type:"button",onClick:r,className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",disabled:o,children:"Cancel"}),e.jsx("button",{type:"submit",className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded disabled:opacity-50",disabled:o||a.useAI&&!a.prompt.trim()||!a.useAI&&(!a.title.trim()||!a.description.trim()),children:o?"Creating...":"Create Task"})]})]})]})})},Rd=({currentProject:t,onClose:r,onTemplateApplied:s})=>{const[a,n]=l.useState([]),[o,i]=l.useState(null),[c,u]=l.useState({}),[d,m]=l.useState("prd.txt"),[p,x]=l.useState(!0),[h,f]=l.useState(!1),[g,k]=l.useState("select");useEffect(()=>{(async()=>{try{const v=await Ge.taskmaster.getTemplates();if(v.ok){const T=await v.json();n(T.templates)}}catch(v){console.error("Error loading templates:",v)}finally{x(!1)}})()},[]);const w=y=>{i(y);const v=y.content.match(/\[([^\]]+)\]/g)||[],T=[...new Set(v.map(I=>I.slice(1,-1)))],z={};T.forEach(I=>{z[I]=""}),u(z),k("customize")},S=async()=>{if(!(!o||!t)){f(!0);try{const y=await Ge.taskmaster.applyTemplate(t.name,{templateId:o.id,fileName:d,customizations:c});if(!y.ok){const T=await y.json();throw new Error(T.message||"Failed to apply template")}const v=await Ge.taskmaster.parsePRD(t.name,{fileName:d,numTasks:10});if(!v.ok){const T=await v.json();throw new Error(T.message||"Failed to generate tasks")}k("generate"),setTimeout(()=>{s()},2e3)}catch(y){console.error("Error applying template:",y),alert(`Error: ${y.message}`),f(!1)}}};return p?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading templates..."})]})})}):e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:g==="select"?"Select PRD Template":g==="customize"?"Customize Template":"Generating Tasks"}),e.jsx("button",{onClick:r,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:e.jsx(qe,{className:"w-4 h-4"})})]}),g==="select"&&e.jsx("div",{className:"space-y-3",children:a.map(y=>e.jsx("div",{className:"p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer transition-colors",onClick:()=>w(y),children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white",children:y.name}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:y.description}),e.jsx("span",{className:"inline-block text-xs bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 px-2 py-1 rounded mt-2",children:y.category})]}),e.jsx(Na,{className:"w-4 h-4 text-gray-400 mt-1"})]})},y.id))}),g==="customize"&&o&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"File Name"}),e.jsx("input",{type:"text",value:d,onChange:y=>m(y.target.value),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"prd.txt"})]}),Object.keys(c).length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Customize Template"}),e.jsx("div",{className:"space-y-3",children:Object.entries(c).map(([y,v])=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:y.replace(/([A-Z])/g," $1").replace(/^./,T=>T.toUpperCase())}),e.jsx("input",{type:"text",value:v,onChange:T=>u(z=>({...z,[y]:T.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:`Enter ${y.toLowerCase()}`})]},y))})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx("button",{onClick:()=>k("select"),className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",children:"Back"}),e.jsx("button",{onClick:S,className:"flex-1 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded disabled:opacity-50",disabled:h,children:h?"Applying...":"Apply & Generate Tasks"})]})]}),g==="generate"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Br,{className:"w-8 h-8 text-green-600 dark:text-green-400"})}),e.jsx("h4",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Template Applied Successfully!"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Your PRD has been created and tasks are being generated..."})]})]})})},Ro={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"},{value:"opusplan",label:"Opus Plan"},{value:"sonnet[1m]",label:"Sonnet [1M]"}],DEFAULT:"sonnet"},zo={OPTIONS:[{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gemini-3-pro",label:"Gemini 3 Pro"},{value:"opus-4.5-thinking",label:"Claude 4.5 Opus (Thinking)"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1",label:"GPT-5.1"},{value:"gpt-5.1-high",label:"GPT-5.1 High"},{value:"composer-1",label:"Composer 1"},{value:"auto",label:"Auto"},{value:"sonnet-4.5",label:"Claude 4.5 Sonnet"},{value:"sonnet-4.5-thinking",label:"Claude 4.5 Sonnet (Thinking)"},{value:"opus-4.5",label:"Claude 4.5 Opus"},{value:"gpt-5.1-codex",label:"GPT-5.1 Codex"},{value:"gpt-5.1-codex-high",label:"GPT-5.1 Codex High"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-max-high",label:"GPT-5.1 Codex Max High"},{value:"opus-4.1",label:"Claude 4.1 Opus"},{value:"grok",label:"Grok"}],DEFAULT:"gpt-5"},Oo={OPTIONS:[{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"o3",label:"O3"},{value:"o4-mini",label:"O4-mini"}],DEFAULT:"gpt-5.2"},zd=[{id:"claude",name:"Claude Code",infoKey:"providerSelection.providerInfo.anthropic",accent:"border-primary",ring:"ring-primary/15",check:"bg-primary text-primary-foreground"},{id:"cursor",name:"Cursor",infoKey:"providerSelection.providerInfo.cursorEditor",accent:"border-violet-500 dark:border-violet-400",ring:"ring-violet-500/15",check:"bg-violet-500 text-white"},{id:"codex",name:"Codex",infoKey:"providerSelection.providerInfo.openai",accent:"border-emerald-600 dark:border-emerald-400",ring:"ring-emerald-600/15",check:"bg-emerald-600 dark:bg-emerald-500 text-white"}];function Od(t){return t==="claude"?Ro:t==="codex"?Oo:zo}function Bd(t,r,s,a){return t==="claude"?r:t==="codex"?a:s}function Wd({selectedSession:t,currentSessionId:r,provider:s,setProvider:a,textareaRef:n,claudeModel:o,setClaudeModel:i,cursorModel:c,setCursorModel:u,codexModel:d,setCodexModel:m,tasksEnabled:p,isTaskMasterInstalled:x,onShowAllTasks:h,setInput:f}){const{t:g}=Ue("chat"),k=g("tasks.nextTaskPrompt",{defaultValue:"Start the next task"}),w=T=>{a(T),localStorage.setItem("selected-provider",T),setTimeout(()=>n.current?.focus(),100)},S=T=>{s==="claude"?(i(T),localStorage.setItem("claude-model",T)):s==="codex"?(m(T),localStorage.setItem("codex-model",T)):(u(T),localStorage.setItem("cursor-model",T))},y=Od(s),v=Bd(s,o,c,d);return!t&&!r?e.jsx("div",{className:"flex items-center justify-center h-full px-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h2",{className:"text-lg sm:text-xl font-semibold text-foreground tracking-tight",children:g("providerSelection.title")}),e.jsx("p",{className:"text-[13px] text-muted-foreground mt-1",children:g("providerSelection.description")})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:gap-2.5 mb-6",children:zd.map(T=>{const z=s===T.id;return e.jsxs("button",{onClick:()=>w(T.id),className:`
50
- relative flex flex-col items-center gap-2.5 pt-5 pb-4 px-2
51
- rounded-xl border-[1.5px] transition-all duration-150
52
- active:scale-[0.97]
53
- ${z?`${T.accent} ${T.ring} ring-2 bg-card shadow-sm`:"border-border bg-card/60 hover:bg-card hover:border-border/80"}
54
- `,children:[e.jsx(jt,{provider:T.id,className:`w-9 h-9 transition-transform duration-150 ${z?"scale-110":""}`}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[13px] font-semibold text-foreground leading-none",children:T.name}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 leading-tight",children:g(T.infoKey)})]}),z&&e.jsx("div",{className:`absolute -top-1 -right-1 w-[18px] h-[18px] rounded-full ${T.check} flex items-center justify-center shadow-sm`,children:e.jsx(vt,{className:"w-2.5 h-2.5",strokeWidth:3})})]},T.id)})}),e.jsxs("div",{className:`transition-all duration-200 ${s?"opacity-100 translate-y-0":"opacity-0 translate-y-1 pointer-events-none"}`,children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-5",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:g("providerSelection.selectModel")}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:v,onChange:T=>S(T.target.value),tabIndex:-1,className:"appearance-none pl-3 pr-7 py-1.5 text-sm font-medium bg-muted/50 border border-border/60 rounded-lg text-foreground cursor-pointer hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary/20",children:y.OPTIONS.map(({value:T,label:z})=>e.jsx("option",{value:T,children:z},T))}),e.jsx(ft,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground pointer-events-none"})]})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground/70",children:s==="claude"?g("providerSelection.readyPrompt.claude",{model:o}):s==="cursor"?g("providerSelection.readyPrompt.cursor",{model:c}):s==="codex"?g("providerSelection.readyPrompt.codex",{model:d}):g("providerSelection.readyPrompt.default")})]}),s&&p&&x&&e.jsx("div",{className:"mt-5",children:e.jsx(pn,{onStartTask:()=>f(k),onShowAllTasks:h})})]})}):t?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center px-6 max-w-md",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground mb-1.5",children:g("session.continue.title")}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:g("session.continue.description")}),p&&x&&e.jsx("div",{className:"mt-5",children:e.jsx(pn,{onStartTask:()=>f(k),onShowAllTasks:h})})]})}):null}function Ud({selectedProvider:t}){return e.jsx("div",{className:"chat-message assistant",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1 bg-transparent",children:e.jsx(jt,{provider:t,className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t==="cursor"?"Cursor":t==="codex"?"Codex":"Claude"})]}),e.jsx("div",{className:"w-full text-sm text-gray-500 dark:text-gray-400 pl-3 sm:pl-0",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("div",{className:"animate-pulse",children:"."}),e.jsx("div",{className:"animate-pulse",style:{animationDelay:"0.2s"},children:"."}),e.jsx("div",{className:"animate-pulse",style:{animationDelay:"0.4s"},children:"."}),e.jsx("span",{className:"ml-2",children:"Thinking..."})]})})]})})}const Hd=t=>{if(typeof t!="string"&&typeof t!="number")return null;const r=String(t).trim();return r.length>0?r:null},Gd=t=>{const r=[t.id,t.messageId,t.toolId,t.toolCallId,t.blobId,t.rowid,t.sequence];for(const o of r){const i=Hd(o);if(i)return`message-${t.type}-${i}`}const s=new Date(t.timestamp).getTime();if(!Number.isFinite(s))return null;const a=typeof t.content=="string"?t.content.slice(0,48):"",n=typeof t.toolName=="string"?t.toolName:"";return`message-${t.type}-${s}-${n}-${a}`};function qd({scrollContainerRef:t,onWheel:r,onTouchMove:s,isLoadingSessionMessages:a,chatMessages:n,selectedSession:o,currentSessionId:i,provider:c,setProvider:u,textareaRef:d,claudeModel:m,setClaudeModel:p,cursorModel:x,setCursorModel:h,codexModel:f,setCodexModel:g,tasksEnabled:k,isTaskMasterInstalled:w,onShowAllTasks:S,setInput:y,isLoadingMoreMessages:v,hasMoreMessages:T,totalMessages:z,sessionMessagesCount:I,visibleMessageCount:F,visibleMessages:B,loadEarlierMessages:D,loadAllMessages:H,allMessagesLoaded:$,isLoadingAllMessages:R,loadAllJustFinished:E,showLoadAllOverlay:U,createDiff:j,onFileOpen:_,onShowSettings:V,onGrantToolPermission:ee,autoExpandTools:M,showRawParameters:G,showThinking:C,selectedProject:b,isLoading:N}){const{t:W}=Ue("chat"),A=l.useRef(new WeakMap),O=l.useRef(new Set),q=l.useRef(0),Z=l.useCallback(J=>{const Q=A.current.get(J);if(Q)return Q;const le=Gd(J);let ae=le;if(!ae||O.current.has(ae))do q.current+=1,ae=le?`${le}-${q.current}`:`message-generated-${q.current}`;while(O.current.has(ae));return O.current.add(ae),A.current.set(J,ae),ae},[]);return e.jsxs("div",{ref:t,onWheel:r,onTouchMove:s,className:"flex-1 overflow-y-auto overflow-x-hidden px-0 py-3 sm:p-4 space-y-3 sm:space-y-4 relative",children:[a&&n.length===0?e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 mt-8",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{children:W("session.loading.sessionMessages")})]})}):n.length===0?e.jsx(Wd,{selectedSession:o,currentSessionId:i,provider:c,setProvider:u,textareaRef:d,claudeModel:m,setClaudeModel:p,cursorModel:x,setCursorModel:h,codexModel:f,setCodexModel:g,tasksEnabled:k,isTaskMasterInstalled:w,onShowAllTasks:S,setInput:y}):e.jsxs(e.Fragment,{children:[v&&!R&&!$&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 py-3",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{className:"text-sm",children:W("session.loading.olderMessages")})]})}),T&&!v&&!$&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:z>0&&e.jsxs("span",{children:[W("session.messages.showingOf",{shown:I,total:z})," ",e.jsx("span",{className:"text-xs",children:W("session.messages.scrollToLoad")})]})}),(U||R||E)&&e.jsx("div",{className:"sticky top-2 z-20 flex justify-center pointer-events-none",children:E?e.jsxs("div",{className:"px-4 py-1.5 text-xs font-medium text-white bg-green-600 dark:bg-green-500 rounded-full shadow-lg flex items-center space-x-2",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})}),e.jsx("span",{children:W("session.messages.allLoaded")})]}):e.jsxs("button",{className:"pointer-events-auto px-4 py-1.5 text-xs font-medium text-white bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 rounded-full shadow-lg transition-all duration-200 hover:scale-105 disabled:opacity-75 disabled:cursor-wait flex items-center space-x-2",onClick:H,disabled:R,children:[R&&e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-2 border-white/30 border-t-white"}),e.jsx("span",{children:R?W("session.messages.loadingAll"):e.jsxs(e.Fragment,{children:[W("session.messages.loadAll")," ",z>0&&`(${z})`]})})]})}),$&&e.jsx("div",{className:"text-center text-amber-600 dark:text-amber-400 text-xs py-1.5 bg-amber-50 dark:bg-amber-900/20 border-b border-amber-200 dark:border-amber-800",children:W("session.messages.perfWarning")}),!T&&n.length>F&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:[W("session.messages.showingLast",{count:F,total:n.length})," |",e.jsx("button",{className:"ml-1 text-blue-600 hover:text-blue-700 underline",onClick:D,children:W("session.messages.loadEarlier")})," | ",e.jsx("button",{className:"text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 underline",onClick:H,children:W("session.messages.loadAll")})]}),B.map((J,Q)=>{const le=Q>0?B[Q-1]:null;return e.jsx(Ld,{message:J,index:Q,prevMessage:le,createDiff:j,onFileOpen:_,onShowSettings:V,onGrantToolPermission:ee,autoExpandTools:M,showRawParameters:G,showThinking:C,selectedProject:b,provider:c},Z(J))})]}),N&&e.jsx(Ud,{selectedProvider:c})]})}const Kd=({commands:t=[],selectedIndex:r=-1,onSelect:s,onClose:a,position:n={top:0,left:0},isOpen:o=!1,frequentCommands:i=[]})=>{const c=l.useRef(null),u=l.useRef(null),m=(()=>{const y=window.innerWidth<640,v=window.innerHeight;return y?{position:"fixed",bottom:`${n.bottom||90}px`,left:"16px",right:"16px",width:"auto",maxWidth:"calc(100vw - 32px)",maxHeight:"min(50vh, 300px)"}:{position:"fixed",top:`${Math.max(16,Math.min(n.top,v-316))}px`,left:`${n.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(l.useEffect(()=>{const y=v=>{c.current&&!c.current.contains(v.target)&&o&&a()};if(o)return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[o,a]),l.useEffect(()=>{if(u.current&&c.current){const y=c.current.getBoundingClientRect(),v=u.current.getBoundingClientRect();v.bottom>y.bottom?u.current.scrollIntoView({block:"nearest",behavior:"smooth"}):v.top<y.top&&u.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[r]),!o)return null;if(t.length===0)return e.jsx("div",{ref:c,className:"command-menu command-menu-empty",style:{...m,maxHeight:"300px",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"20px",opacity:1,transform:"translateY(0)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out",textAlign:"center"},children:"No commands available"});const p=i.length>0,x=y=>`${y.name}::${y.namespace||y.type||"other"}::${y.path||""}`,h=new Set(i.map(x)),f=t.reduce((y,v)=>{if(p&&h.has(x(v)))return y;const T=v.namespace||v.type||"other";return y[T]||(y[T]=[]),y[T].push(v),y},{});p&&(f.frequent=i);const k=(p?["frequent","builtin","project","user","other"]:["builtin","project","user","other"]).filter(y=>f[y]),w={frequent:"⭐ Frequently Used",builtin:"Built-in Commands",project:"Project Commands",user:"User Commands",other:"Other Commands"},S=new Map;return t.forEach((y,v)=>{const T=x(y);S.has(T)||S.set(T,v)}),e.jsxs("div",{ref:c,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...m,maxHeight:"300px",overflowY:"auto",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"8px",opacity:o?1:0,transform:o?"translateY(0)":"translateY(-10px)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out"},children:[k.map(y=>e.jsxs("div",{className:"command-group",children:[k.length>1&&e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:w[y]||y}),f[y].map(v=>{const T=x(v),z=S.get(T)??-1,I=z===r;return e.jsxs("div",{ref:I?u:null,role:"option","aria-selected":I,className:"command-item",onMouseEnter:()=>{s&&z>=0&&s(v,z,!0)},onClick:()=>{s&&s(v,z,!1)},style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:I?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:F=>F.preventDefault(),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:v.description?"4px":0},children:[e.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[y==="builtin"&&"⚡",y==="project"&&"📁",y==="user"&&"👤",y==="other"&&"📝",y==="frequent"&&"⭐"]}),e.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:v.name}),v.metadata?.type&&e.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",fontWeight:500},children:v.metadata.type})]}),v.description&&e.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.description})]}),I&&e.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${y}-${v.name}-${v.path||""}`)})]},y)),e.jsx("style",{children:`
55
- .command-menu {
56
- background-color: white;
57
- border: 1px solid #e5e7eb;
58
- }
59
- .command-menu-empty {
60
- color: #6b7280;
61
- }
62
-
63
- @media (prefers-color-scheme: dark) {
64
- .command-menu {
65
- background-color: #1f2937 !important;
66
- border: 1px solid #374151 !important;
67
- }
68
- .command-menu-empty {
69
- color: #9ca3af !important;
70
- }
71
- .command-item[aria-selected="true"] {
72
- background-color: #1e40af !important;
73
- }
74
- .command-item span:not(.command-metadata-badge) {
75
- color: #f3f4f6 !important;
76
- }
77
- .command-metadata-badge {
78
- background-color: #f3f4f6 !important;
79
- color: #6b7280 !important;
80
- }
81
- .command-item div {
82
- color: #d1d5db !important;
83
- }
84
- .command-group > div:first-child {
85
- color: #9ca3af !important;
86
- }
87
- }
88
- `})]})};function Vd({status:t,onAbort:r,isLoading:s,provider:a="claude"}){const[n,o]=l.useState(0),[i,c]=l.useState(0),[u,d]=l.useState(0);if(l.useEffect(()=>{if(!s){o(0),d(0);return}const w=Date.now(),S=30+Math.random()*20,y=setInterval(()=>{const v=Math.floor((Date.now()-w)/1e3);o(v),d(Math.floor(v*S))},1e3);return()=>clearInterval(y)},[s]),l.useEffect(()=>{if(!s)return;const w=setInterval(()=>{c(S=>(S+1)%4)},500);return()=>clearInterval(w)},[s]),!s)return null;const m=["Thinking","Processing","Analyzing","Working","Computing","Reasoning"],p=Math.floor(n/3)%m.length,x=t?.text||m[p],h=t?.tokens||u,f=t?.can_interrupt!==!1,k=["✻","✹","✸","✶"][i];return e.jsx("div",{className:"w-full mb-3 sm:mb-6 animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between max-w-4xl mx-auto bg-gray-800 dark:bg-gray-900 text-white rounded-lg shadow-lg px-2.5 py-2 sm:px-4 sm:py-3 border border-gray-700 dark:border-gray-800",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("span",{className:he("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:k}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("span",{className:"font-medium text-xs sm:text-sm truncate",children:[x,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),h>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsxs("span",{className:"text-gray-300 text-xs sm:text-sm hidden sm:inline flex-shrink-0",children:["⚒ ",h.toLocaleString()]})]}),e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsx("span",{className:"text-gray-400 text-xs sm:text-sm hidden sm:inline",children:"esc to stop"})]})})]})}),f&&r&&e.jsxs("button",{onClick:r,className:"ml-2 sm:ml-3 text-xs bg-red-600 hover:bg-red-700 active:bg-red-800 text-white px-2 py-1 sm:px-3 sm:py-1.5 rounded-md transition-colors flex items-center gap-1 sm:gap-1.5 flex-shrink-0 font-medium",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"hidden sm:inline",children:"Stop"})]})]})})}async function Jd(t,r){const s=new FormData,a=`recording_${Date.now()}.webm`,n=new File([t],a,{type:t.type});s.append("audio",n);const o=window.localStorage.getItem("whisperMode")||"default";s.append("mode",o);try{const i=await Ge.transcribe(s);if(!i.ok){const u=await i.json().catch(()=>({}));throw new Error(u.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function Bo({onTranscript:t,className:r=""}){const[s,a]=l.useState("idle"),[n,o]=l.useState(null),[i,c]=l.useState(!0),u=l.useRef(null),d=l.useRef(null),m=l.useRef([]),p=l.useRef(0);l.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){c(!1),o("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){c(!1),o("Microphone requires HTTPS. Please use a secure connection.");return}c(!0),o(null)})()},[]);const x=async()=>{try{if(console.log("Starting recording..."),o(null),m.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const y=await navigator.mediaDevices.getUserMedia({audio:!0});d.current=y;const v=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",T=new MediaRecorder(y,{mimeType:v});u.current=T,T.ondataavailable=z=>{z.data.size>0&&m.current.push(z.data)},T.onstop=async()=>{console.log("Recording stopped, creating blob...");const z=new Blob(m.current,{type:v});d.current&&(d.current.getTracks().forEach(D=>D.stop()),d.current=null),a("transcribing");const I=window.localStorage.getItem("whisperMode")||"default",F=I==="prompt"||I==="vibe"||I==="instructions"||I==="architect";let B;F&&(B=setTimeout(()=>{a("processing")},2e3));try{const D=await Jd(z);D&&t&&t(D)}catch(D){console.error("Transcription error:",D),o(D.message)}finally{B&&clearTimeout(B),a("idle")}},T.start(),a("recording"),console.log("Recording started successfully")}catch(y){console.error("Failed to start recording:",y);let v="Microphone access failed";y.name==="NotAllowedError"?v="Microphone access denied. Please allow microphone permissions.":y.name==="NotFoundError"?v="No microphone found. Please check your audio devices.":y.name==="NotSupportedError"?v="Microphone not supported by this browser.":y.name==="NotReadableError"?v="Microphone is being used by another application.":y.message.includes("HTTPS")&&(v=y.message),o(v),a("idle")}},h=()=>{console.log("Stopping recording..."),u.current&&u.current.state==="recording"?u.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),d.current&&(d.current.getTracks().forEach(y=>y.stop()),d.current=null),a("idle"))},f=y=>{if(y&&(y.preventDefault(),y.stopPropagation()),!i)return;const v=Date.now();if(v-p.current<300){console.log("Ignoring rapid tap");return}p.current=v,console.log("Button clicked, current state:",s),s==="idle"?x():s==="recording"&&h()};l.useEffect(()=>()=>{d.current&&d.current.getTracks().forEach(y=>y.stop())},[]);const g=()=>{if(!i)return{icon:e.jsx(ns,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(s){case"recording":return{icon:e.jsx(ns,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:e.jsx(mr,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(ws,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(ns,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:k,className:w,disabled:S}=g();return e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",style:{backgroundColor:s==="recording"?"#ef4444":s==="transcribing"?"#3b82f6":s==="processing"?"#a855f7":"#374151"},className:`
89
- flex items-center justify-center
90
- w-12 h-12 rounded-full
91
- text-white transition-all duration-200
92
- focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500
93
- dark:ring-offset-gray-800
94
- touch-action-manipulation
95
- ${S?"cursor-not-allowed opacity-75":"cursor-pointer"}
96
- ${s==="recording"?"animate-pulse":""}
97
- hover:opacity-90
98
- ${r}
99
- `,onClick:f,disabled:S,children:k}),n&&e.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2 \r
100
- bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10\r
101
- animate-fade-in`,children:n}),s==="recording"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),s==="processing"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}const Yd=({file:t,onRemove:r,uploadProgress:s,error:a})=>{const[n,o]=l.useState(void 0);return l.useEffect(()=>{const i=URL.createObjectURL(t);return o(i),()=>URL.revokeObjectURL(i)},[t]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:n,alt:t.name,className:"w-20 h-20 object-cover rounded"}),s!==void 0&&s<100&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("div",{className:"text-white text-xs",children:[s,"%"]})}),a&&e.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("button",{type:"button",onClick:r,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 focus:opacity-100 transition-opacity","aria-label":"Remove image",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},Wo={};function Qd(t,r){Wo[t]=r}function Xd(t){return Wo[t]||null}Qd("AskUserQuestion",Fd);function Zd({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}){return t.length?e.jsx("div",{className:"mb-3 space-y-2",children:t.map(a=>{const n=Xd(a.toolName);if(n)return e.jsx(n,{request:a,onDecision:r},a.requestId);const o=cn(a.input),i=na(a.toolName,o),c=Ma(),u=i?c.allowedTools.includes(i):!1,d=u?"Allow (saved)":"Allow & remember",m=i?t.filter(p=>na(p.toolName,cn(p.input))===i).map(p=>p.requestId):[a.requestId];return e.jsxs("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20 p-3 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-amber-900 dark:text-amber-100",children:"Permission required"}),e.jsxs("div",{className:"text-xs text-amber-800 dark:text-amber-200",children:["Tool: ",e.jsx("span",{className:"font-mono",children:a.toolName})]})]}),i&&e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["Allow rule: ",e.jsx("span",{className:"font-mono",children:i})]})]}),o&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-amber-800 dark:text-amber-200 hover:text-amber-900 dark:hover:text-amber-100",children:"View tool input"}),e.jsx("pre",{className:"mt-2 max-h-40 overflow-auto rounded-md bg-white/80 dark:bg-gray-900/60 border border-amber-200/60 dark:border-amber-800/60 p-2 text-xs text-amber-900 dark:text-amber-100 whitespace-pre-wrap",children:o})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(a.requestId,{allow:!0}),className:"inline-flex items-center gap-2 rounded-md bg-amber-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-amber-700 transition-colors",children:"Allow once"}),e.jsx("button",{type:"button",onClick:()=>{i&&!u&&s({entry:i,toolName:a.toolName}),r(m,{allow:!0,rememberEntry:i})},className:`inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border transition-colors ${i?"border-amber-300 text-amber-800 hover:bg-amber-100 dark:border-amber-700 dark:text-amber-100 dark:hover:bg-amber-900/30":"border-gray-300 text-gray-400 cursor-not-allowed"}`,disabled:!i,children:d}),e.jsx("button",{type:"button",onClick:()=>r(a.requestId,{allow:!1,message:"User denied tool use"}),className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-red-300 text-red-700 hover:bg-red-50 dark:border-red-800 dark:text-red-200 dark:hover:bg-red-900/30 transition-colors",children:"Deny"})]})]},a.requestId)})}):null}const Uo=[{id:"none",name:"Standard",description:"Regular Claude response",icon:null,prefix:"",color:"text-gray-600"},{id:"think",name:"Think",description:"Basic extended thinking",icon:ws,prefix:"think",color:"text-blue-600"},{id:"think-hard",name:"Think Hard",description:"More thorough evaluation",icon:ja,prefix:"think hard",color:"text-purple-600"},{id:"think-harder",name:"Think Harder",description:"Deep analysis with alternatives",icon:Ft,prefix:"think harder",color:"text-indigo-600"},{id:"ultrathink",name:"Ultrathink",description:"Maximum thinking budget",icon:Ti,prefix:"ultrathink",color:"text-red-600"}];function eu({selectedMode:t,onModeChange:r,onClose:s,className:a=""}){const{t:n}=Ue("chat"),o={"think-hard":"thinkHard","think-harder":"thinkHarder"},i=Uo.map(x=>{const h=o[x.id]||x.id;return{...x,name:n(`thinkingMode.modes.${h}.name`),description:n(`thinkingMode.modes.${h}.description`),prefix:n(`thinkingMode.modes.${h}.prefix`)}}),[c,u]=l.useState(!1),d=l.useRef(null);l.useEffect(()=>{const x=h=>{d.current&&!d.current.contains(h.target)&&(u(!1),s&&s())};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[s]);const m=i.find(x=>x.id===t)||i[0],p=m.icon||ws;return e.jsxs("div",{className:`relative ${a}`,ref:d,children:[e.jsx("button",{type:"button",onClick:()=>u(!c),className:`w-10 h-10 sm:w-10 sm:h-10 rounded-full flex items-center justify-center transition-all duration-200 ${t==="none"?"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600":"bg-blue-100 hover:bg-blue-200 dark:bg-blue-900 dark:hover:bg-blue-800"}`,title:n("thinkingMode.buttonTitle",{mode:m.name}),children:e.jsx(p,{className:`w-5 h-5 ${m.color}`})}),c&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:"p-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:n("thinkingMode.selector.title")}),e.jsx("button",{onClick:()=>{u(!1),s&&s()},className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:e.jsx(qe,{className:"w-4 h-4 text-gray-500"})})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:n("thinkingMode.selector.description")})]}),e.jsx("div",{className:"py-1",children:i.map(x=>{const h=x.icon,f=x.id===t;return e.jsx("button",{onClick:()=>{r(x.id),u(!1),s&&s()},className:`w-full px-4 py-3 text-left hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${f?"bg-gray-50 dark:bg-gray-700":""}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 ${x.icon?x.color:"text-gray-400"}`,children:h?e.jsx(h,{className:"w-5 h-5"}):e.jsx("div",{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium text-sm ${f?"text-gray-900 dark:text-white":"text-gray-700 dark:text-gray-300"}`,children:x.name}),f&&e.jsx("span",{className:"text-xs bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 px-2 py-0.5 rounded",children:n("thinkingMode.selector.active")})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:x.description}),x.prefix&&e.jsx("code",{className:"text-xs bg-gray-100 dark:bg-gray-700 px-1.5 py-0.5 rounded mt-1 inline-block",children:x.prefix})]})]})},x.id)})}),e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("strong",{children:"Tip:"})," ",n("thinkingMode.selector.tip")]})})]})]})}function tu({used:t,total:r}){if(t==null||r==null||r<=0)return null;const s=Math.min(100,t/r*100),a=10,n=2*Math.PI*a,o=n-s/100*n,i=()=>s<50?"#3b82f6":s<75?"#f59e0b":"#ef4444";return e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"transform -rotate-90",children:[e.jsx("circle",{cx:"12",cy:"12",r:a,fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-gray-300 dark:text-gray-600"}),e.jsx("circle",{cx:"12",cy:"12",r:a,fill:"none",stroke:i(),strokeWidth:"2",strokeDasharray:n,strokeDashoffset:o,strokeLinecap:"round"})]}),e.jsxs("span",{title:`${t.toLocaleString()} / ${r.toLocaleString()} tokens`,children:[s.toFixed(1),"%"]})]})}function ru({permissionMode:t,onModeSwitch:r,provider:s,thinkingMode:a,setThinkingMode:n,tokenBudget:o,slashCommandsCount:i,onToggleCommandMenu:c,hasInput:u,onClearInput:d,isUserScrolledUp:m,hasMessages:p,onScrollToBottom:x}){const{t:h}=Ue("chat");return e.jsxs("div",{className:"flex items-center justify-center gap-2 sm:gap-3 flex-wrap",children:[e.jsx("button",{type:"button",onClick:r,className:`px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 ${t==="default"?"bg-muted/50 text-muted-foreground border-border/60 hover:bg-muted":t==="acceptEdits"?"bg-green-50 dark:bg-green-900/15 text-green-700 dark:text-green-300 border-green-300/60 dark:border-green-600/40 hover:bg-green-100 dark:hover:bg-green-900/25":t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/15 text-orange-700 dark:text-orange-300 border-orange-300/60 dark:border-orange-600/40 hover:bg-orange-100 dark:hover:bg-orange-900/25":"bg-primary/5 text-primary border-primary/20 hover:bg-primary/10"}`,title:h("input.clickToChangeMode"),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${t==="default"?"bg-muted-foreground":t==="acceptEdits"?"bg-green-500":t==="bypassPermissions"?"bg-orange-500":"bg-primary"}`}),e.jsxs("span",{children:[t==="default"&&h("codex.modes.default"),t==="acceptEdits"&&h("codex.modes.acceptEdits"),t==="bypassPermissions"&&h("codex.modes.bypassPermissions"),t==="plan"&&h("codex.modes.plan")]})]})}),s==="claude"&&e.jsx(eu,{selectedMode:a,onModeChange:n,onClose:()=>{},className:""}),e.jsx(tu,{used:o?.used||0,total:o?.total||parseInt(void 0)||16e4}),e.jsxs("button",{type:"button",onClick:c,className:"relative w-7 h-7 sm:w-8 sm:h-8 text-muted-foreground hover:text-foreground rounded-lg flex items-center justify-center transition-colors hover:bg-accent/60",title:h("input.showAllCommands"),children:[e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),i>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-primary text-primary-foreground text-[10px] font-bold rounded-full w-4 h-4 sm:w-5 sm:h-5 flex items-center justify-center",children:i})]}),u&&e.jsx("button",{type:"button",onClick:d,className:"w-7 h-7 sm:w-8 sm:h-8 bg-card hover:bg-accent/60 border border-border/50 rounded-lg flex items-center justify-center transition-all duration-200 group shadow-sm",title:h("input.clearInput",{defaultValue:"Clear input"}),children:e.jsx("svg",{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 text-muted-foreground group-hover:text-foreground transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),m&&p&&e.jsx("button",{onClick:x,className:"w-7 h-7 sm:w-8 sm:h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-lg shadow-sm flex items-center justify-center transition-all duration-200 hover:scale-105",title:h("input.scrollToBottom",{defaultValue:"Scroll to bottom"}),children:e.jsx("svg",{className:"w-3.5 h-3.5 sm:w-4 sm:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})})]})}function su({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s,claudeStatus:a,isLoading:n,onAbortSession:o,provider:i,permissionMode:c,onModeSwitch:u,thinkingMode:d,setThinkingMode:m,tokenBudget:p,slashCommandsCount:x,onToggleCommandMenu:h,hasInput:f,onClearInput:g,isUserScrolledUp:k,hasMessages:w,onScrollToBottom:S,onSubmit:y,isDragActive:v,attachedImages:T,onRemoveImage:z,uploadingImages:I,imageErrors:F,showFileDropdown:B,filteredFiles:D,selectedFileIndex:H,onSelectFile:$,filteredCommands:R,selectedCommandIndex:E,onCommandSelect:U,onCloseCommandMenu:j,isCommandMenuOpen:_,frequentCommands:V,getRootProps:ee,getInputProps:M,openImagePicker:G,inputHighlightRef:C,renderInputWithMentions:b,textareaRef:N,input:W,onInputChange:A,onTextareaClick:O,onTextareaKeyDown:q,onTextareaPaste:Z,onTextareaScrollSync:J,onTextareaInput:Q,onInputFocusChange:le,isInputFocused:ae,placeholder:fe,isTextareaExpanded:Ee,sendByCtrlEnter:Pe,onTranscript:He}){const{t:Te}=Ue("chat"),be=Kd,Ae=N.current?.getBoundingClientRect(),Re={top:Ae?Math.max(16,Ae.top-316):0,left:Ae?Ae.left:16,bottom:Ae?window.innerHeight-Ae.top+8:90},X=t.some(xe=>xe.toolName==="AskUserQuestion"),Ce=ae?"max-sm:fixed max-sm:bottom-0 max-sm:left-0 max-sm:right-0 max-sm:z-50 max-sm:bg-background max-sm:shadow-[0_-4px_20px_rgba(0,0,0,0.15)]":"";return e.jsxs("div",{className:`p-2 sm:p-4 md:p-4 flex-shrink-0 pb-2 sm:pb-4 md:pb-6 ${Ce}`,children:[!X&&e.jsx("div",{className:"flex-1",children:e.jsx(Vd,{status:a,isLoading:n,onAbort:o,provider:i})}),e.jsxs("div",{className:"max-w-4xl mx-auto mb-3",children:[e.jsx(Zd,{pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}),!X&&e.jsx(ru,{permissionMode:c,onModeSwitch:u,provider:i,thinkingMode:d,setThinkingMode:m,tokenBudget:p,slashCommandsCount:x,onToggleCommandMenu:h,hasInput:f,onClearInput:g,isUserScrolledUp:k,hasMessages:w,onScrollToBottom:S})]}),!X&&e.jsxs("form",{onSubmit:y,className:"relative max-w-4xl mx-auto",children:[v&&e.jsx("div",{className:"absolute inset-0 bg-primary/15 border-2 border-dashed border-primary/50 rounded-2xl flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card rounded-xl p-4 shadow-lg border border-border/30",children:[e.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("p",{className:"text-sm font-medium",children:"Drop images here"})]})}),T.length>0&&e.jsx("div",{className:"mb-2 p-2 bg-muted/40 rounded-xl",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:T.map((xe,te)=>e.jsx(Yd,{file:xe,onRemove:()=>z(te),uploadProgress:I.get(xe.name),error:F.get(xe.name)},te))})}),B&&D.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-card/95 backdrop-blur-md border border-border/50 rounded-xl shadow-lg max-h-48 overflow-y-auto z-50",children:D.map((xe,te)=>e.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-border/30 last:border-b-0 touch-manipulation ${te===H?"bg-primary/8 text-primary":"hover:bg-accent/50 text-foreground"}`,onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{se.preventDefault(),se.stopPropagation(),$(xe)},children:[e.jsx("div",{className:"font-medium text-sm",children:xe.name}),e.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:xe.path})]},xe.path))}),e.jsx(be,{commands:R,selectedIndex:E,onSelect:U,onClose:j,position:Re,isOpen:_,frequentCommands:V}),e.jsxs("div",{...ee(),className:`relative bg-card/80 backdrop-blur-sm rounded-2xl shadow-sm border border-border/50 focus-within:shadow-md focus-within:border-primary/30 focus-within:ring-1 focus-within:ring-primary/15 transition-all duration-200 overflow-hidden ${Ee?"chat-input-expanded":""}`,children:[e.jsx("input",{...M()}),e.jsx("div",{ref:C,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden rounded-2xl",children:e.jsx("div",{className:"chat-input-placeholder block w-full pl-12 pr-20 sm:pr-40 py-1.5 sm:py-4 text-transparent text-base leading-6 whitespace-pre-wrap break-words",children:b(W)})}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("textarea",{ref:N,value:W,onChange:A,onClick:O,onKeyDown:q,onPaste:Z,onScroll:xe=>J(xe.target),onFocus:()=>le?.(!0),onBlur:()=>le?.(!1),onInput:Q,placeholder:fe,disabled:n,className:"chat-input-placeholder block w-full pl-12 pr-20 sm:pr-40 py-1.5 sm:py-4 bg-transparent rounded-2xl focus:outline-none text-foreground placeholder-muted-foreground/50 disabled:opacity-50 resize-none min-h-[50px] sm:min-h-[80px] max-h-[40vh] sm:max-h-[300px] overflow-y-auto text-base leading-6 transition-all duration-200",style:{height:"50px"}}),e.jsx("button",{type:"button",onClick:G,className:"absolute left-2 top-1/2 transform -translate-y-1/2 p-2 hover:bg-accent/60 rounded-xl transition-colors",title:Te("input.attachImages"),children:e.jsx("svg",{className:"w-5 h-5 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsx("div",{className:"absolute right-16 sm:right-16 top-1/2 transform -translate-y-1/2",style:{display:"none"},children:e.jsx(Bo,{onTranscript:He,className:"w-10 h-10 sm:w-10 sm:h-10"})}),e.jsx("button",{type:"submit",disabled:!W.trim()||n,onMouseDown:xe=>{xe.preventDefault(),y(xe)},onTouchStart:xe=>{xe.preventDefault(),y(xe)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-10 h-10 sm:w-11 sm:h-11 bg-primary hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground disabled:cursor-not-allowed rounded-xl flex items-center justify-center transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:ring-offset-1 focus:ring-offset-background",children:e.jsx("svg",{className:"w-4 h-4 sm:w-[18px] sm:h-[18px] text-primary-foreground transform rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})}),e.jsx("div",{className:`absolute bottom-1 left-12 right-14 sm:right-40 text-xs text-muted-foreground/50 pointer-events-none hidden sm:block transition-opacity duration-200 ${W.trim()?"opacity-0":"opacity-100"}`,children:Te(Pe?"input.hintText.ctrlEnter":"input.hintText.enter")})]})]})]})]})}function au({selectedSession:t}){const[r,s]=l.useState("default"),[a,n]=l.useState([]),[o,i]=l.useState(()=>localStorage.getItem("selected-provider")||"claude"),[c,u]=l.useState(()=>localStorage.getItem("cursor-model")||zo.DEFAULT),[d,m]=l.useState(()=>localStorage.getItem("claude-model")||Ro.DEFAULT),[p,x]=l.useState(()=>localStorage.getItem("codex-model")||Oo.DEFAULT),h=l.useRef(o);l.useEffect(()=>{if(!t?.id)return;const g=localStorage.getItem(`permissionMode-${t.id}`);s(g||"default")},[t?.id]),l.useEffect(()=>{!t?.__provider||t.__provider===o||(i(t.__provider),localStorage.setItem("selected-provider",t.__provider))},[o,t]),l.useEffect(()=>{h.current!==o&&(n([]),h.current=o)},[o]),l.useEffect(()=>{n(g=>g.filter(k=>!k.sessionId||k.sessionId===t?.id))},[t?.id]),l.useEffect(()=>{o==="cursor"&&we("/api/cursor/config").then(g=>g.json()).then(g=>{if(!g.success||!g.config?.model?.modelId)return;const k=g.config.model.modelId;localStorage.getItem("cursor-model")||u(k)}).catch(g=>{console.error("Error loading Cursor config:",g)})},[o]);const f=l.useCallback(()=>{const g=o==="codex"?["default","acceptEdits","bypassPermissions"]:["default","acceptEdits","bypassPermissions","plan"],w=(g.indexOf(r)+1)%g.length,S=g[w];s(S),t?.id&&localStorage.setItem(`permissionMode-${t.id}`,S)},[r,o,t?.id]);return{provider:o,setProvider:i,cursorModel:c,setCursorModel:u,claudeModel:d,setClaudeModel:m,codexModel:p,setCodexModel:x,permissionMode:r,setPermissionMode:s,pendingPermissionRequests:a,setPendingPermissionRequests:n,cyclePermissionMode:f}}const nu=t=>Array.isArray(t)?t:[],xs=t=>{if(t==null||t==="")return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}},Ws=(t,r)=>r&&(r.startsWith("/")?r:`${t}/${r}`),ou=(t,r)=>{const s=t.split(`
102
- `),a=r.split(`
103
- `),n=Array.from({length:s.length+1},()=>new Array(a.length+1).fill(0));for(let u=s.length-1;u>=0;u-=1)for(let d=a.length-1;d>=0;d-=1)s[u]===a[d]?n[u][d]=n[u+1][d+1]+1:n[u][d]=Math.max(n[u+1][d],n[u][d+1]);const o=[];let i=0,c=0;for(;i<s.length&&c<a.length;){const u=s[i],d=a[c];if(u===d){i+=1,c+=1;continue}if(n[i+1][c]>=n[i][c+1]){o.push({type:"removed",content:u,lineNum:i+1}),i+=1;continue}o.push({type:"added",content:d,lineNum:c+1}),c+=1}for(;i<s.length;)o.push({type:"removed",content:s[i],lineNum:i+1}),i+=1;for(;c<a.length;)o.push({type:"added",content:a[c],lineNum:c+1}),c+=1;return o},iu=()=>{const t=new Map;return(r,s)=>{const a=JSON.stringify([r,s]),n=t.get(a);if(n)return n;const o=ou(r,s);if(t.set(a,o),t.size>100){const i=t.keys().next().value;i&&t.delete(i)}return o}},lu=(t,r)=>{const s=[],a={};for(let n=0;n<t.length;n+=1){const o=t[n],i=o.content;let c="",u="assistant",d=null;try{if(i?.role&&i?.content){if(i.role==="system")continue;if(i.role==="tool"){const m=nu(i.content);for(const p of m){if(p?.type!=="tool-result")continue;const x=p.toolName==="ApplyPatch"?"Edit":p.toolName||"Unknown Tool",h=p.toolCallId||i.id,f=p.result||"";h&&a[h]?a[h].toolResult={content:f,isError:!1}:s.push({type:"assistant",content:"",timestamp:new Date(Date.now()+n*1e3),blobId:o.id,sequence:o.sequence,rowid:o.rowid,isToolUse:!0,toolName:x,toolId:h,toolInput:xs(null),toolResult:{content:f,isError:!1}})}continue}if(u=i.role==="user"?"user":"assistant",Array.isArray(i.content)){const m=[];for(const p of i.content){if(p?.type==="text"&&p?.text){m.push(It(p.text));continue}if(p?.type==="reasoning"&&p?.text){d=It(p.text);continue}if(p?.type==="tool-call"||p?.type==="tool_use"){(m.length>0||d)&&(s.push({type:u,content:m.join(`
104
- `),reasoning:d??void 0,timestamp:new Date(Date.now()+n*1e3),blobId:o.id,sequence:o.sequence,rowid:o.rowid}),m.length=0,d=null);const x=p.toolName||p.name||"Unknown Tool",h=x==="ApplyPatch"?"Edit":x,f=p.toolCallId||p.id||`tool_${n}`;let g=p.args||p.input;if(h==="Edit"&&p.args)if(p.args.patch){const w=String(p.args.patch).split(`
105
- `),S=[],y=[];let v=!1;w.forEach(T=>{if(T.startsWith("@@")){v=!0;return}v&&(T.startsWith("-")?S.push(T.slice(1)):T.startsWith("+")?y.push(T.slice(1)):T.startsWith(" ")&&(S.push(T.slice(1)),y.push(T.slice(1))))}),g={file_path:Ws(r,p.args.file_path),old_string:S.join(`
106
- `)||p.args.patch,new_string:y.join(`
107
- `)||p.args.patch}}else g=p.args;else if(h==="Read"&&p.args){const w=p.args.path||p.args.file_path;g={file_path:Ws(r,w)}}else if(h==="Write"&&p.args){const w=p.args.path||p.args.file_path;g={file_path:Ws(r,w),content:p.args.contents||p.args.content}}const k={type:"assistant",content:"",timestamp:new Date(Date.now()+n*1e3),blobId:o.id,sequence:o.sequence,rowid:o.rowid,isToolUse:!0,toolName:h,toolId:f,toolInput:xs(g),toolResult:null};s.push(k),a[f]=k;continue}typeof p=="string"&&m.push(p)}m.length>0?(c=m.join(`
108
- `),d&&!c&&(s.push({type:u,content:"",reasoning:d,timestamp:new Date(Date.now()+n*1e3),blobId:o.id,sequence:o.sequence,rowid:o.rowid}),c="")):c=""}else typeof i.content=="string"&&(c=i.content)}else if(i?.message?.role&&i?.message?.content){if(i.message.role==="system")continue;u=i.message.role==="user"?"user":"assistant",Array.isArray(i.message.content)?c=i.message.content.map(m=>typeof m=="string"?m:m?.text||"").filter(Boolean).join(`
109
- `):typeof i.message.content=="string"&&(c=i.message.content)}}catch(m){console.log("Error parsing blob content:",m)}if(c&&c.trim()){const m={type:u,content:c,timestamp:new Date(Date.now()+n*1e3),blobId:o.id,sequence:o.sequence,rowid:o.rowid};d&&(m.reasoning=d),s.push(m)}}return s.sort((n,o)=>n.sequence!==void 0&&o.sequence!==void 0?Number(n.sequence)-Number(o.sequence):n.rowid!==void 0&&o.rowid!==void 0?Number(n.rowid)-Number(o.rowid):new Date(n.timestamp).getTime()-new Date(o.timestamp).getTime()),s},cu=t=>{const r=[],s=new Map;return t.forEach(a=>{a.message?.role==="user"&&Array.isArray(a.message?.content)&&a.message.content.forEach(n=>{n.type==="tool_result"&&s.set(n.tool_use_id,{content:n.content,isError:!!n.is_error,timestamp:new Date(a.timestamp||Date.now()),toolUseResult:a.toolUseResult||null,subagentTools:a.subagentTools})})}),t.forEach(a=>{if(a.message?.role==="user"&&a.message?.content){let n="";if(Array.isArray(a.message.content)){const i=[];a.message.content.forEach(c=>{c.type==="text"&&i.push(It(c.text))}),n=i.join(`
110
- `)}else typeof a.message.content=="string"?n=It(a.message.content):n=It(String(a.message.content));if(!(!n||n.startsWith("<command-name>")||n.startsWith("<command-message>")||n.startsWith("<command-args>")||n.startsWith("<local-command-stdout>")||n.startsWith("<system-reminder>")||n.startsWith("Caveat:")||n.startsWith("This session is being continued from a previous")||n.startsWith("[Request interrupted"))){const c=/<task-notification>\s*<task-id>[^<]*<\/task-id>\s*<output-file>[^<]*<\/output-file>\s*<status>([^<]*)<\/status>\s*<summary>([^<]*)<\/summary>\s*<\/task-notification>/g.exec(n);if(c){const u=c[1]?.trim()||"completed",d=c[2]?.trim()||"Background task finished";r.push({type:"assistant",content:d,timestamp:a.timestamp||new Date().toISOString(),isTaskNotification:!0,taskStatus:u})}else r.push({type:"user",content:Qr(n),timestamp:a.timestamp||new Date().toISOString()})}return}if(a.type==="thinking"&&a.message?.content){r.push({type:"assistant",content:Qr(a.message.content),timestamp:a.timestamp||new Date().toISOString(),isThinking:!0});return}if(a.type==="tool_use"&&a.toolName){r.push({type:"assistant",content:"",timestamp:a.timestamp||new Date().toISOString(),isToolUse:!0,toolName:a.toolName,toolInput:xs(a.toolInput),toolCallId:a.toolCallId});return}if(a.type==="tool_result"){for(let n=r.length-1;n>=0;n-=1){const o=r[n];if(!(!o.isToolUse||o.toolResult)&&(!a.toolCallId||o.toolCallId===a.toolCallId)){o.toolResult={content:a.output||"",isError:!1};break}}return}if(a.message?.role==="assistant"&&a.message?.content){if(Array.isArray(a.message.content)){a.message.content.forEach(n=>{if(n.type==="text"){let o=n.text;typeof o=="string"&&(o=Qr(o)),r.push({type:"assistant",content:o,timestamp:a.timestamp||new Date().toISOString()});return}if(n.type==="tool_use"){const o=s.get(n.id),i=n.name==="Task",c=[];if(i&&o?.subagentTools&&Array.isArray(o.subagentTools))for(const u of o.subagentTools)c.push({toolId:u.toolId,toolName:u.toolName,toolInput:u.toolInput,toolResult:u.toolResult||null,timestamp:new Date(u.timestamp||Date.now())});r.push({type:"assistant",content:"",timestamp:a.timestamp||new Date().toISOString(),isToolUse:!0,toolName:n.name,toolInput:xs(n.input),toolId:n.id,toolResult:o?{content:typeof o.content=="string"?o.content:JSON.stringify(o.content),isError:o.isError,toolUseResult:o.toolUseResult}:null,toolError:o?.isError||!1,toolResultTimestamp:o?.timestamp||new Date,isSubagentContainer:i,subagentState:i?{childTools:c,currentToolIndex:c.length>0?c.length-1:-1,isComplete:!!o}:void 0})}});return}typeof a.message.content=="string"&&r.push({type:"assistant",content:Qr(a.message.content),timestamp:a.timestamp||new Date().toISOString()})}}),r},du=20,Zr=100;function uu({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:n,externalMessageUpdate:o,processingSessions:i,resetStreamingState:c,pendingViewSessionRef:u}){const[d,m]=l.useState(()=>{if(typeof window<"u"&&t){const ue=dt.getItem(`chat_messages_${t.name}`);if(ue)try{return JSON.parse(ue)}catch{return console.error("Failed to parse saved chat messages, resetting"),dt.removeItem(`chat_messages_${t.name}`),[]}return[]}return[]}),[p,x]=l.useState(!1),[h,f]=l.useState(r?.id||null),[g,k]=l.useState([]),[w,S]=l.useState(!1),[y,v]=l.useState(!1),[T,z]=l.useState(!1),[I,F]=l.useState(0),[B,D]=l.useState(!1),[H,$]=l.useState(!1),[R,E]=l.useState(!1),[U,j]=l.useState(null),[_,V]=l.useState(Zr),[ee,M]=l.useState(null),[G,C]=l.useState(!1),[b,N]=l.useState(!1),[W,A]=l.useState(!1),[O,q]=l.useState(!1),Z=l.useRef(null),J=l.useRef(!1),Q=l.useRef(!1),le=l.useRef(!1),ae=l.useRef(!1),fe=l.useRef(null),Ee=l.useRef(!0),Pe=l.useRef(0),He=l.useRef({height:0,top:0}),Te=l.useRef(null),be=l.useRef(null),Ae=l.useMemo(()=>iu(),[]),Re=l.useCallback(async(ue,De,je=!1,$e="claude")=>{if(!ue||!De)return[];const ze=!je;ze?S(!0):v(!0);try{const Fe=je?Pe.current:0,re=await Ge.sessionMessages(ue,De,du,Fe,$e);if(!re.ok)throw new Error("Failed to load session messages");const ce=await re.json();if(ze&&ce.tokenUsage&&j(ce.tokenUsage),ce.hasMore!==void 0){const Oe=ce.messages?.length||0;return z(!!ce.hasMore),F(Number(ce.total||0)),Pe.current=Fe+Oe,ce.messages||[]}const Le=ce.messages||[];return z(!1),F(Le.length),Pe.current=Le.length,Le}catch(Fe){return console.error("Error loading session messages:",Fe),[]}finally{ze?S(!1):v(!1)}},[]),X=l.useCallback(async(ue,De)=>{if(!ue||!De)return[];S(!0);try{const je=`/api/cursor/sessions/${encodeURIComponent(De)}?projectPath=${encodeURIComponent(ue)}`,$e=await we(je);if(!$e.ok)return[];const Fe=(await $e.json())?.session?.messages||[];return lu(Fe,ue)}catch(je){return console.error("Error loading Cursor session messages:",je),[]}finally{S(!1)}},[]),Ce=l.useMemo(()=>cu(g),[g]),xe=l.useCallback(()=>{const ue=Z.current;ue&&(ue.scrollTop=ue.scrollHeight)},[]),te=l.useCallback(()=>{xe(),G&&(V(Zr),C(!1),le.current=!1)},[G,xe]),se=l.useCallback(()=>{const ue=Z.current;if(!ue)return!1;const{scrollTop:De,scrollHeight:je,clientHeight:$e}=ue;return je-De-$e<50},[]),ke=l.useCallback(async ue=>{if(!ue||Q.current||y||le.current||!T||!r||!t)return!1;const De=r.__provider||"claude";if(De==="cursor")return!1;Q.current=!0;const je=ue.scrollHeight,$e=ue.scrollTop;try{const ze=await Re(t.name,r.id,!0,De);return ze.length===0?!1:(fe.current={height:je,top:$e},k(Fe=>[...ze,...Fe]),V(Fe=>Fe+ze.length),!0)}finally{Q.current=!1}},[T,y,Re,t,r]),Ne=l.useCallback(async()=>{const ue=Z.current;if(!ue)return;const De=se();if(E(!De),!le.current){if(!(ue.scrollTop<100)){ae.current=!1;return}if(ae.current){ue.scrollTop>20&&(ae.current=!1);return}await ke(ue)&&(ae.current=!0)}},[se,ke]);l.useLayoutEffect(()=>{if(!fe.current||!Z.current)return;const{height:ue,top:De}=fe.current,je=Z.current,ze=je.scrollHeight-ue;je.scrollTop=De+Math.max(ze,0),fe.current=null},[d.length]),l.useEffect(()=>{Ee.current=!0,ae.current=!1,fe.current=null,V(Zr),E(!1)},[t?.name,r?.id]),l.useEffect(()=>{if(!(!Ee.current||!Z.current||w)){if(d.length===0){Ee.current=!1;return}Ee.current=!1,setTimeout(()=>{xe()},200)}},[d.length,w,xe]),l.useEffect(()=>{(async()=>{if(r&&t){const De=localStorage.getItem("selected-provider")||"claude";if(J.current=!0,h!==null&&h!==r.id?(B||(c(),u.current=null,m([]),k([]),M(null),$(!1)),Pe.current=0,z(!1),F(0),V(Zr),C(!1),le.current=!1,N(!1),A(!1),q(!1),be.current&&clearTimeout(be.current),Te.current&&clearTimeout(Te.current),j(null),x(!1),s&&a({type:"check-session-status",sessionId:r.id,provider:De})):h===null&&(Pe.current=0,z(!1),F(0),s&&a({type:"check-session-status",sessionId:r.id,provider:De})),De==="cursor")if(f(r.id),sessionStorage.setItem("cursorSessionId",r.id),B)D(!1);else{const $e=t.fullPath||t.path||"",ze=await X($e,r.id);k([]),m(ze)}else if(f(r.id),B)D(!1);else{const $e=await Re(t.name,r.id,!1,r.__provider||"claude");k($e)}}else B||(c(),u.current=null,m([]),k([]),M(null),$(!1),x(!1)),f(null),sessionStorage.removeItem("cursorSessionId"),Pe.current=0,z(!1),F(0),j(null);setTimeout(()=>{J.current=!1},250)})()},[B,X,Re,u,c,t,r,a,s]),l.useEffect(()=>{if(!o||!r||!t)return;(async()=>{try{if((localStorage.getItem("selected-provider")||"claude")==="cursor"){const ze=t.fullPath||t.path||"",Fe=await X(ze,r.id);k([]),m(Fe);return}const je=await Re(t.name,r.id,!1,r.__provider||"claude");k(je),n&&se()&&setTimeout(()=>xe(),200)}catch(De){console.error("Error reloading messages from external update:",De)}})()},[n,o,se,X,Re,xe,t,r]),l.useEffect(()=>{r?.id&&(u.current=null)},[u,r?.id]),l.useEffect(()=>{g.length>0&&m(Ce)},[Ce,g.length]),l.useEffect(()=>{t&&d.length>0&&dt.setItem(`chat_messages_${t.name}`,JSON.stringify(d))},[d,t]),l.useEffect(()=>{if(!t||!r?.id||r.id.startsWith("new-session-")){j(null);return}if((r.__provider||"claude")!=="claude")return;(async()=>{try{const je=`/api/projects/${t.name}/sessions/${r.id}/token-usage`,$e=await we(je);if($e.ok){const ze=await $e.json();j(ze)}else j(null)}catch(je){console.error("Failed to fetch initial token usage:",je)}})()},[t,r?.id,r?.__provider]);const Ie=l.useMemo(()=>d.length<=_?d:d.slice(-_),[d,_]);l.useEffect(()=>{if(!n&&Z.current){const ue=Z.current;He.current={height:ue.scrollHeight,top:ue.scrollTop}}}),l.useEffect(()=>{if(!Z.current||d.length===0||Q.current||y||fe.current)return;if(n){R||setTimeout(()=>xe(),50);return}const ue=Z.current,De=He.current.height,je=He.current.top,ze=ue.scrollHeight-De;ze>0&&je>0&&(ue.scrollTop=je+ze)},[n,d.length,y,R,xe]),l.useEffect(()=>{const ue=Z.current;if(ue)return ue.addEventListener("scroll",Ne),()=>ue.removeEventListener("scroll",Ne)},[Ne]),l.useEffect(()=>{const ue=r?.id||h;if(!ue||!i)return;i.has(ue)&&!p&&(x(!0),$(!0))},[h,p,i,r?.id]);const Ke=l.useRef(!1);l.useEffect(()=>{const ue=Ke.current;return Ke.current=y,ue&&!y&&T&&(be.current&&clearTimeout(be.current),q(!0),be.current=setTimeout(()=>{q(!1)},2e3)),!T&&!y&&(be.current&&clearTimeout(be.current),q(!1)),()=>{be.current&&clearTimeout(be.current)}},[y,T]);const Be=l.useCallback(async()=>{if(!r||!t||b)return;const ue=r.__provider||"claude";if(ue==="cursor"){V(1/0),C(!0),le.current=!0,A(!0),Te.current&&clearTimeout(Te.current),Te.current=setTimeout(()=>{A(!1),q(!1)},1e3);return}const De=r.id;le.current=!0,Q.current=!0,N(!0),q(!0);const je=Z.current,$e=je?je.scrollHeight:0,ze=je?je.scrollTop:0;try{const Fe=await Ge.sessionMessages(t.name,De,null,0,ue);if(h!==De)return;if(Fe.ok){const re=await Fe.json(),ce=re.messages||re;je&&(fe.current={height:$e,top:ze}),k(Array.isArray(ce)?ce:[]),z(!1),F(Array.isArray(ce)?ce.length:0),Pe.current=Array.isArray(ce)?ce.length:0,V(1/0),C(!0),A(!0),Te.current&&clearTimeout(Te.current),Te.current=setTimeout(()=>{A(!1),q(!1)},1e3)}else le.current=!1,q(!1)}catch(Fe){console.error("Error loading all messages:",Fe),le.current=!1,q(!1)}finally{Q.current=!1,N(!1)}},[r,t,b,h]),rt=l.useCallback(()=>{V(ue=>ue+100)},[]);return{chatMessages:d,setChatMessages:m,isLoading:p,setIsLoading:x,currentSessionId:h,setCurrentSessionId:f,sessionMessages:g,setSessionMessages:k,isLoadingSessionMessages:w,isLoadingMoreMessages:y,hasMoreMessages:T,totalMessages:I,isSystemSessionChange:B,setIsSystemSessionChange:D,canAbortSession:H,setCanAbortSession:$,isUserScrolledUp:R,setIsUserScrolledUp:E,tokenBudget:U,setTokenBudget:j,visibleMessageCount:_,visibleMessages:Ie,loadEarlierMessages:rt,loadAllMessages:Be,allMessagesLoaded:G,isLoadingAllMessages:b,loadAllJustFinished:W,showLoadAllOverlay:O,claudeStatus:ee,setClaudeStatus:M,createDiff:Ae,scrollContainerRef:Z,scrollToBottom:xe,scrollToBottomAndReset:te,isNearBottom:se,handleScroll:Ne,loadSessionMessages:Re,loadCursorSessionMessages:X}}const es=(t,r,s=!1)=>{r&&t(a=>{const n=[...a],o=n.length-1,i=n[o];if(i&&i.type==="assistant"&&!i.isToolUse&&i.isStreaming){const c=s?i.content?`${i.content}
111
- ${r}`:r:`${i.content||""}${r}`;n[o]={...i,content:c}}else n.push({type:"assistant",content:r,timestamp:new Date,isStreaming:!0});return n})},mu=t=>{t(r=>{const s=[...r],a=s.length-1,n=s[a];return n&&n.type==="assistant"&&n.isStreaming&&(s[a]={...n,isStreaming:!1}),s})};function pu({latestMessage:t,provider:r,selectedProject:s,selectedSession:a,currentSessionId:n,setCurrentSessionId:o,setChatMessages:i,setIsLoading:c,setCanAbortSession:u,setClaudeStatus:d,setTokenBudget:m,setIsSystemSessionChange:p,setPendingPermissionRequests:x,pendingViewSessionRef:h,streamBufferRef:f,streamTimerRef:g,onSessionInactive:k,onSessionProcessing:w,onSessionNotProcessing:S,onReplaceTemporarySession:y,onNavigateToSession:v}){const T=l.useRef(null);l.useEffect(()=>{if(!t||T.current===t)return;T.current=t;const z=t.data?.message||t.data,I=z&&typeof z=="object"?z:null,F=t.data&&typeof t.data=="object"?t.data:null,D=["projects_updated","taskmaster-project-updated","session-created"].includes(String(t.type)),H=new Set(["claude-complete","codex-complete","cursor-result","session-aborted","claude-error","cursor-error","codex-error"]),$=t.type==="claude-response"&&I&&I.type==="system"&&I.subtype==="init",R=t.type==="cursor-system"&&F&&F.type==="system"&&F.subtype==="init",E=$?I?.session_id:R?F?.session_id:null,U=a?.id||n||h.current?.sessionId||null,j=E&&(!U||E===U),_=D||!!j,V=!t.sessionId&&h.current&&!h.current.sessionId&&(t.type==="claude-error"||t.type==="cursor-error"||t.type==="codex-error"),ee=b=>{b&&(k?.(b),S?.(b))},M=(...b)=>Array.from(new Set(b.filter(N=>typeof N=="string"&&N.length>0))),G=()=>{c(!1),u(!1),d(null)},C=(...b)=>{M(...b).forEach(W=>{k?.(W),S?.(W)})};if(!_){if(!U&&(t.sessionId&&H.has(String(t.type))&&ee(t.sessionId),!V)||!t.sessionId&&!V)return;if(t.sessionId!==U){t.sessionId&&H.has(String(t.type))&&ee(t.sessionId),console.log("Skipping message for different session:",t.sessionId,"current:",U);return}}switch(t.type){case"session-created":t.sessionId&&!n&&(sessionStorage.setItem("pendingSessionId",t.sessionId),h.current&&!h.current.sessionId&&(h.current.sessionId=t.sessionId),p(!0),y?.(t.sessionId),x(b=>b.map(N=>N.sessionId?N:{...N,sessionId:t.sessionId})));break;case"token-budget":t.data&&m(t.data);break;case"claude-response":{if(z&&typeof z=="object"&&z.type){if(z.type==="content_block_delta"&&z.delta?.text){const b=It(z.delta.text);f.current+=b,g.current||(g.current=window.setTimeout(()=>{const N=f.current;f.current="",g.current=null,es(i,N,!1)},100));return}if(z.type==="content_block_stop"){g.current&&(clearTimeout(g.current),g.current=null);const b=f.current;f.current="",es(i,b,!1),mu(i);return}}if(I?.type==="system"&&I.subtype==="init"&&I.session_id&&n&&I.session_id!==n&&j){console.log("Claude CLI session duplication detected:",{originalSession:n,newSession:I.session_id}),p(!0),v?.(I.session_id);return}if(I?.type==="system"&&I.subtype==="init"&&I.session_id&&!n&&j){console.log("New session init detected:",{newSession:I.session_id}),p(!0),v?.(I.session_id);return}if(I?.type==="system"&&I.subtype==="init"&&I.session_id&&n&&I.session_id===n&&j){console.log("System init message for current session, ignoring");return}if(I&&Array.isArray(I.content)){const b=F?.parentToolUseId;I.content.forEach(N=>{if(N.type==="tool_use"){const W=N.input?JSON.stringify(N.input,null,2):"";if(b){i(O=>O.map(q=>{if(q.toolId===b&&q.isSubagentContainer){const Z={toolId:N.id,toolName:N.name,toolInput:N.input,toolResult:null,timestamp:new Date},J=q.subagentState?.childTools||[];return{...q,subagentState:{childTools:[...J,Z],currentToolIndex:J.length,isComplete:!1}}}return q}));return}const A=N.name==="Task";i(O=>[...O,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:N.name,toolInput:W,toolId:N.id,toolResult:null,isSubagentContainer:A,subagentState:A?{childTools:[],currentToolIndex:-1,isComplete:!1}:void 0}]);return}if(N.type==="text"&&N.text?.trim()){let W=It(N.text);W=aa(W),i(A=>[...A,{type:"assistant",content:W,timestamp:new Date}])}})}else if(I&&typeof I.content=="string"&&I.content.trim()){let b=It(I.content);b=aa(b),i(N=>[...N,{type:"assistant",content:b,timestamp:new Date}])}if(I?.role==="user"&&Array.isArray(I.content)){const b=F?.parentToolUseId;I.content.forEach(N=>{N.type==="tool_result"&&i(W=>W.map(A=>{if(b&&A.toolId===b&&A.isSubagentContainer)return{...A,subagentState:{...A.subagentState,childTools:A.subagentState.childTools.map(O=>O.toolId===N.tool_use_id?{...O,toolResult:{content:N.content,isError:N.is_error,timestamp:new Date}}:O)}};if(A.isToolUse&&A.toolId===N.tool_use_id){const O={...A,toolResult:{content:N.content,isError:N.is_error,timestamp:new Date}};return A.isSubagentContainer&&A.subagentState&&(O.subagentState={...A.subagentState,isComplete:!0}),O}return A}))})}break}case"claude-output":{const b=String(t.data||"");b.trim()&&(f.current+=f.current?`
112
- ${b}`:b,g.current||(g.current=window.setTimeout(()=>{const N=f.current;f.current="",g.current=null,es(i,N,!0)},100)));break}case"claude-interactive-prompt":{const b=typeof t.data=="string"?t.data:JSON.stringify(t.data??"",null,2);i(N=>[...N,{type:"assistant",content:b,timestamp:new Date,isInteractivePrompt:!0}])}break;case"claude-permission-request":if(r!=="claude"||!t.requestId)break;{const b=t.requestId;x(N=>N.some(W=>W.requestId===b)?N:[...N,{requestId:b,toolName:t.toolName||"UnknownTool",input:t.input,context:t.context,sessionId:t.sessionId||null,receivedAt:new Date}])}c(!0),u(!0),d({text:"Waiting for permission",tokens:0,can_interrupt:!0});break;case"claude-permission-cancelled":if(!t.requestId)break;x(b=>b.filter(N=>N.requestId!==t.requestId));break;case"claude-error":i(b=>[...b,{type:"error",content:`Error: ${t.error}`,timestamp:new Date}]);break;case"cursor-system":try{const b=t.data;if(b&&b.type==="system"&&b.subtype==="init"&&b.session_id){if(!j)return;if(n&&b.session_id!==n){console.log("Cursor session switch detected:",{originalSession:n,newSession:b.session_id}),p(!0),v?.(b.session_id);return}if(!n){console.log("Cursor new session init detected:",{newSession:b.session_id}),p(!0),v?.(b.session_id);return}}}catch(b){console.warn("Error handling cursor-system message:",b)}break;case"cursor-user":break;case"cursor-tool-use":i(b=>[...b,{type:"assistant",content:`Using tool: ${t.tool} ${t.input?`with ${t.input}`:""}`,timestamp:new Date,isToolUse:!0,toolName:t.tool,toolInput:t.input}]);break;case"cursor-error":i(b=>[...b,{type:"error",content:`Cursor error: ${t.error||"Unknown error"}`,timestamp:new Date}]);break;case"cursor-result":{const b=t.sessionId||n,N=sessionStorage.getItem("pendingSessionId");G(),C(b,n,a?.id,N);try{const W=t.data||{},A=typeof W.result=="string"?W.result:"";g.current&&(clearTimeout(g.current),g.current=null);const O=f.current;f.current="",i(q=>{const Z=[...q],J=Z.length-1,Q=Z[J];if(Q&&Q.type==="assistant"&&!Q.isToolUse&&Q.isStreaming){const le=A&&A.trim()?A:`${Q.content||""}${O||""}`;Z[J]={...Q,content:le,isStreaming:!1}}else A&&A.trim()&&Z.push({type:W.is_error?"error":"assistant",content:A,timestamp:new Date,isStreaming:!1});return Z})}catch(W){console.warn("Error handling cursor-result message:",W)}b&&!n&&b===N&&(o(b),sessionStorage.removeItem("pendingSessionId"),window.refreshProjects&&setTimeout(()=>window.refreshProjects?.(),500));break}case"cursor-output":try{const N=String(t.data??"").replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"").trim();N&&(f.current+=f.current?`
113
- ${N}`:N,g.current||(g.current=window.setTimeout(()=>{const W=f.current;f.current="",g.current=null,es(i,W,!0)},100)))}catch(b){console.warn("Error handling cursor-output message:",b)}break;case"claude-complete":{const b=sessionStorage.getItem("pendingSessionId"),N=t.sessionId||n||b;G(),C(N,n,a?.id,b),b&&!n&&t.exitCode===0&&(o(b),sessionStorage.removeItem("pendingSessionId"),console.log("New session complete, ID set to:",b)),s&&t.exitCode===0&&dt.removeItem(`chat_messages_${s.name}`),x([]);break}case"codex-response":{const b=t.data;if(!b)break;if(b.type==="item")switch(b.itemType){case"agent_message":if(b.message?.content?.trim()){const N=It(b.message.content);i(W=>[...W,{type:"assistant",content:N,timestamp:new Date}])}break;case"reasoning":if(b.message?.content?.trim()){const N=It(b.message.content);i(W=>[...W,{type:"assistant",content:N,timestamp:new Date,isThinking:!0}])}break;case"command_execution":b.command&&i(N=>[...N,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:b.command,toolResult:b.output||null,exitCode:b.exitCode}]);break;case"file_change":if(b.changes?.length>0){const N=b.changes.map(W=>`${W.kind}: ${W.path}`).join(`
114
- `);i(W=>[...W,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:N,toolResult:{content:`Status: ${b.status}`,isError:!1}}])}break;case"mcp_tool_call":i(N=>[...N,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${b.server}:${b.tool}`,toolInput:JSON.stringify(b.arguments,null,2),toolResult:b.result?JSON.stringify(b.result,null,2):b.error?.message||null}]);break;case"error":b.message?.content&&i(N=>[...N,{type:"error",content:b.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",b.itemType,b)}b.type==="turn_complete"&&(G(),C(t.sessionId,n,a?.id)),b.type==="turn_failed"&&(G(),C(t.sessionId,n,a?.id),i(N=>[...N,{type:"error",content:b.error?.message||"Turn failed",timestamp:new Date}]));break}case"codex-complete":{const b=sessionStorage.getItem("pendingSessionId"),N=t.actualSessionId||b,W=t.sessionId||n||b;G(),C(W,N,n,a?.id,b),b&&!n&&(o(N),p(!0),N&&v?.(N),sessionStorage.removeItem("pendingSessionId"),console.log("Codex session complete, ID set to:",b)),s&&dt.removeItem(`chat_messages_${s.name}`);break}case"codex-error":c(!1),u(!1),i(b=>[...b,{type:"error",content:t.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{const b=typeof window<"u"?sessionStorage.getItem("pendingSessionId"):null,N=t.sessionId||n;t.success!==!1?(G(),C(N,n,a?.id,b),b&&(!N||b===N)&&sessionStorage.removeItem("pendingSessionId"),x([]),i(A=>[...A,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}])):i(A=>[...A,{type:"error",content:"Stop request failed. The session is still running.",timestamp:new Date}]);break}case"session-status":{const b=t.sessionId;(b===n||a&&b===a.id)&&t.isProcessing&&(c(!0),u(!0),w?.(b));break}case"claude-status":{const b=t.data;if(!b)break;const N={text:"Working...",tokens:0,can_interrupt:!0};b.message?N.text=b.message:b.status?N.text=b.status:typeof b=="string"&&(N.text=b),b.tokens?N.tokens=b.tokens:b.token_count&&(N.tokens=b.token_count),b.can_interrupt!==void 0&&(N.can_interrupt=b.can_interrupt),d(N),c(!0),u(N.can_interrupt);break}}},[t,r,s,a,n,o,i,c,u,d,m,p,x,k,w,S,y,v])}var Us={exports:{}},Hs,xn;function xu(){if(xn)return Hs;xn=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Hs=t,Hs}var Gs,gn;function gu(){if(gn)return Gs;gn=1;var t=xu();function r(){}function s(){}return s.resetWarningCache=r,Gs=function(){function a(i,c,u,d,m,p){if(p!==t){var x=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw x.name="Invariant Violation",x}}a.isRequired=a;function n(){return a}var o={array:a,bigint:a,bool:a,func:a,number:a,object:a,string:a,symbol:a,any:a,arrayOf:n,element:a,elementType:a,instanceOf:n,node:a,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:s,resetWarningCache:r};return o.PropTypes=o,o},Gs}var hn;function hu(){return hn||(hn=1,Us.exports=gu()()),Us.exports}var fu=hu();const Je=Jn(fu);var fn=function(){return fn=Object.assign||function(r){for(var s,a=1,n=arguments.length;a<n;a++){s=arguments[a];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])}return r},fn.apply(this,arguments)};function xx(t,r){var s={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&r.indexOf(a)<0&&(s[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,a=Object.getOwnPropertySymbols(t);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(t,a[n])&&(s[a[n]]=t[a[n]]);return s}function or(t,r,s,a){function n(o){return o instanceof s?o:new s(function(i){i(o)})}return new(s||(s=Promise))(function(o,i){function c(m){try{d(a.next(m))}catch(p){i(p)}}function u(m){try{d(a.throw(m))}catch(p){i(p)}}function d(m){m.done?o(m.value):n(m.value).then(c,u)}d((a=a.apply(t,r||[])).next())})}function gx(t,r,s){if(s||arguments.length===2)for(var a=0,n=r.length,o;a<n;a++)(o||!(a in r))&&(o||(o=Array.prototype.slice.call(r,0,a)),o[a]=r[a]);return t.concat(o||Array.prototype.slice.call(r))}const bu=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function fr(t,r,s){const a=yu(t),{webkitRelativePath:n}=t,o=typeof r=="string"?r:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof a.path!="string"&&bn(a,"path",o),bn(a,"relativePath",o),a}function yu(t){const{name:r}=t;if(r&&r.lastIndexOf(".")!==-1&&!t.type){const a=r.split(".").pop().toLowerCase(),n=bu.get(a);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function bn(t,r,s){Object.defineProperty(t,r,{value:s,writable:!1,configurable:!1,enumerable:!0})}const vu=[".DS_Store","Thumbs.db"];function ku(t){return or(this,void 0,void 0,function*(){return gs(t)&&ju(t.dataTransfer)?Su(t.dataTransfer,t.type):wu(t)?Nu(t):Array.isArray(t)&&t.every(r=>"getFile"in r&&typeof r.getFile=="function")?Cu(t):[]})}function ju(t){return gs(t)}function wu(t){return gs(t)&&gs(t.target)}function gs(t){return typeof t=="object"&&t!==null}function Nu(t){return ia(t.target.files).map(r=>fr(r))}function Cu(t){return or(this,void 0,void 0,function*(){return(yield Promise.all(t.map(s=>s.getFile()))).map(s=>fr(s))})}function Su(t,r){return or(this,void 0,void 0,function*(){if(t.items){const s=ia(t.items).filter(n=>n.kind==="file");if(r!=="drop")return s;const a=yield Promise.all(s.map(Eu));return yn(Ho(a))}return yn(ia(t.files).map(s=>fr(s)))})}function yn(t){return t.filter(r=>vu.indexOf(r.name)===-1)}function ia(t){if(t===null)return[];const r=[];for(let s=0;s<t.length;s++){const a=t[s];r.push(a)}return r}function Eu(t){if(typeof t.webkitGetAsEntry!="function")return vn(t);const r=t.webkitGetAsEntry();return r&&r.isDirectory?Go(r):vn(t,r)}function Ho(t){return t.reduce((r,s)=>[...r,...Array.isArray(s)?Ho(s):[s]],[])}function vn(t,r){return or(this,void 0,void 0,function*(){var s;if(globalThis.isSecureContext&&typeof t.getAsFileSystemHandle=="function"){const o=yield t.getAsFileSystemHandle();if(o===null)throw new Error(`${t} is not a File`);if(o!==void 0){const i=yield o.getFile();return i.handle=o,fr(i)}}const a=t.getAsFile();if(!a)throw new Error(`${t} is not a File`);return fr(a,(s=r?.fullPath)!==null&&s!==void 0?s:void 0)})}function Tu(t){return or(this,void 0,void 0,function*(){return t.isDirectory?Go(t):Iu(t)})}function Go(t){const r=t.createReader();return new Promise((s,a)=>{const n=[];function o(){r.readEntries(i=>or(this,void 0,void 0,function*(){if(i.length){const c=Promise.all(i.map(Tu));n.push(c),o()}else try{const c=yield Promise.all(n);s(c)}catch(c){a(c)}}),i=>{a(i)})}o()})}function Iu(t){return or(this,void 0,void 0,function*(){return new Promise((r,s)=>{t.file(a=>{const n=fr(a,t.fullPath);r(n)},a=>{s(a)})})})}var ts={},kn;function Du(){return kn||(kn=1,ts.__esModule=!0,ts.default=function(t,r){if(t&&r){var s=Array.isArray(r)?r:r.split(",");if(s.length===0)return!0;var a=t.name||"",n=(t.type||"").toLowerCase(),o=n.replace(/\/.*$/,"");return s.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?a.toLowerCase().endsWith(c):c.endsWith("/*")?o===c.replace(/\/.*$/,""):n===c})}return!0}),ts}var Au=Du();const qs=Jn(Au);function jn(t){return Fu(t)||Pu(t)||Ko(t)||Mu()}function Mu(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
115
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Pu(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Fu(t){if(Array.isArray(t))return la(t)}function wn(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function Nn(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?wn(Object(s),!0).forEach(function(a){qo(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):wn(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function qo(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function zr(t,r){return _u(t)||Lu(t,r)||Ko(t,r)||$u()}function $u(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
116
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ko(t,r){if(t){if(typeof t=="string")return la(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return la(t,r)}}function la(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,a=new Array(r);s<r;s++)a[s]=t[s];return a}function Lu(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var a=[],n=!0,o=!1,i,c;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(u){o=!0,c=u}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw c}}return a}}function _u(t){if(Array.isArray(t))return t}var Ru=typeof qs=="function"?qs:qs.default,zu="file-invalid-type",Ou="file-too-large",Bu="file-too-small",Wu="too-many-files",Uu=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",s=r.split(","),a=s.length>1?"one of ".concat(s.join(", ")):s[0];return{code:zu,message:"File type must be ".concat(a)}},Cn=function(r){return{code:Ou,message:"File is larger than ".concat(r," ").concat(r===1?"byte":"bytes")}},Sn=function(r){return{code:Bu,message:"File is smaller than ".concat(r," ").concat(r===1?"byte":"bytes")}},Hu={code:Wu,message:"Too many files"};function Gu(t){return t.type===""&&typeof t.getAsFile=="function"}function Vo(t,r){var s=t.type==="application/x-moz-file"||Ru(t,r)||Gu(t);return[s,s?null:Uu(r)]}function Jo(t,r,s){if(tr(t.size))if(tr(r)&&tr(s)){if(t.size>s)return[!1,Cn(s)];if(t.size<r)return[!1,Sn(r)]}else{if(tr(r)&&t.size<r)return[!1,Sn(r)];if(tr(s)&&t.size>s)return[!1,Cn(s)]}return[!0,null]}function tr(t){return t!=null}function qu(t){var r=t.files,s=t.accept,a=t.minSize,n=t.maxSize,o=t.multiple,i=t.maxFiles,c=t.validator;return!o&&r.length>1||o&&i>=1&&r.length>i?!1:r.every(function(u){var d=Vo(u,s),m=zr(d,1),p=m[0],x=Jo(u,a,n),h=zr(x,1),f=h[0],g=c?c(u):null;return p&&f&&!g})}function hs(t){return typeof t.isPropagationStopped=="function"?t.isPropagationStopped():typeof t.cancelBubble<"u"?t.cancelBubble:!1}function Dr(t){return t.dataTransfer?Array.prototype.some.call(t.dataTransfer.types,function(r){return r==="Files"||r==="application/x-moz-file"}):!!t.target&&!!t.target.files}function En(t){t.preventDefault()}function Ku(t){return t.indexOf("MSIE")!==-1||t.indexOf("Trident/")!==-1}function Vu(t){return t.indexOf("Edge/")!==-1}function Ju(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Ku(t)||Vu(t)}function Ct(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return function(a){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return r.some(function(c){return!hs(a)&&c&&c.apply(void 0,[a].concat(o)),hs(a)})}}function Yu(){return"showOpenFilePicker"in window}function Qu(t){if(tr(t)){var r=Object.entries(t).filter(function(s){var a=zr(s,2),n=a[0],o=a[1],i=!0;return Yo(n)||(console.warn('Skipped "'.concat(n,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(o)||!o.every(Qo))&&(console.warn('Skipped "'.concat(n,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(s,a){var n=zr(a,2),o=n[0],i=n[1];return Nn(Nn({},s),{},qo({},o,i))},{});return[{description:"Files",accept:r}]}return t}function Xu(t){if(tr(t))return Object.entries(t).reduce(function(r,s){var a=zr(s,2),n=a[0],o=a[1];return[].concat(jn(r),[n],jn(o))},[]).filter(function(r){return Yo(r)||Qo(r)}).join(",")}function Zu(t){return t instanceof DOMException&&(t.name==="AbortError"||t.code===t.ABORT_ERR)}function em(t){return t instanceof DOMException&&(t.name==="SecurityError"||t.code===t.SECURITY_ERR)}function Yo(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||t==="application/*"||/\w+\/[-+.\w]+/g.test(t)}function Qo(t){return/^.*\.[\w]+$/.test(t)}var tm=["children"],rm=["open"],sm=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],am=["refKey","onChange","onClick"];function Tn(t){return im(t)||om(t)||Xo(t)||nm()}function nm(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
117
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function om(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function im(t){if(Array.isArray(t))return ca(t)}function Ks(t,r){return dm(t)||cm(t,r)||Xo(t,r)||lm()}function lm(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
118
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xo(t,r){if(t){if(typeof t=="string")return ca(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return ca(t,r)}}function ca(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,a=new Array(r);s<r;s++)a[s]=t[s];return a}function cm(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var a=[],n=!0,o=!1,i,c;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(u){o=!0,c=u}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw c}}return a}}function dm(t){if(Array.isArray(t))return t}function In(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function Ye(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?In(Object(s),!0).forEach(function(a){da(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):In(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function da(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function fs(t,r){if(t==null)return{};var s=um(t,r),a,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)a=o[n],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(s[a]=t[a])}return s}function um(t,r){if(t==null)return{};var s={},a=Object.keys(t),n,o;for(o=0;o<a.length;o++)n=a[o],!(r.indexOf(n)>=0)&&(s[n]=t[n]);return s}var Pa=l.forwardRef(function(t,r){var s=t.children,a=fs(t,tm),n=ei(a),o=n.open,i=fs(n,rm);return l.useImperativeHandle(r,function(){return{open:o}},[o]),Et.createElement(l.Fragment,null,s(Ye(Ye({},i),{},{open:o})))});Pa.displayName="Dropzone";var Zo={disabled:!1,getFilesFromEvent:ku,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};Pa.defaultProps=Zo;Pa.propTypes={children:Je.func,accept:Je.objectOf(Je.arrayOf(Je.string)),multiple:Je.bool,preventDropOnDocument:Je.bool,noClick:Je.bool,noKeyboard:Je.bool,noDrag:Je.bool,noDragEventsBubbling:Je.bool,minSize:Je.number,maxSize:Je.number,maxFiles:Je.number,disabled:Je.bool,getFilesFromEvent:Je.func,onFileDialogCancel:Je.func,onFileDialogOpen:Je.func,useFsAccessApi:Je.bool,autoFocus:Je.bool,onDragEnter:Je.func,onDragLeave:Je.func,onDragOver:Je.func,onDrop:Je.func,onDropAccepted:Je.func,onDropRejected:Je.func,onError:Je.func,validator:Je.func};var ua={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function ei(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=Ye(Ye({},Zo),t),s=r.accept,a=r.disabled,n=r.getFilesFromEvent,o=r.maxSize,i=r.minSize,c=r.multiple,u=r.maxFiles,d=r.onDragEnter,m=r.onDragLeave,p=r.onDragOver,x=r.onDrop,h=r.onDropAccepted,f=r.onDropRejected,g=r.onFileDialogCancel,k=r.onFileDialogOpen,w=r.useFsAccessApi,S=r.autoFocus,y=r.preventDropOnDocument,v=r.noClick,T=r.noKeyboard,z=r.noDrag,I=r.noDragEventsBubbling,F=r.onError,B=r.validator,D=l.useMemo(function(){return Xu(s)},[s]),H=l.useMemo(function(){return Qu(s)},[s]),$=l.useMemo(function(){return typeof k=="function"?k:Dn},[k]),R=l.useMemo(function(){return typeof g=="function"?g:Dn},[g]),E=l.useRef(null),U=l.useRef(null),j=l.useReducer(mm,ua),_=Ks(j,2),V=_[0],ee=_[1],M=V.isFocused,G=V.isFileDialogActive,C=l.useRef(typeof window<"u"&&window.isSecureContext&&w&&Yu()),b=function(){!C.current&&G&&setTimeout(function(){if(U.current){var se=U.current.files;se.length||(ee({type:"closeDialog"}),R())}},300)};l.useEffect(function(){return window.addEventListener("focus",b,!1),function(){window.removeEventListener("focus",b,!1)}},[U,G,R,C]);var N=l.useRef([]),W=l.useRef([]),A=function(se){E.current&&E.current.contains(se.target)||(se.preventDefault(),N.current=[])};l.useEffect(function(){return y&&(document.addEventListener("dragover",En,!1),document.addEventListener("drop",A,!1)),function(){y&&(document.removeEventListener("dragover",En),document.removeEventListener("drop",A))}},[E,y]),l.useEffect(function(){var te=function(Ke){W.current=[].concat(Tn(W.current),[Ke.target]),Dr(Ke)&&ee({isDragGlobal:!0,type:"setDragGlobal"})},se=function(Ke){W.current=W.current.filter(function(Be){return Be!==Ke.target&&Be!==null}),!(W.current.length>0)&&ee({isDragGlobal:!1,type:"setDragGlobal"})},ke=function(){W.current=[],ee({isDragGlobal:!1,type:"setDragGlobal"})},Ne=function(){W.current=[],ee({isDragGlobal:!1,type:"setDragGlobal"})};return document.addEventListener("dragenter",te,!1),document.addEventListener("dragleave",se,!1),document.addEventListener("dragend",ke,!1),document.addEventListener("drop",Ne,!1),function(){document.removeEventListener("dragenter",te),document.removeEventListener("dragleave",se),document.removeEventListener("dragend",ke),document.removeEventListener("drop",Ne)}},[E]),l.useEffect(function(){return!a&&S&&E.current&&E.current.focus(),function(){}},[E,S,a]);var O=l.useCallback(function(te){F?F(te):console.error(te)},[F]),q=l.useCallback(function(te){te.preventDefault(),te.persist(),Re(te),N.current=[].concat(Tn(N.current),[te.target]),Dr(te)&&Promise.resolve(n(te)).then(function(se){if(!(hs(te)&&!I)){var ke=se.length,Ne=ke>0&&qu({files:se,accept:D,minSize:i,maxSize:o,multiple:c,maxFiles:u,validator:B}),Ie=ke>0&&!Ne;ee({isDragAccept:Ne,isDragReject:Ie,isDragActive:!0,type:"setDraggedFiles"}),d&&d(te)}}).catch(function(se){return O(se)})},[n,d,O,I,D,i,o,c,u,B]),Z=l.useCallback(function(te){te.preventDefault(),te.persist(),Re(te);var se=Dr(te);if(se&&te.dataTransfer)try{te.dataTransfer.dropEffect="copy"}catch{}return se&&p&&p(te),!1},[p,I]),J=l.useCallback(function(te){te.preventDefault(),te.persist(),Re(te);var se=N.current.filter(function(Ne){return E.current&&E.current.contains(Ne)}),ke=se.indexOf(te.target);ke!==-1&&se.splice(ke,1),N.current=se,!(se.length>0)&&(ee({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Dr(te)&&m&&m(te))},[E,m,I]),Q=l.useCallback(function(te,se){var ke=[],Ne=[];te.forEach(function(Ie){var Ke=Vo(Ie,D),Be=Ks(Ke,2),rt=Be[0],ue=Be[1],De=Jo(Ie,i,o),je=Ks(De,2),$e=je[0],ze=je[1],Fe=B?B(Ie):null;if(rt&&$e&&!Fe)ke.push(Ie);else{var re=[ue,ze];Fe&&(re=re.concat(Fe)),Ne.push({file:Ie,errors:re.filter(function(ce){return ce})})}}),(!c&&ke.length>1||c&&u>=1&&ke.length>u)&&(ke.forEach(function(Ie){Ne.push({file:Ie,errors:[Hu]})}),ke.splice(0)),ee({acceptedFiles:ke,fileRejections:Ne,isDragReject:Ne.length>0,type:"setFiles"}),x&&x(ke,Ne,se),Ne.length>0&&f&&f(Ne,se),ke.length>0&&h&&h(ke,se)},[ee,c,D,i,o,u,x,h,f,B]),le=l.useCallback(function(te){te.preventDefault(),te.persist(),Re(te),N.current=[],Dr(te)&&Promise.resolve(n(te)).then(function(se){hs(te)&&!I||Q(se,te)}).catch(function(se){return O(se)}),ee({type:"reset"})},[n,Q,O,I]),ae=l.useCallback(function(){if(C.current){ee({type:"openDialog"}),$();var te={multiple:c,types:H};window.showOpenFilePicker(te).then(function(se){return n(se)}).then(function(se){Q(se,null),ee({type:"closeDialog"})}).catch(function(se){Zu(se)?(R(se),ee({type:"closeDialog"})):em(se)?(C.current=!1,U.current?(U.current.value=null,U.current.click()):O(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):O(se)});return}U.current&&(ee({type:"openDialog"}),$(),U.current.value=null,U.current.click())},[ee,$,R,w,Q,O,H,c]),fe=l.useCallback(function(te){!E.current||!E.current.isEqualNode(te.target)||(te.key===" "||te.key==="Enter"||te.keyCode===32||te.keyCode===13)&&(te.preventDefault(),ae())},[E,ae]),Ee=l.useCallback(function(){ee({type:"focus"})},[]),Pe=l.useCallback(function(){ee({type:"blur"})},[]),He=l.useCallback(function(){v||(Ju()?setTimeout(ae,0):ae())},[v,ae]),Te=function(se){return a?null:se},be=function(se){return T?null:Te(se)},Ae=function(se){return z?null:Te(se)},Re=function(se){I&&se.stopPropagation()},X=l.useMemo(function(){return function(){var te=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},se=te.refKey,ke=se===void 0?"ref":se,Ne=te.role,Ie=te.onKeyDown,Ke=te.onFocus,Be=te.onBlur,rt=te.onClick,ue=te.onDragEnter,De=te.onDragOver,je=te.onDragLeave,$e=te.onDrop,ze=fs(te,sm);return Ye(Ye(da({onKeyDown:be(Ct(Ie,fe)),onFocus:be(Ct(Ke,Ee)),onBlur:be(Ct(Be,Pe)),onClick:Te(Ct(rt,He)),onDragEnter:Ae(Ct(ue,q)),onDragOver:Ae(Ct(De,Z)),onDragLeave:Ae(Ct(je,J)),onDrop:Ae(Ct($e,le)),role:typeof Ne=="string"&&Ne!==""?Ne:"presentation"},ke,E),!a&&!T?{tabIndex:0}:{}),ze)}},[E,fe,Ee,Pe,He,q,Z,J,le,T,z,a]),Ce=l.useCallback(function(te){te.stopPropagation()},[]),xe=l.useMemo(function(){return function(){var te=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},se=te.refKey,ke=se===void 0?"ref":se,Ne=te.onChange,Ie=te.onClick,Ke=fs(te,am),Be=da({accept:D,multiple:c,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:Te(Ct(Ne,le)),onClick:Te(Ct(Ie,Ce)),tabIndex:-1},ke,U);return Ye(Ye({},Be),Ke)}},[U,s,c,le,a]);return Ye(Ye({},V),{},{isFocused:M&&!a,getRootProps:X,getInputProps:xe,rootRef:E,inputRef:U,open:Te(ae)})}function mm(t,r){switch(r.type){case"focus":return Ye(Ye({},t),{},{isFocused:!0});case"blur":return Ye(Ye({},t),{},{isFocused:!1});case"openDialog":return Ye(Ye({},ua),{},{isFileDialogActive:!0});case"closeDialog":return Ye(Ye({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return Ye(Ye({},t),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return Ye(Ye({},t),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"setDragGlobal":return Ye(Ye({},t),{},{isDragGlobal:r.isDragGlobal});case"reset":return Ye({},ua);default:return t}}function Dn(){}const ti=(t,r="")=>{let s=[];return t.forEach(a=>{const n=r?`${r}/${a.name}`:a.name;if(a.type==="directory"&&a.children){s=s.concat(ti(a.children,n));return}a.type==="file"&&s.push({name:a.name,path:n,relativePath:a.path})}),s};function pm({selectedProject:t,input:r,setInput:s,textareaRef:a}){const[n,o]=l.useState([]),[i,c]=l.useState([]),[u,d]=l.useState([]),[m,p]=l.useState(!1),[x,h]=l.useState(-1),[f,g]=l.useState(0),[k,w]=l.useState(-1);l.useEffect(()=>{const B=new AbortController;return(async()=>{const H=t?.name;if(o([]),d([]),!!H)try{const $=await Ge.getFiles(H,{signal:B.signal});if(!$.ok)return;const R=await $.json();o(ti(R))}catch($){if($?.name==="AbortError")return;console.error("Error fetching files:",$)}})(),()=>{B.abort()}},[t?.name]),l.useEffect(()=>{const B=r.slice(0,f),D=B.lastIndexOf("@");if(D===-1){p(!1),w(-1);return}const H=B.slice(D+1);if(H.includes(" ")){p(!1),w(-1);return}w(D),p(!0),h(-1);const $=n.filter(R=>R.name.toLowerCase().includes(H.toLowerCase())||R.path.toLowerCase().includes(H.toLowerCase())).slice(0,10);d($)},[r,f,n]);const S=l.useMemo(()=>!r||i.length===0?[]:i.filter(B=>r.includes(B)),[i,r]),y=l.useMemo(()=>S.length===0?[]:Array.from(new Set(S)).sort((D,H)=>H.length-D.length),[S]),v=l.useMemo(()=>{if(y.length===0)return null;const B=y.map(Po).join("|");return new RegExp(`(${B})`,"g")},[y]),T=l.useMemo(()=>new Set(y),[y]),z=l.useCallback(B=>B?v?B.split(v).map((H,$)=>T.has(H)?e.jsx("span",{className:"bg-blue-200/70 -ml-0.5 dark:bg-blue-300/40 px-0.5 rounded-md box-decoration-clone text-transparent",children:H},`mention-${$}`):e.jsx("span",{children:H},`text-${$}`)):B:"",[v,T]),I=l.useCallback(B=>{const D=r.slice(0,k),H=r.slice(k),$=H.indexOf(" "),R=$!==-1?H.slice($):"",E=`${D}${B.path} ${R}`,U=D.length+B.path.length+1;a.current&&!a.current.matches(":focus")&&a.current.focus(),s(E),g(U),c(j=>j.includes(B.path)?j:[...j,B.path]),p(!1),w(-1),a.current&&requestAnimationFrame(()=>{a.current&&(a.current.setSelectionRange(U,U),a.current.matches(":focus")||a.current.focus())})},[r,k,a,s]),F=l.useCallback(B=>!m||u.length===0?!1:B.key==="ArrowDown"?(B.preventDefault(),h(D=>D<u.length-1?D+1:0),!0):B.key==="ArrowUp"?(B.preventDefault(),h(D=>D>0?D-1:u.length-1),!0):B.key==="Tab"||B.key==="Enter"?(B.preventDefault(),x>=0?I(u[x]):u.length>0&&I(u[0]),!0):B.key==="Escape"?(B.preventDefault(),p(!1),!0):!1,[m,u,x,I]);return{showFileDropdown:m,filteredFiles:u,selectedFileIndex:x,renderInputWithMentions:z,selectFile:I,setCursorPosition:g,handleFileMentionsKeyDown:F}}function _t(t){return Array.isArray?Array.isArray(t):ai(t)==="[object Array]"}function xm(t){if(typeof t=="string")return t;let r=t+"";return r=="0"&&1/t==-1/0?"-0":r}function gm(t){return t==null?"":xm(t)}function Dt(t){return typeof t=="string"}function ri(t){return typeof t=="number"}function hm(t){return t===!0||t===!1||fm(t)&&ai(t)=="[object Boolean]"}function si(t){return typeof t=="object"}function fm(t){return si(t)&&t!==null}function ht(t){return t!=null}function Vs(t){return!t.trim().length}function ai(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const bm="Incorrect 'index' type",ym=t=>`Invalid value for key ${t}`,vm=t=>`Pattern length exceeds max of ${t}.`,km=t=>`Missing ${t} property in key`,jm=t=>`Property 'weight' in key '${t}' must be a positive integer`,An=Object.prototype.hasOwnProperty;class wm{constructor(r){this._keys=[],this._keyMap={};let s=0;r.forEach(a=>{let n=ni(a);this._keys.push(n),this._keyMap[n.id]=n,s+=n.weight}),this._keys.forEach(a=>{a.weight/=s})}get(r){return this._keyMap[r]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ni(t){let r=null,s=null,a=null,n=1,o=null;if(Dt(t)||_t(t))a=t,r=Mn(t),s=ma(t);else{if(!An.call(t,"name"))throw new Error(km("name"));const i=t.name;if(a=i,An.call(t,"weight")&&(n=t.weight,n<=0))throw new Error(jm(i));r=Mn(i),s=ma(i),o=t.getFn}return{path:r,id:s,weight:n,src:a,getFn:o}}function Mn(t){return _t(t)?t:t.split(".")}function ma(t){return _t(t)?t.join("."):t}function Nm(t,r){let s=[],a=!1;const n=(o,i,c)=>{if(ht(o))if(!i[c])s.push(o);else{let u=i[c];const d=o[u];if(!ht(d))return;if(c===i.length-1&&(Dt(d)||ri(d)||hm(d)))s.push(gm(d));else if(_t(d)){a=!0;for(let m=0,p=d.length;m<p;m+=1)n(d[m],i,c+1)}else i.length&&n(d,i,c+1)}};return n(t,Dt(r)?r.split("."):r,0),a?s:s[0]}const Cm={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Sm={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,r)=>t.score===r.score?t.idx<r.idx?-1:1:t.score<r.score?-1:1},Em={location:0,threshold:.6,distance:100},Tm={useExtendedSearch:!1,getFn:Nm,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Se={...Sm,...Cm,...Em,...Tm};const Im=/[^ ]+/g;function Dm(t=1,r=3){const s=new Map,a=Math.pow(10,r);return{get(n){const o=n.match(Im).length;if(s.has(o))return s.get(o);const i=1/Math.pow(o,.5*t),c=parseFloat(Math.round(i*a)/a);return s.set(o,c),c},clear(){s.clear()}}}class Fa{constructor({getFn:r=Se.getFn,fieldNormWeight:s=Se.fieldNormWeight}={}){this.norm=Dm(s,3),this.getFn=r,this.isCreated=!1,this.setIndexRecords()}setSources(r=[]){this.docs=r}setIndexRecords(r=[]){this.records=r}setKeys(r=[]){this.keys=r,this._keysMap={},r.forEach((s,a)=>{this._keysMap[s.id]=a})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Dt(this.docs[0])?this.docs.forEach((r,s)=>{this._addString(r,s)}):this.docs.forEach((r,s)=>{this._addObject(r,s)}),this.norm.clear())}add(r){const s=this.size();Dt(r)?this._addString(r,s):this._addObject(r,s)}removeAt(r){this.records.splice(r,1);for(let s=r,a=this.size();s<a;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(r,s){return r[this._keysMap[s]]}size(){return this.records.length}_addString(r,s){if(!ht(r)||Vs(r))return;let a={v:r,i:s,n:this.norm.get(r)};this.records.push(a)}_addObject(r,s){let a={i:s,$:{}};this.keys.forEach((n,o)=>{let i=n.getFn?n.getFn(r):this.getFn(r,n.path);if(ht(i)){if(_t(i)){let c=[];const u=[{nestedArrIndex:-1,value:i}];for(;u.length;){const{nestedArrIndex:d,value:m}=u.pop();if(ht(m))if(Dt(m)&&!Vs(m)){let p={v:m,i:d,n:this.norm.get(m)};c.push(p)}else _t(m)&&m.forEach((p,x)=>{u.push({nestedArrIndex:x,value:p})})}a.$[o]=c}else if(Dt(i)&&!Vs(i)){let c={v:i,n:this.norm.get(i)};a.$[o]=c}}}),this.records.push(a)}toJSON(){return{keys:this.keys,records:this.records}}}function oi(t,r,{getFn:s=Se.getFn,fieldNormWeight:a=Se.fieldNormWeight}={}){const n=new Fa({getFn:s,fieldNormWeight:a});return n.setKeys(t.map(ni)),n.setSources(r),n.create(),n}function Am(t,{getFn:r=Se.getFn,fieldNormWeight:s=Se.fieldNormWeight}={}){const{keys:a,records:n}=t,o=new Fa({getFn:r,fieldNormWeight:s});return o.setKeys(a),o.setIndexRecords(n),o}function rs(t,{errors:r=0,currentLocation:s=0,expectedLocation:a=0,distance:n=Se.distance,ignoreLocation:o=Se.ignoreLocation}={}){const i=r/t.length;if(o)return i;const c=Math.abs(a-s);return n?i+c/n:c?1:i}function Mm(t=[],r=Se.minMatchCharLength){let s=[],a=-1,n=-1,o=0;for(let i=t.length;o<i;o+=1){let c=t[o];c&&a===-1?a=o:!c&&a!==-1&&(n=o-1,n-a+1>=r&&s.push([a,n]),a=-1)}return t[o-1]&&o-a>=r&&s.push([a,o-1]),s}const rr=32;function Pm(t,r,s,{location:a=Se.location,distance:n=Se.distance,threshold:o=Se.threshold,findAllMatches:i=Se.findAllMatches,minMatchCharLength:c=Se.minMatchCharLength,includeMatches:u=Se.includeMatches,ignoreLocation:d=Se.ignoreLocation}={}){if(r.length>rr)throw new Error(vm(rr));const m=r.length,p=t.length,x=Math.max(0,Math.min(a,p));let h=o,f=x;const g=c>1||u,k=g?Array(p):[];let w;for(;(w=t.indexOf(r,f))>-1;){let I=rs(r,{currentLocation:w,expectedLocation:x,distance:n,ignoreLocation:d});if(h=Math.min(I,h),f=w+m,g){let F=0;for(;F<m;)k[w+F]=1,F+=1}}f=-1;let S=[],y=1,v=m+p;const T=1<<m-1;for(let I=0;I<m;I+=1){let F=0,B=v;for(;F<B;)rs(r,{errors:I,currentLocation:x+B,expectedLocation:x,distance:n,ignoreLocation:d})<=h?F=B:v=B,B=Math.floor((v-F)/2+F);v=B;let D=Math.max(1,x-B+1),H=i?p:Math.min(x+B,p)+m,$=Array(H+2);$[H+1]=(1<<I)-1;for(let E=H;E>=D;E-=1){let U=E-1,j=s[t.charAt(U)];if(g&&(k[U]=+!!j),$[E]=($[E+1]<<1|1)&j,I&&($[E]|=(S[E+1]|S[E])<<1|1|S[E+1]),$[E]&T&&(y=rs(r,{errors:I,currentLocation:U,expectedLocation:x,distance:n,ignoreLocation:d}),y<=h)){if(h=y,f=U,f<=x)break;D=Math.max(1,2*x-f)}}if(rs(r,{errors:I+1,currentLocation:x,expectedLocation:x,distance:n,ignoreLocation:d})>h)break;S=$}const z={isMatch:f>=0,score:Math.max(.001,y)};if(g){const I=Mm(k,c);I.length?u&&(z.indices=I):z.isMatch=!1}return z}function Fm(t){let r={};for(let s=0,a=t.length;s<a;s+=1){const n=t.charAt(s);r[n]=(r[n]||0)|1<<a-s-1}return r}const bs=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class ii{constructor(r,{location:s=Se.location,threshold:a=Se.threshold,distance:n=Se.distance,includeMatches:o=Se.includeMatches,findAllMatches:i=Se.findAllMatches,minMatchCharLength:c=Se.minMatchCharLength,isCaseSensitive:u=Se.isCaseSensitive,ignoreDiacritics:d=Se.ignoreDiacritics,ignoreLocation:m=Se.ignoreLocation}={}){if(this.options={location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:u,ignoreDiacritics:d,ignoreLocation:m},r=u?r:r.toLowerCase(),r=d?bs(r):r,this.pattern=r,this.chunks=[],!this.pattern.length)return;const p=(h,f)=>{this.chunks.push({pattern:h,alphabet:Fm(h),startIndex:f})},x=this.pattern.length;if(x>rr){let h=0;const f=x%rr,g=x-f;for(;h<g;)p(this.pattern.substr(h,rr),h),h+=rr;if(f){const k=x-rr;p(this.pattern.substr(k),k)}}else p(this.pattern,0)}searchIn(r){const{isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n}=this.options;if(r=s?r:r.toLowerCase(),r=a?bs(r):r,this.pattern===r){let g={isMatch:!0,score:0};return n&&(g.indices=[[0,r.length-1]]),g}const{location:o,distance:i,threshold:c,findAllMatches:u,minMatchCharLength:d,ignoreLocation:m}=this.options;let p=[],x=0,h=!1;this.chunks.forEach(({pattern:g,alphabet:k,startIndex:w})=>{const{isMatch:S,score:y,indices:v}=Pm(r,g,k,{location:o+w,distance:i,threshold:c,findAllMatches:u,minMatchCharLength:d,includeMatches:n,ignoreLocation:m});S&&(h=!0),x+=y,S&&v&&(p=[...p,...v])});let f={isMatch:h,score:h?x/this.chunks.length:1};return h&&n&&(f.indices=p),f}}class Yt{constructor(r){this.pattern=r}static isMultiMatch(r){return Pn(r,this.multiRegex)}static isSingleMatch(r){return Pn(r,this.singleRegex)}search(){}}function Pn(t,r){const s=t.match(r);return s?s[1]:null}class $m extends Yt{constructor(r){super(r)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(r){const s=r===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Lm extends Yt{constructor(r){super(r)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(r){const a=r.indexOf(this.pattern)===-1;return{isMatch:a,score:a?0:1,indices:[0,r.length-1]}}}class _m extends Yt{constructor(r){super(r)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(r){const s=r.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Rm extends Yt{constructor(r){super(r)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(r){const s=!r.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,r.length-1]}}}class zm extends Yt{constructor(r){super(r)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(r){const s=r.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[r.length-this.pattern.length,r.length-1]}}}class Om extends Yt{constructor(r){super(r)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(r){const s=!r.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,r.length-1]}}}class li extends Yt{constructor(r,{location:s=Se.location,threshold:a=Se.threshold,distance:n=Se.distance,includeMatches:o=Se.includeMatches,findAllMatches:i=Se.findAllMatches,minMatchCharLength:c=Se.minMatchCharLength,isCaseSensitive:u=Se.isCaseSensitive,ignoreDiacritics:d=Se.ignoreDiacritics,ignoreLocation:m=Se.ignoreLocation}={}){super(r),this._bitapSearch=new ii(r,{location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:u,ignoreDiacritics:d,ignoreLocation:m})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(r){return this._bitapSearch.searchIn(r)}}class ci extends Yt{constructor(r){super(r)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(r){let s=0,a;const n=[],o=this.pattern.length;for(;(a=r.indexOf(this.pattern,s))>-1;)s=a+o,n.push([a,s-1]);const i=!!n.length;return{isMatch:i,score:i?0:1,indices:n}}}const pa=[$m,ci,_m,Rm,Om,zm,Lm,li],Fn=pa.length,Bm=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Wm="|";function Um(t,r={}){return t.split(Wm).map(s=>{let a=s.trim().split(Bm).filter(o=>o&&!!o.trim()),n=[];for(let o=0,i=a.length;o<i;o+=1){const c=a[o];let u=!1,d=-1;for(;!u&&++d<Fn;){const m=pa[d];let p=m.isMultiMatch(c);p&&(n.push(new m(p,r)),u=!0)}if(!u)for(d=-1;++d<Fn;){const m=pa[d];let p=m.isSingleMatch(c);if(p){n.push(new m(p,r));break}}}return n})}const Hm=new Set([li.type,ci.type]);class Gm{constructor(r,{isCaseSensitive:s=Se.isCaseSensitive,ignoreDiacritics:a=Se.ignoreDiacritics,includeMatches:n=Se.includeMatches,minMatchCharLength:o=Se.minMatchCharLength,ignoreLocation:i=Se.ignoreLocation,findAllMatches:c=Se.findAllMatches,location:u=Se.location,threshold:d=Se.threshold,distance:m=Se.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n,minMatchCharLength:o,findAllMatches:c,ignoreLocation:i,location:u,threshold:d,distance:m},r=s?r:r.toLowerCase(),r=a?bs(r):r,this.pattern=r,this.query=Um(this.pattern,this.options)}static condition(r,s){return s.useExtendedSearch}searchIn(r){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:a,isCaseSensitive:n,ignoreDiacritics:o}=this.options;r=n?r:r.toLowerCase(),r=o?bs(r):r;let i=0,c=[],u=0;for(let d=0,m=s.length;d<m;d+=1){const p=s[d];c.length=0,i=0;for(let x=0,h=p.length;x<h;x+=1){const f=p[x],{isMatch:g,indices:k,score:w}=f.search(r);if(g){if(i+=1,u+=w,a){const S=f.constructor.type;Hm.has(S)?c=[...c,...k]:c.push(k)}}else{u=0,i=0,c.length=0;break}}if(i){let x={isMatch:!0,score:u/i};return a&&(x.indices=c),x}}return{isMatch:!1,score:1}}}const xa=[];function qm(...t){xa.push(...t)}function ga(t,r){for(let s=0,a=xa.length;s<a;s+=1){let n=xa[s];if(n.condition(t,r))return new n(t,r)}return new ii(t,r)}const ys={AND:"$and",OR:"$or"},ha={PATH:"$path",PATTERN:"$val"},fa=t=>!!(t[ys.AND]||t[ys.OR]),Km=t=>!!t[ha.PATH],Vm=t=>!_t(t)&&si(t)&&!fa(t),$n=t=>({[ys.AND]:Object.keys(t).map(r=>({[r]:t[r]}))});function di(t,r,{auto:s=!0}={}){const a=n=>{let o=Object.keys(n);const i=Km(n);if(!i&&o.length>1&&!fa(n))return a($n(n));if(Vm(n)){const u=i?n[ha.PATH]:o[0],d=i?n[ha.PATTERN]:n[u];if(!Dt(d))throw new Error(ym(u));const m={keyId:ma(u),pattern:d};return s&&(m.searcher=ga(d,r)),m}let c={children:[],operator:o[0]};return o.forEach(u=>{const d=n[u];_t(d)&&d.forEach(m=>{c.children.push(a(m))})}),c};return fa(t)||(t=$n(t)),a(t)}function Jm(t,{ignoreFieldNorm:r=Se.ignoreFieldNorm}){t.forEach(s=>{let a=1;s.matches.forEach(({key:n,norm:o,score:i})=>{const c=n?n.weight:null;a*=Math.pow(i===0&&c?Number.EPSILON:i,(c||1)*(r?1:o))}),s.score=a})}function Ym(t,r){const s=t.matches;r.matches=[],ht(s)&&s.forEach(a=>{if(!ht(a.indices)||!a.indices.length)return;const{indices:n,value:o}=a;let i={indices:n,value:o};a.key&&(i.key=a.key.src),a.idx>-1&&(i.refIndex=a.idx),r.matches.push(i)})}function Qm(t,r){r.score=t.score}function Xm(t,r,{includeMatches:s=Se.includeMatches,includeScore:a=Se.includeScore}={}){const n=[];return s&&n.push(Ym),a&&n.push(Qm),t.map(o=>{const{idx:i}=o,c={item:r[i],refIndex:i};return n.length&&n.forEach(u=>{u(o,c)}),c})}class vr{constructor(r,s={},a){this.options={...Se,...s},this.options.useExtendedSearch,this._keyStore=new wm(this.options.keys),this.setCollection(r,a)}setCollection(r,s){if(this._docs=r,s&&!(s instanceof Fa))throw new Error(bm);this._myIndex=s||oi(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(r){ht(r)&&(this._docs.push(r),this._myIndex.add(r))}remove(r=()=>!1){const s=[];for(let a=0,n=this._docs.length;a<n;a+=1){const o=this._docs[a];r(o,a)&&(this.removeAt(a),a-=1,n-=1,s.push(o))}return s}removeAt(r){this._docs.splice(r,1),this._myIndex.removeAt(r)}getIndex(){return this._myIndex}search(r,{limit:s=-1}={}){const{includeMatches:a,includeScore:n,shouldSort:o,sortFn:i,ignoreFieldNorm:c}=this.options;let u=Dt(r)?Dt(this._docs[0])?this._searchStringList(r):this._searchObjectList(r):this._searchLogical(r);return Jm(u,{ignoreFieldNorm:c}),o&&u.sort(i),ri(s)&&s>-1&&(u=u.slice(0,s)),Xm(u,this._docs,{includeMatches:a,includeScore:n})}_searchStringList(r){const s=ga(r,this.options),{records:a}=this._myIndex,n=[];return a.forEach(({v:o,i,n:c})=>{if(!ht(o))return;const{isMatch:u,score:d,indices:m}=s.searchIn(o);u&&n.push({item:o,idx:i,matches:[{score:d,value:o,norm:c,indices:m}]})}),n}_searchLogical(r){const s=di(r,this.options),a=(c,u,d)=>{if(!c.children){const{keyId:p,searcher:x}=c,h=this._findMatches({key:this._keyStore.get(p),value:this._myIndex.getValueForItemAtKeyId(u,p),searcher:x});return h&&h.length?[{idx:d,item:u,matches:h}]:[]}const m=[];for(let p=0,x=c.children.length;p<x;p+=1){const h=c.children[p],f=a(h,u,d);if(f.length)m.push(...f);else if(c.operator===ys.AND)return[]}return m},n=this._myIndex.records,o={},i=[];return n.forEach(({$:c,i:u})=>{if(ht(c)){let d=a(s,c,u);d.length&&(o[u]||(o[u]={idx:u,item:c,matches:[]},i.push(o[u])),d.forEach(({matches:m})=>{o[u].matches.push(...m)}))}}),i}_searchObjectList(r){const s=ga(r,this.options),{keys:a,records:n}=this._myIndex,o=[];return n.forEach(({$:i,i:c})=>{if(!ht(i))return;let u=[];a.forEach((d,m)=>{u.push(...this._findMatches({key:d,value:i[m],searcher:s}))}),u.length&&o.push({idx:c,item:i,matches:u})}),o}_findMatches({key:r,value:s,searcher:a}){if(!ht(s))return[];let n=[];if(_t(s))s.forEach(({v:o,i,n:c})=>{if(!ht(o))return;const{isMatch:u,score:d,indices:m}=a.searchIn(o);u&&n.push({score:d,key:r,value:o,idx:i,norm:c,indices:m})});else{const{v:o,n:i}=s,{isMatch:c,score:u,indices:d}=a.searchIn(o);c&&n.push({score:u,key:r,value:o,norm:i,indices:d})}return n}}vr.version="7.1.0";vr.createIndex=oi;vr.parseIndex=Am;vr.config=Se;vr.parseQuery=di;qm(Gm);const Zm=150,ui=t=>`command_history_${t}`,Js=t=>{const r=dt.getItem(ui(t));if(!r)return{};try{return JSON.parse(r)}catch(s){return console.error("Error parsing command history:",s),{}}},ep=(t,r)=>{dt.setItem(ui(t),JSON.stringify(r))},Ln=t=>!!t&&typeof t.then=="function";function tp({selectedProject:t,input:r,setInput:s,textareaRef:a,onExecuteCommand:n}){const[o,i]=l.useState([]),[c,u]=l.useState([]),[d,m]=l.useState(!1),[p,x]=l.useState(""),[h,f]=l.useState(-1),[g,k]=l.useState(-1),w=l.useRef(null),S=l.useCallback(()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]),y=l.useCallback(()=>{m(!1),k(-1),x(""),f(-1),S()},[S]);l.useEffect(()=>{(async()=>{if(!t){i([]),u([]);return}try{const R=await we("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:t.path})});if(!R.ok)throw new Error("Failed to fetch commands");const E=await R.json(),U=[...(E.builtIn||[]).map(V=>({...V,type:"built-in"})),...(E.custom||[]).map(V=>({...V,type:"custom"}))],j=Js(t.name),_=[...U].sort((V,ee)=>{const M=j[V.name]||0;return(j[ee.name]||0)-M});i(_)}catch(R){console.error("Error fetching slash commands:",R),i([])}})()},[t]),l.useEffect(()=>{d||f(-1)},[d]);const v=l.useMemo(()=>o.length?new vr(o,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[o]);l.useEffect(()=>{if(!p){u(o);return}if(!v){u([]);return}const $=v.search(p);u($.map(R=>R.item))},[p,o,v]);const T=l.useMemo(()=>{if(!t||o.length===0)return[];const $=Js(t.name);return o.map(R=>({...R,usageCount:$[R.name]||0})).filter(R=>R.usageCount>0).sort((R,E)=>E.usageCount-R.usageCount).slice(0,5)},[t,o]),z=l.useCallback($=>{if(!t)return;const R=Js(t.name);R[$.name]=(R[$.name]||0)+1,ep(t.name,R)},[t]),I=l.useCallback($=>{const R=r.slice(0,g),E=r.slice(g),U=E.indexOf(" "),j=U!==-1?E.slice(U):"",_=`${R}${$.name} ${j}`;s(_),y();const V=n($);Ln(V)&&V.catch(()=>{})},[r,g,s,y,n]),F=l.useCallback(($,R,E)=>{if(!$||!t)return;if(E){f(R);return}z($);const U=n($);Ln(U)?(U.then(()=>{y()}),U.catch(()=>{})):y()},[t,z,n,y]),B=l.useCallback(()=>{const $=!d;m($),x(""),f(-1),$&&u(o),a.current?.focus()},[d,o,a]),D=l.useCallback(($,R)=>{if(!$.trim()){y();return}const E=$.slice(0,R);if((E.match(/```/g)||[]).length%2===1){y();return}const _=/(^|\s)\/(\S*)$/,V=E.match(_);if(!V){y();return}const ee=(V.index||0)+V[1].length,M=V[2];k(ee),m(!0),f(-1),S(),w.current=window.setTimeout(()=>{x(M)},Zm)},[y,S]),H=l.useCallback($=>d?c.length?$.key==="ArrowDown"?($.preventDefault(),f(R=>R<c.length-1?R+1:0),!0):$.key==="ArrowUp"?($.preventDefault(),f(R=>R>0?R-1:c.length-1),!0):$.key==="Tab"||$.key==="Enter"?($.preventDefault(),h>=0?I(c[h]):c.length>0&&I(c[0]),!0):$.key==="Escape"?($.preventDefault(),y(),!0):!1:$.key==="Escape"?($.preventDefault(),y(),!0):!1:!1,[d,c,y,I,h]);return l.useEffect(()=>()=>{S()},[S]),{slashCommands:o,slashCommandsCount:o.length,filteredCommands:c,frequentCommands:T,commandQuery:p,showCommandMenu:d,selectedCommandIndex:h,resetCommandMenuState:y,handleCommandSelect:F,handleToggleCommandMenu:B,handleCommandInputChange:D,handleCommandMenuKeyDown:H}}const rp=()=>({preventDefault:()=>{}}),sp=t=>!!(t&&t.startsWith("new-session-"));function ap({selectedProject:t,selectedSession:r,currentSessionId:s,provider:a,permissionMode:n,cyclePermissionMode:o,cursorModel:i,claudeModel:c,codexModel:u,isLoading:d,canAbortSession:m,tokenBudget:p,sendMessage:x,sendByCtrlEnter:h,onSessionActive:f,onInputFocusChange:g,onFileOpen:k,onShowSettings:w,pendingViewSessionRef:S,scrollToBottom:y,setChatMessages:v,setSessionMessages:T,setIsLoading:z,setCanAbortSession:I,setClaudeStatus:F,setIsUserScrolledUp:B,setPendingPermissionRequests:D}){const[H,$]=l.useState(()=>typeof window<"u"&&t&&dt.getItem(`draft_input_${t.name}`)||""),[R,E]=l.useState([]),[U,j]=l.useState(new Map),[_,V]=l.useState(new Map),[ee,M]=l.useState(!1),[G,C]=l.useState("none"),b=l.useRef(null),N=l.useRef(null),W=l.useRef(null),A=l.useRef(H),O=l.useCallback(ie=>{const{action:ve,data:oe}=ie;switch(ve){case"clear":v([]),T?.([]);break;case"help":v(ye=>[...ye,{type:"assistant",content:oe.content,timestamp:Date.now()}]);break;case"model":v(ye=>[...ye,{type:"assistant",content:`**Current Model**: ${oe.current.model}
119
-
120
- **Available Models**:
121
-
122
- Claude: ${oe.available.claude.join(", ")}
123
-
124
- Cursor: ${oe.available.cursor.join(", ")}`,timestamp:Date.now()}]);break;case"cost":{const ye=`**Token Usage**: ${oe.tokenUsage.used.toLocaleString()} / ${oe.tokenUsage.total.toLocaleString()} (${oe.tokenUsage.percentage}%)
125
-
126
- **Estimated Cost**:
127
- - Input: $${oe.cost.input}
128
- - Output: $${oe.cost.output}
129
- - **Total**: $${oe.cost.total}
130
-
131
- **Model**: ${oe.model}`;v(L=>[...L,{type:"assistant",content:ye,timestamp:Date.now()}]);break}case"status":{const ye=`**System Status**
132
-
133
- - Version: ${oe.version}
134
- - Uptime: ${oe.uptime}
135
- - Model: ${oe.model}
136
- - Provider: ${oe.provider}
137
- - Node.js: ${oe.nodeVersion}
138
- - Platform: ${oe.platform}`;v(L=>[...L,{type:"assistant",content:ye,timestamp:Date.now()}]);break}case"memory":oe.error?v(ye=>[...ye,{type:"assistant",content:`⚠️ ${oe.message}`,timestamp:Date.now()}]):(v(ye=>[...ye,{type:"assistant",content:`📝 ${oe.message}
139
-
140
- Path: \`${oe.path}\``,timestamp:Date.now()}]),oe.exists&&k&&k(oe.path));break;case"config":w?.();break;case"rewind":oe.error?v(ye=>[...ye,{type:"assistant",content:`⚠️ ${oe.message}`,timestamp:Date.now()}]):(v(ye=>ye.slice(0,-oe.steps*2)),v(ye=>[...ye,{type:"assistant",content:`⏪ ${oe.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",ve)}},[k,w,v,T]),q=l.useCallback(async ie=>{const{content:ve,hasBashCommands:oe}=ie;if(oe&&!window.confirm("This command contains bash commands that will be executed. Do you want to proceed?")){v(K=>[...K,{type:"assistant",content:"❌ Command execution cancelled",timestamp:Date.now()}]);return}const ye=ve||"";$(ye),A.current=ye,setTimeout(()=>{W.current&&W.current(rp())},0)},[v]),Z=l.useCallback(async ie=>{if(!(!ie||!t))try{const ve=H.match(new RegExp(`${Po(ie.name)}\\s*(.*)`)),oe=ve&&ve[1]?ve[1].trim().split(/\s+/):[],ye={projectPath:t.fullPath||t.path,projectName:t.name,sessionId:s,provider:a,model:a==="cursor"?i:a==="codex"?u:c,tokenUsage:p},L=await we("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:ie.name,commandPath:ie.path,args:oe,context:ye})});if(!L.ok){let de=`Failed to execute command (${L.status})`;try{const We=await L.json();de=We?.message||We?.error||de}catch{}throw new Error(de)}const K=await L.json();K.type==="builtin"?(O(K),$(""),A.current=""):K.type==="custom"&&await q(K)}catch(ve){const oe=ve instanceof Error?ve.message:"Unknown error";console.error("Error executing command:",ve),v(ye=>[...ye,{type:"assistant",content:`Error executing command: ${oe}`,timestamp:Date.now()}])}},[c,u,s,i,O,q,H,a,t,v,p]),{slashCommandsCount:J,filteredCommands:Q,frequentCommands:le,commandQuery:ae,showCommandMenu:fe,selectedCommandIndex:Ee,resetCommandMenuState:Pe,handleCommandSelect:He,handleToggleCommandMenu:Te,handleCommandInputChange:be,handleCommandMenuKeyDown:Ae}=tp({selectedProject:t,input:H,setInput:$,textareaRef:b,onExecuteCommand:Z}),{showFileDropdown:Re,filteredFiles:X,selectedFileIndex:Ce,renderInputWithMentions:xe,selectFile:te,setCursorPosition:se,handleFileMentionsKeyDown:ke}=pm({selectedProject:t,input:H,setInput:$,textareaRef:b}),Ne=l.useCallback(ie=>{!N.current||!ie||(N.current.scrollTop=ie.scrollTop,N.current.scrollLeft=ie.scrollLeft)},[]),Ie=l.useCallback(ie=>{const ve=ie.filter(oe=>{try{if(!oe||typeof oe!="object")return console.warn("Invalid file object:",oe),!1;if(!oe.type||!oe.type.startsWith("image/"))return!1;if(!oe.size||oe.size>5242880){const ye=oe.name||"Unknown file";return V(L=>{const K=new Map(L);return K.set(ye,"File too large (max 5MB)"),K}),!1}return!0}catch(ye){return console.error("Error validating file:",ye,oe),!1}});ve.length>0&&E(oe=>[...oe,...ve].slice(0,5))},[]),Ke=l.useCallback(ie=>{const ve=Array.from(ie.clipboardData.items);if(ve.forEach(oe=>{if(!oe.type.startsWith("image/"))return;const ye=oe.getAsFile();ye&&Ie([ye])}),ve.length===0&&ie.clipboardData.files.length>0){const ye=Array.from(ie.clipboardData.files).filter(L=>L.type.startsWith("image/"));ye.length>0&&Ie(ye)}},[Ie]),{getRootProps:Be,getInputProps:rt,isDragActive:ue,open:De}=ei({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:Ie,noClick:!0,noKeyboard:!0}),je=l.useCallback(async ie=>{ie.preventDefault();const ve=A.current;if(!ve.trim()||d||!t)return;let oe=ve;const ye=Uo.find(nt=>nt.id===G);ye&&ye.prefix&&(oe=`${ye.prefix}: ${ve}`);let L=[];if(R.length>0){const nt=new FormData;R.forEach(lt=>{nt.append("images",lt)});try{const lt=await we(`/api/projects/${t.name}/upload-images`,{method:"POST",headers:{},body:nt});if(!lt.ok)throw new Error("Failed to upload images");L=(await lt.json()).images}catch(lt){const Qt=lt instanceof Error?lt.message:"Unknown error";console.error("Image upload failed:",lt),v(kr=>[...kr,{type:"error",content:`Failed to upload images: ${Qt}`,timestamp:new Date}]);return}}const K={type:"user",content:ve,images:L,timestamp:new Date};v(nt=>[...nt,K]),z(!0),I(!0),F({text:"Processing",tokens:0,can_interrupt:!0}),B(!1),setTimeout(()=>y(),100);const de=s||r?.id||sessionStorage.getItem("cursorSessionId"),We=de||`new-session-${Date.now()}`;!de&&!r?.id&&(typeof window<"u"&&sessionStorage.removeItem("pendingSessionId"),S.current={sessionId:null,startedAt:Date.now()}),f?.(We);const Xe=(()=>{try{const nt=a==="cursor"?"cursor-tools-settings":a==="codex"?"codex-settings":"claude-settings",lt=dt.getItem(nt);if(lt)return JSON.parse(lt)}catch(nt){console.error("Error loading tools settings:",nt)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})(),yt=t.fullPath||t.path||"";x(a==="cursor"?{type:"cursor-command",command:oe,sessionId:de,options:{cwd:yt,projectPath:yt,sessionId:de,resume:!!de,model:i,skipPermissions:Xe?.skipPermissions||!1,toolsSettings:Xe}}:a==="codex"?{type:"codex-command",command:oe,sessionId:de,options:{cwd:yt,projectPath:yt,sessionId:de,resume:!!de,model:u,permissionMode:n==="plan"?"default":n}}:{type:"claude-command",command:oe,options:{projectPath:yt,cwd:yt,sessionId:de,resume:!!de,toolsSettings:Xe,permissionMode:n,model:c,images:L}}),$(""),A.current="",Pe(),E([]),j(new Map),V(new Map),M(!1),C("none"),b.current&&(b.current.style.height="auto"),dt.removeItem(`draft_input_${t.name}`)},[R,c,u,s,i,d,f,S,n,a,Pe,y,t,r?.id,x,I,v,F,z,B,G]);l.useEffect(()=>{W.current=je},[je]),l.useEffect(()=>{A.current=H},[H]),l.useEffect(()=>{if(!t)return;const ie=dt.getItem(`draft_input_${t.name}`)||"";$(ve=>{const oe=ve===ie?ve:ie;return A.current=oe,oe})},[t?.name]),l.useEffect(()=>{t&&(H!==""?dt.setItem(`draft_input_${t.name}`,H):dt.removeItem(`draft_input_${t.name}`))},[H,t]),l.useEffect(()=>{if(!b.current)return;b.current.style.height="auto",b.current.style.height=`${b.current.scrollHeight}px`;const ie=parseInt(window.getComputedStyle(b.current).lineHeight),ve=b.current.scrollHeight>ie*2;M(ve)},[H]),l.useEffect(()=>{!b.current||H.trim()||(b.current.style.height="auto",M(!1))},[H]);const $e=l.useCallback(ie=>{const ve=ie.target.value,oe=ie.target.selectionStart;if($(ve),A.current=ve,se(oe),!ve.trim()){ie.target.style.height="auto",M(!1),Pe();return}be(ve,oe)},[be,Pe,se]),ze=l.useCallback(ie=>{if(!Ae(ie)&&!ke(ie)){if(ie.key==="Tab"&&!Re&&!fe){ie.preventDefault(),o();return}if(ie.key==="Enter"){if(ie.nativeEvent.isComposing)return;((ie.ctrlKey||ie.metaKey)&&!ie.shiftKey||!ie.shiftKey&&!ie.ctrlKey&&!ie.metaKey&&!h)&&(ie.preventDefault(),je(ie))}}},[o,Ae,ke,je,h,fe,Re]),Fe=l.useCallback(ie=>{se(ie.currentTarget.selectionStart)},[se]),re=l.useCallback(ie=>{const ve=ie.currentTarget;ve.style.height="auto",ve.style.height=`${ve.scrollHeight}px`,se(ve.selectionStart),Ne(ve);const oe=parseInt(window.getComputedStyle(ve).lineHeight);M(ve.scrollHeight>oe*2)},[se,Ne]),ce=l.useCallback(()=>{$(""),A.current="",Pe(),b.current&&(b.current.style.height="auto",b.current.focus()),M(!1)},[Pe]),Le=l.useCallback(()=>{if(!m)return;const ie=typeof window<"u"?sessionStorage.getItem("pendingSessionId"):null,ve=typeof window<"u"?sessionStorage.getItem("cursorSessionId"):null,ye=[s,S.current?.sessionId||null,ie,a==="cursor"?ve:null,r?.id||null].find(L=>!!L&&!sp(L))||null;if(!ye){console.warn("Abort requested but no concrete session ID is available yet.");return}x({type:"abort-session",sessionId:ye,provider:a})},[m,s,S,a,r?.id,x]),Oe=l.useCallback(ie=>{ie.trim()&&$(ve=>{const oe=ve.trim()?`${ve} ${ie}`:ie;return A.current=oe,setTimeout(()=>{if(!b.current)return;b.current.style.height="auto",b.current.style.height=`${b.current.scrollHeight}px`;const ye=parseInt(window.getComputedStyle(b.current).lineHeight);M(b.current.scrollHeight>ye*2)},0),oe})},[]),st=l.useCallback(ie=>!ie||a!=="claude"?{success:!1}:bd(ie.entry),[a]),kt=l.useCallback((ie,ve)=>{const ye=(Array.isArray(ie)?ie:[ie]).filter(Boolean);ye.length!==0&&(ye.forEach(L=>{x({type:"claude-permission-response",requestId:L,allow:!!ve?.allow,updatedInput:ve?.updatedInput,message:ve?.message,rememberEntry:ve?.rememberEntry})}),D(L=>{const K=L.filter(de=>!ye.includes(de.requestId));return K.length===0&&F(null),K}))},[x,F,D]),[bt,Nt]=l.useState(!1),it=l.useCallback(ie=>{Nt(ie),g?.(ie)},[g]);return{input:H,setInput:$,textareaRef:b,inputHighlightRef:N,isTextareaExpanded:ee,thinkingMode:G,setThinkingMode:C,slashCommandsCount:J,filteredCommands:Q,frequentCommands:le,commandQuery:ae,showCommandMenu:fe,selectedCommandIndex:Ee,resetCommandMenuState:Pe,handleCommandSelect:He,handleToggleCommandMenu:Te,showFileDropdown:Re,filteredFiles:X,selectedFileIndex:Ce,renderInputWithMentions:xe,selectFile:te,attachedImages:R,setAttachedImages:E,uploadingImages:U,imageErrors:_,getRootProps:Be,getInputProps:rt,isDragActive:ue,openImagePicker:De,handleSubmit:je,handleInputChange:$e,handleKeyDown:ze,handlePaste:Ke,handleTextareaClick:Fe,handleTextareaInput:re,syncInputOverlayScroll:Ne,handleClearInput:ce,handleAbortSession:Le,handleTranscript:Oe,handlePermissionDecision:kt,handleGrantToolPermission:st,handleInputFocusChange:it,isInputFocused:bt}}function np({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,latestMessage:n,onFileOpen:o,onInputFocusChange:i,onSessionActive:c,onSessionInactive:u,onSessionProcessing:d,onSessionNotProcessing:m,processingSessions:p,onReplaceTemporarySession:x,onNavigateToSession:h,onShowSettings:f,autoExpandTools:g,showRawParameters:k,showThinking:w,autoScrollToBottom:S,sendByCtrlEnter:y,externalMessageUpdate:v,onShowAllTasks:T}){const{tasksEnabled:z,isTaskMasterInstalled:I}=Or(),{t:F}=Ue("chat"),B=l.useRef(""),D=l.useRef(null),H=l.useRef(null),$=l.useCallback(()=>{D.current&&(clearTimeout(D.current),D.current=null),B.current=""},[]),{provider:R,setProvider:E,cursorModel:U,setCursorModel:j,claudeModel:_,setClaudeModel:V,codexModel:ee,setCodexModel:M,permissionMode:G,pendingPermissionRequests:C,setPendingPermissionRequests:b,cyclePermissionMode:N}=au({selectedSession:r}),{chatMessages:W,setChatMessages:A,isLoading:O,setIsLoading:q,currentSessionId:Z,setCurrentSessionId:J,sessionMessages:Q,setSessionMessages:le,isLoadingSessionMessages:ae,isLoadingMoreMessages:fe,hasMoreMessages:Ee,totalMessages:Pe,setIsSystemSessionChange:He,canAbortSession:Te,setCanAbortSession:be,isUserScrolledUp:Ae,setIsUserScrolledUp:Re,tokenBudget:X,setTokenBudget:Ce,visibleMessageCount:xe,visibleMessages:te,loadEarlierMessages:se,loadAllMessages:ke,allMessagesLoaded:Ne,isLoadingAllMessages:Ie,loadAllJustFinished:Ke,showLoadAllOverlay:Be,claudeStatus:rt,setClaudeStatus:ue,createDiff:De,scrollContainerRef:je,scrollToBottom:$e,scrollToBottomAndReset:ze,handleScroll:Fe}=uu({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:S,externalMessageUpdate:v,processingSessions:p,resetStreamingState:$,pendingViewSessionRef:H}),{input:re,setInput:ce,textareaRef:Le,inputHighlightRef:Oe,isTextareaExpanded:st,thinkingMode:kt,setThinkingMode:bt,slashCommandsCount:Nt,filteredCommands:it,frequentCommands:ie,commandQuery:ve,showCommandMenu:oe,selectedCommandIndex:ye,resetCommandMenuState:L,handleCommandSelect:K,handleToggleCommandMenu:de,showFileDropdown:We,filteredFiles:ot,selectedFileIndex:Xe,renderInputWithMentions:yt,selectFile:nt,attachedImages:lt,setAttachedImages:Qt,uploadingImages:kr,imageErrors:Ss,getRootProps:Es,getInputProps:jr,isDragActive:ir,openImagePicker:Wr,handleSubmit:Ts,handleInputChange:Is,handleKeyDown:Ds,handlePaste:Ur,handleTextareaClick:Hr,handleTextareaInput:Gr,syncInputOverlayScroll:As,handleClearInput:Ms,handleAbortSession:wr,handleTranscript:Ps,handlePermissionDecision:Fs,handleGrantToolPermission:Rt,handleInputFocusChange:qr,isInputFocused:$s}=ap({selectedProject:t,selectedSession:r,currentSessionId:Z,provider:R,permissionMode:G,cyclePermissionMode:N,cursorModel:U,claudeModel:_,codexModel:ee,isLoading:O,canAbortSession:Te,tokenBudget:X,sendMessage:a,sendByCtrlEnter:y,onSessionActive:c,onInputFocusChange:i,onFileOpen:o,onShowSettings:f,pendingViewSessionRef:H,scrollToBottom:$e,setChatMessages:A,setSessionMessages:le,setIsLoading:q,setCanAbortSession:be,setClaudeStatus:ue,setIsUserScrolledUp:Re,setPendingPermissionRequests:b});if(pu({latestMessage:n,provider:R,selectedProject:t,selectedSession:r,currentSessionId:Z,setCurrentSessionId:J,setChatMessages:A,setIsLoading:q,setCanAbortSession:be,setClaudeStatus:ue,setTokenBudget:Ce,setIsSystemSessionChange:He,setPendingPermissionRequests:b,pendingViewSessionRef:H,streamBufferRef:B,streamTimerRef:D,onSessionInactive:u,onSessionProcessing:d,onSessionNotProcessing:m,onReplaceTemporarySession:x,onNavigateToSession:h}),l.useEffect(()=>{if(!O||!Te)return;const xt=zt=>{zt.key!=="Escape"||zt.repeat||zt.defaultPrevented||(zt.preventDefault(),wr())};return document.addEventListener("keydown",xt,{capture:!0}),()=>{document.removeEventListener("keydown",xt,{capture:!0})}},[Te,wr,O]),l.useEffect(()=>{const xt=r?.id||Z;xt&&O&&d&&d(xt)},[Z,O,d,r?.id]),l.useEffect(()=>()=>{$()},[$]),!t){const xt=F(R==="cursor"?"messageTypes.cursor":R==="codex"?"messageTypes.codex":"messageTypes.claude");return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:F("projectSelection.startChatWithProvider",{provider:xt,defaultValue:"Select a project to start chatting with {{provider}}"})})})})}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(qd,{scrollContainerRef:je,onWheel:Fe,onTouchMove:Fe,isLoadingSessionMessages:ae,chatMessages:W,selectedSession:r,currentSessionId:Z,provider:R,setProvider:xt=>E(xt),textareaRef:Le,claudeModel:_,setClaudeModel:V,cursorModel:U,setCursorModel:j,codexModel:ee,setCodexModel:M,tasksEnabled:z,isTaskMasterInstalled:I,onShowAllTasks:T,setInput:ce,isLoadingMoreMessages:fe,hasMoreMessages:Ee,totalMessages:Pe,sessionMessagesCount:Q.length,visibleMessageCount:xe,visibleMessages:te,loadEarlierMessages:se,loadAllMessages:ke,allMessagesLoaded:Ne,isLoadingAllMessages:Ie,loadAllJustFinished:Ke,showLoadAllOverlay:Be,createDiff:De,onFileOpen:o,onShowSettings:f,onGrantToolPermission:Rt,autoExpandTools:g,showRawParameters:k,showThinking:w,selectedProject:t,isLoading:O}),e.jsx(su,{pendingPermissionRequests:C,handlePermissionDecision:Fs,handleGrantToolPermission:Rt,claudeStatus:rt,isLoading:O,onAbortSession:wr,provider:R,permissionMode:G,onModeSwitch:N,thinkingMode:kt,setThinkingMode:bt,tokenBudget:X,slashCommandsCount:Nt,onToggleCommandMenu:de,hasInput:!!re.trim(),onClearInput:Ms,isUserScrolledUp:Ae,hasMessages:W.length>0,onScrollToBottom:ze,onSubmit:Ts,isDragActive:ir,attachedImages:lt,onRemoveImage:xt=>Qt(zt=>zt.filter((La,Xt)=>Xt!==xt)),uploadingImages:kr,imageErrors:Ss,showFileDropdown:We,filteredFiles:ot,selectedFileIndex:Xe,onSelectFile:nt,filteredCommands:it,selectedCommandIndex:ye,onCommandSelect:K,onCloseCommandMenu:L,isCommandMenuOpen:oe,frequentCommands:ve?[]:ie,getRootProps:Es,getInputProps:jr,openImagePicker:Wr,inputHighlightRef:Oe,renderInputWithMentions:yt,textareaRef:Le,input:re,onInputChange:Is,onTextareaClick:Hr,onTextareaKeyDown:Ds,onTextareaPaste:Ur,onTextareaScrollSync:As,onTextareaInput:Gr,onInputFocusChange:qr,isInputFocused:$s,placeholder:F("input.placeholder",{provider:F(R==="cursor"?"messageTypes.cursor":R==="codex"?"messageTypes.codex":"messageTypes.claude")}),isTextareaExpanded:st,sendByCtrlEnter:y,onTranscript:Ps})]}),e.jsx(pd,{})]})}const op=Et.memo(np);function ip({file:t,onClose:r}){const s=`/api/projects/${t.projectName}/files/content?path=${encodeURIComponent(t.path)}`,[a,n]=l.useState(null),[o,i]=l.useState(null),[c,u]=l.useState(!0);return l.useEffect(()=>{let d;const m=new AbortController;return(async()=>{try{u(!0),i(null),n(null);const x=await we(s,{signal:m.signal});if(!x.ok)throw new Error(`Request failed with status ${x.status}`);const h=await x.blob();d=URL.createObjectURL(h),n(d)}catch(x){if(x.name==="AbortError")return;console.error("Error loading image:",x),i("Unable to load image")}finally{u(!1)}})(),()=>{m.abort(),d&&URL.revokeObjectURL(d)}},[s]),e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-4xl max-h-[90vh] w-full mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t.name}),e.jsx(me,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:e.jsx(qe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"p-4 flex justify-center items-center bg-gray-50 dark:bg-gray-900 min-h-[400px]",children:[c&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"Loading image…"})}),!c&&a&&e.jsx("img",{src:a,alt:t.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!c&&!a&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:o||"Unable to load image"}),e.jsx("p",{className:"text-sm mt-2 break-all",children:t.path})]})]}),e.jsx("div",{className:"p-4 border-t bg-gray-50 dark:bg-gray-800",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:t.path})})]})})}const lp="w-4 h-4 flex-shrink-0",_n={js:{icon:Sr,color:"text-yellow-500"},jsx:{icon:Sr,color:"text-yellow-500"},mjs:{icon:Sr,color:"text-yellow-500"},cjs:{icon:Sr,color:"text-yellow-500"},ts:{icon:Er,color:"text-blue-500"},tsx:{icon:Er,color:"text-blue-500"},mts:{icon:Er,color:"text-blue-500"},py:{icon:os,color:"text-emerald-500"},pyw:{icon:os,color:"text-emerald-500"},pyi:{icon:os,color:"text-emerald-400"},ipynb:{icon:$i,color:"text-orange-500"},rs:{icon:Mr,color:"text-orange-600"},toml:{icon:Ve,color:"text-gray-500"},go:{icon:Ar,color:"text-cyan-500"},rb:{icon:ra,color:"text-red-500"},erb:{icon:ra,color:"text-red-400"},php:{icon:Fi,color:"text-violet-500"},java:{icon:Ua,color:"text-red-600"},jar:{icon:Ua,color:"text-red-500"},kt:{icon:Ar,color:"text-violet-500"},kts:{icon:Ar,color:"text-violet-400"},c:{icon:Tr,color:"text-blue-600"},h:{icon:Tr,color:"text-blue-400"},cpp:{icon:Tr,color:"text-blue-700"},hpp:{icon:Tr,color:"text-blue-500"},cc:{icon:Tr,color:"text-blue-700"},cs:{icon:Ar,color:"text-purple-600"},swift:{icon:ta,color:"text-orange-500"},lua:{icon:Pi,color:"text-blue-500"},r:{icon:Mi,color:"text-blue-600"},html:{icon:Rr,color:"text-orange-600"},htm:{icon:Rr,color:"text-orange-600"},css:{icon:pr,color:"text-blue-500"},scss:{icon:pr,color:"text-pink-500"},sass:{icon:pr,color:"text-pink-400"},less:{icon:pr,color:"text-indigo-500"},vue:{icon:Er,color:"text-emerald-500"},svelte:{icon:Er,color:"text-orange-500"},json:{icon:gr,color:"text-yellow-600"},jsonc:{icon:gr,color:"text-yellow-500"},json5:{icon:gr,color:"text-yellow-500"},yaml:{icon:Ve,color:"text-purple-400"},yml:{icon:Ve,color:"text-purple-400"},xml:{icon:Sr,color:"text-orange-500"},csv:{icon:Wa,color:"text-green-600"},tsv:{icon:Wa,color:"text-green-500"},sql:{icon:Ai,color:"text-blue-500"},graphql:{icon:Ba,color:"text-pink-500"},gql:{icon:Ba,color:"text-pink-500"},proto:{icon:Pr,color:"text-green-500"},env:{icon:Tt,color:"text-yellow-600"},md:{icon:ea,color:"text-blue-500"},mdx:{icon:ea,color:"text-blue-400"},txt:{icon:et,color:"text-gray-500"},doc:{icon:et,color:"text-blue-600"},docx:{icon:et,color:"text-blue-600"},pdf:{icon:Zs,color:"text-red-600"},rtf:{icon:et,color:"text-gray-500"},tex:{icon:Xs,color:"text-teal-600"},rst:{icon:et,color:"text-gray-400"},sh:{icon:at,color:"text-green-500"},bash:{icon:at,color:"text-green-500"},zsh:{icon:at,color:"text-green-400"},fish:{icon:at,color:"text-green-400"},ps1:{icon:at,color:"text-blue-400"},bat:{icon:at,color:"text-gray-500"},cmd:{icon:at,color:"text-gray-500"},png:{icon:Bt,color:"text-purple-500"},jpg:{icon:Bt,color:"text-purple-500"},jpeg:{icon:Bt,color:"text-purple-500"},gif:{icon:Bt,color:"text-purple-400"},webp:{icon:Bt,color:"text-purple-400"},ico:{icon:Bt,color:"text-purple-400"},bmp:{icon:Bt,color:"text-purple-400"},tiff:{icon:Bt,color:"text-purple-400"},svg:{icon:Di,color:"text-amber-500"},mp3:{icon:dr,color:"text-pink-500"},wav:{icon:dr,color:"text-pink-500"},ogg:{icon:dr,color:"text-pink-400"},flac:{icon:dr,color:"text-pink-400"},aac:{icon:dr,color:"text-pink-400"},m4a:{icon:dr,color:"text-pink-400"},mp4:{icon:Cr,color:"text-rose-500"},mov:{icon:Cr,color:"text-rose-500"},avi:{icon:Cr,color:"text-rose-500"},webm:{icon:Cr,color:"text-rose-400"},mkv:{icon:Cr,color:"text-rose-400"},ttf:{icon:Nr,color:"text-red-500"},otf:{icon:Nr,color:"text-red-500"},woff:{icon:Nr,color:"text-red-400"},woff2:{icon:Nr,color:"text-red-400"},eot:{icon:Nr,color:"text-red-400"},zip:{icon:cr,color:"text-amber-600"},tar:{icon:cr,color:"text-amber-600"},gz:{icon:cr,color:"text-amber-600"},bz2:{icon:cr,color:"text-amber-600"},rar:{icon:cr,color:"text-amber-500"},"7z":{icon:cr,color:"text-amber-500"},lock:{icon:Gt,color:"text-gray-500"},exe:{icon:lr,color:"text-gray-500"},bin:{icon:lr,color:"text-gray-500"},dll:{icon:lr,color:"text-gray-400"},so:{icon:lr,color:"text-gray-400"},dylib:{icon:lr,color:"text-gray-400"},wasm:{icon:lr,color:"text-purple-500"},ini:{icon:Ve,color:"text-gray-500"},cfg:{icon:Ve,color:"text-gray-500"},conf:{icon:Ve,color:"text-gray-500"},log:{icon:Xs,color:"text-gray-400"},map:{icon:so,color:"text-gray-400"}},Rn={Dockerfile:{icon:Pr,color:"text-blue-500"},"docker-compose.yml":{icon:Pr,color:"text-blue-500"},"docker-compose.yaml":{icon:Pr,color:"text-blue-500"},".dockerignore":{icon:Pr,color:"text-gray-500"},".gitignore":{icon:Ve,color:"text-gray-500"},".gitmodules":{icon:Ve,color:"text-gray-500"},".gitattributes":{icon:Ve,color:"text-gray-500"},".editorconfig":{icon:Ve,color:"text-gray-500"},".prettierrc":{icon:Ve,color:"text-pink-400"},".prettierignore":{icon:Ve,color:"text-gray-500"},".eslintrc":{icon:Ve,color:"text-violet-500"},".eslintrc.js":{icon:Ve,color:"text-violet-500"},".eslintrc.json":{icon:Ve,color:"text-violet-500"},".eslintrc.cjs":{icon:Ve,color:"text-violet-500"},"eslint.config.js":{icon:Ve,color:"text-violet-500"},"eslint.config.mjs":{icon:Ve,color:"text-violet-500"},".env":{icon:Tt,color:"text-yellow-600"},".env.local":{icon:Tt,color:"text-yellow-600"},".env.development":{icon:Tt,color:"text-yellow-500"},".env.production":{icon:Tt,color:"text-yellow-600"},".env.example":{icon:Tt,color:"text-yellow-400"},"package.json":{icon:gr,color:"text-green-500"},"package-lock.json":{icon:Gt,color:"text-gray-500"},"yarn.lock":{icon:Gt,color:"text-blue-400"},"pnpm-lock.yaml":{icon:Gt,color:"text-orange-400"},"bun.lockb":{icon:Gt,color:"text-gray-400"},"Cargo.toml":{icon:Mr,color:"text-orange-600"},"Cargo.lock":{icon:Gt,color:"text-orange-400"},Gemfile:{icon:ra,color:"text-red-500"},"Gemfile.lock":{icon:Gt,color:"text-red-400"},Makefile:{icon:at,color:"text-gray-500"},"CMakeLists.txt":{icon:Mr,color:"text-blue-500"},"tsconfig.json":{icon:gr,color:"text-blue-500"},"jsconfig.json":{icon:gr,color:"text-yellow-500"},"vite.config.ts":{icon:ta,color:"text-purple-500"},"vite.config.js":{icon:ta,color:"text-purple-500"},"webpack.config.js":{icon:Mr,color:"text-blue-500"},"tailwind.config.js":{icon:pr,color:"text-cyan-500"},"tailwind.config.ts":{icon:pr,color:"text-cyan-500"},"postcss.config.js":{icon:Mr,color:"text-red-400"},"babel.config.js":{icon:Ve,color:"text-yellow-500"},".babelrc":{icon:Ve,color:"text-yellow-500"},"README.md":{icon:ea,color:"text-blue-500"},LICENSE:{icon:Zs,color:"text-gray-500"},"LICENSE.md":{icon:Zs,color:"text-gray-500"},"CHANGELOG.md":{icon:Xs,color:"text-blue-400"},"requirements.txt":{icon:et,color:"text-emerald-400"},"go.mod":{icon:Ar,color:"text-cyan-500"},"go.sum":{icon:Gt,color:"text-cyan-400"}};function cp(t){if(Rn[t])return Rn[t];if(t.startsWith(".env"))return{icon:Tt,color:"text-yellow-600"};const r=t.split(".").pop()?.toLowerCase();return r&&_n[r]?_n[r]:{icon:so,color:"text-muted-foreground"}}function dp({selectedProject:t,onFileOpen:r}){const{t:s}=Ue(),[a,n]=l.useState([]),[o,i]=l.useState(!1),[c,u]=l.useState(new Set),[d,m]=l.useState(null),[p,x]=l.useState("detailed"),[h,f]=l.useState(""),[g,k]=l.useState([]);l.useEffect(()=>{t&&S()},[t]),l.useEffect(()=>{const E=localStorage.getItem("file-tree-view-mode");E&&["simple","detailed","compact"].includes(E)&&x(E)},[]),l.useEffect(()=>{if(!h.trim())k(a);else{const E=w(a,h.toLowerCase());k(E);const U=j=>{j.forEach(_=>{_.type==="directory"&&_.children&&_.children.length>0&&(u(V=>new Set(V.add(_.path))),U(_.children))})};U(E)}},[a,h]);const w=(E,U)=>E.reduce((j,_)=>{const V=_.name.toLowerCase().includes(U);let ee=[];return _.type==="directory"&&_.children&&(ee=w(_.children,U)),(V||ee.length>0)&&j.push({..._,children:ee}),j},[]),S=async()=>{i(!0);try{const E=await Ge.getFiles(t.name);if(!E.ok){const j=await E.text();console.error("❌ File fetch failed:",E.status,j),n([]);return}const U=await E.json();n(U)}catch(E){console.error("❌ Error fetching files:",E),n([])}finally{i(!1)}},y=E=>{const U=new Set(c);U.has(E)?U.delete(E):U.add(E),u(U)},v=E=>{x(E),localStorage.setItem("file-tree-view-mode",E)},T=E=>{if(!E||E===0)return"0 B";const U=1024,j=["B","KB","MB","GB"],_=Math.floor(Math.log(E)/Math.log(U));return parseFloat((E/Math.pow(U,_)).toFixed(1))+" "+j[_]},z=E=>{if(!E)return"-";const U=new Date,j=new Date(E),_=Math.floor((U-j)/1e3);return _<60?s("fileTree.justNow"):_<3600?s("fileTree.minAgo",{count:Math.floor(_/60)}):_<86400?s("fileTree.hoursAgo",{count:Math.floor(_/3600)}):_<2592e3?s("fileTree.daysAgo",{count:Math.floor(_/86400)}):j.toLocaleDateString()},I=E=>{const U=E.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","svg","webp","ico","bmp"].includes(U)},F=E=>{const{icon:U,color:j}=cp(E);return e.jsx(U,{className:he(lp,j)})},B=E=>{E.type==="directory"?y(E.path):I(E.name)?m({name:E.name,path:E.path,projectPath:t.path,projectName:t.name}):r&&r(E.path)},D=E=>{const U=E.type==="directory",j=c.has(E.path);return U?e.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(At,{className:he("w-3.5 h-3.5 text-muted-foreground/70 transition-transform duration-150",j&&"rotate-90")}),j?e.jsx(Kt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(Vt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"})]}):e.jsx("span",{className:"flex items-center flex-shrink-0 ml-[18px]",children:F(E.name)})},H=(E,U=0)=>E.map(j=>{const _=j.type==="directory",V=_&&c.has(j.path);return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{className:he("group flex items-center gap-1.5 py-[3px] pr-2 cursor-pointer rounded-sm","hover:bg-accent/60 transition-colors duration-100",_&&V&&"border-l-2 border-primary/30",_&&!V&&"border-l-2 border-transparent",!_&&"border-l-2 border-transparent"),style:{paddingLeft:`${U*16+4}px`},onClick:()=>B(j),children:[D(j),e.jsx("span",{className:he("text-[13px] leading-tight truncate",_?"font-medium text-foreground":"text-foreground/90"),children:j.name})]}),_&&V&&j.children&&j.children.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute top-0 bottom-0 border-l border-border/40",style:{left:`${U*16+14}px`},"aria-hidden":"true"}),H(j.children,U+1)]})]},j.path)}),$=(E,U=0)=>E.map(j=>{const _=j.type==="directory",V=_&&c.has(j.path);return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{className:he("group grid grid-cols-12 gap-2 py-[3px] pr-2 hover:bg-accent/60 cursor-pointer items-center rounded-sm transition-colors duration-100",_&&V&&"border-l-2 border-primary/30",_&&!V&&"border-l-2 border-transparent",!_&&"border-l-2 border-transparent"),style:{paddingLeft:`${U*16+4}px`},onClick:()=>B(j),children:[e.jsxs("div",{className:"col-span-5 flex items-center gap-1.5 min-w-0",children:[D(j),e.jsx("span",{className:he("text-[13px] leading-tight truncate",_?"font-medium text-foreground":"text-foreground/90"),children:j.name})]}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground tabular-nums",children:j.type==="file"?T(j.size):""}),e.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:z(j.modified)}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground font-mono",children:j.permissionsRwx||""})]}),_&&V&&j.children&&e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute top-0 bottom-0 border-l border-border/40",style:{left:`${U*16+14}px`},"aria-hidden":"true"}),$(j.children,U+1)]})]},j.path)}),R=(E,U=0)=>E.map(j=>{const _=j.type==="directory",V=_&&c.has(j.path);return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{className:he("group flex items-center justify-between py-[3px] pr-2 hover:bg-accent/60 cursor-pointer rounded-sm transition-colors duration-100",_&&V&&"border-l-2 border-primary/30",_&&!V&&"border-l-2 border-transparent",!_&&"border-l-2 border-transparent"),style:{paddingLeft:`${U*16+4}px`},onClick:()=>B(j),children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[D(j),e.jsx("span",{className:he("text-[13px] leading-tight truncate",_?"font-medium text-foreground":"text-foreground/90"),children:j.name})]}),e.jsx("div",{className:"flex items-center gap-3 text-sm text-muted-foreground flex-shrink-0 ml-2",children:j.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tabular-nums",children:T(j.size)}),e.jsx("span",{className:"font-mono",children:j.permissionsRwx})]})})]}),_&&V&&j.children&&e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute top-0 bottom-0 border-l border-border/40",style:{left:`${U*16+14}px`},"aria-hidden":"true"}),R(j.children,U+1)]})]},j.path)});return o?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("div",{className:"text-muted-foreground text-sm",children:s("fileTree.loading")})}):e.jsxs("div",{className:"h-full flex flex-col bg-background",children:[e.jsxs("div",{className:"px-3 pt-3 pb-2 border-b border-border space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:s("fileTree.files")}),e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx(me,{variant:p==="simple"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>v("simple"),title:s("fileTree.simpleView"),children:e.jsx(ls,{className:"w-3.5 h-3.5"})}),e.jsx(me,{variant:p==="compact"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>v("compact"),title:s("fileTree.compactView"),children:e.jsx(ar,{className:"w-3.5 h-3.5"})}),e.jsx(me,{variant:p==="detailed"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>v("detailed"),title:s("fileTree.detailedView"),children:e.jsx(Ii,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(sr,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),e.jsx(Qe,{type:"text",placeholder:s("fileTree.searchPlaceholder"),value:h,onChange:E=>f(E.target.value),className:"pl-8 pr-8 h-8 text-sm"}),h&&e.jsx(me,{variant:"ghost",size:"sm",className:"absolute right-0.5 top-1/2 transform -translate-y-1/2 h-5 w-5 p-0 hover:bg-accent",onClick:()=>f(""),title:s("fileTree.clearSearch"),children:e.jsx(qe,{className:"w-3 h-3"})})]})]}),p==="detailed"&&g.length>0&&e.jsx("div",{className:"px-3 pt-1.5 pb-1 border-b border-border",children:e.jsxs("div",{className:"grid grid-cols-12 gap-2 px-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:[e.jsx("div",{className:"col-span-5",children:s("fileTree.name")}),e.jsx("div",{className:"col-span-2",children:s("fileTree.size")}),e.jsx("div",{className:"col-span-3",children:s("fileTree.modified")}),e.jsx("div",{className:"col-span-2",children:s("fileTree.permissions")})]})}),e.jsx(Aa,{className:"flex-1 px-2 py-1",children:a.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(Vt,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:s("fileTree.noFilesFound")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("fileTree.checkProjectPath")})]}):g.length===0&&h?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(sr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:s("fileTree.noMatchesFound")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("fileTree.tryDifferentSearch")})]}):e.jsxs("div",{children:[p==="simple"&&H(g),p==="compact"&&R(g),p==="detailed"&&$(g)]})}),d&&e.jsx(ip,{file:d,onClose:()=>m(null)})]})}function zn({diff:t,fileName:r,isMobile:s,wrapText:a}){if(!t)return e.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No diff available"});const n=(o,i)=>{const c=o.startsWith("+")&&!o.startsWith("+++"),u=o.startsWith("-")&&!o.startsWith("---"),d=o.startsWith("@@");return e.jsx("div",{className:`font-mono text-xs px-3 py-0.5 ${s&&a?"whitespace-pre-wrap break-all":"whitespace-pre overflow-x-auto"} ${c?"bg-green-50 dark:bg-green-950/50 text-green-700 dark:text-green-300":u?"bg-red-50 dark:bg-red-950/50 text-red-700 dark:text-red-300":d?"bg-primary/5 text-primary":"text-muted-foreground/70"}`,children:o},i)};return e.jsx("div",{className:"diff-viewer",children:t.split(`
141
- `).map((o,i)=>n(o,i))})}function up({selectedProject:t,isMobile:r,onFileOpen:s}){const[a,n]=l.useState(null),[o,i]=l.useState({}),[c,u]=l.useState(!1),[d,m]=l.useState(""),[p,x]=l.useState(new Set),[h,f]=l.useState(new Set),[g,k]=l.useState(!1),[w,S]=l.useState(""),[y,v]=l.useState([]),[T,z]=l.useState(!0),[I,F]=l.useState(!1),[B,D]=l.useState(!1),[H,$]=l.useState(!1),[R,E]=l.useState(""),[U,j]=l.useState(!1),[_,V]=l.useState("changes"),[ee,M]=l.useState([]),[G,C]=l.useState(new Set),[b,N]=l.useState({}),[W,A]=l.useState(!1),[O,q]=l.useState(null),[Z,J]=l.useState(!1),[Q,le]=l.useState(!1),[ae,fe]=l.useState(!1),[Ee,Pe]=l.useState(!1),[He,Te]=l.useState(r),[be,Ae]=l.useState(null),[Re,X]=l.useState(!1),Ce=l.useRef(null),xe=l.useRef(null),[te,se]=l.useState(()=>localStorage.getItem("selected-provider")||"claude");l.useEffect(()=>{const L=()=>{const K=localStorage.getItem("selected-provider")||"claude";se(K)};return window.addEventListener("storage",L),()=>window.removeEventListener("storage",L)},[]),l.useEffect(()=>{S(""),v([]),n(null),q(null),f(new Set),t&&(ke(),Ne(),Ie())},[t]),l.useEffect(()=>{!t||_!=="history"||Le()},[t,_]),l.useEffect(()=>{const L=K=>{xe.current&&!xe.current.contains(K.target)&&D(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[]);const ke=async()=>{if(t){u(!0);try{const K=await(await we(`/api/git/status?project=${encodeURIComponent(t.name)}`)).json();if(K.error)console.error("Git status error:",K.error),n({error:K.error,details:K.details}),S(""),f(new Set);else{n(K),S(K.branch||"main");const de=new Set([...K.modified||[],...K.added||[],...K.deleted||[],...K.untracked||[]]);f(de);for(const We of K.modified||[])re(We);for(const We of K.added||[])re(We);for(const We of K.deleted||[])re(We);for(const We of K.untracked||[])re(We)}}catch(L){console.error("Error fetching git status:",L),n({error:"Git operation failed",details:String(L)}),S(""),f(new Set)}finally{u(!1)}}},Ne=async()=>{try{const K=await(await we(`/api/git/branches?project=${encodeURIComponent(t.name)}`)).json();!K.error&&K.branches?v(K.branches):v([])}catch(L){console.error("Error fetching branches:",L),v([])}},Ie=async()=>{if(t)try{const K=await(await we(`/api/git/remote-status?project=${encodeURIComponent(t.name)}`)).json();K.error?q(null):q(K)}catch(L){console.error("Error fetching remote status:",L),q(null)}},Ke=async L=>{try{const de=await(await we("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,branch:L})})).json();de.success?(S(L),D(!1),ke()):console.error("Failed to switch branch:",de.error)}catch(K){console.error("Error switching branch:",K)}},Be=async()=>{if(R.trim()){j(!0);try{const K=await(await we("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,branch:R.trim()})})).json();K.success?(S(R.trim()),$(!1),D(!1),E(""),Ne(),ke()):console.error("Failed to create branch:",K.error)}catch(L){console.error("Error creating branch:",L)}finally{j(!1)}}},rt=async()=>{J(!0);try{const K=await(await we("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();K.success?(ke(),Ie()):console.error("Fetch failed:",K.error)}catch(L){console.error("Error fetching from remote:",L)}finally{J(!1)}},ue=async()=>{le(!0);try{const K=await(await we("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();K.success?(ke(),Ie()):console.error("Pull failed:",K.error)}catch(L){console.error("Error pulling from remote:",L)}finally{le(!1)}},De=async()=>{fe(!0);try{const K=await(await we("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();K.success?(ke(),Ie()):console.error("Push failed:",K.error)}catch(L){console.error("Error pushing to remote:",L)}finally{fe(!1)}},je=async()=>{Pe(!0);try{const K=await(await we("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,branch:w})})).json();K.success?(ke(),Ie()):console.error("Publish failed:",K.error)}catch(L){console.error("Error publishing branch:",L)}finally{Pe(!1)}},$e=async L=>{try{const de=await(await we("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,file:L})})).json();de.success?(f(We=>{const ot=new Set(We);return ot.delete(L),ot}),ke()):console.error("Discard failed:",de.error)}catch(K){console.error("Error discarding changes:",K)}},ze=async L=>{try{const de=await(await we("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,file:L})})).json();de.success?(f(We=>{const ot=new Set(We);return ot.delete(L),ot}),ke()):console.error("Delete failed:",de.error)}catch(K){console.error("Error deleting untracked file:",K)}},Fe=async()=>{if(!be)return;const{type:L,file:K,message:de}=be;Ae(null);try{switch(L){case"discard":await $e(K);break;case"delete":await ze(K);break;case"commit":await it();break;case"pull":await ue();break;case"push":await De();break;case"publish":await je();break}}catch(We){console.error(`Error executing ${L}:`,We)}},re=async L=>{try{const de=await(await we(`/api/git/diff?project=${encodeURIComponent(t.name)}&file=${encodeURIComponent(L)}`)).json();!de.error&&de.diff&&i(We=>({...We,[L]:de.diff}))}catch(K){console.error("Error fetching file diff:",K)}},ce=async L=>{if(s)try{const de=await(await we(`/api/git/file-with-diff?project=${encodeURIComponent(t.name)}&file=${encodeURIComponent(L)}`)).json();if(de.error){console.error("Error fetching file with diff:",de.error),s(L);return}const We={old_string:de.oldContent||"",new_string:de.currentContent||""};s(L,We)}catch(K){console.error("Error opening file:",K),s(L)}},Le=async()=>{try{const K=await(await we(`/api/git/commits?project=${encodeURIComponent(t.name)}&limit=10`)).json();!K.error&&K.commits&&M(K.commits)}catch(L){console.error("Error fetching commits:",L)}},Oe=async L=>{try{const de=await(await we(`/api/git/commit-diff?project=${encodeURIComponent(t.name)}&commit=${L}`)).json();!de.error&&de.diff&&N(We=>({...We,[L]:de.diff}))}catch(K){console.error("Error fetching commit diff:",K)}},st=async()=>{A(!0);try{const K=await(await we("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,files:Array.from(h),provider:te})})).json();K.message?m(K.message):console.error("Failed to generate commit message:",K.error)}catch(L){console.error("Error generating commit message:",L)}finally{A(!1)}},kt=L=>{x(K=>{const de=new Set(K);return de.has(L)?de.delete(L):de.add(L),de})},bt=L=>{C(K=>{const de=new Set(K);return de.has(L)?de.delete(L):(de.add(L),b[L]||Oe(L)),de})},Nt=L=>{f(K=>{const de=new Set(K);return de.has(L)?de.delete(L):de.add(L),de})},it=async()=>{if(!(!d.trim()||h.size===0)){k(!0);try{const K=await(await we("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,message:d,files:Array.from(h)})})).json();K.success?(m(""),f(new Set),ke(),Ie()):console.error("Commit failed:",K.error)}catch(L){console.error("Error committing changes:",L)}finally{k(!1)}}},ie=async()=>{X(!0);try{const K=await(await we("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();K.success?(ke(),Ie()):(console.error("Initial commit failed:",K.error),alert(K.error||"Failed to create initial commit"))}catch(L){console.error("Error creating initial commit:",L),alert("Failed to create initial commit")}finally{X(!1)}},ve=L=>{switch(L){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return L}},oe=L=>{const K=G.has(L.hash),de=b[L.hash];return e.jsxs("div",{className:"border-b border-border last:border-0",children:[e.jsxs("div",{className:"flex items-start p-3 hover:bg-accent/50 cursor-pointer transition-colors",onClick:()=>bt(L.hash),children:[e.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-accent rounded",children:K?e.jsx(ft,{className:"w-3 h-3"}):e.jsx(At,{className:"w-3 h-3"})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:L.message}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[L.author," • ",L.date]})]}),e.jsx("span",{className:"text-sm font-mono text-muted-foreground/60 flex-shrink-0",children:L.hash.substring(0,7)})]})})]}),K&&de&&e.jsx("div",{className:"bg-muted/50",children:e.jsxs("div",{className:"max-h-96 overflow-y-auto p-2",children:[e.jsx("div",{className:"text-sm font-mono text-muted-foreground mb-2",children:L.stats}),e.jsx(zn,{diff:de,fileName:"commit",isMobile:r,wrapText:T})]})})]},L.hash)},ye=(L,K)=>{const de=p.has(L),We=h.has(L),ot=o[L];return e.jsxs("div",{className:"border-b border-border last:border-0",children:[e.jsxs("div",{className:`flex items-center hover:bg-accent/50 transition-colors ${r?"px-2 py-1.5":"px-3 py-2"}`,children:[e.jsx("input",{type:"checkbox",checked:We,onChange:()=>Nt(L),onClick:Xe=>Xe.stopPropagation(),className:`rounded border-border text-primary focus:ring-primary/40 bg-background checked:bg-primary ${r?"mr-1.5":"mr-2"}`}),e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsx("div",{className:`p-0.5 hover:bg-accent rounded cursor-pointer ${r?"mr-1":"mr-2"}`,onClick:Xe=>{Xe.stopPropagation(),kt(L)},children:e.jsx(At,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${de?"rotate-90":"rotate-0"}`})}),e.jsx("span",{className:`flex-1 truncate ${r?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:Xe=>{Xe.stopPropagation(),ce(L)},title:"Click to open file",children:L}),e.jsxs("div",{className:"flex items-center gap-1",children:[(K==="M"||K==="D")&&e.jsxs("button",{onClick:Xe=>{Xe.stopPropagation(),Ae({type:"discard",file:L,message:`Discard all changes to "${L}"? This action cannot be undone.`})},className:`${r?"px-2 py-1 text-xs":"p-1"} hover:bg-destructive/10 rounded text-destructive font-medium flex items-center gap-1`,title:"Discard changes",children:[e.jsx(ut,{className:"w-3 h-3"}),r&&e.jsx("span",{children:"Discard"})]}),K==="U"&&e.jsxs("button",{onClick:Xe=>{Xe.stopPropagation(),Ae({type:"delete",file:L,message:`Delete untracked file "${L}"? This action cannot be undone.`})},className:`${r?"px-2 py-1 text-xs":"p-1"} hover:bg-destructive/10 rounded text-destructive font-medium flex items-center gap-1`,title:"Delete untracked file",children:[e.jsx(ut,{className:"w-3 h-3"}),r&&e.jsx("span",{children:"Delete"})]}),e.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-[10px] font-bold border ${K==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800/50":K==="A"?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300 border-green-200 dark:border-green-800/50":K==="D"?"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300 border-red-200 dark:border-red-800/50":"bg-muted text-muted-foreground border-border"}`,title:ve(K),children:K})]})]})]}),e.jsxs("div",{className:`bg-muted/50 transition-all duration-400 ease-in-out overflow-hidden ${de&&ot?"max-h-[600px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-1"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-[10px] font-bold border ${K==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800/50":K==="A"?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300 border-green-200 dark:border-green-800/50":K==="D"?"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300 border-red-200 dark:border-red-800/50":"bg-muted text-muted-foreground border-border"}`,children:K}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:ve(K)})]}),r&&e.jsx("button",{onClick:Xe=>{Xe.stopPropagation(),z(!T)},className:"text-sm text-muted-foreground hover:text-foreground transition-colors",title:T?"Switch to horizontal scroll":"Switch to text wrap",children:T?"↔️ Scroll":"↩️ Wrap"})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:ot&&e.jsx(zn,{diff:ot,fileName:L,isMobile:r,wrapText:T})})]})]},L)};return t?e.jsxs("div",{className:"h-full flex flex-col bg-background",children:[e.jsxs("div",{className:`flex items-center justify-between border-b border-border/60 ${r?"px-3 py-2":"px-4 py-3"}`,children:[e.jsxs("div",{className:"relative",ref:xe,children:[e.jsxs("button",{onClick:()=>D(!B),className:`flex items-center hover:bg-accent rounded-lg transition-colors ${r?"space-x-1 px-2 py-1":"space-x-2 px-3 py-1.5"}`,children:[e.jsx($t,{className:`text-muted-foreground ${r?"w-3 h-3":"w-4 h-4"}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`font-medium ${r?"text-xs":"text-sm"}`,children:w}),O?.hasRemote&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[O.ahead>0&&e.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${O.ahead} commit${O.ahead!==1?"s":""} ahead`,children:["↑",O.ahead]}),O.behind>0&&e.jsxs("span",{className:"text-primary",title:`${O.behind} commit${O.behind!==1?"s":""} behind`,children:["↓",O.behind]}),O.isUpToDate&&e.jsx("span",{className:"text-muted-foreground",title:"Up to date with remote",children:"✓"})]})]}),e.jsx(ft,{className:`w-3 h-3 text-muted-foreground transition-transform ${B?"rotate-180":""}`})]}),B&&e.jsxs("div",{className:"absolute top-full left-0 mt-1 w-64 bg-card rounded-xl shadow-lg border border-border z-50 overflow-hidden",children:[e.jsx("div",{className:"py-1 max-h-64 overflow-y-auto",children:y.map(L=>e.jsx("button",{onClick:()=>Ke(L),className:`w-full text-left px-4 py-2 text-sm hover:bg-accent transition-colors ${L===w?"bg-accent/50 text-foreground":"text-muted-foreground"}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[L===w&&e.jsx(vt,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:L===w?"font-medium":"",children:L})]})},L))}),e.jsx("div",{className:"border-t border-border py-1",children:e.jsxs("button",{onClick:()=>{$(!0),D(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-accent transition-colors flex items-center space-x-2",children:[e.jsx(tt,{className:"w-3 h-3"}),e.jsx("span",{children:"Create new branch"})]})})]})]}),e.jsxs("div",{className:`flex items-center ${r?"gap-1":"gap-2"}`,children:[O?.hasRemote&&e.jsxs(e.Fragment,{children:[!O?.hasUpstream&&e.jsxs("button",{onClick:()=>Ae({type:"publish",message:`Publish branch "${w}" to ${O.remoteName}?`}),disabled:Ee,className:"px-2.5 py-1 text-sm bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 flex items-center gap-1 transition-colors",title:`Publish branch "${w}" to ${O.remoteName}`,children:[e.jsx(Vr,{className:`w-3 h-3 ${Ee?"animate-pulse":""}`}),e.jsx("span",{children:Ee?"Publishing...":"Publish"})]}),O?.hasUpstream&&!O?.isUpToDate&&e.jsxs(e.Fragment,{children:[O.behind>0&&e.jsxs("button",{onClick:()=>Ae({type:"pull",message:`Pull ${O.behind} commit${O.behind!==1?"s":""} from ${O.remoteName}?`}),disabled:Q,className:"px-2.5 py-1 text-sm bg-green-600 text-white rounded-lg hover:bg-green-700 disabled:opacity-50 flex items-center gap-1 transition-colors",title:`Pull ${O.behind} commit${O.behind!==1?"s":""} from ${O.remoteName}`,children:[e.jsx(cs,{className:`w-3 h-3 ${Q?"animate-pulse":""}`}),e.jsx("span",{children:Q?"Pulling...":`Pull ${O.behind}`})]}),O.ahead>0&&e.jsxs("button",{onClick:()=>Ae({type:"push",message:`Push ${O.ahead} commit${O.ahead!==1?"s":""} to ${O.remoteName}?`}),disabled:ae,className:"px-2.5 py-1 text-sm bg-orange-600 text-white rounded-lg hover:bg-orange-700 disabled:opacity-50 flex items-center gap-1 transition-colors",title:`Push ${O.ahead} commit${O.ahead!==1?"s":""} to ${O.remoteName}`,children:[e.jsx(Vr,{className:`w-3 h-3 ${ae?"animate-pulse":""}`}),e.jsx("span",{children:ae?"Pushing...":`Push ${O.ahead}`})]}),(O.ahead>0||O.behind>0&&O.ahead>0)&&e.jsxs("button",{onClick:rt,disabled:Z,className:"px-2.5 py-1 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-50 flex items-center gap-1 transition-colors",title:`Fetch from ${O.remoteName}`,children:[e.jsx(Pt,{className:`w-3 h-3 ${Z?"animate-spin":""}`}),e.jsx("span",{children:Z?"Fetching...":"Fetch"})]})]})]}),e.jsx("button",{onClick:()=>{ke(),Ne(),Ie()},disabled:c,className:`hover:bg-accent rounded-lg transition-colors ${r?"p-1":"p-1.5"}`,children:e.jsx(Pt,{className:`text-muted-foreground ${c?"animate-spin":""} ${r?"w-3 h-3":"w-4 h-4"}`})})]})]}),a?.error?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-muted-foreground px-6 py-12",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-muted/50 flex items-center justify-center mb-6",children:e.jsx($t,{className:"w-8 h-8 opacity-40"})}),e.jsx("h3",{className:"text-lg font-medium mb-3 text-center text-foreground",children:a.error}),a.details&&e.jsx("p",{className:"text-sm text-center leading-relaxed mb-6 max-w-md",children:a.details}),e.jsx("div",{className:"p-4 bg-primary/5 rounded-xl border border-primary/10 max-w-md",children:e.jsxs("p",{className:"text-sm text-primary text-center",children:[e.jsx("strong",{children:"Tip:"})," Run ",e.jsx("code",{className:"bg-primary/10 px-2 py-1 rounded-md font-mono text-xs",children:"git init"})," in your project directory to initialize git source control."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex border-b border-border/60 transition-all duration-300 ease-in-out ${p.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[e.jsx("button",{onClick:()=>V("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${_==="changes"?"text-primary border-b-2 border-primary":"text-muted-foreground hover:text-foreground"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(et,{className:"w-4 h-4"}),e.jsx("span",{children:"Changes"})]})}),e.jsx("button",{onClick:()=>V("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${_==="history"?"text-primary border-b-2 border-primary":"text-muted-foreground hover:text-foreground"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(Ha,{className:"w-4 h-4"}),e.jsx("span",{children:"History"})]})})]}),_==="changes"&&e.jsx(e.Fragment,{children:e.jsx("div",{className:`transition-all duration-300 ease-in-out ${p.size===0?"max-h-96 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:r&&He?e.jsx("div",{className:"px-4 py-2 border-b border-border/60",children:e.jsxs("button",{onClick:()=>Te(!1),className:"w-full flex items-center justify-center gap-2 px-3 py-2 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors",children:[e.jsx(Ls,{className:"w-4 h-4"}),e.jsxs("span",{children:["Commit ",h.size," file",h.size!==1?"s":""]}),e.jsx(ft,{className:"w-3 h-3"})]})}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"px-4 py-3 border-b border-border/60",children:[r&&e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Commit Changes"}),e.jsx("button",{onClick:()=>Te(!0),className:"p-1 hover:bg-accent rounded-lg transition-colors",children:e.jsx(ft,{className:"w-4 h-4 rotate-180"})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:Ce,value:d,onChange:L=>m(L.target.value),placeholder:"Message (Ctrl+Enter to commit)",className:"w-full px-3 py-2 text-sm border border-border rounded-xl bg-background text-foreground placeholder:text-muted-foreground resize-none pr-20 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/30",rows:"3",onKeyDown:L=>{L.key==="Enter"&&(L.ctrlKey||L.metaKey)&&it()}}),e.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[e.jsx("button",{onClick:st,disabled:h.size===0||W,className:"p-1.5 text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Generate commit message",children:W?e.jsx(Pt,{className:"w-4 h-4 animate-spin"}):e.jsx(Ft,{className:"w-4 h-4"})}),e.jsx("div",{style:{display:"none"},children:e.jsx(Bo,{onTranscript:L=>m(L),mode:"default",className:"p-1.5"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[h.size," file",h.size!==1?"s":""," selected"]}),e.jsxs("button",{onClick:()=>Ae({type:"commit",message:`Commit ${h.size} file${h.size!==1?"s":""} with message: "${d.trim()}"?`}),disabled:!d.trim()||h.size===0||g,className:"px-3 py-1.5 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1 transition-colors",children:[e.jsx(vt,{className:"w-3 h-3"}),e.jsx("span",{children:g?"Committing...":"Commit"})]})]})]})})})}),_==="changes"&&a&&!a.error&&e.jsxs("div",{className:`border-b border-border/60 flex items-center justify-between transition-all duration-300 ease-in-out ${r?"px-3 py-1.5":"px-4 py-2"} ${p.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[h.size," of ",(a?.modified?.length||0)+(a?.added?.length||0)+(a?.deleted?.length||0)+(a?.untracked?.length||0)," ",r?"":"files"," selected"]}),e.jsxs("div",{className:`flex ${r?"gap-1":"gap-2"}`,children:[e.jsx("button",{onClick:()=>{const L=new Set([...a?.modified||[],...a?.added||[],...a?.deleted||[],...a?.untracked||[]]);f(L)},className:"text-sm text-primary hover:text-primary/80 transition-colors",children:r?"All":"Select All"}),e.jsx("span",{className:"text-border",children:"|"}),e.jsx("button",{onClick:()=>f(new Set),className:"text-sm text-primary hover:text-primary/80 transition-colors",children:r?"None":"Deselect All"})]})]}),!a?.error&&!r&&e.jsxs("div",{className:"border-b border-border/60",children:[e.jsxs("button",{onClick:()=>F(!I),className:"w-full px-4 py-2 bg-muted/30 hover:bg-muted/50 text-sm text-muted-foreground flex items-center justify-center gap-1 transition-colors",children:[e.jsx(Li,{className:"w-3 h-3"}),e.jsx("span",{children:"File Status Guide"}),I?e.jsx(ft,{className:"w-3 h-3"}):e.jsx(At,{className:"w-3 h-3"})]}),I&&e.jsx("div",{className:"px-4 py-3 bg-muted/30 text-sm",children:e.jsxs("div",{className:`${r?"grid grid-cols-2 gap-3 justify-items-center":"flex justify-center gap-6"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300 rounded border border-yellow-200 dark:border-yellow-800/50 font-bold text-[10px]",children:"M"}),e.jsx("span",{className:"text-muted-foreground italic",children:"Modified"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300 rounded border border-green-200 dark:border-green-800/50 font-bold text-[10px]",children:"A"}),e.jsx("span",{className:"text-muted-foreground italic",children:"Added"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300 rounded border border-red-200 dark:border-red-800/50 font-bold text-[10px]",children:"D"}),e.jsx("span",{className:"text-muted-foreground italic",children:"Deleted"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-muted text-muted-foreground rounded border border-border font-bold text-[10px]",children:"U"}),e.jsx("span",{className:"text-muted-foreground italic",children:"Untracked"})]})]})})]})]}),_==="changes"&&!a?.error&&e.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:c?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(Pt,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):a?.hasCommits===!1?e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-muted/50 flex items-center justify-center mb-4",children:e.jsx($t,{className:"w-7 h-7 text-muted-foreground/50"})}),e.jsx("h3",{className:"text-lg font-medium mb-2 text-foreground",children:"No commits yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-md",children:"This repository doesn't have any commits yet. Create your first commit to start tracking changes."}),e.jsx("button",{onClick:ie,disabled:Re,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 transition-colors",children:Re?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:"Creating Initial Commit..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ls,{className:"w-4 h-4"}),e.jsx("span",{children:"Create Initial Commit"})]})})]}):!a||!a.modified?.length&&!a.added?.length&&!a.deleted?.length&&!a.untracked?.length?e.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-muted-foreground",children:[e.jsx(Ls,{className:"w-10 h-10 mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No changes detected"})]}):e.jsxs("div",{className:r?"pb-4":"",children:[a.modified?.map(L=>ye(L,"M")),a.added?.map(L=>ye(L,"A")),a.deleted?.map(L=>ye(L,"D")),a.untracked?.map(L=>ye(L,"U"))]})}),_==="history"&&!a?.error&&e.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:c?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(Pt,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):ee.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-muted-foreground",children:[e.jsx(Ha,{className:"w-10 h-10 mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No commits found"})]}):e.jsx("div",{className:r?"pb-4":"",children:ee.map(L=>oe(L))})}),H&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>$(!1)}),e.jsx("div",{className:"relative bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:e.jsxs("div",{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"Create New Branch"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-2",children:"Branch Name"}),e.jsx("input",{type:"text",value:R,onChange:L=>E(L.target.value),onKeyDown:L=>{L.key==="Enter"&&!U&&Be()},placeholder:"feature/new-feature",className:"w-full px-3 py-2 border border-border rounded-xl bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/30",autoFocus:!0})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mb-4",children:["This will create a new branch from the current branch (",w,")"]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{$(!1),E("")},className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",children:"Cancel"}),e.jsx("button",{onClick:Be,disabled:!R.trim()||U,className:"px-4 py-2 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2 transition-colors",children:U?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Creating..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(tt,{className:"w-3 h-3"}),e.jsx("span",{children:"Create Branch"})]})})]})]})})]}),be&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>Ae(null)}),e.jsx("div",{className:"relative bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:`p-2 rounded-full mr-3 ${be.type==="discard"||be.type==="delete"?"bg-red-100 dark:bg-red-900/30":"bg-yellow-100 dark:bg-yellow-900/30"}`,children:e.jsx(Lt,{className:`w-5 h-5 ${be.type==="discard"||be.type==="delete"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400"}`})}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:be.type==="discard"?"Discard Changes":be.type==="delete"?"Delete File":be.type==="commit"?"Confirm Commit":be.type==="pull"?"Confirm Pull":be.type==="publish"?"Publish Branch":"Confirm Push"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:be.message}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>Ae(null),className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",children:"Cancel"}),e.jsx("button",{onClick:Fe,className:`px-4 py-2 text-sm text-white rounded-lg transition-colors ${be.type==="discard"||be.type==="delete"?"bg-red-600 hover:bg-red-700":be.type==="commit"?"bg-primary hover:bg-primary/90":be.type==="pull"?"bg-green-600 hover:bg-green-700":be.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:be.type==="discard"?e.jsxs(e.Fragment,{children:[e.jsx(ut,{className:"w-4 h-4"}),e.jsx("span",{children:"Discard"})]}):be.type==="delete"?e.jsxs(e.Fragment,{children:[e.jsx(ut,{className:"w-4 h-4"}),e.jsx("span",{children:"Delete"})]}):be.type==="commit"?e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"w-4 h-4"}),e.jsx("span",{children:"Commit"})]}):be.type==="pull"?e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-4 h-4"}),e.jsx("span",{children:"Pull"})]}):be.type==="publish"?e.jsxs(e.Fragment,{children:[e.jsx(Vr,{className:"w-4 h-4"}),e.jsx("span",{children:"Publish"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Vr,{className:"w-4 h-4"}),e.jsx("span",{children:"Push"})]})})]})]})})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:e.jsx("p",{children:"Select a project to view source control"})})}class On extends Et.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,s){console.error("ErrorBoundary caught an error:",r,s),this.setState({error:r,errorInfo:s})}render(){return this.state.hasError?e.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),e.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"Something went wrong"})]}),e.jsxs("div",{className:"text-sm text-red-700",children:[e.jsx("p",{className:"mb-2",children:"An error occurred while loading the chat interface."}),this.props.showDetails&&this.state.error&&e.jsxs("details",{className:"mt-4",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"Error Details"}),e.jsxs("pre",{className:"mt-2 text-xs bg-red-100 p-2 rounded overflow-auto max-h-40",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-red-600 text-white px-4 py-2 rounded text-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500",children:"Try Again"})})]})}):this.props.children}}function mp(t){const r=l.useRef(!1),s=l.useCallback(o=>{o&&(o.preventDefault(),o.stopPropagation()),t()},[t]),a=l.useCallback(o=>{r.current=!0,s(o),window.setTimeout(()=>{r.current=!1},350)},[s]);return{handleMobileMenuClick:l.useCallback(o=>{if(r.current){o.preventDefault(),o.stopPropagation();return}s(o)},[s]),handleMobileMenuTouchEnd:a}}function mi({onMenuClick:t,compact:r=!1}){const{handleMobileMenuClick:s,handleMobileMenuTouchEnd:a}=mp(t),n=r?"p-1.5 text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/60 pwa-menu-button":"p-1.5 text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/60 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0";return e.jsx("button",{onClick:s,onTouchEnd:a,className:n,"aria-label":"Open menu",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}const St=({children:t,content:r,position:s="top",className:a="",delay:n=500})=>{const[o,i]=l.useState(!1),[c,u]=l.useState(null),d=()=>{const h=setTimeout(()=>{i(!0)},n);u(h)},m=()=>{c&&(clearTimeout(c),u(null)),i(!1)},p=()=>{switch(s){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},x=()=>{switch(s){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return r?e.jsxs("div",{className:"relative inline-block",onMouseEnter:d,onMouseLeave:m,children:[t,o&&e.jsxs("div",{className:he("absolute z-50 px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",p(),a),children:[r,e.jsx("div",{className:he("absolute w-0 h-0 border-4 border-transparent",x())})]})]}):t},Bn=[{id:"chat",labelKey:"tabs.chat",icon:Ca},{id:"canvas",labelKey:"Canvas",icon:_i},{id:"shell",labelKey:"tabs.shell",icon:at},{id:"files",labelKey:"tabs.files",icon:Vt},{id:"git",labelKey:"tabs.git",icon:$t}],pp={id:"tasks",labelKey:"tabs.tasks",icon:ao};function xp({activeTab:t,setActiveTab:r,shouldShowTasksTab:s}){const{t:a}=Ue(),n=s?[...Bn,pp]:Bn;return e.jsx("div",{className:"inline-flex items-center bg-muted/60 rounded-lg p-[3px] gap-[2px]",children:n.map(o=>{const i=o.icon,c=o.id===t;return e.jsx(St,{content:a(o.labelKey),position:"bottom",children:e.jsxs("button",{onClick:()=>r(o.id),className:`relative flex items-center gap-1.5 px-2.5 py-[5px] text-sm font-medium rounded-md transition-all duration-150 ${c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(i,{className:"w-3.5 h-3.5",strokeWidth:c?2.2:1.8}),e.jsx("span",{className:"hidden lg:inline",children:a(o.labelKey)})]})},o.id)})})}function gp(t,r,s){return t==="files"?s("mainContent.projectFiles"):t==="git"?s("tabs.git"):t==="tasks"&&r?"TaskMaster":"Project"}function hp(t){return t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session"}function fp({activeTab:t,selectedProject:r,selectedSession:s,shouldShowTasksTab:a}){const{t:n}=Ue(),o=t==="chat"&&!!s,i=t==="chat"&&!s;return e.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[o&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(jt,{provider:s?.__provider,className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:t==="chat"&&s?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground whitespace-nowrap overflow-x-auto scrollbar-hide leading-tight",children:hp(s)}),e.jsx("div",{className:"text-[11px] text-muted-foreground truncate leading-tight",children:r.displayName})]}):i?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground leading-tight",children:n("mainContent.newSession")}),e.jsx("div",{className:"text-xs text-muted-foreground truncate leading-tight",children:r.displayName})]}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground leading-tight",children:gp(t,a,n)}),e.jsx("div",{className:"text-[11px] text-muted-foreground truncate leading-tight",children:r.displayName})]})})]})}function bp({activeTab:t,setActiveTab:r,selectedProject:s,selectedSession:a,shouldShowTasksTab:n,isMobile:o,onMenuClick:i}){return e.jsx("div",{className:"bg-background border-b border-border/60 px-3 py-1.5 sm:px-4 sm:py-2 pwa-header-safe flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o&&e.jsx(mi,{onMenuClick:i}),e.jsx(fp,{activeTab:t,selectedProject:s,selectedSession:a,shouldShowTasksTab:n})]}),e.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:e.jsx(xp,{activeTab:t,setActiveTab:r,shouldShowTasksTab:n})})]})})}function Wn({mode:t,isMobile:r,onMenuClick:s}){const{t:a}=Ue(),n=t==="loading";return e.jsxs("div",{className:"h-full flex flex-col",children:[r&&e.jsx("div",{className:"bg-background/80 backdrop-blur-sm border-b border-border/50 p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsx(mi,{onMenuClick:s,compact:!0})}),n?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx("div",{className:"w-10 h-10 mx-auto mb-4",children:e.jsx("div",{className:"w-full h-full rounded-full border-[3px] border-muted border-t-primary",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:a("mainContent.loading")}),e.jsx("p",{className:"text-sm",children:a("mainContent.settingUpWorkspace")})]})}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto px-6",children:[e.jsx("div",{className:"w-14 h-14 mx-auto mb-5 bg-muted/50 rounded-2xl flex items-center justify-center",children:e.jsx(Vt,{className:"w-7 h-7 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2 text-foreground",children:a("mainContent.chooseProject")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-5 leading-relaxed",children:a("mainContent.selectProjectDescription")}),e.jsx("div",{className:"bg-primary/5 rounded-xl p-3.5 border border-primary/10",children:e.jsxs("p",{className:"text-sm text-primary",children:[e.jsxs("strong",{children:[a("mainContent.tip"),":"]})," ",a(r?"mainContent.createProjectMobile":"mainContent.createProjectDesktop")]})})]})})]})}var yp=function(t,r){var s={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&r.indexOf(a)<0&&(s[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,a=Object.getOwnPropertySymbols(t);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(t,a[n])&&(s[a[n]]=t[a[n]]);return s};const mt=lo.define({combine:t=>{const r=[];for(let s of t){if(!s)continue;const{create:a,gutters:n}=s,o=yp(s,["create","gutters"]);r.push(Object.assign(Object.assign({},o),{enabled:!0,gutters:n?n.filter(i=>Object.keys(i).length>0):void 0}))}return nl(r,{enabled:r.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),gt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},vp=qt.theme({".cm-minimap-overlay-container":{position:"absolute",top:0,height:"100%",width:"100%","&.cm-minimap-overlay-mouse-over":{opacity:0,transition:"visibility 0s linear 300ms, opacity 300ms"},"&.cm-minimap-overlay-mouse-over:hover":{opacity:1,transition:"visibility 0s linear 0ms, opacity 300ms"},"&.cm-minimap-overlay-off":{display:"none"},"& .cm-minimap-overlay":{background:"rgb(121, 121, 121)",opacity:"0.2",position:"absolute",right:0,top:0,width:"100%",transition:"top 0s ease-in 0ms","&:hover":{opacity:"0.3"}},"&.cm-minimap-overlay-active":{opacity:1,visibility:"visible",transition:"visibility 0s linear 0ms, opacity 300ms","& .cm-minimap-overlay":{opacity:"0.4"}}}}),Ht=gt.PixelMultiplier*gt.SizeRatio,kp=Sa.fromClass(class{constructor(t){this.view=t,this._isDragging=!1,t.state.facet(mt).enabled&&this.create(t)}create(t){this.container=hr("div",{class:"cm-minimap-overlay-container"}),this.dom=hr("div",{class:"cm-minimap-overlay"}),this.container.appendChild(this.dom),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)),window.addEventListener("mouseup",this.onMouseUp.bind(this)),window.addEventListener("mousemove",this.onMouseMove.bind(this));const r=t.dom.querySelector(".cm-minimap-inner");r&&r.appendChild(this.container),this.computeShowOverlay(),this.computeHeight(),this.computeTop()}remove(){this.container&&(this.container.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),this.container.remove())}update(t){const r=t.startState.facet(mt).enabled,s=t.state.facet(mt).enabled;if(r&&!s){this.remove();return}!r&&s&&this.create(t.view),s&&(this.computeShowOverlay(),t.geometryChanged&&(this.computeHeight(),this.computeTop()))}computeHeight(){if(!this.dom)return;const t=this.view.dom.clientHeight/Ht;this.dom.style.height=t+"px"}computeTop(){if(!this._isDragging&&this.dom){const{clientHeight:t,scrollHeight:r,scrollTop:s}=this.view.scrollDOM,a=r-t,n=s/Ht,o=t/Ht,i=t-o;let c=s/a;isNaN(c)&&(c=0);const u=i*c,d=Math.min(u,n);this.dom.style.top=d+"px"}}computeShowOverlay(){if(!this.container)return;const{showOverlay:t}=this.view.state.facet(mt);t==="mouse-over"?this.container.classList.add("cm-minimap-overlay-mouse-over"):this.container.classList.remove("cm-minimap-overlay-mouse-over");const{clientHeight:r,scrollHeight:s}=this.view.scrollDOM;r===s?this.container.classList.add("cm-minimap-overlay-off"):this.container.classList.remove("cm-minimap-overlay-off")}onMouseDown(t){if(!this.container||t.button===2)return;const{clientY:r,target:s}=t;if(s===this.dom){this._dragStartY=t.clientY,this._isDragging=!0,this.container.classList.add("cm-minimap-overlay-active");return}const{clientHeight:a,scrollHeight:n,scrollTop:o}=this.view.scrollDOM,i=s.getBoundingClientRect().top,c=(r-i)*Ht,u=o/(n-a),m=(a*Ht-a)*u,p=Math.max(0,o-m);this.view.scrollDOM.scrollTop=p+c-a/2}onMouseUp(t){this._isDragging&&this.container&&(this._dragStartY=void 0,this._isDragging=!1,this.container.classList.remove("cm-minimap-overlay-active"))}onMouseMove(t){if(!this._isDragging||!this.dom)return;if(t.preventDefault(),t.stopPropagation(),!this._dragStartY){this._dragStartY=t.clientY;return}const r=t.clientY-this._dragStartY,s=r<0,a=r>0;this._dragStartY=t.clientY;const n=this.dom.getBoundingClientRect().height,o=this.dom.getBoundingClientRect().y,i=o+n,c=parseFloat(this.dom.style.top),u=this.view.scrollDOM.scrollTop,d=this.view.scrollDOM.clientHeight,m=this.view.scrollDOM.scrollHeight,p=u===0,x=Math.round(u)>=Math.round(m-d);if(p&&s||p&&t.clientY<o||x&&a||x&&t.clientY>i)return;const h=this.view.scrollDOM.scrollHeight,f=this.view.scrollDOM.clientHeight,g=(h-f)/Ht,k=f-f/Ht,w=c+r,S=w/k,y=(h-f)*S,v=w*Ht;this.view.scrollDOM.scrollTop=Math.max(y,v);const T=Math.min(Math.max(0,w),Math.min(k,g));this.dom.style.top=T+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),jp=[vp,kp];class $a{constructor(r){this.map=new Map,this.view=r}get(r){return this.map.get(r)}set(r,s){this.map.set(r,s)}}function Un(t){var r;if(!t.facet(mt).enabled)return[];const s=[],a=t.doc.iterLines(),n=ll(t).iter();let o=0;for(a.next();!a.done;){const i=a.value;let c=o,u=c+i.length;for(;n.value&&n.to<c;)n.next();const{from:d,to:m}=n,p=c>=d&&c<m,x=u>d&&u<=m;if(p){let h=(r=s.pop())!==null&&r!==void 0?r:[],f=h.pop();f&&f.folded&&(f.to=m),f&&h.push(f),(!f||!f.folded)&&h.push({from:d,to:m,folded:!0}),x||h.push({from:m,to:u,folded:!1}),s.push(h)}else x?s.push([{from:c,to:d,folded:!1},{from:d,to:m,folded:!0}]):s.push([{from:c,to:u,folded:!1}]);o=u+1,a.next()}return s}const br=al.define({create:t=>Un(t),update:(t,r)=>Ns([r])||r.docChanged?Un(r.state):t});function Ns(t){return t.find(r=>r.effects.find(s=>s.is(ol)||s.is(il)))}class wp extends $a{constructor(r){super(r),this.count=void 0}shouldUpdate(r){if(!r.state.facet(mt).enabled)return!1;if(r.docChanged)return!0;for(const s of r.transactions)for(const a of s.effects)if(a.is(dl))return!0;return!!(Ns(r.transactions)||this.count===void 0)}update(r){if(!this.shouldUpdate(r))return;this.map.clear();const s=r.state.field(br);this.count=ul(r.state),ml(r.state,(a,n,o)=>{const i=this.findLine(n,s),c=this.findLine(o,s);let u=a.severity;for(let d=i;d<=c;d++){const m=this.get(d);m&&(u=[u,m].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(d,u)}})}drawLine(r,s){const{context:a,lineHeight:n,offsetX:o,offsetY:i}=r,c=this.get(s);c&&(a.globalAlpha=.65,a.beginPath(),a.rect(o,i,a.canvas.width-o,n),a.fillStyle=this.color(c),a.fill())}findLine(r,s){return s.findIndex(n=>{const o=n.slice(0,1)[0],i=n.slice(-1)[0];return!o||!i?!1:o.from<=r&&r<=i.to})+1}color(r){return r==="error"?"#d11":r==="warning"?"orange":"#999"}sort(r,s){return this.score(s)-this.score(r)}score(r){switch(r){case"error":return 3;case"warning":return 2;default:return 1}}}function Np(t){return new wp(t)}class Cp extends $a{constructor(r){super(r),this.getDrawInfo(),this._themeClasses=r.dom.classList.value}shouldUpdate(r){return r.state.facet(mt).enabled?!!(r.docChanged||r.selectionSet||this._themeClasses!==this.view.dom.classList.value||Ns(r.transactions)):!1}update(r){if(!this.shouldUpdate(r))return;this.map.clear(),this._themeClasses!==this.view.dom.classList.value&&(this._drawInfo=void 0,this._themeClasses=this.view.dom.classList.value);const{ranges:s}=r.state.selection;let a=0;for(const[n,o]of r.state.field(br).entries()){const i=[];let c=0;for(const d of o){do{if(a>=s.length||d.to<s[a].from)continue;if(s[a].from===s[a].to){a++;continue}const m=s[a],p={from:c+Math.max(d.from,m.from)-d.from,to:c+Math.min(d.to,m.to)-d.from,extends:m.to>d.to},x=i.slice(-1)[0];if(x&&x.to===p.from){let{to:h}=p;d.folded&&p.extends?h=p.from+1:d.folded&&!p.extends&&(h=x.to),i[i.length-1]=Object.assign(Object.assign({},x),{to:h,extends:p.extends})}else d.folded||i.push(p);if(p.extends)break;a++}while(a<s.length&&d.to>=s[a].from);c+=d.folded?1:d.to-d.from}if(i.length===0)continue;const u=n+1;this.map.set(u,i)}}drawLine(r,s){let{context:a,lineHeight:n,charWidth:o,offsetX:i,offsetY:c}=r;const u=this.get(s);if(u)for(const d of u){const m=i+d.from*o,p=(d.to-d.from)*o,x=a.canvas.width-m;d.extends&&(a.globalAlpha=.65,a.beginPath(),a.rect(m,c,x,n),a.fillStyle=this.getDrawInfo().backgroundColor,a.fill()),a.globalAlpha=1,a.beginPath(),a.rect(m,c,p,n),a.fillStyle=this.getDrawInfo().backgroundColor,a.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const r=document.createElement("span");r.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(r);const a={backgroundColor:window.getComputedStyle(r).backgroundColor};return this._drawInfo=a,this.view.dom.removeChild(r),a}}function Sp(t){return new Cp(t)}class Ep extends $a{constructor(r){super(r),this._fontInfoMap=new Map,this._themeClasses=new Set(r.dom.classList.values()),r.state.facet(mt).enabled&&this.updateImpl(r.state)}shouldUpdate(r){return!!(r.docChanged||r.state.facet(mt)!==r.startState.facet(mt)||this.themeChanged()||Ns(r.transactions))}update(r){this.shouldUpdate(r)&&(this._highlightingCallbackId&&(typeof window.requestIdleCallback<"u"?cancelIdleCallback(this._highlightingCallbackId):clearTimeout(this._highlightingCallbackId)),this.updateImpl(r.state,r.changes))}updateImpl(r,s){var a;this.map.clear(),this._displayText=r.facet(mt).displayText,this.themeChanged()&&this._fontInfoMap.clear();let n;if(this._previousTree&&s){const p=qa.addTree(this._previousTree),x=[];s.iterChangedRanges((h,f,g,k)=>x.push({fromA:h,toA:f,fromB:g,toB:k})),n=qa.applyChanges(p,x)}const o=r.doc.toString(),i=(a=r.facet(cl))===null||a===void 0?void 0:a.parser,c=i?i.parse(o,n):void 0;this._previousTree=c;const u={style:p=>pl(r,p)};let d=[];if(c){const p=r.doc.lineAt(this.view.viewport.from).number,x=r.doc.lineAt(this.view.viewport.to).number,h=x-p,f=p/(r.doc.lines-h),{SizeRatio:g,PixelMultiplier:k}=gt,w=h*g*k,S=f*w,y=Math.max(1,Math.floor(p-S)),v=Math.min(x+Math.floor(w-S),r.doc.lines);Ka(c,u,(T,z,I)=>{d.push({from:T,to:z,tags:I})},r.doc.line(y).from,r.doc.line(v).to)}this.updateMapImpl(r,d),d=[];const m=()=>{c&&(Ka(c,u,(p,x,h)=>{d.push({from:p,to:x,tags:h})}),this.updateMapImpl(r,d),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(m):setTimeout(m)}updateMapImpl(r,s){this.map.clear();const a=r.doc.toString(),n=s.values();let o=n.next();for(const[i,c]of r.field(br).entries()){const u=[];for(const m of c){if(m.from===m.to)continue;if(m.folded){u.push({text:"…",tags:""});continue}let p=m.from;for(;!o.done&&o.value.from<m.to;){const{from:x,to:h,tags:f}=o.value;if(h<p){o=n.next();continue}x>p&&u.push({text:a.slice(p,x),tags:""});const g=Math.max(x,m.from),k=Math.min(h,m.to);if(u.push({text:a.slice(g,k),tags:f}),p=k,h>k)break;o=n.next()}p!==m.to&&u.push({text:a.slice(p,m.to),tags:""})}const d=i+1;this.map.set(d,u)}}measure(r){const{color:s,font:a,lineHeight:n}=this.getFontInfo("");return r.textBaseline="ideographic",r.fillStyle=s,r.font=a,{charWidth:r.measureText("_").width,lineHeight:n}}beforeDraw(){this._fontInfoMap.clear()}drawLine(r,s){const a=this.get(s);if(!a)return;let{context:n,charWidth:o,lineHeight:i,offsetX:c,offsetY:u}=r,d;n.textBaseline="ideographic";for(const m of a){const p=this.getFontInfo(m.tags);switch((!d||d.color!==p.color)&&(n.fillStyle=p.color),(!d||d.font!==p.font)&&(n.font=p.font),d=p,i=Math.max(i,p.lineHeight),this._displayText){case"characters":{n.fillText(m.text,c,u+i),c+=m.text.length*o;break}case"blocks":{const x=/\S+/g;let h;for(;(h=x.exec(m.text))!==null;){const f=c+h.index*o;let g=(x.lastIndex-h.index)*o;if(f>n.canvas.width)break;f+g>n.canvas.width&&(g=n.canvas.width-f);const k=2/gt.SizeRatio,w=i-k;n.fillStyle=p.color,n.globalAlpha=.65,n.beginPath(),n.rect(f,u,g,w),n.fill()}c+=m.text.length*o;break}}}}getFontInfo(r){const s=this._fontInfoMap.get(r);if(s)return s;const a=hr("span",{class:r}),n=hr("div",{class:"cm-line",style:"display: none"},a);this.view.contentDOM.appendChild(n);const o=window.getComputedStyle(a),i=parseFloat(o.lineHeight)/gt.SizeRatio,c={color:o.color,font:`${o.fontStyle} ${o.fontWeight} ${i}px ${o.fontFamily}`,lineHeight:i};return this._fontInfoMap.set(r,c),this.view.contentDOM.removeChild(n),c}themeChanged(){const r=this._themeClasses,s=new Set(this.view.dom.classList.values());if(this._themeClasses=s,!r||(r.delete("cm-focused"),s.delete("cm-focused"),r.size!==s.size))return!0;let a=!0;return r.forEach(n=>{s.has(n)||(a=!1)}),!a}}function Tp(t){return new Ep(t)}const pi=4;function Ip(t,r,s){const a=t[s];a&&(r.context.fillStyle=a,r.context.globalAlpha=1,r.context.beginPath(),r.context.rect(r.offsetX,r.offsetY,pi,r.lineHeight),r.context.fill())}const Dp=qt.theme({"&":{height:"100%",overflowY:"auto"},"& .cm-minimap-gutter":{borderRight:0,flexShrink:0,left:"unset",position:"sticky",right:0,top:0},"& .cm-minimap-inner":{height:"100%",position:"absolute",right:0,top:0,overflowY:"hidden","& canvas":{display:"block"}},"& .cm-minimap-box-shadow":{boxShadow:"12px 0px 20px 5px #6c6c6c"}}),Hn=6,Ap=Sa.fromClass(class{constructor(t){this.view=t,this.text=Tp(t),this.selection=Sp(t),this.diagnostic=Np(t),t.state.facet($r)&&this.create(t)}create(t){const r=t.state.facet($r);if(!r)throw Error("Expected nonnull");this.inner=hr("div",{class:"cm-minimap-inner"}),this.canvas=hr("canvas"),this.dom=r.create(t).dom,this.dom.classList.add("cm-gutters"),this.dom.classList.add("cm-minimap-gutter"),this.inner.appendChild(this.canvas),this.dom.appendChild(this.inner),this.view.scrollDOM.insertBefore(this.dom,this.view.contentDOM.nextSibling);for(const s in this.view.state.facet(mt).eventHandlers){const a=this.view.state.facet(mt).eventHandlers[s];a&&this.dom.addEventListener(s,n=>a(n,this.view))}}remove(){this.dom&&this.dom.remove()}update(t){const r=t.startState.facet($r),s=t.state.facet($r);if(r&&!s){this.remove();return}!r&&s&&this.create(t.view),s&&(this.text.update(t),this.selection.update(t),this.diagnostic.update(t),this.render())}getWidth(){const t=this.view.dom.clientWidth;if(t<=gt.MaxWidth*Hn){const r=t/(gt.MaxWidth*Hn);return gt.MaxWidth*r}return gt.MaxWidth}render(){if(!this.dom||!this.canvas||!this.inner)return;this.text.beforeDraw(),this.updateBoxShadow(),this.dom.style.width=this.getWidth()+"px",this.canvas.style.maxWidth=this.getWidth()+"px",this.canvas.width=this.getWidth()*gt.PixelMultiplier;const t=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=t+"px",this.canvas.height=t*gt.PixelMultiplier,this.canvas.style.height=t+"px";const r=this.canvas.getContext("2d");if(!r)return;r.clearRect(0,0,this.canvas.width,this.canvas.height);const{charWidth:s,lineHeight:a}=this.text.measure(r);let{startIndex:n,endIndex:o,offsetY:i}=this.canvasStartAndEndIndex(r,a);const c=this.view.state.facet(mt).gutters;for(let u=n;u<o;u++){const d=this.view.state.field(br);if(u>=d.length)break;const m={offsetX:0,offsetY:i,context:r,lineHeight:a,charWidth:s};if(c.length){m.offsetX+=2;for(let p of c)Ip(p,m,u+1),m.offsetX+=pi;m.offsetX+=2}this.text.drawLine(m,u+1),this.selection.drawLine(m,u+1),this.diagnostic.drawLine(m,u+1),i+=a}r.restore()}canvasStartAndEndIndex(t,r){let{top:s,bottom:a}=this.view.documentPadding;s/=gt.SizeRatio,a/=gt.SizeRatio;const n=t.canvas.height,{clientHeight:o,scrollHeight:i,scrollTop:c}=this.view.scrollDOM;let u=c/(i-o);isNaN(u)&&(u=0);const d=this.view.state.field(br).length,m=s+a+d*r,p=Math.max(0,u*(m-n)),x=Math.max(0,s-p),h=Math.round(Math.max(0,p-s)/r),f=Math.round((n-x)/r);return{startIndex:h,endIndex:h+f,offsetY:x}}updateBoxShadow(){if(!this.canvas)return;const{clientWidth:t,scrollWidth:r,scrollLeft:s}=this.view.scrollDOM;t+s<r?this.canvas.classList.add("cm-minimap-box-shadow"):this.canvas.classList.remove("cm-minimap-box-shadow")}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.render())}},provide:t=>qt.scrollMargins.of(r=>{var s;const a=(s=r.plugin(t))===null||s===void 0?void 0:s.getWidth();return a?{right:a}:null})}),$r=lo.define({combine:t=>{var r;return(r=t.find(s=>s!==null))!==null&&r!==void 0?r:null},enables:t=>[[mt.compute([t],r=>r.facet(t)),Dp,br,Ap,jp]]}),Mp=l.lazy(()=>io(()=>import("./MarkdownPreview-B3c7OEj6.js"),__vite__mapDeps([0,1,2,3]))),Gn=hl.define({token(t){return t.match(/^#.*/)?"comment":t.sol()&&t.match(/^[A-Za-z_][A-Za-z0-9_.]*(?==)/)?"variableName.definition":t.match(/^=/)?"operator":t.match(/^"(?:[^"\\]|\\.)*"?/)||t.match(/^'(?:[^'\\]|\\.)*'?/)?"string":t.match(/^\$\{[^}]*\}?/)||t.match(/^\$[A-Za-z_][A-Za-z0-9_]*/)?"variableName.special":t.match(/^\d+/)?"number":(t.next(),null)}});function Pp({file:t,onClose:r,projectPath:s,isSidebar:a=!1,isExpanded:n=!1,onToggleExpand:o=null,onPopOut:i=null}){const{t:c}=Ue("codeEditor"),[u,d]=l.useState(""),[m,p]=l.useState(!0),[x,h]=l.useState(!1),[f,g]=l.useState(!1),[k,w]=l.useState(()=>{const A=localStorage.getItem("codeEditorTheme");return A?A==="dark":!0}),[S,y]=l.useState(!1),[v,T]=l.useState(!!t.diffInfo),[z,I]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[F,B]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[D,H]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[$,R]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"12"),[E,U]=l.useState(!1),j=l.useRef(null),_=l.useMemo(()=>{const A=t.name.split(".").pop()?.toLowerCase();return A==="md"||A==="markdown"},[t.name]),V=l.useMemo(()=>{if(!t.diffInfo||!v||!F)return[];const A={};return[$r.compute(["doc"],O=>{const Z=_s(O)?.chunks||[];return Object.keys(A).forEach(J=>delete A[J]),Z.forEach(J=>{const Q=O.doc.lineAt(J.fromB).number,le=O.doc.lineAt(Math.min(J.toB,O.doc.length)).number;for(let ae=Q;ae<=le;ae++)A[ae]=k?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[A]}})]},[t.diffInfo,v,F,k]),ee=l.useMemo(()=>!t.diffInfo||!v?[]:[Sa.fromClass(class{constructor(A){setTimeout(()=>{const q=_s(A.state)?.chunks||[];if(q.length>0){const Z=q[0];A.dispatch({effects:qt.scrollIntoView(Z.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[t.diffInfo,v]),M=!!(t.diffInfo||a&&i||a&&o),G=l.useMemo(()=>{if(!M)return[];const A=O=>{const q=document.createElement("div");q.className="cm-editor-toolbar-panel";let Z=0;const J=()=>{const Q=t.diffInfo&&v,ae=(Q?_s(O.state):null)?.chunks||[],fe=ae.length;let Ee='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(Ee+='<div style="display: flex; align-items: center; gap: 8px;">',Q&&(Ee+=`
142
- <span style="font-weight: 500;">${fe>0?`${Z+1}/${fe}`:"0"} ${c("toolbar.changes")}</span>
143
- <button class="cm-diff-nav-btn cm-diff-nav-prev" title="${c("toolbar.previousChange")}" ${fe===0?"disabled":""}>
144
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
145
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
146
- </svg>
147
- </button>
148
- <button class="cm-diff-nav-btn cm-diff-nav-next" title="${c("toolbar.nextChange")}" ${fe===0?"disabled":""}>
149
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
150
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
151
- </svg>
152
- </button>
153
- `),Ee+="</div>",Ee+='<div style="display: flex; align-items: center; gap: 4px;">',t.diffInfo&&(Ee+=`
154
- <button class="cm-toolbar-btn cm-toggle-diff-btn" title="${c(v?"toolbar.hideDiff":"toolbar.showDiff")}">
155
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
156
- ${v?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />'}
157
- </svg>
158
- </button>
159
- `),a&&i&&(Ee+=`
160
- <button class="cm-toolbar-btn cm-popout-btn" title="Open in modal">
161
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
162
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3" />
163
- </svg>
164
- </button>
165
- `),a&&o&&(Ee+=`
166
- <button class="cm-toolbar-btn cm-expand-btn" title="${c(n?"toolbar.collapse":"toolbar.expand")}">
167
- <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
168
- ${n?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />'}
169
- </svg>
170
- </button>
171
- `),Ee+="</div>",Ee+="</div>",q.innerHTML=Ee,Q){const Pe=q.querySelector(".cm-diff-nav-prev"),He=q.querySelector(".cm-diff-nav-next");Pe?.addEventListener("click",()=>{if(ae.length===0)return;Z=Z>0?Z-1:ae.length-1;const Te=ae[Z];Te&&O.dispatch({effects:qt.scrollIntoView(Te.fromB,{y:"center"})}),J()}),He?.addEventListener("click",()=>{if(ae.length===0)return;Z=Z<ae.length-1?Z+1:0;const Te=ae[Z];Te&&O.dispatch({effects:qt.scrollIntoView(Te.fromB,{y:"center"})}),J()})}t.diffInfo&&q.querySelector(".cm-toggle-diff-btn")?.addEventListener("click",()=>{T(!v)}),a&&i&&q.querySelector(".cm-popout-btn")?.addEventListener("click",()=>{i()}),a&&o&&q.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{o()})};return J(),{top:!0,dom:q,update:J}};return[xl.of(A)]},[t.diffInfo,v,a,n,o,i]),C=A=>{const O=A.toLowerCase();if(O===".env"||O.startsWith(".env."))return[Gn];const q=A.split(".").pop()?.toLowerCase();switch(q){case"js":case"jsx":case"ts":case"tsx":return[kl({jsx:!0,typescript:q.includes("ts")})];case"py":return[vl()];case"html":case"htm":return[yl()];case"css":case"scss":case"less":return[bl()];case"json":return[fl()];case"md":case"markdown":return[mo()];case"env":return[Gn];default:return[]}};l.useEffect(()=>{(async()=>{try{if(p(!0),t.diffInfo&&t.diffInfo.new_string!==void 0&&t.diffInfo.old_string!==void 0){d(t.diffInfo.new_string),p(!1);return}const O=await Ge.readFile(t.projectName,t.path);if(!O.ok)throw new Error(`Failed to load file: ${O.status} ${O.statusText}`);const q=await O.json();d(q.content)}catch(O){console.error("Error loading file:",O),d(`// Error loading file: ${O.message}
172
- // File: ${t.name}
173
- // Path: ${t.path}`)}finally{p(!1)}})()},[t,s]);const b=async()=>{h(!0);try{console.log("Saving file:",{projectName:t.projectName,path:t.path,contentLength:u?.length});const A=await Ge.saveFile(t.projectName,t.path,u);if(console.log("Save response:",{status:A.status,ok:A.ok,contentType:A.headers.get("content-type")}),!A.ok){const q=A.headers.get("content-type");if(q&&q.includes("application/json")){const Z=await A.json();throw new Error(Z.error||`Save failed: ${A.status}`)}else{const Z=await A.text();throw console.error("Non-JSON error response:",Z),new Error(`Save failed: ${A.status} ${A.statusText}`)}}const O=await A.json();console.log("Save successful:",O),y(!0),setTimeout(()=>y(!1),2e3)}catch(A){console.error("Error saving file:",A),alert(`Error saving file: ${A.message}`)}finally{h(!1)}},N=()=>{const A=new Blob([u],{type:"text/plain"}),O=URL.createObjectURL(A),q=document.createElement("a");q.href=O,q.download=t.name,document.body.appendChild(q),q.click(),document.body.removeChild(q),URL.revokeObjectURL(O)},W=()=>{g(!f)};return l.useEffect(()=>{localStorage.setItem("codeEditorTheme",k?"dark":"light")},[k]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",z.toString())},[z]),l.useEffect(()=>{const A=()=>{const O=localStorage.getItem("codeEditorTheme");O&&w(O==="dark");const q=localStorage.getItem("codeEditorWordWrap");q!==null&&I(q==="true");const Z=localStorage.getItem("codeEditorShowMinimap");Z!==null&&B(Z!=="false");const J=localStorage.getItem("codeEditorLineNumbers");J!==null&&H(J!=="false");const Q=localStorage.getItem("codeEditorFontSize");Q&&R(Q)};return window.addEventListener("storage",A),window.addEventListener("codeEditorSettingsChanged",A),()=>{window.removeEventListener("storage",A),window.removeEventListener("codeEditorSettingsChanged",A)}},[]),l.useEffect(()=>{const A=O=>{(O.ctrlKey||O.metaKey)&&(O.key==="s"?(O.preventDefault(),b()):O.key==="Escape"&&(O.preventDefault(),r()))};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[u]),m?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
174
- .code-editor-loading {
175
- background-color: ${k?"#111827":"#ffffff"} !important;
176
- }
177
- .code-editor-loading:hover {
178
- background-color: ${k?"#111827":"#ffffff"} !important;
179
- }
180
- `}),a?e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-background",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:c("loading",{fileName:t.name})})]})}):e.jsx("div",{className:"fixed inset-0 z-[9999] md:bg-black/50 md:flex md:items-center md:justify-center",children:e.jsx("div",{className:"code-editor-loading w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:c("loading",{fileName:t.name})})]})})})]}):e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
181
- /* Light background for full line changes */
182
- .cm-deletedChunk {
183
- background-color: ${k?"rgba(239, 68, 68, 0.15)":"rgba(255, 235, 235, 1)"} !important;
184
- border-left: 3px solid ${k?"rgba(239, 68, 68, 0.6)":"rgb(239, 68, 68)"} !important;
185
- padding-left: 4px !important;
186
- }
187
-
188
- .cm-insertedChunk {
189
- background-color: ${k?"rgba(34, 197, 94, 0.15)":"rgba(230, 255, 237, 1)"} !important;
190
- border-left: 3px solid ${k?"rgba(34, 197, 94, 0.6)":"rgb(34, 197, 94)"} !important;
191
- padding-left: 4px !important;
192
- }
193
-
194
- /* Override linear-gradient underline and use solid darker background for partial changes */
195
- .cm-editor.cm-merge-b .cm-changedText {
196
- background: ${k?"rgba(34, 197, 94, 0.4)":"rgba(34, 197, 94, 0.3)"} !important;
197
- padding-top: 2px !important;
198
- padding-bottom: 2px !important;
199
- margin-top: -2px !important;
200
- margin-bottom: -2px !important;
201
- }
202
-
203
- .cm-editor .cm-deletedChunk .cm-changedText {
204
- background: ${k?"rgba(239, 68, 68, 0.4)":"rgba(239, 68, 68, 0.3)"} !important;
205
- padding-top: 2px !important;
206
- padding-bottom: 2px !important;
207
- margin-top: -2px !important;
208
- margin-bottom: -2px !important;
209
- }
210
-
211
- /* Minimap gutter styling */
212
- .cm-gutter.cm-gutter-minimap {
213
- background-color: ${k?"#1e1e1e":"#f5f5f5"};
214
- }
215
-
216
- /* Editor toolbar panel styling */
217
- .cm-editor-toolbar-panel {
218
- padding: 4px 10px;
219
- background-color: ${k?"#1f2937":"#ffffff"};
220
- border-bottom: 1px solid ${k?"#374151":"#e5e7eb"};
221
- color: ${k?"#d1d5db":"#374151"};
222
- font-size: 12px;
223
- }
224
-
225
- .cm-diff-nav-btn,
226
- .cm-toolbar-btn {
227
- padding: 3px;
228
- background: transparent;
229
- border: none;
230
- cursor: pointer;
231
- border-radius: 4px;
232
- display: inline-flex;
233
- align-items: center;
234
- justify-content: center;
235
- color: inherit;
236
- transition: background-color 0.2s;
237
- }
238
-
239
- .cm-diff-nav-btn:hover,
240
- .cm-toolbar-btn:hover {
241
- background-color: ${k?"#374151":"#f3f4f6"};
242
- }
243
-
244
- .cm-diff-nav-btn:disabled {
245
- opacity: 0.5;
246
- cursor: not-allowed;
247
- }
248
- `}),e.jsx("div",{className:a?"w-full h-full flex flex-col":`fixed inset-0 z-[9999] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${f?"md:p-0":""}`,children:e.jsxs("div",{className:a?"bg-background flex flex-col w-full h-full":`bg-background shadow-2xl flex flex-col ${"w-full h-full md:rounded-lg md:shadow-2xl"+(f?" md:w-full md:h-full md:rounded-none":" md:w-full md:max-w-6xl md:h-[80vh] md:max-h-[80vh]")}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border flex-shrink-0 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:t.name}),t.diffInfo&&e.jsx("span",{className:"text-[10px] bg-blue-100 dark:bg-blue-900 text-blue-600 dark:text-blue-300 px-1.5 py-0.5 rounded whitespace-nowrap",children:c("header.showingChanges")})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.path})]})}),e.jsxs("div",{className:"flex items-center gap-0.5 md:gap-1 flex-shrink-0",children:[_&&e.jsx("button",{onClick:()=>U(!E),className:`p-1.5 rounded-md min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center transition-colors ${E?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:c(E?"actions.editMarkdown":"actions.previewMarkdown"),children:E?e.jsx(os,{className:"w-4 h-4"}):e.jsx(ar,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>window.openSettings?.("appearance"),className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("toolbar.settings"),children:e.jsx(Ve,{className:"w-4 h-4"})}),e.jsx("button",{onClick:N,className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("actions.download"),children:e.jsx(cs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:b,disabled:x,className:`p-1.5 rounded-md disabled:opacity-50 flex items-center justify-center transition-colors min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 ${S?"text-green-600 dark:text-green-400 bg-green-50 dark:bg-green-900/30":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:c(S?"actions.saved":x?"actions.saving":"actions.save"),children:S?e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.jsx(is,{className:"w-4 h-4"})}),!a&&e.jsx("button",{onClick:W,className:"hidden md:flex p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:c(f?"actions.exitFullscreen":"actions.fullscreen"),children:f?e.jsx(no,{className:"w-4 h-4"}):e.jsx(wa,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("actions.close"),children:e.jsx(qe,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:E&&_?e.jsx("div",{className:"h-full overflow-y-auto bg-white dark:bg-gray-900",children:e.jsx("div",{className:"max-w-4xl mx-auto px-8 py-6 prose prose-sm dark:prose-invert prose-headings:font-semibold prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-code:text-sm prose-pre:bg-gray-900 prose-img:rounded-lg max-w-none",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"text-muted-foreground text-sm p-4",children:"Loading preview..."}),children:e.jsx(Mp,{content:u})})})}):e.jsx(co,{ref:j,value:u,onChange:d,extensions:[...C(t.name),...G,...t.diffInfo&&v&&t.diffInfo.old_string!==void 0?[gl({original:t.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...V,...ee]:[],...z?[qt.lineWrapping]:[]],theme:k?uo:void 0,height:"100%",style:{fontSize:`${$}px`,height:"100%"},basicSetup:{lineNumbers:D,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-border bg-muted flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:[c("footer.lines")," ",u.split(`
249
- `).length]}),e.jsxs("span",{children:[c("footer.characters")," ",u.length]})]}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("footer.shortcuts")})]})]})})]})}const qn=Pp;function Fp({editingFile:t,isMobile:r,editorExpanded:s,editorWidth:a,resizeHandleRef:n,onResizeStart:o,onCloseEditor:i,onToggleEditorExpand:c,projectPath:u,fillSpace:d}){const[m,p]=l.useState(!1);if(!t)return null;if(r||m)return e.jsx(qn,{file:t,onClose:()=>{p(!1),i()},projectPath:u,isSidebar:!1});const x=s||d;return e.jsxs(e.Fragment,{children:[!s&&e.jsx("div",{ref:n,onMouseDown:o,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${x?"flex-1":""}`,style:x?void 0:{width:`${a}px`},children:e.jsx(qn,{file:t,onClose:i,projectPath:u,isSidebar:!0,isExpanded:s,onToggleExpand:c,onPopOut:()=>p(!0)})})]})}const Kn=({task:t,onClick:r,showParent:s=!1,className:a=""})=>{const o=(c=>{switch(c){case"done":return{icon:Br,bgColor:"bg-green-50 dark:bg-green-950",borderColor:"border-green-200 dark:border-green-800",iconColor:"text-green-600 dark:text-green-400",textColor:"text-green-900 dark:text-green-100",statusText:"Done"};case"in-progress":return{icon:Lr,bgColor:"bg-blue-50 dark:bg-blue-950",borderColor:"border-blue-200 dark:border-blue-800",iconColor:"text-blue-600 dark:text-blue-400",textColor:"text-blue-900 dark:text-blue-100",statusText:"In Progress"};case"review":return{icon:ks,bgColor:"bg-amber-50 dark:bg-amber-950",borderColor:"border-amber-200 dark:border-amber-800",iconColor:"text-amber-600 dark:text-amber-400",textColor:"text-amber-900 dark:text-amber-100",statusText:"Review"};case"deferred":return{icon:ro,bgColor:"bg-gray-50 dark:bg-gray-800",borderColor:"border-gray-200 dark:border-gray-700",iconColor:"text-gray-500 dark:text-gray-400",textColor:"text-gray-700 dark:text-gray-300",statusText:"Deferred"};case"cancelled":return{icon:qe,bgColor:"bg-red-50 dark:bg-red-950",borderColor:"border-red-200 dark:border-red-800",iconColor:"text-red-600 dark:text-red-400",textColor:"text-red-900 dark:text-red-100",statusText:"Cancelled"};default:return{icon:xr,bgColor:"bg-slate-50 dark:bg-slate-800",borderColor:"border-slate-200 dark:border-slate-700",iconColor:"text-slate-500 dark:text-slate-400",textColor:"text-slate-900 dark:text-slate-100",statusText:"Pending"}}})(t.status);o.icon;const i=c=>{switch(c){case"high":return e.jsx(St,{content:"High Priority",children:e.jsx("div",{className:"w-4 h-4 bg-red-100 dark:bg-red-900/30 rounded flex items-center justify-center",children:e.jsx(zi,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})});case"medium":return e.jsx(St,{content:"Medium Priority",children:e.jsx("div",{className:"w-4 h-4 bg-amber-100 dark:bg-amber-900/30 rounded flex items-center justify-center",children:e.jsx(Ri,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})})});case"low":return e.jsx(St,{content:"Low Priority",children:e.jsx("div",{className:"w-4 h-4 bg-blue-100 dark:bg-blue-900/30 rounded flex items-center justify-center",children:e.jsx(xr,{className:"w-1.5 h-1.5 text-blue-600 dark:text-blue-400 fill-current"})})});default:return e.jsx(St,{content:"No Priority Set",children:e.jsx("div",{className:"w-4 h-4 bg-gray-100 dark:bg-gray-800 rounded flex items-center justify-center",children:e.jsx(xr,{className:"w-1.5 h-1.5 text-gray-400 dark:text-gray-500"})})})}};return e.jsxs("div",{className:he("bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700","hover:shadow-md hover:border-blue-300 dark:hover:border-blue-600 transition-all duration-200 cursor-pointer","p-3 space-y-3",r&&"hover:-translate-y-0.5",a),onClick:r,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx(St,{content:`Task ID: ${t.id}`,children:e.jsx("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 px-2 py-0.5 rounded",children:t.id})})}),e.jsx("h3",{className:"font-medium text-sm text-gray-900 dark:text-white line-clamp-2 leading-tight",children:t.title}),s&&t.parentId&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium",children:["Task ",t.parentId]})]}),e.jsx("div",{className:"flex-shrink-0",children:i(t.priority)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:t.dependencies&&Array.isArray(t.dependencies)&&t.dependencies.length>0&&e.jsx(St,{content:`Depends on: ${t.dependencies.map(c=>`Task ${c}`).join(", ")}`,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[e.jsx(Na,{className:"w-3 h-3"}),e.jsxs("span",{children:["Depends on: ",t.dependencies.join(", ")]})]})})}),e.jsx(St,{content:`Status: ${o.statusText}`,children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:he("w-2 h-2 rounded-full",o.iconColor.replace("text-","bg-"))}),e.jsx("span",{className:he("text-xs font-medium",o.textColor),children:o.statusText})]})})]}),t.subtasks&&t.subtasks.length>0&&e.jsx("div",{className:"ml-3",children:e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Progress:"}),e.jsx(St,{content:`${t.subtasks.filter(c=>c.status==="done").length} of ${t.subtasks.length} subtasks completed`,children:e.jsx("div",{className:"flex-1 bg-gray-200 dark:bg-gray-700 rounded-full h-1.5",children:e.jsx("div",{className:he("h-full rounded-full transition-all duration-300",t.status==="done"?"bg-green-500":"bg-blue-500"),style:{width:`${Math.round(t.subtasks.filter(c=>c.status==="done").length/t.subtasks.length*100)}%`}})})}),e.jsx(St,{content:`${t.subtasks.filter(c=>c.status==="done").length} completed, ${t.subtasks.filter(c=>c.status==="pending").length} pending, ${t.subtasks.filter(c=>c.status==="in-progress").length} in progress`,children:e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t.subtasks.filter(c=>c.status==="done").length,"/",t.subtasks.length]})})]})})]})},$p=({currentProject:t,onClose:r,onTaskCreated:s})=>e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ft,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create AI-Generated Task"})]}),e.jsx("button",{onClick:r,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ft,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-3",children:"You can simply ask your AI assistant in the chat to create tasks for you. The AI assistant will automatically generate detailed tasks with research-backed insights."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-blue-200 dark:border-blue-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Example:"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white font-mono",children:'"Please add a new task to implement user profile image uploads using Cloudinary, research the best approach."'})]}),e.jsxs("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:[e.jsx("strong",{children:"This runs:"})," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900/50 px-1 rounded text-xs",children:'task-master add-task --prompt="Implement user profile image uploads using Cloudinary" --research'})]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:r,className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),Lp=({tasks:t=[],onTaskClick:r,className:s="",showParentTasks:a=!1,defaultView:n="kanban",currentProject:o,onTaskCreated:i,onShowPRDEditor:c,existingPRDs:u=[],onRefreshPRDs:d})=>{const[m,p]=l.useState(""),[x,h]=l.useState("all"),[f,g]=l.useState("all"),[k,w]=l.useState("id"),[S,y]=l.useState("asc"),[v,T]=l.useState(n),[z,I]=l.useState(!1),[F,B]=l.useState(!1),[D,H]=l.useState(!1),[$,R]=l.useState(!1),[E,U]=l.useState(!1),[j,_]=l.useState(!1),{projectTaskMaster:V,refreshProjects:ee,refreshTasks:M,setCurrentProject:G}=yr(),{t:C}=Ue("tasks");l.useEffect(()=>{const J=Q=>{j&&!Q.target.closest(".relative")&&_(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[j]);const b=l.useMemo(()=>{const J=new Set(t.map(Q=>Q.status).filter(Boolean));return Array.from(J).sort()},[t]),N=l.useMemo(()=>{const J=new Set(t.map(Q=>Q.priority).filter(Boolean));return Array.from(J).sort()},[t]),W=l.useMemo(()=>{let J=t.filter(Q=>{const le=m.toLowerCase(),ae=!m||Q.title.toLowerCase().includes(le)||Q.description?.toLowerCase().includes(le)||Q.id.toString().includes(le),fe=x==="all"||Q.status===x,Ee=f==="all"||Q.priority===f;return ae&&fe&&Ee});return J.sort((Q,le)=>{let ae,fe;switch(k){case"title":ae=Q.title.toLowerCase(),fe=le.title.toLowerCase();break;case"status":const Ee={pending:1,"in-progress":2,done:3,blocked:4,deferred:5,cancelled:6};ae=Ee[Q.status]||99,fe=Ee[le.status]||99;break;case"priority":const Pe={high:3,medium:2,low:1};ae=Pe[Q.priority]||0,fe=Pe[le.priority]||0;break;case"updated":ae=new Date(Q.updatedAt||Q.createdAt||0),fe=new Date(le.updatedAt||le.createdAt||0);break;default:const He=Ae=>Ae.toString().split(".").map(X=>parseInt(X,10)),Te=He(Q.id),be=He(le.id);for(let Ae=0;Ae<Math.max(Te.length,be.length);Ae++){const Re=Te[Ae]||0,X=be[Ae]||0;if(Re!==X){ae=Re,fe=X;break}}break}return k==="updated"?S==="asc"?ae-fe:fe-ae:typeof ae=="string"?S==="asc"?ae.localeCompare(fe):fe.localeCompare(ae):S==="asc"?ae-fe:fe-ae}),J},[t,m,x,f,k,S]),A=l.useMemo(()=>{const J=[{id:"pending",title:C("kanban.pending"),status:"pending",color:"bg-slate-50 dark:bg-slate-900/50 border-slate-200 dark:border-slate-700",headerColor:"bg-slate-100 dark:bg-slate-800 text-slate-800 dark:text-slate-200"},{id:"in-progress",title:C("kanban.inProgress"),status:"in-progress",color:"bg-blue-50 dark:bg-blue-900/50 border-blue-200 dark:border-blue-700",headerColor:"bg-blue-100 dark:bg-blue-800 text-blue-800 dark:text-blue-200"},{id:"done",title:C("kanban.done"),status:"done",color:"bg-emerald-50 dark:bg-emerald-900/50 border-emerald-200 dark:border-emerald-700",headerColor:"bg-emerald-100 dark:bg-emerald-800 text-emerald-800 dark:text-emerald-200"},{id:"blocked",title:C("kanban.blocked"),status:"blocked",color:"bg-red-50 dark:bg-red-900/50 border-red-200 dark:border-red-700",headerColor:"bg-red-100 dark:bg-red-800 text-red-800 dark:text-red-200"},{id:"deferred",title:C("kanban.deferred"),status:"deferred",color:"bg-amber-50 dark:bg-amber-900/50 border-amber-200 dark:border-amber-700",headerColor:"bg-amber-100 dark:bg-amber-800 text-amber-800 dark:text-amber-200"},{id:"cancelled",title:C("kanban.cancelled"),status:"cancelled",color:"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700",headerColor:"bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-200"}],Q=["pending","in-progress","done"];return J.filter(ae=>{const fe=W.some(Pe=>Pe.status===ae.status),Ee=Q.includes(ae.status);return fe||Ee}).map(ae=>({...ae,tasks:W.filter(fe=>fe.status===ae.status)}))},[W,C]),O=J=>{k===J?y(S==="asc"?"desc":"asc"):(w(J),y("asc"))},q=()=>{p(""),h("all"),g("all")},Z=J=>k!==J?e.jsx(Hi,{className:"w-4 h-4"}):S==="asc"?e.jsx(Gi,{className:"w-4 h-4"}):e.jsx(eo,{className:"w-4 h-4"});if(t.length===0){const J=o?.taskMasterConfigured||o?.taskmaster?.hasTaskmaster||V?.hasTaskmaster;return e.jsxs("div",{className:he("text-center py-12",s),children:[J?e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/50 dark:to-indigo-950/50 rounded-xl border border-blue-200 dark:border-blue-800 p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(et,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:C("gettingStarted.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:C("gettingStarted.subtitle")})]})]}),e.jsxs("div",{className:"space-y-4 text-left",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:C("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:C("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{c?.()},className:"inline-flex items-center gap-1 text-xs bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 px-2 py-1 rounded hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors",children:[e.jsx(et,{className:"w-3 h-3"}),C("gettingStarted.steps.createPRD.addButton")]}),u.length>0&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:C("gettingStarted.steps.createPRD.existingPRDs")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(Q=>e.jsxs("button",{onClick:async()=>{try{const le=await Ge.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(Q.name)}`);if(le.ok){const ae=await le.json();c?.({name:Q.name,content:ae.content,isExisting:!0})}else console.error("Failed to load PRD:",le.statusText)}catch(le){console.error("Error loading PRD:",le)}},className:"inline-flex items-center gap-1 text-xs bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 px-2 py-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(et,{className:"w-3 h-3"}),Q.name]},Q.name))})]})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:C("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:C("gettingStarted.steps.generateTasks.description")})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:C("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:C("gettingStarted.steps.analyzeTasks.description")})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"4"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:C("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:C("gettingStarted.steps.startBuilding.description")})]})]})]}),e.jsx("div",{className:"flex gap-3 pt-4 border-t border-blue-200 dark:border-blue-700",children:e.jsxs("button",{onClick:Q=>{Q.preventDefault(),Q.stopPropagation(),c?.()},className:"flex items-center gap-2 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg font-medium transition-colors cursor-pointer",style:{zIndex:10},children:[e.jsx(et,{className:"w-4 h-4"}),C("buttons.addPRD")]})})]})]}),e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mb-2",children:C("gettingStarted.tip")})})]}):e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsx("div",{className:"text-blue-600 dark:text-blue-400 mb-4",children:e.jsx(Ve,{className:"w-12 h-12 mx-auto mb-4"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:C("notConfigured.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:C("notConfigured.description")}),e.jsxs("div",{className:"mb-6 p-4 bg-blue-50 dark:bg-blue-950 rounded-lg text-left",children:[e.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-3",children:C("notConfigured.whatIsTitle")}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("p",{children:["• ",C("notConfigured.features.aiPowered")]}),e.jsxs("p",{children:["• ",C("notConfigured.features.prdTemplates")]}),e.jsxs("p",{children:["• ",C("notConfigured.features.dependencyTracking")]}),e.jsxs("p",{children:["• ",C("notConfigured.features.progressVisualization")]}),e.jsxs("p",{children:["• ",C("notConfigured.features.cliIntegration")]})]})]}),e.jsxs("button",{onClick:()=>{U(!1),H(!0)},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium transition-colors flex items-center gap-2 mx-auto",children:[e.jsx(at,{className:"w-4 h-4"}),C("notConfigured.initializeButton")]})]}),D&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center p-4 pt-16 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(at,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:C("setupModal.title")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:C("setupModal.subtitle",{projectName:o?.displayName})})]})]}),e.jsx("button",{onClick:()=>{H(!1),setTimeout(()=>{ee(),o&&G(o)},1e3)},className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:e.jsx(tt,{className:"w-5 h-5 rotate-45"})})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",onClick:Q=>{const le=Q.currentTarget.querySelector(".xterm-screen");le&&le.focus()},children:e.jsx(oo,{selectedProject:o,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0,onProcessComplete:Q=>{U(!0),Q===0&&setTimeout(()=>{ee(),o&&G(o)},1e3)}})})}),e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:E?e.jsxs("span",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),C("setupModal.completed")]}):C("setupModal.willStart")}),e.jsx("button",{onClick:()=>{H(!1),U(!1),setTimeout(()=>{ee(),o&&G(o)},1e3)},className:he("px-4 py-2 text-sm font-medium rounded-md transition-colors",E?"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:C(E?"setupModal.closeContinueButton":"setupModal.closeButton")})]})})]})})]})}return e.jsxs("div",{className:he("space-y-4",s),children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-3 lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(sr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),e.jsx("input",{type:"text",placeholder:C("search.placeholder"),value:m,onChange:J=>p(J.target.value),className:"pl-10 pr-4 py-2 w-full border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[e.jsx("button",{onClick:()=>T("kanban"),className:he("p-2 rounded-md transition-colors",v==="kanban"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:C("views.kanban"),children:e.jsx(Oi,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>T("list"),className:he("p-2 rounded-md transition-colors",v==="list"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:C("views.list"),children:e.jsx(ls,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>T("grid"),className:he("p-2 rounded-md transition-colors",v==="grid"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:C("views.grid"),children:e.jsx(Bi,{className:"w-4 h-4"})})]}),e.jsxs("button",{onClick:()=>I(!z),className:he("flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors",z?"bg-blue-50 dark:bg-blue-900 border-blue-200 dark:border-blue-700 text-blue-700 dark:text-blue-300":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),children:[e.jsx(Wi,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:C("filters.button")}),e.jsx(ft,{className:he("w-4 h-4 transition-transform",z&&"rotate-180")})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>R(!0),className:"p-2 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors border border-gray-300 dark:border-gray-600",title:C("buttons.help"),children:e.jsx(Ui,{className:"w-4 h-4"})}),e.jsx("div",{className:"relative",children:u.length>0?e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>_(!j),className:"flex items-center gap-2 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium",title:C("buttons.prdsAvailable",{count:u.length}),children:[e.jsx(et,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:C("buttons.prds")}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-purple-500 rounded-full min-w-[1.25rem] text-center",children:u.length}),e.jsx(ft,{className:he("w-3 h-3 transition-transform hidden sm:block",j&&"rotate-180")})]}),j&&e.jsx("div",{className:"absolute right-0 top-full mt-2 w-56 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-xl z-30",children:e.jsxs("div",{className:"p-2",children:[e.jsxs("button",{onClick:()=>{c?.(),_(!1)},className:"w-full text-left px-3 py-2 text-sm font-medium text-purple-700 dark:text-purple-300 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded flex items-center gap-2",children:[e.jsx(tt,{className:"w-4 h-4"}),C("buttons.createNewPRD")]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 my-1"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 px-3 py-1 font-medium",children:C("gettingStarted.steps.createPRD.existingPRDs")}),u.map(J=>e.jsxs("button",{onClick:async()=>{try{const Q=await Ge.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(J.name)}`);if(Q.ok){const le=await Q.json();c?.({name:J.name,content:le.content,isExisting:!0}),_(!1)}}catch(Q){console.error("Error loading PRD:",Q)}},className:"w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded flex items-center gap-2",title:C("prd.modified",{date:new Date(J.modified).toLocaleDateString()}),children:[e.jsx(et,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate",children:J.name})]},J.name))]})})]}):e.jsxs("button",{onClick:()=>{c?.()},className:"flex items-center gap-2 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium",title:C("buttons.addPRD"),children:[e.jsx(et,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:C("buttons.addPRD")})]})}),(o?.taskMasterConfigured||o?.taskmaster?.hasTaskmaster||V?.hasTaskmaster||t.length>0)&&e.jsxs("button",{onClick:()=>B(!0),className:"flex items-center gap-2 px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium",title:C("buttons.addTask"),children:[e.jsx(tt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:C("buttons.addTask")})]})]})]})]}),z&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:C("filters.status")}),e.jsxs("select",{value:x,onChange:J=>h(J.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:C("filters.allStatuses")}),b.map(J=>e.jsx("option",{value:J,children:C(`statuses.${J}`,J.charAt(0).toUpperCase()+J.slice(1).replace("-"," "))},J))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:C("filters.priority")}),e.jsxs("select",{value:f,onChange:J=>g(J.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:C("filters.allPriorities")}),N.map(J=>e.jsx("option",{value:J,children:C(`priorities.${J}`,J.charAt(0).toUpperCase()+J.slice(1))},J))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:C("filters.sortBy")}),e.jsxs("select",{value:`${k}-${S}`,onChange:J=>{const[Q,le]=J.target.value.split("-");w(Q),y(le)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"id-asc",children:C("sort.idAsc")}),e.jsx("option",{value:"id-desc",children:C("sort.idDesc")}),e.jsx("option",{value:"title-asc",children:C("sort.titleAsc")}),e.jsx("option",{value:"title-desc",children:C("sort.titleDesc")}),e.jsx("option",{value:"status-asc",children:C("sort.statusAsc")}),e.jsx("option",{value:"status-desc",children:C("sort.statusDesc")}),e.jsx("option",{value:"priority-asc",children:C("sort.priorityAsc")}),e.jsx("option",{value:"priority-desc",children:C("sort.priorityDesc")})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:C("filters.showing",{filtered:W.length,total:t.length})}),e.jsx("button",{onClick:q,className:"text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium",children:C("filters.clearFilters")})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>O("id"),className:he("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",k==="id"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[C("sort.id")," ",Z("id")]}),e.jsxs("button",{onClick:()=>O("status"),className:he("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",k==="status"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[C("sort.status")," ",Z("status")]}),e.jsxs("button",{onClick:()=>O("priority"),className:he("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",k==="priority"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[C("sort.priority")," ",Z("priority")]})]}),W.length===0?e.jsx("div",{className:"text-center py-12",children:e.jsxs("div",{className:"text-gray-500 dark:text-gray-400",children:[e.jsx(sr,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:C("noMatchingTasks.title")}),e.jsx("p",{className:"text-sm",children:C("noMatchingTasks.description")})]})}):v==="kanban"?e.jsx("div",{className:he("grid gap-6",A.length===1&&"grid-cols-1 max-w-md mx-auto",A.length===2&&"grid-cols-1 md:grid-cols-2",A.length===3&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",A.length===4&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-4",A.length===5&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5",A.length>=6&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6"),children:A.map(J=>e.jsxs("div",{className:he("rounded-xl border shadow-sm transition-shadow hover:shadow-md",J.color),children:[e.jsx("div",{className:he("px-4 py-3 rounded-t-xl border-b",J.headerColor),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold text-sm",children:J.title}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-xs font-medium px-2 py-1 bg-white/60 dark:bg-black/20 rounded-full",children:J.tasks.length})})]})}),e.jsx("div",{className:"p-3 space-y-3 min-h-[200px] max-h-[calc(100vh-300px)] overflow-y-auto",children:J.tasks.length===0?e.jsxs("div",{className:"text-center py-8 text-gray-400 dark:text-gray-500",children:[e.jsx("div",{className:"w-8 h-8 mx-auto mb-2 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center",children:e.jsx("div",{className:"w-3 h-3 rounded-full bg-gray-300 dark:bg-gray-600"})}),e.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:C("kanban.noTasksYet")}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:J.status==="pending"?C("kanban.tasksWillAppear"):J.status==="in-progress"?C("kanban.moveTasksHere"):J.status==="done"?C("kanban.completedTasksHere"):C("kanban.statusTasksHere")})]}):J.tasks.map(Q=>e.jsx("div",{className:"transform transition-transform hover:scale-[1.02]",children:e.jsx(Kn,{task:Q,onClick:()=>r?.(Q),showParent:a,className:"w-full shadow-sm hover:shadow-md transition-shadow cursor-pointer"})},Q.id))})]},J.id))}):e.jsx("div",{className:he("gap-4",v==="grid"?"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3":"space-y-4"),children:W.map(J=>e.jsx(Kn,{task:J,onClick:()=>r?.(J),showParent:a,className:v==="grid"?"h-full":""},J.id))}),F&&e.jsx($p,{currentProject:o,onClose:()=>B(!1),onTaskCreated:()=>{B(!1),i&&i()}}),$&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl max-h-[90vh] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(et,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:C("helpGuide.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:C("helpGuide.subtitle")})]})]}),e.jsx("button",{onClick:()=>R(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-120px)]",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/50 dark:to-indigo-950/50 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-blue-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:C("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:C("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{c?.(),R(!1)},className:"inline-flex items-center gap-2 text-sm bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 px-3 py-1.5 rounded-lg hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors",children:[e.jsx(et,{className:"w-4 h-4"}),C("buttons.addPRD")]})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-green-50 to-emerald-50 dark:from-green-950/50 dark:to-emerald-950/50 rounded-lg border border-green-200 dark:border-green-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-green-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:C("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:C("gettingStarted.steps.generateTasks.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-green-200 dark:border-green-700/50 p-3 mb-2",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:C("helpGuide.examples.parsePRD")})})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-amber-50 to-orange-50 dark:from-amber-950/50 dark:to-orange-950/50 rounded-lg border border-amber-200 dark:border-amber-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-amber-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:C("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:C("gettingStarted.steps.analyzeTasks.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-amber-200 dark:border-amber-700/50 p-3 mb-2",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:C("helpGuide.examples.expandTask")})})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-purple-50 to-pink-50 dark:from-purple-950/50 dark:to-pink-950/50 rounded-lg border border-purple-200 dark:border-purple-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-purple-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"4"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:C("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:C("gettingStarted.steps.startBuilding.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-purple-200 dark:border-purple-700/50 p-3 mb-3",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:C("helpGuide.examples.addTask")})}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:C("helpGuide.moreExamples")})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-3",children:C("helpGuide.proTips.title")}),e.jsxs("ul",{className:"space-y-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full mt-2 flex-shrink-0"}),C("helpGuide.proTips.search")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-green-500 rounded-full mt-2 flex-shrink-0"}),C("helpGuide.proTips.views")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-purple-500 rounded-full mt-2 flex-shrink-0"}),C("helpGuide.proTips.filters")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-orange-500 rounded-full mt-2 flex-shrink-0"}),C("helpGuide.proTips.details")]})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-blue-50 dark:bg-blue-950/50 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-3",children:C("helpGuide.learnMore.title")}),e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-3",children:C("helpGuide.learnMore.description")}),e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm bg-blue-600 hover:bg-blue-700 text-white px-3 py-2 rounded-lg font-medium transition-colors",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),C("helpGuide.learnMore.githubButton"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]})})]})})]})},_p=({file:t,onClose:r,projectPath:s,project:a,initialContent:n="",isNewFile:o=!1,onSave:i})=>{const[c,u]=l.useState(n),[d,m]=l.useState(!o),[p,x]=l.useState(!1),[h,f]=l.useState(!1),[g,k]=l.useState(!0),[w,S]=l.useState(!1),[y,v]=l.useState(!1),[T,z]=l.useState(!0),[I,F]=l.useState(""),[B,D]=l.useState(!1),[H,$]=l.useState(!1),[R,E]=l.useState([]),U=l.useRef(null),j=`# Product Requirements Document - Example Project
250
-
251
- ## 1. Overview
252
- **Product Name:** AI-Powered Task Manager
253
- **Version:** 1.0
254
- **Date:** 2024-12-27
255
- **Author:** Development Team
256
-
257
- This document outlines the requirements for building an AI-powered task management application that integrates with development workflows and provides intelligent task breakdown and prioritization.
258
-
259
- ## 2. Objectives
260
- - Create an intuitive task management system that works seamlessly with developer tools
261
- - Provide AI-powered task generation from high-level requirements
262
- - Enable real-time collaboration and progress tracking
263
- - Integrate with popular development environments (VS Code, Cursor, etc.)
264
-
265
- ### Success Metrics
266
- - User adoption rate > 80% within development teams
267
- - Task completion rate improvement of 25%
268
- - Time-to-delivery reduction of 15%
269
-
270
- ## 3. User Stories
271
-
272
- ### Core Functionality
273
- - As a project manager, I want to create PRDs that automatically generate detailed tasks so I can save time on project planning
274
- - As a developer, I want to see my next task clearly highlighted so I can maintain focus
275
- - As a team lead, I want to track progress across multiple projects so I can provide accurate status updates
276
- - As a developer, I want tasks to be broken down into implementable subtasks so I can work more efficiently
277
-
278
- ### AI Integration
279
- - As a user, I want to describe a feature in natural language and get detailed implementation tasks so I can start working immediately
280
- - As a project manager, I want the AI to analyze task complexity and suggest appropriate time estimates
281
- - As a developer, I want intelligent task prioritization based on dependencies and deadlines
282
-
283
- ### Collaboration
284
- - As a team member, I want to see real-time updates when tasks are completed so I can coordinate my work
285
- - As a stakeholder, I want to view project progress through intuitive dashboards
286
- - As a developer, I want to add implementation notes to tasks for future reference
287
-
288
- ## 4. Functional Requirements
289
-
290
- ### Task Management
291
- - Create, edit, and delete tasks with rich metadata (priority, status, dependencies, estimates)
292
- - Hierarchical task structure with subtasks and sub-subtasks
293
- - Real-time status updates and progress tracking
294
- - Dependency management with circular dependency detection
295
- - Bulk operations (move, update status, assign)
296
-
297
- ### AI Features
298
- - Natural language PRD parsing to generate structured tasks
299
- - Intelligent task breakdown with complexity analysis
300
- - Automated subtask generation with implementation details
301
- - Smart dependency suggestion
302
- - Progress prediction based on historical data
303
-
304
- ### Integration Features
305
- - VS Code/Cursor extension for in-editor task management
306
- - Git integration for linking commits to tasks
307
- - API for third-party tool integration
308
- - Webhook support for external notifications
309
- - CLI tool for command-line task management
310
-
311
- ### User Interface
312
- - Responsive web application (desktop and mobile)
313
- - Multiple view modes (Kanban, list, calendar)
314
- - Dark/light theme support
315
- - Drag-and-drop task organization
316
- - Advanced filtering and search capabilities
317
- - Keyboard shortcuts for power users
318
-
319
- ## 5. Technical Requirements
320
-
321
- ### Frontend
322
- - React.js with TypeScript for type safety
323
- - Modern UI framework (Tailwind CSS)
324
- - State management (Context API or Redux)
325
- - Real-time updates via WebSockets
326
- - Progressive Web App (PWA) support
327
- - Accessibility compliance (WCAG 2.1 AA)
328
-
329
- ### Backend
330
- - Node.js with Express.js framework
331
- - RESTful API design with OpenAPI documentation
332
- - Real-time communication via Socket.io
333
- - Background job processing
334
- - Rate limiting and security middleware
335
-
336
- ### AI Integration
337
- - Integration with multiple AI providers (OpenAI, Anthropic, etc.)
338
- - Fallback model support
339
- - Context-aware prompt engineering
340
- - Token usage optimization
341
- - Model response caching
342
-
343
- ### Database
344
- - Primary: PostgreSQL for relational data
345
- - Cache: Redis for session management and real-time features
346
- - Full-text search capabilities
347
- - Database migrations and seeding
348
- - Backup and recovery procedures
349
-
350
- ### Infrastructure
351
- - Docker containerization
352
- - Cloud deployment (AWS/GCP/Azure)
353
- - Auto-scaling capabilities
354
- - Monitoring and logging (structured logging)
355
- - CI/CD pipeline with automated testing
356
-
357
- ## 6. Non-Functional Requirements
358
-
359
- ### Performance
360
- - Page load time < 2 seconds
361
- - API response time < 500ms for 95% of requests
362
- - Support for 1000+ concurrent users
363
- - Efficient handling of large task lists (10,000+ tasks)
364
-
365
- ### Security
366
- - JWT-based authentication with refresh tokens
367
- - Role-based access control (RBAC)
368
- - Data encryption at rest and in transit
369
- - Regular security audits and penetration testing
370
- - GDPR and privacy compliance
371
-
372
- ### Reliability
373
- - 99.9% uptime SLA
374
- - Graceful error handling and recovery
375
- - Data backup every 6 hours with point-in-time recovery
376
- - Disaster recovery plan with RTO < 4 hours
377
-
378
- ### Scalability
379
- - Horizontal scaling for both frontend and backend
380
- - Database read replicas for query optimization
381
- - CDN for static asset delivery
382
- - Microservices architecture for future expansion
383
-
384
- ## 7. User Experience Design
385
-
386
- ### Information Architecture
387
- - Intuitive navigation with breadcrumbs
388
- - Context-aware menus and actions
389
- - Progressive disclosure of complex features
390
- - Consistent design patterns throughout
391
-
392
- ### Interaction Design
393
- - Smooth animations and transitions
394
- - Immediate feedback for user actions
395
- - Undo/redo functionality for critical operations
396
- - Smart defaults and auto-save features
397
-
398
- ### Visual Design
399
- - Modern, clean interface with plenty of whitespace
400
- - Consistent color scheme and typography
401
- - Clear visual hierarchy with proper contrast ratios
402
- - Iconography that supports comprehension
403
-
404
- ## 8. Integration Requirements
405
-
406
- ### Development Tools
407
- - VS Code extension with task panel and quick actions
408
- - Cursor IDE integration with AI task suggestions
409
- - Terminal CLI for command-line workflow
410
- - Browser extension for web-based tools
411
-
412
- ### Third-Party Services
413
- - GitHub/GitLab integration for issue sync
414
- - Slack/Discord notifications
415
- - Calendar integration (Google Calendar, Outlook)
416
- - Time tracking tools (Toggl, Harvest)
417
-
418
- ### APIs and Webhooks
419
- - RESTful API with comprehensive documentation
420
- - GraphQL endpoint for complex queries
421
- - Webhook system for external integrations
422
- - SDK development for major programming languages
423
-
424
- ## 9. Implementation Phases
425
-
426
- ### Phase 1: Core MVP (8-10 weeks)
427
- - Basic task management (CRUD operations)
428
- - Simple AI task generation
429
- - Web interface with essential features
430
- - User authentication and basic permissions
431
-
432
- ### Phase 2: Enhanced Features (6-8 weeks)
433
- - Advanced AI features (complexity analysis, subtask generation)
434
- - Real-time collaboration
435
- - Mobile-responsive design
436
- - Integration with one development tool (VS Code)
437
-
438
- ### Phase 3: Enterprise Features (4-6 weeks)
439
- - Advanced user management and permissions
440
- - API and webhook system
441
- - Performance optimization
442
- - Comprehensive testing and security audit
443
-
444
- ### Phase 4: Ecosystem Expansion (4-6 weeks)
445
- - Additional tool integrations
446
- - Mobile app development
447
- - Advanced analytics and reporting
448
- - Third-party marketplace preparation
449
-
450
- ## 10. Risk Assessment
451
-
452
- ### Technical Risks
453
- - AI model reliability and cost management
454
- - Real-time synchronization complexity
455
- - Database performance with large datasets
456
- - Integration complexity with multiple tools
457
-
458
- ### Business Risks
459
- - User adoption in competitive market
460
- - AI provider dependency
461
- - Data privacy and security concerns
462
- - Feature scope creep and timeline delays
463
-
464
- ### Mitigation Strategies
465
- - Implement robust error handling and fallback systems
466
- - Develop comprehensive testing strategy
467
- - Create detailed documentation and user guides
468
- - Establish clear project scope and change management process
469
-
470
- ## 11. Success Criteria
471
-
472
- ### Development Milestones
473
- - Alpha version with core features completed
474
- - Beta version with selected user group feedback
475
- - Production-ready version with full feature set
476
- - Post-launch iterations based on user feedback
477
-
478
- ### Business Metrics
479
- - User engagement and retention rates
480
- - Task completion and productivity metrics
481
- - Customer satisfaction scores (NPS > 50)
482
- - Revenue targets and subscription growth
483
-
484
- ## 12. Appendices
485
-
486
- ### Glossary
487
- - **PRD**: Product Requirements Document
488
- - **AI**: Artificial Intelligence
489
- - **CRUD**: Create, Read, Update, Delete
490
- - **API**: Application Programming Interface
491
- - **CI/CD**: Continuous Integration/Continuous Deployment
492
-
493
- ### References
494
- - Industry best practices for task management
495
- - AI integration patterns and examples
496
- - Security and compliance requirements
497
- - Performance benchmarking data
498
-
499
- ---
500
-
501
- **Document Control:**
502
- - Version: 1.0
503
- - Last Updated: December 27, 2024
504
- - Next Review: January 15, 2025
505
- - Approved By: Product Owner, Technical Lead`;l.useEffect(()=>{(async()=>{if(t?.name)F(t.name.replace(/\.(txt|md)$/,""));else if(o){const W=new Date().toISOString().split("T")[0];F(`prd-${W}`)}if(o){u(j),m(!1);return}if(t.content){u(t.content),m(!1);return}try{m(!0);const N=await Ge.readFile(t.projectName,t.path);if(!N.ok)throw new Error(`Failed to load file: ${N.status} ${N.statusText}`);const W=await N.json();u(W.content||j)}catch(N){console.error("Error loading PRD file:",N),u(`# Error Loading PRD
506
-
507
- Error: ${N.message}
508
-
509
- File: ${t?.name||"New PRD"}
510
- Path: ${t?.path||"Not saved yet"}
511
-
512
- ${j}`)}finally{m(!1)}})()},[t,s,o]),l.useEffect(()=>{(async()=>{if(!a?.name){console.log("No project name available:",a);return}try{console.log("Fetching PRDs for project:",a.name);const N=await Ge.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(N.ok){const W=await N.json();console.log("Fetched existing PRDs:",W.prds),E(W.prds||[])}else console.log("Failed to fetch PRDs:",N.status,N.statusText)}catch(N){console.error("Error fetching existing PRDs:",N)}})()},[a?.name]);const _=async()=>{if(!c.trim()){alert("Please add content before saving.");return}if(!I.trim()){alert("Please provide a filename for the PRD.");return}const b=I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,N=R.find(W=>W.name===b);if(console.log("Save check:",{fullFileName:b,existingPRDs:R,existingFile:N,isExisting:t?.isExisting,fileObject:t,shouldShowModal:N&&!t?.isExisting}),N&&!t?.isExisting){console.log("Showing overwrite confirmation modal"),$(!0);return}await V()},V=async()=>{x(!0);try{const b=I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,N=await we(`/api/taskmaster/prd/${encodeURIComponent(a?.name)}`,{method:"POST",body:JSON.stringify({fileName:b,content:c})});if(!N.ok){const A=await N.json();throw new Error(A.message||`Save failed: ${N.status}`)}S(!0),setTimeout(()=>S(!1),2e3);const W=await Ge.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(W.ok){const A=await W.json();E(A.prds||[])}i&&await i()}catch(b){console.error("Error saving PRD:",b),alert(`Error saving PRD: ${b.message}`)}finally{x(!1)}},ee=()=>{const b=new Blob([c],{type:"text/markdown"}),N=URL.createObjectURL(b),W=document.createElement("a");W.href=N;const A=I?`${I}.txt`:"prd.txt";W.download=A,document.body.appendChild(W),W.click(),document.body.removeChild(W),URL.revokeObjectURL(N)},M=async()=>{if(!c.trim()){alert("Please add content to the PRD before generating tasks.");return}D(!0)},G=()=>{f(!h)};l.useEffect(()=>{const b=N=>{(N.ctrlKey||N.metaKey)&&(N.key==="s"?(N.preventDefault(),_()):N.key==="Escape"&&(N.preventDefault(),r()))};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[c]);const C=b=>b.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/^\- (.*$)/gim,"<li>$1</li>").replace(/(<li>.*<\/li>)/gims,"<ul>$1</ul>").replace(/\n\n/gim,"</p><p>").replace(/^(?!<[h|u|l])(.*$)/gim,"<p>$1</p>").replace(/<\/ul>\s*<ul>/gim,"");return d?e.jsx("div",{className:"fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center",children:e.jsx("div",{className:"w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center bg-white dark:bg-gray-900",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading PRD..."})]})})}):e.jsxs("div",{className:`fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${h?"md:p-0":""}`,children:[e.jsxs("div",{className:he("bg-white dark:bg-gray-900 shadow-2xl flex flex-col","w-full h-full md:rounded-lg md:shadow-2xl",h?"md:w-full md:h-full md:rounded-none":"md:w-full md:max-w-6xl md:h-[85vh] md:max-h-[85vh]"),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-600 rounded flex items-center justify-center flex-shrink-0",children:e.jsx(et,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center min-w-0 flex-1 bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md px-3 py-2 focus-within:ring-2 focus-within:ring-purple-500 focus-within:border-purple-500 dark:focus-within:ring-purple-400 dark:focus-within:border-purple-400",children:[e.jsx("input",{type:"text",value:I,onChange:b=>{const N=b.target.value.replace(/[<>:"/\\|?*]/g,"");F(N)},className:"font-medium text-gray-900 dark:text-white bg-transparent border-none outline-none min-w-0 flex-1 text-base sm:text-sm placeholder-gray-400 dark:placeholder-gray-500",placeholder:"Enter PRD filename",maxLength:100}),e.jsx("span",{className:"text-sm sm:text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap ml-1",children:".txt"})]}),e.jsx("button",{onClick:()=>document.querySelector('input[placeholder="Enter PRD filename"]')?.focus(),className:"p-1 text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 transition-colors",title:"Click to edit filename",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:"text-xs bg-purple-100 dark:bg-purple-900 text-purple-600 dark:text-purple-300 px-2 py-1 rounded whitespace-nowrap",children:"📋 PRD"}),o&&e.jsx("span",{className:"text-xs bg-green-100 dark:bg-green-900 text-green-600 dark:text-green-300 px-2 py-1 rounded whitespace-nowrap",children:"✨ New"})]})]}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:"Product Requirements Document"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>v(!y),className:he("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",y?"text-purple-600 dark:text-purple-400 bg-purple-50 dark:bg-purple-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:y?"Switch to edit mode":"Preview markdown",children:e.jsx(ar,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsx("button",{onClick:()=>z(!T),className:he("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",T?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:T?"Disable word wrap":"Enable word wrap",children:e.jsx("span",{className:"text-sm md:text-xs font-mono font-bold",children:"↵"})}),e.jsx("button",{onClick:()=>k(!g),className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Toggle theme",children:e.jsx("span",{className:"text-lg md:text-base",children:g?"☀️":"🌙"})}),e.jsx("button",{onClick:ee,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Download PRD",children:e.jsx(cs,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsxs("button",{onClick:M,disabled:!c.trim(),className:he("px-3 py-2 rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors text-sm font-medium","bg-purple-600 hover:bg-purple-700 text-white","min-h-[44px] md:min-h-0"),title:"Generate tasks from PRD content",children:[e.jsx(Ft,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:"Generate Tasks"})]}),e.jsx("button",{onClick:_,disabled:p,className:he("px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors","min-h-[44px] md:min-h-0",w?"bg-green-600 hover:bg-green-700":"bg-purple-600 hover:bg-purple-700"),children:w?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"hidden sm:inline",children:"Saved!"})]}):e.jsxs(e.Fragment,{children:[e.jsx(is,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Saving...":"Save PRD"})]})}),e.jsx("button",{onClick:G,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:h?"Exit fullscreen":"Fullscreen",children:h?e.jsx(no,{className:"w-4 h-4"}):e.jsx(wa,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Close",children:e.jsx(qe,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:y?e.jsx("div",{className:"h-full overflow-y-auto p-6 prose prose-gray dark:prose-invert max-w-none",children:e.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:C(c)}})}):e.jsx(co,{ref:U,value:c,onChange:u,extensions:[mo(),...T?[qt.lineWrapping]:[]],theme:g?uo:void 0,height:"100%",style:{fontSize:"14px",height:"100%"},basicSetup:{lineNumbers:!0,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:["Lines: ",c.split(`
513
- `).length]}),e.jsxs("span",{children:["Characters: ",c.length]}),e.jsxs("span",{children:["Words: ",c.split(/\s+/).filter(b=>b.length>0).length]}),e.jsx("span",{children:"Format: Markdown"})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]}),B&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ft,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Generate Tasks from PRD"})]}),e.jsx("button",{onClick:()=>D(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ft,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-purple-900 dark:text-purple-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-purple-800 dark:text-purple-200 mb-3",children:"You can simply ask your AI assistant in the chat to parse your PRD and generate tasks. The AI assistant will automatically save your PRD and create detailed tasks with implementation details."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-purple-200 dark:border-purple-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"💬 Example:"}),e.jsxs("p",{className:"text-xs text-gray-900 dark:text-white font-mono",children:[`"I've just initialized a new project with Claude Task Master. I have a PRD at .taskmaster/docs/`,I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,'. Can you help me parse it and set up the initial tasks?"']})]}),e.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[e.jsx("strong",{children:"This will:"})," Save your PRD, analyze its content, and generate structured tasks with subtasks, dependencies, and implementation details."]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:()=>D(!1),className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),H&&e.jsxs("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>$(!1)}),e.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"p-2 rounded-full mr-3 bg-yellow-100 dark:bg-yellow-900",children:e.jsx(Lt,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"File Already Exists"})]}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:['A PRD file named "',I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,'" already exists. Do you want to overwrite it with the current content?']}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>$(!1),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:async()=>{$(!1),await V()},className:"px-4 py-2 text-sm text-white bg-yellow-600 hover:bg-yellow-700 rounded-md flex items-center space-x-2 transition-colors",children:[e.jsx(is,{className:"w-4 h-4"}),e.jsx("span",{children:"Overwrite"})]})]})]})})]})]})},Rp=Lp,zp=_o,Op=_p,Bp="PRD saved successfully!";function Wp(t){return t.prdFiles||t.prds||[]}function Up({isVisible:t}){const{tasks:r=[],currentProject:s,refreshTasks:a}=yr(),[n,o]=l.useState(null),[i,c]=l.useState(!1),[u,d]=l.useState(!1),[m,p]=l.useState(null),[x,h]=l.useState([]),[f,g]=l.useState(null),k=l.useRef(null),w=l.useCallback(D=>{k.current&&clearTimeout(k.current),g(D),k.current=setTimeout(()=>{g(null),k.current=null},3e3)},[]),S=l.useCallback(async()=>{if(!s?.name){h([]);return}try{const D=await Ge.get(`/taskmaster/prd/${encodeURIComponent(s.name)}`);if(!D.ok){h([]);return}const H=await D.json();h(Wp(H))}catch(D){console.error("Failed to load existing PRDs:",D),h([])}},[s?.name]),y=l.useCallback(async(D=!1)=>{await S(),D&&w(Bp)},[S,w]);l.useEffect(()=>{S()},[S]),l.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]);const v=l.useCallback(D=>{if(!(!D||typeof D!="object"||!("id"in D))){if(!("title"in D)||!D.title){const H=r.find($=>String($.id)===String(D.id));H&&(o(H),c(!0));return}o(D),c(!0)}},[r]),T=l.useCallback(()=>{c(!1),o(null)},[]),z=l.useCallback((D,H)=>{console.log("Update task status:",D,H),a?.()},[a]),I=l.useCallback((D=null)=>{p(D),d(!0)},[]),F=l.useCallback(()=>{d(!1),p(null)},[]),B=l.useCallback(async()=>{F(),await y(!0),a?.()},[F,y,a]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`h-full ${t?"block":"hidden"}`,children:e.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:e.jsx(Rp,{tasks:r,onTaskClick:v,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:s,onTaskCreated:a||void 0,onShowPRDEditor:I,existingPRDs:x,onRefreshPRDs:(D=!1)=>{y(D)}})})}),i&&n&&e.jsx(zp,{task:n,isOpen:i,onClose:T,onStatusChange:z,onTaskClick:v}),u&&e.jsx(Op,{project:s,projectPath:s?.fullPath||s?.path,onClose:F,isNewFile:!m?.isExisting,file:{name:m?.name||"prd.txt",content:m?.content||""},onSave:B}),f&&e.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-2 duration-300",children:e.jsxs("div",{className:"bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"font-medium",children:f})]})})]})}function Hp(){const{isRelayConnected:t,isChecking:r}=ba(),[s,a]=l.useState(null),[n,o]=l.useState(!1),[i,c]=l.useState(!1),[u,d]=l.useState(!1),[m,p]=l.useState(!1);l.useEffect(()=>{if(t||p(!0),t&&m){d(!0),a(null);const f=setTimeout(()=>d(!1),3e3);return()=>clearTimeout(f)}},[t,m]);const x=l.useCallback(async()=>{try{o(!0);const f=await Ge.relay.createToken(`web-${Date.now()}`);if(f.ok){const g=await f.json();a(g.token)}}catch{}finally{o(!1)}},[]),h=l.useCallback(()=>{if(!s)return;const f=`npx upfynai-code connect --server ${window.location.host} --key ${s}`;navigator.clipboard.writeText(f),c(!0),setTimeout(()=>c(!1),2e3)},[s]);return r||t&&!u?null:t&&u?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-green-500/10 border-b border-green-500/20 text-green-400 text-sm",children:[e.jsx(Ga,{className:"w-4 h-4"}),e.jsx("span",{children:"Machine connected"})]}):e.jsxs("div",{className:"border-b border-amber-500/20 bg-amber-500/10",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(Yn,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-amber-300",children:"Connect your machine to get started"}),!s&&e.jsxs("button",{onClick:x,disabled:n,className:"ml-auto flex items-center gap-1.5 px-3 py-1 text-xs font-medium rounded-md bg-amber-500/20 hover:bg-amber-500/30 text-amber-300 transition-colors disabled:opacity-50",children:[n?e.jsx(mr,{className:"w-3 h-3 animate-spin"}):e.jsx(Ga,{className:"w-3 h-3"}),"Start Listening"]})]}),s&&e.jsxs("div",{className:"px-4 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:[e.jsxs("code",{className:"text-xs text-foreground flex-1 overflow-x-auto whitespace-nowrap",children:["npx upfynai-code connect --server ",window.location.host," --key ",s]}),e.jsx("button",{onClick:h,className:"flex-shrink-0 p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",title:"Copy command",children:i?e.jsx(vt,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(ka,{className:"w-3.5 h-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1.5",children:"Run this command in your terminal to connect"})]})]})}function ss({children:t,fallback:r,bypass:s}){const{isRelayConnected:a}=ba();return s||a?e.jsx(e.Fragment,{children:t}):e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 backdrop-blur-sm",children:r}),e.jsx("div",{className:"h-full w-full opacity-30 pointer-events-none select-none","aria-hidden":!0,children:t})]})}function Cs({icon:t,label:r}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[e.jsx(t,{className:"w-10 h-10 opacity-40"}),e.jsxs("p",{className:"text-sm font-medium",children:[r," requires a connected machine"]}),e.jsx("p",{className:"text-xs opacity-60",children:"Connect your machine to get started"})]})}function Gp(){return e.jsx(Cs,{icon:Ca,label:"Chat"})}function qp(){return e.jsx(Cs,{icon:at,label:"Shell"})}function Kp(){return e.jsx(Cs,{icon:qi,label:"Files"})}function Vp(){return e.jsx(Cs,{icon:$t,label:"Git"})}function Jp({selectedProject:t,isMobile:r,initialWidth:s=600}){const[a,n]=l.useState(null),[o,i]=l.useState(s),[c,u]=l.useState(!1),[d,m]=l.useState(!1),p=l.useRef(null),x=l.useCallback((k,w=null)=>{const y=k.replace(/\\/g,"/").split("/").pop()||k;n({name:y,path:k,projectName:t?.name,diffInfo:w})},[t?.name]),h=l.useCallback(()=>{n(null),u(!1)},[]),f=l.useCallback(()=>{u(k=>!k)},[]),g=l.useCallback(k=>{r||(m(!0),k.preventDefault())},[r]);return l.useEffect(()=>{const k=S=>{if(!d)return;const y=p.current?.parentElement;if(!y)return;const v=y.getBoundingClientRect(),T=v.right-S.clientX,z=300,I=v.width*.8;T>=z&&T<=I&&i(T)},w=()=>{m(!1)};return d&&(document.addEventListener("mousemove",k),document.addEventListener("mouseup",w),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",w),document.body.style.cursor="",document.body.style.userSelect=""}},[d]),{editingFile:a,editorWidth:o,editorExpanded:c,resizeHandleRef:p,handleFileOpen:x,handleCloseEditor:h,handleToggleEditorExpand:f,handleResizeStart:g}}const Yp=l.lazy(()=>io(()=>import("./CanvasPanel-Cig0Mo9s.js"),__vite__mapDeps([4,3,1,2,5,6]))),Qp=Qi,Xp=up;function Zp({selectedProject:t,selectedSession:r,activeTab:s,setActiveTab:a,ws:n,sendMessage:o,latestMessage:i,isMobile:c,onMenuClick:u,isLoading:d,onInputFocusChange:m,onSessionActive:p,onSessionInactive:x,onSessionProcessing:h,onSessionNotProcessing:f,processingSessions:g,onReplaceTemporarySession:k,onNavigateToSession:w,onShowSettings:S,externalMessageUpdate:y}){const{preferences:v}=Ta(),{autoExpandTools:T,showRawParameters:z,showThinking:I,autoScrollToBottom:F,sendByCtrlEnter:B}=v,{currentProject:D,setCurrentProject:H}=yr(),{tasksEnabled:$,isTaskMasterInstalled:R}=Or(),E=$!==!1,{editingFile:U,editorWidth:j,editorExpanded:_,resizeHandleRef:V,handleFileOpen:ee,handleCloseEditor:M,handleToggleEditorExpand:G,handleResizeStart:C}=Jp({selectedProject:t,isMobile:c});return l.useEffect(()=>{t&&t!==D&&H?.(t)},[t,D,H]),l.useEffect(()=>{!E&&s==="tasks"&&a("chat")},[E,s,a]),d?e.jsx(Wn,{mode:"loading",isMobile:c,onMenuClick:u}):t?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(bp,{activeTab:s,setActiveTab:a,selectedProject:t,selectedSession:r,shouldShowTasksTab:E,isMobile:c,onMenuClick:u}),e.jsx(Hp,{}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:`flex flex-col min-h-0 overflow-hidden ${_?"hidden":""} ${s==="files"&&U?"w-[280px] flex-shrink-0":"flex-1"}`,children:[e.jsx("div",{className:`h-full ${s==="chat"?"block":"hidden"}`,children:e.jsx(ss,{fallback:e.jsx(Gp,{}),children:e.jsx(On,{showDetails:!0,children:e.jsx(op,{selectedProject:t,selectedSession:r,ws:n,sendMessage:o,latestMessage:i,onFileOpen:ee,onInputFocusChange:m,onSessionActive:p,onSessionInactive:x,onSessionProcessing:h,onSessionNotProcessing:f,processingSessions:g,onReplaceTemporarySession:k,onNavigateToSession:w,onShowSettings:S,autoExpandTools:T,showRawParameters:z,showThinking:I,autoScrollToBottom:F,sendByCtrlEnter:B,externalMessageUpdate:y,onShowAllTasks:$?()=>a("tasks"):null})})})}),s==="canvas"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(On,{showDetails:!0,children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading canvas..."}),children:e.jsx(Yp,{})})})}),s==="files"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(ss,{fallback:e.jsx(Kp,{}),children:e.jsx(dp,{selectedProject:t,onFileOpen:ee})})}),s==="shell"&&e.jsx("div",{className:"h-full w-full overflow-hidden",children:e.jsx(ss,{fallback:e.jsx(qp,{}),children:e.jsx(Qp,{project:t,session:r,showHeader:!1})})}),s==="git"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(ss,{fallback:e.jsx(Vp,{}),children:e.jsx(Xp,{selectedProject:t,isMobile:c,onFileOpen:ee})})}),E&&e.jsx(Up,{isVisible:s==="tasks"}),e.jsx("div",{className:`h-full overflow-hidden ${s==="preview"?"block":"hidden"}`})]}),e.jsx(Fp,{editingFile:U,isMobile:c,editorExpanded:_,editorWidth:j,resizeHandleRef:V,onResizeStart:C,onCloseEditor:M,onToggleEditorExpand:G,projectPath:t.path,fillSpace:s==="files"})]})]}):e.jsx(Wn,{mode:"empty",isMobile:c,onMenuClick:u})}const ex=Et.memo(Zp);function tx({activeTab:t,setActiveTab:r,isInputFocused:s}){const{tasksEnabled:a,isTaskMasterInstalled:n}=Or(),i=[{id:"chat",icon:Ca,label:"Chat",onClick:()=>r("chat")},{id:"shell",icon:at,label:"Shell",onClick:()=>r("shell")},{id:"files",icon:Vt,label:"Files",onClick:()=>r("files")},{id:"git",icon:$t,label:"Git",onClick:()=>r("git")},...!!(a&&n)?[{id:"tasks",icon:ao,label:"Tasks",onClick:()=>r("tasks")}]:[]];return e.jsx("div",{className:`fixed bottom-0 left-0 right-0 z-50 px-3 pb-[max(8px,env(safe-area-inset-bottom))] transform transition-transform duration-300 ease-in-out ${s?"translate-y-full":"translate-y-0"}`,children:e.jsx("div",{className:"nav-glass mobile-nav-float rounded-2xl border border-border/30",children:e.jsx("div",{className:"flex items-center justify-around px-1 py-1.5 gap-0.5",children:i.map(c=>{const u=c.icon,d=t===c.id;return e.jsxs("button",{onClick:c.onClick,onTouchStart:m=>{m.preventDefault(),c.onClick()},className:`flex flex-col items-center justify-center gap-0.5 px-3 py-2 rounded-xl flex-1 relative touch-manipulation transition-all duration-200 active:scale-95 ${d?"text-primary":"text-muted-foreground hover:text-foreground"}`,"aria-label":c.label,"aria-current":d?"page":void 0,children:[d&&e.jsx("div",{className:"absolute inset-0 bg-primary/8 dark:bg-primary/12 rounded-xl"}),e.jsx(u,{className:`relative z-10 transition-all duration-200 ${d?"w-5 h-5":"w-[18px] h-[18px]"}`,strokeWidth:d?2.4:1.8}),e.jsx("span",{className:`relative z-10 text-[10px] font-medium transition-all duration-200 ${d?"opacity-100":"opacity-60"}`,children:c.label})]},c.id)})})})})}function rx(){const[t,r]=l.useState(new Set),[s,a]=l.useState(new Set),n=l.useCallback(d=>{d&&r(m=>new Set([...m,d]))},[]),o=l.useCallback(d=>{d&&r(m=>{const p=new Set(m);return p.delete(d),p})},[]),i=l.useCallback(d=>{d&&a(m=>new Set([...m,d]))},[]),c=l.useCallback(d=>{d&&a(m=>{const p=new Set(m);return p.delete(d),p})},[]),u=l.useCallback(d=>{d&&r(m=>{const p=new Set;for(const x of m)x.startsWith("new-session-")||p.add(x);return p.add(d),p})},[]);return{activeSessions:t,processingSessions:s,markSessionAsActive:n,markSessionAsInactive:o,markSessionAsProcessing:i,markSessionAsNotProcessing:c,replaceTemporarySession:u}}const pt=t=>JSON.stringify(t??null),Vn=(t,r,s)=>t.length!==r.length?!0:r.some((a,n)=>{const o=t[n];return!o||a.name!==o.name||a.displayName!==o.displayName||a.fullPath!==o.fullPath||pt(a.sessionMeta)!==pt(o.sessionMeta)||pt(a.sessions)!==pt(o.sessions)?!0:pt(a.cursorSessions)!==pt(o.cursorSessions)||pt(a.codexSessions)!==pt(o.codexSessions)}),vs=t=>[...t.sessions??[],...t.codexSessions??[],...t.cursorSessions??[]],sx=(t,r,s,a)=>{if(!s||!a)return!0;const n=t.find(u=>u.name===s.name),o=r.find(u=>u.name===s.name);if(!n||!o)return!1;const i=vs(n).find(u=>u.id===a.id),c=vs(o).find(u=>u.id===a.id);return!i||!c?!1:i.id===c.id&&i.title===c.title&&i.created_at===c.created_at&&i.updated_at===c.updated_at};function ax({sessionId:t,navigate:r,latestMessage:s,isMobile:a,activeSessions:n}){const[o,i]=l.useState([]),[c,u]=l.useState(null),[d,m]=l.useState(null),[p,x]=l.useState("chat"),[h,f]=l.useState(!1),[g,k]=l.useState(!0),[w,S]=l.useState(null),[y,v]=l.useState(!1),[T,z]=l.useState(!1),[I,F]=l.useState("agents"),[B,D]=l.useState(0),H=l.useRef(null),$=l.useCallback(async()=>{try{k(!0);const C=await(await Ge.projects()).json();i(b=>b.length===0||Vn(b,C,!0)?C:b)}catch(G){console.error("Error fetching projects:",G)}finally{k(!1)}},[]),R=l.useCallback((G="tools")=>{F(G),z(!0)},[]);l.useEffect(()=>{$()},[$]),l.useEffect(()=>{!g&&o.length===1&&!c&&!t&&u(o[0])},[g,o,c,t]),l.useEffect(()=>{if(!s)return;if(s.type==="loading_progress"){H.current&&(clearTimeout(H.current),H.current=null),S(s),s.phase==="complete"&&(H.current=setTimeout(()=>{S(null),H.current=null},500));return}if(s.type!=="projects_updated")return;const G=s;if(G.changedFile&&d&&c){const O=G.changedFile.replace(/\\/g,"/").split("/");O.length>=2&&O[O.length-1].replace(".jsonl","")===d.id&&(n.has(d.id)||D(Q=>Q+1))}const C=d&&n.has(d.id)||n.size>0&&Array.from(n).some(A=>A.startsWith("new-session-")),b=G.projects;if(C&&!sx(o,b,c,d)||(i(b),!c))return;const N=b.find(A=>A.name===c.name);if(!N||(pt(N)!==pt(c)&&u(N),!d))return;vs(N).find(A=>A.id===d.id)||m(null)},[s,c,d,n,o]),l.useEffect(()=>()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]),l.useEffect(()=>{if(!t||o.length===0)return;const G=!d||d.id!==t;for(const C of o){const b=C.sessions?.find(A=>A.id===t);if(b){const A=c?.name!==C.name,O=d?.id!==t||d.__provider!=="claude";A&&u(C),O&&m({...b,__provider:"claude"}),G&&x("chat");return}const N=C.cursorSessions?.find(A=>A.id===t);if(N){const A=c?.name!==C.name,O=d?.id!==t||d.__provider!=="cursor";A&&u(C),O&&m({...N,__provider:"cursor"}),G&&x("chat");return}const W=C.codexSessions?.find(A=>A.id===t);if(W){const A=c?.name!==C.name,O=d?.id!==t||d.__provider!=="codex";A&&u(C),O&&m({...W,__provider:"codex"}),G&&x("chat");return}}},[t,o,c?.name,d?.id,d?.__provider]);const E=l.useCallback(G=>{u(G),m(null),r("/"),a&&f(!1)},[a,r]),U=l.useCallback(G=>{if(m(G),p!=="git"&&p!=="preview"&&x("chat"),(localStorage.getItem("selected-provider")||"claude")==="cursor"&&sessionStorage.setItem("cursorSessionId",G.id),a){const b=G.__projectName,N=c?.name;b!==N&&f(!1)}r(`/session/${G.id}`)},[p,a,r,c?.name]),j=l.useCallback(G=>{u(G),m(null),x("chat"),r("/"),a&&f(!1)},[a,r]),_=l.useCallback(G=>{d?.id===G&&(m(null),r("/")),i(C=>C.map(b=>({...b,sessions:b.sessions?.filter(N=>N.id!==G)??[],sessionMeta:{...b.sessionMeta,total:Math.max(0,(b.sessionMeta?.total??0)-1)}})))},[r,d?.id]),V=l.useCallback(async()=>{try{const C=await(await Ge.projects()).json();if(i(W=>Vn(W,C,!0)?C:W),!c)return;const b=C.find(W=>W.name===c.name);if(!b||(pt(b)!==pt(c)&&u(b),!d))return;const N=vs(b).find(W=>W.id===d.id);if(N){const W=N.__provider||!d.__provider?N:{...N,__provider:d.__provider};pt(W)!==pt(d)&&m(W)}}catch(G){console.error("Error refreshing sidebar:",G)}},[c,d]),ee=l.useCallback(G=>{c?.name===G&&(u(null),m(null),r("/")),i(C=>C.filter(b=>b.name!==G))},[r,c?.name]),M=l.useMemo(()=>({projects:o,selectedProject:c,selectedSession:d,onProjectSelect:E,onSessionSelect:U,onNewSession:j,onSessionDelete:_,onProjectDelete:ee,isLoading:g,loadingProgress:w,onRefresh:V,onShowSettings:()=>z(!0),showSettings:T,settingsInitialTab:I,onCloseSettings:()=>z(!1),isMobile:a}),[j,ee,E,_,U,V,g,a,w,o,I,c,d,T]);return{projects:o,selectedProject:c,selectedSession:d,activeTab:p,sidebarOpen:h,isLoadingProjects:g,loadingProgress:w,isInputFocused:y,showSettings:T,settingsInitialTab:I,externalMessageUpdate:B,setActiveTab:x,setSidebarOpen:f,setIsInputFocused:v,setShowSettings:z,openSettings:R,fetchProjects:$,sidebarSharedProps:M,handleProjectSelect:E,handleSessionSelect:U,handleNewSession:j,handleSessionDelete:_,handleProjectDelete:ee,handleSidebarRefresh:V}}function nx(){const t=xi(),{sessionId:r}=gi(),{t:s}=Ue("common"),{isMobile:a}=Ea({trackPWA:!1}),{ws:n,sendMessage:o,latestMessage:i}=hi(),{activeSessions:c,processingSessions:u,markSessionAsActive:d,markSessionAsInactive:m,markSessionAsProcessing:p,markSessionAsNotProcessing:x,replaceTemporarySession:h}=rx(),{selectedProject:f,selectedSession:g,activeTab:k,sidebarOpen:w,isLoadingProjects:S,isInputFocused:y,externalMessageUpdate:v,setActiveTab:T,setSidebarOpen:z,setIsInputFocused:I,setShowSettings:F,openSettings:B,fetchProjects:D,sidebarSharedProps:H}=ax({sessionId:r,navigate:t,latestMessage:i,isMobile:a,activeSessions:c});return l.useEffect(()=>(window.refreshProjects=D,()=>{window.refreshProjects===D&&delete window.refreshProjects}),[D]),l.useEffect(()=>(window.openSettings=B,()=>{window.openSettings===B&&delete window.openSettings}),[B]),e.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[a?e.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${w?"opacity-100 visible":"opacity-0 invisible"}`,children:[e.jsx("button",{className:"fixed inset-0 bg-background/60 backdrop-blur-sm transition-opacity duration-150 ease-out",onClick:$=>{$.stopPropagation(),z(!1)},onTouchStart:$=>{$.preventDefault(),$.stopPropagation(),z(!1)},"aria-label":s("versionUpdate.ariaLabels.closeSidebar")}),e.jsx("div",{className:`relative w-[85vw] max-w-sm sm:w-80 h-full bg-card border-r border-border/40 transform transition-transform duration-150 ease-out ${w?"translate-x-0":"-translate-x-full"}`,onClick:$=>$.stopPropagation(),onTouchStart:$=>$.stopPropagation(),children:e.jsx(ln,{...H})})]}):e.jsx("div",{className:"h-full flex-shrink-0 border-r border-border/50",children:e.jsx(ln,{...H})}),e.jsx("div",{className:`flex-1 flex flex-col min-w-0 ${a?"pb-mobile-nav":""}`,children:e.jsx(ex,{selectedProject:f,selectedSession:g,activeTab:k,setActiveTab:T,ws:n,sendMessage:o,latestMessage:i,isMobile:a,onMenuClick:()=>z(!0),isLoading:S,onInputFocusChange:I,onSessionActive:d,onSessionInactive:m,onSessionProcessing:p,onSessionNotProcessing:x,processingSessions:u,onReplaceTemporarySession:h,onNavigateToSession:$=>t(`/session/${$}`),onShowSettings:()=>F(!0),externalMessageUpdate:v})}),a&&e.jsx(tx,{activeTab:k,setActiveTab:T,isInputFocused:y})]})}const hx=Object.freeze(Object.defineProperty({__proto__:null,default:nx},Symbol.toStringTag,{value:"Module"}));export{hx as A,fn as _,xx as a,gx as b};