upfynai-code 2.3.0 → 2.4.1

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 (162) 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 +255 -23
  123. package/server/constants/config.js +29 -3
  124. package/server/database/auth.db +0 -0
  125. package/server/index.js +380 -121
  126. package/server/mcp-server.js +2 -1
  127. package/server/middleware/auth.js +18 -8
  128. package/server/openrouter.js +137 -0
  129. package/server/relay-client.js +262 -18
  130. package/server/routes/agent.js +54 -19
  131. package/server/routes/auth.js +23 -12
  132. package/server/routes/commands.js +1 -1
  133. package/server/routes/settings.js +91 -0
  134. package/shared/modelConstants.js +29 -0
  135. package/client/dist/assets/AppContent-CTSHQdyq.js +0 -513
  136. package/client/dist/assets/CanvasPanel-Cig0Mo9s.js +0 -6
  137. package/client/dist/assets/LoginModal-silya-zP.js +0 -11
  138. package/client/dist/assets/MarkdownPreview-B3c7OEj6.js +0 -1
  139. package/client/dist/assets/channel-CSnvHe_M.js +0 -1
  140. package/client/dist/assets/classDiagram-v2-f2320105-xtym7GEZ.js +0 -2
  141. package/client/dist/assets/clone-B75abXxS.js +0 -1
  142. package/client/dist/assets/flowDiagram-66a62f08-tffoET0H.js +0 -4
  143. package/client/dist/assets/flowDiagram-v2-96b9c2cf-Byc3JCHh.js +0 -1
  144. package/client/dist/assets/index-BnXuHrpJ.js +0 -523
  145. package/client/dist/assets/index-BwxNox94.css +0 -1
  146. package/client/dist/assets/index-D1urGMYu.js +0 -95
  147. package/client/dist/assets/mindmap-definition-fc14e90a-BOOrexmz.js +0 -415
  148. package/client/dist/assets/pdf-TYrZqVzP.js +0 -12
  149. package/client/dist/assets/percentages-BXMCSKIN-C9GT0OD3.js +0 -199
  150. package/client/dist/assets/pica-VkdyTzi8.js +0 -2
  151. package/client/dist/assets/roundRect-mAH3dD0p.js +0 -1
  152. package/client/dist/assets/subset-worker.chunk-C8QUSruZ.js +0 -1
  153. package/client/dist/assets/vendor-codemirror-BARtJV1V.js +0 -16
  154. package/client/dist/assets/vendor-codemirror-langs-52_y1wip.js +0 -20
  155. package/client/dist/assets/vendor-i18n-ByAl-gdx.js +0 -1
  156. package/client/dist/assets/vendor-icons-D33IkSIf.js +0 -1
  157. package/client/dist/assets/vendor-react-CHoMc7ka.js +0 -8
  158. package/client/dist/assets/vendor-xterm-DBb3RXlu.js +0 -66
  159. package/client/dist/assets/vendor-xterm-DrlLKa8f.css +0 -1
  160. package/client/dist/llms.txt +0 -40
  161. package/client/dist/robots.txt +0 -11
  162. package/client/dist/sitemap.xml +0 -45
@@ -0,0 +1,513 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-CYdvwJaV.js","assets/vendor-react-9mUTKBHH.js","assets/vendor-markdown-BXEi_H3G.js","assets/vendor-syntax-DnmwQQJF.js","assets/CanvasPanel-DlTW6Jh6.js","assets/vendor-icons-Dh9m_Ydt.js","assets/CanvasPanel-q4HEqNtV.css"])))=>i.map(i=>d[i]);
2
+ import{r as c,j as e,v as Ft,e as Zr,g as to,u as vi,f as ki}from"./vendor-react-9mUTKBHH.js";import{d as Ge,e as va,a as Se,f as qr,l as Ua,c as ka,h as Er,i as wi}from"./index-BGmwbRlb.js";import{P as ji,f as Ve,d as Wt,g as Ha,R as Bt,h as it,i as Ni,j as dr,X as qe,k as ds,l as Es,m as Kr,n as Wr,T as ft,C as Et,o as Ci,p as Ct,q as tr,r as rr,s as Ga,t as Ur,c as zt,W as ro,G as Ut,K as wa,b as vr,a as so,E as mr,u as ao,v as ja,w as qa,x as Si,L as Ei,y as Ht,z as Pt,B as Ts,D as mt,H as Hr,Z as Na,I as no,J as Xs,N as Zs,O as Ti,Q as Ii,V as Ca,Y as Is,_ as oo,$ as ms,F as ot,a0 as wr,a1 as Ai,a2 as ps,a3 as Di,a4 as io,a5 as Sa,a6 as lo,a7 as xs,a8 as Mi,a9 as $i,aa as Fi,ab as Pi,ac as Zt,ad as _r,ae as ea,af as ta,ag as ra,ah as zr,ai as kr,aj as sa,ak as jr,al as aa,am as Or,an as co,ao as hr,ap as fr,aq as Ar,ar as Dr,as as br,at as Li,au as Jt,av as Ka,aw as _i,ax as Va,ay as Mr,az as $r,aA as zi,aB as Oi,aC as Fr,aD as Ja,aE as Ri,aF as Bi,aG as us,aH as es,aI as gs,aJ as Ya,aK as zs,aL as Wi,e as Ea,aM as Ui,aN as mo,aO as uo,aP as Hi,aQ as Gi,aR as qi,aS as Ki,aT as Vi,aU as Ji,aV as Yi,aW as Qi,aX as Qa,aY as Xi}from"./vendor-icons-Dh9m_Ydt.js";import{a as Zi,b as el,C as tl,u as He,L as rl,S as po,c as sl}from"./LoginModal-CWoFm0au.js";import{h as al,p as nl,b as xo}from"./vendor-syntax-DnmwQQJF.js";import{a as ol,b as il,d as ll,M as cl}from"./vendor-markdown-BXEi_H3G.js";import{F as go,E as er,S as dl,V as Ta,y as Nr,z as ml,A as ul,B as pl,D as xl,G as gl,H as hl,I as fl,J as bl,K as yl,M as Os,N as vl,R as ho,O as fo,Q as kl,T as wl}from"./vendor-codemirror-rix45NST.js";import{d as Xa,h as Za,m as bo,j as jl,e as Nl,f as Cl,p as Sl,g as El}from"./vendor-codemirror-langs-BH1ZcKHY.js";const en=t=>typeof window>"u"?!1:window.innerWidth<t,tn=()=>{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 Ia(t={}){const{mobileBreakpoint:r=768,trackMobile:s=!0,trackPWA:a=!0}=t,[n,o]=c.useState(()=>s?en(r):!1),[i,l]=c.useState(()=>a?tn():!1);return c.useEffect(()=>{if(!s||typeof window>"u")return;const m=()=>{o(en(r))};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[r,s]),c.useEffect(()=>{if(!a||typeof window>"u")return;const m=window.matchMedia("(display-mode: standalone)"),d=()=>{l(tn())};return d(),typeof m.addEventListener=="function"?(m.addEventListener("change",d),()=>{m.removeEventListener("change",d)}):(m.addListener(d),()=>{m.removeListener(d)})},[a]),{isMobile:n,isPWA:i}}const rn="2.4.0",Tl=(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},yo=(t,r)=>{const[s,a]=c.useState(!1),[n,o]=c.useState(null),[i,l]=c.useState(null);return c.useEffect(()=>{const m=async()=>{try{const g=await(await fetch(`https://api.github.com/repos/${t}/${r}/releases/latest`)).json();if(g.tag_name){const p=g.tag_name.replace(/^v/,"");o(p),a(Tl(p,rn)>0),l({title:g.name||g.tag_name,body:g.body||"",htmlUrl:g.html_url||`https://github.com/${t}/${r}/releases/latest`,publishedAt:g.published_at})}else a(!1),o(null),l(null)}catch(u){console.error("Version check failed:",u),a(!1),o(null),l(null)}};m();const d=setInterval(m,300*1e3);return()=>clearInterval(d)},[t,r]),{updateAvailable:s,latestVersion:n,currentVersion:rn,releaseInfo:i}},ir={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0},hs=Object.keys(ir),Il=new Set(hs),Rs="ui-preferences:sync",fs=(t,r)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return r},Al=(t,r)=>{try{const s=localStorage.getItem(t);if(s===null)return r;const a=JSON.parse(s);return fs(a,r)}catch{return r}},Dl=t=>{if(typeof window>"u")return ir;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 hs.reduce((n,o)=>(n[o]=fs(a[o],ir[o]),n),{...ir})}}}catch{}return hs.reduce((r,s)=>(r[s]=Al(s,ir[s]),r),{...ir})};function Ml(t,r){switch(r.type){case"set":{const{key:s,value:a}=r;if(!Il.has(s))return t;const n=fs(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 hs){if(!(o in s))continue;const i=s[o],l=fs(i,t[o]);n[o]!==l&&(n[o]=l,a=!0)}return a?n:t}case"reset":return{...ir,...r.value||{}};default:return t}}function Aa(t="uiPreferences"){const r=c.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[s,a]=c.useReducer(Ml,t,Dl);return c.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]),c.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||a({type:"set_many",value:u})},m=u=>{if(!(u.key!==t||u.newValue===null))try{const g=JSON.parse(u.newValue);l(g)}catch{}},d=u=>{const p=u.detail;!p||p.storageKey!==t||p.sourceId===r.current||l(p.value)};return window.addEventListener("storage",m),window.addEventListener(Rs,d),()=>{window.removeEventListener("storage",m),window.removeEventListener(Rs,d)}},[t]),{preferences:s,setPreference:(l,m)=>{a({type:"set",key:l,value:m})},setPreferences:l=>{a({type:"set_many",value:l})},resetPreferences:l=>{a({type:"reset",value:l})},dispatch:a}}const $l=()=>{try{const t=localStorage.getItem("claude-settings");return t&&JSON.parse(t).projectSortOrder==="date"?"date":"name"}catch{return"name"}},Fl=()=>{try{const t=localStorage.getItem("starredProjects");return t?new Set(JSON.parse(t)):new Set}catch{return new Set}},Pl=t=>{try{localStorage.setItem("starredProjects",JSON.stringify([...t]))}catch{}},bs=t=>t.__provider==="cursor"?new Date(t.createdAt||0):t.__provider==="codex"?new Date(t.createdAt||t.lastActivity||0):new Date(t.lastActivity||0),Ll=(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"),_l=t=>t.__provider==="cursor"?String(t.createdAt||""):t.__provider==="codex"?String(t.createdAt||t.lastActivity||""):String(t.lastActivity||""),zl=(t,r,s)=>{const a=bs(t),n=Math.floor((r.getTime()-a.getTime())/(1e3*60));return{isCursorSession:t.__provider==="cursor",isCodexSession:t.__provider==="codex",isActive:n<10,sessionName:Ll(t,s),sessionTime:_l(t),messageCount:Number(t.messageCount||0)}},vo=(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)=>bs(i).getTime()-bs(o).getTime())},sn=(t,r)=>{const s=vo(t,r);return s.length===0?new Date(0):s.reduce((a,n)=>{const o=bs(n);return o>a?o:a},new Date(0))},Ol=(t,r,s,a)=>{const n=[...t];return n.sort((o,i)=>{const l=s.has(o.name),m=s.has(i.name);return l&&!m?-1:!l&&m?1:r==="date"?sn(i,a).getTime()-sn(o,a).getTime():(o.displayName||o.name).localeCompare(i.displayName||i.name)}),n},Rl=(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},Bl=(t,r)=>{var n;const s=!!((n=t.taskmaster)!=null&&n.hasTaskmaster),a=!!(r!=null&&r.hasMCPServer&&(r!=null&&r.isConfigured));return s&&a?"fully-configured":s?"taskmaster-only":a?"mcp-only":"not-configured"},Wl=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 Ul({projects:t,selectedProject:r,selectedSession:s,isLoading:a,isMobile:n,t:o,onRefresh:i,onProjectSelect:l,onSessionSelect:m,onSessionDelete:d,onProjectDelete:u,setCurrentProject:g,setSidebarVisible:p,sidebarVisible:x}){const[f,h]=c.useState(new Set),[y,N]=c.useState(null),[S,v]=c.useState(!1),[b,D]=c.useState(""),[A,j]=c.useState({}),[C,L]=c.useState({}),[R,_]=c.useState(new Set),[$,F]=c.useState(new Date),[I,U]=c.useState("name"),[w,z]=c.useState(!1),[q,ee]=c.useState({}),[M,K]=c.useState(null),[T,G]=c.useState(""),[Y,J]=c.useState(""),[W,O]=c.useState(new Set),[se,B]=c.useState(null),[ge,pe]=c.useState(null),[k,E]=c.useState(!1),[X,ae]=c.useState(()=>Fl()),oe=!n&&!x;c.useEffect(()=>{const te=setInterval(()=>{F(new Date)},6e4);return()=>clearInterval(te)},[]),c.useEffect(()=>{L({}),_(new Set),ee({})},[t]),c.useEffect(()=>{r&&h(te=>{if(te.has(r.name))return te;const be=new Set(te);return be.add(r.name),be})},[s,r]),c.useEffect(()=>{if(t.length>0&&!a){const te=new Set;t.forEach(be=>{be.sessions&&be.sessions.length>=0&&te.add(be.name)}),_(te)}},[t,a]),c.useEffect(()=>{const te=()=>{U($l())};te();const be=Be=>{Be.key==="claude-settings"&&te()};window.addEventListener("storage",be);const $e=setInterval(()=>{document.hasFocus()&&te()},1e3);return()=>{window.removeEventListener("storage",be),clearInterval($e)}},[]);const Fe=c.useCallback(te=>be=>{const $e=be.target;$e.closest(".overflow-y-auto")||$e.closest("[data-scroll-container]")||(be.preventDefault(),be.stopPropagation(),te())},[]),he=c.useCallback(te=>{h(be=>{const $e=new Set;return be.has(te)||$e.add(te),$e})},[]),xe=c.useCallback((te,be)=>{m({...te,__projectName:be})},[m]),Te=c.useCallback(te=>{ae(be=>{const $e=new Set(be);return $e.has(te)?$e.delete(te):$e.add(te),Pl($e),$e})},[]),Le=c.useCallback(te=>X.has(te),[X]),ze=c.useCallback(te=>vo(te,C),[C]),re=c.useMemo(()=>t.map(te=>{const be=q[te.name];return be===void 0?te:{...te,sessionMeta:{...te.sessionMeta,hasMore:be}}}),[q,t]),fe=c.useMemo(()=>Ol(re,I,X,C),[C,I,re,X]),V=c.useMemo(()=>Rl(fe,Y),[Y,fe]),ne=c.useCallback(te=>{N(te.name),D(te.displayName)},[]),we=c.useCallback(()=>{N(null),D("")},[]),Ie=c.useCallback(async te=>{try{(await Ge.renameProject(te,b)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(be){console.error("Error renaming project:",be)}finally{N(null),D("")}},[b]),De=c.useCallback((te,be,$e,Be="claude")=>{pe({projectName:te,sessionId:be,sessionTitle:$e,provider:Be})},[]),Ue=c.useCallback(async()=>{if(!ge)return;const{projectName:te,sessionId:be,provider:$e}=ge;pe(null);try{const Be=$e==="codex"?await Ge.deleteCodexSession(be):await Ge.deleteSession(te,be);if(Be.ok)d==null||d(be);else{const st=await Be.text();console.error("[Sidebar] Failed to delete session:",{status:Be.status,error:st}),alert(o("messages.deleteSessionFailed"))}}catch(Be){console.error("[Sidebar] Error deleting session:",Be),alert(o("messages.deleteSessionError"))}},[d,ge,o]),Ke=c.useCallback(te=>{B({project:te,sessionCount:ze(te).length})},[ze]),Je=c.useCallback(async()=>{if(!se)return;const{project:te,sessionCount:be}=se,$e=be===0;B(null),O(Be=>new Set([...Be,te.name]));try{const Be=await Ge.deleteProject(te.name,!$e);if(Be.ok)u==null||u(te.name);else{const st=await Be.json();alert(st.error||o("messages.deleteProjectFailed"))}}catch(Be){console.error("Error deleting project:",Be),alert(o("messages.deleteProjectError"))}finally{O(Be=>{const st=new Set(Be);return st.delete(te.name),st})}},[se,u,o]),de=c.useCallback(async te=>{var Be,st,Tt;const be=q[te.name];if(!(!(be!==void 0?be:((Be=te.sessionMeta)==null?void 0:Be.hasMore)===!0)||A[te.name])){j(pt=>({...pt,[te.name]:!0}));try{const pt=(((st=te.sessions)==null?void 0:st.length)||0)+(((Tt=C[te.name])==null?void 0:Tt.length)||0),vt=await Ge.sessions(te.name,5,pt);if(!vt.ok)return;const lt=await vt.json();L(ie=>({...ie,[te.name]:[...ie[te.name]||[],...lt.sessions||[]]})),lt.hasMore===!1&&ee(ie=>({...ie,[te.name]:!1}))}catch(pt){console.error("Error loading more sessions:",pt)}finally{j(pt=>({...pt,[te.name]:!1}))}}},[C,A,q]),Me=c.useCallback(te=>{l(te),g(te)},[l,g]),Ne=c.useCallback(async()=>{z(!0);try{await i()}finally{z(!1)}},[i]),_e=c.useCallback(async(te,be,$e)=>{K(null),G("")},[]),Oe=c.useCallback(()=>{p(!1)},[p]),Pe=c.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:oe,expandedProjects:f,editingProject:y,showNewProject:S,editingName:b,loadingSessions:A,additionalSessions:C,initialSessionsLoaded:R,currentTime:$,projectSortOrder:I,isRefreshing:w,editingSession:M,editingSessionName:T,searchFilter:Y,deletingProjects:W,deleteConfirmation:se,sessionDeleteConfirmation:ge,showVersionModal:k,starredProjects:X,filteredProjects:V,handleTouchClick:Fe,toggleProject:he,handleSessionClick:xe,toggleStarProject:Te,isProjectStarred:Le,getProjectSessions:ze,startEditing:ne,cancelEditing:we,saveProjectName:Ie,showDeleteSessionConfirmation:De,confirmDeleteSession:Ue,requestProjectDelete:Ke,confirmDeleteProject:Je,loadMoreSessions:de,handleProjectSelect:Me,refreshProjects:Ne,updateSessionSummary:_e,collapseSidebar:Oe,expandSidebar:Pe,setShowNewProject:v,setEditingName:D,setEditingSession:K,setEditingSessionName:G,setSearchFilter:J,setDeleteConfirmation:B,setSessionDeleteConfirmation:pe,setShowVersionModal:E}}function Hl({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(ji,{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(Wt,{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 ko(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=ko(t[r]))&&(a&&(a+=" "),a+=s)}else for(s in t)t[s]&&(a&&(a+=" "),a+=s);return a}function wo(){for(var t,r,s=0,a="",n=arguments.length;s<n;s++)(t=arguments[s])&&(r=ko(t))&&(a&&(a+=" "),a+=r);return a}const Gl=(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},ql=(t,r)=>({classGroupId:t,validator:r}),jo=(t=new Map,r=null,s)=>({nextPart:t,validators:r,classGroupId:s}),ys="-",an=[],Kl="arbitrary..",Vl=t=>{const r=Yl(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Jl(i);const l=i.split(ys),m=l[0]===""&&l.length>1?1:0;return No(l,m,r)},getConflictingClassGroupIds:(i,l)=>{if(l){const m=a[i],d=s[i];return m?d?Gl(d,m):m:d||an}return s[i]||an}}},No=(t,r,s)=>{if(t.length-r===0)return s.classGroupId;const n=t[r],o=s.nextPart.get(n);if(o){const d=No(t,r+1,o);if(d)return d}const i=s.validators;if(i===null)return;const l=r===0?t.join(ys):t.slice(r).join(ys),m=i.length;for(let d=0;d<m;d++){const u=i[d];if(u.validator(l))return u.classGroupId}},Jl=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?Kl+a:void 0})(),Yl=t=>{const{theme:r,classGroups:s}=t;return Ql(s,r)},Ql=(t,r)=>{const s=jo();for(const a in t){const n=t[a];Da(n,s,a,r)}return s},Da=(t,r,s,a)=>{const n=t.length;for(let o=0;o<n;o++){const i=t[o];Xl(i,r,s,a)}},Xl=(t,r,s,a)=>{if(typeof t=="string"){Zl(t,r,s);return}if(typeof t=="function"){ec(t,r,s,a);return}tc(t,r,s,a)},Zl=(t,r,s)=>{const a=t===""?r:Co(r,t);a.classGroupId=s},ec=(t,r,s,a)=>{if(rc(t)){Da(t(a),r,s,a);return}r.validators===null&&(r.validators=[]),r.validators.push(ql(s,t))},tc=(t,r,s,a)=>{const n=Object.entries(t),o=n.length;for(let i=0;i<o;i++){const[l,m]=n[i];Da(m,Co(r,l),s,a)}},Co=(t,r)=>{let s=t;const a=r.split(ys),n=a.length;for(let o=0;o<n;o++){const i=a[o];let l=s.nextPart.get(i);l||(l=jo(),s.nextPart.set(i,l)),s=l}return s},rc=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,sc=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)}}},na="!",nn=":",ac=[],on=(t,r,s,a,n)=>({modifiers:t,hasImportantModifier:r,baseClassName:s,maybePostfixModifierPosition:a,isExternal:n}),nc=t=>{const{prefix:r,experimentalParseClassName:s}=t;let a=n=>{const o=[];let i=0,l=0,m=0,d;const u=n.length;for(let h=0;h<u;h++){const y=n[h];if(i===0&&l===0){if(y===nn){o.push(n.slice(m,h)),m=h+1;continue}if(y==="/"){d=h;continue}}y==="["?i++:y==="]"?i--:y==="("?l++:y===")"&&l--}const g=o.length===0?n:n.slice(m);let p=g,x=!1;g.endsWith(na)?(p=g.slice(0,-1),x=!0):g.startsWith(na)&&(p=g.slice(1),x=!0);const f=d&&d>m?d-m:void 0;return on(o,x,p,f)};if(r){const n=r+nn,o=a;a=i=>i.startsWith(n)?o(i.slice(n.length)):on(ac,!1,i,void 0,!0)}if(s){const n=a;a=o=>s({className:o,parseClassName:n})}return a},oc=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],l=i[0]==="[",m=r.has(i);l||m?(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}},ic=t=>({cache:sc(t.cacheSize),parseClassName:nc(t),sortModifiers:oc(t),...Vl(t)}),lc=/\s+/,cc=(t,r)=>{const{parseClassName:s,getClassGroupId:a,getConflictingClassGroupIds:n,sortModifiers:o}=r,i=[],l=t.trim().split(lc);let m="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:g,modifiers:p,hasImportantModifier:x,baseClassName:f,maybePostfixModifierPosition:h}=s(u);if(g){m=u+(m.length>0?" "+m:m);continue}let y=!!h,N=a(y?f.substring(0,h):f);if(!N){if(!y){m=u+(m.length>0?" "+m:m);continue}if(N=a(f),!N){m=u+(m.length>0?" "+m:m);continue}y=!1}const S=p.length===0?"":p.length===1?p[0]:o(p).join(":"),v=x?S+na:S,b=v+N;if(i.indexOf(b)>-1)continue;i.push(b);const D=n(N,y);for(let A=0;A<D.length;++A){const j=D[A];i.push(v+j)}m=u+(m.length>0?" "+m:m)}return m},dc=(...t)=>{let r=0,s,a,n="";for(;r<t.length;)(s=t[r++])&&(a=So(s))&&(n&&(n+=" "),n+=a);return n},So=t=>{if(typeof t=="string")return t;let r,s="";for(let a=0;a<t.length;a++)t[a]&&(r=So(t[a]))&&(s&&(s+=" "),s+=r);return s},mc=(t,...r)=>{let s,a,n,o;const i=m=>{const d=r.reduce((u,g)=>g(u),t());return s=ic(d),a=s.cache.get,n=s.cache.set,o=l,l(m)},l=m=>{const d=a(m);if(d)return d;const u=cc(m,s);return n(m,u),u};return o=i,(...m)=>o(dc(...m))},uc=[],nt=t=>{const r=s=>s[t]||uc;return r.isThemeGetter=!0,r},Eo=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,To=/^\((?:(\w[\w-]*):)?(.+)\)$/i,pc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,xc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,gc=/\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$/,hc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,bc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Yt=t=>pc.test(t),Re=t=>!!t&&!Number.isNaN(Number(t)),Qt=t=>!!t&&Number.isInteger(Number(t)),Bs=t=>t.endsWith("%")&&Re(t.slice(0,-1)),Rt=t=>xc.test(t),Io=()=>!0,yc=t=>gc.test(t)&&!hc.test(t),Ma=()=>!1,vc=t=>fc.test(t),kc=t=>bc.test(t),wc=t=>!ye(t)&&!ve(t),jc=t=>sr(t,Mo,Ma),ye=t=>Eo.test(t),or=t=>sr(t,$o,yc),ln=t=>sr(t,Dc,Re),Nc=t=>sr(t,Po,Io),Cc=t=>sr(t,Fo,Ma),cn=t=>sr(t,Ao,Ma),Sc=t=>sr(t,Do,kc),ts=t=>sr(t,Lo,vc),ve=t=>To.test(t),Pr=t=>ur(t,$o),Ec=t=>ur(t,Fo),dn=t=>ur(t,Ao),Tc=t=>ur(t,Mo),Ic=t=>ur(t,Do),rs=t=>ur(t,Lo,!0),Ac=t=>ur(t,Po,!0),sr=(t,r,s)=>{const a=Eo.exec(t);return a?a[1]?r(a[1]):s(a[2]):!1},ur=(t,r,s=!1)=>{const a=To.exec(t);return a?a[1]?r(a[1]):s:!1},Ao=t=>t==="position"||t==="percentage",Do=t=>t==="image"||t==="url",Mo=t=>t==="length"||t==="size"||t==="bg-size",$o=t=>t==="length",Dc=t=>t==="number",Fo=t=>t==="family-name",Po=t=>t==="number"||t==="weight",Lo=t=>t==="shadow",Mc=()=>{const t=nt("color"),r=nt("font"),s=nt("text"),a=nt("font-weight"),n=nt("tracking"),o=nt("leading"),i=nt("breakpoint"),l=nt("container"),m=nt("spacing"),d=nt("radius"),u=nt("shadow"),g=nt("inset-shadow"),p=nt("text-shadow"),x=nt("drop-shadow"),f=nt("blur"),h=nt("perspective"),y=nt("aspect"),N=nt("ease"),S=nt("animate"),v=()=>["auto","avoid","all","avoid-page","page","left","right","column"],b=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],D=()=>[...b(),ve,ye],A=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],C=()=>[ve,ye,m],L=()=>[Yt,"full","auto",...C()],R=()=>[Qt,"none","subgrid",ve,ye],_=()=>["auto",{span:["full",Qt,ve,ye]},Qt,ve,ye],$=()=>[Qt,"auto",ve,ye],F=()=>["auto","min","max","fr",ve,ye],I=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],U=()=>["start","end","center","stretch","center-safe","end-safe"],w=()=>["auto",...C()],z=()=>[Yt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],q=()=>[Yt,"screen","full","dvw","lvw","svw","min","max","fit",...C()],ee=()=>[Yt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...C()],M=()=>[t,ve,ye],K=()=>[...b(),dn,cn,{position:[ve,ye]}],T=()=>["no-repeat",{repeat:["","x","y","space","round"]}],G=()=>["auto","cover","contain",Tc,jc,{size:[ve,ye]}],Y=()=>[Bs,Pr,or],J=()=>["","none","full",d,ve,ye],W=()=>["",Re,Pr,or],O=()=>["solid","dashed","dotted","double"],se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],B=()=>[Re,Bs,dn,cn],ge=()=>["","none",f,ve,ye],pe=()=>["none",Re,ve,ye],k=()=>["none",Re,ve,ye],E=()=>[Re,ve,ye],X=()=>[Yt,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Rt],breakpoint:[Rt],color:[Io],container:[Rt],"drop-shadow":[Rt],ease:["in","out","in-out"],font:[wc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Rt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Rt],shadow:[Rt],spacing:["px",Re],text:[Rt],"text-shadow":[Rt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Yt,ye,ve,y]}],container:["container"],columns:[{columns:[Re,ye,ve,l]}],"break-after":[{"break-after":v()}],"break-before":[{"break-before":v()}],"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:D()}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:L()}],"inset-x":[{"inset-x":L()}],"inset-y":[{"inset-y":L()}],start:[{"inset-s":L(),start:L()}],end:[{"inset-e":L(),end:L()}],"inset-bs":[{"inset-bs":L()}],"inset-be":[{"inset-be":L()}],top:[{top:L()}],right:[{right:L()}],bottom:[{bottom:L()}],left:[{left:L()}],visibility:["visible","invisible","collapse"],z:[{z:[Qt,"auto",ve,ye]}],basis:[{basis:[Yt,"full","auto",l,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Re,Yt,"auto","initial","none",ye]}],grow:[{grow:["",Re,ve,ye]}],shrink:[{shrink:["",Re,ve,ye]}],order:[{order:[Qt,"first","last","none",ve,ye]}],"grid-cols":[{"grid-cols":R()}],"col-start-end":[{col:_()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":R()}],"row-start-end":[{row:_()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":F()}],"auto-rows":[{"auto-rows":F()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...I(),"normal"]}],"justify-items":[{"justify-items":[...U(),"normal"]}],"justify-self":[{"justify-self":["auto",...U()]}],"align-content":[{content:["normal",...I()]}],"align-items":[{items:[...U(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...U(),{baseline:["","last"]}]}],"place-content":[{"place-content":I()}],"place-items":[{"place-items":[...U(),"baseline"]}],"place-self":[{"place-self":["auto",...U()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pbs:[{pbs:C()}],pbe:[{pbe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:w()}],mx:[{mx:w()}],my:[{my:w()}],ms:[{ms:w()}],me:[{me:w()}],mbs:[{mbs:w()}],mbe:[{mbe:w()}],mt:[{mt:w()}],mr:[{mr:w()}],mb:[{mb:w()}],ml:[{ml:w()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],"inline-size":[{inline:["auto",...q()]}],"min-inline-size":[{"min-inline":["auto",...q()]}],"max-inline-size":[{"max-inline":["none",...q()]}],"block-size":[{block:["auto",...ee()]}],"min-block-size":[{"min-block":["auto",...ee()]}],"max-block-size":[{"max-block":["none",...ee()]}],w:[{w:[l,"screen",...z()]}],"min-w":[{"min-w":[l,"screen","none",...z()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",s,Pr,or]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Ac,Nc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Bs,ye]}],"font-family":[{font:[Ec,Cc,r]}],"font-features":[{"font-features":[ye]}],"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,ve,ye]}],"line-clamp":[{"line-clamp":[Re,"none",ve,ln]}],leading:[{leading:[o,...C()]}],"list-image":[{"list-image":["none",ve,ye]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ve,ye]}],"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:[Re,"from-font","auto",ve,or]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[Re,"auto",ve,ye]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ve,ye]}],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",ve,ye]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:K()}],"bg-repeat":[{bg:T()}],"bg-size":[{bg:G()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Qt,ve,ye],radial:["",ve,ye],conic:[Qt,ve,ye]},Ic,Sc]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:J()}],"rounded-s":[{"rounded-s":J()}],"rounded-e":[{"rounded-e":J()}],"rounded-t":[{"rounded-t":J()}],"rounded-r":[{"rounded-r":J()}],"rounded-b":[{"rounded-b":J()}],"rounded-l":[{"rounded-l":J()}],"rounded-ss":[{"rounded-ss":J()}],"rounded-se":[{"rounded-se":J()}],"rounded-ee":[{"rounded-ee":J()}],"rounded-es":[{"rounded-es":J()}],"rounded-tl":[{"rounded-tl":J()}],"rounded-tr":[{"rounded-tr":J()}],"rounded-br":[{"rounded-br":J()}],"rounded-bl":[{"rounded-bl":J()}],"border-w":[{border:W()}],"border-w-x":[{"border-x":W()}],"border-w-y":[{"border-y":W()}],"border-w-s":[{"border-s":W()}],"border-w-e":[{"border-e":W()}],"border-w-bs":[{"border-bs":W()}],"border-w-be":[{"border-be":W()}],"border-w-t":[{"border-t":W()}],"border-w-r":[{"border-r":W()}],"border-w-b":[{"border-b":W()}],"border-w-l":[{"border-l":W()}],"divide-x":[{"divide-x":W()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":W()}],"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":[Re,ve,ye]}],"outline-w":[{outline:["",Re,Pr,or]}],"outline-color":[{outline:M()}],shadow:[{shadow:["","none",u,rs,ts]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":["none",g,rs,ts]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[Re,or]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":W()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":["none",p,rs,ts]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[Re,ve,ye]}],"mix-blend":[{"mix-blend":[...se(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":se()}],"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":[Re]}],"mask-image-linear-from-pos":[{"mask-linear-from":B()}],"mask-image-linear-to-pos":[{"mask-linear-to":B()}],"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":B()}],"mask-image-t-to-pos":[{"mask-t-to":B()}],"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":B()}],"mask-image-r-to-pos":[{"mask-r-to":B()}],"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":B()}],"mask-image-b-to-pos":[{"mask-b-to":B()}],"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":B()}],"mask-image-l-to-pos":[{"mask-l-to":B()}],"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":B()}],"mask-image-x-to-pos":[{"mask-x-to":B()}],"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":B()}],"mask-image-y-to-pos":[{"mask-y-to":B()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[ve,ye]}],"mask-image-radial-from-pos":[{"mask-radial-from":B()}],"mask-image-radial-to-pos":[{"mask-radial-to":B()}],"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":b()}],"mask-image-conic-pos":[{"mask-conic":[Re]}],"mask-image-conic-from-pos":[{"mask-conic-from":B()}],"mask-image-conic-to-pos":[{"mask-conic-to":B()}],"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:K()}],"mask-repeat":[{mask:T()}],"mask-size":[{mask:G()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ve,ye]}],filter:[{filter:["","none",ve,ye]}],blur:[{blur:ge()}],brightness:[{brightness:[Re,ve,ye]}],contrast:[{contrast:[Re,ve,ye]}],"drop-shadow":[{"drop-shadow":["","none",x,rs,ts]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:["",Re,ve,ye]}],"hue-rotate":[{"hue-rotate":[Re,ve,ye]}],invert:[{invert:["",Re,ve,ye]}],saturate:[{saturate:[Re,ve,ye]}],sepia:[{sepia:["",Re,ve,ye]}],"backdrop-filter":[{"backdrop-filter":["","none",ve,ye]}],"backdrop-blur":[{"backdrop-blur":ge()}],"backdrop-brightness":[{"backdrop-brightness":[Re,ve,ye]}],"backdrop-contrast":[{"backdrop-contrast":[Re,ve,ye]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Re,ve,ye]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Re,ve,ye]}],"backdrop-invert":[{"backdrop-invert":["",Re,ve,ye]}],"backdrop-opacity":[{"backdrop-opacity":[Re,ve,ye]}],"backdrop-saturate":[{"backdrop-saturate":[Re,ve,ye]}],"backdrop-sepia":[{"backdrop-sepia":["",Re,ve,ye]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ve,ye]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Re,"initial",ve,ye]}],ease:[{ease:["linear","initial",N,ve,ye]}],delay:[{delay:[Re,ve,ye]}],animate:[{animate:["none",S,ve,ye]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,ve,ye]}],"perspective-origin":[{"perspective-origin":D()}],rotate:[{rotate:pe()}],"rotate-x":[{"rotate-x":pe()}],"rotate-y":[{"rotate-y":pe()}],"rotate-z":[{"rotate-z":pe()}],scale:[{scale:k()}],"scale-x":[{"scale-x":k()}],"scale-y":[{"scale-y":k()}],"scale-z":[{"scale-z":k()}],"scale-3d":["scale-3d"],skew:[{skew:E()}],"skew-x":[{"skew-x":E()}],"skew-y":[{"skew-y":E()}],transform:[{transform:[ve,ye,"","none","gpu","cpu"]}],"transform-origin":[{origin:D()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:X()}],"translate-x":[{"translate-x":X()}],"translate-y":[{"translate-y":X()}],"translate-z":[{"translate-z":X()}],"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",ve,ye]}],"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":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mbs":[{"scroll-mbs":C()}],"scroll-mbe":[{"scroll-mbe":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pbs":[{"scroll-pbs":C()}],"scroll-pbe":[{"scroll-pbe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"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",ve,ye]}],fill:[{fill:["none",...M()]}],"stroke-w":[{stroke:[Re,Pr,or,ln]}],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"]}},$c=mc(Mc);function ke(...t){return $c(wo(t))}function Fc(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const $a=c.forwardRef(({className:t,children:r,...s},a)=>e.jsx("div",{className:ke(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})}));$a.displayName="ScrollArea";function Pc({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(Ha,{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==null?void 0: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(Ha,{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==null?void 0: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 mn=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,un=wo,_o=(t,r)=>s=>{var a;if((r==null?void 0:r.variants)==null)return un(t,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:n,defaultVariants:o}=r,i=Object.keys(n).map(d=>{const u=s==null?void 0:s[d],g=o==null?void 0:o[d];if(u===null)return null;const p=mn(u)||mn(g);return n[d][p]}),l=s&&Object.entries(s).reduce((d,u)=>{let[g,p]=u;return p===void 0||(d[g]=p),d},{}),m=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((d,u)=>{let{class:g,className:p,...x}=u;return Object.entries(x).every(f=>{let[h,y]=f;return Array.isArray(y)?y.includes({...o,...l}[h]):{...o,...l}[h]===y})?[...d,g,p]:d},[]);return un(t,i,m,s==null?void 0:s.class,s==null?void 0:s.className)},Lc=_o("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=c.forwardRef(({className:t,variant:r,size:s,...a},n)=>e.jsx("button",{className:ke(Lc({variant:r,size:s,className:t})),ref:n,...a}));me.displayName="Button";const rt=c.forwardRef(({className:t,type:r,...s},a)=>e.jsx("input",{type:r,className:ke("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}));rt.displayName="Input";function _c({isPWA:t,isMobile:r,isLoading:s,projectsCount:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:l,isRefreshing:m,onCreateProject:d,onCollapseSidebar:u,t:g}){const p=()=>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:g("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(p,{}),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:l,disabled:m,title:g("tooltips.refresh"),children:e.jsx(Bt,{className:`w-3.5 h-3.5 ${m?"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:g("tooltips.createProject"),children:e.jsx(it,{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:u,title:g("tooltips.hideSidebar"),children:e.jsx(Ni,{className:"w-3.5 h-3.5"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(dr,{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(rt,{type:"text",placeholder:g("projects.searchPlaceholder"),value:n,onChange:x=>o(x.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(p,{}),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:l,disabled:m,children:e.jsx(Bt,{className:`w-4 h-4 text-muted-foreground ${m?"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(ds,{className:"w-4 h-4"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(dr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 pointer-events-none"}),e.jsx(rt,{type:"text",placeholder:g("projects.searchPlaceholder"),value:n,onChange:x=>o(x.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 zc=({status:t="not-configured",size:r="sm",className:s="",showLabel:a=!1})=>{const o=(()=>{switch(t){case"fully-configured":return{icon:Kr,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:Es,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"};case"not-configured":case"error":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,l={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},m={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"};return a?e.jsxs("div",{className:ke("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:l[r]}),e.jsx("span",{className:"font-medium",children:o.label})]}):e.jsx("div",{className:ke("inline-flex items-center justify-center rounded-full transition-colors",o.bgColor,m[r],s),title:o.title,children:e.jsx(i,{className:ke(l[r],o.color)})})},Oc=_o("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 At({className:t,variant:r,...s}){return e.jsx("div",{className:ke(Oc({variant:r}),t),...s})}const pn=(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),l=Math.floor(o/(1e3*60)),m=Math.floor(o/(1e3*60*60)),d=Math.floor(o/(1e3*60*60*24));return i<60?s?s("time.justNow"):"Just now":l===1?s?s("time.oneMinuteAgo"):"1 min ago":l<60?s?s("time.minutesAgo",{count:l}):`${l} mins ago`:m===1?s?s("time.oneHourAgo"):"1 hour ago":m<24?s?s("time.hoursAgo",{count:m}):`${m} 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 It({provider:t="claude",className:r="w-5 h-5"}){return t==="cursor"?e.jsx(Zi,{className:r}):t==="codex"?e.jsx(el,{className:r}):e.jsx(tl,{className:r})}function Rc({project:t,session:r,selectedSession:s,currentTime:a,editingSession:n,editingSessionName:o,onEditingSessionNameChange:i,onStartEditingSession:l,onCancelEditingSession:m,onSaveEditingSession:d,onProjectSelect:u,onSessionSelect:g,onDeleteSession:p,touchHandlerFactory:x,t:f}){const h=zl(r,a,f),y=(s==null?void 0:s.id)===r.id,N=()=>{u(t),g(r,t.name)},S=()=>{d(t.name,r.id,o)},v=()=>{p(t.name,r.id,h.sessionName,r.__provider)};return e.jsxs("div",{className:"group relative",children:[h.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:ke("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",y?"bg-primary/5 border-primary/20":"",!y&&h.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:N,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:ke("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",y?"bg-primary/10":"bg-muted/50"),children:e.jsx(It,{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:h.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Wr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:pn(h.sessionTime,a,f)}),h.messageCount>0&&e.jsx(At,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:h.messageCount}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(It,{provider:r.__provider,className:"w-3 h-3"})})]})]}),!h.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:b=>{b.stopPropagation(),v()},children:e.jsx(ft,{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:ke("w-full justify-start p-2 h-auto font-normal text-left hover:bg-accent/50 transition-colors duration-200",y&&"bg-accent text-accent-foreground"),onClick:()=>g(r,t.name),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full",children:[e.jsx(It,{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:h.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Wr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:pn(h.sessionTime,a,f)}),h.messageCount>0&&e.jsx(At,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto group-hover:opacity-0 transition-opacity",children:h.messageCount}),e.jsx("span",{className:"ml-1 opacity-70 group-hover:opacity-0 transition-opacity",children:e.jsx(It,{provider:r.__provider,className:"w-3 h-3"})})]})]})]})}),!h.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&&!h.isCodexSession?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:o,onChange:b=>i(b.target.value),onKeyDown:b=>{b.stopPropagation(),b.key==="Enter"?S():b.key==="Escape"&&m()},onClick:b=>b.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:b=>{b.stopPropagation(),S()},title:f("tooltips.save"),children:e.jsx(Et,{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:b=>{b.stopPropagation(),m()},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:[!h.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:b=>{b.stopPropagation(),l(r.id,r.summary||f("projects.newSession"))},title:f("tooltips.editSessionName"),children:e.jsx(Ci,{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:b=>{b.stopPropagation(),v()},title:f("tooltips.deleteSession"),children:e.jsx(ft,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]})}function Bc(){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 Wc({project:t,isExpanded:r,sessions:s,selectedSession:a,initialSessionsLoaded:n,isLoadingSessions:o,currentTime:i,editingSession:l,editingSessionName:m,onEditingSessionNameChange:d,onStartEditingSession:u,onCancelEditingSession:g,onSaveEditingSession:p,onProjectSelect:x,onSessionSelect:f,onDeleteSession:h,onLoadMoreSessions:y,onNewSession:N,touchHandlerFactory:S,t:v}){var A;if(!r)return null;const b=s.length>0,D=((A=t.sessionMeta)==null?void 0:A.hasMore)===!0;return e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[n?!b&&!o?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:v("sessions.noSessions")})}):s.map(j=>e.jsx(Rc,{project:t,session:j,selectedSession:a,currentTime:i,editingSession:l,editingSessionName:m,onEditingSessionNameChange:d,onStartEditingSession:u,onCancelEditingSession:g,onSaveEditingSession:p,onProjectSelect:x,onSessionSelect:f,onDeleteSession:h,touchHandlerFactory:S,t:v},j.id)):e.jsx(Bc,{}),b&&D&&e.jsx(me,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>y(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"}),v("sessions.loading")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ct,{className:"w-3 h-3"}),v("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:()=>{x(t),N(t)},children:[e.jsx(it,{className:"w-3 h-3"}),v("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:()=>N(t),children:[e.jsx(it,{className:"w-3 h-3"}),v("sessions.newSession")]})]})}const Uc=(t,r)=>{const s=t.length;return r&&s>=5?`${s}+`:`${s}`};function Hc({project:t,selectedProject:r,selectedSession:s,isExpanded:a,isDeleting:n,isStarred:o,editingProject:i,editingName:l,sessions:m,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:g,editingSession:p,editingSessionName:x,tasksEnabled:f,mcpServerStatus:h,onEditingNameChange:y,onToggleProject:N,onProjectSelect:S,onToggleStarProject:v,onStartEditingProject:b,onCancelEditingProject:D,onSaveProjectName:A,onDeleteProject:j,onSessionSelect:C,onDeleteSession:L,onLoadMoreSessions:R,onNewSession:_,onEditingSessionNameChange:$,onStartEditingSession:F,onCancelEditingSession:I,onSaveEditingSession:U,touchHandlerFactory:w,t:z}){var se;const q=(r==null?void 0:r.name)===t.name,ee=i===t.name,M=((se=t.sessionMeta)==null?void 0:se.hasMore)===!0,K=Uc(m,M),T=`${K} session${m.length===1?"":"s"}`,G=Bl(t,h),Y=()=>N(t.name),J=()=>v(t.name),W=()=>{A(t.name)},O=()=>{(r==null?void 0:r.name)!==t.name&&S(t),Y()};return e.jsxs("div",{className:ke("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:ke("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",q&&"bg-primary/5 border-primary/20",o&&!q&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:Y,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:ke("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",a?"bg-primary/10":"bg-muted"),children:a?e.jsx(tr,{className:"w-4 h-4 text-primary"}):e.jsx(rr,{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:l,onChange:B=>y(B.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:z("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:B=>B.stopPropagation(),onKeyDown:B=>{B.key==="Enter"&&W(),B.key==="Escape"&&D()},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(zc,{status:G,size:"xs",className:"hidden md:inline-flex flex-shrink-0 ml-2"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:T})]})})]}),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:B=>{B.stopPropagation(),W()},children:e.jsx(Et,{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:B=>{B.stopPropagation(),D()},children:e.jsx(qe,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:ke("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:B=>{B.stopPropagation(),J()},title:z(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(Ga,{className:ke("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:B=>{B.stopPropagation(),j(t)},children:e.jsx(ft,{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:B=>{B.stopPropagation(),b(t)},children:e.jsx(Ur,{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(Ct,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(zt,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(me,{variant:"ghost",className:ke("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",q&&"bg-accent text-accent-foreground",o&&!q&&"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(tr,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(rr,{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:l,onChange:B=>y(B.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:z("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:B=>{B.key==="Enter"&&W(),B.key==="Escape"&&D()}}),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:[K,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:B=>{B.stopPropagation(),W()},children:e.jsx(Et,{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:B=>{B.stopPropagation(),D()},children:e.jsx(qe,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ke("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:B=>{B.stopPropagation(),J()},title:z(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(Ga,{className:ke("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:B=>{B.stopPropagation(),b(t)},title:z("tooltips.renameProject"),children:e.jsx(Ur,{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:B=>{B.stopPropagation(),j(t)},title:z("tooltips.deleteProject"),children:e.jsx(ft,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),a?e.jsx(Ct,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(zt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),e.jsx(Wc,{project:t,isExpanded:a,sessions:m,selectedSession:s,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:g,editingSession:p,editingSessionName:x,onEditingSessionNameChange:$,onStartEditingSession:F,onCancelEditingSession:I,onSaveEditingSession:U,onProjectSelect:S,onSessionSelect:C,onDeleteSession:L,onLoadMoreSessions:R,onNewSession:_,touchHandlerFactory:w,t:z})]})}function Gc({isLoading:t,loadingProgress:r,projectsCount:s,filteredProjectsCount:a,t:n}){const{isRelayConnected:o}=va();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(rr,{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(ro,{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(dr,{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 qc({projects:t,filteredProjects:r,selectedProject:s,selectedSession:a,isLoading:n,loadingProgress:o,expandedProjects:i,editingProject:l,editingName:m,loadingSessions:d,initialSessionsLoaded:u,currentTime:g,editingSession:p,editingSessionName:x,deletingProjects:f,tasksEnabled:h,mcpServerStatus:y,getProjectSessions:N,isProjectStarred:S,onEditingNameChange:v,onToggleProject:b,onProjectSelect:D,onToggleStarProject:A,onStartEditingProject:j,onCancelEditingProject:C,onSaveProjectName:L,onDeleteProject:R,onSessionSelect:_,onDeleteSession:$,onLoadMoreSessions:F,onNewSession:I,onEditingSessionNameChange:U,onStartEditingSession:w,onCancelEditingSession:z,onSaveEditingSession:q,touchHandlerFactory:ee,t:M}){const K=e.jsx(Gc,{isLoading:n,loadingProgress:o,projectsCount:t.length,filteredProjectsCount:r.length,t:M}),T=!n&&t.length>0&&r.length>0;return e.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:T?r.map(G=>e.jsx(Hc,{project:G,selectedProject:s,selectedSession:a,isExpanded:i.has(G.name),isDeleting:f.has(G.name),isStarred:S(G.name),editingProject:l,editingName:m,sessions:N(G),initialSessionsLoaded:u.has(G.name),isLoadingSessions:!!d[G.name],currentTime:g,editingSession:p,editingSessionName:x,tasksEnabled:h,mcpServerStatus:y,onEditingNameChange:v,onToggleProject:b,onProjectSelect:D,onToggleStarProject:A,onStartEditingProject:j,onCancelEditingProject:C,onSaveProjectName:L,onDeleteProject:R,onSessionSelect:_,onDeleteSession:$,onLoadMoreSessions:F,onNewSession:I,onEditingSessionNameChange:U,onStartEditingSession:w,onCancelEditingSession:z,onSaveEditingSession:q,touchHandlerFactory:ee,t:M},G.name)):K})}function Kc({isPWA:t,isMobile:r,isLoading:s,projects:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:l,isRefreshing:m,onCreateProject:d,onCollapseSidebar:u,updateAvailable:g,releaseInfo:p,latestVersion:x,onShowVersionModal:f,onShowSettings:h,projectListProps:y,t:N}){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(_c,{isPWA:t,isMobile:r,isLoading:s,projectsCount:a.length,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:l,isRefreshing:m,onCreateProject:d,onCollapseSidebar:u,t:N}),e.jsx($a,{className:"flex-1 md:px-1.5 md:py-2 overflow-y-auto overscroll-contain",children:e.jsx(qc,{...y})}),e.jsx(Pc,{updateAvailable:g,releaseInfo:p,latestVersion:x,onShowVersionModal:f,onShowSettings:h,t:N})]})}const Vc=({onClose:t,onProjectCreated:r})=>{var ze;const{t:s}=He(),[a,n]=c.useState(1),[o,i]=c.useState("existing"),[l,m]=c.useState(""),[d,u]=c.useState(""),[g,p]=c.useState(""),[x,f]=c.useState("stored"),[h,y]=c.useState(""),[N,S]=c.useState(!1),[v,b]=c.useState(null),[D,A]=c.useState([]),[j,C]=c.useState(!1),[L,R]=c.useState([]),[_,$]=c.useState(!1),[F,I]=c.useState(!1),[U,w]=c.useState("~"),[z,q]=c.useState([]),[ee,M]=c.useState(!1),[K,T]=c.useState(!1),[G,Y]=c.useState(!1),[J,W]=c.useState(""),[O,se]=c.useState(!1),[B,ge]=c.useState("");c.useEffect(()=>{a===2&&o==="new"&&d&&pe()},[a,o,d]),c.useEffect(()=>{l.length>2?k(l):(R([]),$(!1))},[l]);const pe=async()=>{try{C(!0);const V=((await(await Ge.get("/settings/credentials?type=github_token")).json()).credentials||[]).filter(ne=>ne.is_active);A(V),V.length>0&&!g&&p(V[0].id.toString())}catch(re){console.error("Error loading GitHub tokens:",re)}finally{C(!1)}},k=async re=>{try{const fe=re.lastIndexOf("/"),V=fe>0?re.substring(0,fe):"~",we=await(await Ge.browseFilesystem(V)).json();if(we.suggestions){const Ie=we.suggestions.filter(De=>De.path.toLowerCase().startsWith(re.toLowerCase())&&De.path.toLowerCase()!==re.toLowerCase());R(Ie.slice(0,5)),$(Ie.length>0)}}catch(fe){console.error("Error loading path suggestions:",fe)}},E=()=>{if(b(null),a===1){if(!o){b(s("projectWizard.errors.selectType"));return}n(2)}else if(a===2){if(!l.trim()){b(s("projectWizard.errors.providePath"));return}n(3)}},X=()=>{b(null),n(a-1)},ae=async()=>{S(!0),b(null),ge("");try{if(o==="new"&&d){const ne=new URLSearchParams({path:l.trim(),githubUrl:d.trim()});x==="stored"&&g?ne.append("githubTokenId",g):x==="new"&&h&&ne.append("newGithubToken",h.trim());const we=`/api/projects/clone-progress?${ne}`;await new Promise((Ie,De)=>{const Ue=new EventSource(we);Ue.onmessage=Ke=>{try{const Je=JSON.parse(Ke.data);Je.type==="progress"?ge(Je.message):Je.type==="complete"?(Ue.close(),r&&r(Je.project),t(),Ie()):Je.type==="error"&&(Ue.close(),De(new Error(Je.message)))}catch(Je){console.error("Error parsing SSE event:",Je)}},Ue.onerror=()=>{Ue.close(),De(new Error("Connection lost during clone"))}});return}const re={workspaceType:o,path:l.trim()},fe=await Ge.createWorkspace(re),V=await fe.json();if(!fe.ok)throw new Error(V.details||V.error||s("projectWizard.errors.failedToCreate"));r&&r(V.project),t()}catch(re){console.error("Error creating workspace:",re),b(re.message||s("projectWizard.errors.failedToCreate"))}finally{S(!1)}},oe=re=>{m(re.path),$(!1)},Fe=async()=>{I(!0),await he("~")},he=async re=>{try{M(!0);const V=await(await Ge.browseFilesystem(re)).json();w(V.path||re),q(V.suggestions||[])}catch(fe){console.error("Error loading folders:",fe)}finally{M(!1)}},xe=(re,fe=!1)=>{m(re),I(!1),fe&&n(3)},Te=async re=>{await he(re)},Le=async()=>{if(J.trim()){se(!0),b(null);try{const re=U.includes("\\")?"\\":"/",fe=`${U}${re}${J.trim()}`,V=await Ge.createFolder(fe),ne=await V.json();if(!V.ok)throw new Error(ne.error||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"));W(""),Y(!1),await he(ne.path||fe)}catch(re){console.error("Error creating folder:",re),b(re.message||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{se(!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(ds,{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:N,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(re=>e.jsxs(Ft.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 ${re<a?"bg-green-500 text-white":re===a?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:re<a?e.jsx(Et,{className:"w-4 h-4"}):re}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:s(re===1?"projectWizard.steps.type":re===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),re<3&&e.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${re<a?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},re))})}),e.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[v&&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(Es,{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:v})})]}),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(ds,{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(Ut,{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(rt,{type:"text",value:l,onChange:re=>m(re.target.value),placeholder:o==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),_&&L.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:L.map((re,fe)=>e.jsxs("button",{onClick:()=>oe(re),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:re.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:re.path})]},fe))})]}),e.jsx(me,{type:"button",variant:"outline",onClick:Fe,className:"px-3",title:"Browse folders",children:e.jsx(tr,{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(rt,{type:"text",value:d,onChange:re=>u(re.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(wa,{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")})]})]}),j?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(vr,{className:"w-4 h-4 animate-spin"}),s("projectWizard.step2.loadingTokens")]}):D.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 ${x==="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 ${x==="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"),p(""),y("")},className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${x==="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")})]}),x==="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:g,onChange:re=>p(re.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")}),D.map(re=>e.jsx("option",{value:re.id,children:re.credential_name},re.id))]})]}):x==="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(rt,{type:"password",value:h,onChange:re=>y(re.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(rt,{type:"password",value:h,onChange:re=>y(re.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:l})]}),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:x==="stored"&&g?`${s("projectWizard.step3.usingStoredToken")} ${((ze=D.find(re=>re.id.toString()===g))==null?void 0:ze.credential_name)||"Unknown"}`:x==="new"&&h?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:N&&B?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:B})]}):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:X,disabled:N,children:a===1?s("projectWizard.buttons.cancel"):e.jsxs(e.Fragment,{children:[e.jsx(so,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.back")]})}),e.jsx(me,{onClick:a===3?ae:E,disabled:N||a===1&&!o,children:N?e.jsxs(e.Fragment,{children:[e.jsx(vr,{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(Et,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.createProject")]}):e.jsxs(e.Fragment,{children:[s("projectWizard.buttons.next"),e.jsx(zt,{className:"w-4 h-4 ml-1"})]})})]})]}),F&&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(tr,{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:()=>T(!K),className:`p-2 rounded-md transition-colors ${K?"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:K?"Hide hidden folders":"Show hidden folders",children:K?e.jsx(mr,{className:"w-5 h-5"}):e.jsx(ao,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>Y(!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:"Create new folder",children:e.jsx(it,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>I(!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"})})]})]}),G&&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(rt,{type:"text",value:J,onChange:re=>W(re.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:re=>{re.key==="Enter"&&Le(),re.key==="Escape"&&(Y(!1),W(""))},autoFocus:!0}),e.jsx(me,{size:"sm",onClick:Le,disabled:!J.trim()||O,children:O?e.jsx(vr,{className:"w-4 h-4 animate-spin"}):"Create"}),e.jsx(me,{size:"sm",variant:"ghost",onClick:()=>{Y(!1),W("")},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(vr,{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 re=Math.max(U.lastIndexOf("/"),U.lastIndexOf("\\"));let fe;re<=0?fe="/":re===2&&/^[A-Za-z]:/.test(U)?fe=U.substring(0,3):fe=U.substring(0,re),Te(fe)},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(tr,{className:"w-5 h-5 text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),z.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):z.filter(re=>K||!re.name.startsWith(".")).sort((re,fe)=>re.name.toLowerCase().localeCompare(fe.name.toLowerCase())).map((re,fe)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Te(re.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(ds,{className:"w-5 h-5 text-blue-500"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:re.name})]}),e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>xe(re.path,o==="existing"),className:"text-xs px-3",children:"Select"})]},fe))]})}),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:()=>{I(!1),Y(!1),W("")},children:"Cancel"}),e.jsx(me,{variant:"outline",onClick:()=>xe(U,o==="existing"),children:"Use this folder"})]})]})]})})]})},Jc="2.4.0";function Yc(){const{t}=He("settings"),[r,s]=c.useState([]),[a,n]=c.useState([]),[o,i]=c.useState(!0),[l,m]=c.useState(!1),[d,u]=c.useState(!1),[g,p]=c.useState(""),[x,f]=c.useState(""),[h,y]=c.useState(""),[N,S]=c.useState(""),[v,b]=c.useState({}),[D,A]=c.useState(null),[j,C]=c.useState(null),{updateAvailable:L,latestVersion:R,releaseInfo:_}=yo("thinqmesh","upfynai-code");c.useEffect(()=>{$()},[]);const $=async()=>{try{i(!0);const K=await(await Se("/api/settings/api-keys")).json();s(K.apiKeys||[]);const G=await(await Se("/api/settings/credentials?type=github_token")).json();n(G.credentials||[])}catch(M){console.error("Error fetching settings:",M)}finally{i(!1)}},F=async()=>{if(g.trim())try{const K=await(await Se("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:g})})).json();K.success&&(C(K.apiKey),p(""),m(!1),$())}catch(M){console.error("Error creating API key:",M)}},I=async M=>{if(confirm(t("apiKeys.confirmDelete")))try{await Se(`/api/settings/api-keys/${M}`,{method:"DELETE"}),$()}catch(K){console.error("Error deleting API key:",K)}},U=async(M,K)=>{try{await Se(`/api/settings/api-keys/${M}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!K})}),$()}catch(T){console.error("Error toggling API key:",T)}},w=async()=>{if(!(!x.trim()||!h.trim()))try{(await(await Se("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:x,credentialType:"github_token",credentialValue:h,description:N})})).json()).success&&(f(""),y(""),S(""),u(!1),$())}catch(M){console.error("Error creating GitHub credential:",M)}},z=async M=>{if(confirm(t("apiKeys.github.confirmDelete")))try{await Se(`/api/settings/credentials/${M}`,{method:"DELETE"}),$()}catch(K){console.error("Error deleting GitHub credential:",K)}},q=async(M,K)=>{try{await Se(`/api/settings/credentials/${M}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!K})}),$()}catch(T){console.error("Error toggling GitHub credential:",T)}},ee=(M,K)=>{navigator.clipboard.writeText(M),A(K),setTimeout(()=>A(null),2e3)};return o?e.jsx("div",{className:"text-muted-foreground",children:t("apiKeys.loading")}):e.jsxs("div",{className:"space-y-8",children:[j&&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:j.apiKey}),e.jsx(me,{size:"sm",variant:"outline",onClick:()=>ee(j.apiKey,"new"),children:D==="new"?e.jsx(Et,{className:"h-4 w-4"}):e.jsx(ja,{className:"h-4 w-4"})})]}),e.jsx(me,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>C(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(wa,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.title")})]}),e.jsxs(me,{size:"sm",onClick:()=>m(!l),children:[e.jsx(it,{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(qa,{className:"h-3 w-3"})]})]}),l&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[e.jsx(rt,{placeholder:t("apiKeys.form.placeholder"),value:g,onChange:M=>p(M.target.value),className:"mb-2"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(me,{onClick:F,children:t("apiKeys.form.createButton")}),e.jsx(me,{variant:"outline",onClick:()=>m(!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:()=>I(M.id),children:e.jsx(ft,{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(Si,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.github.title")})]}),e.jsxs(me,{size:"sm",onClick:()=>u(!d),children:[e.jsx(it,{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(rt,{placeholder:t("apiKeys.github.form.namePlaceholder"),value:x,onChange:M=>f(M.target.value)}),e.jsxs("div",{className:"relative",children:[e.jsx(rt,{type:v.new?"text":"password",placeholder:t("apiKeys.github.form.tokenPlaceholder"),value:h,onChange:M=>y(M.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>b({...v,new:!v.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:v.new?e.jsx(ao,{className:"h-4 w-4"}):e.jsx(mr,{className:"h-4 w-4"})})]}),e.jsx(rt,{placeholder:t("apiKeys.github.form.descriptionPlaceholder"),value:N,onChange:M=>S(M.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(me,{onClick:w,children:t("apiKeys.github.form.addButton")}),e.jsx(me,{variant:"outline",onClick:()=>{u(!1),f(""),y(""),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:()=>q(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:()=>z(M.id),children:e.jsx(ft,{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:(_==null?void 0:_.htmlUrl)||"https://github.com/thinqmesh/upfynai-code/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Jc]}),L&&R&&e.jsxs("a",{href:(_==null?void 0:_.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:R})}),e.jsx(qa,{className:"h-2.5 w-2.5"})]})]})})]})}function Qc(){const{t}=He("settings"),[r,s]=c.useState(""),[a,n]=c.useState(""),[o,i]=c.useState(!1),[l,m]=c.useState(!1),[d,u]=c.useState(null);c.useEffect(()=>{g()},[]);const g=async()=>{try{i(!0);const x=await Se("/api/user/git-config");if(x.ok){const f=await x.json();s(f.gitName||""),n(f.gitEmail||"")}}catch(x){console.error("Error loading git config:",x)}finally{i(!1)}},p=async()=>{try{m(!0);const x=await Se("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:a})});if(x.ok)u("success"),setTimeout(()=>u(null),3e3);else{const f=await x.json();u("error"),console.error("Failed to save git config:",f.error)}}catch(x){console.error("Error saving git config:",x),u("error")}finally{m(!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(Ut,{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(rt,{id:"settings-git-name",type:"text",value:r,onChange:x=>s(x.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(rt,{id:"settings-git-email",type:"email",value:a,onChange:x=>n(x.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:p,disabled:l||!r||!a,children:t(l?"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(Et,{className:"w-4 h-4"}),t("git.status.success")]})]})]})]})})}function Xc(){const{t}=He("settings"),{tasksEnabled:r,setTasksEnabled:s,isTaskMasterInstalled:a,isCheckingInstallation:n}=qr();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 Zc={claude:{name:"Claude",color:"blue"},cursor:{name:"Cursor",color:"purple"},codex:{name:"Codex",color:"gray"}},ed={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 yr({agentId:t,authStatus:r,isSelected:s,onClick:a,isMobile:n=!1}){const{t:o}=He("settings"),i=Zc[t],l=ed[i.color];return n?e.jsx("button",{onClick:a,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${s?`${l.borderBottom} ${l.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(It,{provider:t,className:"w-5 h-5"}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:i.name}),(r==null?void 0:r.authenticated)&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l.dot}`})]})}):e.jsxs("button",{onClick:a,className:`w-full text-left p-3 border-l-4 transition-colors ${s?`${l.border} ${l.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(It,{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!=null&&r.loading?e.jsx("span",{className:"text-gray-400",children:o("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l.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 td={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 rd({agent:t,authStatus:r,onLogin:s}){const{t:a}=He("settings"),n=td[t];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(It,{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!=null&&r.loading?a("agents.authStatus.checkingAuth"):r!=null&&r.authenticated?a("agents.authStatus.loggedInAs",{email:r.email||a("agents.authStatus.authenticatedUser")}):a("agents.authStatus.notConnected")})]}),e.jsx("div",{children:r!=null&&r.loading?e.jsx(At,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:a("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsx(At,{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(At,{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!=null&&r.authenticated?a("agents.login.reAuthenticate"):a("agents.login.title")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&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(Ei,{className:"w-4 h-4 mr-2"}),r!=null&&r.authenticated?a("agents.login.reLoginButton"):a("agents.login.button")]})]})}),(r==null?void 0: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 sd=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],ad=["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 nd({skipPermissions:t,setSkipPermissions:r,allowedTools:s,setAllowedTools:a,disallowedTools:n,setDisallowedTools:o,newAllowedTool:i,setNewAllowedTool:l,newDisallowedTool:m,setNewDisallowedTool:d}){const{t:u}=He("settings"),g=h=>{h&&!s.includes(h)&&(a([...s,h]),l(""))},p=h=>{a(s.filter(y=>y!==h))},x=h=>{h&&!n.includes(h)&&(o([...n,h]),d(""))},f=h=>{o(n.filter(y=>y!==h))};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(Ht,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("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:h=>r(h.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:u("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:u("permissions.skipPermissions.claudeDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pt,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("permissions.allowedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u("permissions.allowedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(rt,{value:i,onChange:h=>l(h.target.value),placeholder:u("permissions.allowedTools.placeholder"),onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),g(i))},className:"flex-1 h-10"}),e.jsxs(me,{onClick:()=>g(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(it,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:u("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:u("permissions.allowedTools.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:sd.map(h=>e.jsx(me,{variant:"outline",size:"sm",onClick:()=>g(h),disabled:s.includes(h),className:"text-xs h-8",children:h},h))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(h=>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:h}),e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>p(h),className:"text-green-600 hover:text-green-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},h)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:u("permissions.allowedTools.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ht,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("permissions.blockedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u("permissions.blockedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(rt,{value:m,onChange:h=>d(h.target.value),placeholder:u("permissions.blockedTools.placeholder"),onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),x(m))},className:"flex-1 h-10"}),e.jsxs(me,{onClick:()=>x(m),disabled:!m,size:"sm",className:"h-10 px-4",children:[e.jsx(it,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:u("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(h=>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:h}),e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>f(h),className:"text-red-600 hover:text-red-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},h)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:u("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:u("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:*)"'})," ",u("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:*)"'})," ",u("permissions.toolExamples.bashGitDiff")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," ",u("permissions.toolExamples.write")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," ",u("permissions.toolExamples.bashRm")]})]})]})]})}function od({skipPermissions:t,setSkipPermissions:r,allowedCommands:s,setAllowedCommands:a,disallowedCommands:n,setDisallowedCommands:o,newAllowedCommand:i,setNewAllowedCommand:l,newDisallowedCommand:m,setNewDisallowedCommand:d}){const{t:u}=He("settings"),g=h=>{h&&!s.includes(h)&&(a([...s,h]),l(""))},p=h=>{a(s.filter(y=>y!==h))},x=h=>{h&&!n.includes(h)&&(o([...n,h]),d(""))},f=h=>{o(n.filter(y=>y!==h))};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(Ht,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("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:h=>r(h.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:u("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:u("permissions.skipPermissions.cursorDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pt,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("permissions.allowedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u("permissions.allowedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(rt,{value:i,onChange:h=>l(h.target.value),placeholder:u("permissions.allowedCommands.placeholder"),onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),g(i))},className:"flex-1 h-10"}),e.jsxs(me,{onClick:()=>g(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(it,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:u("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:u("permissions.allowedCommands.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ad.map(h=>e.jsx(me,{variant:"outline",size:"sm",onClick:()=>g(h),disabled:s.includes(h),className:"text-xs h-8",children:h},h))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(h=>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:h}),e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>p(h),className:"text-green-600 hover:text-green-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},h)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:u("permissions.allowedCommands.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ht,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("permissions.blockedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u("permissions.blockedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(rt,{value:m,onChange:h=>d(h.target.value),placeholder:u("permissions.blockedCommands.placeholder"),onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),x(m))},className:"flex-1 h-10"}),e.jsxs(me,{onClick:()=>x(m),disabled:!m,size:"sm",className:"h-10 px-4",children:[e.jsx(it,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:u("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(h=>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:h}),e.jsx(me,{variant:"ghost",size:"sm",onClick:()=>f(h),className:"text-red-600 hover:text-red-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},h)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:u("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:u("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)"'})," ",u("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)"'})," ",u("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)"'})," ",u("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)"'})," ",u("permissions.shellExamples.rmRf")]})]})]})]})}function id({permissionMode:t,setPermissionMode:r}){const{t:s}=He("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(Pt,{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(Ht,{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 Ws({agent:t,...r}){return t==="claude"?e.jsx(nd,{...r}):t==="cursor"?e.jsx(od,{...r}):t==="codex"?e.jsx(id,{...r}):null}const ld=t=>{switch(t){case"stdio":return e.jsx(mt,{className:"w-4 h-4"});case"sse":return e.jsx(Na,{className:"w-4 h-4"});case"http":return e.jsx(Hr,{className:"w-4 h-4"});default:return e.jsx(Ts,{className:"w-4 h-4"})}};function cd({servers:t,onAdd:r,onEdit:s,onDelete:a,onTest:n,onDiscoverTools:o,testResults:i,serverTools:l,toolsLoading:m}){const{t:d}=He("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ts,{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(it,{className:"w-4 h-4 mr-2"}),d("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(u=>{var g,p,x,f;return 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:[ld(u.type),e.jsx("span",{className:"font-medium text-foreground",children:u.name}),e.jsx(At,{variant:"outline",className:"text-xs",children:u.type}),e.jsx(At,{variant:"outline",className:"text-xs",children:u.scope==="local"?d("mcpServers.scope.local"):u.scope==="user"?d("mcpServers.scope.user"):u.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[u.type==="stdio"&&((g=u.config)==null?void 0:g.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:u.config.command})]}),(u.type==="sse"||u.type==="http")&&((p=u.config)==null?void 0:p.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:u.config.url})]}),((x=u.config)==null?void 0:x.args)&&u.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:u.config.args.join(" ")})]})]}),(i==null?void 0:i[u.id])&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[u.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[u.id].message})}),(l==null?void 0:l[u.id])&&((f=l[u.id].tools)==null?void 0:f.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:l[u.id].tools.length})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[l[u.id].tools.slice(0,5).map((h,y)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:h.name},y)),l[u.id].tools.length>5&&e.jsx("span",{className:"text-xs opacity-75",children:d("mcpServers.tools.more",{count:l[u.id].tools.length-5})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(me,{onClick:()=>s(u),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:d("mcpServers.actions.edit"),children:e.jsx(Ur,{className:"w-4 h-4"})}),e.jsx(me,{onClick:()=>a(u.id,u.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:d("mcpServers.actions.delete"),children:e.jsx(ft,{className:"w-4 h-4"})})]})]})},u.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:d("mcpServers.empty")})]})]})}function dd({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=He("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ts,{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(it,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i;return 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(mt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(At,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:((i=o.config)==null?void 0:i.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(Ur,{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(ft,{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 md({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=He("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ts,{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(it,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i,l,m;return 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(mt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(At,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[((i=o.config)==null?void 0:i.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})]}),((l=o.config)==null?void 0:l.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(" ")})]}),((m=o.config)==null?void 0:m.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(([d,u])=>`${d}=${u}`).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(Ur,{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(ft,{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 Us({agent:t,...r}){return t==="claude"?e.jsx(cd,{...r}):t==="cursor"?e.jsx(dd,{...r}):t==="codex"?e.jsx(md,{...r}):null}function zo({compact:t=!1}){const{i18n:r,t:s}=He("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(no,{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:Ua.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:Ua.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]})})}function ud({isOpen:t,onClose:r,projects:s=[],initialTab:a="agents"}){var Oa,Ra,Ba,Wa;const{isDarkMode:n,toggleDarkMode:o}=ka(),{t:i}=He("settings"),[l,m]=c.useState([]),[d,u]=c.useState([]),[g,p]=c.useState(""),[x,f]=c.useState(""),[h,y]=c.useState(!1),[N,S]=c.useState(!1),[v,b]=c.useState(null),[D,A]=c.useState("name"),[j,C]=c.useState([]),[L,R]=c.useState(!1),[_,$]=c.useState(null),[F,I]=c.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[U,w]=c.useState(!1),[z,q]=c.useState({}),[ee,M]=c.useState({}),[K,T]=c.useState({}),[G,Y]=c.useState(a),[J,W]=c.useState(""),[O,se]=c.useState("claude"),[B,ge]=c.useState("account"),[pe,k]=c.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[E,X]=c.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[ae,oe]=c.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[Fe,he]=c.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[xe,Te]=c.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[Le,ze]=c.useState([]),[re,fe]=c.useState([]),[V,ne]=c.useState(!1),[we,Ie]=c.useState(""),[De,Ue]=c.useState(""),[Ke,Je]=c.useState([]),[de,Me]=c.useState([]),[Ne,_e]=c.useState("default"),[Oe,Pe]=c.useState(!1),[te,be]=c.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[$e,Be]=c.useState(null),[st,Tt]=c.useState(!1),[pt,vt]=c.useState(!1),[lt,ie]=c.useState(""),[ue,ce]=c.useState(null),[je,We]=c.useState({authenticated:!1,email:null,loading:!0,error:null}),[Ye,Ze]=c.useState({authenticated:!1,email:null,loading:!0,error:null}),[ct,Ot]=c.useState({authenticated:!1,email:null,loading:!0,error:null}),St=async()=>{try{const P=await Se("/api/cursor/mcp");if(P.ok){const Q=await P.json();Je(Q.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(P){console.error("Error fetching Cursor MCP servers:",P)}},xt=async()=>{try{const P=await Se("/api/codex/mcp/config/read");if(P.ok){const le=await P.json();if(le.success&&le.servers){Me(le.servers);return}}const Q=await Se("/api/codex/mcp/cli/list");if(Q.ok){const le=await Q.json();if(le.success&&le.servers){const Ce=le.servers.map(et=>({id:et.name,name:et.name,type:et.type||"stdio",scope:"user",config:{command:et.command||"",args:et.args||[],env:et.env||{}}}));Me(Ce)}}}catch(P){console.error("Error fetching Codex MCP servers:",P)}},at=async()=>{try{const P=await Se("/api/mcp/config/read");if(P.ok){const Ce=await P.json();if(Ce.success&&Ce.servers){C(Ce.servers);return}}const Q=await Se("/api/mcp/cli/list");if(Q.ok){const Ce=await Q.json();if(Ce.success&&Ce.servers){const et=Ce.servers.map(ut=>({id:ut.name,name:ut.name,type:ut.type,scope:"user",config:{command:ut.command||"",args:ut.args||[],env:ut.env||{},url:ut.url||"",headers:ut.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));C(et);return}}const le=await Se("/api/mcp/servers?scope=user");if(le.ok){const Ce=await le.json();C(Ce.servers||[])}else console.error("Failed to fetch MCP servers")}catch(P){console.error("Error fetching MCP servers:",P)}},dt=async P=>{var Q,le,Ce,et,ut;try{_&&await Dt(_.id,"user");const gr=await Se("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath,command:(Q=P.config)==null?void 0:Q.command,args:((le=P.config)==null?void 0:le.args)||[],url:(Ce=P.config)==null?void 0:Ce.url,headers:((et=P.config)==null?void 0:et.headers)||{},env:((ut=P.config)==null?void 0:ut.env)||{}})});if(gr.ok){const Xr=await gr.json();if(Xr.success)return await at(),!0;throw new Error(Xr.error||"Failed to save server via Claude CLI")}else{const Xr=await gr.json();throw new Error(Xr.error||"Failed to save server")}}catch(gr){throw console.error("Error saving MCP server:",gr),gr}},Dt=async(P,Q="user")=>{try{const le=await Se(`/api/mcp/cli/remove/${P}?scope=${Q}`,{method:"DELETE"});if(le.ok){const Ce=await le.json();if(Ce.success)return await at(),!0;throw new Error(Ce.error||"Failed to delete server via Claude CLI")}else{const Ce=await le.json();throw new Error(Ce.error||"Failed to delete server")}}catch(le){throw console.error("Error deleting MCP server:",le),le}},qt=async(P,Q="user")=>{try{const le=await Se(`/api/mcp/servers/${P}/test?scope=${Q}`,{method:"POST"});if(le.ok)return(await le.json()).testResult;{const Ce=await le.json();throw new Error(Ce.error||"Failed to test server")}}catch(le){throw console.error("Error testing MCP server:",le),le}},xr=async(P,Q="user")=>{try{const le=await Se(`/api/mcp/servers/${P}/tools?scope=${Q}`,{method:"POST"});if(le.ok)return(await le.json()).toolsResult;{const Ce=await le.json();throw new Error(Ce.error||"Failed to discover tools")}}catch(le){throw console.error("Error discovering MCP tools:",le),le}},H=async P=>{var Q,le,Ce;try{$e&&await Z($e.id);const et=await Se("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,command:(Q=P.config)==null?void 0:Q.command,args:((le=P.config)==null?void 0:le.args)||[],env:((Ce=P.config)==null?void 0:Ce.env)||{}})});if(et.ok){const ut=await et.json();if(ut.success)return await xt(),!0;throw new Error(ut.error||"Failed to save Codex MCP server")}else{const ut=await et.json();throw new Error(ut.error||"Failed to save server")}}catch(et){throw console.error("Error saving Codex MCP server:",et),et}},Z=async P=>{try{const Q=await Se(`/api/codex/mcp/cli/remove/${P}`,{method:"DELETE"});if(Q.ok){const le=await Q.json();if(le.success)return await xt(),!0;throw new Error(le.error||"Failed to delete Codex MCP server")}else{const le=await Q.json();throw new Error(le.error||"Failed to delete server")}}catch(Q){throw console.error("Error deleting Codex MCP server:",Q),Q}},Ee=()=>{be({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),Be(null),Pe(!1)},Xe=(P=null)=>{var Q,le,Ce;P?(Be(P),be({name:P.name,type:P.type||"stdio",config:{command:((Q=P.config)==null?void 0:Q.command)||"",args:((le=P.config)==null?void 0:le.args)||[],env:((Ce=P.config)==null?void 0:Ce.env)||{}}})):Ee(),Pe(!0)},kt=async P=>{P.preventDefault(),Tt(!0);try{$e&&await Z($e.name),await H(te),Ee(),b("success")}catch(Q){alert(`Error: ${Q.message}`),b("error")}finally{Tt(!1)}},gt=async P=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await Z(P),b("success")}catch(Q){alert(`Error: ${Q.message}`),b("error")}};c.useEffect(()=>{t&&(Ms(),Vr(),Jr(),Yr(),Y(a))},[t,a]),c.useEffect(()=>{localStorage.setItem("codeEditorTheme",pe),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[pe]),c.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",E.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[E]),c.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",ae.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ae]),c.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",Fe.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Fe]),c.useEffect(()=>{localStorage.setItem("codeEditorFontSize",xe),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[xe]);const Ms=async()=>{try{const P=localStorage.getItem("claude-settings");if(P){const Ce=JSON.parse(P);m(Ce.allowedTools||[]),u(Ce.disallowedTools||[]),y(Ce.skipPermissions||!1),A(Ce.projectSortOrder||"name")}else m([]),u([]),y(!1),A("name");const Q=localStorage.getItem("cursor-tools-settings");if(Q){const Ce=JSON.parse(Q);ze(Ce.allowedCommands||[]),fe(Ce.disallowedCommands||[]),ne(Ce.skipPermissions||!1)}else ze([]),fe([]),ne(!1);const le=localStorage.getItem("codex-settings");if(le){const Ce=JSON.parse(le);_e(Ce.permissionMode||"default")}else _e("default");await at(),await St(),await xt()}catch(P){console.error("Error loading tool settings:",P),m([]),u([]),y(!1),A("name")}},Vr=async()=>{try{const P=await Se("/api/cli/claude/status");if(P.ok){const Q=await P.json();We({authenticated:Q.authenticated,email:Q.email,loading:!1,error:Q.error||null})}else We({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Claude auth status:",P),We({authenticated:!1,email:null,loading:!1,error:P.message})}},Jr=async()=>{try{const P=await Se("/api/cli/cursor/status");if(P.ok){const Q=await P.json();Ze({authenticated:Q.authenticated,email:Q.email,loading:!1,error:Q.error||null})}else Ze({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Cursor auth status:",P),Ze({authenticated:!1,email:null,loading:!1,error:P.message})}},Yr=async()=>{try{const P=await Se("/api/cli/codex/status");if(P.ok){const Q=await P.json();Ot({authenticated:Q.authenticated,email:Q.email,loading:!1,error:Q.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})}},$s=()=>{ie("claude"),ce((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),vt(!0)},Fs=()=>{ie("cursor"),ce((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),vt(!0)},Ir=()=>{ie("codex"),ce((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),vt(!0)},Ps=P=>{P===0&&(b("success"),lt==="claude"?Vr():lt==="cursor"?Jr():lt==="codex"&&Yr())},Ls=()=>{S(!0),b(null);try{const P={allowedTools:l,disallowedTools:d,skipPermissions:h,projectSortOrder:D,lastUpdated:new Date().toISOString()},Q={allowedCommands:Le,disallowedCommands:re,skipPermissions:V,lastUpdated:new Date().toISOString()},le={permissionMode:Ne,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(P)),localStorage.setItem("cursor-tools-settings",JSON.stringify(Q)),localStorage.setItem("codex-settings",JSON.stringify(le)),b("success"),setTimeout(()=>{r()},1e3)}catch(P){console.error("Error saving tool settings:",P),b("error")}finally{S(!1)}},Kt=()=>{I({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),$(null),R(!1),W("")},Qr=(P=null)=>{P?($(P),I({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath||"",config:{...P.config},raw:P.raw,importMode:"form",jsonInput:""})):Kt(),R(!0)},_s=async P=>{P.preventDefault(),w(!0);try{if(F.importMode==="json"){const Q=await Se("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:F.name,jsonConfig:F.jsonInput,scope:F.scope,projectPath:F.projectPath})});if(Q.ok){const le=await Q.json();if(le.success)await at(),Kt(),b("success");else throw new Error(le.error||"Failed to add server via JSON")}else{const le=await Q.json();throw new Error(le.error||"Failed to add server")}}else await dt(F),Kt(),b("success")}catch(Q){alert(`Error: ${Q.message}`),b("error")}finally{w(!1)}},wt=async(P,Q)=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await Dt(P,Q),b("success")}catch(le){alert(`Error: ${le.message}`),b("error")}},Vt=async(P,Q)=>{try{q({...z,[P]:{loading:!0}});const le=await qt(P,Q);q({...z,[P]:le})}catch(le){q({...z,[P]:{success:!1,message:le.message,details:[]}})}},za=async(P,Q)=>{try{T({...K,[P]:!0});const le=await xr(P,Q);M({...ee,[P]:le})}catch{M({...ee,[P]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{T({...K,[P]:!1})}},nr=(P,Q)=>{I(le=>({...le,config:{...le.config,[P]:Q}}))};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:()=>Y("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${G==="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:()=>Y("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${G==="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:()=>Y("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${G==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Ut,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.git")]}),e.jsxs("button",{onClick:()=>Y("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${G==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(wa,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]}),e.jsx("button",{onClick:()=>Y("tasks"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${G==="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:[G==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:G==="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(Xs,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Zs,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),e.jsx("div",{className:"space-y-4",children:e.jsx(zo,{})}),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:D,onChange:P=>A(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:()=>k(pe==="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":pe==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${pe==="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:pe==="dark"?e.jsx(Xs,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Zs,{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:()=>X(!E),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":E,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${E?"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:()=>oe(!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 minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),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.lineNumbers.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.description")})]}),e.jsxs("button",{onClick:()=>he(!Fe),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":Fe,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${Fe?"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:xe,onChange:P=>Te(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"})]})]})})]})]})}),G==="git"&&e.jsx(Qc,{}),G==="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(yr,{agentId:"claude",authStatus:je,isSelected:O==="claude",onClick:()=>se("claude"),isMobile:!0}),e.jsx(yr,{agentId:"cursor",authStatus:Ye,isSelected:O==="cursor",onClick:()=>se("cursor"),isMobile:!0}),e.jsx(yr,{agentId:"codex",authStatus:ct,isSelected:O==="codex",onClick:()=>se("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(yr,{agentId:"claude",authStatus:je,isSelected:O==="claude",onClick:()=>se("claude")}),e.jsx(yr,{agentId:"cursor",authStatus:Ye,isSelected:O==="cursor",onClick:()=>se("cursor")}),e.jsx(yr,{agentId:"codex",authStatus:ct,isSelected:O==="codex",onClick:()=>se("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:()=>ge("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 ${B==="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:()=>ge("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 ${B==="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:()=>ge("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 ${B==="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:[B==="account"&&e.jsx(rd,{agent:O,authStatus:O==="claude"?je:O==="cursor"?Ye:ct,onLogin:O==="claude"?$s:O==="cursor"?Fs:Ir}),B==="permissions"&&O==="claude"&&e.jsx(Ws,{agent:"claude",skipPermissions:h,setSkipPermissions:y,allowedTools:l,setAllowedTools:m,disallowedTools:d,setDisallowedTools:u,newAllowedTool:g,setNewAllowedTool:p,newDisallowedTool:x,setNewDisallowedTool:f}),B==="permissions"&&O==="cursor"&&e.jsx(Ws,{agent:"cursor",skipPermissions:V,setSkipPermissions:ne,allowedCommands:Le,setAllowedCommands:ze,disallowedCommands:re,setDisallowedCommands:fe,newAllowedCommand:we,setNewAllowedCommand:Ie,newDisallowedCommand:De,setNewDisallowedCommand:Ue}),B==="permissions"&&O==="codex"&&e.jsx(Ws,{agent:"codex",permissionMode:Ne,setPermissionMode:_e}),B==="mcp"&&O==="claude"&&e.jsx(Us,{agent:"claude",servers:j,onAdd:()=>Qr(),onEdit:P=>Qr(P),onDelete:(P,Q)=>wt(P,Q),onTest:(P,Q)=>Vt(P,Q),onDiscoverTools:(P,Q)=>za(P,Q),testResults:z,serverTools:ee,toolsLoading:K}),B==="mcp"&&O==="cursor"&&e.jsx(Us,{agent:"cursor",servers:Ke,onAdd:()=>{},onEdit:P=>{},onDelete:P=>{}}),B==="mcp"&&O==="codex"&&e.jsx(Us,{agent:"codex",servers:de,onAdd:()=>Xe(),onEdit:P=>Xe(P),onDelete:P=>gt(P)})]})]})]}),L&&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(_?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(me,{variant:"ghost",size:"sm",onClick:Kt,children:e.jsx(qe,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:_s,className:"p-4 space-y-4",children:[!_&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>I(P=>({...P,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${F.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:()=>I(P=>({...P,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${F.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")})]}),F.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-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:[F.scope==="user"?e.jsx(Hr,{className:"w-4 h-4"}):e.jsx(tr,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:F.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),F.scope==="local"&&F.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",F.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),F.importMode==="form"&&!_&&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:()=>I(P=>({...P,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${F.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(Hr,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),e.jsx("button",{type:"button",onClick:()=>I(P=>({...P,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${F.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(tr,{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:F.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),F.scope==="local"&&!_&&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:F.projectPath,onChange:P=>I(Q=>({...Q,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:F.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))]}),F.projectPath&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:F.projectPath})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:F.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(rt,{value:F.name,onChange:P=>{I(Q=>({...Q,name:P.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),F.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:F.type,onChange:P=>{I(Q=>({...Q,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"})]})]})]}),_&&F.raw&&F.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:_.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(F.raw,null,2)})]}),F.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:F.jsonInput,onChange:P=>{I(Q=>({...Q,jsonInput:P.target.value}));try{if(P.target.value.trim()){const Q=JSON.parse(P.target.value);Q.type?Q.type==="stdio"&&!Q.command?W(i("mcpForm.validation.stdioRequiresCommand")):(Q.type==="http"||Q.type==="sse")&&!Q.url?W(i("mcpForm.validation.httpRequiresUrl",{type:Q.type})):W(""):W(i("mcpForm.validation.missingType"))}}catch{P.target.value.trim()?W(i("mcpForm.validation.invalidJson")):W("")}},className:`w-full px-3 py-2 border ${J?"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}),J&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:J}),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"}']})]})}),F.importMode==="form"&&F.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(rt,{value:F.config.command,onChange:P=>nr("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(F.config.args)?F.config.args.join(`
10
+ `):"",onChange:P=>nr("args",P.target.value.split(`
11
+ `).filter(Q=>Q.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`})]})]}),F.importMode==="form"&&(F.type==="sse"||F.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(rt,{value:F.config.url,onChange:P=>nr("url",P.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),F.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(F.config.env||{}).map(([P,Q])=>`${P}=${Q}`).join(`
13
+ `),onChange:P=>{const Q={};P.target.value.split(`
14
+ `).forEach(le=>{const[Ce,...et]=le.split("=");Ce&&Ce.trim()&&(Q[Ce.trim()]=et.join("=").trim())}),nr("env",Q)},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`})]}),F.importMode==="form"&&(F.type==="sse"||F.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(F.config.headers||{}).map(([P,Q])=>`${P}=${Q}`).join(`
16
+ `),onChange:P=>{const Q={};P.target.value.split(`
17
+ `).forEach(le=>{const[Ce,...et]=le.split("=");Ce&&Ce.trim()&&(Q[Ce.trim()]=et.join("=").trim())}),nr("headers",Q)},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:Kt,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":_?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),Oe&&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($e?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(me,{variant:"ghost",size:"sm",onClick:Ee,children:e.jsx(qe,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:kt,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(rt,{value:te.name,onChange:P=>be(Q=>({...Q,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(rt,{value:((Oa=te.config)==null?void 0:Oa.command)||"",onChange:P=>be(Q=>({...Q,config:{...Q.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:(((Ra=te.config)==null?void 0:Ra.args)||[]).join(`
19
+ `),onChange:P=>be(Q=>({...Q,config:{...Q.config,args:P.target.value.split(`
20
+ `).filter(le=>le.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(((Ba=te.config)==null?void 0:Ba.env)||{}).map(([P,Q])=>`${P}=${Q}`).join(`
22
+ `),onChange:P=>{const Q={};P.target.value.split(`
23
+ `).forEach(le=>{const[Ce,...et]=le.split("=");Ce&&et.length>0&&(Q[Ce.trim()]=et.join("=").trim())}),be(le=>({...le,config:{...le.config,env:Q}}))},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:Ee,children:i("mcpForm.actions.cancel")}),e.jsx(me,{type:"submit",disabled:st||!te.name||!((Wa=te.config)!=null&&Wa.command),className:"bg-green-600 hover:bg-green-700 text-white",children:i(st?"mcpForm.actions.saving":$e?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),G==="tasks"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(Xc,{})}),G==="api"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(Yc,{})})]})]}),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:[v==="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")]}),v==="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:N,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),e.jsx(me,{onClick:Ls,disabled:N,className:"flex-1 sm:flex-none h-10 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 touch-manipulation",children:N?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(rl,{isOpen:pt,onClose:()=>vt(!1),provider:lt,project:ue,onComplete:Ps,isAuthenticated:lt==="claude"?je.authenticated:lt==="cursor"?Ye.authenticated:lt==="codex"?ct.authenticated:!1},lt)]}):null}function pd({isOpen:t,onClose:r,releaseInfo:s,currentVersion:a,latestVersion:n}){const{t:o}=He("common"),[i,l]=c.useState(!1),[m,d]=c.useState(""),[u,g]=c.useState(""),p=c.useCallback(async()=>{l(!0),d(`Starting update...
25
+ `),g("");try{const x=await Se("/api/system/update",{method:"POST"}),f=await x.json();x.ok?(d(h=>h+f.output+`
26
+ `),d(h=>h+`
27
+ ✅ Update completed successfully!
28
+ `),d(h=>h+`Please restart the server to apply changes.
29
+ `)):(g(f.error||"Update failed"),d(h=>h+`
30
+ ❌ Update failed: `+(f.error||"Unknown error")+`
31
+ `))}catch(x){g(x.message),d(f=>f+`
32
+ ❌ Update failed: `+x.message+`
33
+ `)}finally{l(!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==null?void 0: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==null?void 0: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==null?void 0: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:xd(s.body)})})]}),(m||u)&&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:m})}),u&&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:u})]}),!i&&!m&&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(m?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!m&&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:p,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 xd=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():"",gd=ud;function hd(t){return e.jsx(gd,{...t})}function fd({projects:t,showSettings:r,settingsInitialTab:s,onCloseSettings:a,showNewProject:n,onCloseNewProject:o,onProjectCreated:i,deleteConfirmation:l,onCancelDeleteProject:m,onConfirmDeleteProject:d,sessionDeleteConfirmation:u,onCancelDeleteSession:g,onConfirmDeleteSession:p,showVersionModal:x,onCloseVersionModal:f,releaseInfo:h,currentVersion:y,latestVersion:N,t:S}){const v=c.useMemo(()=>t.map(Wl),[t]);return e.jsxs(e.Fragment,{children:[n&&Zr.createPortal(e.jsx(Vc,{onClose:o,onProjectCreated:i}),document.body),r&&Zr.createPortal(e.jsx(hd,{isOpen:r,onClose:a,projects:v,initialTab:s}),document.body),l&&Zr.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(Ht,{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:l.project.displayName||l.project.name}),"?"]}),l.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:l.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:m,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(ft,{className:"w-4 h-4 mr-2"}),S("actions.delete")]})]})]})}),document.body),u&&Zr.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(Ht,{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:u.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:g,children:S("actions.cancel")}),e.jsxs(me,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:p,children:[e.jsx(ft,{className:"w-4 h-4 mr-2"}),S("actions.delete")]})]})]})}),document.body),e.jsx(pd,{isOpen:x,onClose:f,releaseInfo:h,currentVersion:y,latestVersion:N})]})}function xn({projects:t,selectedProject:r,selectedSession:s,onProjectSelect:a,onSessionSelect:n,onNewSession:o,onSessionDelete:i,onProjectDelete:l,isLoading:m,loadingProgress:d,onRefresh:u,onShowSettings:g,showSettings:p,settingsInitialTab:x,onCloseSettings:f,isMobile:h}){const{t:y}=He(["sidebar","common"]),{isPWA:N}=Ia({trackMobile:!1}),{updateAvailable:S,latestVersion:v,currentVersion:b,releaseInfo:D}=yo("thinqmesh","upfynai-code"),{preferences:A,setPreference:j}=Aa(),{sidebarVisible:C}=A,{setCurrentProject:L,mcpServerStatus:R}=Er(),{tasksEnabled:_}=qr(),{isSidebarCollapsed:$,expandedProjects:F,editingProject:I,showNewProject:U,editingName:w,loadingSessions:z,initialSessionsLoaded:q,currentTime:ee,isRefreshing:M,editingSession:K,editingSessionName:T,searchFilter:G,deletingProjects:Y,deleteConfirmation:J,sessionDeleteConfirmation:W,showVersionModal:O,filteredProjects:se,handleTouchClick:B,toggleProject:ge,handleSessionClick:pe,toggleStarProject:k,isProjectStarred:E,getProjectSessions:X,startEditing:ae,cancelEditing:oe,saveProjectName:Fe,showDeleteSessionConfirmation:he,confirmDeleteSession:xe,requestProjectDelete:Te,confirmDeleteProject:Le,loadMoreSessions:ze,handleProjectSelect:re,refreshProjects:fe,updateSessionSummary:V,collapseSidebar:ne,expandSidebar:we,setShowNewProject:Ie,setEditingName:De,setEditingSession:Ue,setEditingSessionName:Ke,setSearchFilter:Je,setDeleteConfirmation:de,setSessionDeleteConfirmation:Me,setShowVersionModal:Ne}=Ul({projects:t,selectedProject:r,selectedSession:s,isLoading:m,isMobile:h,t:y,onRefresh:u,onProjectSelect:a,onSessionSelect:n,onSessionDelete:i,onProjectDelete:l,setCurrentProject:L,setSidebarVisible:Pe=>j("sidebarVisible",Pe),sidebarVisible:C});c.useEffect(()=>{typeof document>"u"||(document.documentElement.classList.toggle("pwa-mode",N),document.body.classList.toggle("pwa-mode",N))},[N]);const _e=()=>{if(window.refreshProjects){window.refreshProjects();return}window.location.reload()},Oe={projects:t,filteredProjects:se,selectedProject:r,selectedSession:s,isLoading:m,loadingProgress:d,expandedProjects:F,editingProject:I,editingName:w,loadingSessions:z,initialSessionsLoaded:q,currentTime:ee,editingSession:K,editingSessionName:T,deletingProjects:Y,tasksEnabled:_,mcpServerStatus:R,getProjectSessions:X,isProjectStarred:E,onEditingNameChange:De,onToggleProject:ge,onProjectSelect:re,onToggleStarProject:k,onStartEditingProject:ae,onCancelEditingProject:oe,onSaveProjectName:Pe=>{Fe(Pe)},onDeleteProject:Te,onSessionSelect:pe,onDeleteSession:he,onLoadMoreSessions:Pe=>{ze(Pe)},onNewSession:o,onEditingSessionNameChange:Ke,onStartEditingSession:(Pe,te)=>{Ue(Pe),Ke(te)},onCancelEditingSession:()=>{Ue(null),Ke("")},onSaveEditingSession:(Pe,te,be)=>{V(Pe,te,be)},touchHandlerFactory:B,t:y};return e.jsxs(e.Fragment,{children:[e.jsx(fd,{projects:t,showSettings:p,settingsInitialTab:x,onCloseSettings:f,showNewProject:U,onCloseNewProject:()=>Ie(!1),onProjectCreated:_e,deleteConfirmation:J,onCancelDeleteProject:()=>de(null),onConfirmDeleteProject:Le,sessionDeleteConfirmation:W,onCancelDeleteSession:()=>Me(null),onConfirmDeleteSession:xe,showVersionModal:O,onCloseVersionModal:()=>Ne(!1),releaseInfo:D,currentVersion:b,latestVersion:v,t:y}),$?e.jsx(Hl,{onExpand:we,onShowSettings:g,updateAvailable:S,onShowVersionModal:()=>Ne(!0),t:y}):e.jsx(e.Fragment,{children:e.jsx(Kc,{isPWA:N,isMobile:h,isLoading:m,projects:t,searchFilter:G,onSearchFilterChange:Je,onClearSearchFilter:()=>Je(""),onRefresh:()=>{fe()},isRefreshing:M,onCreateProject:()=>Ie(!0),onCollapseSidebar:ne,updateAvailable:S,releaseInfo:D,latestVersion:v,onShowVersionModal:()=>Ne(!0),onShowSettings:g,projectListProps:Oe,t:y})})]})}function bd(){const{isDarkMode:t,toggleDarkMode:r}=ka();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 yd=()=>{const{t}=He("settings"),[r,s]=c.useState(!1),[a,n]=c.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:o}=ka(),{isMobile:i}=Ia({trackPWA:!1}),{preferences:l,setPreference:m}=Aa(),{autoExpandTools:d,showRawParameters:u,showThinking:g,autoScrollToBottom:p,sendByCtrlEnter:x}=l,[f,h]=c.useState(()=>{const w=localStorage.getItem("quickSettingsHandlePosition");if(w)try{return JSON.parse(w).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[y,N]=c.useState(!1),[S,v]=c.useState(0),[b,D]=c.useState(0),[A,j]=c.useState(!1),C=c.useRef(null),L=c.useRef({min:10,max:90}),R=5;c.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:f}))},[f]);const _=c.useCallback(()=>i?{bottom:`${window.innerHeight*f/100}px`}:{top:`${f}%`,transform:"translateY(-50%)"},[f,i]),$=c.useCallback(w=>{w.stopPropagation();const z=w.type.includes("touch")?w.touches[0].clientY:w.clientY;v(z),D(f),j(!1),N(!1)},[f]),F=c.useCallback(w=>{if(S===0)return;const z=w.type.includes("touch")?w.touches[0].clientY:w.clientY,q=Math.abs(z-S);if(!y&&q>R&&(N(!0),j(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",w.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!y)return;w.type.includes("touch")&&w.preventDefault();const ee=z-S;let M;i?M=-(ee/window.innerHeight)*100:M=ee/window.innerHeight*100;let K=b+M;K=Math.max(L.current.min,Math.min(L.current.max,K)),h(K)},[y,S,b,i,R]),I=c.useCallback(()=>{N(!1),v(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);c.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),c.useEffect(()=>{if(S!==0){const w=M=>F(M),z=()=>I(),q=M=>F(M),ee=()=>I();return document.addEventListener("mousemove",w),document.addEventListener("mouseup",z),document.addEventListener("touchmove",q,{passive:!1}),document.addEventListener("touchend",ee),()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",q),document.removeEventListener("touchend",ee)}}},[S,F,I]);const U=w=>{if(A){w.preventDefault(),j(!1);return}s(z=>!z)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:C,onClick:U,onMouseDown:w=>{$(w)},onTouchStart:w=>{$(w)},className:`fixed ${r?"right-64":"right-0"} z-50 ${y?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${y?"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 ${y?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{..._(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":t(y?"quickSettings.dragHandle.dragging":r?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:t(y?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:y?e.jsx(Ti,{className:"h-5 w-5 text-blue-500 dark:text-blue-400"}):r?e.jsx(zt,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(so,{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(Ii,{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(Xs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):e.jsx(Zs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.darkMode")]}),e.jsx(bd,{})]}),e.jsx("div",{children:e.jsx(zo,{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(Ca,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoExpandTools")]}),e.jsx("input",{type:"checkbox",checked:d,onChange:w=>m("autoExpandTools",w.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(mr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showRawParameters")]}),e.jsx("input",{type:"checkbox",checked:u,onChange:w=>m("showRawParameters",w.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(Is,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showThinking")]}),e.jsx("input",{type:"checkbox",checked:g,onChange:w=>m("showThinking",w.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(oo,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoScrollToBottom")]}),e.jsx("input",{type:"checkbox",checked:p,onChange:w=>m("autoScrollToBottom",w.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(no,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.sendByCtrlEnter")]}),e.jsx("input",{type:"checkbox",checked:x,onChange:w=>m("sendByCtrlEnter",w.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(ms,{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(Wt,{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(ot,{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 Lt(t){return t&&t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function vd(t){if(!t||typeof t!="string")return t;try{return t.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return t}}function ss(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 Oo(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function oa(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(),l=i>=0?"+":"-",m=Math.abs(i),d=Math.floor(m/60),u=m%60,g=`GMT${l}${d}${u?":"+String(u).padStart(2,"0"):""}`,f=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,S=>S.toUpperCase()),h=f?`${g} (${f})`:g,y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],N=`${n.getDate()} ${y[n.getMonth()]} ${n.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${o} ${h}** - ${N}`})}catch{return t}}const kd=({node:t,inline:r,className:s,children:a,...n})=>{const{t:o}=He("chat"),[i,l]=c.useState(!1),m=Array.isArray(a)?a.join(""):String(a??""),d=/[\r\n]/.test(m);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 p=/language-(\w+)/.exec(s||""),x=p?p[1]:"text",f=m,h=()=>{const y=()=>{l(!0),setTimeout(()=>l(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(f).then(y).catch(()=>{const N=document.createElement("textarea");N.value=f,N.style.position="fixed",N.style.opacity="0",document.body.appendChild(N),N.select();try{document.execCommand("copy")}catch{}document.body.removeChild(N),y()});else{const N=document.createElement("textarea");N.value=f,N.style.position="fixed",N.style.opacity="0",document.body.appendChild(N),N.select();try{document.execCommand("copy")}catch{}document.body.removeChild(N),y()}}catch{}};return e.jsxs("div",{className:"relative group my-2",children:[x&&x!=="text"&&e.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:x}),e.jsx("button",{type:"button",onClick:h,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(al,{language:x,style:nl,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:x&&x!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:m})]})},wd={code:kd,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 Rr({children:t,className:r}){const s=vd(String(t??"")),a=c.useMemo(()=>[ol,il],[]),n=c.useMemo(()=>[ll],[]);return e.jsx("div",{className:r,children:e.jsx(cl,{remarkPlugins:a,rehypePlugins:n,components:wd,children:s})})}const Ro="claude-settings",ht={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==null?void 0: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 l=JSON.parse(r);if(Array.isArray(l)&&l.length>10){const m=l.slice(-10);localStorage.setItem(t,JSON.stringify(m))}}catch(l){console.error("Final save attempt failed:",l)}}}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 Fa(){const t=ht.getItem(Ro);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 ia(t,r){if(!t)return null;if(t!=="Bash")return t;const s=Fc(r),a=typeof(s==null?void 0: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 gn(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function jd(t,r){var i;if(r!=="claude"||!((i=t==null?void 0:t.toolResult)!=null&&i.isError))return null;const s=t==null?void 0:t.toolName,a=ia(s,t.toolInput);if(!a)return null;const o=Fa().allowedTools.includes(a);return{toolName:s||"UnknownTool",entry:a,isAllowed:o}}function Nd(t){if(!t)return{success:!1};const r=Fa(),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 ht.setItem(Ro,JSON.stringify(o)),{success:!0,alreadyAllowed:s,updatedSettings:o}}const hn={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=>{var s;return`${((s=t.file_path)==null?void 0:s.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=>{var s;return`${((s=t.file_path)==null?void 0:s.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=>{var s;return`${((s=t.file_path)==null?void 0:s.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=>{var a;const r=t.toolUseResult||{},s=r.numFiles||((a=r.filenames)==null?void 0:a.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=>{var a;const r=t.toolUseResult||{},s=r.numFiles||((a=r.filenames)==null?void 0:a.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==null?void 0: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==null?void 0: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=>{var a,n;const r=((a=t.questions)==null?void 0:a.length)||0,s=t.answers&&Object.keys(t.answers).length>0;if(r===1){const o=((n=t.questions[0])==null?void 0:n.header)||"Question";return s?`${o} — answered`:o}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=>{var r;return{content:((r=t.plan)==null?void 0:r.replace(/\\n/g,`
42
+ `))||t.plan}}},result:{type:"collapsible",contentType:"markdown",getContentProps:t=>{var r;try{let s=t.content;return typeof s=="string"&&(s=JSON.parse(s)),{content:((r=s.plan)==null?void 0:r.replace(/\\n/g,`
43
+ `))||s.plan}}catch{return{content:""}}}}},ExitPlanMode:{input:{type:"collapsible",title:"Implementation plan",defaultOpen:!0,contentType:"markdown",getContentProps:t=>{var r;return{content:((r=t.plan)==null?void 0:r.replace(/\\n/g,`
44
+ `))||t.plan}}},result:{type:"collapsible",contentType:"markdown",getContentProps:t=>{var r;try{let s=t.content;return typeof s=="string"&&(s=JSON.parse(s)),{content:((r=s.plan)==null?void 0:r.replace(/\\n/g,`
45
+ `))||s.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==null?void 0:t.content)||""),format:"plain"})}}};function Bo(t){return hn[t]||hn.Default}function Cd(t,r){const s=Bo(t);return s.result?!!(s.result.hidden||s.result.hideOnSuccess&&r&&!r.isError):!1}const Wo=({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:l=>{l.preventDefault(),l.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})]}),Sd=({oldContent:t,newContent:r,filePath:s,createDiff:a,onFileClick:n,badge:o="Diff",badgeColor:i="gray"})=>{const l=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",m=c.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 ${l} flex-shrink-0 ml-2`,children:o})]}),e.jsx("div",{className:"text-[11px] font-mono leading-[18px]",children:m.map((d,u)=>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})]},u))})]})},Ed=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},Td=async t=>{var r;if(typeof navigator<"u"&&typeof window<"u"&&window.isSecureContext&&((r=navigator.clipboard)!=null&&r.writeText))try{return await navigator.clipboard.writeText(t),!0}catch{}return Ed(t)},Id=({toolName:t,icon:r,label:s,value:a,secondary:n,action:o="none",onAction:i,style:l,wrapText:m=!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:u,toolResult:g,toolId:p})=>{const[x,f]=c.useState(!1),h=l==="terminal",y=async()=>{if(o==="copy"&&a){if(!await Td(a))return;f(!0),setTimeout(()=>f(!1),2e3)}else i&&i()},N=()=>e.jsx("button",{onClick:y,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:x?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(h)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 ${m?"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"&&N()]})]}),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:y,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}),g&&e.jsx("a",{href:`#tool-result-${p}`,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 ${m?"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"&&N()]})},fn={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"},Ad=({toolName:t,title:r,defaultOpen:s=!1,action:a,onTitleClick:n,children:o,showRawParameters:i=!1,rawContent:l,className:m="",toolCategory:d})=>{const u=fn[d||"default"]||fn.default;return e.jsx("div",{className:`border-l-2 ${u} pl-3 py-0.5 my-1 ${m}`,children:e.jsxs(Wo,{title:r,toolName:t,open:s,action:a,onTitleClick:n,children:[o,i&&l&&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:l})]})]})})},as=(t,r)=>{var a;const s=typeof r=="string"?(()=>{try{return JSON.parse(r)}catch{return{}}})():r||{};switch(t){case"Read":case"Write":case"Edit":case"ApplyPatch":return((a=s.file_path)==null?void 0:a.split("/").pop())||s.file_path||"";case"Grep":case"Glob":return s.pattern||"";case"Bash":const n=s.command||"";return n.length>40?`${n.slice(0,40)}...`:n;case"Task":return s.description||s.subagent_type||"";case"WebFetch":case"WebSearch":return s.url||s.query||"";default:return""}},Dd=({toolInput:t,toolResult:r,subagentState:s})=>{const a=typeof t=="string"?(()=>{try{return JSON.parse(t)}catch{return{}}})():t||{},n=(a==null?void 0:a.subagent_type)||"Agent",o=(a==null?void 0:a.description)||"Running task",i=(a==null?void 0:a.prompt)||"",{childTools:l,currentToolIndex:m,isComplete:d}=s,u=m>=0?l[m]:null,g=`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(Wo,{title:g,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}),u&&!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:u.toolName}),as(u.toolName,u.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:as(u.toolName,u.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 (",l.length," ",l.length===1?"tool":"tools",")"]})]}),l.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 (",l.length,")"]})]}),e.jsx("div",{className:"mt-1 pl-3 border-l border-gray-200 dark:border-gray-700 space-y-0.5",children:l.map((p,x)=>{var f;return 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:[x+1,"."]}),e.jsx("span",{className:"font-medium",children:p.toolName}),as(p.toolName,p.toolInput)&&e.jsx("span",{className:"font-mono truncate text-gray-400 dark:text-gray-500",children:as(p.toolName,p.toolInput)}),((f=p.toolResult)==null?void 0:f.isError)&&e.jsx("span",{className:"text-red-500 flex-shrink-0",children:"(error)"})]},p.toolId)})})]}),d&&r&&e.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:(()=>{let p=r.content;if(typeof p=="string")try{const x=JSON.parse(p);if(Array.isArray(x)){const f=x.filter(h=>h.type==="text"&&h.text).map(h=>h.text);f.length>0&&(p=f.join(`
46
+ `))}}catch{}else if(Array.isArray(p)){const x=p.filter(f=>f.type==="text"&&f.text).map(f=>f.text);x.length>0&&(p=x.join(`
47
+ `))}return typeof p=="string"?e.jsx("div",{className:"whitespace-pre-wrap break-words line-clamp-6",children:p}):p?e.jsx("pre",{className:"whitespace-pre-wrap break-words line-clamp-6 font-mono text-[11px]",children:JSON.stringify(p,null,2)}):null})()})]})})},Md=({content:t,className:r="mt-1 prose prose-sm max-w-none dark:prose-invert"})=>e.jsx(Rr,{className:r,children:t}),$d=({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,l=typeof a=="string"?()=>r==null?void 0:r(a):a.onClick;return e.jsxs("span",{className:"inline-flex items-center",children:[e.jsx("button",{onClick:l,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)})})]}),Fd=({todos:t,isResult:r=!1})=>{if(!t||!Array.isArray(t))return null;const s=o=>{switch(o){case"completed":return e.jsx(Ai,{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(Wr,{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(wr,{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";case"pending":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";case"low":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(At,{variant:"outline",className:`text-[10px] px-1.5 py-px ${n(o.priority)}`,children:o.priority}),e.jsx(At,{variant:"outline",className:`text-[10px] px-1.5 py-px ${a(o.status)}`,children:o.status.replace("_"," ")})]})]})})]},o.id||`todo-${i}`))]})},Pd=({todos:t,isResult:r=!1})=>e.jsx(Fd,{todos:t,isResult:r});function Ld(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,l]=n,m=a.match(/blockedBy:\s*\[([^\]]*)\]/);r.push({id:o,subject:l.trim(),status:i||"pending",blockedBy:m?m[1].split(",").map(d=>d.trim()).filter(Boolean):void 0})}}return r}const bn={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"}},_d=({content:t})=>{const r=Ld(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=bn[n.status]||bn.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)})})]})},zd=({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})},Od=({questions:t,answers:r,className:s=""})=>{const[a,n]=c.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((l,m)=>{const d=r==null?void 0:r[l.question],u=d?d.split(", "):[],g=!d,p=a===m;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(p?null:m),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 ${u.length>0?"bg-blue-100 dark:bg-blue-900/40":"bg-gray-100 dark:bg-gray-800"}`,children:u.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:[l.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:l.header}),i>1&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500",children:[m+1,"/",i]})]}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5 leading-snug",children:l.question}),!p&&u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:u.map(x=>{const f=!l.options.some(h=>h.label===x);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:[x,f&&e.jsx("span",{className:"text-[9px] text-blue-400 dark:text-blue-500 font-normal",children:"(custom)"})]},x)})}),!p&&g&&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 ${p?"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"})})]}),p&&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:[l.options.map(x=>{const f=u.includes(x.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 ${l.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:x.label}),x.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:x.description})]})]},x.label)}),u.filter(x=>!l.options.some(f=>f.label===x)).map(x=>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 ${l.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:x}),e.jsx("span",{className:"text-[10px] text-blue-500 dark:text-blue-400 ml-1",children:"(custom)"})]})]},x)),g&&o&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic px-2.5 py-1",children:"No answer provided"})]})})]},m)}),!o&&i===1&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]})},Rd=({request:t,onDecision:r})=>{const s=t.input,a=(s==null?void 0:s.questions)||[],[n,o]=c.useState(0),[i,l]=c.useState(()=>new Map),[m,d]=c.useState(()=>new Map),[u,g]=c.useState(()=>new Map),[p,x]=c.useState(!1),f=c.useRef(null),h=c.useRef(null);c.useEffect(()=>{requestAnimationFrame(()=>x(!0))},[]),c.useEffect(()=>{var w;u.get(n)||(w=f.current)==null||w.focus()},[n,u]),c.useEffect(()=>{var w;u.get(n)&&((w=h.current)==null||w.focus())},[u,n]);const y=c.useCallback((w,z,q)=>{l(ee=>{const M=new Map(ee),K=new Set(M.get(w)||[]);return q?K.has(z)?K.delete(z):K.add(z):(K.clear(),K.add(z),g(T=>{const G=new Map(T);return G.set(w,!1),G})),M.set(w,K),M})},[]),N=c.useCallback((w,z)=>{g(q=>{const ee=new Map(q),M=ee.get(w)||!1;return ee.set(w,!M),!z&&!M&&l(K=>{const T=new Map(K);return T.set(w,new Set),T}),ee})},[]),S=c.useCallback((w,z)=>{d(q=>{const ee=new Map(q);return ee.set(w,z),ee})},[]),v=c.useCallback(()=>{const w={};return a.forEach((z,q)=>{const ee=Array.from(i.get(q)||[]),M=u.get(q)||!1,K=(m.get(q)||"").trim();M&&K&&ee.push(K),ee.length>0&&(w[z.question]=ee.join(", "))}),w},[a,i,u,m]),b=c.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:v()}})},[r,t.requestId,s,v]),D=c.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:{}}})},[r,t.requestId,s]),A=c.useCallback(w=>{if(w.target instanceof HTMLInputElement)return;const z=a[n];if(!z)return;const q=z.multiSelect||!1,ee=z.options.length,M=parseInt(w.key);if(!isNaN(M)&&M>=1&&M<=ee){w.preventDefault(),y(n,z.options[M-1].label,q);return}if(w.key==="0"){w.preventDefault(),N(n,q);return}if(w.key==="Enter"){w.preventDefault(),n===a.length-1?b():o(T=>T+1);return}if(w.key==="Escape"){w.preventDefault(),D();return}},[n,a,y,N,b,D]);if(a.length===0)return null;const j=a.length,C=j===1,L=a[n],R=L.multiSelect||!1,_=i.get(n)||new Set,$=u.get(n)||!1,F=n===j-1,I=n===0,U=_.size>0||$&&(m.get(n)||"").trim().length>0;return e.jsx("div",{ref:f,tabIndex:-1,onKeyDown:A,className:`w-full outline-none transition-all duration-500 ease-out ${p?"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"}),L.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:L.header})]}),!C&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500 flex-shrink-0",children:[n+1,"/",j]})]}),!C&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:a.map((w,z)=>e.jsx("button",{type:"button",onClick:()=>o(z),className:`h-[3px] rounded-full transition-all duration-300 ${z===n?"w-5 bg-blue-500 dark:bg-blue-400":z<n?"w-2.5 bg-blue-300 dark:bg-blue-600":"w-2.5 bg-gray-200 dark:bg-gray-700"}`},z))}),e.jsx("p",{className:"text-[14px] leading-snug font-medium text-gray-900 dark:text-gray-100",children:L.question}),R&&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:R?"group":"radiogroup","aria-label":L.question,children:e.jsxs("div",{className:"space-y-1",children:[L.options.map((w,z)=>{const q=_.has(w.label);return e.jsxs("button",{type:"button",onClick:()=>y(n,w.label,R),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${q?"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 ${q?"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:z+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-[13px] leading-tight transition-colors duration-150 ${q?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-700 dark:text-gray-300"}`,children:w.label}),w.description&&e.jsx("div",{className:`text-[11px] leading-snug transition-colors duration-150 ${q?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-500"}`,children:w.description})]}),q&&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"})})]},w.label)}),e.jsxs("button",{type:"button",onClick:()=>N(n,R),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:h,type:"text",value:m.get(n)||"",onChange:w=>S(n,w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),F?b():o(z=>z+1)),w.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:D,className:"text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:[C?"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:[!C&&!I&&e.jsxs("button",{type:"button",onClick:()=>o(w=>w-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"]}),F?e.jsxs("button",{type:"button",onClick:b,disabled:!U&&!Object.keys(v()).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(w=>w+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 Bd(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 la=c.memo(({toolName:t,toolInput:r,toolResult:s,toolId:a,mode:n,onFileOpen:o,createDiff:i,selectedProject:l,autoExpandTools:m=!1,showRawParameters:d=!1,rawToolInput:u,isSubagentContainer:g,subagentState:p})=>{var N,S,v,b,D;if(g&&p)return n==="result"?null:e.jsx(Dd,{toolInput:r,toolResult:s,subagentState:p});const x=Bo(t),f=n==="input"?x.input:x.result,h=c.useMemo(()=>{try{const A=n==="input"?r:s;return typeof A=="string"?JSON.parse(A):A}catch{return n==="input"?r:s}},[n,r,s]),y=c.useCallback(()=>{var A;if((f==null?void 0:f.action)==="open-file"&&o){const j=((A=f.getValue)==null?void 0:A.call(f,h))||"";o(j)}},[f,h,o]);if(!f)return null;if(f.type==="one-line"){const A=((N=f.getValue)==null?void 0:N.call(f,h))||"",j=(S=f.getSecondary)==null?void 0:S.call(f,h);return e.jsx(Id,{toolName:t,toolResult:s,toolId:a,icon:f.icon,label:f.label,value:A,secondary:j,action:f.action,onAction:y,style:f.style,wrapText:f.wrapText,colorScheme:f.colorScheme,resultId:n==="input"?`tool-result-${a}`:void 0})}if(f.type==="collapsible"){const A=typeof f.title=="function"?f.title(h):f.title||"Details",j=f.defaultOpen!==void 0?f.defaultOpen:m,C=((v=f.getContentProps)==null?void 0:v.call(f,h,{selectedProject:l,createDiff:i,onFileOpen:o}))||{};let L=null;switch(f.contentType){case"diff":i&&(L=e.jsx(Sd,{...C,createDiff:i,onFileClick:()=>o==null?void 0:o(C.filePath)}));break;case"markdown":L=e.jsx(Md,{content:C.content||""});break;case"file-list":L=e.jsx($d,{files:C.files||[],onFileClick:o,title:C.title});break;case"todo-list":((b=C.todos)==null?void 0:b.length)>0&&(L=e.jsx(Pd,{todos:C.todos,isResult:C.isResult}));break;case"task":L=e.jsx(_d,{content:C.content||""});break;case"question-answer":L=e.jsx(Od,{questions:C.questions||[],answers:C.answers||{}});break;case"text":L=e.jsx(zd,{content:C.content||"",format:C.format||"plain"});break;case"success-message":{const _=((D=f.getMessage)==null?void 0:D.call(f,h))||"Success";L=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"})}),_]});break}}const R=(t==="Edit"||t==="Write"||t==="ApplyPatch")&&C.filePath&&o?()=>o(C.filePath,{old_string:C.oldContent,new_string:C.newContent}):void 0;return e.jsx(Ad,{toolName:t,toolId:a,title:A,defaultOpen:j,onTitleClick:R,showRawParameters:n==="input"&&d,rawContent:u,toolCategory:Bd(t),children:L})}return null});la.displayName="ToolRenderer";const Wd=c.memo(({message:t,index:r,prevMessage:s,createDiff:a,onFileOpen:n,onShowSettings:o,onGrantToolPermission:i,autoExpandTools:l,showRawParameters:m,showThinking:d,selectedProject:u,provider:g})=>{const{t:p}=He("chat"),x=s&&s.type===t.type&&(s.type==="assistant"||s.type==="user"||s.type==="tool"||s.type==="error"),f=Ft.useRef(null),[h,y]=Ft.useState(!1),N=jd(t,g),[S,v]=Ft.useState("idle");Ft.useEffect(()=>{v("idle")},[N==null?void 0:N.entry,t.toolId]),Ft.useEffect(()=>{const A=f.current;if(!l||!A||!t.isToolUse)return;const j=new IntersectionObserver(C=>{C.forEach(L=>{L.isIntersecting&&!h&&(y(!0),A.querySelectorAll("details").forEach(_=>{_.open=!0}))})},{threshold:.1});return j.observe(A),()=>{j.unobserve(A)}},[l,h,t.isToolUse]);const b=c.useMemo(()=>new Date(t.timestamp).toLocaleTimeString(),[t.timestamp]);return t.isThinking&&!d?null:e.jsx("div",{ref:f,className:`chat-message ${t.type} ${x?"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((A,j)=>e.jsx("img",{src:A.data,alt:A.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(A.data,"_blank")},A.name||j))}),e.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:b})]}),!x&&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:[!x&&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(It,{provider:g,className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.type==="error"?p("messageTypes.error"):t.type==="tool"?p("messageTypes.tool"):p(g==="cursor"?"messageTypes.cursor":g==="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(Rr,{className:"prose prose-sm max-w-none dark:prose-invert",children:String(t.displayText||"")})})}),t.toolInput&&e.jsx(la,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"input",onFileOpen:n,createDiff:a,selectedProject:u,autoExpandTools:l,showRawParameters:m,rawToolInput:typeof t.toolInput=="string"?t.toolInput:void 0,isSubagentContainer:t.isSubagentContainer,subagentState:t.subagentState}),t.toolResult&&!Cd(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:p("messageTypes.error")})]}),e.jsxs("div",{className:"relative text-sm text-red-900 dark:text-red-100",children:[e.jsx(Rr,{className:"prose prose-sm max-w-none prose-red dark:prose-invert",children:String(t.toolResult.content||"")}),N&&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;const A=i(N);A!=null&&A.success?v("granted"):v("error")},disabled:N.isAllowed||S==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N.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:N.isAllowed||S==="granted"?p("permissions.added"):p("permissions.grant",{tool:N.toolName})}),o&&e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),o()},className:"text-xs text-red-700 dark:text-red-200 underline hover:text-red-800 dark:hover:text-red-100",children:p("permissions.openSettings")})]}),e.jsx("div",{className:"mt-2 text-xs text-red-700/90 dark:text-red-200/80",children:p("permissions.addTo",{entry:N.entry})}),S==="error"&&e.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:p("permissions.error")}),(N.isAllowed||S==="granted")&&e.jsx("div",{className:"mt-2 text-xs text-green-700 dark:text-green-200",children:p("permissions.retry")})]})]})]}):e.jsx("div",{id:`tool-result-${t.toolId}`,className:"scroll-mt-4",children:e.jsx(la,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"result",onFileOpen:n,createDiff:a,selectedProject:u,autoExpandTools:l})}))]}):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:p("interactive.title")}),(()=>{const A=(t.content||"").split(`
49
+ `).filter(L=>L.trim()),j=A.find(L=>L.includes("?"))||A[0]||"",C=[];return A.forEach(L=>{const R=L.match(/[❯\s]*(\d+)\.\s+(.+)/);if(R){const _=L.includes("❯");C.push({number:R[1],text:R[2].trim(),isSelected:_})}}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:j}),e.jsx("div",{className:"space-y-2 mb-4",children:C.map(L=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${L.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 ${L.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:L.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:L.text}),L.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},L.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:p("interactive.waiting")}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:p("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:p("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(Rr,{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:p("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 A=oa(String(t.content||"")),j=A.trim();if((j.startsWith("{")||j.startsWith("["))&&(j.endsWith("}")||j.endsWith("]")))try{const C=JSON.parse(j),L=JSON.stringify(C,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:p("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:L})})})]})}catch{}return t.type==="assistant"?e.jsx(Rr,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:A}):e.jsx("div",{className:"whitespace-pre-wrap",children:A})})()]}),!x&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 mt-1",children:b})]})]})})}),Uo=({task:t,onClose:r,onEdit:s,onStatusChange:a,onTaskClick:n,isOpen:o=!0,className:i=""})=>{var R;const[l,m]=c.useState(!1),[d,u]=c.useState(t||{}),[g,p]=c.useState(!1),[x,f]=c.useState(!1),[h,y]=c.useState(!1),{currentProject:N,refreshTasks:S}=Er();if(!o||!t)return null;const v=async()=>{if(N){p(!0);try{const _={};if(d.title!==t.title&&(_.title=d.title),d.description!==t.description&&(_.description=d.description),d.details!==t.details&&(_.details=d.details),Object.keys(_).length>0){const $=await Ge.taskmaster.updateTask(N.name,t.id,_);if($.ok)S==null||S(),s==null||s(d),m(!1);else{const F=await $.json();console.error("Failed to update task:",F),alert(`Failed to update task: ${F.message}`)}}else m(!1)}catch(_){console.error("Error updating task:",_),alert("Error updating task. Please try again.")}finally{p(!1)}}},b=()=>{navigator.clipboard.writeText(t.id.toString())},D=_=>{switch(_){case"done":return{icon:Kr,color:"text-green-600 dark:text-green-400",bg:"bg-green-50 dark:bg-green-950"};case"in-progress":return{icon:Wr,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-50 dark:bg-blue-950"};case"review":return{icon:Es,color:"text-amber-600 dark:text-amber-400",bg:"bg-amber-50 dark:bg-amber-950"};case"deferred":return{icon:lo,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:wr,color:"text-slate-500 dark:text-slate-400",bg:"bg-slate-50 dark:bg-slate-800"}}},A=D(t.status),j=A.icon,C=_=>{switch(_){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"}},L=[{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:ke("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(j,{className:ke("w-6 h-6",A.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:b,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(ja,{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]})]}),l?e.jsx("input",{type:"text",value:d.title||"",onChange:_=>u({...d,title:_.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:[l?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:v,disabled:g,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:g?"Saving...":"Save changes",children:e.jsx(ps,{className:ke("w-5 h-5",g&&"animate-spin")})}),e.jsx("button",{onClick:()=>{m(!1),u(t)},disabled:g,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:()=>m(!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(Di,{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:ke("w-full px-3 py-2 rounded-md border border-gray-300 dark:border-gray-600",A.bg,A.color),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium capitalize",children:((R=L.find(_=>_.value===t.status))==null?void 0:R.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:ke("px-3 py-2 rounded-md text-sm font-medium capitalize",C(t.priority)),children:[e.jsx(io,{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(_=>e.jsxs("button",{onClick:()=>n&&n({id:_}),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 ${_}`:`Task ${_}`,children:[e.jsx(Sa,{className:"w-3 h-3 inline mr-1"}),_]},_))}):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"}),l?e.jsx("textarea",{value:d.description||"",onChange:_=>u({...d,description:_.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(!x),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"}),x?e.jsx(Ct,{className:"w-4 h-4 text-gray-500"}):e.jsx(zt,{className:"w-4 h-4 text-gray-500"})]}),x&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:l?e.jsx("textarea",{value:d.details||"",onChange:_=>u({...d,details:_.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:()=>y(!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:"Test Strategy"}),h?e.jsx(Ct,{className:"w-4 h-4 text-gray-500"}):e.jsx(zt,{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: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(_=>{const $=D(_.status),F=$.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(F,{className:ke("w-4 h-4",$.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:_.title}),_.description&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 truncate",children:_.description})]}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:_.id})]},_.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"})})]})]})})},yn=({onShowAllTasks:t,onStartTask:r,className:s=""})=>{const{nextTask:a,tasks:n,currentProject:o,isLoadingTasks:i,projectTaskMaster:l,refreshTasks:m,refreshProjects:d}=Er(),[u,g]=c.useState(!1),[p,x]=c.useState(!1),[f,h]=c.useState(!1),[y,N]=c.useState(!1),[S,v]=c.useState(!1),[b,D]=c.useState(!1),[A,j]=c.useState(!1),C=()=>{h(!0),x(!1)},L=()=>{N(!0),x(!1)};if(!o||i)return null;let R;if((!n||n.length===0)&&!(l!=null&&l.hasTaskmaster))R=e.jsxs("div",{className:ke("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(xs,{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:()=>x(!p),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"]})})]}),p&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-blue-200 dark:border-blue-800",children:[!(l!=null&&l.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:l!=null&&l.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:C,disabled:A,children:[e.jsx(it,{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:L,disabled:A,children:[e.jsx(ot,{className:"w-3 h-3"}),A?"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:()=>v(!0),children:[e.jsx(mt,{className:"w-3 h-3"}),"Initialize TaskMaster"]})})]})]});else if(a)R=e.jsx("div",{className:ke("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(Mi,{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(Na,{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(io,{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(wr,{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==null?void 0: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($i,{className:"w-3 h-3"}),"Start Task"]}),e.jsx("button",{onClick:()=>D(!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(mr,{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(xs,{className:"w-3 h-3"})})]})]})});else if(n&&n.length>0){const _=n.filter(F=>F.status==="done").length,$=n.length;R=e.jsx("div",{className:ke("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(Kr,{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:_===$?"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:[_,"/",$]}),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 R=null;return e.jsxs(e.Fragment,{children:[R,f&&e.jsx(Ud,{currentProject:o,onClose:()=>h(!1),onTaskCreated:()=>{m(),h(!1)}}),y&&e.jsx(Hd,{currentProject:o,onClose:()=>N(!1),onTemplateApplied:()=>{m(),N(!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(mt,{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==null?void 0:o.displayName]})]})]}),e.jsx("button",{onClick:()=>v(!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(po,{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:()=>v(!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"})]})})]})}),b&&a&&e.jsx(Uo,{task:a,isOpen:b,onClose:()=>D(!1),onStatusChange:()=>m==null?void 0:m(),onTaskClick:null})]})},Ud=({currentProject:t,onClose:r,onTaskCreated:s})=>{const[a,n]=c.useState({title:"",description:"",priority:"medium",useAI:!1,prompt:""}),[o,i]=c.useState(!1),l=async m=>{if(m.preventDefault(),!!t){i(!0);try{const d=a.useAI?{prompt:a.prompt,priority:a.priority}:{title:a.title,description:a.description,priority:a.priority},u=await Ge.taskmaster.addTask(t.name,d);if(u.ok)s();else{const g=await u.json();console.error("Failed to create task:",g),alert(`Failed to create task: ${g.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:l,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:m=>n(d=>({...d,useAI:m.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:m=>n(d=>({...d,prompt:m.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:m=>n(d=>({...d,title:m.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:m=>n(d=>({...d,description:m.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:m=>n(d=>({...d,priority:m.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"})]})]})]})})},Hd=({currentProject:t,onClose:r,onTemplateApplied:s})=>{const[a,n]=c.useState([]),[o,i]=c.useState(null),[l,m]=c.useState({}),[d,u]=c.useState("prd.txt"),[g,p]=c.useState(!0),[x,f]=c.useState(!1),[h,y]=c.useState("select");useEffect(()=>{(async()=>{try{const b=await Ge.taskmaster.getTemplates();if(b.ok){const D=await b.json();n(D.templates)}}catch(b){console.error("Error loading templates:",b)}finally{p(!1)}})()},[]);const N=v=>{i(v);const b=v.content.match(/\[([^\]]+)\]/g)||[],D=[...new Set(b.map(j=>j.slice(1,-1)))],A={};D.forEach(j=>{A[j]=""}),m(A),y("customize")},S=async()=>{if(!(!o||!t)){f(!0);try{const v=await Ge.taskmaster.applyTemplate(t.name,{templateId:o.id,fileName:d,customizations:l});if(!v.ok){const D=await v.json();throw new Error(D.message||"Failed to apply template")}const b=await Ge.taskmaster.parsePRD(t.name,{fileName:d,numTasks:10});if(!b.ok){const D=await b.json();throw new Error(D.message||"Failed to generate tasks")}y("generate"),setTimeout(()=>{s()},2e3)}catch(v){console.error("Error applying template:",v),alert(`Error: ${v.message}`),f(!1)}}};return g?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:h==="select"?"Select PRD Template":h==="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"})})]}),h==="select"&&e.jsx("div",{className:"space-y-3",children:a.map(v=>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:()=>N(v),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:v.name}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:v.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:v.category})]}),e.jsx(Sa,{className:"w-4 h-4 text-gray-400 mt-1"})]})},v.id))}),h==="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:v=>u(v.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(l).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(l).map(([v,b])=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:v.replace(/([A-Z])/g," $1").replace(/^./,D=>D.toUpperCase())}),e.jsx("input",{type:"text",value:b,onChange:D=>m(A=>({...A,[v]:D.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 ${v.toLowerCase()}`})]},v))})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx("button",{onClick:()=>y("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:x,children:x?"Applying...":"Apply & Generate Tasks"})]})]}),h==="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(Kr,{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..."})]})]})})},Ho={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"},Go={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"},qo={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"},Gd=[{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 qd(t){return t==="claude"?Ho:t==="codex"?qo:Go}function Kd(t,r,s,a){return t==="claude"?r:t==="codex"?a:s}function Vd({selectedSession:t,currentSessionId:r,provider:s,setProvider:a,textareaRef:n,claudeModel:o,setClaudeModel:i,cursorModel:l,setCursorModel:m,codexModel:d,setCodexModel:u,tasksEnabled:g,isTaskMasterInstalled:p,onShowAllTasks:x,setInput:f}){const{t:h}=He("chat"),y=h("tasks.nextTaskPrompt",{defaultValue:"Start the next task"}),N=D=>{a(D),localStorage.setItem("selected-provider",D),setTimeout(()=>{var A;return(A=n.current)==null?void 0:A.focus()},100)},S=D=>{s==="claude"?(i(D),localStorage.setItem("claude-model",D)):s==="codex"?(u(D),localStorage.setItem("codex-model",D)):(m(D),localStorage.setItem("cursor-model",D))},v=qd(s),b=Kd(s,o,l,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:h("providerSelection.title")}),e.jsx("p",{className:"text-[13px] text-muted-foreground mt-1",children:h("providerSelection.description")})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:gap-2.5 mb-6",children:Gd.map(D=>{const A=s===D.id;return e.jsxs("button",{onClick:()=>N(D.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
+ ${A?`${D.accent} ${D.ring} ring-2 bg-card shadow-sm`:"border-border bg-card/60 hover:bg-card hover:border-border/80"}
54
+ `,children:[e.jsx(It,{provider:D.id,className:`w-9 h-9 transition-transform duration-150 ${A?"scale-110":""}`}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[13px] font-semibold text-foreground leading-none",children:D.name}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 leading-tight",children:h(D.infoKey)})]}),A&&e.jsx("div",{className:`absolute -top-1 -right-1 w-[18px] h-[18px] rounded-full ${D.check} flex items-center justify-center shadow-sm`,children:e.jsx(Et,{className:"w-2.5 h-2.5",strokeWidth:3})})]},D.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:h("providerSelection.selectModel")}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:b,onChange:D=>S(D.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:v.OPTIONS.map(({value:D,label:A})=>e.jsx("option",{value:D,children:A},D))}),e.jsx(Ct,{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"?h("providerSelection.readyPrompt.claude",{model:o}):s==="cursor"?h("providerSelection.readyPrompt.cursor",{model:l}):s==="codex"?h("providerSelection.readyPrompt.codex",{model:d}):h("providerSelection.readyPrompt.default")})]}),s&&g&&p&&e.jsx("div",{className:"mt-5",children:e.jsx(yn,{onStartTask:()=>f(y),onShowAllTasks:x})})]})}):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:h("session.continue.title")}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:h("session.continue.description")}),g&&p&&e.jsx("div",{className:"mt-5",children:e.jsx(yn,{onStartTask:()=>f(y),onShowAllTasks:x})})]})}):null}function Jd({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(It,{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 Yd=t=>{if(typeof t!="string"&&typeof t!="number")return null;const r=String(t).trim();return r.length>0?r:null},Qd=t=>{const r=[t.id,t.messageId,t.toolId,t.toolCallId,t.blobId,t.rowid,t.sequence];for(const o of r){const i=Yd(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 Xd({scrollContainerRef:t,onWheel:r,onTouchMove:s,isLoadingSessionMessages:a,chatMessages:n,selectedSession:o,currentSessionId:i,provider:l,setProvider:m,textareaRef:d,claudeModel:u,setClaudeModel:g,cursorModel:p,setCursorModel:x,codexModel:f,setCodexModel:h,tasksEnabled:y,isTaskMasterInstalled:N,onShowAllTasks:S,setInput:v,isLoadingMoreMessages:b,hasMoreMessages:D,totalMessages:A,sessionMessagesCount:j,visibleMessageCount:C,visibleMessages:L,loadEarlierMessages:R,loadAllMessages:_,allMessagesLoaded:$,isLoadingAllMessages:F,loadAllJustFinished:I,showLoadAllOverlay:U,createDiff:w,onFileOpen:z,onShowSettings:q,onGrantToolPermission:ee,autoExpandTools:M,showRawParameters:K,showThinking:T,selectedProject:G,isLoading:Y}){const{t:J}=He("chat"),W=c.useRef(new WeakMap),O=c.useRef(new Set),se=c.useRef(0),B=c.useCallback(ge=>{const pe=W.current.get(ge);if(pe)return pe;const k=Qd(ge);let E=k;if(!E||O.current.has(E))do se.current+=1,E=k?`${k}-${se.current}`:`message-generated-${se.current}`;while(O.current.has(E));return O.current.add(E),W.current.set(ge,E),E},[]);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:J("session.loading.sessionMessages")})]})}):n.length===0?e.jsx(Vd,{selectedSession:o,currentSessionId:i,provider:l,setProvider:m,textareaRef:d,claudeModel:u,setClaudeModel:g,cursorModel:p,setCursorModel:x,codexModel:f,setCodexModel:h,tasksEnabled:y,isTaskMasterInstalled:N,onShowAllTasks:S,setInput:v}):e.jsxs(e.Fragment,{children:[b&&!F&&!$&&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:J("session.loading.olderMessages")})]})}),D&&!b&&!$&&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:A>0&&e.jsxs("span",{children:[J("session.messages.showingOf",{shown:j,total:A})," ",e.jsx("span",{className:"text-xs",children:J("session.messages.scrollToLoad")})]})}),(U||F||I)&&e.jsx("div",{className:"sticky top-2 z-20 flex justify-center pointer-events-none",children:I?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:J("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:_,disabled:F,children:[F&&e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-2 border-white/30 border-t-white"}),e.jsx("span",{children:F?J("session.messages.loadingAll"):e.jsxs(e.Fragment,{children:[J("session.messages.loadAll")," ",A>0&&`(${A})`]})})]})}),$&&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:J("session.messages.perfWarning")}),!D&&n.length>C&&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:[J("session.messages.showingLast",{count:C,total:n.length})," |",e.jsx("button",{className:"ml-1 text-blue-600 hover:text-blue-700 underline",onClick:R,children:J("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:_,children:J("session.messages.loadAll")})]}),L.map((ge,pe)=>{const k=pe>0?L[pe-1]:null;return e.jsx(Wd,{message:ge,index:pe,prevMessage:k,createDiff:w,onFileOpen:z,onShowSettings:q,onGrantToolPermission:ee,autoExpandTools:M,showRawParameters:K,showThinking:T,selectedProject:G,provider:l},B(ge))})]}),Y&&e.jsx(Jd,{selectedProvider:l})]})}const Zd=({commands:t=[],selectedIndex:r=-1,onSelect:s,onClose:a,position:n={top:0,left:0},isOpen:o=!1,frequentCommands:i=[]})=>{const l=c.useRef(null),m=c.useRef(null),u=(()=>{const v=window.innerWidth<640,b=window.innerHeight;return v?{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,b-316))}px`,left:`${n.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(c.useEffect(()=>{const v=b=>{l.current&&!l.current.contains(b.target)&&o&&a()};if(o)return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[o,a]),c.useEffect(()=>{if(m.current&&l.current){const v=l.current.getBoundingClientRect(),b=m.current.getBoundingClientRect();b.bottom>v.bottom?m.current.scrollIntoView({block:"nearest",behavior:"smooth"}):b.top<v.top&&m.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[r]),!o)return null;if(t.length===0)return e.jsx("div",{ref:l,className:"command-menu command-menu-empty",style:{...u,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 g=i.length>0,p=v=>`${v.name}::${v.namespace||v.type||"other"}::${v.path||""}`,x=new Set(i.map(p)),f=t.reduce((v,b)=>{if(g&&x.has(p(b)))return v;const D=b.namespace||b.type||"other";return v[D]||(v[D]=[]),v[D].push(b),v},{});g&&(f.frequent=i);const y=(g?["frequent","builtin","project","user","other"]:["builtin","project","user","other"]).filter(v=>f[v]),N={frequent:"⭐ Frequently Used",builtin:"Built-in Commands",project:"Project Commands",user:"User Commands",other:"Other Commands"},S=new Map;return t.forEach((v,b)=>{const D=p(v);S.has(D)||S.set(D,b)}),e.jsxs("div",{ref:l,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...u,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:[y.map(v=>e.jsxs("div",{className:"command-group",children:[y.length>1&&e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:N[v]||v}),f[v].map(b=>{var C;const D=p(b),A=S.get(D)??-1,j=A===r;return e.jsxs("div",{ref:j?m:null,role:"option","aria-selected":j,className:"command-item",onMouseEnter:()=>{s&&A>=0&&s(b,A,!0)},onClick:()=>{s&&s(b,A,!1)},style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:j?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:L=>L.preventDefault(),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:b.description?"4px":0},children:[e.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[v==="builtin"&&"⚡",v==="project"&&"📁",v==="user"&&"👤",v==="other"&&"📝",v==="frequent"&&"⭐"]}),e.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:b.name}),((C=b.metadata)==null?void 0:C.type)&&e.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",fontWeight:500},children:b.metadata.type})]}),b.description&&e.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:b.description})]}),j&&e.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${v}-${b.name}-${b.path||""}`)})]},v)),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 em({status:t,onAbort:r,isLoading:s,provider:a="claude"}){const[n,o]=c.useState(0),[i,l]=c.useState(0),[m,d]=c.useState(0);if(c.useEffect(()=>{if(!s){o(0),d(0);return}const N=Date.now(),S=30+Math.random()*20,v=setInterval(()=>{const b=Math.floor((Date.now()-N)/1e3);o(b),d(Math.floor(b*S))},1e3);return()=>clearInterval(v)},[s]),c.useEffect(()=>{if(!s)return;const N=setInterval(()=>{l(S=>(S+1)%4)},500);return()=>clearInterval(N)},[s]),!s)return null;const u=["Thinking","Processing","Analyzing","Working","Computing","Reasoning"],g=Math.floor(n/3)%u.length,p=(t==null?void 0:t.text)||u[g],x=(t==null?void 0:t.tokens)||m,f=(t==null?void 0:t.can_interrupt)!==!1,y=["✻","✹","✸","✶"][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:ke("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:y}),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:[p,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),x>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:["⚒ ",x.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 tm(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 m=await i.json().catch(()=>({}));throw new Error(m.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 Ko({onTranscript:t,className:r=""}){const[s,a]=c.useState("idle"),[n,o]=c.useState(null),[i,l]=c.useState(!0),m=c.useRef(null),d=c.useRef(null),u=c.useRef([]),g=c.useRef(0);c.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){l(!1),o("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){l(!1),o("Microphone requires HTTPS. Please use a secure connection.");return}l(!0),o(null)})()},[]);const p=async()=>{try{if(console.log("Starting recording..."),o(null),u.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const v=await navigator.mediaDevices.getUserMedia({audio:!0});d.current=v;const b=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",D=new MediaRecorder(v,{mimeType:b});m.current=D,D.ondataavailable=A=>{A.data.size>0&&u.current.push(A.data)},D.onstop=async()=>{console.log("Recording stopped, creating blob...");const A=new Blob(u.current,{type:b});d.current&&(d.current.getTracks().forEach(R=>R.stop()),d.current=null),a("transcribing");const j=window.localStorage.getItem("whisperMode")||"default",C=j==="prompt"||j==="vibe"||j==="instructions"||j==="architect";let L;C&&(L=setTimeout(()=>{a("processing")},2e3));try{const R=await tm(A);R&&t&&t(R)}catch(R){console.error("Transcription error:",R),o(R.message)}finally{L&&clearTimeout(L),a("idle")}},D.start(),a("recording"),console.log("Recording started successfully")}catch(v){console.error("Failed to start recording:",v);let b="Microphone access failed";v.name==="NotAllowedError"?b="Microphone access denied. Please allow microphone permissions.":v.name==="NotFoundError"?b="No microphone found. Please check your audio devices.":v.name==="NotSupportedError"?b="Microphone not supported by this browser.":v.name==="NotReadableError"?b="Microphone is being used by another application.":v.message.includes("HTTPS")&&(b=v.message),o(b),a("idle")}},x=()=>{console.log("Stopping recording..."),m.current&&m.current.state==="recording"?m.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),d.current&&(d.current.getTracks().forEach(v=>v.stop()),d.current=null),a("idle"))},f=v=>{if(v&&(v.preventDefault(),v.stopPropagation()),!i)return;const b=Date.now();if(b-g.current<300){console.log("Ignoring rapid tap");return}g.current=b,console.log("Button clicked, current state:",s),s==="idle"?p():s==="recording"&&x()};c.useEffect(()=>()=>{d.current&&d.current.getTracks().forEach(v=>v.stop())},[]);const h=()=>{if(!i)return{icon:e.jsx(ms,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(s){case"recording":return{icon:e.jsx(ms,{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(vr,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(Is,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(ms,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:y,className:N,disabled:S}=h();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:y}),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 rm=({file:t,onRemove:r,uploadProgress:s,error:a})=>{const[n,o]=c.useState(void 0);return c.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"})})})]})},Vo={};function sm(t,r){Vo[t]=r}function am(t){return Vo[t]||null}sm("AskUserQuestion",Rd);function nm({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}){return t.length?e.jsx("div",{className:"mb-3 space-y-2",children:t.map(a=>{const n=am(a.toolName);if(n)return e.jsx(n,{request:a,onDecision:r},a.requestId);const o=gn(a.input),i=ia(a.toolName,o),l=Fa(),m=i?l.allowedTools.includes(i):!1,d=m?"Allow (saved)":"Allow & remember",u=i?t.filter(g=>ia(g.toolName,gn(g.input))===i).map(g=>g.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&&!m&&s({entry:i,toolName:a.toolName}),r(u,{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 Jo=[{id:"none",name:"Standard",description:"Regular Claude response",icon:null,prefix:"",color:"text-gray-600"},{id:"think",name:"Think",description:"Basic extended thinking",icon:Is,prefix:"think",color:"text-blue-600"},{id:"think-hard",name:"Think Hard",description:"More thorough evaluation",icon:Na,prefix:"think hard",color:"text-purple-600"},{id:"think-harder",name:"Think Harder",description:"Deep analysis with alternatives",icon:Wt,prefix:"think harder",color:"text-indigo-600"},{id:"ultrathink",name:"Ultrathink",description:"Maximum thinking budget",icon:Fi,prefix:"ultrathink",color:"text-red-600"}];function om({selectedMode:t,onModeChange:r,onClose:s,className:a=""}){const{t:n}=He("chat"),o={"think-hard":"thinkHard","think-harder":"thinkHarder"},i=Jo.map(p=>{const x=o[p.id]||p.id;return{...p,name:n(`thinkingMode.modes.${x}.name`),description:n(`thinkingMode.modes.${x}.description`),prefix:n(`thinkingMode.modes.${x}.prefix`)}}),[l,m]=c.useState(!1),d=c.useRef(null);c.useEffect(()=>{const p=x=>{d.current&&!d.current.contains(x.target)&&(m(!1),s&&s())};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]);const u=i.find(p=>p.id===t)||i[0],g=u.icon||Is;return e.jsxs("div",{className:`relative ${a}`,ref:d,children:[e.jsx("button",{type:"button",onClick:()=>m(!l),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:u.name}),children:e.jsx(g,{className:`w-5 h-5 ${u.color}`})}),l&&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:()=>{m(!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(p=>{const x=p.icon,f=p.id===t;return e.jsx("button",{onClick:()=>{r(p.id),m(!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 ${p.icon?p.color:"text-gray-400"}`,children:x?e.jsx(x,{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:p.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:p.description}),p.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:p.prefix})]})]})},p.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 im({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 lm({permissionMode:t,onModeSwitch:r,provider:s,thinkingMode:a,setThinkingMode:n,tokenBudget:o,slashCommandsCount:i,onToggleCommandMenu:l,hasInput:m,onClearInput:d,isUserScrolledUp:u,hasMessages:g,onScrollToBottom:p}){const{t:x}=He("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:x("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"&&x("codex.modes.default"),t==="acceptEdits"&&x("codex.modes.acceptEdits"),t==="bypassPermissions"&&x("codex.modes.bypassPermissions"),t==="plan"&&x("codex.modes.plan")]})]})}),s==="claude"&&e.jsx(om,{selectedMode:a,onModeChange:n,onClose:()=>{},className:""}),e.jsx(im,{used:(o==null?void 0:o.used)||0,total:(o==null?void 0:o.total)||parseInt(void 0)||16e4}),e.jsxs("button",{type:"button",onClick:l,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:x("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})]}),m&&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:x("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"})})}),u&&g&&e.jsx("button",{onClick:p,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:x("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 cm({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s,claudeStatus:a,isLoading:n,onAbortSession:o,provider:i,permissionMode:l,onModeSwitch:m,thinkingMode:d,setThinkingMode:u,tokenBudget:g,slashCommandsCount:p,onToggleCommandMenu:x,hasInput:f,onClearInput:h,isUserScrolledUp:y,hasMessages:N,onScrollToBottom:S,onSubmit:v,isDragActive:b,attachedImages:D,onRemoveImage:A,uploadingImages:j,imageErrors:C,showFileDropdown:L,filteredFiles:R,selectedFileIndex:_,onSelectFile:$,filteredCommands:F,selectedCommandIndex:I,onCommandSelect:U,onCloseCommandMenu:w,isCommandMenuOpen:z,frequentCommands:q,getRootProps:ee,getInputProps:M,openImagePicker:K,inputHighlightRef:T,renderInputWithMentions:G,textareaRef:Y,input:J,onInputChange:W,onTextareaClick:O,onTextareaKeyDown:se,onTextareaPaste:B,onTextareaScrollSync:ge,onTextareaInput:pe,onInputFocusChange:k,isInputFocused:E,placeholder:X,isTextareaExpanded:ae,sendByCtrlEnter:oe,onTranscript:Fe}){var fe;const{t:he}=He("chat"),xe=Zd,Te=(fe=Y.current)==null?void 0:fe.getBoundingClientRect(),Le={top:Te?Math.max(16,Te.top-316):0,left:Te?Te.left:16,bottom:Te?window.innerHeight-Te.top+8:90},ze=t.some(V=>V.toolName==="AskUserQuestion"),re=E?"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 ${re}`,children:[!ze&&e.jsx("div",{className:"flex-1",children:e.jsx(em,{status:a,isLoading:n,onAbort:o,provider:i})}),e.jsxs("div",{className:"max-w-4xl mx-auto mb-3",children:[e.jsx(nm,{pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}),!ze&&e.jsx(lm,{permissionMode:l,onModeSwitch:m,provider:i,thinkingMode:d,setThinkingMode:u,tokenBudget:g,slashCommandsCount:p,onToggleCommandMenu:x,hasInput:f,onClearInput:h,isUserScrolledUp:y,hasMessages:N,onScrollToBottom:S})]}),!ze&&e.jsxs("form",{onSubmit:v,className:"relative max-w-4xl mx-auto",children:[b&&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"})]})}),D.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:D.map((V,ne)=>e.jsx(rm,{file:V,onRemove:()=>A(ne),uploadProgress:j.get(V.name),error:C.get(V.name)},ne))})}),L&&R.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:R.map((V,ne)=>e.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-border/30 last:border-b-0 touch-manipulation ${ne===_?"bg-primary/8 text-primary":"hover:bg-accent/50 text-foreground"}`,onMouseDown:we=>{we.preventDefault(),we.stopPropagation()},onClick:we=>{we.preventDefault(),we.stopPropagation(),$(V)},children:[e.jsx("div",{className:"font-medium text-sm",children:V.name}),e.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:V.path})]},V.path))}),e.jsx(xe,{commands:F,selectedIndex:I,onSelect:U,onClose:w,position:Le,isOpen:z,frequentCommands:q}),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 ${ae?"chat-input-expanded":""}`,children:[e.jsx("input",{...M()}),e.jsx("div",{ref:T,"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:G(J)})}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("textarea",{ref:Y,value:J,onChange:W,onClick:O,onKeyDown:se,onPaste:B,onScroll:V=>ge(V.target),onFocus:()=>k==null?void 0:k(!0),onBlur:()=>k==null?void 0:k(!1),onInput:pe,placeholder:X,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:K,className:"absolute left-2 top-1/2 transform -translate-y-1/2 p-2 hover:bg-accent/60 rounded-xl transition-colors",title:he("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(Ko,{onTranscript:Fe,className:"w-10 h-10 sm:w-10 sm:h-10"})}),e.jsx("button",{type:"submit",disabled:!J.trim()||n,onMouseDown:V=>{V.preventDefault(),v(V)},onTouchStart:V=>{V.preventDefault(),v(V)},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 ${J.trim()?"opacity-0":"opacity-100"}`,children:he(oe?"input.hintText.ctrlEnter":"input.hintText.enter")})]})]})]})]})}function dm({selectedSession:t}){const[r,s]=c.useState("default"),[a,n]=c.useState([]),[o,i]=c.useState(()=>localStorage.getItem("selected-provider")||"claude"),[l,m]=c.useState(()=>localStorage.getItem("cursor-model")||Go.DEFAULT),[d,u]=c.useState(()=>localStorage.getItem("claude-model")||Ho.DEFAULT),[g,p]=c.useState(()=>localStorage.getItem("codex-model")||qo.DEFAULT),x=c.useRef(o);c.useEffect(()=>{if(!(t!=null&&t.id))return;const h=localStorage.getItem(`permissionMode-${t.id}`);s(h||"default")},[t==null?void 0:t.id]),c.useEffect(()=>{!(t!=null&&t.__provider)||t.__provider===o||(i(t.__provider),localStorage.setItem("selected-provider",t.__provider))},[o,t]),c.useEffect(()=>{x.current!==o&&(n([]),x.current=o)},[o]),c.useEffect(()=>{n(h=>h.filter(y=>!y.sessionId||y.sessionId===(t==null?void 0:t.id)))},[t==null?void 0:t.id]),c.useEffect(()=>{o==="cursor"&&Se("/api/cursor/config").then(h=>h.json()).then(h=>{var N,S;if(!h.success||!((S=(N=h.config)==null?void 0:N.model)!=null&&S.modelId))return;const y=h.config.model.modelId;localStorage.getItem("cursor-model")||m(y)}).catch(h=>{console.error("Error loading Cursor config:",h)})},[o]);const f=c.useCallback(()=>{const h=o==="codex"?["default","acceptEdits","bypassPermissions"]:["default","acceptEdits","bypassPermissions","plan"],N=(h.indexOf(r)+1)%h.length,S=h[N];s(S),t!=null&&t.id&&localStorage.setItem(`permissionMode-${t.id}`,S)},[r,o,t==null?void 0:t.id]);return{provider:o,setProvider:i,cursorModel:l,setCursorModel:m,claudeModel:d,setClaudeModel:u,codexModel:g,setCodexModel:p,permissionMode:r,setPermissionMode:s,pendingPermissionRequests:a,setPendingPermissionRequests:n,cyclePermissionMode:f}}const mm=t=>Array.isArray(t)?t:[],vs=t=>{if(t==null||t==="")return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}},Hs=(t,r)=>r&&(r.startsWith("/")?r:`${t}/${r}`),um=(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 m=s.length-1;m>=0;m-=1)for(let d=a.length-1;d>=0;d-=1)s[m]===a[d]?n[m][d]=n[m+1][d+1]+1:n[m][d]=Math.max(n[m+1][d],n[m][d+1]);const o=[];let i=0,l=0;for(;i<s.length&&l<a.length;){const m=s[i],d=a[l];if(m===d){i+=1,l+=1;continue}if(n[i+1][l]>=n[i][l+1]){o.push({type:"removed",content:m,lineNum:i+1}),i+=1;continue}o.push({type:"added",content:d,lineNum:l+1}),l+=1}for(;i<s.length;)o.push({type:"removed",content:s[i],lineNum:i+1}),i+=1;for(;l<a.length;)o.push({type:"added",content:a[l],lineNum:l+1}),l+=1;return o},pm=()=>{const t=new Map;return(r,s)=>{const a=JSON.stringify([r,s]),n=t.get(a);if(n)return n;const o=um(r,s);if(t.set(a,o),t.size>100){const i=t.keys().next().value;i&&t.delete(i)}return o}},xm=(t,r)=>{var n,o;const s=[],a={};for(let i=0;i<t.length;i+=1){const l=t[i],m=l.content;let d="",u="assistant",g=null;try{if(m!=null&&m.role&&(m!=null&&m.content)){if(m.role==="system")continue;if(m.role==="tool"){const p=mm(m.content);for(const x of p){if((x==null?void 0:x.type)!=="tool-result")continue;const f=x.toolName==="ApplyPatch"?"Edit":x.toolName||"Unknown Tool",h=x.toolCallId||m.id,y=x.result||"";h&&a[h]?a[h].toolResult={content:y,isError:!1}:s.push({type:"assistant",content:"",timestamp:new Date(Date.now()+i*1e3),blobId:l.id,sequence:l.sequence,rowid:l.rowid,isToolUse:!0,toolName:f,toolId:h,toolInput:vs(null),toolResult:{content:y,isError:!1}})}continue}if(u=m.role==="user"?"user":"assistant",Array.isArray(m.content)){const p=[];for(const x of m.content){if((x==null?void 0:x.type)==="text"&&(x!=null&&x.text)){p.push(Lt(x.text));continue}if((x==null?void 0:x.type)==="reasoning"&&(x!=null&&x.text)){g=Lt(x.text);continue}if((x==null?void 0:x.type)==="tool-call"||(x==null?void 0:x.type)==="tool_use"){(p.length>0||g)&&(s.push({type:u,content:p.join(`
104
+ `),reasoning:g??void 0,timestamp:new Date(Date.now()+i*1e3),blobId:l.id,sequence:l.sequence,rowid:l.rowid}),p.length=0,g=null);const f=x.toolName||x.name||"Unknown Tool",h=f==="ApplyPatch"?"Edit":f,y=x.toolCallId||x.id||`tool_${i}`;let N=x.args||x.input;if(h==="Edit"&&x.args)if(x.args.patch){const v=String(x.args.patch).split(`
105
+ `),b=[],D=[];let A=!1;v.forEach(j=>{if(j.startsWith("@@")){A=!0;return}A&&(j.startsWith("-")?b.push(j.slice(1)):j.startsWith("+")?D.push(j.slice(1)):j.startsWith(" ")&&(b.push(j.slice(1)),D.push(j.slice(1))))}),N={file_path:Hs(r,x.args.file_path),old_string:b.join(`
106
+ `)||x.args.patch,new_string:D.join(`
107
+ `)||x.args.patch}}else N=x.args;else if(h==="Read"&&x.args){const v=x.args.path||x.args.file_path;N={file_path:Hs(r,v)}}else if(h==="Write"&&x.args){const v=x.args.path||x.args.file_path;N={file_path:Hs(r,v),content:x.args.contents||x.args.content}}const S={type:"assistant",content:"",timestamp:new Date(Date.now()+i*1e3),blobId:l.id,sequence:l.sequence,rowid:l.rowid,isToolUse:!0,toolName:h,toolId:y,toolInput:vs(N),toolResult:null};s.push(S),a[y]=S;continue}typeof x=="string"&&p.push(x)}p.length>0?(d=p.join(`
108
+ `),g&&!d&&(s.push({type:u,content:"",reasoning:g,timestamp:new Date(Date.now()+i*1e3),blobId:l.id,sequence:l.sequence,rowid:l.rowid}),d="")):d=""}else typeof m.content=="string"&&(d=m.content)}else if((n=m==null?void 0:m.message)!=null&&n.role&&((o=m==null?void 0:m.message)!=null&&o.content)){if(m.message.role==="system")continue;u=m.message.role==="user"?"user":"assistant",Array.isArray(m.message.content)?d=m.message.content.map(p=>typeof p=="string"?p:(p==null?void 0:p.text)||"").filter(Boolean).join(`
109
+ `):typeof m.message.content=="string"&&(d=m.message.content)}}catch(p){console.log("Error parsing blob content:",p)}if(d&&d.trim()){const p={type:u,content:d,timestamp:new Date(Date.now()+i*1e3),blobId:l.id,sequence:l.sequence,rowid:l.rowid};g&&(p.reasoning=g),s.push(p)}}return s.sort((i,l)=>i.sequence!==void 0&&l.sequence!==void 0?Number(i.sequence)-Number(l.sequence):i.rowid!==void 0&&l.rowid!==void 0?Number(i.rowid)-Number(l.rowid):new Date(i.timestamp).getTime()-new Date(l.timestamp).getTime()),s},gm=t=>{const r=[],s=new Map;return t.forEach(a=>{var n,o;((n=a.message)==null?void 0:n.role)==="user"&&Array.isArray((o=a.message)==null?void 0:o.content)&&a.message.content.forEach(i=>{i.type==="tool_result"&&s.set(i.tool_use_id,{content:i.content,isError:!!i.is_error,timestamp:new Date(a.timestamp||Date.now()),toolUseResult:a.toolUseResult||null,subagentTools:a.subagentTools})})}),t.forEach(a=>{var n,o,i,l,m,d,u;if(((n=a.message)==null?void 0:n.role)==="user"&&((o=a.message)!=null&&o.content)){let g="";if(Array.isArray(a.message.content)){const x=[];a.message.content.forEach(f=>{f.type==="text"&&x.push(Lt(f.text))}),g=x.join(`
110
+ `)}else typeof a.message.content=="string"?g=Lt(a.message.content):g=Lt(String(a.message.content));if(!(!g||g.startsWith("<command-name>")||g.startsWith("<command-message>")||g.startsWith("<command-args>")||g.startsWith("<local-command-stdout>")||g.startsWith("<system-reminder>")||g.startsWith("Caveat:")||g.startsWith("This session is being continued from a previous")||g.startsWith("[Request interrupted"))){const f=/<task-notification>\s*<task-id>[^<]*<\/task-id>\s*<output-file>[^<]*<\/output-file>\s*<status>([^<]*)<\/status>\s*<summary>([^<]*)<\/summary>\s*<\/task-notification>/g.exec(g);if(f){const h=((i=f[1])==null?void 0:i.trim())||"completed",y=((l=f[2])==null?void 0:l.trim())||"Background task finished";r.push({type:"assistant",content:y,timestamp:a.timestamp||new Date().toISOString(),isTaskNotification:!0,taskStatus:h})}else r.push({type:"user",content:ss(g),timestamp:a.timestamp||new Date().toISOString()})}return}if(a.type==="thinking"&&((m=a.message)!=null&&m.content)){r.push({type:"assistant",content:ss(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:vs(a.toolInput),toolCallId:a.toolCallId});return}if(a.type==="tool_result"){for(let g=r.length-1;g>=0;g-=1){const p=r[g];if(!(!p.isToolUse||p.toolResult)&&(!a.toolCallId||p.toolCallId===a.toolCallId)){p.toolResult={content:a.output||"",isError:!1};break}}return}if(((d=a.message)==null?void 0:d.role)==="assistant"&&((u=a.message)!=null&&u.content)){if(Array.isArray(a.message.content)){a.message.content.forEach(g=>{if(g.type==="text"){let p=g.text;typeof p=="string"&&(p=ss(p)),r.push({type:"assistant",content:p,timestamp:a.timestamp||new Date().toISOString()});return}if(g.type==="tool_use"){const p=s.get(g.id),x=g.name==="Task",f=[];if(x&&(p!=null&&p.subagentTools)&&Array.isArray(p.subagentTools))for(const h of p.subagentTools)f.push({toolId:h.toolId,toolName:h.toolName,toolInput:h.toolInput,toolResult:h.toolResult||null,timestamp:new Date(h.timestamp||Date.now())});r.push({type:"assistant",content:"",timestamp:a.timestamp||new Date().toISOString(),isToolUse:!0,toolName:g.name,toolInput:vs(g.input),toolId:g.id,toolResult:p?{content:typeof p.content=="string"?p.content:JSON.stringify(p.content),isError:p.isError,toolUseResult:p.toolUseResult}:null,toolError:(p==null?void 0:p.isError)||!1,toolResultTimestamp:(p==null?void 0:p.timestamp)||new Date,isSubagentContainer:x,subagentState:x?{childTools:f,currentToolIndex:f.length>0?f.length-1:-1,isComplete:!!p}:void 0})}});return}typeof a.message.content=="string"&&r.push({type:"assistant",content:ss(a.message.content),timestamp:a.timestamp||new Date().toISOString()})}}),r},hm=20,ns=100;function fm({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:n,externalMessageUpdate:o,processingSessions:i,resetStreamingState:l,pendingViewSessionRef:m}){const[d,u]=c.useState(()=>{if(typeof window<"u"&&t){const de=ht.getItem(`chat_messages_${t.name}`);if(de)try{return JSON.parse(de)}catch{return console.error("Failed to parse saved chat messages, resetting"),ht.removeItem(`chat_messages_${t.name}`),[]}return[]}return[]}),[g,p]=c.useState(!1),[x,f]=c.useState((r==null?void 0:r.id)||null),[h,y]=c.useState([]),[N,S]=c.useState(!1),[v,b]=c.useState(!1),[D,A]=c.useState(!1),[j,C]=c.useState(0),[L,R]=c.useState(!1),[_,$]=c.useState(!1),[F,I]=c.useState(!1),[U,w]=c.useState(null),[z,q]=c.useState(ns),[ee,M]=c.useState(null),[K,T]=c.useState(!1),[G,Y]=c.useState(!1),[J,W]=c.useState(!1),[O,se]=c.useState(!1),B=c.useRef(null),ge=c.useRef(!1),pe=c.useRef(!1),k=c.useRef(!1),E=c.useRef(!1),X=c.useRef(null),ae=c.useRef(!0),oe=c.useRef(0),Fe=c.useRef({height:0,top:0}),he=c.useRef(null),xe=c.useRef(null),Te=c.useMemo(()=>pm(),[]),Le=c.useCallback(async(de,Me,Ne=!1,_e="claude")=>{var Pe;if(!de||!Me)return[];const Oe=!Ne;Oe?S(!0):b(!0);try{const te=Ne?oe.current:0,be=await Ge.sessionMessages(de,Me,hm,te,_e);if(!be.ok)throw new Error("Failed to load session messages");const $e=await be.json();if(Oe&&$e.tokenUsage&&w($e.tokenUsage),$e.hasMore!==void 0){const st=((Pe=$e.messages)==null?void 0:Pe.length)||0;return A(!!$e.hasMore),C(Number($e.total||0)),oe.current=te+st,$e.messages||[]}const Be=$e.messages||[];return A(!1),C(Be.length),oe.current=Be.length,Be}catch(te){return console.error("Error loading session messages:",te),[]}finally{Oe?S(!1):b(!1)}},[]),ze=c.useCallback(async(de,Me)=>{var Ne;if(!de||!Me)return[];S(!0);try{const _e=`/api/cursor/sessions/${encodeURIComponent(Me)}?projectPath=${encodeURIComponent(de)}`,Oe=await Se(_e);if(!Oe.ok)return[];const Pe=await Oe.json(),te=((Ne=Pe==null?void 0:Pe.session)==null?void 0:Ne.messages)||[];return xm(te,de)}catch(_e){return console.error("Error loading Cursor session messages:",_e),[]}finally{S(!1)}},[]),re=c.useMemo(()=>gm(h),[h]),fe=c.useCallback(()=>{const de=B.current;de&&(de.scrollTop=de.scrollHeight)},[]),V=c.useCallback(()=>{fe(),K&&(q(ns),T(!1),k.current=!1)},[K,fe]),ne=c.useCallback(()=>{const de=B.current;if(!de)return!1;const{scrollTop:Me,scrollHeight:Ne,clientHeight:_e}=de;return Ne-Me-_e<50},[]),we=c.useCallback(async de=>{if(!de||pe.current||v||k.current||!D||!r||!t)return!1;const Me=r.__provider||"claude";if(Me==="cursor")return!1;pe.current=!0;const Ne=de.scrollHeight,_e=de.scrollTop;try{const Oe=await Le(t.name,r.id,!0,Me);return Oe.length===0?!1:(X.current={height:Ne,top:_e},y(Pe=>[...Oe,...Pe]),q(Pe=>Pe+Oe.length),!0)}finally{pe.current=!1}},[D,v,Le,t,r]),Ie=c.useCallback(async()=>{const de=B.current;if(!de)return;const Me=ne();if(I(!Me),!k.current){if(!(de.scrollTop<100)){E.current=!1;return}if(E.current){de.scrollTop>20&&(E.current=!1);return}await we(de)&&(E.current=!0)}},[ne,we]);c.useLayoutEffect(()=>{if(!X.current||!B.current)return;const{height:de,top:Me}=X.current,Ne=B.current,Oe=Ne.scrollHeight-de;Ne.scrollTop=Me+Math.max(Oe,0),X.current=null},[d.length]),c.useEffect(()=>{ae.current=!0,E.current=!1,X.current=null,q(ns),I(!1)},[t==null?void 0:t.name,r==null?void 0:r.id]),c.useEffect(()=>{if(!(!ae.current||!B.current||N)){if(d.length===0){ae.current=!1;return}ae.current=!1,setTimeout(()=>{fe()},200)}},[d.length,N,fe]),c.useEffect(()=>{(async()=>{if(r&&t){const Me=localStorage.getItem("selected-provider")||"claude";if(ge.current=!0,x!==null&&x!==r.id?(L||(l(),m.current=null,u([]),y([]),M(null),$(!1)),oe.current=0,A(!1),C(0),q(ns),T(!1),k.current=!1,Y(!1),W(!1),se(!1),xe.current&&clearTimeout(xe.current),he.current&&clearTimeout(he.current),w(null),p(!1),s&&a({type:"check-session-status",sessionId:r.id,provider:Me})):x===null&&(oe.current=0,A(!1),C(0),s&&a({type:"check-session-status",sessionId:r.id,provider:Me})),Me==="cursor")if(f(r.id),sessionStorage.setItem("cursorSessionId",r.id),L)R(!1);else{const _e=t.fullPath||t.path||"",Oe=await ze(_e,r.id);y([]),u(Oe)}else if(f(r.id),L)R(!1);else{const _e=await Le(t.name,r.id,!1,r.__provider||"claude");y(_e)}}else L||(l(),m.current=null,u([]),y([]),M(null),$(!1),p(!1)),f(null),sessionStorage.removeItem("cursorSessionId"),oe.current=0,A(!1),C(0),w(null);setTimeout(()=>{ge.current=!1},250)})()},[L,ze,Le,m,l,t,r,a,s]),c.useEffect(()=>{if(!o||!r||!t)return;(async()=>{try{if((localStorage.getItem("selected-provider")||"claude")==="cursor"){const Oe=t.fullPath||t.path||"",Pe=await ze(Oe,r.id);y([]),u(Pe);return}const Ne=await Le(t.name,r.id,!1,r.__provider||"claude");y(Ne),!!n&&ne()&&setTimeout(()=>fe(),200)}catch(Me){console.error("Error reloading messages from external update:",Me)}})()},[n,o,ne,ze,Le,fe,t,r]),c.useEffect(()=>{r!=null&&r.id&&(m.current=null)},[m,r==null?void 0:r.id]),c.useEffect(()=>{h.length>0&&u(re)},[re,h.length]),c.useEffect(()=>{t&&d.length>0&&ht.setItem(`chat_messages_${t.name}`,JSON.stringify(d))},[d,t]),c.useEffect(()=>{if(!t||!(r!=null&&r.id)||r.id.startsWith("new-session-")){w(null);return}if((r.__provider||"claude")!=="claude")return;(async()=>{try{const Ne=`/api/projects/${t.name}/sessions/${r.id}/token-usage`,_e=await Se(Ne);if(_e.ok){const Oe=await _e.json();w(Oe)}else w(null)}catch(Ne){console.error("Failed to fetch initial token usage:",Ne)}})()},[t,r==null?void 0:r.id,r==null?void 0:r.__provider]);const De=c.useMemo(()=>d.length<=z?d:d.slice(-z),[d,z]);c.useEffect(()=>{if(!n&&B.current){const de=B.current;Fe.current={height:de.scrollHeight,top:de.scrollTop}}}),c.useEffect(()=>{if(!B.current||d.length===0||pe.current||v||X.current)return;if(n){F||setTimeout(()=>fe(),50);return}const de=B.current,Me=Fe.current.height,Ne=Fe.current.top,Oe=de.scrollHeight-Me;Oe>0&&Ne>0&&(de.scrollTop=Ne+Oe)},[n,d.length,v,F,fe]),c.useEffect(()=>{const de=B.current;if(de)return de.addEventListener("scroll",Ie),()=>de.removeEventListener("scroll",Ie)},[Ie]),c.useEffect(()=>{const de=(r==null?void 0:r.id)||x;if(!de||!i)return;i.has(de)&&!g&&(p(!0),$(!0))},[x,g,i,r==null?void 0:r.id]);const Ue=c.useRef(!1);c.useEffect(()=>{const de=Ue.current;return Ue.current=v,de&&!v&&D&&(xe.current&&clearTimeout(xe.current),se(!0),xe.current=setTimeout(()=>{se(!1)},2e3)),!D&&!v&&(xe.current&&clearTimeout(xe.current),se(!1)),()=>{xe.current&&clearTimeout(xe.current)}},[v,D]);const Ke=c.useCallback(async()=>{if(!r||!t||G)return;const de=r.__provider||"claude";if(de==="cursor"){q(1/0),T(!0),k.current=!0,W(!0),he.current&&clearTimeout(he.current),he.current=setTimeout(()=>{W(!1),se(!1)},1e3);return}const Me=r.id;k.current=!0,pe.current=!0,Y(!0),se(!0);const Ne=B.current,_e=Ne?Ne.scrollHeight:0,Oe=Ne?Ne.scrollTop:0;try{const Pe=await Ge.sessionMessages(t.name,Me,null,0,de);if(x!==Me)return;if(Pe.ok){const te=await Pe.json(),be=te.messages||te;Ne&&(X.current={height:_e,top:Oe}),y(Array.isArray(be)?be:[]),A(!1),C(Array.isArray(be)?be.length:0),oe.current=Array.isArray(be)?be.length:0,q(1/0),T(!0),W(!0),he.current&&clearTimeout(he.current),he.current=setTimeout(()=>{W(!1),se(!1)},1e3)}else k.current=!1,se(!1)}catch(Pe){console.error("Error loading all messages:",Pe),k.current=!1,se(!1)}finally{pe.current=!1,Y(!1)}},[r,t,G,x]),Je=c.useCallback(()=>{q(de=>de+100)},[]);return{chatMessages:d,setChatMessages:u,isLoading:g,setIsLoading:p,currentSessionId:x,setCurrentSessionId:f,sessionMessages:h,setSessionMessages:y,isLoadingSessionMessages:N,isLoadingMoreMessages:v,hasMoreMessages:D,totalMessages:j,isSystemSessionChange:L,setIsSystemSessionChange:R,canAbortSession:_,setCanAbortSession:$,isUserScrolledUp:F,setIsUserScrolledUp:I,tokenBudget:U,setTokenBudget:w,visibleMessageCount:z,visibleMessages:De,loadEarlierMessages:Je,loadAllMessages:Ke,allMessagesLoaded:K,isLoadingAllMessages:G,loadAllJustFinished:J,showLoadAllOverlay:O,claudeStatus:ee,setClaudeStatus:M,createDiff:Te,scrollContainerRef:B,scrollToBottom:fe,scrollToBottomAndReset:V,isNearBottom:ne,handleScroll:Ie,loadSessionMessages:Le,loadCursorSessionMessages:ze}}const os=(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 l=s?i.content?`${i.content}
111
+ ${r}`:r:`${i.content||""}${r}`;n[o]={...i,content:l}}else n.push({type:"assistant",content:r,timestamp:new Date,isStreaming:!0});return n})},bm=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 ym({latestMessage:t,provider:r,selectedProject:s,selectedSession:a,currentSessionId:n,setCurrentSessionId:o,setChatMessages:i,setIsLoading:l,setCanAbortSession:m,setClaudeStatus:d,setTokenBudget:u,setIsSystemSessionChange:g,setPendingPermissionRequests:p,pendingViewSessionRef:x,streamBufferRef:f,streamTimerRef:h,onSessionInactive:y,onSessionProcessing:N,onSessionNotProcessing:S,onReplaceTemporarySession:v,onNavigateToSession:b}){const D=c.useRef(null);c.useEffect(()=>{var G,Y,J,W,O,se,B,ge,pe;if(!t||D.current===t)return;D.current=t;const A=((G=t.data)==null?void 0:G.message)||t.data,j=A&&typeof A=="object"?A:null,C=t.data&&typeof t.data=="object"?t.data:null,R=["projects_updated","taskmaster-project-updated","session-created"].includes(String(t.type)),_=new Set(["claude-complete","codex-complete","cursor-result","session-aborted","claude-error","cursor-error","codex-error"]),$=t.type==="claude-response"&&j&&j.type==="system"&&j.subtype==="init",F=t.type==="cursor-system"&&C&&C.type==="system"&&C.subtype==="init",I=$?j==null?void 0:j.session_id:F?C==null?void 0:C.session_id:null,U=(a==null?void 0:a.id)||n||((Y=x.current)==null?void 0:Y.sessionId)||null,w=I&&(!U||I===U),z=R||!!w,q=!t.sessionId&&x.current&&!x.current.sessionId&&(t.type==="claude-error"||t.type==="cursor-error"||t.type==="codex-error"),ee=k=>{k&&(y==null||y(k),S==null||S(k))},M=(...k)=>Array.from(new Set(k.filter(E=>typeof E=="string"&&E.length>0))),K=()=>{l(!1),m(!1),d(null)},T=(...k)=>{M(...k).forEach(X=>{y==null||y(X),S==null||S(X)})};if(!z){if(!U&&(t.sessionId&&_.has(String(t.type))&&ee(t.sessionId),!q)||!t.sessionId&&!q)return;if(t.sessionId!==U){t.sessionId&&_.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),x.current&&!x.current.sessionId&&(x.current.sessionId=t.sessionId),g(!0),v==null||v(t.sessionId),p(k=>k.map(E=>E.sessionId?E:{...E,sessionId:t.sessionId})));break;case"token-budget":t.data&&u(t.data);break;case"claude-response":{if(A&&typeof A=="object"&&A.type){if(A.type==="content_block_delta"&&((J=A.delta)!=null&&J.text)){const k=Lt(A.delta.text);f.current+=k,h.current||(h.current=window.setTimeout(()=>{const E=f.current;f.current="",h.current=null,os(i,E,!1)},100));return}if(A.type==="content_block_stop"){h.current&&(clearTimeout(h.current),h.current=null);const k=f.current;f.current="",os(i,k,!1),bm(i);return}}if((j==null?void 0:j.type)==="system"&&j.subtype==="init"&&j.session_id&&n&&j.session_id!==n&&w){console.log("Claude CLI session duplication detected:",{originalSession:n,newSession:j.session_id}),g(!0),b==null||b(j.session_id);return}if((j==null?void 0:j.type)==="system"&&j.subtype==="init"&&j.session_id&&!n&&w){console.log("New session init detected:",{newSession:j.session_id}),g(!0),b==null||b(j.session_id);return}if((j==null?void 0:j.type)==="system"&&j.subtype==="init"&&j.session_id&&n&&j.session_id===n&&w){console.log("System init message for current session, ignoring");return}if(j&&Array.isArray(j.content)){const k=C==null?void 0:C.parentToolUseId;j.content.forEach(E=>{var X;if(E.type==="tool_use"){const ae=E.input?JSON.stringify(E.input,null,2):"";if(k){i(Fe=>Fe.map(he=>{var xe;if(he.toolId===k&&he.isSubagentContainer){const Te={toolId:E.id,toolName:E.name,toolInput:E.input,toolResult:null,timestamp:new Date},Le=((xe=he.subagentState)==null?void 0:xe.childTools)||[];return{...he,subagentState:{childTools:[...Le,Te],currentToolIndex:Le.length,isComplete:!1}}}return he}));return}const oe=E.name==="Task";i(Fe=>[...Fe,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:E.name,toolInput:ae,toolId:E.id,toolResult:null,isSubagentContainer:oe,subagentState:oe?{childTools:[],currentToolIndex:-1,isComplete:!1}:void 0}]);return}if(E.type==="text"&&((X=E.text)!=null&&X.trim())){let ae=Lt(E.text);ae=oa(ae),i(oe=>[...oe,{type:"assistant",content:ae,timestamp:new Date}])}})}else if(j&&typeof j.content=="string"&&j.content.trim()){let k=Lt(j.content);k=oa(k),i(E=>[...E,{type:"assistant",content:k,timestamp:new Date}])}if((j==null?void 0:j.role)==="user"&&Array.isArray(j.content)){const k=C==null?void 0:C.parentToolUseId;j.content.forEach(E=>{E.type==="tool_result"&&i(X=>X.map(ae=>{if(k&&ae.toolId===k&&ae.isSubagentContainer)return{...ae,subagentState:{...ae.subagentState,childTools:ae.subagentState.childTools.map(oe=>oe.toolId===E.tool_use_id?{...oe,toolResult:{content:E.content,isError:E.is_error,timestamp:new Date}}:oe)}};if(ae.isToolUse&&ae.toolId===E.tool_use_id){const oe={...ae,toolResult:{content:E.content,isError:E.is_error,timestamp:new Date}};return ae.isSubagentContainer&&ae.subagentState&&(oe.subagentState={...ae.subagentState,isComplete:!0}),oe}return ae}))})}break}case"claude-output":{const k=String(t.data||"");k.trim()&&(f.current+=f.current?`
112
+ ${k}`:k,h.current||(h.current=window.setTimeout(()=>{const E=f.current;f.current="",h.current=null,os(i,E,!0)},100)));break}case"claude-interactive-prompt":{const k=typeof t.data=="string"?t.data:JSON.stringify(t.data??"",null,2);i(E=>[...E,{type:"assistant",content:k,timestamp:new Date,isInteractivePrompt:!0}])}break;case"claude-permission-request":if(r!=="claude"||!t.requestId)break;{const k=t.requestId;p(E=>E.some(X=>X.requestId===k)?E:[...E,{requestId:k,toolName:t.toolName||"UnknownTool",input:t.input,context:t.context,sessionId:t.sessionId||null,receivedAt:new Date}])}l(!0),m(!0),d({text:"Waiting for permission",tokens:0,can_interrupt:!0});break;case"claude-permission-cancelled":if(!t.requestId)break;p(k=>k.filter(E=>E.requestId!==t.requestId));break;case"claude-error":i(k=>[...k,{type:"error",content:`Error: ${t.error}`,timestamp:new Date}]);break;case"cursor-system":try{const k=t.data;if(k&&k.type==="system"&&k.subtype==="init"&&k.session_id){if(!w)return;if(n&&k.session_id!==n){console.log("Cursor session switch detected:",{originalSession:n,newSession:k.session_id}),g(!0),b==null||b(k.session_id);return}if(!n){console.log("Cursor new session init detected:",{newSession:k.session_id}),g(!0),b==null||b(k.session_id);return}}}catch(k){console.warn("Error handling cursor-system message:",k)}break;case"cursor-user":break;case"cursor-tool-use":i(k=>[...k,{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(k=>[...k,{type:"error",content:`Cursor error: ${t.error||"Unknown error"}`,timestamp:new Date}]);break;case"cursor-result":{const k=t.sessionId||n,E=sessionStorage.getItem("pendingSessionId");K(),T(k,n,a==null?void 0:a.id,E);try{const X=t.data||{},ae=typeof X.result=="string"?X.result:"";h.current&&(clearTimeout(h.current),h.current=null);const oe=f.current;f.current="",i(Fe=>{const he=[...Fe],xe=he.length-1,Te=he[xe];if(Te&&Te.type==="assistant"&&!Te.isToolUse&&Te.isStreaming){const Le=ae&&ae.trim()?ae:`${Te.content||""}${oe||""}`;he[xe]={...Te,content:Le,isStreaming:!1}}else ae&&ae.trim()&&he.push({type:X.is_error?"error":"assistant",content:ae,timestamp:new Date,isStreaming:!1});return he})}catch(X){console.warn("Error handling cursor-result message:",X)}k&&!n&&k===E&&(o(k),sessionStorage.removeItem("pendingSessionId"),window.refreshProjects&&setTimeout(()=>{var X;return(X=window.refreshProjects)==null?void 0:X.call(window)},500));break}case"cursor-output":try{const E=String(t.data??"").replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"").trim();E&&(f.current+=f.current?`
113
+ ${E}`:E,h.current||(h.current=window.setTimeout(()=>{const X=f.current;f.current="",h.current=null,os(i,X,!0)},100)))}catch(k){console.warn("Error handling cursor-output message:",k)}break;case"claude-complete":{const k=sessionStorage.getItem("pendingSessionId"),E=t.sessionId||n||k;K(),T(E,n,a==null?void 0:a.id,k),k&&!n&&t.exitCode===0&&(o(k),sessionStorage.removeItem("pendingSessionId"),console.log("New session complete, ID set to:",k)),s&&t.exitCode===0&&ht.removeItem(`chat_messages_${s.name}`),p([]);break}case"codex-response":{const k=t.data;if(!k)break;if(k.type==="item")switch(k.itemType){case"agent_message":if((O=(W=k.message)==null?void 0:W.content)!=null&&O.trim()){const E=Lt(k.message.content);i(X=>[...X,{type:"assistant",content:E,timestamp:new Date}])}break;case"reasoning":if((B=(se=k.message)==null?void 0:se.content)!=null&&B.trim()){const E=Lt(k.message.content);i(X=>[...X,{type:"assistant",content:E,timestamp:new Date,isThinking:!0}])}break;case"command_execution":k.command&&i(E=>[...E,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:k.command,toolResult:k.output||null,exitCode:k.exitCode}]);break;case"file_change":if(((ge=k.changes)==null?void 0:ge.length)>0){const E=k.changes.map(X=>`${X.kind}: ${X.path}`).join(`
114
+ `);i(X=>[...X,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:E,toolResult:{content:`Status: ${k.status}`,isError:!1}}])}break;case"mcp_tool_call":i(E=>{var X;return[...E,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${k.server}:${k.tool}`,toolInput:JSON.stringify(k.arguments,null,2),toolResult:k.result?JSON.stringify(k.result,null,2):((X=k.error)==null?void 0:X.message)||null}]});break;case"error":(pe=k.message)!=null&&pe.content&&i(E=>[...E,{type:"error",content:k.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",k.itemType,k)}k.type==="turn_complete"&&(K(),T(t.sessionId,n,a==null?void 0:a.id)),k.type==="turn_failed"&&(K(),T(t.sessionId,n,a==null?void 0:a.id),i(E=>{var X;return[...E,{type:"error",content:((X=k.error)==null?void 0:X.message)||"Turn failed",timestamp:new Date}]}));break}case"codex-complete":{const k=sessionStorage.getItem("pendingSessionId"),E=t.actualSessionId||k,X=t.sessionId||n||k;K(),T(X,E,n,a==null?void 0:a.id,k),k&&!n&&(o(E),g(!0),E&&(b==null||b(E)),sessionStorage.removeItem("pendingSessionId"),console.log("Codex session complete, ID set to:",k)),s&&ht.removeItem(`chat_messages_${s.name}`);break}case"codex-error":l(!1),m(!1),i(k=>[...k,{type:"error",content:t.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{const k=typeof window<"u"?sessionStorage.getItem("pendingSessionId"):null,E=t.sessionId||n;t.success!==!1?(K(),T(E,n,a==null?void 0:a.id,k),k&&(!E||k===E)&&sessionStorage.removeItem("pendingSessionId"),p([]),i(ae=>[...ae,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}])):i(ae=>[...ae,{type:"error",content:"Stop request failed. The session is still running.",timestamp:new Date}]);break}case"session-status":{const k=t.sessionId;(k===n||a&&k===a.id)&&t.isProcessing&&(l(!0),m(!0),N==null||N(k));break}case"claude-status":{const k=t.data;if(!k)break;const E={text:"Working...",tokens:0,can_interrupt:!0};k.message?E.text=k.message:k.status?E.text=k.status:typeof k=="string"&&(E.text=k),k.tokens?E.tokens=k.tokens:k.token_count&&(E.tokens=k.token_count),k.can_interrupt!==void 0&&(E.can_interrupt=k.can_interrupt),d(E),l(!0),m(E.can_interrupt);break}}},[t,r,s,a,n,o,i,l,m,d,u,g,p,y,N,S,v,b])}var Gs={exports:{}},qs,vn;function vm(){if(vn)return qs;vn=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return qs=t,qs}var Ks,kn;function km(){if(kn)return Ks;kn=1;var t=vm();function r(){}function s(){}return s.resetWarningCache=r,Ks=function(){function a(i,l,m,d,u,g){if(g!==t){var p=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 p.name="Invariant Violation",p}}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},Ks}var wn;function wm(){return wn||(wn=1,Gs.exports=km()()),Gs.exports}var jm=wm();const Qe=to(jm);var jn=function(){return jn=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},jn.apply(this,arguments)};function vx(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 pr(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 l(u){try{d(a.next(u))}catch(g){i(g)}}function m(u){try{d(a.throw(u))}catch(g){i(g)}}function d(u){u.done?o(u.value):n(u.value).then(l,m)}d((a=a.apply(t,r||[])).next())})}function kx(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 Nm=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 Cr(t,r,s){const a=Cm(t),{webkitRelativePath:n}=t,o=typeof r=="string"?r:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof a.path!="string"&&Nn(a,"path",o),Nn(a,"relativePath",o),a}function Cm(t){const{name:r}=t;if(r&&r.lastIndexOf(".")!==-1&&!t.type){const a=r.split(".").pop().toLowerCase(),n=Nm.get(a);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function Nn(t,r,s){Object.defineProperty(t,r,{value:s,writable:!1,configurable:!1,enumerable:!0})}const Sm=[".DS_Store","Thumbs.db"];function Em(t){return pr(this,void 0,void 0,function*(){return ks(t)&&Tm(t.dataTransfer)?Mm(t.dataTransfer,t.type):Im(t)?Am(t):Array.isArray(t)&&t.every(r=>"getFile"in r&&typeof r.getFile=="function")?Dm(t):[]})}function Tm(t){return ks(t)}function Im(t){return ks(t)&&ks(t.target)}function ks(t){return typeof t=="object"&&t!==null}function Am(t){return ca(t.target.files).map(r=>Cr(r))}function Dm(t){return pr(this,void 0,void 0,function*(){return(yield Promise.all(t.map(s=>s.getFile()))).map(s=>Cr(s))})}function Mm(t,r){return pr(this,void 0,void 0,function*(){if(t.items){const s=ca(t.items).filter(n=>n.kind==="file");if(r!=="drop")return s;const a=yield Promise.all(s.map($m));return Cn(Yo(a))}return Cn(ca(t.files).map(s=>Cr(s)))})}function Cn(t){return t.filter(r=>Sm.indexOf(r.name)===-1)}function ca(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 $m(t){if(typeof t.webkitGetAsEntry!="function")return Sn(t);const r=t.webkitGetAsEntry();return r&&r.isDirectory?Qo(r):Sn(t,r)}function Yo(t){return t.reduce((r,s)=>[...r,...Array.isArray(s)?Yo(s):[s]],[])}function Sn(t,r){return pr(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,Cr(i)}}const a=t.getAsFile();if(!a)throw new Error(`${t} is not a File`);return Cr(a,(s=r==null?void 0:r.fullPath)!==null&&s!==void 0?s:void 0)})}function Fm(t){return pr(this,void 0,void 0,function*(){return t.isDirectory?Qo(t):Pm(t)})}function Qo(t){const r=t.createReader();return new Promise((s,a)=>{const n=[];function o(){r.readEntries(i=>pr(this,void 0,void 0,function*(){if(i.length){const l=Promise.all(i.map(Fm));n.push(l),o()}else try{const l=yield Promise.all(n);s(l)}catch(l){a(l)}}),i=>{a(i)})}o()})}function Pm(t){return pr(this,void 0,void 0,function*(){return new Promise((r,s)=>{t.file(a=>{const n=Cr(a,t.fullPath);r(n)},a=>{s(a)})})})}var is={},En;function Lm(){return En||(En=1,is.__esModule=!0,is.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 l=i.trim().toLowerCase();return l.charAt(0)==="."?a.toLowerCase().endsWith(l):l.endsWith("/*")?o===l.replace(/\/.*$/,""):n===l})}return!0}),is}var _m=Lm();const Vs=to(_m);function Tn(t){return Rm(t)||Om(t)||Zo(t)||zm()}function zm(){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 Om(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Rm(t){if(Array.isArray(t))return da(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 An(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){Xo(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 Xo(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function Gr(t,r){return Um(t)||Wm(t,r)||Zo(t,r)||Bm()}function Bm(){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 Zo(t,r){if(t){if(typeof t=="string")return da(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 da(t,r)}}function da(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 Wm(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,l;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(m){o=!0,l=m}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw l}}return a}}function Um(t){if(Array.isArray(t))return t}var Hm=typeof Vs=="function"?Vs:Vs.default,Gm="file-invalid-type",qm="file-too-large",Km="file-too-small",Vm="too-many-files",Jm=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:Gm,message:"File type must be ".concat(a)}},Dn=function(r){return{code:qm,message:"File is larger than ".concat(r," ").concat(r===1?"byte":"bytes")}},Mn=function(r){return{code:Km,message:"File is smaller than ".concat(r," ").concat(r===1?"byte":"bytes")}},Ym={code:Vm,message:"Too many files"};function Qm(t){return t.type===""&&typeof t.getAsFile=="function"}function ei(t,r){var s=t.type==="application/x-moz-file"||Hm(t,r)||Qm(t);return[s,s?null:Jm(r)]}function ti(t,r,s){if(lr(t.size))if(lr(r)&&lr(s)){if(t.size>s)return[!1,Dn(s)];if(t.size<r)return[!1,Mn(r)]}else{if(lr(r)&&t.size<r)return[!1,Mn(r)];if(lr(s)&&t.size>s)return[!1,Dn(s)]}return[!0,null]}function lr(t){return t!=null}function Xm(t){var r=t.files,s=t.accept,a=t.minSize,n=t.maxSize,o=t.multiple,i=t.maxFiles,l=t.validator;return!o&&r.length>1||o&&i>=1&&r.length>i?!1:r.every(function(m){var d=ei(m,s),u=Gr(d,1),g=u[0],p=ti(m,a,n),x=Gr(p,1),f=x[0],h=l?l(m):null;return g&&f&&!h})}function ws(t){return typeof t.isPropagationStopped=="function"?t.isPropagationStopped():typeof t.cancelBubble<"u"?t.cancelBubble:!1}function Lr(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 $n(t){t.preventDefault()}function Zm(t){return t.indexOf("MSIE")!==-1||t.indexOf("Trident/")!==-1}function eu(t){return t.indexOf("Edge/")!==-1}function tu(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Zm(t)||eu(t)}function Mt(){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(l){return!ws(a)&&l&&l.apply(void 0,[a].concat(o)),ws(a)})}}function ru(){return"showOpenFilePicker"in window}function su(t){if(lr(t)){var r=Object.entries(t).filter(function(s){var a=Gr(s,2),n=a[0],o=a[1],i=!0;return ri(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(si))&&(console.warn('Skipped "'.concat(n,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(s,a){var n=Gr(a,2),o=n[0],i=n[1];return An(An({},s),{},Xo({},o,i))},{});return[{description:"Files",accept:r}]}return t}function au(t){if(lr(t))return Object.entries(t).reduce(function(r,s){var a=Gr(s,2),n=a[0],o=a[1];return[].concat(Tn(r),[n],Tn(o))},[]).filter(function(r){return ri(r)||si(r)}).join(",")}function nu(t){return t instanceof DOMException&&(t.name==="AbortError"||t.code===t.ABORT_ERR)}function ou(t){return t instanceof DOMException&&(t.name==="SecurityError"||t.code===t.SECURITY_ERR)}function ri(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||t==="application/*"||/\w+\/[-+.\w]+/g.test(t)}function si(t){return/^.*\.[\w]+$/.test(t)}var iu=["children"],lu=["open"],cu=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],du=["refKey","onChange","onClick"];function Fn(t){return pu(t)||uu(t)||ai(t)||mu()}function mu(){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 uu(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function pu(t){if(Array.isArray(t))return ma(t)}function Js(t,r){return hu(t)||gu(t,r)||ai(t,r)||xu()}function xu(){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 ai(t,r){if(t){if(typeof t=="string")return ma(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 ma(t,r)}}function ma(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 gu(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,l;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(m){o=!0,l=m}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw l}}return a}}function hu(t){if(Array.isArray(t))return t}function Pn(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 tt(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?Pn(Object(s),!0).forEach(function(a){ua(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Pn(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function ua(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function js(t,r){if(t==null)return{};var s=fu(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 fu(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=c.forwardRef(function(t,r){var s=t.children,a=js(t,iu),n=oi(a),o=n.open,i=js(n,lu);return c.useImperativeHandle(r,function(){return{open:o}},[o]),Ft.createElement(c.Fragment,null,s(tt(tt({},i),{},{open:o})))});Pa.displayName="Dropzone";var ni={disabled:!1,getFilesFromEvent:Em,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=ni;Pa.propTypes={children:Qe.func,accept:Qe.objectOf(Qe.arrayOf(Qe.string)),multiple:Qe.bool,preventDropOnDocument:Qe.bool,noClick:Qe.bool,noKeyboard:Qe.bool,noDrag:Qe.bool,noDragEventsBubbling:Qe.bool,minSize:Qe.number,maxSize:Qe.number,maxFiles:Qe.number,disabled:Qe.bool,getFilesFromEvent:Qe.func,onFileDialogCancel:Qe.func,onFileDialogOpen:Qe.func,useFsAccessApi:Qe.bool,autoFocus:Qe.bool,onDragEnter:Qe.func,onDragLeave:Qe.func,onDragOver:Qe.func,onDrop:Qe.func,onDropAccepted:Qe.func,onDropRejected:Qe.func,onError:Qe.func,validator:Qe.func};var pa={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function oi(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=tt(tt({},ni),t),s=r.accept,a=r.disabled,n=r.getFilesFromEvent,o=r.maxSize,i=r.minSize,l=r.multiple,m=r.maxFiles,d=r.onDragEnter,u=r.onDragLeave,g=r.onDragOver,p=r.onDrop,x=r.onDropAccepted,f=r.onDropRejected,h=r.onFileDialogCancel,y=r.onFileDialogOpen,N=r.useFsAccessApi,S=r.autoFocus,v=r.preventDropOnDocument,b=r.noClick,D=r.noKeyboard,A=r.noDrag,j=r.noDragEventsBubbling,C=r.onError,L=r.validator,R=c.useMemo(function(){return au(s)},[s]),_=c.useMemo(function(){return su(s)},[s]),$=c.useMemo(function(){return typeof y=="function"?y:Ln},[y]),F=c.useMemo(function(){return typeof h=="function"?h:Ln},[h]),I=c.useRef(null),U=c.useRef(null),w=c.useReducer(bu,pa),z=Js(w,2),q=z[0],ee=z[1],M=q.isFocused,K=q.isFileDialogActive,T=c.useRef(typeof window<"u"&&window.isSecureContext&&N&&ru()),G=function(){!T.current&&K&&setTimeout(function(){if(U.current){var ne=U.current.files;ne.length||(ee({type:"closeDialog"}),F())}},300)};c.useEffect(function(){return window.addEventListener("focus",G,!1),function(){window.removeEventListener("focus",G,!1)}},[U,K,F,T]);var Y=c.useRef([]),J=c.useRef([]),W=function(ne){I.current&&I.current.contains(ne.target)||(ne.preventDefault(),Y.current=[])};c.useEffect(function(){return v&&(document.addEventListener("dragover",$n,!1),document.addEventListener("drop",W,!1)),function(){v&&(document.removeEventListener("dragover",$n),document.removeEventListener("drop",W))}},[I,v]),c.useEffect(function(){var V=function(Ue){J.current=[].concat(Fn(J.current),[Ue.target]),Lr(Ue)&&ee({isDragGlobal:!0,type:"setDragGlobal"})},ne=function(Ue){J.current=J.current.filter(function(Ke){return Ke!==Ue.target&&Ke!==null}),!(J.current.length>0)&&ee({isDragGlobal:!1,type:"setDragGlobal"})},we=function(){J.current=[],ee({isDragGlobal:!1,type:"setDragGlobal"})},Ie=function(){J.current=[],ee({isDragGlobal:!1,type:"setDragGlobal"})};return document.addEventListener("dragenter",V,!1),document.addEventListener("dragleave",ne,!1),document.addEventListener("dragend",we,!1),document.addEventListener("drop",Ie,!1),function(){document.removeEventListener("dragenter",V),document.removeEventListener("dragleave",ne),document.removeEventListener("dragend",we),document.removeEventListener("drop",Ie)}},[I]),c.useEffect(function(){return!a&&S&&I.current&&I.current.focus(),function(){}},[I,S,a]);var O=c.useCallback(function(V){C?C(V):console.error(V)},[C]),se=c.useCallback(function(V){V.preventDefault(),V.persist(),Le(V),Y.current=[].concat(Fn(Y.current),[V.target]),Lr(V)&&Promise.resolve(n(V)).then(function(ne){if(!(ws(V)&&!j)){var we=ne.length,Ie=we>0&&Xm({files:ne,accept:R,minSize:i,maxSize:o,multiple:l,maxFiles:m,validator:L}),De=we>0&&!Ie;ee({isDragAccept:Ie,isDragReject:De,isDragActive:!0,type:"setDraggedFiles"}),d&&d(V)}}).catch(function(ne){return O(ne)})},[n,d,O,j,R,i,o,l,m,L]),B=c.useCallback(function(V){V.preventDefault(),V.persist(),Le(V);var ne=Lr(V);if(ne&&V.dataTransfer)try{V.dataTransfer.dropEffect="copy"}catch{}return ne&&g&&g(V),!1},[g,j]),ge=c.useCallback(function(V){V.preventDefault(),V.persist(),Le(V);var ne=Y.current.filter(function(Ie){return I.current&&I.current.contains(Ie)}),we=ne.indexOf(V.target);we!==-1&&ne.splice(we,1),Y.current=ne,!(ne.length>0)&&(ee({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Lr(V)&&u&&u(V))},[I,u,j]),pe=c.useCallback(function(V,ne){var we=[],Ie=[];V.forEach(function(De){var Ue=ei(De,R),Ke=Js(Ue,2),Je=Ke[0],de=Ke[1],Me=ti(De,i,o),Ne=Js(Me,2),_e=Ne[0],Oe=Ne[1],Pe=L?L(De):null;if(Je&&_e&&!Pe)we.push(De);else{var te=[de,Oe];Pe&&(te=te.concat(Pe)),Ie.push({file:De,errors:te.filter(function(be){return be})})}}),(!l&&we.length>1||l&&m>=1&&we.length>m)&&(we.forEach(function(De){Ie.push({file:De,errors:[Ym]})}),we.splice(0)),ee({acceptedFiles:we,fileRejections:Ie,isDragReject:Ie.length>0,type:"setFiles"}),p&&p(we,Ie,ne),Ie.length>0&&f&&f(Ie,ne),we.length>0&&x&&x(we,ne)},[ee,l,R,i,o,m,p,x,f,L]),k=c.useCallback(function(V){V.preventDefault(),V.persist(),Le(V),Y.current=[],Lr(V)&&Promise.resolve(n(V)).then(function(ne){ws(V)&&!j||pe(ne,V)}).catch(function(ne){return O(ne)}),ee({type:"reset"})},[n,pe,O,j]),E=c.useCallback(function(){if(T.current){ee({type:"openDialog"}),$();var V={multiple:l,types:_};window.showOpenFilePicker(V).then(function(ne){return n(ne)}).then(function(ne){pe(ne,null),ee({type:"closeDialog"})}).catch(function(ne){nu(ne)?(F(ne),ee({type:"closeDialog"})):ou(ne)?(T.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(ne)});return}U.current&&(ee({type:"openDialog"}),$(),U.current.value=null,U.current.click())},[ee,$,F,N,pe,O,_,l]),X=c.useCallback(function(V){!I.current||!I.current.isEqualNode(V.target)||(V.key===" "||V.key==="Enter"||V.keyCode===32||V.keyCode===13)&&(V.preventDefault(),E())},[I,E]),ae=c.useCallback(function(){ee({type:"focus"})},[]),oe=c.useCallback(function(){ee({type:"blur"})},[]),Fe=c.useCallback(function(){b||(tu()?setTimeout(E,0):E())},[b,E]),he=function(ne){return a?null:ne},xe=function(ne){return D?null:he(ne)},Te=function(ne){return A?null:he(ne)},Le=function(ne){j&&ne.stopPropagation()},ze=c.useMemo(function(){return function(){var V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ne=V.refKey,we=ne===void 0?"ref":ne,Ie=V.role,De=V.onKeyDown,Ue=V.onFocus,Ke=V.onBlur,Je=V.onClick,de=V.onDragEnter,Me=V.onDragOver,Ne=V.onDragLeave,_e=V.onDrop,Oe=js(V,cu);return tt(tt(ua({onKeyDown:xe(Mt(De,X)),onFocus:xe(Mt(Ue,ae)),onBlur:xe(Mt(Ke,oe)),onClick:he(Mt(Je,Fe)),onDragEnter:Te(Mt(de,se)),onDragOver:Te(Mt(Me,B)),onDragLeave:Te(Mt(Ne,ge)),onDrop:Te(Mt(_e,k)),role:typeof Ie=="string"&&Ie!==""?Ie:"presentation"},we,I),!a&&!D?{tabIndex:0}:{}),Oe)}},[I,X,ae,oe,Fe,se,B,ge,k,D,A,a]),re=c.useCallback(function(V){V.stopPropagation()},[]),fe=c.useMemo(function(){return function(){var V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ne=V.refKey,we=ne===void 0?"ref":ne,Ie=V.onChange,De=V.onClick,Ue=js(V,du),Ke=ua({accept:R,multiple:l,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:he(Mt(Ie,k)),onClick:he(Mt(De,re)),tabIndex:-1},we,U);return tt(tt({},Ke),Ue)}},[U,s,l,k,a]);return tt(tt({},q),{},{isFocused:M&&!a,getRootProps:ze,getInputProps:fe,rootRef:I,inputRef:U,open:he(E)})}function bu(t,r){switch(r.type){case"focus":return tt(tt({},t),{},{isFocused:!0});case"blur":return tt(tt({},t),{},{isFocused:!1});case"openDialog":return tt(tt({},pa),{},{isFileDialogActive:!0});case"closeDialog":return tt(tt({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return tt(tt({},t),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return tt(tt({},t),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"setDragGlobal":return tt(tt({},t),{},{isDragGlobal:r.isDragGlobal});case"reset":return tt({},pa);default:return t}}function Ln(){}const ii=(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(ii(a.children,n));return}a.type==="file"&&s.push({name:a.name,path:n,relativePath:a.path})}),s};function yu({selectedProject:t,input:r,setInput:s,textareaRef:a}){const[n,o]=c.useState([]),[i,l]=c.useState([]),[m,d]=c.useState([]),[u,g]=c.useState(!1),[p,x]=c.useState(-1),[f,h]=c.useState(0),[y,N]=c.useState(-1);c.useEffect(()=>{const L=new AbortController;return(async()=>{const _=t==null?void 0:t.name;if(o([]),d([]),!!_)try{const $=await Ge.getFiles(_,{signal:L.signal});if(!$.ok)return;const F=await $.json();o(ii(F))}catch($){if(($==null?void 0:$.name)==="AbortError")return;console.error("Error fetching files:",$)}})(),()=>{L.abort()}},[t==null?void 0:t.name]),c.useEffect(()=>{const L=r.slice(0,f),R=L.lastIndexOf("@");if(R===-1){g(!1),N(-1);return}const _=L.slice(R+1);if(_.includes(" ")){g(!1),N(-1);return}N(R),g(!0),x(-1);const $=n.filter(F=>F.name.toLowerCase().includes(_.toLowerCase())||F.path.toLowerCase().includes(_.toLowerCase())).slice(0,10);d($)},[r,f,n]);const S=c.useMemo(()=>!r||i.length===0?[]:i.filter(L=>r.includes(L)),[i,r]),v=c.useMemo(()=>S.length===0?[]:Array.from(new Set(S)).sort((R,_)=>_.length-R.length),[S]),b=c.useMemo(()=>{if(v.length===0)return null;const L=v.map(Oo).join("|");return new RegExp(`(${L})`,"g")},[v]),D=c.useMemo(()=>new Set(v),[v]),A=c.useCallback(L=>L?b?L.split(b).map((_,$)=>D.has(_)?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:_},`mention-${$}`):e.jsx("span",{children:_},`text-${$}`)):L:"",[b,D]),j=c.useCallback(L=>{const R=r.slice(0,y),_=r.slice(y),$=_.indexOf(" "),F=$!==-1?_.slice($):"",I=`${R}${L.path} ${F}`,U=R.length+L.path.length+1;a.current&&!a.current.matches(":focus")&&a.current.focus(),s(I),h(U),l(w=>w.includes(L.path)?w:[...w,L.path]),g(!1),N(-1),a.current&&requestAnimationFrame(()=>{a.current&&(a.current.setSelectionRange(U,U),a.current.matches(":focus")||a.current.focus())})},[r,y,a,s]),C=c.useCallback(L=>!u||m.length===0?!1:L.key==="ArrowDown"?(L.preventDefault(),x(R=>R<m.length-1?R+1:0),!0):L.key==="ArrowUp"?(L.preventDefault(),x(R=>R>0?R-1:m.length-1),!0):L.key==="Tab"||L.key==="Enter"?(L.preventDefault(),p>=0?j(m[p]):m.length>0&&j(m[0]),!0):L.key==="Escape"?(L.preventDefault(),g(!1),!0):!1,[u,m,p,j]);return{showFileDropdown:u,filteredFiles:m,selectedFileIndex:p,renderInputWithMentions:A,selectFile:j,setCursorPosition:h,handleFileMentionsKeyDown:C}}function Gt(t){return Array.isArray?Array.isArray(t):di(t)==="[object Array]"}function vu(t){if(typeof t=="string")return t;let r=t+"";return r=="0"&&1/t==-1/0?"-0":r}function ku(t){return t==null?"":vu(t)}function _t(t){return typeof t=="string"}function li(t){return typeof t=="number"}function wu(t){return t===!0||t===!1||ju(t)&&di(t)=="[object Boolean]"}function ci(t){return typeof t=="object"}function ju(t){return ci(t)&&t!==null}function Nt(t){return t!=null}function Ys(t){return!t.trim().length}function di(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Nu="Incorrect 'index' type",Cu=t=>`Invalid value for key ${t}`,Su=t=>`Pattern length exceeds max of ${t}.`,Eu=t=>`Missing ${t} property in key`,Tu=t=>`Property 'weight' in key '${t}' must be a positive integer`,_n=Object.prototype.hasOwnProperty;class Iu{constructor(r){this._keys=[],this._keyMap={};let s=0;r.forEach(a=>{let n=mi(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 mi(t){let r=null,s=null,a=null,n=1,o=null;if(_t(t)||Gt(t))a=t,r=zn(t),s=xa(t);else{if(!_n.call(t,"name"))throw new Error(Eu("name"));const i=t.name;if(a=i,_n.call(t,"weight")&&(n=t.weight,n<=0))throw new Error(Tu(i));r=zn(i),s=xa(i),o=t.getFn}return{path:r,id:s,weight:n,src:a,getFn:o}}function zn(t){return Gt(t)?t:t.split(".")}function xa(t){return Gt(t)?t.join("."):t}function Au(t,r){let s=[],a=!1;const n=(o,i,l)=>{if(Nt(o))if(!i[l])s.push(o);else{let m=i[l];const d=o[m];if(!Nt(d))return;if(l===i.length-1&&(_t(d)||li(d)||wu(d)))s.push(ku(d));else if(Gt(d)){a=!0;for(let u=0,g=d.length;u<g;u+=1)n(d[u],i,l+1)}else i.length&&n(d,i,l+1)}};return n(t,_t(r)?r.split("."):r,0),a?s:s[0]}const Du={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Mu={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},$u={location:0,threshold:.6,distance:100},Fu={useExtendedSearch:!1,getFn:Au,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Ae={...Mu,...Du,...$u,...Fu};const Pu=/[^ ]+/g;function Lu(t=1,r=3){const s=new Map,a=Math.pow(10,r);return{get(n){const o=n.match(Pu).length;if(s.has(o))return s.get(o);const i=1/Math.pow(o,.5*t),l=parseFloat(Math.round(i*a)/a);return s.set(o,l),l},clear(){s.clear()}}}class La{constructor({getFn:r=Ae.getFn,fieldNormWeight:s=Ae.fieldNormWeight}={}){this.norm=Lu(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,_t(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();_t(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(!Nt(r)||Ys(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(Nt(i)){if(Gt(i)){let l=[];const m=[{nestedArrIndex:-1,value:i}];for(;m.length;){const{nestedArrIndex:d,value:u}=m.pop();if(Nt(u))if(_t(u)&&!Ys(u)){let g={v:u,i:d,n:this.norm.get(u)};l.push(g)}else Gt(u)&&u.forEach((g,p)=>{m.push({nestedArrIndex:p,value:g})})}a.$[o]=l}else if(_t(i)&&!Ys(i)){let l={v:i,n:this.norm.get(i)};a.$[o]=l}}}),this.records.push(a)}toJSON(){return{keys:this.keys,records:this.records}}}function ui(t,r,{getFn:s=Ae.getFn,fieldNormWeight:a=Ae.fieldNormWeight}={}){const n=new La({getFn:s,fieldNormWeight:a});return n.setKeys(t.map(mi)),n.setSources(r),n.create(),n}function _u(t,{getFn:r=Ae.getFn,fieldNormWeight:s=Ae.fieldNormWeight}={}){const{keys:a,records:n}=t,o=new La({getFn:r,fieldNormWeight:s});return o.setKeys(a),o.setIndexRecords(n),o}function ls(t,{errors:r=0,currentLocation:s=0,expectedLocation:a=0,distance:n=Ae.distance,ignoreLocation:o=Ae.ignoreLocation}={}){const i=r/t.length;if(o)return i;const l=Math.abs(a-s);return n?i+l/n:l?1:i}function zu(t=[],r=Ae.minMatchCharLength){let s=[],a=-1,n=-1,o=0;for(let i=t.length;o<i;o+=1){let l=t[o];l&&a===-1?a=o:!l&&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 cr=32;function Ou(t,r,s,{location:a=Ae.location,distance:n=Ae.distance,threshold:o=Ae.threshold,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:l=Ae.minMatchCharLength,includeMatches:m=Ae.includeMatches,ignoreLocation:d=Ae.ignoreLocation}={}){if(r.length>cr)throw new Error(Su(cr));const u=r.length,g=t.length,p=Math.max(0,Math.min(a,g));let x=o,f=p;const h=l>1||m,y=h?Array(g):[];let N;for(;(N=t.indexOf(r,f))>-1;){let j=ls(r,{currentLocation:N,expectedLocation:p,distance:n,ignoreLocation:d});if(x=Math.min(j,x),f=N+u,h){let C=0;for(;C<u;)y[N+C]=1,C+=1}}f=-1;let S=[],v=1,b=u+g;const D=1<<u-1;for(let j=0;j<u;j+=1){let C=0,L=b;for(;C<L;)ls(r,{errors:j,currentLocation:p+L,expectedLocation:p,distance:n,ignoreLocation:d})<=x?C=L:b=L,L=Math.floor((b-C)/2+C);b=L;let R=Math.max(1,p-L+1),_=i?g:Math.min(p+L,g)+u,$=Array(_+2);$[_+1]=(1<<j)-1;for(let I=_;I>=R;I-=1){let U=I-1,w=s[t.charAt(U)];if(h&&(y[U]=+!!w),$[I]=($[I+1]<<1|1)&w,j&&($[I]|=(S[I+1]|S[I])<<1|1|S[I+1]),$[I]&D&&(v=ls(r,{errors:j,currentLocation:U,expectedLocation:p,distance:n,ignoreLocation:d}),v<=x)){if(x=v,f=U,f<=p)break;R=Math.max(1,2*p-f)}}if(ls(r,{errors:j+1,currentLocation:p,expectedLocation:p,distance:n,ignoreLocation:d})>x)break;S=$}const A={isMatch:f>=0,score:Math.max(.001,v)};if(h){const j=zu(y,l);j.length?m&&(A.indices=j):A.isMatch=!1}return A}function Ru(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 Ns=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 pi{constructor(r,{location:s=Ae.location,threshold:a=Ae.threshold,distance:n=Ae.distance,includeMatches:o=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:l=Ae.minMatchCharLength,isCaseSensitive:m=Ae.isCaseSensitive,ignoreDiacritics:d=Ae.ignoreDiacritics,ignoreLocation:u=Ae.ignoreLocation}={}){if(this.options={location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:l,isCaseSensitive:m,ignoreDiacritics:d,ignoreLocation:u},r=m?r:r.toLowerCase(),r=d?Ns(r):r,this.pattern=r,this.chunks=[],!this.pattern.length)return;const g=(x,f)=>{this.chunks.push({pattern:x,alphabet:Ru(x),startIndex:f})},p=this.pattern.length;if(p>cr){let x=0;const f=p%cr,h=p-f;for(;x<h;)g(this.pattern.substr(x,cr),x),x+=cr;if(f){const y=p-cr;g(this.pattern.substr(y),y)}}else g(this.pattern,0)}searchIn(r){const{isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n}=this.options;if(r=s?r:r.toLowerCase(),r=a?Ns(r):r,this.pattern===r){let h={isMatch:!0,score:0};return n&&(h.indices=[[0,r.length-1]]),h}const{location:o,distance:i,threshold:l,findAllMatches:m,minMatchCharLength:d,ignoreLocation:u}=this.options;let g=[],p=0,x=!1;this.chunks.forEach(({pattern:h,alphabet:y,startIndex:N})=>{const{isMatch:S,score:v,indices:b}=Ou(r,h,y,{location:o+N,distance:i,threshold:l,findAllMatches:m,minMatchCharLength:d,includeMatches:n,ignoreLocation:u});S&&(x=!0),p+=v,S&&b&&(g=[...g,...b])});let f={isMatch:x,score:x?p/this.chunks.length:1};return x&&n&&(f.indices=g),f}}class ar{constructor(r){this.pattern=r}static isMultiMatch(r){return On(r,this.multiRegex)}static isSingleMatch(r){return On(r,this.singleRegex)}search(){}}function On(t,r){const s=t.match(r);return s?s[1]:null}class Bu extends ar{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 Wu extends ar{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 Uu extends ar{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 Hu extends ar{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 Gu extends ar{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 qu extends ar{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 xi extends ar{constructor(r,{location:s=Ae.location,threshold:a=Ae.threshold,distance:n=Ae.distance,includeMatches:o=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:l=Ae.minMatchCharLength,isCaseSensitive:m=Ae.isCaseSensitive,ignoreDiacritics:d=Ae.ignoreDiacritics,ignoreLocation:u=Ae.ignoreLocation}={}){super(r),this._bitapSearch=new pi(r,{location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:l,isCaseSensitive:m,ignoreDiacritics:d,ignoreLocation:u})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(r){return this._bitapSearch.searchIn(r)}}class gi extends ar{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 ga=[Bu,gi,Uu,Hu,qu,Gu,Wu,xi],Rn=ga.length,Ku=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Vu="|";function Ju(t,r={}){return t.split(Vu).map(s=>{let a=s.trim().split(Ku).filter(o=>o&&!!o.trim()),n=[];for(let o=0,i=a.length;o<i;o+=1){const l=a[o];let m=!1,d=-1;for(;!m&&++d<Rn;){const u=ga[d];let g=u.isMultiMatch(l);g&&(n.push(new u(g,r)),m=!0)}if(!m)for(d=-1;++d<Rn;){const u=ga[d];let g=u.isSingleMatch(l);if(g){n.push(new u(g,r));break}}}return n})}const Yu=new Set([xi.type,gi.type]);class Qu{constructor(r,{isCaseSensitive:s=Ae.isCaseSensitive,ignoreDiacritics:a=Ae.ignoreDiacritics,includeMatches:n=Ae.includeMatches,minMatchCharLength:o=Ae.minMatchCharLength,ignoreLocation:i=Ae.ignoreLocation,findAllMatches:l=Ae.findAllMatches,location:m=Ae.location,threshold:d=Ae.threshold,distance:u=Ae.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n,minMatchCharLength:o,findAllMatches:l,ignoreLocation:i,location:m,threshold:d,distance:u},r=s?r:r.toLowerCase(),r=a?Ns(r):r,this.pattern=r,this.query=Ju(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?Ns(r):r;let i=0,l=[],m=0;for(let d=0,u=s.length;d<u;d+=1){const g=s[d];l.length=0,i=0;for(let p=0,x=g.length;p<x;p+=1){const f=g[p],{isMatch:h,indices:y,score:N}=f.search(r);if(h){if(i+=1,m+=N,a){const S=f.constructor.type;Yu.has(S)?l=[...l,...y]:l.push(y)}}else{m=0,i=0,l.length=0;break}}if(i){let p={isMatch:!0,score:m/i};return a&&(p.indices=l),p}}return{isMatch:!1,score:1}}}const ha=[];function Xu(...t){ha.push(...t)}function fa(t,r){for(let s=0,a=ha.length;s<a;s+=1){let n=ha[s];if(n.condition(t,r))return new n(t,r)}return new pi(t,r)}const Cs={AND:"$and",OR:"$or"},ba={PATH:"$path",PATTERN:"$val"},ya=t=>!!(t[Cs.AND]||t[Cs.OR]),Zu=t=>!!t[ba.PATH],ep=t=>!Gt(t)&&ci(t)&&!ya(t),Bn=t=>({[Cs.AND]:Object.keys(t).map(r=>({[r]:t[r]}))});function hi(t,r,{auto:s=!0}={}){const a=n=>{let o=Object.keys(n);const i=Zu(n);if(!i&&o.length>1&&!ya(n))return a(Bn(n));if(ep(n)){const m=i?n[ba.PATH]:o[0],d=i?n[ba.PATTERN]:n[m];if(!_t(d))throw new Error(Cu(m));const u={keyId:xa(m),pattern:d};return s&&(u.searcher=fa(d,r)),u}let l={children:[],operator:o[0]};return o.forEach(m=>{const d=n[m];Gt(d)&&d.forEach(u=>{l.children.push(a(u))})}),l};return ya(t)||(t=Bn(t)),a(t)}function tp(t,{ignoreFieldNorm:r=Ae.ignoreFieldNorm}){t.forEach(s=>{let a=1;s.matches.forEach(({key:n,norm:o,score:i})=>{const l=n?n.weight:null;a*=Math.pow(i===0&&l?Number.EPSILON:i,(l||1)*(r?1:o))}),s.score=a})}function rp(t,r){const s=t.matches;r.matches=[],Nt(s)&&s.forEach(a=>{if(!Nt(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 sp(t,r){r.score=t.score}function ap(t,r,{includeMatches:s=Ae.includeMatches,includeScore:a=Ae.includeScore}={}){const n=[];return s&&n.push(rp),a&&n.push(sp),t.map(o=>{const{idx:i}=o,l={item:r[i],refIndex:i};return n.length&&n.forEach(m=>{m(o,l)}),l})}class Tr{constructor(r,s={},a){this.options={...Ae,...s},this.options.useExtendedSearch,this._keyStore=new Iu(this.options.keys),this.setCollection(r,a)}setCollection(r,s){if(this._docs=r,s&&!(s instanceof La))throw new Error(Nu);this._myIndex=s||ui(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(r){Nt(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:l}=this.options;let m=_t(r)?_t(this._docs[0])?this._searchStringList(r):this._searchObjectList(r):this._searchLogical(r);return tp(m,{ignoreFieldNorm:l}),o&&m.sort(i),li(s)&&s>-1&&(m=m.slice(0,s)),ap(m,this._docs,{includeMatches:a,includeScore:n})}_searchStringList(r){const s=fa(r,this.options),{records:a}=this._myIndex,n=[];return a.forEach(({v:o,i,n:l})=>{if(!Nt(o))return;const{isMatch:m,score:d,indices:u}=s.searchIn(o);m&&n.push({item:o,idx:i,matches:[{score:d,value:o,norm:l,indices:u}]})}),n}_searchLogical(r){const s=hi(r,this.options),a=(l,m,d)=>{if(!l.children){const{keyId:g,searcher:p}=l,x=this._findMatches({key:this._keyStore.get(g),value:this._myIndex.getValueForItemAtKeyId(m,g),searcher:p});return x&&x.length?[{idx:d,item:m,matches:x}]:[]}const u=[];for(let g=0,p=l.children.length;g<p;g+=1){const x=l.children[g],f=a(x,m,d);if(f.length)u.push(...f);else if(l.operator===Cs.AND)return[]}return u},n=this._myIndex.records,o={},i=[];return n.forEach(({$:l,i:m})=>{if(Nt(l)){let d=a(s,l,m);d.length&&(o[m]||(o[m]={idx:m,item:l,matches:[]},i.push(o[m])),d.forEach(({matches:u})=>{o[m].matches.push(...u)}))}}),i}_searchObjectList(r){const s=fa(r,this.options),{keys:a,records:n}=this._myIndex,o=[];return n.forEach(({$:i,i:l})=>{if(!Nt(i))return;let m=[];a.forEach((d,u)=>{m.push(...this._findMatches({key:d,value:i[u],searcher:s}))}),m.length&&o.push({idx:l,item:i,matches:m})}),o}_findMatches({key:r,value:s,searcher:a}){if(!Nt(s))return[];let n=[];if(Gt(s))s.forEach(({v:o,i,n:l})=>{if(!Nt(o))return;const{isMatch:m,score:d,indices:u}=a.searchIn(o);m&&n.push({score:d,key:r,value:o,idx:i,norm:l,indices:u})});else{const{v:o,n:i}=s,{isMatch:l,score:m,indices:d}=a.searchIn(o);l&&n.push({score:m,key:r,value:o,norm:i,indices:d})}return n}}Tr.version="7.1.0";Tr.createIndex=ui;Tr.parseIndex=_u;Tr.config=Ae;Tr.parseQuery=hi;Xu(Qu);const np=150,fi=t=>`command_history_${t}`,Qs=t=>{const r=ht.getItem(fi(t));if(!r)return{};try{return JSON.parse(r)}catch(s){return console.error("Error parsing command history:",s),{}}},op=(t,r)=>{ht.setItem(fi(t),JSON.stringify(r))},Wn=t=>!!t&&typeof t.then=="function";function ip({selectedProject:t,input:r,setInput:s,textareaRef:a,onExecuteCommand:n}){const[o,i]=c.useState([]),[l,m]=c.useState([]),[d,u]=c.useState(!1),[g,p]=c.useState(""),[x,f]=c.useState(-1),[h,y]=c.useState(-1),N=c.useRef(null),S=c.useCallback(()=>{N.current!==null&&(window.clearTimeout(N.current),N.current=null)},[]),v=c.useCallback(()=>{u(!1),y(-1),p(""),f(-1),S()},[S]);c.useEffect(()=>{(async()=>{if(!t){i([]),m([]);return}try{const F=await Se("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:t.path})});if(!F.ok)throw new Error("Failed to fetch commands");const I=await F.json(),U=[...(I.builtIn||[]).map(q=>({...q,type:"built-in"})),...(I.custom||[]).map(q=>({...q,type:"custom"}))],w=Qs(t.name),z=[...U].sort((q,ee)=>{const M=w[q.name]||0;return(w[ee.name]||0)-M});i(z)}catch(F){console.error("Error fetching slash commands:",F),i([])}})()},[t]),c.useEffect(()=>{d||f(-1)},[d]);const b=c.useMemo(()=>o.length?new Tr(o,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[o]);c.useEffect(()=>{if(!g){m(o);return}if(!b){m([]);return}const $=b.search(g);m($.map(F=>F.item))},[g,o,b]);const D=c.useMemo(()=>{if(!t||o.length===0)return[];const $=Qs(t.name);return o.map(F=>({...F,usageCount:$[F.name]||0})).filter(F=>F.usageCount>0).sort((F,I)=>I.usageCount-F.usageCount).slice(0,5)},[t,o]),A=c.useCallback($=>{if(!t)return;const F=Qs(t.name);F[$.name]=(F[$.name]||0)+1,op(t.name,F)},[t]),j=c.useCallback($=>{const F=r.slice(0,h),I=r.slice(h),U=I.indexOf(" "),w=U!==-1?I.slice(U):"",z=`${F}${$.name} ${w}`;s(z),v();const q=n($);Wn(q)&&q.catch(()=>{})},[r,h,s,v,n]),C=c.useCallback(($,F,I)=>{if(!$||!t)return;if(I){f(F);return}A($);const U=n($);Wn(U)?(U.then(()=>{v()}),U.catch(()=>{})):v()},[t,A,n,v]),L=c.useCallback(()=>{var F;const $=!d;u($),p(""),f(-1),$&&m(o),(F=a.current)==null||F.focus()},[d,o,a]),R=c.useCallback(($,F)=>{if(!$.trim()){v();return}const I=$.slice(0,F);if((I.match(/```/g)||[]).length%2===1){v();return}const z=/(^|\s)\/(\S*)$/,q=I.match(z);if(!q){v();return}const ee=(q.index||0)+q[1].length,M=q[2];y(ee),u(!0),f(-1),S(),N.current=window.setTimeout(()=>{p(M)},np)},[v,S]),_=c.useCallback($=>d?l.length?$.key==="ArrowDown"?($.preventDefault(),f(F=>F<l.length-1?F+1:0),!0):$.key==="ArrowUp"?($.preventDefault(),f(F=>F>0?F-1:l.length-1),!0):$.key==="Tab"||$.key==="Enter"?($.preventDefault(),x>=0?j(l[x]):l.length>0&&j(l[0]),!0):$.key==="Escape"?($.preventDefault(),v(),!0):!1:$.key==="Escape"?($.preventDefault(),v(),!0):!1:!1,[d,l,v,j,x]);return c.useEffect(()=>()=>{S()},[S]),{slashCommands:o,slashCommandsCount:o.length,filteredCommands:l,frequentCommands:D,commandQuery:g,showCommandMenu:d,selectedCommandIndex:x,resetCommandMenuState:v,handleCommandSelect:C,handleToggleCommandMenu:L,handleCommandInputChange:R,handleCommandMenuKeyDown:_}}const lp=()=>({preventDefault:()=>{}}),cp=t=>!!(t&&t.startsWith("new-session-"));function dp({selectedProject:t,selectedSession:r,currentSessionId:s,provider:a,permissionMode:n,cyclePermissionMode:o,cursorModel:i,claudeModel:l,codexModel:m,isLoading:d,canAbortSession:u,tokenBudget:g,sendMessage:p,sendByCtrlEnter:x,onSessionActive:f,onInputFocusChange:h,onFileOpen:y,onShowSettings:N,pendingViewSessionRef:S,scrollToBottom:v,setChatMessages:b,setSessionMessages:D,setIsLoading:A,setCanAbortSession:j,setClaudeStatus:C,setIsUserScrolledUp:L,setPendingPermissionRequests:R}){const[_,$]=c.useState(()=>typeof window<"u"&&t&&ht.getItem(`draft_input_${t.name}`)||""),[F,I]=c.useState([]),[U,w]=c.useState(new Map),[z,q]=c.useState(new Map),[ee,M]=c.useState(!1),[K,T]=c.useState("none"),G=c.useRef(null),Y=c.useRef(null),J=c.useRef(null),W=c.useRef(_),O=c.useCallback(ie=>{const{action:ue,data:ce}=ie;switch(ue){case"clear":b([]),D==null||D([]);break;case"help":b(je=>[...je,{type:"assistant",content:ce.content,timestamp:Date.now()}]);break;case"model":b(je=>[...je,{type:"assistant",content:`**Current Model**: ${ce.current.model}
119
+
120
+ **Available Models**:
121
+
122
+ Claude: ${ce.available.claude.join(", ")}
123
+
124
+ Cursor: ${ce.available.cursor.join(", ")}`,timestamp:Date.now()}]);break;case"cost":{const je=`**Token Usage**: ${ce.tokenUsage.used.toLocaleString()} / ${ce.tokenUsage.total.toLocaleString()} (${ce.tokenUsage.percentage}%)
125
+
126
+ **Estimated Cost**:
127
+ - Input: $${ce.cost.input}
128
+ - Output: $${ce.cost.output}
129
+ - **Total**: $${ce.cost.total}
130
+
131
+ **Model**: ${ce.model}`;b(We=>[...We,{type:"assistant",content:je,timestamp:Date.now()}]);break}case"status":{const je=`**System Status**
132
+
133
+ - Version: ${ce.version}
134
+ - Uptime: ${ce.uptime}
135
+ - Model: ${ce.model}
136
+ - Provider: ${ce.provider}
137
+ - Node.js: ${ce.nodeVersion}
138
+ - Platform: ${ce.platform}`;b(We=>[...We,{type:"assistant",content:je,timestamp:Date.now()}]);break}case"memory":ce.error?b(je=>[...je,{type:"assistant",content:`⚠️ ${ce.message}`,timestamp:Date.now()}]):(b(je=>[...je,{type:"assistant",content:`📝 ${ce.message}
139
+
140
+ Path: \`${ce.path}\``,timestamp:Date.now()}]),ce.exists&&y&&y(ce.path));break;case"config":N==null||N();break;case"rewind":ce.error?b(je=>[...je,{type:"assistant",content:`⚠️ ${ce.message}`,timestamp:Date.now()}]):(b(je=>je.slice(0,-ce.steps*2)),b(je=>[...je,{type:"assistant",content:`⏪ ${ce.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",ue)}},[y,N,b,D]),se=c.useCallback(async ie=>{const{content:ue,hasBashCommands:ce}=ie;if(ce&&!window.confirm("This command contains bash commands that will be executed. Do you want to proceed?")){b(Ye=>[...Ye,{type:"assistant",content:"❌ Command execution cancelled",timestamp:Date.now()}]);return}const je=ue||"";$(je),W.current=je,setTimeout(()=>{J.current&&J.current(lp())},0)},[b]),B=c.useCallback(async ie=>{if(!(!ie||!t))try{const ue=_.match(new RegExp(`${Oo(ie.name)}\\s*(.*)`)),ce=ue&&ue[1]?ue[1].trim().split(/\s+/):[],je={projectPath:t.fullPath||t.path,projectName:t.name,sessionId:s,provider:a,model:a==="cursor"?i:a==="codex"?m:l,tokenUsage:g},We=await Se("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:ie.name,commandPath:ie.path,args:ce,context:je})});if(!We.ok){let Ze=`Failed to execute command (${We.status})`;try{const ct=await We.json();Ze=(ct==null?void 0:ct.message)||(ct==null?void 0:ct.error)||Ze}catch{}throw new Error(Ze)}const Ye=await We.json();Ye.type==="builtin"?(O(Ye),$(""),W.current=""):Ye.type==="custom"&&await se(Ye)}catch(ue){const ce=ue instanceof Error?ue.message:"Unknown error";console.error("Error executing command:",ue),b(je=>[...je,{type:"assistant",content:`Error executing command: ${ce}`,timestamp:Date.now()}])}},[l,m,s,i,O,se,_,a,t,b,g]),{slashCommandsCount:ge,filteredCommands:pe,frequentCommands:k,commandQuery:E,showCommandMenu:X,selectedCommandIndex:ae,resetCommandMenuState:oe,handleCommandSelect:Fe,handleToggleCommandMenu:he,handleCommandInputChange:xe,handleCommandMenuKeyDown:Te}=ip({selectedProject:t,input:_,setInput:$,textareaRef:G,onExecuteCommand:B}),{showFileDropdown:Le,filteredFiles:ze,selectedFileIndex:re,renderInputWithMentions:fe,selectFile:V,setCursorPosition:ne,handleFileMentionsKeyDown:we}=yu({selectedProject:t,input:_,setInput:$,textareaRef:G}),Ie=c.useCallback(ie=>{!Y.current||!ie||(Y.current.scrollTop=ie.scrollTop,Y.current.scrollLeft=ie.scrollLeft)},[]),De=c.useCallback(ie=>{const ue=ie.filter(ce=>{try{if(!ce||typeof ce!="object")return console.warn("Invalid file object:",ce),!1;if(!ce.type||!ce.type.startsWith("image/"))return!1;if(!ce.size||ce.size>5242880){const je=ce.name||"Unknown file";return q(We=>{const Ye=new Map(We);return Ye.set(je,"File too large (max 5MB)"),Ye}),!1}return!0}catch(je){return console.error("Error validating file:",je,ce),!1}});ue.length>0&&I(ce=>[...ce,...ue].slice(0,5))},[]),Ue=c.useCallback(ie=>{const ue=Array.from(ie.clipboardData.items);if(ue.forEach(ce=>{if(!ce.type.startsWith("image/"))return;const je=ce.getAsFile();je&&De([je])}),ue.length===0&&ie.clipboardData.files.length>0){const je=Array.from(ie.clipboardData.files).filter(We=>We.type.startsWith("image/"));je.length>0&&De(je)}},[De]),{getRootProps:Ke,getInputProps:Je,isDragActive:de,open:Me}=oi({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:De,noClick:!0,noKeyboard:!0}),Ne=c.useCallback(async ie=>{ie.preventDefault();const ue=W.current;if(!ue.trim()||d||!t)return;let ce=ue;const je=Jo.find(at=>at.id===K);je&&je.prefix&&(ce=`${je.prefix}: ${ue}`);let We=[];if(F.length>0){const at=new FormData;F.forEach(dt=>{at.append("images",dt)});try{const dt=await Se(`/api/projects/${t.name}/upload-images`,{method:"POST",headers:{},body:at});if(!dt.ok)throw new Error("Failed to upload images");We=(await dt.json()).images}catch(dt){const Dt=dt instanceof Error?dt.message:"Unknown error";console.error("Image upload failed:",dt),b(qt=>[...qt,{type:"error",content:`Failed to upload images: ${Dt}`,timestamp:new Date}]);return}}const Ye={type:"user",content:ue,images:We,timestamp:new Date};b(at=>[...at,Ye]),A(!0),j(!0),C({text:"Processing",tokens:0,can_interrupt:!0}),L(!1),setTimeout(()=>v(),100);const Ze=s||(r==null?void 0:r.id)||sessionStorage.getItem("cursorSessionId"),ct=Ze||`new-session-${Date.now()}`;!Ze&&!(r!=null&&r.id)&&(typeof window<"u"&&sessionStorage.removeItem("pendingSessionId"),S.current={sessionId:null,startedAt:Date.now()}),f==null||f(ct);const St=(()=>{try{const at=a==="cursor"?"cursor-tools-settings":a==="codex"?"codex-settings":"claude-settings",dt=ht.getItem(at);if(dt)return JSON.parse(dt)}catch(at){console.error("Error loading tools settings:",at)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})(),xt=t.fullPath||t.path||"";p(a==="cursor"?{type:"cursor-command",command:ce,sessionId:Ze,options:{cwd:xt,projectPath:xt,sessionId:Ze,resume:!!Ze,model:i,skipPermissions:(St==null?void 0:St.skipPermissions)||!1,toolsSettings:St}}:a==="codex"?{type:"codex-command",command:ce,sessionId:Ze,options:{cwd:xt,projectPath:xt,sessionId:Ze,resume:!!Ze,model:m,permissionMode:n==="plan"?"default":n}}:{type:"claude-command",command:ce,options:{projectPath:xt,cwd:xt,sessionId:Ze,resume:!!Ze,toolsSettings:St,permissionMode:n,model:l,images:We}}),$(""),W.current="",oe(),I([]),w(new Map),q(new Map),M(!1),T("none"),G.current&&(G.current.style.height="auto"),ht.removeItem(`draft_input_${t.name}`)},[F,l,m,s,i,d,f,S,n,a,oe,v,t,r==null?void 0:r.id,p,j,b,C,A,L,K]);c.useEffect(()=>{J.current=Ne},[Ne]),c.useEffect(()=>{W.current=_},[_]),c.useEffect(()=>{if(!t)return;const ie=ht.getItem(`draft_input_${t.name}`)||"";$(ue=>{const ce=ue===ie?ue:ie;return W.current=ce,ce})},[t==null?void 0:t.name]),c.useEffect(()=>{t&&(_!==""?ht.setItem(`draft_input_${t.name}`,_):ht.removeItem(`draft_input_${t.name}`))},[_,t]),c.useEffect(()=>{if(!G.current)return;G.current.style.height="auto",G.current.style.height=`${G.current.scrollHeight}px`;const ie=parseInt(window.getComputedStyle(G.current).lineHeight),ue=G.current.scrollHeight>ie*2;M(ue)},[_]),c.useEffect(()=>{!G.current||_.trim()||(G.current.style.height="auto",M(!1))},[_]);const _e=c.useCallback(ie=>{const ue=ie.target.value,ce=ie.target.selectionStart;if($(ue),W.current=ue,ne(ce),!ue.trim()){ie.target.style.height="auto",M(!1),oe();return}xe(ue,ce)},[xe,oe,ne]),Oe=c.useCallback(ie=>{if(!Te(ie)&&!we(ie)){if(ie.key==="Tab"&&!Le&&!X){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&&!x)&&(ie.preventDefault(),Ne(ie))}}},[o,Te,we,Ne,x,X,Le]),Pe=c.useCallback(ie=>{ne(ie.currentTarget.selectionStart)},[ne]),te=c.useCallback(ie=>{const ue=ie.currentTarget;ue.style.height="auto",ue.style.height=`${ue.scrollHeight}px`,ne(ue.selectionStart),Ie(ue);const ce=parseInt(window.getComputedStyle(ue).lineHeight);M(ue.scrollHeight>ce*2)},[ne,Ie]),be=c.useCallback(()=>{$(""),W.current="",oe(),G.current&&(G.current.style.height="auto",G.current.focus()),M(!1)},[oe]),$e=c.useCallback(()=>{var We;if(!u)return;const ie=typeof window<"u"?sessionStorage.getItem("pendingSessionId"):null,ue=typeof window<"u"?sessionStorage.getItem("cursorSessionId"):null,je=[s,((We=S.current)==null?void 0:We.sessionId)||null,ie,a==="cursor"?ue:null,(r==null?void 0:r.id)||null].find(Ye=>!!Ye&&!cp(Ye))||null;if(!je){console.warn("Abort requested but no concrete session ID is available yet.");return}p({type:"abort-session",sessionId:je,provider:a})},[u,s,S,a,r==null?void 0:r.id,p]),Be=c.useCallback(ie=>{ie.trim()&&$(ue=>{const ce=ue.trim()?`${ue} ${ie}`:ie;return W.current=ce,setTimeout(()=>{if(!G.current)return;G.current.style.height="auto",G.current.style.height=`${G.current.scrollHeight}px`;const je=parseInt(window.getComputedStyle(G.current).lineHeight);M(G.current.scrollHeight>je*2)},0),ce})},[]),st=c.useCallback(ie=>!ie||a!=="claude"?{success:!1}:Nd(ie.entry),[a]),Tt=c.useCallback((ie,ue)=>{const je=(Array.isArray(ie)?ie:[ie]).filter(Boolean);je.length!==0&&(je.forEach(We=>{p({type:"claude-permission-response",requestId:We,allow:!!(ue!=null&&ue.allow),updatedInput:ue==null?void 0:ue.updatedInput,message:ue==null?void 0:ue.message,rememberEntry:ue==null?void 0:ue.rememberEntry})}),R(We=>{const Ye=We.filter(Ze=>!je.includes(Ze.requestId));return Ye.length===0&&C(null),Ye}))},[p,C,R]),[pt,vt]=c.useState(!1),lt=c.useCallback(ie=>{vt(ie),h==null||h(ie)},[h]);return{input:_,setInput:$,textareaRef:G,inputHighlightRef:Y,isTextareaExpanded:ee,thinkingMode:K,setThinkingMode:T,slashCommandsCount:ge,filteredCommands:pe,frequentCommands:k,commandQuery:E,showCommandMenu:X,selectedCommandIndex:ae,resetCommandMenuState:oe,handleCommandSelect:Fe,handleToggleCommandMenu:he,showFileDropdown:Le,filteredFiles:ze,selectedFileIndex:re,renderInputWithMentions:fe,selectFile:V,attachedImages:F,setAttachedImages:I,uploadingImages:U,imageErrors:z,getRootProps:Ke,getInputProps:Je,isDragActive:de,openImagePicker:Me,handleSubmit:Ne,handleInputChange:_e,handleKeyDown:Oe,handlePaste:Ue,handleTextareaClick:Pe,handleTextareaInput:te,syncInputOverlayScroll:Ie,handleClearInput:be,handleAbortSession:$e,handleTranscript:Be,handlePermissionDecision:Tt,handleGrantToolPermission:st,handleInputFocusChange:lt,isInputFocused:pt}}function mp({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,latestMessage:n,onFileOpen:o,onInputFocusChange:i,onSessionActive:l,onSessionInactive:m,onSessionProcessing:d,onSessionNotProcessing:u,processingSessions:g,onReplaceTemporarySession:p,onNavigateToSession:x,onShowSettings:f,autoExpandTools:h,showRawParameters:y,showThinking:N,autoScrollToBottom:S,sendByCtrlEnter:v,externalMessageUpdate:b,onShowAllTasks:D}){const{tasksEnabled:A,isTaskMasterInstalled:j}=qr(),{t:C}=He("chat"),L=c.useRef(""),R=c.useRef(null),_=c.useRef(null),$=c.useCallback(()=>{R.current&&(clearTimeout(R.current),R.current=null),L.current=""},[]),{provider:F,setProvider:I,cursorModel:U,setCursorModel:w,claudeModel:z,setClaudeModel:q,codexModel:ee,setCodexModel:M,permissionMode:K,pendingPermissionRequests:T,setPendingPermissionRequests:G,cyclePermissionMode:Y}=dm({selectedSession:r}),{chatMessages:J,setChatMessages:W,isLoading:O,setIsLoading:se,currentSessionId:B,setCurrentSessionId:ge,sessionMessages:pe,setSessionMessages:k,isLoadingSessionMessages:E,isLoadingMoreMessages:X,hasMoreMessages:ae,totalMessages:oe,setIsSystemSessionChange:Fe,canAbortSession:he,setCanAbortSession:xe,isUserScrolledUp:Te,setIsUserScrolledUp:Le,tokenBudget:ze,setTokenBudget:re,visibleMessageCount:fe,visibleMessages:V,loadEarlierMessages:ne,loadAllMessages:we,allMessagesLoaded:Ie,isLoadingAllMessages:De,loadAllJustFinished:Ue,showLoadAllOverlay:Ke,claudeStatus:Je,setClaudeStatus:de,createDiff:Me,scrollContainerRef:Ne,scrollToBottom:_e,scrollToBottomAndReset:Oe,handleScroll:Pe}=fm({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:S,externalMessageUpdate:b,processingSessions:g,resetStreamingState:$,pendingViewSessionRef:_}),{input:te,setInput:be,textareaRef:$e,inputHighlightRef:Be,isTextareaExpanded:st,thinkingMode:Tt,setThinkingMode:pt,slashCommandsCount:vt,filteredCommands:lt,frequentCommands:ie,commandQuery:ue,showCommandMenu:ce,selectedCommandIndex:je,resetCommandMenuState:We,handleCommandSelect:Ye,handleToggleCommandMenu:Ze,showFileDropdown:ct,filteredFiles:Ot,selectedFileIndex:St,renderInputWithMentions:xt,selectFile:at,attachedImages:dt,setAttachedImages:Dt,uploadingImages:qt,imageErrors:xr,getRootProps:H,getInputProps:Z,isDragActive:Ee,openImagePicker:Xe,handleSubmit:kt,handleInputChange:gt,handleKeyDown:Ms,handlePaste:Vr,handleTextareaClick:Jr,handleTextareaInput:Yr,syncInputOverlayScroll:$s,handleClearInput:Fs,handleAbortSession:Ir,handleTranscript:Ps,handlePermissionDecision:Ls,handleGrantToolPermission:Kt,handleInputFocusChange:Qr,isInputFocused:_s}=dp({selectedProject:t,selectedSession:r,currentSessionId:B,provider:F,permissionMode:K,cyclePermissionMode:Y,cursorModel:U,claudeModel:z,codexModel:ee,isLoading:O,canAbortSession:he,tokenBudget:ze,sendMessage:a,sendByCtrlEnter:v,onSessionActive:l,onInputFocusChange:i,onFileOpen:o,onShowSettings:f,pendingViewSessionRef:_,scrollToBottom:_e,setChatMessages:W,setSessionMessages:k,setIsLoading:se,setCanAbortSession:xe,setClaudeStatus:de,setIsUserScrolledUp:Le,setPendingPermissionRequests:G});if(ym({latestMessage:n,provider:F,selectedProject:t,selectedSession:r,currentSessionId:B,setCurrentSessionId:ge,setChatMessages:W,setIsLoading:se,setCanAbortSession:xe,setClaudeStatus:de,setTokenBudget:re,setIsSystemSessionChange:Fe,setPendingPermissionRequests:G,pendingViewSessionRef:_,streamBufferRef:L,streamTimerRef:R,onSessionInactive:m,onSessionProcessing:d,onSessionNotProcessing:u,onReplaceTemporarySession:p,onNavigateToSession:x}),c.useEffect(()=>{if(!O||!he)return;const wt=Vt=>{Vt.key!=="Escape"||Vt.repeat||Vt.defaultPrevented||(Vt.preventDefault(),Ir())};return document.addEventListener("keydown",wt,{capture:!0}),()=>{document.removeEventListener("keydown",wt,{capture:!0})}},[he,Ir,O]),c.useEffect(()=>{const wt=(r==null?void 0:r.id)||B;wt&&O&&d&&d(wt)},[B,O,d,r==null?void 0:r.id]),c.useEffect(()=>()=>{$()},[$]),!t){const wt=C(F==="cursor"?"messageTypes.cursor":F==="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:C("projectSelection.startChatWithProvider",{provider:wt,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(Xd,{scrollContainerRef:Ne,onWheel:Pe,onTouchMove:Pe,isLoadingSessionMessages:E,chatMessages:J,selectedSession:r,currentSessionId:B,provider:F,setProvider:wt=>I(wt),textareaRef:$e,claudeModel:z,setClaudeModel:q,cursorModel:U,setCursorModel:w,codexModel:ee,setCodexModel:M,tasksEnabled:A,isTaskMasterInstalled:j,onShowAllTasks:D,setInput:be,isLoadingMoreMessages:X,hasMoreMessages:ae,totalMessages:oe,sessionMessagesCount:pe.length,visibleMessageCount:fe,visibleMessages:V,loadEarlierMessages:ne,loadAllMessages:we,allMessagesLoaded:Ie,isLoadingAllMessages:De,loadAllJustFinished:Ue,showLoadAllOverlay:Ke,createDiff:Me,onFileOpen:o,onShowSettings:f,onGrantToolPermission:Kt,autoExpandTools:h,showRawParameters:y,showThinking:N,selectedProject:t,isLoading:O}),e.jsx(cm,{pendingPermissionRequests:T,handlePermissionDecision:Ls,handleGrantToolPermission:Kt,claudeStatus:Je,isLoading:O,onAbortSession:Ir,provider:F,permissionMode:K,onModeSwitch:Y,thinkingMode:Tt,setThinkingMode:pt,tokenBudget:ze,slashCommandsCount:vt,onToggleCommandMenu:Ze,hasInput:!!te.trim(),onClearInput:Fs,isUserScrolledUp:Te,hasMessages:J.length>0,onScrollToBottom:Oe,onSubmit:kt,isDragActive:Ee,attachedImages:dt,onRemoveImage:wt=>Dt(Vt=>Vt.filter((za,nr)=>nr!==wt)),uploadingImages:qt,imageErrors:xr,showFileDropdown:ct,filteredFiles:Ot,selectedFileIndex:St,onSelectFile:at,filteredCommands:lt,selectedCommandIndex:je,onCommandSelect:Ye,onCloseCommandMenu:We,isCommandMenuOpen:ce,frequentCommands:ue?[]:ie,getRootProps:H,getInputProps:Z,openImagePicker:Xe,inputHighlightRef:Be,renderInputWithMentions:xt,textareaRef:$e,input:te,onInputChange:gt,onTextareaClick:Jr,onTextareaKeyDown:Ms,onTextareaPaste:Vr,onTextareaScrollSync:$s,onTextareaInput:Yr,onInputFocusChange:Qr,isInputFocused:_s,placeholder:C("input.placeholder",{provider:C(F==="cursor"?"messageTypes.cursor":F==="codex"?"messageTypes.codex":"messageTypes.claude")}),isTextareaExpanded:st,sendByCtrlEnter:v,onTranscript:Ps})]}),e.jsx(yd,{})]})}const up=Ft.memo(mp);function pp({file:t,onClose:r}){const s=`/api/projects/${t.projectName}/files/content?path=${encodeURIComponent(t.path)}`,[a,n]=c.useState(null),[o,i]=c.useState(null),[l,m]=c.useState(!0);return c.useEffect(()=>{let d;const u=new AbortController;return(async()=>{try{m(!0),i(null),n(null);const p=await Se(s,{signal:u.signal});if(!p.ok)throw new Error(`Request failed with status ${p.status}`);const x=await p.blob();d=URL.createObjectURL(x),n(d)}catch(p){if(p.name==="AbortError")return;console.error("Error loading image:",p),i("Unable to load image")}finally{m(!1)}})(),()=>{u.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:[l&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"Loading image…"})}),!l&&a&&e.jsx("img",{src:a,alt:t.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!l&&!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 xp="w-4 h-4 flex-shrink-0",Un={js:{icon:Mr,color:"text-yellow-500"},jsx:{icon:Mr,color:"text-yellow-500"},mjs:{icon:Mr,color:"text-yellow-500"},cjs:{icon:Mr,color:"text-yellow-500"},ts:{icon:$r,color:"text-blue-500"},tsx:{icon:$r,color:"text-blue-500"},mts:{icon:$r,color:"text-blue-500"},py:{icon:us,color:"text-emerald-500"},pyw:{icon:us,color:"text-emerald-500"},pyi:{icon:us,color:"text-emerald-400"},ipynb:{icon:Bi,color:"text-orange-500"},rs:{icon:zr,color:"text-orange-600"},toml:{icon:Ve,color:"text-gray-500"},go:{icon:_r,color:"text-cyan-500"},rb:{icon:aa,color:"text-red-500"},erb:{icon:aa,color:"text-red-400"},php:{icon:Ri,color:"text-violet-500"},java:{icon:Ja,color:"text-red-600"},jar:{icon:Ja,color:"text-red-500"},kt:{icon:_r,color:"text-violet-500"},kts:{icon:_r,color:"text-violet-400"},c:{icon:Fr,color:"text-blue-600"},h:{icon:Fr,color:"text-blue-400"},cpp:{icon:Fr,color:"text-blue-700"},hpp:{icon:Fr,color:"text-blue-500"},cc:{icon:Fr,color:"text-blue-700"},cs:{icon:_r,color:"text-purple-600"},swift:{icon:sa,color:"text-orange-500"},lua:{icon:Oi,color:"text-blue-500"},r:{icon:zi,color:"text-blue-600"},html:{icon:Hr,color:"text-orange-600"},htm:{icon:Hr,color:"text-orange-600"},css:{icon:kr,color:"text-blue-500"},scss:{icon:kr,color:"text-pink-500"},sass:{icon:kr,color:"text-pink-400"},less:{icon:kr,color:"text-indigo-500"},vue:{icon:$r,color:"text-emerald-500"},svelte:{icon:$r,color:"text-orange-500"},json:{icon:jr,color:"text-yellow-600"},jsonc:{icon:jr,color:"text-yellow-500"},json5:{icon:jr,color:"text-yellow-500"},yaml:{icon:Ve,color:"text-purple-400"},yml:{icon:Ve,color:"text-purple-400"},xml:{icon:Mr,color:"text-orange-500"},csv:{icon:Va,color:"text-green-600"},tsv:{icon:Va,color:"text-green-500"},sql:{icon:_i,color:"text-blue-500"},graphql:{icon:Ka,color:"text-pink-500"},gql:{icon:Ka,color:"text-pink-500"},proto:{icon:Or,color:"text-green-500"},env:{icon:Pt,color:"text-yellow-600"},md:{icon:ra,color:"text-blue-500"},mdx:{icon:ra,color:"text-blue-400"},txt:{icon:ot,color:"text-gray-500"},doc:{icon:ot,color:"text-blue-600"},docx:{icon:ot,color:"text-blue-600"},pdf:{icon:ta,color:"text-red-600"},rtf:{icon:ot,color:"text-gray-500"},tex:{icon:ea,color:"text-teal-600"},rst:{icon:ot,color:"text-gray-400"},sh:{icon:mt,color:"text-green-500"},bash:{icon:mt,color:"text-green-500"},zsh:{icon:mt,color:"text-green-400"},fish:{icon:mt,color:"text-green-400"},ps1:{icon:mt,color:"text-blue-400"},bat:{icon:mt,color:"text-gray-500"},cmd:{icon:mt,color:"text-gray-500"},png:{icon:Jt,color:"text-purple-500"},jpg:{icon:Jt,color:"text-purple-500"},jpeg:{icon:Jt,color:"text-purple-500"},gif:{icon:Jt,color:"text-purple-400"},webp:{icon:Jt,color:"text-purple-400"},ico:{icon:Jt,color:"text-purple-400"},bmp:{icon:Jt,color:"text-purple-400"},tiff:{icon:Jt,color:"text-purple-400"},svg:{icon:Li,color:"text-amber-500"},mp3:{icon:br,color:"text-pink-500"},wav:{icon:br,color:"text-pink-500"},ogg:{icon:br,color:"text-pink-400"},flac:{icon:br,color:"text-pink-400"},aac:{icon:br,color:"text-pink-400"},m4a:{icon:br,color:"text-pink-400"},mp4:{icon:Dr,color:"text-rose-500"},mov:{icon:Dr,color:"text-rose-500"},avi:{icon:Dr,color:"text-rose-500"},webm:{icon:Dr,color:"text-rose-400"},mkv:{icon:Dr,color:"text-rose-400"},ttf:{icon:Ar,color:"text-red-500"},otf:{icon:Ar,color:"text-red-500"},woff:{icon:Ar,color:"text-red-400"},woff2:{icon:Ar,color:"text-red-400"},eot:{icon:Ar,color:"text-red-400"},zip:{icon:fr,color:"text-amber-600"},tar:{icon:fr,color:"text-amber-600"},gz:{icon:fr,color:"text-amber-600"},bz2:{icon:fr,color:"text-amber-600"},rar:{icon:fr,color:"text-amber-500"},"7z":{icon:fr,color:"text-amber-500"},lock:{icon:Zt,color:"text-gray-500"},exe:{icon:hr,color:"text-gray-500"},bin:{icon:hr,color:"text-gray-500"},dll:{icon:hr,color:"text-gray-400"},so:{icon:hr,color:"text-gray-400"},dylib:{icon:hr,color:"text-gray-400"},wasm:{icon:hr,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:ea,color:"text-gray-400"},map:{icon:co,color:"text-gray-400"}},Hn={Dockerfile:{icon:Or,color:"text-blue-500"},"docker-compose.yml":{icon:Or,color:"text-blue-500"},"docker-compose.yaml":{icon:Or,color:"text-blue-500"},".dockerignore":{icon:Or,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:Pt,color:"text-yellow-600"},".env.local":{icon:Pt,color:"text-yellow-600"},".env.development":{icon:Pt,color:"text-yellow-500"},".env.production":{icon:Pt,color:"text-yellow-600"},".env.example":{icon:Pt,color:"text-yellow-400"},"package.json":{icon:jr,color:"text-green-500"},"package-lock.json":{icon:Zt,color:"text-gray-500"},"yarn.lock":{icon:Zt,color:"text-blue-400"},"pnpm-lock.yaml":{icon:Zt,color:"text-orange-400"},"bun.lockb":{icon:Zt,color:"text-gray-400"},"Cargo.toml":{icon:zr,color:"text-orange-600"},"Cargo.lock":{icon:Zt,color:"text-orange-400"},Gemfile:{icon:aa,color:"text-red-500"},"Gemfile.lock":{icon:Zt,color:"text-red-400"},Makefile:{icon:mt,color:"text-gray-500"},"CMakeLists.txt":{icon:zr,color:"text-blue-500"},"tsconfig.json":{icon:jr,color:"text-blue-500"},"jsconfig.json":{icon:jr,color:"text-yellow-500"},"vite.config.ts":{icon:sa,color:"text-purple-500"},"vite.config.js":{icon:sa,color:"text-purple-500"},"webpack.config.js":{icon:zr,color:"text-blue-500"},"tailwind.config.js":{icon:kr,color:"text-cyan-500"},"tailwind.config.ts":{icon:kr,color:"text-cyan-500"},"postcss.config.js":{icon:zr,color:"text-red-400"},"babel.config.js":{icon:Ve,color:"text-yellow-500"},".babelrc":{icon:Ve,color:"text-yellow-500"},"README.md":{icon:ra,color:"text-blue-500"},LICENSE:{icon:ta,color:"text-gray-500"},"LICENSE.md":{icon:ta,color:"text-gray-500"},"CHANGELOG.md":{icon:ea,color:"text-blue-400"},"requirements.txt":{icon:ot,color:"text-emerald-400"},"go.mod":{icon:_r,color:"text-cyan-500"},"go.sum":{icon:Zt,color:"text-cyan-400"}};function gp(t){var s;if(Hn[t])return Hn[t];if(t.startsWith(".env"))return{icon:Pt,color:"text-yellow-600"};const r=(s=t.split(".").pop())==null?void 0:s.toLowerCase();return r&&Un[r]?Un[r]:{icon:co,color:"text-muted-foreground"}}function hp({selectedProject:t,onFileOpen:r}){const{t:s}=He(),[a,n]=c.useState([]),[o,i]=c.useState(!1),[l,m]=c.useState(new Set),[d,u]=c.useState(null),[g,p]=c.useState("detailed"),[x,f]=c.useState(""),[h,y]=c.useState([]);c.useEffect(()=>{t&&S()},[t]),c.useEffect(()=>{const I=localStorage.getItem("file-tree-view-mode");I&&["simple","detailed","compact"].includes(I)&&p(I)},[]),c.useEffect(()=>{if(!x.trim())y(a);else{const I=N(a,x.toLowerCase());y(I);const U=w=>{w.forEach(z=>{z.type==="directory"&&z.children&&z.children.length>0&&(m(q=>new Set(q.add(z.path))),U(z.children))})};U(I)}},[a,x]);const N=(I,U)=>I.reduce((w,z)=>{const q=z.name.toLowerCase().includes(U);let ee=[];return z.type==="directory"&&z.children&&(ee=N(z.children,U)),(q||ee.length>0)&&w.push({...z,children:ee}),w},[]),S=async()=>{i(!0);try{const I=await Ge.getFiles(t.name);if(!I.ok){const w=await I.text();console.error("❌ File fetch failed:",I.status,w),n([]);return}const U=await I.json();n(U)}catch(I){console.error("❌ Error fetching files:",I),n([])}finally{i(!1)}},v=I=>{const U=new Set(l);U.has(I)?U.delete(I):U.add(I),m(U)},b=I=>{p(I),localStorage.setItem("file-tree-view-mode",I)},D=I=>{if(!I||I===0)return"0 B";const U=1024,w=["B","KB","MB","GB"],z=Math.floor(Math.log(I)/Math.log(U));return parseFloat((I/Math.pow(U,z)).toFixed(1))+" "+w[z]},A=I=>{if(!I)return"-";const U=new Date,w=new Date(I),z=Math.floor((U-w)/1e3);return z<60?s("fileTree.justNow"):z<3600?s("fileTree.minAgo",{count:Math.floor(z/60)}):z<86400?s("fileTree.hoursAgo",{count:Math.floor(z/3600)}):z<2592e3?s("fileTree.daysAgo",{count:Math.floor(z/86400)}):w.toLocaleDateString()},j=I=>{var z;const U=(z=I.split(".").pop())==null?void 0:z.toLowerCase();return["png","jpg","jpeg","gif","svg","webp","ico","bmp"].includes(U)},C=I=>{const{icon:U,color:w}=gp(I);return e.jsx(U,{className:ke(xp,w)})},L=I=>{I.type==="directory"?v(I.path):j(I.name)?u({name:I.name,path:I.path,projectPath:t.path,projectName:t.name}):r&&r(I.path)},R=I=>{const U=I.type==="directory",w=l.has(I.path);return U?e.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(zt,{className:ke("w-3.5 h-3.5 text-muted-foreground/70 transition-transform duration-150",w&&"rotate-90")}),w?e.jsx(tr,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(rr,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"})]}):e.jsx("span",{className:"flex items-center flex-shrink-0 ml-[18px]",children:C(I.name)})},_=(I,U=0)=>I.map(w=>{const z=w.type==="directory",q=z&&l.has(w.path);return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{className:ke("group flex items-center gap-1.5 py-[3px] pr-2 cursor-pointer rounded-sm","hover:bg-accent/60 transition-colors duration-100",z&&q&&"border-l-2 border-primary/30",z&&!q&&"border-l-2 border-transparent",!z&&"border-l-2 border-transparent"),style:{paddingLeft:`${U*16+4}px`},onClick:()=>L(w),children:[R(w),e.jsx("span",{className:ke("text-[13px] leading-tight truncate",z?"font-medium text-foreground":"text-foreground/90"),children:w.name})]}),z&&q&&w.children&&w.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"}),_(w.children,U+1)]})]},w.path)}),$=(I,U=0)=>I.map(w=>{const z=w.type==="directory",q=z&&l.has(w.path);return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{className:ke("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",z&&q&&"border-l-2 border-primary/30",z&&!q&&"border-l-2 border-transparent",!z&&"border-l-2 border-transparent"),style:{paddingLeft:`${U*16+4}px`},onClick:()=>L(w),children:[e.jsxs("div",{className:"col-span-5 flex items-center gap-1.5 min-w-0",children:[R(w),e.jsx("span",{className:ke("text-[13px] leading-tight truncate",z?"font-medium text-foreground":"text-foreground/90"),children:w.name})]}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground tabular-nums",children:w.type==="file"?D(w.size):""}),e.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:A(w.modified)}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground font-mono",children:w.permissionsRwx||""})]}),z&&q&&w.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"}),$(w.children,U+1)]})]},w.path)}),F=(I,U=0)=>I.map(w=>{const z=w.type==="directory",q=z&&l.has(w.path);return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{className:ke("group flex items-center justify-between py-[3px] pr-2 hover:bg-accent/60 cursor-pointer rounded-sm transition-colors duration-100",z&&q&&"border-l-2 border-primary/30",z&&!q&&"border-l-2 border-transparent",!z&&"border-l-2 border-transparent"),style:{paddingLeft:`${U*16+4}px`},onClick:()=>L(w),children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[R(w),e.jsx("span",{className:ke("text-[13px] leading-tight truncate",z?"font-medium text-foreground":"text-foreground/90"),children:w.name})]}),e.jsx("div",{className:"flex items-center gap-3 text-sm text-muted-foreground flex-shrink-0 ml-2",children:w.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tabular-nums",children:D(w.size)}),e.jsx("span",{className:"font-mono",children:w.permissionsRwx})]})})]}),z&&q&&w.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"}),F(w.children,U+1)]})]},w.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:g==="simple"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>b("simple"),title:s("fileTree.simpleView"),children:e.jsx(xs,{className:"w-3.5 h-3.5"})}),e.jsx(me,{variant:g==="compact"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>b("compact"),title:s("fileTree.compactView"),children:e.jsx(mr,{className:"w-3.5 h-3.5"})}),e.jsx(me,{variant:g==="detailed"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>b("detailed"),title:s("fileTree.detailedView"),children:e.jsx(Pi,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(dr,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),e.jsx(rt,{type:"text",placeholder:s("fileTree.searchPlaceholder"),value:x,onChange:I=>f(I.target.value),className:"pl-8 pr-8 h-8 text-sm"}),x&&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"})})]})]}),g==="detailed"&&h.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($a,{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(rr,{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")})]}):h.length===0&&x?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(dr,{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:[g==="simple"&&_(h),g==="compact"&&F(h),g==="detailed"&&$(h)]})}),d&&e.jsx(pp,{file:d,onClose:()=>u(null)})]})}function Gn({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 l=o.startsWith("+")&&!o.startsWith("+++"),m=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"} ${l?"bg-green-50 dark:bg-green-950/50 text-green-700 dark:text-green-300":m?"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 fp({selectedProject:t,isMobile:r,onFileOpen:s}){var We,Ye,Ze,ct,Ot,St,xt,at,dt,Dt,qt,xr;const[a,n]=c.useState(null),[o,i]=c.useState({}),[l,m]=c.useState(!1),[d,u]=c.useState(""),[g,p]=c.useState(new Set),[x,f]=c.useState(new Set),[h,y]=c.useState(!1),[N,S]=c.useState(""),[v,b]=c.useState([]),[D,A]=c.useState(!0),[j,C]=c.useState(!1),[L,R]=c.useState(!1),[_,$]=c.useState(!1),[F,I]=c.useState(""),[U,w]=c.useState(!1),[z,q]=c.useState("changes"),[ee,M]=c.useState([]),[K,T]=c.useState(new Set),[G,Y]=c.useState({}),[J,W]=c.useState(!1),[O,se]=c.useState(null),[B,ge]=c.useState(!1),[pe,k]=c.useState(!1),[E,X]=c.useState(!1),[ae,oe]=c.useState(!1),[Fe,he]=c.useState(r),[xe,Te]=c.useState(null),[Le,ze]=c.useState(!1),re=c.useRef(null),fe=c.useRef(null),[V,ne]=c.useState(()=>localStorage.getItem("selected-provider")||"claude");c.useEffect(()=>{const H=()=>{const Z=localStorage.getItem("selected-provider")||"claude";ne(Z)};return window.addEventListener("storage",H),()=>window.removeEventListener("storage",H)},[]),c.useEffect(()=>{S(""),b([]),n(null),se(null),f(new Set),t&&(we(),Ie(),De())},[t]),c.useEffect(()=>{!t||z!=="history"||$e()},[t,z]),c.useEffect(()=>{const H=Z=>{fe.current&&!fe.current.contains(Z.target)&&R(!1)};return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[]);const we=async()=>{if(t){m(!0);try{const Z=await(await Se(`/api/git/status?project=${encodeURIComponent(t.name)}`)).json();if(Z.error)console.error("Git status error:",Z.error),n({error:Z.error,details:Z.details}),S(""),f(new Set);else{n(Z),S(Z.branch||"main");const Ee=new Set([...Z.modified||[],...Z.added||[],...Z.deleted||[],...Z.untracked||[]]);f(Ee);for(const Xe of Z.modified||[])te(Xe);for(const Xe of Z.added||[])te(Xe);for(const Xe of Z.deleted||[])te(Xe);for(const Xe of Z.untracked||[])te(Xe)}}catch(H){console.error("Error fetching git status:",H),n({error:"Git operation failed",details:String(H)}),S(""),f(new Set)}finally{m(!1)}}},Ie=async()=>{try{const Z=await(await Se(`/api/git/branches?project=${encodeURIComponent(t.name)}`)).json();!Z.error&&Z.branches?b(Z.branches):b([])}catch(H){console.error("Error fetching branches:",H),b([])}},De=async()=>{if(t)try{const Z=await(await Se(`/api/git/remote-status?project=${encodeURIComponent(t.name)}`)).json();Z.error?se(null):se(Z)}catch(H){console.error("Error fetching remote status:",H),se(null)}},Ue=async H=>{try{const Ee=await(await Se("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,branch:H})})).json();Ee.success?(S(H),R(!1),we()):console.error("Failed to switch branch:",Ee.error)}catch(Z){console.error("Error switching branch:",Z)}},Ke=async()=>{if(F.trim()){w(!0);try{const Z=await(await Se("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,branch:F.trim()})})).json();Z.success?(S(F.trim()),$(!1),R(!1),I(""),Ie(),we()):console.error("Failed to create branch:",Z.error)}catch(H){console.error("Error creating branch:",H)}finally{w(!1)}}},Je=async()=>{ge(!0);try{const Z=await(await Se("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();Z.success?(we(),De()):console.error("Fetch failed:",Z.error)}catch(H){console.error("Error fetching from remote:",H)}finally{ge(!1)}},de=async()=>{k(!0);try{const Z=await(await Se("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();Z.success?(we(),De()):console.error("Pull failed:",Z.error)}catch(H){console.error("Error pulling from remote:",H)}finally{k(!1)}},Me=async()=>{X(!0);try{const Z=await(await Se("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();Z.success?(we(),De()):console.error("Push failed:",Z.error)}catch(H){console.error("Error pushing to remote:",H)}finally{X(!1)}},Ne=async()=>{oe(!0);try{const Z=await(await Se("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,branch:N})})).json();Z.success?(we(),De()):console.error("Publish failed:",Z.error)}catch(H){console.error("Error publishing branch:",H)}finally{oe(!1)}},_e=async H=>{try{const Ee=await(await Se("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,file:H})})).json();Ee.success?(f(Xe=>{const kt=new Set(Xe);return kt.delete(H),kt}),we()):console.error("Discard failed:",Ee.error)}catch(Z){console.error("Error discarding changes:",Z)}},Oe=async H=>{try{const Ee=await(await Se("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,file:H})})).json();Ee.success?(f(Xe=>{const kt=new Set(Xe);return kt.delete(H),kt}),we()):console.error("Delete failed:",Ee.error)}catch(Z){console.error("Error deleting untracked file:",Z)}},Pe=async()=>{if(!xe)return;const{type:H,file:Z,message:Ee}=xe;Te(null);try{switch(H){case"discard":await _e(Z);break;case"delete":await Oe(Z);break;case"commit":await lt();break;case"pull":await de();break;case"push":await Me();break;case"publish":await Ne();break}}catch(Xe){console.error(`Error executing ${H}:`,Xe)}},te=async H=>{try{const Ee=await(await Se(`/api/git/diff?project=${encodeURIComponent(t.name)}&file=${encodeURIComponent(H)}`)).json();!Ee.error&&Ee.diff&&i(Xe=>({...Xe,[H]:Ee.diff}))}catch(Z){console.error("Error fetching file diff:",Z)}},be=async H=>{if(s)try{const Ee=await(await Se(`/api/git/file-with-diff?project=${encodeURIComponent(t.name)}&file=${encodeURIComponent(H)}`)).json();if(Ee.error){console.error("Error fetching file with diff:",Ee.error),s(H);return}const Xe={old_string:Ee.oldContent||"",new_string:Ee.currentContent||""};s(H,Xe)}catch(Z){console.error("Error opening file:",Z),s(H)}},$e=async()=>{try{const Z=await(await Se(`/api/git/commits?project=${encodeURIComponent(t.name)}&limit=10`)).json();!Z.error&&Z.commits&&M(Z.commits)}catch(H){console.error("Error fetching commits:",H)}},Be=async H=>{try{const Ee=await(await Se(`/api/git/commit-diff?project=${encodeURIComponent(t.name)}&commit=${H}`)).json();!Ee.error&&Ee.diff&&Y(Xe=>({...Xe,[H]:Ee.diff}))}catch(Z){console.error("Error fetching commit diff:",Z)}},st=async()=>{W(!0);try{const Z=await(await Se("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,files:Array.from(x),provider:V})})).json();Z.message?u(Z.message):console.error("Failed to generate commit message:",Z.error)}catch(H){console.error("Error generating commit message:",H)}finally{W(!1)}},Tt=H=>{p(Z=>{const Ee=new Set(Z);return Ee.has(H)?Ee.delete(H):Ee.add(H),Ee})},pt=H=>{T(Z=>{const Ee=new Set(Z);return Ee.has(H)?Ee.delete(H):(Ee.add(H),G[H]||Be(H)),Ee})},vt=H=>{f(Z=>{const Ee=new Set(Z);return Ee.has(H)?Ee.delete(H):Ee.add(H),Ee})},lt=async()=>{if(!(!d.trim()||x.size===0)){y(!0);try{const Z=await(await Se("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,message:d,files:Array.from(x)})})).json();Z.success?(u(""),f(new Set),we(),De()):console.error("Commit failed:",Z.error)}catch(H){console.error("Error committing changes:",H)}finally{y(!1)}}},ie=async()=>{ze(!0);try{const Z=await(await Se("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();Z.success?(we(),De()):(console.error("Initial commit failed:",Z.error),alert(Z.error||"Failed to create initial commit"))}catch(H){console.error("Error creating initial commit:",H),alert("Failed to create initial commit")}finally{ze(!1)}},ue=H=>{switch(H){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return H}},ce=H=>{const Z=K.has(H.hash),Ee=G[H.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:()=>pt(H.hash),children:[e.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-accent rounded",children:Z?e.jsx(Ct,{className:"w-3 h-3"}):e.jsx(zt,{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:H.message}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[H.author," • ",H.date]})]}),e.jsx("span",{className:"text-sm font-mono text-muted-foreground/60 flex-shrink-0",children:H.hash.substring(0,7)})]})})]}),Z&&Ee&&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:H.stats}),e.jsx(Gn,{diff:Ee,fileName:"commit",isMobile:r,wrapText:D})]})})]},H.hash)},je=(H,Z)=>{const Ee=g.has(H),Xe=x.has(H),kt=o[H];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:Xe,onChange:()=>vt(H),onClick:gt=>gt.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:gt=>{gt.stopPropagation(),Tt(H)},children:e.jsx(zt,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${Ee?"rotate-90":"rotate-0"}`})}),e.jsx("span",{className:`flex-1 truncate ${r?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:gt=>{gt.stopPropagation(),be(H)},title:"Click to open file",children:H}),e.jsxs("div",{className:"flex items-center gap-1",children:[(Z==="M"||Z==="D")&&e.jsxs("button",{onClick:gt=>{gt.stopPropagation(),Te({type:"discard",file:H,message:`Discard all changes to "${H}"? 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(ft,{className:"w-3 h-3"}),r&&e.jsx("span",{children:"Discard"})]}),Z==="U"&&e.jsxs("button",{onClick:gt=>{gt.stopPropagation(),Te({type:"delete",file:H,message:`Delete untracked file "${H}"? 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(ft,{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 ${Z==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800/50":Z==="A"?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300 border-green-200 dark:border-green-800/50":Z==="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:ue(Z),children:Z})]})]})]}),e.jsxs("div",{className:`bg-muted/50 transition-all duration-400 ease-in-out overflow-hidden ${Ee&&kt?"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 ${Z==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800/50":Z==="A"?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300 border-green-200 dark:border-green-800/50":Z==="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:Z}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:ue(Z)})]}),r&&e.jsx("button",{onClick:gt=>{gt.stopPropagation(),A(!D)},className:"text-sm text-muted-foreground hover:text-foreground transition-colors",title:D?"Switch to horizontal scroll":"Switch to text wrap",children:D?"↔️ Scroll":"↩️ Wrap"})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:kt&&e.jsx(Gn,{diff:kt,fileName:H,isMobile:r,wrapText:D})})]})]},H)};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:fe,children:[e.jsxs("button",{onClick:()=>R(!L),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(Ut,{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:N}),(O==null?void 0: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(Ct,{className:`w-3 h-3 text-muted-foreground transition-transform ${L?"rotate-180":""}`})]}),L&&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:v.map(H=>e.jsx("button",{onClick:()=>Ue(H),className:`w-full text-left px-4 py-2 text-sm hover:bg-accent transition-colors ${H===N?"bg-accent/50 text-foreground":"text-muted-foreground"}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[H===N&&e.jsx(Et,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:H===N?"font-medium":"",children:H})]})},H))}),e.jsx("div",{className:"border-t border-border py-1",children:e.jsxs("button",{onClick:()=>{$(!0),R(!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(it,{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==null?void 0:O.hasRemote)&&e.jsxs(e.Fragment,{children:[!(O!=null&&O.hasUpstream)&&e.jsxs("button",{onClick:()=>Te({type:"publish",message:`Publish branch "${N}" to ${O.remoteName}?`}),disabled:ae,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 "${N}" to ${O.remoteName}`,children:[e.jsx(es,{className:`w-3 h-3 ${ae?"animate-pulse":""}`}),e.jsx("span",{children:ae?"Publishing...":"Publish"})]}),(O==null?void 0:O.hasUpstream)&&!(O!=null&&O.isUpToDate)&&e.jsxs(e.Fragment,{children:[O.behind>0&&e.jsxs("button",{onClick:()=>Te({type:"pull",message:`Pull ${O.behind} commit${O.behind!==1?"s":""} from ${O.remoteName}?`}),disabled:pe,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(gs,{className:`w-3 h-3 ${pe?"animate-pulse":""}`}),e.jsx("span",{children:pe?"Pulling...":`Pull ${O.behind}`})]}),O.ahead>0&&e.jsxs("button",{onClick:()=>Te({type:"push",message:`Push ${O.ahead} commit${O.ahead!==1?"s":""} to ${O.remoteName}?`}),disabled:E,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(es,{className:`w-3 h-3 ${E?"animate-pulse":""}`}),e.jsx("span",{children:E?"Pushing...":`Push ${O.ahead}`})]}),(O.ahead>0||O.behind>0&&O.ahead>0)&&e.jsxs("button",{onClick:Je,disabled:B,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(Bt,{className:`w-3 h-3 ${B?"animate-spin":""}`}),e.jsx("span",{children:B?"Fetching...":"Fetch"})]})]})]}),e.jsx("button",{onClick:()=>{we(),Ie(),De()},disabled:l,className:`hover:bg-accent rounded-lg transition-colors ${r?"p-1":"p-1.5"}`,children:e.jsx(Bt,{className:`text-muted-foreground ${l?"animate-spin":""} ${r?"w-3 h-3":"w-4 h-4"}`})})]})]}),a!=null&&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(Ut,{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 ${g.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:()=>q("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${z==="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(ot,{className:"w-4 h-4"}),e.jsx("span",{children:"Changes"})]})}),e.jsx("button",{onClick:()=>q("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${z==="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(Ya,{className:"w-4 h-4"}),e.jsx("span",{children:"History"})]})})]}),z==="changes"&&e.jsx(e.Fragment,{children:e.jsx("div",{className:`transition-all duration-300 ease-in-out ${g.size===0?"max-h-96 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:r&&Fe?e.jsx("div",{className:"px-4 py-2 border-b border-border/60",children:e.jsxs("button",{onClick:()=>he(!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(zs,{className:"w-4 h-4"}),e.jsxs("span",{children:["Commit ",x.size," file",x.size!==1?"s":""]}),e.jsx(Ct,{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:()=>he(!0),className:"p-1 hover:bg-accent rounded-lg transition-colors",children:e.jsx(Ct,{className:"w-4 h-4 rotate-180"})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:re,value:d,onChange:H=>u(H.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:H=>{H.key==="Enter"&&(H.ctrlKey||H.metaKey)&&lt()}}),e.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[e.jsx("button",{onClick:st,disabled:x.size===0||J,className:"p-1.5 text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Generate commit message",children:J?e.jsx(Bt,{className:"w-4 h-4 animate-spin"}):e.jsx(Wt,{className:"w-4 h-4"})}),e.jsx("div",{style:{display:"none"},children:e.jsx(Ko,{onTranscript:H=>u(H),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:[x.size," file",x.size!==1?"s":""," selected"]}),e.jsxs("button",{onClick:()=>Te({type:"commit",message:`Commit ${x.size} file${x.size!==1?"s":""} with message: "${d.trim()}"?`}),disabled:!d.trim()||x.size===0||h,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(Et,{className:"w-3 h-3"}),e.jsx("span",{children:h?"Committing...":"Commit"})]})]})]})})})}),z==="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"} ${g.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:[x.size," of ",(((We=a==null?void 0:a.modified)==null?void 0:We.length)||0)+(((Ye=a==null?void 0:a.added)==null?void 0:Ye.length)||0)+(((Ze=a==null?void 0:a.deleted)==null?void 0:Ze.length)||0)+(((ct=a==null?void 0:a.untracked)==null?void 0:ct.length)||0)," ",r?"":"files"," selected"]}),e.jsxs("div",{className:`flex ${r?"gap-1":"gap-2"}`,children:[e.jsx("button",{onClick:()=>{const H=new Set([...(a==null?void 0:a.modified)||[],...(a==null?void 0:a.added)||[],...(a==null?void 0:a.deleted)||[],...(a==null?void 0:a.untracked)||[]]);f(H)},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!=null&&a.error)&&!r&&e.jsxs("div",{className:"border-b border-border/60",children:[e.jsxs("button",{onClick:()=>C(!j),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(Wi,{className:"w-3 h-3"}),e.jsx("span",{children:"File Status Guide"}),j?e.jsx(Ct,{className:"w-3 h-3"}):e.jsx(zt,{className:"w-3 h-3"})]}),j&&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"})]})]})})]})]}),z==="changes"&&!(a!=null&&a.error)&&e.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:l?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(Bt,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):(a==null?void 0: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(Ut,{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:Le,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:Le?e.jsxs(e.Fragment,{children:[e.jsx(Bt,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:"Creating Initial Commit..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(zs,{className:"w-4 h-4"}),e.jsx("span",{children:"Create Initial Commit"})]})})]}):!a||!((Ot=a.modified)!=null&&Ot.length)&&!((St=a.added)!=null&&St.length)&&!((xt=a.deleted)!=null&&xt.length)&&!((at=a.untracked)!=null&&at.length)?e.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-muted-foreground",children:[e.jsx(zs,{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:[(dt=a.modified)==null?void 0:dt.map(H=>je(H,"M")),(Dt=a.added)==null?void 0:Dt.map(H=>je(H,"A")),(qt=a.deleted)==null?void 0:qt.map(H=>je(H,"D")),(xr=a.untracked)==null?void 0:xr.map(H=>je(H,"U"))]})}),z==="history"&&!(a!=null&&a.error)&&e.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:l?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(Bt,{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(Ya,{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(H=>ce(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:F,onChange:H=>I(H.target.value),onKeyDown:H=>{H.key==="Enter"&&!U&&Ke()},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 (",N,")"]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{$(!1),I("")},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:Ke,disabled:!F.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(Bt,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Creating..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(it,{className:"w-3 h-3"}),e.jsx("span",{children:"Create Branch"})]})})]})]})})]}),xe&&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:()=>Te(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 ${xe.type==="discard"||xe.type==="delete"?"bg-red-100 dark:bg-red-900/30":"bg-yellow-100 dark:bg-yellow-900/30"}`,children:e.jsx(Ht,{className:`w-5 h-5 ${xe.type==="discard"||xe.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:xe.type==="discard"?"Discard Changes":xe.type==="delete"?"Delete File":xe.type==="commit"?"Confirm Commit":xe.type==="pull"?"Confirm Pull":xe.type==="publish"?"Publish Branch":"Confirm Push"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:xe.message}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>Te(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:Pe,className:`px-4 py-2 text-sm text-white rounded-lg transition-colors ${xe.type==="discard"||xe.type==="delete"?"bg-red-600 hover:bg-red-700":xe.type==="commit"?"bg-primary hover:bg-primary/90":xe.type==="pull"?"bg-green-600 hover:bg-green-700":xe.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:xe.type==="discard"?e.jsxs(e.Fragment,{children:[e.jsx(ft,{className:"w-4 h-4"}),e.jsx("span",{children:"Discard"})]}):xe.type==="delete"?e.jsxs(e.Fragment,{children:[e.jsx(ft,{className:"w-4 h-4"}),e.jsx("span",{children:"Delete"})]}):xe.type==="commit"?e.jsxs(e.Fragment,{children:[e.jsx(Et,{className:"w-4 h-4"}),e.jsx("span",{children:"Commit"})]}):xe.type==="pull"?e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"w-4 h-4"}),e.jsx("span",{children:"Pull"})]}):xe.type==="publish"?e.jsxs(e.Fragment,{children:[e.jsx(es,{className:"w-4 h-4"}),e.jsx("span",{children:"Publish"})]}):e.jsxs(e.Fragment,{children:[e.jsx(es,{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 qn extends Ft.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 bp(t){const r=c.useRef(!1),s=c.useCallback(o=>{o&&(o.preventDefault(),o.stopPropagation()),t()},[t]),a=c.useCallback(o=>{r.current=!0,s(o),window.setTimeout(()=>{r.current=!1},350)},[s]);return{handleMobileMenuClick:c.useCallback(o=>{if(r.current){o.preventDefault(),o.stopPropagation();return}s(o)},[s]),handleMobileMenuTouchEnd:a}}function bi({onMenuClick:t,compact:r=!1}){const{handleMobileMenuClick:s,handleMobileMenuTouchEnd:a}=bp(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 $t=({children:t,content:r,position:s="top",className:a="",delay:n=500})=>{const[o,i]=c.useState(!1),[l,m]=c.useState(null),d=()=>{const x=setTimeout(()=>{i(!0)},n);m(x)},u=()=>{l&&(clearTimeout(l),m(null)),i(!1)},g=()=>{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"}},p=()=>{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:u,children:[t,o&&e.jsxs("div",{className:ke("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",g(),a),children:[r,e.jsx("div",{className:ke("absolute w-0 h-0 border-4 border-transparent",p())})]})]}):t},Kn=[{id:"chat",labelKey:"tabs.chat",icon:Ea},{id:"canvas",labelKey:"Canvas",icon:Ui},{id:"shell",labelKey:"tabs.shell",icon:mt},{id:"files",labelKey:"tabs.files",icon:rr},{id:"git",labelKey:"tabs.git",icon:Ut}],yp={id:"tasks",labelKey:"tabs.tasks",icon:mo};function vp({activeTab:t,setActiveTab:r,shouldShowTasksTab:s}){const{t:a}=He(),n=s?[...Kn,yp]:Kn;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,l=o.id===t;return e.jsx($t,{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 ${l?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(i,{className:"w-3.5 h-3.5",strokeWidth:l?2.2:1.8}),e.jsx("span",{className:"hidden lg:inline",children:a(o.labelKey)})]})},o.id)})})}function kp(t,r,s){return t==="files"?s("mainContent.projectFiles"):t==="git"?s("tabs.git"):t==="tasks"&&r?"TaskMaster":"Project"}function wp(t){return t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session"}function jp({activeTab:t,selectedProject:r,selectedSession:s,shouldShowTasksTab:a}){const{t:n}=He(),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(It,{provider:s==null?void 0: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:wp(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:kp(t,a,n)}),e.jsx("div",{className:"text-[11px] text-muted-foreground truncate leading-tight",children:r.displayName})]})})]})}function Np({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(bi,{onMenuClick:i}),e.jsx(jp,{activeTab:t,selectedProject:s,selectedSession:a,shouldShowTasksTab:n})]}),e.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:e.jsx(vp,{activeTab:t,setActiveTab:r,shouldShowTasksTab:n})})]})})}function Vn({mode:t,isMobile:r,onMenuClick:s}){const{t:a}=He(),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(bi,{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(rr,{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 Cp=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 bt=go.define({combine:t=>{const r=[];for(let s of t){if(!s)continue;const{create:a,gutters:n}=s,o=Cp(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 ml(r,{enabled:r.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),jt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},Sp=er.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"}}}}),Xt=jt.PixelMultiplier*jt.SizeRatio,Ep=Ta.fromClass(class{constructor(t){this.view=t,this._isDragging=!1,t.state.facet(bt).enabled&&this.create(t)}create(t){this.container=Nr("div",{class:"cm-minimap-overlay-container"}),this.dom=Nr("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(bt).enabled,s=t.state.facet(bt).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/Xt;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/Xt,o=t/Xt,i=t-o;let l=s/a;isNaN(l)&&(l=0);const m=i*l,d=Math.min(m,n);this.dom.style.top=d+"px"}}computeShowOverlay(){if(!this.container)return;const{showOverlay:t}=this.view.state.facet(bt);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,l=(r-i)*Xt,m=o/(n-a),u=(a*Xt-a)*m,g=Math.max(0,o-u);this.view.scrollDOM.scrollTop=g+l-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,l=parseFloat(this.dom.style.top),m=this.view.scrollDOM.scrollTop,d=this.view.scrollDOM.clientHeight,u=this.view.scrollDOM.scrollHeight,g=m===0,p=Math.round(m)>=Math.round(u-d);if(g&&s||g&&t.clientY<o||p&&a||p&&t.clientY>i)return;const x=this.view.scrollDOM.scrollHeight,f=this.view.scrollDOM.clientHeight,h=(x-f)/Xt,y=f-f/Xt,N=l+r,S=N/y,v=(x-f)*S,b=N*Xt;this.view.scrollDOM.scrollTop=Math.max(v,b);const D=Math.min(Math.max(0,N),Math.min(y,h));this.dom.style.top=D+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),Tp=[Sp,Ep];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 Jn(t){var r;if(!t.facet(bt).enabled)return[];const s=[],a=t.doc.iterLines(),n=xl(t).iter();let o=0;for(a.next();!a.done;){const i=a.value;let l=o,m=l+i.length;for(;n.value&&n.to<l;)n.next();const{from:d,to:u}=n,g=l>=d&&l<u,p=m>d&&m<=u;if(g){let x=(r=s.pop())!==null&&r!==void 0?r:[],f=x.pop();f&&f.folded&&(f.to=u),f&&x.push(f),(!f||!f.folded)&&x.push({from:d,to:u,folded:!0}),p||x.push({from:u,to:m,folded:!1}),s.push(x)}else p?s.push([{from:l,to:d,folded:!1},{from:d,to:u,folded:!0}]):s.push([{from:l,to:m,folded:!1}]);o=m+1,a.next()}return s}const Sr=dl.define({create:t=>Jn(t),update:(t,r)=>As([r])||r.docChanged?Jn(r.state):t});function As(t){return t.find(r=>r.effects.find(s=>s.is(ul)||s.is(pl)))}class Ip extends _a{constructor(r){super(r),this.count=void 0}shouldUpdate(r){if(!r.state.facet(bt).enabled)return!1;if(r.docChanged)return!0;for(const s of r.transactions)for(const a of s.effects)if(a.is(hl))return!0;return!!(As(r.transactions)||this.count===void 0)}update(r){if(!this.shouldUpdate(r))return;this.map.clear();const s=r.state.field(Sr);this.count=fl(r.state),bl(r.state,(a,n,o)=>{const i=this.findLine(n,s),l=this.findLine(o,s);let m=a.severity;for(let d=i;d<=l;d++){const u=this.get(d);u&&(m=[m,u].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(d,m)}})}drawLine(r,s){const{context:a,lineHeight:n,offsetX:o,offsetY:i}=r,l=this.get(s);l&&(a.globalAlpha=.65,a.beginPath(),a.rect(o,i,a.canvas.width-o,n),a.fillStyle=this.color(l),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 Ap(t){return new Ip(t)}class Dp extends _a{constructor(r){super(r),this.getDrawInfo(),this._themeClasses=r.dom.classList.value}shouldUpdate(r){return r.state.facet(bt).enabled?!!(r.docChanged||r.selectionSet||this._themeClasses!==this.view.dom.classList.value||As(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(Sr).entries()){const i=[];let l=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 u=s[a],g={from:l+Math.max(d.from,u.from)-d.from,to:l+Math.min(d.to,u.to)-d.from,extends:u.to>d.to},p=i.slice(-1)[0];if(p&&p.to===g.from){let{to:x}=g;d.folded&&g.extends?x=g.from+1:d.folded&&!g.extends&&(x=p.to),i[i.length-1]=Object.assign(Object.assign({},p),{to:x,extends:g.extends})}else d.folded||i.push(g);if(g.extends)break;a++}while(a<s.length&&d.to>=s[a].from);l+=d.folded?1:d.to-d.from}if(i.length===0)continue;const m=n+1;this.map.set(m,i)}}drawLine(r,s){let{context:a,lineHeight:n,charWidth:o,offsetX:i,offsetY:l}=r;const m=this.get(s);if(m)for(const d of m){const u=i+d.from*o,g=(d.to-d.from)*o,p=a.canvas.width-u;d.extends&&(a.globalAlpha=.65,a.beginPath(),a.rect(u,l,p,n),a.fillStyle=this.getDrawInfo().backgroundColor,a.fill()),a.globalAlpha=1,a.beginPath(),a.rect(u,l,g,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 Mp(t){return new Dp(t)}class $p extends _a{constructor(r){super(r),this._fontInfoMap=new Map,this._themeClasses=new Set(r.dom.classList.values()),r.state.facet(bt).enabled&&this.updateImpl(r.state)}shouldUpdate(r){return!!(r.docChanged||r.state.facet(bt)!==r.startState.facet(bt)||this.themeChanged()||As(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(bt).displayText,this.themeChanged()&&this._fontInfoMap.clear();let n;if(this._previousTree&&s){const g=Xa.addTree(this._previousTree),p=[];s.iterChangedRanges((x,f,h,y)=>p.push({fromA:x,toA:f,fromB:h,toB:y})),n=Xa.applyChanges(g,p)}const o=r.doc.toString(),i=(a=r.facet(gl))===null||a===void 0?void 0:a.parser,l=i?i.parse(o,n):void 0;this._previousTree=l;const m={style:g=>yl(r,g)};let d=[];if(l){const g=r.doc.lineAt(this.view.viewport.from).number,p=r.doc.lineAt(this.view.viewport.to).number,x=p-g,f=g/(r.doc.lines-x),{SizeRatio:h,PixelMultiplier:y}=jt,N=x*h*y,S=f*N,v=Math.max(1,Math.floor(g-S)),b=Math.min(p+Math.floor(N-S),r.doc.lines);Za(l,m,(D,A,j)=>{d.push({from:D,to:A,tags:j})},r.doc.line(v).from,r.doc.line(b).to)}this.updateMapImpl(r,d),d=[];const u=()=>{l&&(Za(l,m,(g,p,x)=>{d.push({from:g,to:p,tags:x})}),this.updateMapImpl(r,d),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(u):setTimeout(u)}updateMapImpl(r,s){this.map.clear();const a=r.doc.toString(),n=s.values();let o=n.next();for(const[i,l]of r.field(Sr).entries()){const m=[];for(const u of l){if(u.from===u.to)continue;if(u.folded){m.push({text:"…",tags:""});continue}let g=u.from;for(;!o.done&&o.value.from<u.to;){const{from:p,to:x,tags:f}=o.value;if(x<g){o=n.next();continue}p>g&&m.push({text:a.slice(g,p),tags:""});const h=Math.max(p,u.from),y=Math.min(x,u.to);if(m.push({text:a.slice(h,y),tags:f}),g=y,x>y)break;o=n.next()}g!==u.to&&m.push({text:a.slice(g,u.to),tags:""})}const d=i+1;this.map.set(d,m)}}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:l,offsetY:m}=r,d;n.textBaseline="ideographic";for(const u of a){const g=this.getFontInfo(u.tags);switch((!d||d.color!==g.color)&&(n.fillStyle=g.color),(!d||d.font!==g.font)&&(n.font=g.font),d=g,i=Math.max(i,g.lineHeight),this._displayText){case"characters":{n.fillText(u.text,l,m+i),l+=u.text.length*o;break}case"blocks":{const p=/\S+/g;let x;for(;(x=p.exec(u.text))!==null;){const f=l+x.index*o;let h=(p.lastIndex-x.index)*o;if(f>n.canvas.width)break;f+h>n.canvas.width&&(h=n.canvas.width-f);const y=2/jt.SizeRatio,N=i-y;n.fillStyle=g.color,n.globalAlpha=.65,n.beginPath(),n.rect(f,m,h,N),n.fill()}l+=u.text.length*o;break}}}}getFontInfo(r){const s=this._fontInfoMap.get(r);if(s)return s;const a=Nr("span",{class:r}),n=Nr("div",{class:"cm-line",style:"display: none"},a);this.view.contentDOM.appendChild(n);const o=window.getComputedStyle(a),i=parseFloat(o.lineHeight)/jt.SizeRatio,l={color:o.color,font:`${o.fontStyle} ${o.fontWeight} ${i}px ${o.fontFamily}`,lineHeight:i};return this._fontInfoMap.set(r,l),this.view.contentDOM.removeChild(n),l}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 Fp(t){return new $p(t)}const yi=4;function Pp(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,yi,r.lineHeight),r.context.fill())}const Lp=er.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"}}),Yn=6,_p=Ta.fromClass(class{constructor(t){this.view=t,this.text=Fp(t),this.selection=Mp(t),this.diagnostic=Ap(t),t.state.facet(Br)&&this.create(t)}create(t){const r=t.state.facet(Br);if(!r)throw Error("Expected nonnull");this.inner=Nr("div",{class:"cm-minimap-inner"}),this.canvas=Nr("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(bt).eventHandlers){const a=this.view.state.facet(bt).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(Br),s=t.state.facet(Br);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<=jt.MaxWidth*Yn){const r=t/(jt.MaxWidth*Yn);return jt.MaxWidth*r}return jt.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()*jt.PixelMultiplier;const t=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=t+"px",this.canvas.height=t*jt.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 l=this.view.state.facet(bt).gutters;for(let m=n;m<o;m++){const d=this.view.state.field(Sr);if(m>=d.length)break;const u={offsetX:0,offsetY:i,context:r,lineHeight:a,charWidth:s};if(l.length){u.offsetX+=2;for(let g of l)Pp(g,u,m+1),u.offsetX+=yi;u.offsetX+=2}this.text.drawLine(u,m+1),this.selection.drawLine(u,m+1),this.diagnostic.drawLine(u,m+1),i+=a}r.restore()}canvasStartAndEndIndex(t,r){let{top:s,bottom:a}=this.view.documentPadding;s/=jt.SizeRatio,a/=jt.SizeRatio;const n=t.canvas.height,{clientHeight:o,scrollHeight:i,scrollTop:l}=this.view.scrollDOM;let m=l/(i-o);isNaN(m)&&(m=0);const d=this.view.state.field(Sr).length,u=s+a+d*r,g=Math.max(0,m*(u-n)),p=Math.max(0,s-g),x=Math.round(Math.max(0,g-s)/r),f=Math.round((n-p)/r);return{startIndex:x,endIndex:x+f,offsetY:p}}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=>er.scrollMargins.of(r=>{var s;const a=(s=r.plugin(t))===null||s===void 0?void 0:s.getWidth();return a?{right:a}:null})}),Br=go.define({combine:t=>{var r;return(r=t.find(s=>s!==null))!==null&&r!==void 0?r:null},enables:t=>[[bt.compute([t],r=>r.facet(t)),Lp,Sr,_p,Tp]]}),zp=c.lazy(()=>xo(()=>import("./MarkdownPreview-CYdvwJaV.js"),__vite__mapDeps([0,1,2,3]))),Qn=wl.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 Op({file:t,onClose:r,projectPath:s,isSidebar:a=!1,isExpanded:n=!1,onToggleExpand:o=null,onPopOut:i=null}){const{t:l}=He("codeEditor"),[m,d]=c.useState(""),[u,g]=c.useState(!0),[p,x]=c.useState(!1),[f,h]=c.useState(!1),[y,N]=c.useState(()=>{const W=localStorage.getItem("codeEditorTheme");return W?W==="dark":!0}),[S,v]=c.useState(!1),[b,D]=c.useState(!!t.diffInfo),[A,j]=c.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[C,L]=c.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[R,_]=c.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[$,F]=c.useState(()=>localStorage.getItem("codeEditorFontSize")||"12"),[I,U]=c.useState(!1),w=c.useRef(null),z=c.useMemo(()=>{var O;const W=(O=t.name.split(".").pop())==null?void 0:O.toLowerCase();return W==="md"||W==="markdown"},[t.name]),q=c.useMemo(()=>{if(!t.diffInfo||!b||!C)return[];const W={};return[Br.compute(["doc"],O=>{const se=Os(O),B=(se==null?void 0:se.chunks)||[];return Object.keys(W).forEach(ge=>delete W[ge]),B.forEach(ge=>{const pe=O.doc.lineAt(ge.fromB).number,k=O.doc.lineAt(Math.min(ge.toB,O.doc.length)).number;for(let E=pe;E<=k;E++)W[E]=y?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[W]}})]},[t.diffInfo,b,C,y]),ee=c.useMemo(()=>!t.diffInfo||!b?[]:[Ta.fromClass(class{constructor(W){setTimeout(()=>{const O=Os(W.state),se=(O==null?void 0:O.chunks)||[];if(se.length>0){const B=se[0];W.dispatch({effects:er.scrollIntoView(B.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[t.diffInfo,b]),M=!!(t.diffInfo||a&&i||a&&o),K=c.useMemo(()=>{if(!M)return[];const W=O=>{const se=document.createElement("div");se.className="cm-editor-toolbar-panel";let B=0;const ge=()=>{const pe=t.diffInfo&&b,k=pe?Os(O.state):null,E=(k==null?void 0:k.chunks)||[],X=E.length;let ae='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(ae+='<div style="display: flex; align-items: center; gap: 8px;">',pe&&(ae+=`
142
+ <span style="font-weight: 500;">${X>0?`${B+1}/${X}`:"0"} ${l("toolbar.changes")}</span>
143
+ <button class="cm-diff-nav-btn cm-diff-nav-prev" title="${l("toolbar.previousChange")}" ${X===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="${l("toolbar.nextChange")}" ${X===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
+ `),ae+="</div>",ae+='<div style="display: flex; align-items: center; gap: 4px;">',t.diffInfo&&(ae+=`
154
+ <button class="cm-toolbar-btn cm-toggle-diff-btn" title="${l(b?"toolbar.hideDiff":"toolbar.showDiff")}">
155
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
156
+ ${b?'<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&&(ae+=`
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&&(ae+=`
166
+ <button class="cm-toolbar-btn cm-expand-btn" title="${l(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
+ `),ae+="</div>",ae+="</div>",se.innerHTML=ae,pe){const oe=se.querySelector(".cm-diff-nav-prev"),Fe=se.querySelector(".cm-diff-nav-next");oe==null||oe.addEventListener("click",()=>{if(E.length===0)return;B=B>0?B-1:E.length-1;const he=E[B];he&&O.dispatch({effects:er.scrollIntoView(he.fromB,{y:"center"})}),ge()}),Fe==null||Fe.addEventListener("click",()=>{if(E.length===0)return;B=B<E.length-1?B+1:0;const he=E[B];he&&O.dispatch({effects:er.scrollIntoView(he.fromB,{y:"center"})}),ge()})}if(t.diffInfo){const oe=se.querySelector(".cm-toggle-diff-btn");oe==null||oe.addEventListener("click",()=>{D(!b)})}if(a&&i){const oe=se.querySelector(".cm-popout-btn");oe==null||oe.addEventListener("click",()=>{i()})}if(a&&o){const oe=se.querySelector(".cm-expand-btn");oe==null||oe.addEventListener("click",()=>{o()})}};return ge(),{top:!0,dom:se,update:ge}};return[vl.of(W)]},[t.diffInfo,b,a,n,o,i]),T=W=>{var B;const O=W.toLowerCase();if(O===".env"||O.startsWith(".env."))return[Qn];const se=(B=W.split(".").pop())==null?void 0:B.toLowerCase();switch(se){case"js":case"jsx":case"ts":case"tsx":return[El({jsx:!0,typescript:se.includes("ts")})];case"py":return[Sl()];case"html":case"htm":return[Cl()];case"css":case"scss":case"less":return[Nl()];case"json":return[jl()];case"md":case"markdown":return[bo()];case"env":return[Qn];default:return[]}};c.useEffect(()=>{(async()=>{try{if(g(!0),t.diffInfo&&t.diffInfo.new_string!==void 0&&t.diffInfo.old_string!==void 0){d(t.diffInfo.new_string),g(!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 se=await O.json();d(se.content)}catch(O){console.error("Error loading file:",O),d(`// Error loading file: ${O.message}
172
+ // File: ${t.name}
173
+ // Path: ${t.path}`)}finally{g(!1)}})()},[t,s]);const G=async()=>{x(!0);try{console.log("Saving file:",{projectName:t.projectName,path:t.path,contentLength:m==null?void 0:m.length});const W=await Ge.saveFile(t.projectName,t.path,m);if(console.log("Save response:",{status:W.status,ok:W.ok,contentType:W.headers.get("content-type")}),!W.ok){const se=W.headers.get("content-type");if(se&&se.includes("application/json")){const B=await W.json();throw new Error(B.error||`Save failed: ${W.status}`)}else{const B=await W.text();throw console.error("Non-JSON error response:",B),new Error(`Save failed: ${W.status} ${W.statusText}`)}}const O=await W.json();console.log("Save successful:",O),v(!0),setTimeout(()=>v(!1),2e3)}catch(W){console.error("Error saving file:",W),alert(`Error saving file: ${W.message}`)}finally{x(!1)}},Y=()=>{const W=new Blob([m],{type:"text/plain"}),O=URL.createObjectURL(W),se=document.createElement("a");se.href=O,se.download=t.name,document.body.appendChild(se),se.click(),document.body.removeChild(se),URL.revokeObjectURL(O)},J=()=>{h(!f)};return c.useEffect(()=>{localStorage.setItem("codeEditorTheme",y?"dark":"light")},[y]),c.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",A.toString())},[A]),c.useEffect(()=>{const W=()=>{const O=localStorage.getItem("codeEditorTheme");O&&N(O==="dark");const se=localStorage.getItem("codeEditorWordWrap");se!==null&&j(se==="true");const B=localStorage.getItem("codeEditorShowMinimap");B!==null&&L(B!=="false");const ge=localStorage.getItem("codeEditorLineNumbers");ge!==null&&_(ge!=="false");const pe=localStorage.getItem("codeEditorFontSize");pe&&F(pe)};return window.addEventListener("storage",W),window.addEventListener("codeEditorSettingsChanged",W),()=>{window.removeEventListener("storage",W),window.removeEventListener("codeEditorSettingsChanged",W)}},[]),c.useEffect(()=>{const W=O=>{(O.ctrlKey||O.metaKey)&&(O.key==="s"?(O.preventDefault(),G()):O.key==="Escape"&&(O.preventDefault(),r()))};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[m]),u?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
174
+ .code-editor-loading {
175
+ background-color: ${y?"#111827":"#ffffff"} !important;
176
+ }
177
+ .code-editor-loading:hover {
178
+ background-color: ${y?"#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:l("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:l("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: ${y?"rgba(239, 68, 68, 0.15)":"rgba(255, 235, 235, 1)"} !important;
184
+ border-left: 3px solid ${y?"rgba(239, 68, 68, 0.6)":"rgb(239, 68, 68)"} !important;
185
+ padding-left: 4px !important;
186
+ }
187
+
188
+ .cm-insertedChunk {
189
+ background-color: ${y?"rgba(34, 197, 94, 0.15)":"rgba(230, 255, 237, 1)"} !important;
190
+ border-left: 3px solid ${y?"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: ${y?"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: ${y?"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: ${y?"#1e1e1e":"#f5f5f5"};
214
+ }
215
+
216
+ /* Editor toolbar panel styling */
217
+ .cm-editor-toolbar-panel {
218
+ padding: 4px 10px;
219
+ background-color: ${y?"#1f2937":"#ffffff"};
220
+ border-bottom: 1px solid ${y?"#374151":"#e5e7eb"};
221
+ color: ${y?"#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: ${y?"#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:l("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:[z&&e.jsx("button",{onClick:()=>U(!I),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 ${I?"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:l(I?"actions.editMarkdown":"actions.previewMarkdown"),children:I?e.jsx(us,{className:"w-4 h-4"}):e.jsx(mr,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{var W;return(W=window.openSettings)==null?void 0:W.call(window,"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:l("toolbar.settings"),children:e.jsx(Ve,{className:"w-4 h-4"})}),e.jsx("button",{onClick:Y,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:l("actions.download"),children:e.jsx(gs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:G,disabled:p,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:l(S?"actions.saved":p?"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(ps,{className:"w-4 h-4"})}),!a&&e.jsx("button",{onClick:J,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:l(f?"actions.exitFullscreen":"actions.fullscreen"),children:f?e.jsx(uo,{className:"w-4 h-4"}):e.jsx(Ca,{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:l("actions.close"),children:e.jsx(qe,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:I&&z?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(c.Suspense,{fallback:e.jsx("div",{className:"text-muted-foreground text-sm p-4",children:"Loading preview..."}),children:e.jsx(zp,{content:m})})})}):e.jsx(ho,{ref:w,value:m,onChange:d,extensions:[...T(t.name),...K,...t.diffInfo&&b&&t.diffInfo.old_string!==void 0?[kl({original:t.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...q,...ee]:[],...A?[er.lineWrapping]:[]],theme:y?fo:void 0,height:"100%",style:{fontSize:`${$}px`,height:"100%"},basicSetup:{lineNumbers:R,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:[l("footer.lines")," ",m.split(`
249
+ `).length]}),e.jsxs("span",{children:[l("footer.characters")," ",m.length]})]}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:l("footer.shortcuts")})]})]})})]})}const Xn=Op;function Rp({editingFile:t,isMobile:r,editorExpanded:s,editorWidth:a,resizeHandleRef:n,onResizeStart:o,onCloseEditor:i,onToggleEditorExpand:l,projectPath:m,fillSpace:d}){const[u,g]=c.useState(!1);if(!t)return null;if(r||u)return e.jsx(Xn,{file:t,onClose:()=>{g(!1),i()},projectPath:m,isSidebar:!1});const p=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 ${p?"flex-1":""}`,style:p?void 0:{width:`${a}px`},children:e.jsx(Xn,{file:t,onClose:i,projectPath:m,isSidebar:!0,isExpanded:s,onToggleExpand:l,onPopOut:()=>g(!0)})})]})}const Zn=({task:t,onClick:r,showParent:s=!1,className:a=""})=>{const o=(l=>{switch(l){case"done":return{icon:Kr,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:Wr,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:Es,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:lo,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"};case"pending":default:return{icon:wr,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=l=>{switch(l){case"high":return e.jsx($t,{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(Gi,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})});case"medium":return e.jsx($t,{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(Hi,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})})});case"low":return e.jsx($t,{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(wr,{className:"w-1.5 h-1.5 text-blue-600 dark:text-blue-400 fill-current"})})});default:return e.jsx($t,{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(wr,{className:"w-1.5 h-1.5 text-gray-400 dark:text-gray-500"})})})}};return e.jsxs("div",{className:ke("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($t,{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($t,{content:`Depends on: ${t.dependencies.map(l=>`Task ${l}`).join(", ")}`,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[e.jsx(Sa,{className:"w-3 h-3"}),e.jsxs("span",{children:["Depends on: ",t.dependencies.join(", ")]})]})})}),e.jsx($t,{content:`Status: ${o.statusText}`,children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:ke("w-2 h-2 rounded-full",o.iconColor.replace("text-","bg-"))}),e.jsx("span",{className:ke("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($t,{content:`${t.subtasks.filter(l=>l.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:ke("h-full rounded-full transition-all duration-300",t.status==="done"?"bg-green-500":"bg-blue-500"),style:{width:`${Math.round(t.subtasks.filter(l=>l.status==="done").length/t.subtasks.length*100)}%`}})})}),e.jsx($t,{content:`${t.subtasks.filter(l=>l.status==="done").length} completed, ${t.subtasks.filter(l=>l.status==="pending").length} pending, ${t.subtasks.filter(l=>l.status==="in-progress").length} in progress`,children:e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t.subtasks.filter(l=>l.status==="done").length,"/",t.subtasks.length]})})]})})]})},Bp=({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(Wt,{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(Wt,{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"})})]})]})}),Wp=({tasks:t=[],onTaskClick:r,className:s="",showParentTasks:a=!1,defaultView:n="kanban",currentProject:o,onTaskCreated:i,onShowPRDEditor:l,existingPRDs:m=[],onRefreshPRDs:d})=>{var ge,pe;const[u,g]=c.useState(""),[p,x]=c.useState("all"),[f,h]=c.useState("all"),[y,N]=c.useState("id"),[S,v]=c.useState("asc"),[b,D]=c.useState(n),[A,j]=c.useState(!1),[C,L]=c.useState(!1),[R,_]=c.useState(!1),[$,F]=c.useState(!1),[I,U]=c.useState(!1),[w,z]=c.useState(!1),{projectTaskMaster:q,refreshProjects:ee,refreshTasks:M,setCurrentProject:K}=Er(),{t:T}=He("tasks");c.useEffect(()=>{const k=E=>{w&&!E.target.closest(".relative")&&z(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[w]);const G=c.useMemo(()=>{const k=new Set(t.map(E=>E.status).filter(Boolean));return Array.from(k).sort()},[t]),Y=c.useMemo(()=>{const k=new Set(t.map(E=>E.priority).filter(Boolean));return Array.from(k).sort()},[t]),J=c.useMemo(()=>{let k=t.filter(E=>{var he;const X=u.toLowerCase(),ae=!u||E.title.toLowerCase().includes(X)||((he=E.description)==null?void 0:he.toLowerCase().includes(X))||E.id.toString().includes(X),oe=p==="all"||E.status===p,Fe=f==="all"||E.priority===f;return ae&&oe&&Fe});return k.sort((E,X)=>{let ae,oe;switch(y){case"title":ae=E.title.toLowerCase(),oe=X.title.toLowerCase();break;case"status":const Fe={pending:1,"in-progress":2,done:3,blocked:4,deferred:5,cancelled:6};ae=Fe[E.status]||99,oe=Fe[X.status]||99;break;case"priority":const he={high:3,medium:2,low:1};ae=he[E.priority]||0,oe=he[X.priority]||0;break;case"updated":ae=new Date(E.updatedAt||E.createdAt||0),oe=new Date(X.updatedAt||X.createdAt||0);break;case"id":default:const xe=ze=>ze.toString().split(".").map(fe=>parseInt(fe,10)),Te=xe(E.id),Le=xe(X.id);for(let ze=0;ze<Math.max(Te.length,Le.length);ze++){const re=Te[ze]||0,fe=Le[ze]||0;if(re!==fe){ae=re,oe=fe;break}}break}return y==="updated"?S==="asc"?ae-oe:oe-ae:typeof ae=="string"?S==="asc"?ae.localeCompare(oe):oe.localeCompare(ae):S==="asc"?ae-oe:oe-ae}),k},[t,u,p,f,y,S]),W=c.useMemo(()=>{const k=[{id:"pending",title:T("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:T("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:T("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:T("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:T("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:T("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"}],E=["pending","in-progress","done"];return k.filter(ae=>{const oe=J.some(he=>he.status===ae.status),Fe=E.includes(ae.status);return oe||Fe}).map(ae=>({...ae,tasks:J.filter(oe=>oe.status===ae.status)}))},[J,T]),O=k=>{y===k?v(S==="asc"?"desc":"asc"):(N(k),v("asc"))},se=()=>{g(""),x("all"),h("all")},B=k=>y!==k?e.jsx(Yi,{className:"w-4 h-4"}):S==="asc"?e.jsx(Qi,{className:"w-4 h-4"}):e.jsx(oo,{className:"w-4 h-4"});if(t.length===0){const k=(o==null?void 0:o.taskMasterConfigured)||((ge=o==null?void 0:o.taskmaster)==null?void 0:ge.hasTaskmaster)||(q==null?void 0:q.hasTaskmaster);return e.jsxs("div",{className:ke("text-center py-12",s),children:[k?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(ot,{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:T("gettingStarted.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:T("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:T("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:T("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{l==null||l()},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(ot,{className:"w-3 h-3"}),T("gettingStarted.steps.createPRD.addButton")]}),m.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:T("gettingStarted.steps.createPRD.existingPRDs")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:m.map(E=>e.jsxs("button",{onClick:async()=>{try{const X=await Ge.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(E.name)}`);if(X.ok){const ae=await X.json();l==null||l({name:E.name,content:ae.content,isExisting:!0})}else console.error("Failed to load PRD:",X.statusText)}catch(X){console.error("Error loading PRD:",X)}},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(ot,{className:"w-3 h-3"}),E.name]},E.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:T("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:T("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:T("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:T("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:T("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:T("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:E=>{E.preventDefault(),E.stopPropagation(),l==null||l()},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(ot,{className:"w-4 h-4"}),T("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:T("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:T("notConfigured.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:T("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:T("notConfigured.whatIsTitle")}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("p",{children:["• ",T("notConfigured.features.aiPowered")]}),e.jsxs("p",{children:["• ",T("notConfigured.features.prdTemplates")]}),e.jsxs("p",{children:["• ",T("notConfigured.features.dependencyTracking")]}),e.jsxs("p",{children:["• ",T("notConfigured.features.progressVisualization")]}),e.jsxs("p",{children:["• ",T("notConfigured.features.cliIntegration")]})]})]}),e.jsxs("button",{onClick:()=>{U(!1),_(!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(mt,{className:"w-4 h-4"}),T("notConfigured.initializeButton")]})]}),R&&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(mt,{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:T("setupModal.title")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:T("setupModal.subtitle",{projectName:o==null?void 0:o.displayName})})]})]}),e.jsx("button",{onClick:()=>{_(!1),setTimeout(()=>{ee(),o&&K(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(it,{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:E=>{const X=E.currentTarget.querySelector(".xterm-screen");X&&X.focus()},children:e.jsx(po,{selectedProject:o,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0,onProcessComplete:E=>{U(!0),E===0&&setTimeout(()=>{ee(),o&&K(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:I?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"}),T("setupModal.completed")]}):T("setupModal.willStart")}),e.jsx("button",{onClick:()=>{_(!1),U(!1),setTimeout(()=>{ee(),o&&K(o)},1e3)},className:ke("px-4 py-2 text-sm font-medium rounded-md transition-colors",I?"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:T(I?"setupModal.closeContinueButton":"setupModal.closeButton")})]})})]})})]})}return e.jsxs("div",{className:ke("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(dr,{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:T("search.placeholder"),value:u,onChange:k=>g(k.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:()=>D("kanban"),className:ke("p-2 rounded-md transition-colors",b==="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:T("views.kanban"),children:e.jsx(qi,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>D("list"),className:ke("p-2 rounded-md transition-colors",b==="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:T("views.list"),children:e.jsx(xs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>D("grid"),className:ke("p-2 rounded-md transition-colors",b==="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:T("views.grid"),children:e.jsx(Ki,{className:"w-4 h-4"})})]}),e.jsxs("button",{onClick:()=>j(!A),className:ke("flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors",A?"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(Vi,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:T("filters.button")}),e.jsx(Ct,{className:ke("w-4 h-4 transition-transform",A&&"rotate-180")})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>F(!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:T("buttons.help"),children:e.jsx(Ji,{className:"w-4 h-4"})}),e.jsx("div",{className:"relative",children:m.length>0?e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>z(!w),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:T("buttons.prdsAvailable",{count:m.length}),children:[e.jsx(ot,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:T("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:m.length}),e.jsx(Ct,{className:ke("w-3 h-3 transition-transform hidden sm:block",w&&"rotate-180")})]}),w&&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:()=>{l==null||l(),z(!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(it,{className:"w-4 h-4"}),T("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:T("gettingStarted.steps.createPRD.existingPRDs")}),m.map(k=>e.jsxs("button",{onClick:async()=>{try{const E=await Ge.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(k.name)}`);if(E.ok){const X=await E.json();l==null||l({name:k.name,content:X.content,isExisting:!0}),z(!1)}}catch(E){console.error("Error loading PRD:",E)}},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:T("prd.modified",{date:new Date(k.modified).toLocaleDateString()}),children:[e.jsx(ot,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate",children:k.name})]},k.name))]})})]}):e.jsxs("button",{onClick:()=>{l==null||l()},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:T("buttons.addPRD"),children:[e.jsx(ot,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:T("buttons.addPRD")})]})}),((o==null?void 0:o.taskMasterConfigured)||((pe=o==null?void 0:o.taskmaster)==null?void 0:pe.hasTaskmaster)||(q==null?void 0:q.hasTaskmaster)||t.length>0)&&e.jsxs("button",{onClick:()=>L(!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:T("buttons.addTask"),children:[e.jsx(it,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:T("buttons.addTask")})]})]})]})]}),A&&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:T("filters.status")}),e.jsxs("select",{value:p,onChange:k=>x(k.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:T("filters.allStatuses")}),G.map(k=>e.jsx("option",{value:k,children:T(`statuses.${k}`,k.charAt(0).toUpperCase()+k.slice(1).replace("-"," "))},k))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:T("filters.priority")}),e.jsxs("select",{value:f,onChange:k=>h(k.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:T("filters.allPriorities")}),Y.map(k=>e.jsx("option",{value:k,children:T(`priorities.${k}`,k.charAt(0).toUpperCase()+k.slice(1))},k))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:T("filters.sortBy")}),e.jsxs("select",{value:`${y}-${S}`,onChange:k=>{const[E,X]=k.target.value.split("-");N(E),v(X)},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:T("sort.idAsc")}),e.jsx("option",{value:"id-desc",children:T("sort.idDesc")}),e.jsx("option",{value:"title-asc",children:T("sort.titleAsc")}),e.jsx("option",{value:"title-desc",children:T("sort.titleDesc")}),e.jsx("option",{value:"status-asc",children:T("sort.statusAsc")}),e.jsx("option",{value:"status-desc",children:T("sort.statusDesc")}),e.jsx("option",{value:"priority-asc",children:T("sort.priorityAsc")}),e.jsx("option",{value:"priority-desc",children:T("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:T("filters.showing",{filtered:J.length,total:t.length})}),e.jsx("button",{onClick:se,className:"text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium",children:T("filters.clearFilters")})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>O("id"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",y==="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:[T("sort.id")," ",B("id")]}),e.jsxs("button",{onClick:()=>O("status"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",y==="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:[T("sort.status")," ",B("status")]}),e.jsxs("button",{onClick:()=>O("priority"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",y==="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:[T("sort.priority")," ",B("priority")]})]}),J.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(dr,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:T("noMatchingTasks.title")}),e.jsx("p",{className:"text-sm",children:T("noMatchingTasks.description")})]})}):b==="kanban"?e.jsx("div",{className:ke("grid gap-6",W.length===1&&"grid-cols-1 max-w-md mx-auto",W.length===2&&"grid-cols-1 md:grid-cols-2",W.length===3&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",W.length===4&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-4",W.length===5&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5",W.length>=6&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6"),children:W.map(k=>e.jsxs("div",{className:ke("rounded-xl border shadow-sm transition-shadow hover:shadow-md",k.color),children:[e.jsx("div",{className:ke("px-4 py-3 rounded-t-xl border-b",k.headerColor),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold text-sm",children:k.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:k.tasks.length})})]})}),e.jsx("div",{className:"p-3 space-y-3 min-h-[200px] max-h-[calc(100vh-300px)] overflow-y-auto",children:k.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:T("kanban.noTasksYet")}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:k.status==="pending"?T("kanban.tasksWillAppear"):k.status==="in-progress"?T("kanban.moveTasksHere"):k.status==="done"?T("kanban.completedTasksHere"):T("kanban.statusTasksHere")})]}):k.tasks.map(E=>e.jsx("div",{className:"transform transition-transform hover:scale-[1.02]",children:e.jsx(Zn,{task:E,onClick:()=>r==null?void 0:r(E),showParent:a,className:"w-full shadow-sm hover:shadow-md transition-shadow cursor-pointer"})},E.id))})]},k.id))}):e.jsx("div",{className:ke("gap-4",b==="grid"?"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3":"space-y-4"),children:J.map(k=>e.jsx(Zn,{task:k,onClick:()=>r==null?void 0:r(k),showParent:a,className:b==="grid"?"h-full":""},k.id))}),C&&e.jsx(Bp,{currentProject:o,onClose:()=>L(!1),onTaskCreated:()=>{L(!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(ot,{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:T("helpGuide.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:T("helpGuide.subtitle")})]})]}),e.jsx("button",{onClick:()=>F(!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:T("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:T("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{l==null||l(),F(!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(ot,{className:"w-4 h-4"}),T("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:T("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:T("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:T("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:T("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:T("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:T("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:T("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:T("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:T("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:T("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:T("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"}),T("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"}),T("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"}),T("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"}),T("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:T("helpGuide.learnMore.title")}),e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-3",children:T("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"})}),T("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"})})]})]})]})})]})})]})},Up=({file:t,onClose:r,projectPath:s,project:a,initialContent:n="",isNewFile:o=!1,onSave:i})=>{const[l,m]=c.useState(n),[d,u]=c.useState(!o),[g,p]=c.useState(!1),[x,f]=c.useState(!1),[h,y]=c.useState(!0),[N,S]=c.useState(!1),[v,b]=c.useState(!1),[D,A]=c.useState(!0),[j,C]=c.useState(""),[L,R]=c.useState(!1),[_,$]=c.useState(!1),[F,I]=c.useState([]),U=c.useRef(null),w=`# 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`;c.useEffect(()=>{(async()=>{if(t!=null&&t.name)C(t.name.replace(/\.(txt|md)$/,""));else if(o){const J=new Date().toISOString().split("T")[0];C(`prd-${J}`)}if(o){m(w),u(!1);return}if(t.content){m(t.content),u(!1);return}try{u(!0);const Y=await Ge.readFile(t.projectName,t.path);if(!Y.ok)throw new Error(`Failed to load file: ${Y.status} ${Y.statusText}`);const J=await Y.json();m(J.content||w)}catch(Y){console.error("Error loading PRD file:",Y),m(`# Error Loading PRD
506
+
507
+ Error: ${Y.message}
508
+
509
+ File: ${(t==null?void 0:t.name)||"New PRD"}
510
+ Path: ${(t==null?void 0:t.path)||"Not saved yet"}
511
+
512
+ ${w}`)}finally{u(!1)}})()},[t,s,o]),c.useEffect(()=>{(async()=>{if(!(a!=null&&a.name)){console.log("No project name available:",a);return}try{console.log("Fetching PRDs for project:",a.name);const Y=await Ge.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(Y.ok){const J=await Y.json();console.log("Fetched existing PRDs:",J.prds),I(J.prds||[])}else console.log("Failed to fetch PRDs:",Y.status,Y.statusText)}catch(Y){console.error("Error fetching existing PRDs:",Y)}})()},[a==null?void 0:a.name]);const z=async()=>{if(!l.trim()){alert("Please add content before saving.");return}if(!j.trim()){alert("Please provide a filename for the PRD.");return}const G=j.endsWith(".txt")||j.endsWith(".md")?j:`${j}.txt`,Y=F.find(J=>J.name===G);if(console.log("Save check:",{fullFileName:G,existingPRDs:F,existingFile:Y,isExisting:t==null?void 0:t.isExisting,fileObject:t,shouldShowModal:Y&&!(t!=null&&t.isExisting)}),Y&&!(t!=null&&t.isExisting)){console.log("Showing overwrite confirmation modal"),$(!0);return}await q()},q=async()=>{p(!0);try{const G=j.endsWith(".txt")||j.endsWith(".md")?j:`${j}.txt`,Y=await Se(`/api/taskmaster/prd/${encodeURIComponent(a==null?void 0:a.name)}`,{method:"POST",body:JSON.stringify({fileName:G,content:l})});if(!Y.ok){const W=await Y.json();throw new Error(W.message||`Save failed: ${Y.status}`)}S(!0),setTimeout(()=>S(!1),2e3);const J=await Ge.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(J.ok){const W=await J.json();I(W.prds||[])}i&&await i()}catch(G){console.error("Error saving PRD:",G),alert(`Error saving PRD: ${G.message}`)}finally{p(!1)}},ee=()=>{const G=new Blob([l],{type:"text/markdown"}),Y=URL.createObjectURL(G),J=document.createElement("a");J.href=Y;const W=j?`${j}.txt`:"prd.txt";J.download=W,document.body.appendChild(J),J.click(),document.body.removeChild(J),URL.revokeObjectURL(Y)},M=async()=>{if(!l.trim()){alert("Please add content to the PRD before generating tasks.");return}R(!0)},K=()=>{f(!x)};c.useEffect(()=>{const G=Y=>{(Y.ctrlKey||Y.metaKey)&&(Y.key==="s"?(Y.preventDefault(),z()):Y.key==="Escape"&&(Y.preventDefault(),r()))};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[l]);const T=G=>G.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 ${x?"md:p-0":""}`,children:[e.jsxs("div",{className:ke("bg-white dark:bg-gray-900 shadow-2xl flex flex-col","w-full h-full md:rounded-lg md:shadow-2xl",x?"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(ot,{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:j,onChange:G=>{const Y=G.target.value.replace(/[<>:"/\\|?*]/g,"");C(Y)},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:()=>{var G;return(G=document.querySelector('input[placeholder="Enter PRD filename"]'))==null?void 0:G.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:()=>b(!v),className:ke("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",v?"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:v?"Switch to edit mode":"Preview markdown",children:e.jsx(mr,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsx("button",{onClick:()=>A(!D),className:ke("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",D?"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:D?"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:()=>y(!h),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:h?"☀️":"🌙"})}),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(gs,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsxs("button",{onClick:M,disabled:!l.trim(),className:ke("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(Wt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:"Generate Tasks"})]}),e.jsx("button",{onClick:z,disabled:g,className:ke("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",N?"bg-green-600 hover:bg-green-700":"bg-purple-600 hover:bg-purple-700"),children:N?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(ps,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:g?"Saving...":"Save PRD"})]})}),e.jsx("button",{onClick:K,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:x?"Exit fullscreen":"Fullscreen",children:x?e.jsx(uo,{className:"w-4 h-4"}):e.jsx(Ca,{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:v?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:T(l)}})}):e.jsx(ho,{ref:U,value:l,onChange:m,extensions:[bo(),...D?[er.lineWrapping]:[]],theme:h?fo: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: ",l.split(`
513
+ `).length]}),e.jsxs("span",{children:["Characters: ",l.length]}),e.jsxs("span",{children:["Words: ",l.split(/\s+/).filter(G=>G.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"})]})]}),L&&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(Wt,{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:()=>R(!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(Wt,{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/`,j.endsWith(".txt")||j.endsWith(".md")?j:`${j}.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:()=>R(!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"})})]})]})}),_&&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(Ht,{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 "',j.endsWith(".txt")||j.endsWith(".md")?j:`${j}.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 q()},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(ps,{className:"w-4 h-4"}),e.jsx("span",{children:"Overwrite"})]})]})]})})]})]})},Hp=Wp,Gp=Uo,qp=Up,Kp="PRD saved successfully!";function Vp(t){return t.prdFiles||t.prds||[]}function Jp({isVisible:t}){const{tasks:r=[],currentProject:s,refreshTasks:a}=Er(),[n,o]=c.useState(null),[i,l]=c.useState(!1),[m,d]=c.useState(!1),[u,g]=c.useState(null),[p,x]=c.useState([]),[f,h]=c.useState(null),y=c.useRef(null),N=c.useCallback(R=>{y.current&&clearTimeout(y.current),h(R),y.current=setTimeout(()=>{h(null),y.current=null},3e3)},[]),S=c.useCallback(async()=>{if(!(s!=null&&s.name)){x([]);return}try{const R=await Ge.get(`/taskmaster/prd/${encodeURIComponent(s.name)}`);if(!R.ok){x([]);return}const _=await R.json();x(Vp(_))}catch(R){console.error("Failed to load existing PRDs:",R),x([])}},[s==null?void 0:s.name]),v=c.useCallback(async(R=!1)=>{await S(),R&&N(Kp)},[S,N]);c.useEffect(()=>{S()},[S]),c.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const b=c.useCallback(R=>{if(!(!R||typeof R!="object"||!("id"in R))){if(!("title"in R)||!R.title){const _=r.find($=>String($.id)===String(R.id));_&&(o(_),l(!0));return}o(R),l(!0)}},[r]),D=c.useCallback(()=>{l(!1),o(null)},[]),A=c.useCallback((R,_)=>{console.log("Update task status:",R,_),a==null||a()},[a]),j=c.useCallback((R=null)=>{g(R),d(!0)},[]),C=c.useCallback(()=>{d(!1),g(null)},[]),L=c.useCallback(async()=>{C(),await v(!0),a==null||a()},[C,v,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(Hp,{tasks:r,onTaskClick:b,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:s,onTaskCreated:a||void 0,onShowPRDEditor:j,existingPRDs:p,onRefreshPRDs:(R=!1)=>{v(R)}})})}),i&&n&&e.jsx(Gp,{task:n,isOpen:i,onClose:D,onStatusChange:A,onTaskClick:b}),m&&e.jsx(qp,{project:s,projectPath:(s==null?void 0:s.fullPath)||(s==null?void 0:s.path),onClose:C,isNewFile:!(u!=null&&u.isExisting),file:{name:(u==null?void 0:u.name)||"prd.txt",content:(u==null?void 0:u.content)||""},onSave:L}),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 Yp(){const{isRelayConnected:t,isChecking:r}=va(),[s,a]=c.useState(null),[n,o]=c.useState(!1),[i,l]=c.useState(!1),[m,d]=c.useState(!1),[u,g]=c.useState(!1);c.useEffect(()=>{if(t||g(!0),t&&u){d(!0),a(null);const f=setTimeout(()=>d(!1),3e3);return()=>clearTimeout(f)}},[t,u]);const p=c.useCallback(async()=>{try{o(!0);const f=await Ge.relay.createToken(`web-${Date.now()}`);if(f.ok){const h=await f.json();a(h.token)}}catch{}finally{o(!1)}},[]),x=c.useCallback(()=>{if(!s)return;const f=`npx upfynai-code connect --server ${window.location.host} --key ${s}`;navigator.clipboard.writeText(f),l(!0),setTimeout(()=>l(!1),2e3)},[s]);return r||t&&!m?null:t&&m?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(Qa,{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(ro,{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:p,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(vr,{className:"w-3 h-3 animate-spin"}):e.jsx(Qa,{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:x,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(Et,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(ja,{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 cs({children:t,fallback:r,bypass:s}){const{isRelayConnected:a}=va();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 Ds({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 Qp(){return e.jsx(Ds,{icon:Ea,label:"Chat"})}function Xp(){return e.jsx(Ds,{icon:mt,label:"Shell"})}function Zp(){return e.jsx(Ds,{icon:Xi,label:"Files"})}function ex(){return e.jsx(Ds,{icon:Ut,label:"Git"})}function tx({selectedProject:t,isMobile:r,initialWidth:s=600}){const[a,n]=c.useState(null),[o,i]=c.useState(s),[l,m]=c.useState(!1),[d,u]=c.useState(!1),g=c.useRef(null),p=c.useCallback((y,N=null)=>{const v=y.replace(/\\/g,"/").split("/").pop()||y;n({name:v,path:y,projectName:t==null?void 0:t.name,diffInfo:N})},[t==null?void 0:t.name]),x=c.useCallback(()=>{n(null),m(!1)},[]),f=c.useCallback(()=>{m(y=>!y)},[]),h=c.useCallback(y=>{r||(u(!0),y.preventDefault())},[r]);return c.useEffect(()=>{const y=S=>{var C;if(!d)return;const v=(C=g.current)==null?void 0:C.parentElement;if(!v)return;const b=v.getBoundingClientRect(),D=b.right-S.clientX,A=300,j=b.width*.8;D>=A&&D<=j&&i(D)},N=()=>{u(!1)};return d&&(document.addEventListener("mousemove",y),document.addEventListener("mouseup",N),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",N),document.body.style.cursor="",document.body.style.userSelect=""}},[d]),{editingFile:a,editorWidth:o,editorExpanded:l,resizeHandleRef:g,handleFileOpen:p,handleCloseEditor:x,handleToggleEditorExpand:f,handleResizeStart:h}}const rx=c.lazy(()=>xo(()=>import("./CanvasPanel-DlTW6Jh6.js"),__vite__mapDeps([4,3,1,2,5,6]))),sx=sl,ax=fp;function nx({selectedProject:t,selectedSession:r,activeTab:s,setActiveTab:a,ws:n,sendMessage:o,latestMessage:i,isMobile:l,onMenuClick:m,isLoading:d,onInputFocusChange:u,onSessionActive:g,onSessionInactive:p,onSessionProcessing:x,onSessionNotProcessing:f,processingSessions:h,onReplaceTemporarySession:y,onNavigateToSession:N,onShowSettings:S,externalMessageUpdate:v}){const{preferences:b}=Aa(),{autoExpandTools:D,showRawParameters:A,showThinking:j,autoScrollToBottom:C,sendByCtrlEnter:L}=b,{currentProject:R,setCurrentProject:_}=Er(),{tasksEnabled:$,isTaskMasterInstalled:F}=qr(),I=$!==!1,{editingFile:U,editorWidth:w,editorExpanded:z,resizeHandleRef:q,handleFileOpen:ee,handleCloseEditor:M,handleToggleEditorExpand:K,handleResizeStart:T}=tx({selectedProject:t,isMobile:l});return c.useEffect(()=>{t&&t!==R&&(_==null||_(t))},[t,R,_]),c.useEffect(()=>{!I&&s==="tasks"&&a("chat")},[I,s,a]),d?e.jsx(Vn,{mode:"loading",isMobile:l,onMenuClick:m}):t?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(Np,{activeTab:s,setActiveTab:a,selectedProject:t,selectedSession:r,shouldShowTasksTab:I,isMobile:l,onMenuClick:m}),e.jsx(Yp,{}),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 ${z?"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(cs,{fallback:e.jsx(Qp,{}),children:e.jsx(qn,{showDetails:!0,children:e.jsx(up,{selectedProject:t,selectedSession:r,ws:n,sendMessage:o,latestMessage:i,onFileOpen:ee,onInputFocusChange:u,onSessionActive:g,onSessionInactive:p,onSessionProcessing:x,onSessionNotProcessing:f,processingSessions:h,onReplaceTemporarySession:y,onNavigateToSession:N,onShowSettings:S,autoExpandTools:D,showRawParameters:A,showThinking:j,autoScrollToBottom:C,sendByCtrlEnter:L,externalMessageUpdate:v,onShowAllTasks:$?()=>a("tasks"):null})})})}),s==="canvas"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(qn,{showDetails:!0,children:e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading canvas..."}),children:e.jsx(rx,{})})})}),s==="files"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(cs,{fallback:e.jsx(Zp,{}),children:e.jsx(hp,{selectedProject:t,onFileOpen:ee})})}),s==="shell"&&e.jsx("div",{className:"h-full w-full overflow-hidden",children:e.jsx(cs,{fallback:e.jsx(Xp,{}),children:e.jsx(sx,{project:t,session:r,showHeader:!1})})}),s==="git"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(cs,{fallback:e.jsx(ex,{}),children:e.jsx(ax,{selectedProject:t,isMobile:l,onFileOpen:ee})})}),I&&e.jsx(Jp,{isVisible:s==="tasks"}),e.jsx("div",{className:`h-full overflow-hidden ${s==="preview"?"block":"hidden"}`})]}),e.jsx(Rp,{editingFile:U,isMobile:l,editorExpanded:z,editorWidth:w,resizeHandleRef:q,onResizeStart:T,onCloseEditor:M,onToggleEditorExpand:K,projectPath:t.path,fillSpace:s==="files"})]})]}):e.jsx(Vn,{mode:"empty",isMobile:l,onMenuClick:m})}const ox=Ft.memo(nx);function ix({activeTab:t,setActiveTab:r,isInputFocused:s}){const{tasksEnabled:a,isTaskMasterInstalled:n}=qr(),i=[{id:"chat",icon:Ea,label:"Chat",onClick:()=>r("chat")},{id:"shell",icon:mt,label:"Shell",onClick:()=>r("shell")},{id:"files",icon:rr,label:"Files",onClick:()=>r("files")},{id:"git",icon:Ut,label:"Git",onClick:()=>r("git")},...!!(a&&n)?[{id:"tasks",icon:mo,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(l=>{const m=l.icon,d=t===l.id;return e.jsxs("button",{onClick:l.onClick,onTouchStart:u=>{u.preventDefault(),l.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":l.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(m,{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:l.label})]},l.id)})})})})}function lx(){const[t,r]=c.useState(new Set),[s,a]=c.useState(new Set),n=c.useCallback(d=>{d&&r(u=>new Set([...u,d]))},[]),o=c.useCallback(d=>{d&&r(u=>{const g=new Set(u);return g.delete(d),g})},[]),i=c.useCallback(d=>{d&&a(u=>new Set([...u,d]))},[]),l=c.useCallback(d=>{d&&a(u=>{const g=new Set(u);return g.delete(d),g})},[]),m=c.useCallback(d=>{d&&r(u=>{const g=new Set;for(const p of u)p.startsWith("new-session-")||g.add(p);return g.add(d),g})},[]);return{activeSessions:t,processingSessions:s,markSessionAsActive:n,markSessionAsInactive:o,markSessionAsProcessing:i,markSessionAsNotProcessing:l,replaceTemporarySession:m}}const yt=t=>JSON.stringify(t??null),eo=(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||yt(a.sessionMeta)!==yt(o.sessionMeta)||yt(a.sessions)!==yt(o.sessions)?!0:yt(a.cursorSessions)!==yt(o.cursorSessions)||yt(a.codexSessions)!==yt(o.codexSessions)}),Ss=t=>[...t.sessions??[],...t.codexSessions??[],...t.cursorSessions??[]],cx=(t,r,s,a)=>{if(!s||!a)return!0;const n=t.find(m=>m.name===s.name),o=r.find(m=>m.name===s.name);if(!n||!o)return!1;const i=Ss(n).find(m=>m.id===a.id),l=Ss(o).find(m=>m.id===a.id);return!i||!l?!1:i.id===l.id&&i.title===l.title&&i.created_at===l.created_at&&i.updated_at===l.updated_at};function dx({sessionId:t,navigate:r,latestMessage:s,isMobile:a,activeSessions:n}){const[o,i]=c.useState([]),[l,m]=c.useState(null),[d,u]=c.useState(null),[g,p]=c.useState("chat"),[x,f]=c.useState(!1),[h,y]=c.useState(!0),[N,S]=c.useState(null),[v,b]=c.useState(!1),[D,A]=c.useState(!1),[j,C]=c.useState("agents"),[L,R]=c.useState(0),_=c.useRef(null),$=c.useCallback(async()=>{try{y(!0);const T=await(await Ge.projects()).json();i(G=>G.length===0||eo(G,T,!0)?T:G)}catch(K){console.error("Error fetching projects:",K)}finally{y(!1)}},[]),F=c.useCallback((K="tools")=>{C(K),A(!0)},[]);c.useEffect(()=>{$()},[$]),c.useEffect(()=>{!h&&o.length===1&&!l&&!t&&m(o[0])},[h,o,l,t]),c.useEffect(()=>{if(!s)return;if(s.type==="loading_progress"){_.current&&(clearTimeout(_.current),_.current=null),S(s),s.phase==="complete"&&(_.current=setTimeout(()=>{S(null),_.current=null},500));return}if(s.type!=="projects_updated")return;const K=s;if(K.changedFile&&d&&l){const O=K.changedFile.replace(/\\/g,"/").split("/");O.length>=2&&O[O.length-1].replace(".jsonl","")===d.id&&(n.has(d.id)||R(pe=>pe+1))}const T=d&&n.has(d.id)||n.size>0&&Array.from(n).some(W=>W.startsWith("new-session-")),G=K.projects;if(T&&!cx(o,G,l,d)||(i(G),!l))return;const Y=G.find(W=>W.name===l.name);if(!Y||(yt(Y)!==yt(l)&&m(Y),!d))return;Ss(Y).find(W=>W.id===d.id)||u(null)},[s,l,d,n,o]),c.useEffect(()=>()=>{_.current&&(clearTimeout(_.current),_.current=null)},[]),c.useEffect(()=>{var T,G,Y;if(!t||o.length===0)return;const K=!d||d.id!==t;for(const J of o){const W=(T=J.sessions)==null?void 0:T.find(B=>B.id===t);if(W){const B=(l==null?void 0:l.name)!==J.name,ge=(d==null?void 0:d.id)!==t||d.__provider!=="claude";B&&m(J),ge&&u({...W,__provider:"claude"}),K&&p("chat");return}const O=(G=J.cursorSessions)==null?void 0:G.find(B=>B.id===t);if(O){const B=(l==null?void 0:l.name)!==J.name,ge=(d==null?void 0:d.id)!==t||d.__provider!=="cursor";B&&m(J),ge&&u({...O,__provider:"cursor"}),K&&p("chat");return}const se=(Y=J.codexSessions)==null?void 0:Y.find(B=>B.id===t);if(se){const B=(l==null?void 0:l.name)!==J.name,ge=(d==null?void 0:d.id)!==t||d.__provider!=="codex";B&&m(J),ge&&u({...se,__provider:"codex"}),K&&p("chat");return}}},[t,o,l==null?void 0:l.name,d==null?void 0:d.id,d==null?void 0:d.__provider]);const I=c.useCallback(K=>{m(K),u(null),r("/"),a&&f(!1)},[a,r]),U=c.useCallback(K=>{if(u(K),g!=="git"&&g!=="preview"&&p("chat"),(localStorage.getItem("selected-provider")||"claude")==="cursor"&&sessionStorage.setItem("cursorSessionId",K.id),a){const G=K.__projectName,Y=l==null?void 0:l.name;G!==Y&&f(!1)}r(`/session/${K.id}`)},[g,a,r,l==null?void 0:l.name]),w=c.useCallback(K=>{m(K),u(null),p("chat"),r("/"),a&&f(!1)},[a,r]),z=c.useCallback(K=>{(d==null?void 0:d.id)===K&&(u(null),r("/")),i(T=>T.map(G=>{var Y,J;return{...G,sessions:((Y=G.sessions)==null?void 0:Y.filter(W=>W.id!==K))??[],sessionMeta:{...G.sessionMeta,total:Math.max(0,(((J=G.sessionMeta)==null?void 0:J.total)??0)-1)}}}))},[r,d==null?void 0:d.id]),q=c.useCallback(async()=>{try{const T=await(await Ge.projects()).json();if(i(J=>eo(J,T,!0)?T:J),!l)return;const G=T.find(J=>J.name===l.name);if(!G||(yt(G)!==yt(l)&&m(G),!d))return;const Y=Ss(G).find(J=>J.id===d.id);if(Y){const J=Y.__provider||!d.__provider?Y:{...Y,__provider:d.__provider};yt(J)!==yt(d)&&u(J)}}catch(K){console.error("Error refreshing sidebar:",K)}},[l,d]),ee=c.useCallback(K=>{(l==null?void 0:l.name)===K&&(m(null),u(null),r("/")),i(T=>T.filter(G=>G.name!==K))},[r,l==null?void 0:l.name]),M=c.useMemo(()=>({projects:o,selectedProject:l,selectedSession:d,onProjectSelect:I,onSessionSelect:U,onNewSession:w,onSessionDelete:z,onProjectDelete:ee,isLoading:h,loadingProgress:N,onRefresh:q,onShowSettings:()=>A(!0),showSettings:D,settingsInitialTab:j,onCloseSettings:()=>A(!1),isMobile:a}),[w,ee,I,z,U,q,h,a,N,o,j,l,d,D]);return{projects:o,selectedProject:l,selectedSession:d,activeTab:g,sidebarOpen:x,isLoadingProjects:h,loadingProgress:N,isInputFocused:v,showSettings:D,settingsInitialTab:j,externalMessageUpdate:L,setActiveTab:p,setSidebarOpen:f,setIsInputFocused:b,setShowSettings:A,openSettings:F,fetchProjects:$,sidebarSharedProps:M,handleProjectSelect:I,handleSessionSelect:U,handleNewSession:w,handleSessionDelete:z,handleProjectDelete:ee,handleSidebarRefresh:q}}function mx(){const t=vi(),{sessionId:r}=ki(),{t:s}=He("common"),{isMobile:a}=Ia({trackPWA:!1}),{ws:n,sendMessage:o,latestMessage:i}=wi(),{activeSessions:l,processingSessions:m,markSessionAsActive:d,markSessionAsInactive:u,markSessionAsProcessing:g,markSessionAsNotProcessing:p,replaceTemporarySession:x}=lx(),{selectedProject:f,selectedSession:h,activeTab:y,sidebarOpen:N,isLoadingProjects:S,isInputFocused:v,externalMessageUpdate:b,setActiveTab:D,setSidebarOpen:A,setIsInputFocused:j,setShowSettings:C,openSettings:L,fetchProjects:R,sidebarSharedProps:_}=dx({sessionId:r,navigate:t,latestMessage:i,isMobile:a,activeSessions:l});return c.useEffect(()=>(window.refreshProjects=R,()=>{window.refreshProjects===R&&delete window.refreshProjects}),[R]),c.useEffect(()=>(window.openSettings=L,()=>{window.openSettings===L&&delete window.openSettings}),[L]),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 ${N?"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(),A(!1)},onTouchStart:$=>{$.preventDefault(),$.stopPropagation(),A(!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 ${N?"translate-x-0":"-translate-x-full"}`,onClick:$=>$.stopPropagation(),onTouchStart:$=>$.stopPropagation(),children:e.jsx(xn,{..._})})]}):e.jsx("div",{className:"h-full flex-shrink-0 border-r border-border/50",children:e.jsx(xn,{..._})}),e.jsx("div",{className:`flex-1 flex flex-col min-w-0 ${a?"pb-mobile-nav":""}`,children:e.jsx(ox,{selectedProject:f,selectedSession:h,activeTab:y,setActiveTab:D,ws:n,sendMessage:o,latestMessage:i,isMobile:a,onMenuClick:()=>A(!0),isLoading:S,onInputFocusChange:j,onSessionActive:d,onSessionInactive:u,onSessionProcessing:g,onSessionNotProcessing:p,processingSessions:m,onReplaceTemporarySession:x,onNavigateToSession:$=>t(`/session/${$}`),onShowSettings:()=>C(!0),externalMessageUpdate:b})}),a&&e.jsx(ix,{activeTab:y,setActiveTab:D,isInputFocused:v})]})}const wx=Object.freeze(Object.defineProperty({__proto__:null,default:mx},Symbol.toStringTag,{value:"Module"}));export{wx as A,jn as _,vx as a,kx as b};