wind-agent-cli 1.38.2 → 1.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +8 -1
  2. package/dist/api-docs.html +4 -3
  3. package/dist/assets/{CodeEditor-C6BtLdoC.js → CodeEditor-C8eMIGen.js} +1 -1
  4. package/dist/assets/{FileTree-CGxNFZda.js → FileTree-D52nAPO4.js} +1 -1
  5. package/dist/assets/{GitPanel-BV-IAyEC.js → GitPanel-DgeKbZsW.js} +1 -1
  6. package/dist/assets/{MarkdownPreview-DVoEzpoc.js → MarkdownPreview-B00VQTx6.js} +1 -1
  7. package/dist/assets/{Shell-CUTO-THd.js → Shell-twzi9t5B.js} +7 -7
  8. package/dist/assets/{StandaloneShell-BKM1qxUc.js → StandaloneShell-DH_GBJMj.js} +1 -1
  9. package/dist/assets/{TaskMasterPanel-DDDCVF6M.js → TaskMasterPanel-BY-pMPMl.js} +2 -2
  10. package/dist/assets/{abnfDiagram-N423BO3Z-Crubtav6.js → abnfDiagram-N423BO3Z-BwBdstkH.js} +1 -1
  11. package/dist/assets/{arc-h9xb7EWA.js → arc-C0IOpbFP.js} +1 -1
  12. package/dist/assets/{architectureDiagram-T3A2C74G-BmMQp4MC.js → architectureDiagram-T3A2C74G-C-Wkj_AY.js} +1 -1
  13. package/dist/assets/{blockDiagram-VBNYF7ZC-BtD-zDnJ.js → blockDiagram-VBNYF7ZC-_sXAZKku.js} +1 -1
  14. package/dist/assets/{c4Diagram-5PPSVZJV-D18s6J-v.js → c4Diagram-5PPSVZJV-C0DUsZv8.js} +1 -1
  15. package/dist/assets/channel-B6xiB58V.js +1 -0
  16. package/dist/assets/{chunk-2GRJ4B5K-BHIcCvB_.js → chunk-2GRJ4B5K-D2TFB_6A.js} +1 -1
  17. package/dist/assets/{chunk-2Q5K7J3B-DcX4AeRe.js → chunk-2Q5K7J3B-B_co_2bI.js} +1 -1
  18. package/dist/assets/{chunk-5RXB4S5H-CZwYDv9K.js → chunk-5RXB4S5H-BcUSLq4H.js} +1 -1
  19. package/dist/assets/{chunk-5VM5RSS4-CR-F7R13.js → chunk-5VM5RSS4-0mQFBKSp.js} +1 -1
  20. package/dist/assets/{chunk-6Q2QTUOP-BPP216SB.js → chunk-6Q2QTUOP-BAkqmW1M.js} +1 -1
  21. package/dist/assets/{chunk-GF5L2VYU-CcFeSmHe.js → chunk-GF5L2VYU-Cyz0Xl7f.js} +1 -1
  22. package/dist/assets/{chunk-JWPE2WC7-C5T_9-OI.js → chunk-JWPE2WC7-DYO47aT-.js} +1 -1
  23. package/dist/assets/{chunk-KBJHAD2P-g5eR5X5h.js → chunk-KBJHAD2P-DvXEzV8J.js} +1 -1
  24. package/dist/assets/{chunk-RYQCIY6F-76WBDsoZ.js → chunk-RYQCIY6F-Beut8dYt.js} +1 -1
  25. package/dist/assets/{chunk-XXDRQBXY-DGuy3LLn.js → chunk-XXDRQBXY-DLIy1GFl.js} +1 -1
  26. package/dist/assets/classDiagram-JCYQIIEL-C7xIPTll.js +1 -0
  27. package/dist/assets/classDiagram-v2-OCEON4UE-C7xIPTll.js +1 -0
  28. package/dist/assets/{cose-bilkent-JH36ORCC-Cg4R1M0H.js → cose-bilkent-JH36ORCC-DynbO4dj.js} +1 -1
  29. package/dist/assets/{cynefin-VYW2F7L2-Cbmals-o.js → cynefin-VYW2F7L2-CYTJsH3o.js} +1 -1
  30. package/dist/assets/{cynefinDiagram-MW4NZA55-CI79hpHc.js → cynefinDiagram-MW4NZA55-ftj-lAeE.js} +1 -1
  31. package/dist/assets/{dagre-VZM6K2ZE-r3Uz8Fhv.js → dagre-VZM6K2ZE-C1kSFboe.js} +1 -1
  32. package/dist/assets/{diagram-7IWD3JNH-ClRIkmQw.js → diagram-7IWD3JNH-CqXHTFrY.js} +1 -1
  33. package/dist/assets/{diagram-B4RE2ZJO-C71qkNlS.js → diagram-B4RE2ZJO-B84n3Zko.js} +1 -1
  34. package/dist/assets/{diagram-LBJQPF4R-CC7ShhCC.js → diagram-LBJQPF4R-B710SefS.js} +1 -1
  35. package/dist/assets/{diagram-Q27KOJAE-DPHL4vnP.js → diagram-Q27KOJAE-CmVPl9pq.js} +1 -1
  36. package/dist/assets/{diagram-UB23O5K3-CP_My5E9.js → diagram-UB23O5K3-LozbeaFL.js} +1 -1
  37. package/dist/assets/{ebnfDiagram-BXEA7PRR-BQe4AU9Z.js → ebnfDiagram-BXEA7PRR-B321UBUA.js} +1 -1
  38. package/dist/assets/{erDiagram-JOGREHBK-CFidQ-d5.js → erDiagram-JOGREHBK-CTbw676k.js} +1 -1
  39. package/dist/assets/feature-chat-pY0kOrz2.js +88 -0
  40. package/dist/assets/feature-workspace-FLomYkPq.js +39 -0
  41. package/dist/assets/{flowDiagram-UKHOOZJN-X5fPFxbp.js → flowDiagram-UKHOOZJN-BWVKTWlw.js} +1 -1
  42. package/dist/assets/{ganttDiagram-PKOTCBZU-CILFHjP8.js → ganttDiagram-PKOTCBZU-BAj9eeeX.js} +1 -1
  43. package/dist/assets/{gitGraphDiagram-DS77QQ5N-DCQCtC_g.js → gitGraphDiagram-DS77QQ5N-DcVMRU7N.js} +1 -1
  44. package/dist/assets/{index-cNARKAN2.js → index-BYFstHFT.js} +1 -1
  45. package/dist/assets/index-BbBSplOU.js +35 -0
  46. package/dist/assets/{index-D0vbG70l.js → index-BrWTp075.js} +1 -1
  47. package/dist/assets/index-CHukVVB2.css +1 -0
  48. package/dist/assets/{index-Bo9nFrtn.js → index-k9M0VaFg.js} +1 -1
  49. package/dist/assets/{infoDiagram-6WML65LV-Da145n1G.js → infoDiagram-6WML65LV-V6wz33B4.js} +1 -1
  50. package/dist/assets/{ishikawaDiagram-WSZJBQD7-DGUP61eq.js → ishikawaDiagram-WSZJBQD7-Dd-WNPyK.js} +1 -1
  51. package/dist/assets/{journeyDiagram-NVQOT4AX-BqfnKWDJ.js → journeyDiagram-NVQOT4AX-D9VCuCeA.js} +1 -1
  52. package/dist/assets/{kanban-definition-27J2QSJJ-US6pQfNy.js → kanban-definition-27J2QSJJ-CUtwDOl-.js} +1 -1
  53. package/dist/assets/{linear-d91wK5kZ.js → linear-D_XGf1jO.js} +1 -1
  54. package/dist/assets/{mermaid.core-BsWqrIaW.js → mermaid.core-DOnsXioB.js} +4 -4
  55. package/dist/assets/{mindmap-definition-FAOFIHXS-CXWD2UbS.js → mindmap-definition-FAOFIHXS-DAYNL5ZV.js} +1 -1
  56. package/dist/assets/{pegDiagram-VL7TDLO6-BVzfDR-8.js → pegDiagram-VL7TDLO6-B5FX3-E6.js} +1 -1
  57. package/dist/assets/{pieDiagram-7S7Q4E2Y-PNpHZnJ9.js → pieDiagram-7S7Q4E2Y-EbnDBVd0.js} +1 -1
  58. package/dist/assets/{quadrantDiagram-CIZ2JOQS-DxCI4i3K.js → quadrantDiagram-CIZ2JOQS-C1koOtwT.js} +1 -1
  59. package/dist/assets/{railroadDiagram-AXF67PYL-BYkvo3om.js → railroadDiagram-AXF67PYL-D52xmshj.js} +1 -1
  60. package/dist/assets/{requirementDiagram-LRYGKXZP-LUtvOYtV.js → requirementDiagram-LRYGKXZP-B7VbfNnW.js} +1 -1
  61. package/dist/assets/{sankeyDiagram-W5VNT64P-CVyI8YeM.js → sankeyDiagram-W5VNT64P-CeRG1vHN.js} +1 -1
  62. package/dist/assets/{sequenceDiagram-SI44F4Z6-1vuRFolM.js → sequenceDiagram-SI44F4Z6-CfKHnmSE.js} +1 -1
  63. package/dist/assets/{sizeCapture-X5ZJPWSS-o4oVZXe8.js → sizeCapture-X5ZJPWSS-DJTzyd0S.js} +1 -1
  64. package/dist/assets/{stateDiagram-OKZ733FA-WedLIlXF.js → stateDiagram-OKZ733FA-DN0c7IYD.js} +1 -1
  65. package/dist/assets/stateDiagram-v2-UEYNNEHI-DbihlVOQ.js +1 -0
  66. package/dist/assets/{swimlanes-SLNWSIFB-CpeXuk67.js → swimlanes-SLNWSIFB-CaaJpBDA.js} +2 -2
  67. package/dist/assets/swimlanesDiagram-ULZ7WXOC-BBRevuGP.js +8 -0
  68. package/dist/assets/{timeline-definition-Z64GVDOM-DFcPWe47.js → timeline-definition-Z64GVDOM-CrzHN7d2.js} +1 -1
  69. package/dist/assets/{vennDiagram-T6HMQDX7-BH8C1C49.js → vennDiagram-T6HMQDX7-BTldHIjo.js} +1 -1
  70. package/dist/assets/{wardleyDiagram-T6FBY63Y-K1Ew0uit.js → wardleyDiagram-T6FBY63Y-D9Y50OsZ.js} +1 -1
  71. package/dist/assets/{xychartDiagram-ELKLHX3M-CQHlqWY2.js → xychartDiagram-ELKLHX3M-DjxSJ3aF.js} +1 -1
  72. package/dist/favicon.png +0 -0
  73. package/dist/icons/icon-128x128.png +0 -0
  74. package/dist/icons/icon-144x144.png +0 -0
  75. package/dist/icons/icon-152x152.png +0 -0
  76. package/dist/icons/icon-180x180.png +0 -0
  77. package/dist/icons/icon-192x192.png +0 -0
  78. package/dist/icons/icon-384x384.png +0 -0
  79. package/dist/icons/icon-512x512.png +0 -0
  80. package/dist/icons/icon-72x72.png +0 -0
  81. package/dist/icons/icon-96x96.png +0 -0
  82. package/dist/icons/icon-maskable-192x192.png +0 -0
  83. package/dist/icons/icon-maskable-512x512.png +0 -0
  84. package/dist/icons/new.png +0 -0
  85. package/dist/index.html +4 -4
  86. package/dist/logo-128.png +0 -0
  87. package/dist/logo-256.png +0 -0
  88. package/dist/sw.js +1 -1
  89. package/dist-server/server/index.js +2 -0
  90. package/dist-server/server/index.js.map +1 -1
  91. package/dist-server/server/modules/agent/agent.routes.js +14 -2
  92. package/dist-server/server/modules/agent/agent.routes.js.map +1 -1
  93. package/dist-server/server/modules/agent/tests/agent.routes.test.js +1 -0
  94. package/dist-server/server/modules/agent/tests/agent.routes.test.js.map +1 -1
  95. package/dist-server/server/modules/commands/commands.routes.js +2 -1
  96. package/dist-server/server/modules/commands/commands.routes.js.map +1 -1
  97. package/dist-server/server/modules/database/migrations.js +43 -0
  98. package/dist-server/server/modules/database/migrations.js.map +1 -1
  99. package/dist-server/server/modules/database/tests/projects.db.integration.test.js +24 -1
  100. package/dist-server/server/modules/database/tests/projects.db.integration.test.js.map +1 -1
  101. package/dist-server/server/modules/notifications/services/notification-orchestrator.service.js +2 -0
  102. package/dist-server/server/modules/notifications/services/notification-orchestrator.service.js.map +1 -1
  103. package/dist-server/server/modules/providers/list/opencode/opencode-session-synchronizer.provider.js +10 -1
  104. package/dist-server/server/modules/providers/list/opencode/opencode-session-synchronizer.provider.js.map +1 -1
  105. package/dist-server/server/modules/providers/list/pi/index.js +5 -0
  106. package/dist-server/server/modules/providers/list/pi/index.js.map +1 -0
  107. package/dist-server/server/modules/providers/list/pi/pi-auth.provider.js +55 -0
  108. package/dist-server/server/modules/providers/list/pi/pi-auth.provider.js.map +1 -0
  109. package/dist-server/server/modules/providers/list/pi/pi-mcp.provider.js +23 -0
  110. package/dist-server/server/modules/providers/list/pi/pi-mcp.provider.js.map +1 -0
  111. package/dist-server/server/modules/providers/list/pi/pi-models.provider.js +99 -0
  112. package/dist-server/server/modules/providers/list/pi/pi-models.provider.js.map +1 -0
  113. package/dist-server/server/modules/providers/list/pi/pi-runtime.provider.js +262 -0
  114. package/dist-server/server/modules/providers/list/pi/pi-runtime.provider.js.map +1 -0
  115. package/dist-server/server/modules/providers/list/pi/pi-session-synchronizer.provider.js +136 -0
  116. package/dist-server/server/modules/providers/list/pi/pi-session-synchronizer.provider.js.map +1 -0
  117. package/dist-server/server/modules/providers/list/pi/pi-sessions.provider.js +225 -0
  118. package/dist-server/server/modules/providers/list/pi/pi-sessions.provider.js.map +1 -0
  119. package/dist-server/server/modules/providers/list/pi/pi-skills.provider.js +31 -0
  120. package/dist-server/server/modules/providers/list/pi/pi-skills.provider.js.map +1 -0
  121. package/dist-server/server/modules/providers/list/pi/pi.provider.js +22 -0
  122. package/dist-server/server/modules/providers/list/pi/pi.provider.js.map +1 -0
  123. package/dist-server/server/modules/providers/provider.registry.js +2 -0
  124. package/dist-server/server/modules/providers/provider.registry.js.map +1 -1
  125. package/dist-server/server/modules/providers/provider.routes.js +2 -1
  126. package/dist-server/server/modules/providers/provider.routes.js.map +1 -1
  127. package/dist-server/server/modules/providers/services/provider-capabilities.service.js +26 -0
  128. package/dist-server/server/modules/providers/services/provider-capabilities.service.js.map +1 -1
  129. package/dist-server/server/modules/providers/services/session-synchronizer.service.js +1 -0
  130. package/dist-server/server/modules/providers/services/session-synchronizer.service.js.map +1 -1
  131. package/dist-server/server/modules/providers/services/sessions-watcher.service.js +5 -0
  132. package/dist-server/server/modules/providers/services/sessions-watcher.service.js.map +1 -1
  133. package/dist-server/server/modules/providers/tests/mcp.test.js +4 -2
  134. package/dist-server/server/modules/providers/tests/mcp.test.js.map +1 -1
  135. package/dist-server/server/modules/providers/tests/opencode-sessions.test.js +56 -5
  136. package/dist-server/server/modules/providers/tests/opencode-sessions.test.js.map +1 -1
  137. package/dist-server/server/modules/providers/tests/pi-provider.test.js +244 -0
  138. package/dist-server/server/modules/providers/tests/pi-provider.test.js.map +1 -0
  139. package/dist-server/server/modules/providers/tests/provider-runtime.service.test.js +9 -0
  140. package/dist-server/server/modules/providers/tests/provider-runtime.service.test.js.map +1 -1
  141. package/dist-server/server/shared/utils.js +19 -0
  142. package/dist-server/server/shared/utils.js.map +1 -1
  143. package/package.json +1 -1
  144. package/public/api-docs.html +4 -3
  145. package/scripts/generate-pwa-icons.ps1 +1 -1
  146. package/server/index.ts +2 -0
  147. package/server/modules/agent/agent.module.ts +1 -1
  148. package/server/modules/agent/agent.routes.ts +15 -2
  149. package/server/modules/agent/tests/agent.routes.test.ts +1 -0
  150. package/server/modules/commands/commands.routes.ts +2 -1
  151. package/server/modules/database/migrations.ts +52 -0
  152. package/server/modules/database/tests/projects.db.integration.test.ts +28 -1
  153. package/server/modules/notifications/services/notification-orchestrator.service.js +2 -0
  154. package/server/modules/providers/README.md +5 -1
  155. package/server/modules/providers/list/opencode/opencode-session-synchronizer.provider.ts +18 -0
  156. package/server/modules/providers/list/pi/index.ts +4 -0
  157. package/server/modules/providers/list/pi/pi-auth.provider.ts +58 -0
  158. package/server/modules/providers/list/pi/pi-mcp.provider.ts +33 -0
  159. package/server/modules/providers/list/pi/pi-models.provider.ts +114 -0
  160. package/server/modules/providers/list/pi/pi-runtime.provider.ts +271 -0
  161. package/server/modules/providers/list/pi/pi-session-synchronizer.provider.ts +134 -0
  162. package/server/modules/providers/list/pi/pi-sessions.provider.ts +206 -0
  163. package/server/modules/providers/list/pi/pi-skills.provider.ts +37 -0
  164. package/server/modules/providers/list/pi/pi.provider.ts +33 -0
  165. package/server/modules/providers/provider.registry.ts +2 -0
  166. package/server/modules/providers/provider.routes.ts +1 -0
  167. package/server/modules/providers/services/provider-capabilities.service.ts +32 -0
  168. package/server/modules/providers/services/session-synchronizer.service.ts +1 -0
  169. package/server/modules/providers/services/sessions-watcher.service.ts +5 -0
  170. package/server/modules/providers/tests/mcp.test.ts +4 -2
  171. package/server/modules/providers/tests/opencode-sessions.test.ts +81 -6
  172. package/server/modules/providers/tests/pi-provider.test.ts +244 -0
  173. package/server/modules/providers/tests/provider-runtime.service.test.ts +10 -0
  174. package/server/shared/types.ts +1 -1
  175. package/server/shared/utils.ts +23 -0
  176. package/dist/assets/channel-CuR3zGvy.js +0 -1
  177. package/dist/assets/classDiagram-JCYQIIEL-BWpl-4NG.js +0 -1
  178. package/dist/assets/classDiagram-v2-OCEON4UE-BWpl-4NG.js +0 -1
  179. package/dist/assets/feature-chat-CHKsDTs-.js +0 -88
  180. package/dist/assets/feature-workspace-BodovOw6.js +0 -39
  181. package/dist/assets/index-Bn37f1jp.js +0 -35
  182. package/dist/assets/index-Cr5MbHuj.css +0 -1
  183. package/dist/assets/stateDiagram-v2-UEYNNEHI-BqzvLVVB.js +0 -1
  184. package/dist/assets/swimlanesDiagram-ULZ7WXOC-CeI6fByR.js +0 -8
  185. package/dist/icons/new-icon.png +0 -0
@@ -1,39 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/StandaloneShell-BKM1qxUc.js","assets/vendor-react-C2GTiUCy.js","assets/Shell-CUTO-THd.js","assets/vendor-ui-CAUHSABu.js","assets/vendor-i18n-B6HjLCnN.js","assets/Shell-DrlLKa8f.css","assets/vendor-data-DsEZeNPr.js","assets/vendor-markdown-DkITEES2.js"])))=>i.map(i=>d[i]);
2
- import{r as n,j as e,b as ys,c as qt}from"./vendor-react-C2GTiUCy.js";import{X as ge,P as po,S as as,T as Oe,a as xo,L as ve,C as ns,_ as ke,b as et,M as ho,c as go,B as fo,d as bo,e as yo,f as Ir,g as os,R as is,h as Ee,i as vo,F as ht,j as ft,A as Xe,k as ls,l as xr,m as jo,n as Aa,E as Rr,o as Fe,p as Ar,q as La,r as Te,s as ar,t as cs,u as Lr,v as Ma,w as Fa,G as Ft,K as hr,x as wo,y as _a,z as Oa,D as No,H as gr,I as Da,J as ds,N as Lt,O as nr,Q as ko,U as $a,Z as So,V as Co,W as Vs,Y as Mr,$ as Fr,a0 as Po,a1 as Eo,a2 as To,a3 as Io,a4 as fr,a5 as Ro,a6 as Mt,a7 as za,a8 as us,a9 as Ua,aa as Ga,ab as _r,ac as Or,ad as Ao,ae as Lo,af as or,ag as Mo,ah as Fo,ai as _o,aj as Oo,ak as Do,al as $o,am as zo,an as Uo,ao as Go}from"./vendor-ui-CAUHSABu.js";import{u as ce}from"./vendor-i18n-B6HjLCnN.js";import{p as Vo}from"./vendor-data-DsEZeNPr.js";import{M as Ko,r as Bo}from"./vendor-markdown-DkITEES2.js";const Va=n.createContext(),br=()=>{const t=n.useContext(Va);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},Em=({children:t})=>{const[s,r]=n.useState(()=>{const i=localStorage.getItem("theme");return i?i==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1});n.useEffect(()=>{if(s){document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark");const i=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');i&&i.setAttribute("content","black-translucent");const l=document.querySelector('meta[name="theme-color"]');l&&l.setAttribute("content","#141414")}else{document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light");const i=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');i&&i.setAttribute("content","default");const l=document.querySelector('meta[name="theme-color"]');l&&l.setAttribute("content","#f6f4ef")}},[s]),n.useEffect(()=>{if(!window.matchMedia)return;const i=window.matchMedia("(prefers-color-scheme: dark)"),l=c=>{localStorage.getItem("theme")||r(c.matches)};return i.addEventListener("change",l),()=>i.removeEventListener("change",l)},[]);const o={isDarkMode:s,toggleDarkMode:()=>{r(i=>!i)}};return e.jsx(Va.Provider,{value:o,children:t})},Wo={},he=Wo?.VITE_IS_PLATFORM==="true",ir="auth-token-refreshed",lr="auth-session-expired",ms=t=>typeof t=="string"&&/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(t),Ka=t=>{if(!ms(t))return null;try{const s=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=s.padEnd(s.length+(4-s.length%4)%4,"="),a=JSON.parse(atob(r));return typeof a.iat!="number"||!Number.isFinite(a.iat)||typeof a.exp!="number"||!Number.isFinite(a.exp)?null:{issuedAt:a.iat*1e3,expiresAt:a.exp*1e3}}catch{return null}},Ho=6e4,Ba=t=>{const s=Ka(t);return s?Date.now()>=s.expiresAt+Ho:!1},Dr=t=>{const s=Ka(t);if(!s)return null;const r=s.issuedAt+(s.expiresAt-s.issuedAt)/2;return Math.max(0,r-Date.now())},yr=()=>{localStorage.removeItem("auth-token"),typeof window<"u"&&window.dispatchEvent(new Event(lr))},vr=()=>{const t=localStorage.getItem("auth-token");return t&&Ba(t)?(yr(),null):t},Wa=t=>ms(t)?(localStorage.setItem("auth-token",t),typeof window<"u"&&window.dispatchEvent(new CustomEvent(ir,{detail:t})),!0):!1,z=(t,s={})=>{const r=vr(),a={};return s.body instanceof FormData||(a["Content-Type"]="application/json"),!he&&r&&(a.Authorization=`Bearer ${r}`),fetch(t,{...s,headers:{...a,...s.headers}}).then(o=>{const i=o.headers.get("X-Refreshed-Token");return i&&Wa(i),o.headers.get("X-Auth-Error")&&yr(),o})},ue={auth:{status:()=>fetch("/api/auth/status"),login:(t,s)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})}),register:(t,s)=>fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})}),refresh:()=>z("/api/auth/refresh",{method:"POST"}),user:()=>z("/api/auth/user"),logout:()=>z("/api/auth/logout",{method:"POST"})},projects:()=>z("/api/projects"),archivedProjects:()=>z("/api/projects/archived"),projectSessions:(t,{limit:s=20,offset:r=0}={})=>{const a=new URLSearchParams;return a.set("limit",String(s)),a.set("offset",String(r)),z(`/api/projects/${encodeURIComponent(t)}/sessions?${a.toString()}`)},projectTaskmaster:t=>z(`/api/projects/${encodeURIComponent(t)}/taskmaster`),unifiedSessionMessages:(t,s="claude",{limit:r=null,offset:a=0}={})=>{const o=new URLSearchParams;r!==null&&(o.append("limit",String(r)),o.append("offset",String(a)));const i=o.toString();return z(`/api/providers/sessions/${encodeURIComponent(t)}/messages${i?`?${i}`:""}`)},renameProject:(t,s)=>z(`/api/projects/${t}/rename`,{method:"PUT",body:JSON.stringify({displayName:s})}),restoreProject:t=>z(`/api/projects/${encodeURIComponent(t)}/restore`,{method:"POST"}),deleteSession:(t,s=!1)=>{const r=new URLSearchParams;s&&r.set("force","true");const a=r.toString();return z(`/api/providers/sessions/${t}${a?`?${a}`:""}`,{method:"DELETE"})},getArchivedSessions:()=>z("/api/providers/sessions/archived"),sessionDetails:t=>z(`/api/providers/sessions/${encodeURIComponent(t)}`),runningSessions:()=>z("/api/providers/sessions/running"),recentConversations:({limit:t=40,offset:s=0}={})=>{const r=new URLSearchParams({limit:String(t),offset:String(s)});return z(`/api/providers/sessions/recent?${r.toString()}`)},providerSessionId:t=>z(`/api/providers/sessions/${encodeURIComponent(t)}/provider-id`),restoreSession:t=>z(`/api/providers/sessions/${t}/restore`,{method:"POST"}),renameSession:(t,s)=>z(`/api/providers/sessions/${t}`,{method:"PUT",body:JSON.stringify({summary:s})}),deleteProject:(t,s=!1)=>{const r=new URLSearchParams;s&&r.set("force","true");const a=r.toString();return z(`/api/projects/${t}${a?`?${a}`:""}`,{method:"DELETE"})},searchConversationsUrl:(t,s=50)=>{const r=vr(),a=new URLSearchParams({q:t,limit:String(s)});return r&&a.set("token",r),`/api/providers/search/sessions?${a.toString()}`},createProject:t=>z("/api/projects/create-project",{method:"POST",body:JSON.stringify(t)}),migrateLegacyProjectStars:t=>z("/api/projects/migrate-legacy-stars",{method:"POST",body:JSON.stringify({projectIds:t})}),toggleProjectStar:t=>z(`/api/projects/${encodeURIComponent(t)}/toggle-star`,{method:"POST"}),readFile:(t,s)=>z(`/api/file-tree/projects/${t}/file?filePath=${encodeURIComponent(s)}`),readFileBlob:(t,s)=>z(`/api/file-tree/projects/${t}/files/content?path=${encodeURIComponent(s)}`),saveFile:(t,s,r)=>z(`/api/file-tree/projects/${t}/file`,{method:"PUT",body:JSON.stringify({filePath:s,content:r})}),getFiles:(t,s={})=>z(`/api/file-tree/projects/${t}/files?respectGitignore=true`,s),getMentionableFiles:(t,s={})=>z(`/api/file-tree/projects/${t}/files?respectGitignore=true`,s),createFile:(t,{path:s,type:r,name:a})=>z(`/api/file-tree/projects/${t}/files/create`,{method:"POST",body:JSON.stringify({path:s,type:r,name:a})}),renameFile:(t,{oldPath:s,newName:r})=>z(`/api/file-tree/projects/${t}/files/rename`,{method:"PUT",body:JSON.stringify({oldPath:s,newName:r})}),deleteFile:(t,{path:s,type:r})=>z(`/api/file-tree/projects/${t}/files`,{method:"DELETE",body:JSON.stringify({path:s,type:r})}),uploadFiles:(t,s)=>z(`/api/file-tree/projects/${t}/files/upload`,{method:"POST",body:s,headers:{}}),taskmaster:{init:t=>z(`/api/taskmaster/init/${t}`,{method:"POST"}),addTask:(t,{prompt:s,title:r,description:a,priority:o,dependencies:i})=>z(`/api/taskmaster/add-task/${t}`,{method:"POST",body:JSON.stringify({prompt:s,title:r,description:a,priority:o,dependencies:i})}),parsePRD:(t,{fileName:s,numTasks:r,append:a})=>z(`/api/taskmaster/parse-prd/${t}`,{method:"POST",body:JSON.stringify({fileName:s,numTasks:r,append:a})}),getTemplates:()=>z("/api/taskmaster/prd-templates"),applyTemplate:(t,{templateId:s,fileName:r,customizations:a})=>z(`/api/taskmaster/apply-template/${t}`,{method:"POST",body:JSON.stringify({templateId:s,fileName:r,customizations:a})}),updateTask:(t,s,r)=>z(`/api/taskmaster/update-task/${t}/${s}`,{method:"PUT",body:JSON.stringify(r)})},browseFilesystem:(t=null)=>{const s=new URLSearchParams;return t&&s.append("path",t),z(`/api/file-tree/browse-filesystem?${s}`)},createFolder:t=>z("/api/file-tree/create-folder",{method:"POST",body:JSON.stringify({path:t})}),user:{gitConfig:()=>z("/api/user/git-config"),updateGitConfig:(t,s)=>z("/api/user/git-config",{method:"POST",body:JSON.stringify({gitName:t,gitEmail:s})}),onboardingStatus:()=>z("/api/user/onboarding-status"),completeOnboarding:()=>z("/api/user/complete-onboarding",{method:"POST"})},get:t=>z(`/api${t}`),post:(t,s)=>z(`/api${t}`,{method:"POST",...s instanceof FormData?{body:s}:{body:JSON.stringify(s)}}),put:(t,s)=>z(`/api${t}`,{method:"PUT",body:JSON.stringify(s)}),delete:(t,s={})=>z(`/api${t}`,{method:"DELETE",...s})},Ha="auth-token",Ve={authStatusCheckFailed:"Failed to check authentication status",loginFailed:"Login failed",registrationFailed:"Registration failed",networkError:"Network error. Please try again.",sessionExpired:"Your session expired. Please log in again."};async function it(t){try{return await t.json()}catch{return null}}function $r(t,s){return t?typeof t.error=="string"?t.error:typeof t.error=="object"&&t.error!==null&&"message"in t.error&&typeof t.error.message=="string"?t.error.message:typeof t.message=="string"?t.message:s:s}const Ja=n.createContext(null),Jo=()=>localStorage.getItem(Ha),zr=t=>{Wa(t)},qo=()=>{localStorage.removeItem(Ha)};function qa(){const t=n.useContext(Ja);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t}function Tm({children:t}){const[s,r]=n.useState(null),[a,o]=n.useState(()=>Jo()),[i,l]=n.useState(!0),[c,m]=n.useState(!1),[d,u]=n.useState(!0),[x,h]=n.useState(null),p=n.useCallback((C,T)=>{r(C),o(T),zr(T)},[]),f=n.useCallback(()=>{r(null),o(null),qo()},[]),b=n.useCallback(async()=>{try{const C=await ue.user.onboardingStatus();if(!C.ok)return;const T=await it(C);u(!!T?.hasCompletedOnboarding)}catch(C){console.error("Error checking onboarding status:",C),u(!0)}},[]),g=n.useCallback(async()=>{await b()},[b]),v=n.useCallback(async()=>{if(!(he||!a||!s))try{const C=await ue.auth.refresh();if(!C.ok)return;const T=await it(C);ms(T?.token)&&(o(T.token),zr(T.token))}catch(C){console.warn("[Auth] Session refresh failed:",C)}},[a,s]);n.useEffect(()=>{const C=I=>{const j=I.detail;ms(j)&&o(j)},T=()=>{f(),h(Ve.sessionExpired)};return window.addEventListener(ir,C),window.addEventListener(lr,T),()=>{window.removeEventListener(ir,C),window.removeEventListener(lr,T)}},[f]);const S=n.useCallback(async()=>{try{l(!0),h(null);const C=await ue.auth.status();if((await it(C))?.needsSetup){m(!0);return}if(m(!1),!a)return;const I=await ue.auth.user();if(!I.ok){f();return}const j=await it(I);if(!j?.user){f();return}r(j.user),await b()}catch(C){console.error("[Auth] Auth status check failed:",C),h(Ve.authStatusCheckFailed)}finally{l(!1)}},[b,f,a]);n.useEffect(()=>{if(he){r({username:"platform-user"}),m(!1),b().finally(()=>{l(!1)});return}S()},[S,b]),n.useEffect(()=>{if(he||!a||!s)return;const C=()=>{const $=Dr(a);$!==null&&$<=0&&v()},T=()=>{document.visibilityState==="visible"&&C()},I=Dr(a),j=I===null?null:window.setTimeout(()=>{v()},I);return window.addEventListener("focus",C),document.addEventListener("visibilitychange",T),()=>{j!==null&&window.clearTimeout(j),window.removeEventListener("focus",C),document.removeEventListener("visibilitychange",T)}},[v,a,s]);const k=n.useCallback(async(C,T)=>{try{h(null);const I=await ue.auth.login(C,T),j=await it(I);if(!I.ok||!j?.token||!j.user){const $=$r(j,Ve.loginFailed);return h($),{success:!1,error:$}}return p(j.user,j.token),m(!1),await b(),{success:!0}}catch(I){return console.error("Login error:",I),h(Ve.networkError),{success:!1,error:Ve.networkError}}},[b,p]),y=n.useCallback(async(C,T)=>{try{h(null);const I=await ue.auth.register(C,T),j=await it(I);if(!I.ok||!j?.token||!j.user){const $=$r(j,Ve.registrationFailed);return h($),{success:!1,error:$}}return p(j.user,j.token),m(!1),await b(),{success:!0}}catch(I){return console.error("Registration error:",I),h(Ve.networkError),{success:!1,error:Ve.networkError}}},[b,p]),P=n.useCallback(()=>{f()},[f]),E=n.useMemo(()=>({user:s,token:a,isLoading:i,needsSetup:c,hasCompletedOnboarding:d,error:x,login:k,register:y,logout:P,refreshOnboardingStatus:g}),[x,d,i,k,P,c,g,y,a,s]);return e.jsx(Ja.Provider,{value:E,children:t})}const Qo=["claude","cursor","codex","opencode"],Yo={claude:"/api/providers/claude/auth/status",cursor:"/api/providers/cursor/auth/status",codex:"/api/providers/codex/auth/status",opencode:"/api/providers/opencode/auth/status"},Zo=(t=!0)=>({claude:{authenticated:!1,email:null,method:null,error:null,loading:t},cursor:{authenticated:!1,email:null,method:null,error:null,loading:t},codex:{authenticated:!1,email:null,method:null,error:null,loading:t},opencode:{authenticated:!1,email:null,method:null,error:null,loading:t}}),Xo="Failed to check authentication status",ei="Unknown error",ti=t=>t instanceof Error?t.message:ei,si=(t,s=null)=>({authenticated:!!t.authenticated,email:t.email??null,method:t.method??null,error:t.error??s,loading:!1});function ri({initialLoading:t=!0}={}){const[s,r]=n.useState(()=>Zo(t)),a=n.useCallback(c=>{r(m=>({...m,[c]:{...m[c],loading:!0,error:null}}))},[]),o=n.useCallback((c,m)=>{r(d=>({...d,[c]:m}))},[]),i=n.useCallback(async c=>{a(c);try{const m=await z(Yo[c]);if(!m.ok){const x={authenticated:!1,email:null,method:null,loading:!1,error:Xo};return o(c,x),x}const d=await m.json(),u=si(d.data);return o(c,u),u}catch(m){console.error(`Error checking ${c} auth status:`,m);const d={authenticated:!1,email:null,method:null,loading:!1,error:ti(m)};return o(c,d),d}},[a,o]),l=n.useCallback(async(c=Qo)=>{await Promise.all(c.map(m=>i(m)))},[i]);return{providerAuthStatus:s,setProviderAuthStatus:r,checkProviderAuthStatus:i,refreshProviderAuthStatuses:l}}const ai="modulepreload",ni=function(t){return"/"+t},Ur={},oi=function(s,r,a){let o=Promise.resolve();if(r&&r.length>0){let m=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");o=m(r.map(d=>{if(d=ni(d),d in Ur)return;Ur[d]=!0;const u=d.endsWith(".css"),x=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${x}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":ai,u||(h.as="script"),h.crossOrigin="",h.href=d,c&&h.setAttribute("nonce",c),document.head.appendChild(h),u)return new Promise((p,f)=>{h.addEventListener("load",p),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return o.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return s().catch(i)})},ii=n.lazy(()=>oi(()=>import("./StandaloneShell-BKM1qxUc.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]))),li={projectId:"default",displayName:"default",fullPath:he?"/workspace":"",path:he?"/workspace":""},ci=({provider:t,customCommand:s,isAuthenticated:r})=>s||(t==="claude"?"claude --dangerously-skip-permissions /login":t==="cursor"?"cursor-agent login":t==="codex"?he?"codex login --device-auth":"codex login":t==="opencode"?"opencode auth login":"claude --dangerously-skip-permissions /login"),di=t=>t==="claude"?"Claude CLI Login":t==="cursor"?"Cursor CLI Login":t==="codex"?"Codex CLI Login":t==="opencode"?"OpenCode CLI Login":"Claude CLI Login";function ui({isOpen:t,onClose:s,provider:r="claude",onComplete:a,customCommand:o,isAuthenticated:i=!1}){if(!t)return null;const l=ci({provider:r,customCommand:o,isAuthenticated:i}),c=di(r),m=d=>{a?.(d)};return e.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black bg-opacity-50 max-md:items-stretch max-md:justify-stretch",children:e.jsxs("div",{className:"flex h-3/4 w-full max-w-4xl flex-col rounded-lg bg-white shadow-xl dark:bg-gray-800 max-md:m-0 max-md:h-full max-md:max-w-none max-md:rounded-none md:m-4 md:h-3/4 md:max-w-4xl md:rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:c}),e.jsx("button",{onClick:s,className:"text-gray-400 transition-colors hover:text-gray-600 dark:hover:text-gray-300","aria-label":"Close login modal",children:e.jsx(ge,{className:"h-6 w-6"})})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"h-full w-full bg-gray-900"}),children:e.jsx(ii,{project:li,command:l,onComplete:m,minimal:!0})})})]})})}const mi=({className:t="w-5 h-5"})=>e.jsxs("svg",{viewBox:"0 0 512 509.64",role:"img","aria-label":"Claude",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{fill:"#D77655",d:"M115.612 0h280.775C459.974 0 512 52.026 512 115.612v278.415c0 63.587-52.026 115.612-115.613 115.612H115.612C52.026 509.639 0 457.614 0 394.027V115.612C0 52.026 52.026 0 115.612 0z"}),e.jsx("path",{fill:"#FCF2EE",fillRule:"nonzero",d:"M142.27 316.619l73.655-41.326 1.238-3.589-1.238-1.996-3.589-.001-12.31-.759-42.084-1.138-36.498-1.516-35.361-1.896-8.897-1.895-8.34-10.995.859-5.484 7.482-5.03 10.717.935 23.683 1.617 35.537 2.452 25.782 1.517 38.193 3.968h6.064l.86-2.451-2.073-1.517-1.618-1.517-36.776-24.922-39.81-26.338-20.852-15.166-11.273-7.683-5.687-7.204-2.451-15.721 10.237-11.273 13.75.935 3.513.936 13.928 10.716 29.749 23.027 38.848 28.612 5.687 4.727 2.275-1.617.278-1.138-2.553-4.271-21.13-38.193-22.546-38.848-10.035-16.101-2.654-9.655c-.935-3.968-1.617-7.304-1.617-11.374l11.652-15.823 6.445-2.073 15.545 2.073 6.547 5.687 9.655 22.092 15.646 34.78 24.265 47.291 7.103 14.028 3.791 12.992 1.416 3.968 2.449-.001v-2.275l1.997-26.641 3.69-32.707 3.589-42.084 1.239-11.854 5.863-14.206 11.652-7.683 9.099 4.348 7.482 10.716-1.036 6.926-4.449 28.915-8.72 45.294-5.687 30.331h3.313l3.792-3.791 15.342-20.372 25.782-32.227 11.374-12.789 13.27-14.129 8.517-6.724 16.1-.001 11.854 17.617-5.307 18.199-16.581 21.029-13.75 17.819-19.716 26.54-12.309 21.231 1.138 1.694 2.932-.278 44.536-9.479 24.062-4.347 28.714-4.928 12.992 6.066 1.416 6.167-5.106 12.613-30.71 7.583-36.018 7.204-53.636 12.689-.657.48.758.935 24.164 2.275 10.337.556h25.301l47.114 3.514 12.309 8.139 7.381 9.959-1.238 7.583-18.957 9.655-25.579-6.066-59.702-14.205-20.474-5.106-2.83-.001v1.694l17.061 16.682 31.266 28.233 39.152 36.397 1.997 8.999-5.03 7.102-5.307-.758-34.401-25.883-13.27-11.651-30.053-25.302-1.996-.001v2.654l6.926 10.136 36.574 54.975 1.895 16.859-2.653 5.485-9.479 3.311-10.414-1.895-21.408-30.054-22.092-33.844-17.819-30.331-2.173 1.238-10.515 113.261-4.929 5.788-11.374 4.348-9.478-7.204-5.03-11.652 5.03-23.027 6.066-30.052 4.928-23.886 4.449-29.674 2.654-9.858-.177-.657-2.173.278-22.37 30.71-34.021 45.977-26.919 28.815-6.445 2.553-11.173-5.789 1.037-10.337 6.243-9.2 37.257-47.392 22.47-29.371 14.508-16.961-.101-2.451h-.859l-98.954 64.251-17.618 2.275-7.583-7.103.936-11.652 3.589-3.791 29.749-20.474-.101.102.024.101z"})]}),pi=({className:t="w-5 h-5"})=>e.jsx("svg",{viewBox:"100 100 520 520",role:"img","aria-label":"Codex",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M304.246 294.611V249.028C304.246 245.189 305.687 242.309 309.044 240.392L400.692 187.612C413.167 180.415 428.042 177.058 443.394 177.058C500.971 177.058 537.44 221.682 537.44 269.182C537.44 272.54 537.44 276.379 536.959 280.218L441.954 224.558C436.197 221.201 430.437 221.201 424.68 224.558L304.246 294.611ZM518.245 472.145V363.224C518.245 356.505 515.364 351.707 509.608 348.349L389.174 278.296L428.519 255.743C431.877 253.826 434.757 253.826 438.115 255.743L529.762 308.523C556.154 323.879 573.905 356.505 573.905 388.171C573.905 424.636 552.315 458.225 518.245 472.141V472.145ZM275.937 376.182L236.592 353.152C233.235 351.235 231.794 348.354 231.794 344.515V238.956C231.794 187.617 271.139 148.749 324.4 148.749C344.555 148.749 363.264 155.468 379.102 167.463L284.578 222.164C278.822 225.521 275.942 230.319 275.942 237.039V376.186L275.937 376.182ZM360.626 425.122L304.246 393.455V326.283L360.626 294.616L417.002 326.283V393.455L360.626 425.122ZM396.852 570.989C376.698 570.989 357.989 564.27 342.151 552.276L436.674 497.574C442.431 494.217 445.311 489.419 445.311 482.699V343.552L485.138 366.582C488.495 368.499 489.936 371.379 489.936 375.219V480.778C489.936 532.117 450.109 570.985 396.852 570.985V570.989ZM283.134 463.99L191.486 411.211C165.094 395.854 147.343 363.229 147.343 331.562C147.343 294.616 169.415 261.509 203.48 247.593V356.991C203.48 363.71 206.361 368.508 212.117 371.866L332.074 441.437L292.729 463.99C289.372 465.907 286.491 465.907 283.134 463.99ZM277.859 542.68C223.639 542.68 183.813 501.895 183.813 451.514C183.813 447.675 184.294 443.836 184.771 439.997L279.295 494.698C285.051 498.056 290.812 498.056 296.568 494.698L417.002 425.127V470.71C417.002 474.549 415.562 477.429 412.204 479.346L320.557 532.126C308.081 539.323 293.206 542.68 277.854 542.68H277.859ZM396.852 599.776C454.911 599.776 503.37 558.513 514.41 503.812C568.149 489.896 602.696 439.515 602.696 388.176C602.696 354.587 588.303 321.962 562.392 298.45C564.791 288.373 566.231 278.296 566.231 268.224C566.231 199.611 510.571 148.267 446.274 148.267C433.322 148.267 420.846 150.184 408.37 154.505C386.775 133.392 357.026 119.958 324.4 119.958C266.342 119.958 217.883 161.22 206.843 215.921C153.104 229.837 118.557 280.218 118.557 331.557C118.557 365.146 132.95 397.771 158.861 421.283C156.462 431.36 155.022 441.437 155.022 451.51C155.022 520.123 210.682 571.466 274.978 571.466C287.931 571.466 300.407 569.549 312.883 565.228C334.473 586.341 364.222 599.776 396.852 599.776Z",fill:"currentColor"})}),xi=({className:t="w-5 h-5"})=>e.jsxs("svg",{viewBox:"0 0 24 24",role:"img","aria-label":"Cursor",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M11.925 24l10.425-6-10.425-6L1.5 18l10.425 6z",fill:"currentColor",opacity:".39"}),e.jsx("path",{d:"M22.35 18V6L11.925 0v12l10.425 6z",fill:"currentColor",opacity:".8"}),e.jsx("path",{d:"M11.925 0L1.5 6v12l10.425-6V0z",fill:"currentColor",opacity:".6"}),e.jsx("path",{d:"M22.35 6L11.925 24V12L22.35 6z",fill:"currentColor",opacity:".72"}),e.jsx("path",{d:"M22.35 6l-10.425 6L1.5 6h20.85z",fill:"currentColor",opacity:".95"})]}),hi=({className:t="w-5 h-5"})=>e.jsxs("svg",{viewBox:"0 0 24 24",role:"img","aria-label":"OpenCode",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2.5",y:"2.5",width:"19",height:"19",rx:"4",className:"fill-foreground"}),e.jsx("path",{d:"M8.1 8.1 4.9 12l3.2 3.9M15.9 8.1l3.2 3.9-3.2 3.9M13.2 6.9l-2.4 10.2",className:"stroke-background",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round"})]});function _e({provider:t="claude",className:s="w-5 h-5"}){return t==="cursor"?e.jsx(xi,{className:s}):t==="codex"?e.jsx(pi,{className:s}):t==="opencode"?e.jsx(hi,{className:s}):e.jsx(mi,{className:s})}const Qa="ui-sans-serif, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji",Ya=n.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0}),Za=()=>{const t=n.useContext(Ya);if(!t)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return t},Im=({children:t})=>{const[s,r]=n.useState(()=>{const p=localStorage.getItem("tasks-enabled");return p!==null?JSON.parse(p):!0}),[a,o]=n.useState(null),[i,l]=n.useState(null),[c,m]=n.useState(null),[d,u]=n.useState(!0);n.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(s))},[s]),n.useEffect(()=>{setTimeout(async()=>{try{const f=await ue.get("/taskmaster/installation-status");if(f.ok){const b=await f.json();m(b),o(b.installation?.isInstalled||!1),l(b.isReady||!1);const g=localStorage.getItem("tasks-enabled");!b.installation?.isInstalled&&!g&&r(!1)}else console.error("Failed to check TaskMaster installation status"),o(!1),l(!1)}catch(f){console.error("Error checking TaskMaster installation:",f),o(!1),l(!1)}finally{u(!1)}},0)},[]);const h={tasksEnabled:s,setTasksEnabled:r,toggleTasksEnabled:()=>{r(p=>!p)},isTaskMasterInstalled:a,isTaskMasterReady:i,installationStatus:c,isCheckingInstallation:d};return e.jsx(Ya.Provider,{value:h,children:t})},Xa=n.createContext(null),gi=()=>{const t=n.useContext(Xa);if(!t)throw new Error("useWebSocket must be used within a WebSocketProvider");return t},fi=t=>{const s=window.location.protocol==="https:"?"wss:":"ws:";return he?`${s}//${window.location.host}/ws`:t?Ba(t)?(yr(),null):`${s}//${window.location.host}/ws?token=${encodeURIComponent(t)}`:null},bi=()=>{const t=n.useRef(null),s=n.useRef(!1),r=n.useRef(!1),a=n.useRef(new Set),[o,i]=n.useState(null),[l,c]=n.useState(!1),m=n.useRef(null),{isLoading:d,token:u,user:x}=qa(),h=n.useCallback(v=>{for(const S of a.current)try{S(v)}catch(k){console.error("WebSocket listener error:",k)}i(v)},[]),p=n.useCallback(()=>{if(!s.current&&!(!he&&(d||!x)))try{const v=fi(u);if(!v)return console.warn("No authentication token found for WebSocket connection");const S=new WebSocket(v);t.current=S,S.onopen=()=>{c(!0),r.current&&h({kind:"websocket_reconnected",timestamp:Date.now()}),r.current=!0},S.onmessage=k=>{try{const y=JSON.parse(k.data);h(y)}catch(y){console.error("Error parsing WebSocket message:",y)}},S.onclose=()=>{t.current===S&&(c(!1),t.current=null,m.current=setTimeout(()=>{s.current||p()},3e3))},S.onerror=k=>{console.error("WebSocket error:",k)}}catch(v){console.error("Error creating WebSocket connection:",v)}},[h,d,u,x]);n.useEffect(()=>{if(s.current=!1,!(!he&&(d||!x)))return p(),()=>{s.current=!0,m.current&&clearTimeout(m.current);const v=t.current;v&&(v.onopen=null,v.onmessage=null,v.onclose=null,v.onerror=null,v.close(),t.current=null)}},[p,d,x]);const f=n.useCallback(v=>{const S=t.current;S&&S.readyState===WebSocket.OPEN?S.send(JSON.stringify(v)):console.warn("WebSocket not connected")},[]),b=n.useCallback(v=>(a.current.add(v),()=>{a.current.delete(v)}),[]);return n.useMemo(()=>({ws:t.current,sendMessage:f,subscribe:b,latestMessage:o,isConnected:l}),[f,b,o,l])},Rm=({children:t})=>{const s=bi();return e.jsx(Xa.Provider,{value:s,children:t})},en=n.createContext(null);function tn(){const t=n.useContext(en);if(!t)throw new Error("usePlugins must be used within a PluginsProvider");return t}function Am({children:t}){const[s,r]=n.useState([]),[a,o]=n.useState(!0),[i,l]=n.useState(null),c=n.useCallback(async()=>{try{const h=await z("/api/plugins");if(h.ok){const p=await h.json();r(p.plugins||[]),l(null)}else{let p=`Failed to fetch plugins (${h.status})`;try{const f=await h.json();p=f.details||f.error||p}catch{p=h.statusText||p}l(p)}}catch(h){const p=h instanceof Error?h.message:"Failed to fetch plugins";l(p),console.error("[Plugins] Failed to fetch plugins:",h)}finally{o(!1)}},[]);n.useEffect(()=>{c()},[c]);const m=n.useCallback(async h=>{try{const p=await z("/api/plugins/install",{method:"POST",body:JSON.stringify({url:h})}),f=await p.json();return p.ok?(await c(),{success:!0}):{success:!1,error:f.details||f.error||"Install failed"}}catch(p){return{success:!1,error:p instanceof Error?p.message:"Install failed"}}},[c]),d=n.useCallback(async h=>{try{const p=await z(`/api/plugins/${encodeURIComponent(h)}`,{method:"DELETE"}),f=await p.json();return p.ok?(await c(),{success:!0}):{success:!1,error:f.details||f.error||"Uninstall failed"}}catch(p){return{success:!1,error:p instanceof Error?p.message:"Uninstall failed"}}},[c]),u=n.useCallback(async h=>{try{const p=await z(`/api/plugins/${encodeURIComponent(h)}/update`,{method:"POST"}),f=await p.json();return p.ok?(await c(),{success:!0}):{success:!1,error:f.details||f.error||"Update failed"}}catch(p){return{success:!1,error:p instanceof Error?p.message:"Update failed"}}},[c]),x=n.useCallback(async(h,p)=>{try{const f=await z(`/api/plugins/${encodeURIComponent(h)}/enable`,{method:"PUT",body:JSON.stringify({enabled:p})});if(!f.ok){let b=`Toggle failed (${f.status})`;try{const g=await f.json();b=g.details||g.error||b}catch{b=f.statusText||b}return{success:!1,error:b}}return await c(),{success:!0,error:null}}catch(f){return{success:!1,error:f instanceof Error?f.message:"Toggle failed"}}},[c]);return e.jsx(en.Provider,{value:{plugins:s,loading:a,pluginsError:i,refreshPlugins:c,installPlugin:m,uninstallPlugin:d,updatePlugin:u,togglePlugin:x},children:t})}const Gr=t=>typeof window>"u"?!1:window.innerWidth<t,Vr=()=>{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 yi(t={}){const{mobileBreakpoint:s=768,trackMobile:r=!0,trackPWA:a=!0}=t,[o,i]=n.useState(()=>r?Gr(s):!1),[l,c]=n.useState(()=>a?Vr():!1);return n.useEffect(()=>{if(!r||typeof window>"u")return;const m=()=>{i(Gr(s))};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[s,r]),n.useEffect(()=>{if(!a||typeof window>"u")return;const m=window.matchMedia("(display-mode: standalone)"),d=()=>{c(Vr())};return d(),typeof m.addEventListener=="function"?(m.addEventListener("change",d),()=>{m.removeEventListener("change",d)}):(m.addListener(d),()=>{m.removeListener(d)})},[a]),{isMobile:o,isPWA:l}}const Ks="1.38.2",vi=(t,s)=>{const r=t.split(".").map(Number),a=s.split(".").map(Number);for(let o=0;o<Math.max(r.length,a.length);o++){const i=r[o]||0,l=a[o]||0;if(i!==l)return i-l}return 0},sn=(t,s)=>{const[r,a]=n.useState(!1),[o,i]=n.useState(null),[l,c]=n.useState(null),[m,d]=n.useState("git"),[u,x]=n.useState(null),[h,p]=n.useState(!1);return n.useEffect(()=>{(async()=>{try{const g=await(await fetch("/health")).json();(g.installMode==="npm"||g.installMode==="git")&&d(g.installMode),typeof g.version=="string"&&g.version.length>0&&(x(g.version),p(g.version!==Ks))}catch{}})()},[]),n.useEffect(()=>{const f=async()=>{try{const v=await(await fetch(`https://api.github.com/repos/${t}/${s}/releases/latest`)).json();if(v.tag_name){const S=v.tag_name.replace(/^v/,"");i(S),a(vi(S,Ks)>0),c({title:v.name||v.tag_name,body:v.body||"",htmlUrl:v.html_url||`https://github.com/${t}/${s}/releases/latest`,publishedAt:v.published_at})}else a(!1),i(null),c(null)}catch(g){console.error("Version check failed:",g),a(!1),i(null),c(null)}};f();const b=setInterval(f,300*1e3);return()=>clearInterval(b)},[t,s]),{updateAvailable:r,latestVersion:o,currentVersion:Ks,releaseInfo:l,installMode:m,runningVersion:u,restartRequired:h}},Ze={showRawParameters:!1,showThinking:!0,sendByCtrlEnter:!1,sidebarVisible:!0,voiceEnabled:!1},ps=Object.keys(Ze),ji=new Set(ps),Bs="ui-preferences:sync",xs=(t,s)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return s},wi=(t,s)=>{try{const r=localStorage.getItem(t);if(r===null)return s;const a=JSON.parse(r);return xs(a,s)}catch{return s}},Ni=t=>{if(typeof window>"u")return Ze;try{const s=localStorage.getItem(t);if(s){const r=JSON.parse(s);if(r&&typeof r=="object"&&!Array.isArray(r)){const a=r;return ps.reduce((o,i)=>(o[i]=xs(a[i],Ze[i]),o),{...Ze})}}}catch{}return ps.reduce((s,r)=>(s[r]=wi(r,Ze[r]),s),{...Ze})};function ki(t,s){switch(s.type){case"set":{const{key:r,value:a}=s;if(!ji.has(r))return t;const o=xs(a,t[r]);return t[r]===o?t:{...t,[r]:o}}case"set_many":{const r=s.value||{};let a=!1;const o={...t};for(const i of ps){if(!(i in r))continue;const l=r[i],c=xs(l,t[i]);o[i]!==c&&(o[i]=c,a=!0)}return a?o:t}case"reset":return{...Ze,...s.value||{}};default:return t}}function rn(t="uiPreferences"){const s=n.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,a]=n.useReducer(ki,t,Ni);return n.useEffect(()=>{typeof window>"u"||(localStorage.setItem(t,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(Bs,{detail:{storageKey:t,sourceId:s.current,value:r}})))},[r,t]),n.useEffect(()=>{if(typeof window>"u")return;const c=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 x=JSON.parse(u.newValue);c(x)}catch{}},d=u=>{const h=u.detail;!h||h.storageKey!==t||h.sourceId===s.current||c(h.value)};return window.addEventListener("storage",m),window.addEventListener(Bs,d),()=>{window.removeEventListener("storage",m),window.removeEventListener(Bs,d)}},[t]),{preferences:r,setPreference:(c,m)=>{a({type:"set",key:c,value:m})},setPreferences:c=>{a({type:"set_many",value:c})},resetPreferences:c=>{a({type:"reset",value:c})},dispatch:a}}const jr=n.createContext(null),Qt={openFile:()=>{},openFileInEditor:()=>{},openSettings:()=>{},refreshProjects:()=>{}};function Lm({children:t}){const s=n.useRef({});return e.jsx(jr.Provider,{value:s,children:t})}function an(){const t=n.useContext(jr);return n.useMemo(()=>({openFile:s=>(t?.current.openFile??Qt.openFile)(s),openFileInEditor:s=>(t?.current.openFileInEditor??Qt.openFileInEditor)(s),openSettings:s=>(t?.current.openSettings??Qt.openSettings)(s),refreshProjects:()=>(t?.current.refreshProjects??Qt.refreshProjects)()}),[t])}function Mm(t){const s=n.useContext(jr),{openFile:r,openFileInEditor:a,openSettings:o,refreshProjects:i}=t;n.useEffect(()=>{if(!s)return;const l=s.current,c={...l};return r&&(l.openFile=r),a&&(l.openFileInEditor=a),o&&(l.openSettings=o),i&&(l.refreshProjects=i),()=>{r&&l.openFile===r&&(l.openFile=c.openFile),a&&l.openFileInEditor===a&&(l.openFileInEditor=c.openFileInEditor),o&&l.openSettings===o&&(l.openSettings=c.openSettings),i&&l.refreshProjects===i&&(l.refreshProjects=c.refreshProjects)}},[s,r,a,o,i])}const Rt=(t,s)=>{if(!t)return"";const r=new Date(t);if(Number.isNaN(r.getTime()))return"";const a=Math.floor(Math.max(0,s.getTime()-r.getTime())/6e4);if(a<1)return"<1m";if(a<60)return`${a}m`;const o=Math.floor(a/60);return o<24?`${o}hr`:`${Math.floor(o/24)}d`},Si=()=>{try{const t=localStorage.getItem("claude-settings");return t&&JSON.parse(t).projectSortOrder==="date"?"date":"name"}catch{return"name"}},nn="starredProjects",Ci=()=>{try{const t=localStorage.getItem(nn);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s.map(r=>String(r).trim()).filter(r=>r.length>0):[]}catch{return[]}},Pi=()=>{try{localStorage.removeItem(nn)}catch{}},on=t=>String(t.createdAt||t.created_at||""),ln=t=>String(t.lastActivity||""),Ei=t=>{const s=t.__provider??t.provider;return typeof s=="string"&&s.trim()?s:"claude"},hs=t=>new Date(ln(t)||on(t)||0),Ti=(t,s)=>t.summary||t.name||s("projects.newSession"),Ii=t=>ln(t)||on(t),Ri=(t,s,r)=>{const a=hs(t);return{isActive:Math.floor((s.getTime()-a.getTime())/(1e3*60))<10,sessionName:Ti(t,r),sessionTime:Ii(t),messageCount:Number(t.messageCount||0)}},gs=t=>(t.sessions||[]).map(s=>({...s,__provider:Ei(s)})).sort((s,r)=>hs(r).getTime()-hs(s).getTime()),Kr=t=>{const s=gs(t);return s.length===0?new Date(0):s.reduce((r,a)=>{const o=hs(a);return o>r?o:r},new Date(0))},Ai=(t,s)=>{const r=[...t];return r.sort((a,o)=>{const i=!!a.isStarred,l=!!o.isStarred;return i&&!l?-1:!i&&l?1:s==="date"?Kr(o).getTime()-Kr(a).getTime():(a.displayName||a.projectId).localeCompare(o.displayName||o.projectId)}),r},Li=(t,s)=>{const r=s.trim().toLowerCase();return r?t.filter(a=>{const o=(a.displayName||a.projectId).toLowerCase(),i=(a.path||a.fullPath||"").toLowerCase();return o.includes(r)||i.includes(r)}):t},Mi=(t,s)=>{const r=!!t.taskmaster?.hasTaskmaster,a=!!(s?.hasMCPServer&&s?.isConfigured);return r&&a?"fully-configured":r?"taskmaster-only":a?"mcp-only":"not-configured"},Fi=t=>{const s=typeof t.fullPath=="string"&&t.fullPath.length>0?t.fullPath:typeof t.path=="string"?t.path:"";return{name:t.projectId,displayName:typeof t.displayName=="string"&&t.displayName.trim().length>0?t.displayName:t.projectId,fullPath:s,path:typeof t.path=="string"&&t.path.length>0?t.path:s}};function _i({projects:t,selectedProject:s,selectedSession:r,activeSessions:a,isLoading:o,isMobile:i,t:l,onRefresh:c,onProjectSelect:m,onSessionSelect:d,onSessionDelete:u,onLoadMoreSessions:x,onProjectDelete:h,setSidebarVisible:p,sidebarVisible:f}){const b=an(),[g,v]=n.useState(new Set),[S,k]=n.useState(null),[y,P]=n.useState(!1),[E,C]=n.useState(""),[T,I]=n.useState(new Set),[j,$]=n.useState(new Date),[G,K]=n.useState("name"),[M,X]=n.useState(!1),[H,B]=n.useState(null),[w,D]=n.useState(""),[L,O]=n.useState(""),[U,N]=n.useState(new Set),[A,ee]=n.useState(null),[V,ae]=n.useState(null),[de,te]=n.useState(!1),[q,ye]=n.useState("projects"),[se,ne]=n.useState(null),[re,Ie]=n.useState(!1),[Ss,Re]=n.useState(null),[De,Cs]=n.useState([]),[tt,Ps]=n.useState([]),[Es,_t]=n.useState(!1),[vt,Ts]=n.useState([]),[Is,Rs]=n.useState(0),[jt,As]=n.useState(!1),[Ls,Ot]=n.useState(!1),[wt,qe]=n.useState(!1),[Ms,Dt]=n.useState(!1),[Se,Fs]=n.useState(""),[$e,st]=n.useState(new Map),[_s,$t]=n.useState(new Set),Ce=n.useRef(0),rt=n.useRef(0),we=n.useRef(null),at=n.useRef(new Map),Nt=n.useRef(!1),zt=n.useRef(c),Os=!i&&!f,nt=n.useMemo(()=>new Set(a.keys()),[a]),Ds=nt.size;n.useEffect(()=>{const R=setInterval(()=>{$(new Date)},6e4);return()=>clearInterval(R)},[]),n.useEffect(()=>{I(new Set)},[t]),n.useEffect(()=>{const R=s?.projectId;R&&v(_=>{if(_.has(R))return _;const Z=new Set(_);return Z.add(R),Z})},[s?.projectId]),n.useEffect(()=>{if(t.length>0&&!o){const R=new Set;t.forEach(_=>{_.sessions&&_.sessions.length>=0&&R.add(_.projectId)}),I(R)}},[t,o]),n.useEffect(()=>{const R=()=>{K(Si())};R();const _=J=>{J.key==="claude-settings"&&R()};window.addEventListener("storage",_);const Z=setInterval(()=>{document.hasFocus()&&R()},1e3);return()=>{window.removeEventListener("storage",_),clearInterval(Z)}},[]),n.useEffect(()=>{zt.current=c},[c]);const Ne=n.useCallback(async()=>{_t(!0);try{const[R,_]=await Promise.all([ue.archivedProjects(),ue.getArchivedSessions()]);if(!R.ok)throw new Error(`Failed to load archived projects: ${R.status}`);if(!_.ok)throw new Error(`Failed to load archived sessions: ${_.status}`);const Z=await R.json(),J=await _.json(),le=Array.isArray(Z.data?.projects)?Z.data.projects:[],ie=new Set(le.map(je=>je.projectId)),fe=Array.isArray(J.data?.sessions)?J.data.sessions.filter(je=>!je.projectId||!ie.has(je.projectId)):[];Cs(le),Ps(fe)}catch(R){console.error("[Sidebar] Failed to load archived sessions:",R)}finally{_t(!1)}},[]),ze=n.useCallback(async(R,_)=>{const Z=++rt.current;_?qe(!0):Ot(!0),Dt(!1);try{const J=await ue.recentConversations({limit:40,offset:R});if(!J.ok)throw new Error(`Failed to load recent conversations: ${J.status}`);const le=await J.json(),ie=Array.isArray(le.data?.conversations)?le.data.conversations:[];if(Z!==rt.current)return;Ts(fe=>{if(!_)return ie;const je=new Set(fe.map(xe=>xe.sessionId));return[...fe,...ie.filter(xe=>!je.has(xe.sessionId))]}),Rs(Number(le.data?.total??ie.length)),As(!!le.data?.hasMore)}catch(J){if(Z!==rt.current)return;console.error("[Sidebar] Failed to load recent conversations:",J),Dt(!0)}finally{Z===rt.current&&(Ot(!1),qe(!1))}},[]),kt=n.useCallback(()=>{ze(0,!1)},[ze]),Ut=n.useCallback(()=>{wt||!jt||ze(vt.length,!0)},[ze,wt,vt.length,jt]);n.useEffect(()=>{if(Nt.current)return;const R=Ci();if(R.length===0)return;Nt.current=!0,(async()=>{try{await ue.migrateLegacyProjectStars(R),await zt.current()}catch(Z){console.error("[Sidebar] Failed to migrate legacy starred projects:",Z)}finally{Pi()}})()},[c]),n.useEffect(()=>{Ne()},[Ne]),n.useEffect(()=>{q!=="conversations"||Se.length>=2||kt()},[Se,kt,q]),n.useEffect(()=>{q==="archived"&&Ne()},[Ne,q]),n.useEffect(()=>{st(R=>{if(R.size===0)return R;const _=new Map(R);let Z=!1;for(const[J,le]of R.entries()){const ie=t.find(fe=>fe.projectId===J);if(!ie){_.delete(J),Z=!0;continue}!!ie.isStarred===le&&(_.delete(J),Z=!0)}return Z?_:R})},[t]),n.useEffect(()=>{const R=setTimeout(()=>{Fs(L.trim())},300);return()=>{clearTimeout(R)}},[L]),n.useEffect(()=>{we.current&&(we.current.close(),we.current=null);const R=Se;if(q!=="conversations"||R.length<2){Ce.current+=1,ne(null),Re(null),Ie(!1);return}Ie(!0),ne(null),Re(null);const _=++Ce.current;if(_!==Ce.current)return;const Z=ue.searchConversationsUrl(R),J=new EventSource(Z);we.current=J;const le=[];let ie=[],fe=0;return J.addEventListener("title-results",je=>{if(_!==Ce.current){J.close();return}try{const xe=JSON.parse(je.data);ie=Array.isArray(xe.titleResults)?xe.titleResults:[],ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R})}catch{}}),J.addEventListener("result",je=>{if(_!==Ce.current){J.close();return}try{const xe=JSON.parse(je.data);le.push(xe.projectResult),fe=xe.totalMatches,ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R}),Re({scannedProjects:xe.scannedProjects,totalProjects:xe.totalProjects})}catch{}}),J.addEventListener("progress",je=>{if(_!==Ce.current){J.close();return}try{const xe=JSON.parse(je.data);fe=xe.totalMatches,Re({scannedProjects:xe.scannedProjects,totalProjects:xe.totalProjects})}catch{}}),J.addEventListener("done",()=>{if(_!==Ce.current){J.close();return}J.close(),we.current=null,Ie(!1),Re(null),ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R})}),J.addEventListener("error",()=>{if(_!==Ce.current){J.close();return}J.close(),we.current=null,Ie(!1),Re(null),ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R})}),()=>{we.current&&(we.current.close(),we.current=null)}},[Se,q]);const $s=n.useCallback(R=>{v(_=>{const Z=new Set;return _.has(R)||Z.add(R),Z})},[]),Gt=n.useCallback((R,_)=>{d({...R,__projectId:_})},[d]),Ue=n.useCallback(R=>$e.has(R)?!!$e.get(R):t.some(_=>_.projectId===R&&!!_.isStarred),[$e,t]),Vt=n.useCallback(R=>{const _=Ue(R),Z=!_,J=(at.current.get(R)??0)+1;at.current.set(R,J),st(ie=>{const fe=new Map(ie);return fe.set(R,Z),fe}),(async()=>{try{const ie=await ue.toggleProjectStar(R);if(!ie.ok){const Ae=(await ie.json()).error,mo=typeof Ae=="string"?Ae:Ae&&typeof Ae=="object"&&Ae.message?Ae.message:l("messages.updateProjectError");throw new Error(mo)}const fe=await ie.json();if(!(at.current.get(R)===J))return;st(xe=>{const Ae=new Map(xe);return Ae.set(R,!!fe.isStarred),Ae})}catch(ie){if(!(at.current.get(R)===J))return;st(je=>{const xe=new Map(je);return xe.set(R,_),xe}),console.error("[Sidebar] Failed to toggle project star:",ie),alert(l("messages.updateProjectError"))}})()},[Ue,l]),zs=n.useCallback(R=>Ue(R),[Ue]),St=n.useCallback(R=>gs(R),[]),Ct=n.useCallback(async R=>{if(!x)return;let _=!1;if($t(Z=>{if(Z.has(R))return Z;_=!0;const J=new Set(Z);return J.add(R),J}),!!_)try{await x(R)}catch(Z){console.error("[Sidebar] Failed to load more sessions:",Z),alert(l("messages.refreshError"))}finally{$t(Z=>{const J=new Set(Z);return J.delete(R),J})}},[x,l]),Kt=n.useMemo(()=>$e.size===0?t:t.map(R=>{const _=$e.get(R.projectId);return _===void 0||!!R.isStarred===_?R:{...R,isStarred:_}}),[$e,t]),ot=n.useMemo(()=>Ai(Kt,G),[G,Kt]),pe=n.useMemo(()=>nt.size===0?[]:ot.reduce((R,_)=>{const Z=(_.sessions??[]).filter(le=>nt.has(String(le.id))),J=Z.length;return J===0||R.push({..._,sessions:Z,sessionMeta:{..._.sessionMeta,total:J,hasMore:!1}}),R},[]),[nt,ot]),Ge=n.useMemo(()=>Li(q==="running"?pe:ot,Se),[Se,pe,q,ot]),Pt=n.useMemo(()=>{const R=Se.trim().toLowerCase();return R?tt.filter(_=>[_.sessionTitle,_.projectDisplayName,_.projectPath??"",_.provider].some(J=>J.toLowerCase().includes(R))):tt},[tt,Se]),Et=n.useMemo(()=>{const R=Se.trim().toLowerCase();return R?De.filter(_=>[_.displayName,_.fullPath||""].some(J=>J.toLowerCase().includes(R))?!0:gs(_).some(J=>[typeof J.summary=="string"&&J.summary.trim().length>0?J.summary:typeof J.name=="string"?J.name:"",J.__provider].some(ie=>ie.toLowerCase().includes(R)))):De},[De,Se]),Us=n.useCallback(R=>{k(R.projectId),C(R.displayName)},[]),Gs=n.useCallback(()=>{k(null),C("")},[]),Qe=n.useCallback(async R=>{try{(await ue.renameProject(R,E)).ok?await b.refreshProjects():console.error("Failed to rename project")}catch(_){console.error("Error renaming project:",_)}finally{k(null),C("")}},[E,b]),Bt=n.useCallback((R,_,Z,J="claude",le={})=>{ae({projectId:R,sessionId:_,sessionTitle:Z,provider:J,isArchived:!!le.isArchived})},[]),Wt=n.useCallback(async(R=!1)=>{if(!V)return;const{sessionId:_}=V;ae(null);try{const Z=await ue.deleteSession(_,R);if(Z.ok)u?.(_),await Ne();else{const J=await Z.text();console.error("[Sidebar] Failed to delete session:",{status:Z.status,error:J}),alert(l("messages.deleteSessionFailed"))}}catch(Z){console.error("[Sidebar] Error deleting session:",Z),alert(l("messages.deleteSessionError"))}},[Ne,u,V,l]),Ht=n.useCallback(R=>{ee({project:R,sessionCount:St(R).length})},[St]),Jt=n.useCallback(async(R=!1)=>{if(!A)return;const{project:_}=A;ee(null),N(Z=>new Set([...Z,_.projectId]));try{const Z=await ue.deleteProject(_.projectId,R);if(Z.ok)h?.(_.projectId);else{const le=(await Z.json()).error,ie=typeof le=="string"?le:le&&typeof le=="object"&&le.message?le.message:l("messages.deleteProjectFailed");alert(ie)}}catch(Z){console.error("Error deleting project:",Z),alert(l("messages.deleteProjectError"))}finally{N(Z=>{const J=new Set(Z);return J.delete(_.projectId),J})}},[A,h,l]),Tt=n.useCallback(R=>{m(R)},[m]),ao=n.useCallback(R=>{const _=R.projectId?t.find(ie=>ie.projectId===R.projectId):null,Z=R.projectId?De.find(ie=>ie.projectId===R.projectId):null,J=_??Z??null,le={id:R.sessionId,summary:R.sessionTitle,__provider:R.provider,__projectId:J?.projectId??R.projectId??void 0};J&&Tt(J),d(le)},[De,Tt,d,t]),no=n.useCallback(async R=>{try{const _=await ue.restoreProject(R);if(!_.ok){const Z=await _.text();console.error("[Sidebar] Failed to restore project:",{status:_.status,error:Z}),alert(l("messages.restoreProjectFailed","Failed to restore project. Please try again."));return}await Promise.all([Promise.resolve(c()),Ne()])}catch(_){console.error("[Sidebar] Error restoring project:",_),alert(l("messages.restoreProjectError","Error restoring project. Please try again."))}},[Ne,c,l]),oo=n.useCallback(async R=>{try{const _=await ue.restoreSession(R);if(!_.ok){const Z=await _.text();console.error("[Sidebar] Failed to restore session:",{status:_.status,error:Z}),alert(l("messages.restoreSessionFailed","Failed to restore session. Please try again."));return}await Promise.all([Promise.resolve(c()),Ne()])}catch(_){console.error("[Sidebar] Error restoring session:",_),alert(l("messages.restoreSessionError","Error restoring session. Please try again."))}},[Ne,c,l]),io=n.useCallback(async()=>{X(!0);try{await Promise.all([Promise.resolve(c()),Ne(),q==="conversations"?ze(0,!1):Promise.resolve()])}finally{X(!1)}},[Ne,ze,c,q]),lo=n.useCallback(async(R,_,Z,J)=>{const le=Z.trim();if(!le){B(null),D("");return}try{const ie=await ue.renameSession(_,le);ie.ok?await c():(console.error("[Sidebar] Failed to rename session:",ie.status),alert(l("messages.renameSessionFailed")))}catch(ie){console.error("[Sidebar] Error renaming session:",ie),alert(l("messages.renameSessionError"))}finally{B(null),D("")}},[c,l]),co=n.useCallback(()=>{p(!1)},[p]),uo=n.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:Os,expandedProjects:g,editingProject:S,showNewProject:y,editingName:E,initialSessionsLoaded:T,currentTime:j,projectSortOrder:G,isRefreshing:M,editingSession:H,editingSessionName:w,searchFilter:L,deletingProjects:U,loadingMoreProjects:_s,deleteConfirmation:A,sessionDeleteConfirmation:V,showVersionModal:de,filteredProjects:Ge,runningSessionsCount:Ds,archivedProjects:Et,archivedSessions:Pt,archivedSessionsCount:De.length+tt.length,isArchivedSessionsLoading:Es,recentConversations:vt,recentConversationsTotal:Is,recentConversationsHasMore:jt,isRecentConversationsLoading:Ls,isLoadingMoreRecentConversations:wt,recentConversationsError:Ms,reloadRecentConversations:kt,loadMoreRecentConversations:Ut,toggleProject:$s,handleSessionClick:Gt,toggleStarProject:Vt,isProjectStarred:zs,getProjectSessions:St,loadMoreSessionsForProject:Ct,startEditing:Us,cancelEditing:Gs,saveProjectName:Qe,showDeleteSessionConfirmation:Bt,confirmDeleteSession:Wt,requestProjectDelete:Ht,confirmDeleteProject:Jt,handleProjectSelect:Tt,openArchivedSession:ao,restoreArchivedProject:no,restoreArchivedSession:oo,refreshProjects:io,updateSessionSummary:lo,collapseSidebar:co,expandSidebar:uo,setShowNewProject:P,setEditingName:C,setEditingSession:B,setEditingSessionName:D,searchMode:q,setSearchMode:ye,conversationResults:se,isSearching:re,searchProgress:Ss,clearConversationResults:n.useCallback(()=>{Ce.current+=1,we.current&&(we.current.close(),we.current=null),Ie(!1),Re(null),ne(null)},[]),setSearchFilter:O,setDeleteConfirmation:ee,setSessionDeleteConfirmation:ae,setShowVersionModal:te}}const cn=n.createContext(null);function Oi(t,s){return{message:s instanceof Error?s.message:`Failed to ${t}`,context:t,timestamp:new Date().toISOString()}}function Br(t){return{...t,taskMasterConfigured:t.taskmaster?.hasTaskmaster??!1,taskMasterStatus:t.taskmaster?.status??"not-configured",taskCount:Number(t.taskmaster?.metadata?.taskCount??0),completedCount:Number(t.taskmaster?.metadata?.completed??0)}}function Di(t){return t.find(s=>s.status==="pending"||s.status==="in-progress")??null}function $i(t){return t?.type?t.type.startsWith("taskmaster-"):!1}function zi(){const t=n.useContext(cn);if(!t)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return t}function Fm({children:t,project:s,onProjectTaskMasterChange:r}){const{latestMessage:a}=gi(),{user:o,token:i,isLoading:l}=qa(),[c,m]=n.useState(null),[d,u]=n.useState(null),[x,h]=n.useState(null),[p,f]=n.useState([]),[b,g]=n.useState(null),[v,S]=n.useState(!1),[k,y]=n.useState(!1),[P,E]=n.useState(!1),[C,T]=n.useState(null),I=n.useRef(null),j=n.useRef(null),$=n.useRef(0),G=n.useRef(r);G.current=r,n.useEffect(()=>{I.current=c?.projectId??null},[c?.projectId]),n.useEffect(()=>{j.current=d},[d]);const K=n.useCallback(()=>{T(null)},[]),M=n.useCallback((O,U)=>{console.error(`TaskMaster ${O} error:`,U),T(Oi(O,U))},[]),X=n.useCallback((O,U)=>{u(U),m(N=>!N||N.projectId!==O?N:Br({...N,taskmaster:U??void 0})),G.current(O,U)},[]),H=n.useCallback(async O=>{if(!O||!o||!i)return;const U=++$.current;try{const N=await ue.projectTaskmaster(O);if(!N.ok)throw new Error(`Failed to fetch TaskMaster details: ${N.status}`);const ee=(await N.json()).taskmaster??null;if(U!==$.current||I.current!==O)return;X(O,ee)}catch(N){if(U!==$.current||I.current!==O)return;M("load selected project TaskMaster info",N)}},[X,M,i,o]),B=n.useCallback(async()=>{const O=I.current;if(O){S(!0);try{await H(O)}finally{I.current===O&&S(!1)}}},[H]);n.useEffect(()=>{const O=s?Br(s):null,U=I.current,N=O?.projectId??null;I.current=N,m(O),u(O?.taskmaster??null),U!==N&&($.current+=1,f([]),g(null))},[s]),n.useEffect(()=>{s?.projectId&&o&&i&&B()},[s?.projectId,B,i,o]);const w=n.useCallback(async()=>{const O=c?.projectId;if(!O||!o||!i){f([]),g(null);return}try{y(!0),K();const U=await ue.get(`/taskmaster/tasks/${encodeURIComponent(O)}`);if(!U.ok){const ee=await U.json();throw new Error(ee.message??"Failed to load tasks")}const N=await U.json(),A=Array.isArray(N.tasks)?N.tasks:[];f(A),g(Di(A))}catch(U){M("load tasks",U),f([]),g(null)}finally{y(!1)}},[K,c?.projectId,M,i,o]),D=n.useCallback(async()=>{if(!o||!i){h(null);return}try{E(!0),K();const O=await ue.get("/taskmaster/mcp-status");if(!O.ok)throw new Error(`Failed to load MCP status: ${O.status}`);const U=await O.json();h(U)}catch(O){M("check MCP server status",O),h(null)}finally{E(!1)}},[K,M,i,o]);n.useEffect(()=>{!l&&o&&i&&D()},[l,D,i,o]),n.useEffect(()=>{c?.projectId&&o&&i&&w()},[c?.projectId,w,i,o]),n.useEffect(()=>{const O=a;if($i(O)){if(O.type==="taskmaster-project-updated"&&O.projectId){O.projectId===I.current&&H(O.projectId);return}if(O.type==="taskmaster-tasks-updated"&&O.projectId===c?.projectId){w();return}O.type==="taskmaster-mcp-status-changed"&&D()}},[c?.projectId,a,H,D,w]);const L=n.useMemo(()=>({currentProject:c,projectTaskMaster:d,mcpServerStatus:x,tasks:p,nextTask:b,isLoading:v,isLoadingTasks:k,isLoadingMCP:P,error:C,refreshProjectTaskMaster:B,refreshTasks:w,refreshMCPStatus:D,clearError:K}),[K,c,C,v,P,k,x,b,d,D,B,w,p]);return e.jsx(cn.Provider,{value:L,children:t})}function Ui({onExpand:t,onShowSettings:s,updateAvailable:r,restartRequired:a,onShowVersionModal:o,t:i}){return e.jsxs("div",{className:"flex h-full w-12 flex-col items-center gap-1 bg-background/80 py-3 backdrop-blur-sm",children:[e.jsx("button",{onClick:t,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":i("common:versionUpdate.ariaLabels.showSidebar"),title:i("common:versionUpdate.ariaLabels.showSidebar"),children:e.jsx(po,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),e.jsx("div",{className:"nav-divider my-1 w-6"}),e.jsx("button",{onClick:s,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":i("actions.settings"),title:i("actions.settings"),children:e.jsx(as,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),a&&e.jsxs("div",{className:"relative flex h-8 w-8 items-center justify-center rounded-lg","aria-label":i("version.restartRequired"),title:i("version.restartRequired"),children:[e.jsx(Oe,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-amber-500"})]}),r&&e.jsxs("button",{onClick:o,className:"relative flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":i("common:versionUpdate.ariaLabels.updateAvailable"),title:i("common:versionUpdate.ariaLabels.updateAvailable"),children:[e.jsx(xo,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]})]})}function dn(t){var s,r,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(s=0;s<o;s++)t[s]&&(r=dn(t[s]))&&(a&&(a+=" "),a+=r)}else for(r in t)t[r]&&(a&&(a+=" "),a+=r);return a}function un(){for(var t,s,r=0,a="",o=arguments.length;r<o;r++)(t=arguments[r])&&(s=dn(t))&&(a&&(a+=" "),a+=s);return a}const Wr=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Hr=un,wr=(t,s)=>r=>{var a;if(s?.variants==null)return Hr(t,r?.class,r?.className);const{variants:o,defaultVariants:i}=s,l=Object.keys(o).map(d=>{const u=r?.[d],x=i?.[d];if(u===null)return null;const h=Wr(u)||Wr(x);return o[d][h]}),c=r&&Object.entries(r).reduce((d,u)=>{let[x,h]=u;return h===void 0||(d[x]=h),d},{}),m=s==null||(a=s.compoundVariants)===null||a===void 0?void 0:a.reduce((d,u)=>{let{class:x,className:h,...p}=u;return Object.entries(p).every(f=>{let[b,g]=f;return Array.isArray(g)?g.includes({...i,...c}[b]):{...i,...c}[b]===g})?[...d,x,h]:d},[]);return Hr(t,l,m,r?.class,r?.className)},Nr="-",Gi=t=>{const s=Ki(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:l=>{const c=l.split(Nr);return c[0]===""&&c.length!==1&&c.shift(),mn(c,s)||Vi(l)},getConflictingClassGroupIds:(l,c)=>{const m=r[l]||[];return c&&a[l]?[...m,...a[l]]:m}}},mn=(t,s)=>{if(t.length===0)return s.classGroupId;const r=t[0],a=s.nextPart.get(r),o=a?mn(t.slice(1),a):void 0;if(o)return o;if(s.validators.length===0)return;const i=t.join(Nr);return s.validators.find(({validator:l})=>l(i))?.classGroupId},Jr=/^\[(.+)\]$/,Vi=t=>{if(Jr.test(t)){const s=Jr.exec(t)[1],r=s?.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},Ki=t=>{const{theme:s,classGroups:r}=t,a={nextPart:new Map,validators:[]};for(const o in r)cr(r[o],a,o,s);return a},cr=(t,s,r,a)=>{t.forEach(o=>{if(typeof o=="string"){const i=o===""?s:qr(s,o);i.classGroupId=r;return}if(typeof o=="function"){if(Bi(o)){cr(o(a),s,r,a);return}s.validators.push({validator:o,classGroupId:r});return}Object.entries(o).forEach(([i,l])=>{cr(l,qr(s,i),r,a)})})},qr=(t,s)=>{let r=t;return s.split(Nr).forEach(a=>{r.nextPart.has(a)||r.nextPart.set(a,{nextPart:new Map,validators:[]}),r=r.nextPart.get(a)}),r},Bi=t=>t.isThemeGetter,Wi=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,r=new Map,a=new Map;const o=(i,l)=>{r.set(i,l),s++,s>t&&(s=0,a=r,r=new Map)};return{get(i){let l=r.get(i);if(l!==void 0)return l;if((l=a.get(i))!==void 0)return o(i,l),l},set(i,l){r.has(i)?r.set(i,l):o(i,l)}}},dr="!",ur=":",Hi=ur.length,Ji=t=>{const{prefix:s,experimentalParseClassName:r}=t;let a=o=>{const i=[];let l=0,c=0,m=0,d;for(let f=0;f<o.length;f++){let b=o[f];if(l===0&&c===0){if(b===ur){i.push(o.slice(m,f)),m=f+Hi;continue}if(b==="/"){d=f;continue}}b==="["?l++:b==="]"?l--:b==="("?c++:b===")"&&c--}const u=i.length===0?o:o.substring(m),x=qi(u),h=x!==u,p=d&&d>m?d-m:void 0;return{modifiers:i,hasImportantModifier:h,baseClassName:x,maybePostfixModifierPosition:p}};if(s){const o=s+ur,i=a;a=l=>l.startsWith(o)?i(l.substring(o.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:l,maybePostfixModifierPosition:void 0}}if(r){const o=a;a=i=>r({className:i,parseClassName:o})}return a},qi=t=>t.endsWith(dr)?t.substring(0,t.length-1):t.startsWith(dr)?t.substring(1):t,Qi=t=>{const s=Object.fromEntries(t.orderSensitiveModifiers.map(a=>[a,!0]));return a=>{if(a.length<=1)return a;const o=[];let i=[];return a.forEach(l=>{l[0]==="["||s[l]?(o.push(...i.sort(),l),i=[]):i.push(l)}),o.push(...i.sort()),o}},Yi=t=>({cache:Wi(t.cacheSize),parseClassName:Ji(t),sortModifiers:Qi(t),...Gi(t)}),Zi=/\s+/,Xi=(t,s)=>{const{parseClassName:r,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:i}=s,l=[],c=t.trim().split(Zi);let m="";for(let d=c.length-1;d>=0;d-=1){const u=c[d],{isExternal:x,modifiers:h,hasImportantModifier:p,baseClassName:f,maybePostfixModifierPosition:b}=r(u);if(x){m=u+(m.length>0?" "+m:m);continue}let g=!!b,v=a(g?f.substring(0,b):f);if(!v){if(!g){m=u+(m.length>0?" "+m:m);continue}if(v=a(f),!v){m=u+(m.length>0?" "+m:m);continue}g=!1}const S=i(h).join(":"),k=p?S+dr:S,y=k+v;if(l.includes(y))continue;l.push(y);const P=o(v,g);for(let E=0;E<P.length;++E){const C=P[E];l.push(k+C)}m=u+(m.length>0?" "+m:m)}return m};function el(){let t=0,s,r,a="";for(;t<arguments.length;)(s=arguments[t++])&&(r=pn(s))&&(a&&(a+=" "),a+=r);return a}const pn=t=>{if(typeof t=="string")return t;let s,r="";for(let a=0;a<t.length;a++)t[a]&&(s=pn(t[a]))&&(r&&(r+=" "),r+=s);return r};function tl(t,...s){let r,a,o,i=l;function l(m){const d=s.reduce((u,x)=>x(u),t());return r=Yi(d),a=r.cache.get,o=r.cache.set,i=c,c(m)}function c(m){const d=a(m);if(d)return d;const u=Xi(m,r);return o(m,u),u}return function(){return i(el.apply(null,arguments))}}const be=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},xn=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,hn=/^\((?:(\w[\w-]*):)?(.+)\)$/i,sl=/^\d+\/\d+$/,rl=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,al=/\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$/,nl=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ol=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,il=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,lt=t=>sl.test(t),oe=t=>!!t&&!Number.isNaN(Number(t)),Ke=t=>!!t&&Number.isInteger(Number(t)),Ws=t=>t.endsWith("%")&&oe(t.slice(0,-1)),Le=t=>rl.test(t),ll=()=>!0,cl=t=>al.test(t)&&!nl.test(t),gn=()=>!1,dl=t=>ol.test(t),ul=t=>il.test(t),ml=t=>!Q(t)&&!Y(t),pl=t=>bt(t,yn,gn),Q=t=>xn.test(t),Ye=t=>bt(t,vn,cl),Hs=t=>bt(t,bl,oe),Qr=t=>bt(t,fn,gn),xl=t=>bt(t,bn,ul),Yt=t=>bt(t,jn,dl),Y=t=>hn.test(t),It=t=>yt(t,vn),hl=t=>yt(t,yl),Yr=t=>yt(t,fn),gl=t=>yt(t,yn),fl=t=>yt(t,bn),Zt=t=>yt(t,jn,!0),bt=(t,s,r)=>{const a=xn.exec(t);return a?a[1]?s(a[1]):r(a[2]):!1},yt=(t,s,r=!1)=>{const a=hn.exec(t);return a?a[1]?s(a[1]):r:!1},fn=t=>t==="position"||t==="percentage",bn=t=>t==="image"||t==="url",yn=t=>t==="length"||t==="size"||t==="bg-size",vn=t=>t==="length",bl=t=>t==="number",yl=t=>t==="family-name",jn=t=>t==="shadow",vl=()=>{const t=be("color"),s=be("font"),r=be("text"),a=be("font-weight"),o=be("tracking"),i=be("leading"),l=be("breakpoint"),c=be("container"),m=be("spacing"),d=be("radius"),u=be("shadow"),x=be("inset-shadow"),h=be("text-shadow"),p=be("drop-shadow"),f=be("blur"),b=be("perspective"),g=be("aspect"),v=be("ease"),S=be("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...y(),Y,Q],E=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],T=()=>[Y,Q,m],I=()=>[lt,"full","auto",...T()],j=()=>[Ke,"none","subgrid",Y,Q],$=()=>["auto",{span:["full",Ke,Y,Q]},Ke,Y,Q],G=()=>[Ke,"auto",Y,Q],K=()=>["auto","min","max","fr",Y,Q],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...T()],B=()=>[lt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],w=()=>[t,Y,Q],D=()=>[...y(),Yr,Qr,{position:[Y,Q]}],L=()=>["no-repeat",{repeat:["","x","y","space","round"]}],O=()=>["auto","cover","contain",gl,pl,{size:[Y,Q]}],U=()=>[Ws,It,Ye],N=()=>["","none","full",d,Y,Q],A=()=>["",oe,It,Ye],ee=()=>["solid","dashed","dotted","double"],V=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ae=()=>[oe,Ws,Yr,Qr],de=()=>["","none",f,Y,Q],te=()=>["none",oe,Y,Q],q=()=>["none",oe,Y,Q],ye=()=>[oe,Y,Q],se=()=>[lt,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Le],breakpoint:[Le],color:[ll],container:[Le],"drop-shadow":[Le],ease:["in","out","in-out"],font:[ml],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Le],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Le],shadow:[Le],spacing:["px",oe],text:[Le],"text-shadow":[Le],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",lt,Q,Y,g]}],container:["container"],columns:[{columns:[oe,Q,Y,c]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"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:P()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{start:I()}],end:[{end:I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[Ke,"auto",Y,Q]}],basis:[{basis:[lt,"full","auto",c,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[oe,lt,"auto","initial","none",Q]}],grow:[{grow:["",oe,Y,Q]}],shrink:[{shrink:["",oe,Y,Q]}],order:[{order:[Ke,"first","last","none",Y,Q]}],"grid-cols":[{"grid-cols":j()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":G()}],"col-end":[{"col-end":G()}],"grid-rows":[{"grid-rows":j()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":G()}],"row-end":[{"row-end":G()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":K()}],"auto-rows":[{"auto-rows":K()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],w:[{w:[c,"screen",...B()]}],"min-w":[{"min-w":[c,"screen","none",...B()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[l]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",r,It,Ye]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Y,Hs]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ws,Q]}],"font-family":[{font:[hl,Q,s]}],"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:[o,Y,Q]}],"line-clamp":[{"line-clamp":[oe,"none",Y,Hs]}],leading:[{leading:[i,...T()]}],"list-image":[{"list-image":["none",Y,Q]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Y,Q]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:w()}],"text-color":[{text:w()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:[oe,"from-font","auto",Y,Ye]}],"text-decoration-color":[{decoration:w()}],"underline-offset":[{"underline-offset":[oe,"auto",Y,Q]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Y,Q]}],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",Y,Q]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:D()}],"bg-repeat":[{bg:L()}],"bg-size":[{bg:O()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ke,Y,Q],radial:["",Y,Q],conic:[Ke,Y,Q]},fl,xl]}],"bg-color":[{bg:w()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:w()}],"gradient-via":[{via:w()}],"gradient-to":[{to:w()}],rounded:[{rounded:N()}],"rounded-s":[{"rounded-s":N()}],"rounded-e":[{"rounded-e":N()}],"rounded-t":[{"rounded-t":N()}],"rounded-r":[{"rounded-r":N()}],"rounded-b":[{"rounded-b":N()}],"rounded-l":[{"rounded-l":N()}],"rounded-ss":[{"rounded-ss":N()}],"rounded-se":[{"rounded-se":N()}],"rounded-ee":[{"rounded-ee":N()}],"rounded-es":[{"rounded-es":N()}],"rounded-tl":[{"rounded-tl":N()}],"rounded-tr":[{"rounded-tr":N()}],"rounded-br":[{"rounded-br":N()}],"rounded-bl":[{"rounded-bl":N()}],"border-w":[{border:A()}],"border-w-x":[{"border-x":A()}],"border-w-y":[{"border-y":A()}],"border-w-s":[{"border-s":A()}],"border-w-e":[{"border-e":A()}],"border-w-t":[{"border-t":A()}],"border-w-r":[{"border-r":A()}],"border-w-b":[{"border-b":A()}],"border-w-l":[{"border-l":A()}],"divide-x":[{"divide-x":A()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":A()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ee(),"hidden","none"]}],"divide-style":[{divide:[...ee(),"hidden","none"]}],"border-color":[{border:w()}],"border-color-x":[{"border-x":w()}],"border-color-y":[{"border-y":w()}],"border-color-s":[{"border-s":w()}],"border-color-e":[{"border-e":w()}],"border-color-t":[{"border-t":w()}],"border-color-r":[{"border-r":w()}],"border-color-b":[{"border-b":w()}],"border-color-l":[{"border-l":w()}],"divide-color":[{divide:w()}],"outline-style":[{outline:[...ee(),"none","hidden"]}],"outline-offset":[{"outline-offset":[oe,Y,Q]}],"outline-w":[{outline:["",oe,It,Ye]}],"outline-color":[{outline:w()}],shadow:[{shadow:["","none",u,Zt,Yt]}],"shadow-color":[{shadow:w()}],"inset-shadow":[{"inset-shadow":["none",x,Zt,Yt]}],"inset-shadow-color":[{"inset-shadow":w()}],"ring-w":[{ring:A()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:w()}],"ring-offset-w":[{"ring-offset":[oe,Ye]}],"ring-offset-color":[{"ring-offset":w()}],"inset-ring-w":[{"inset-ring":A()}],"inset-ring-color":[{"inset-ring":w()}],"text-shadow":[{"text-shadow":["none",h,Zt,Yt]}],"text-shadow-color":[{"text-shadow":w()}],opacity:[{opacity:[oe,Y,Q]}],"mix-blend":[{"mix-blend":[...V(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":V()}],"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":[oe]}],"mask-image-linear-from-pos":[{"mask-linear-from":ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":ae()}],"mask-image-linear-from-color":[{"mask-linear-from":w()}],"mask-image-linear-to-color":[{"mask-linear-to":w()}],"mask-image-t-from-pos":[{"mask-t-from":ae()}],"mask-image-t-to-pos":[{"mask-t-to":ae()}],"mask-image-t-from-color":[{"mask-t-from":w()}],"mask-image-t-to-color":[{"mask-t-to":w()}],"mask-image-r-from-pos":[{"mask-r-from":ae()}],"mask-image-r-to-pos":[{"mask-r-to":ae()}],"mask-image-r-from-color":[{"mask-r-from":w()}],"mask-image-r-to-color":[{"mask-r-to":w()}],"mask-image-b-from-pos":[{"mask-b-from":ae()}],"mask-image-b-to-pos":[{"mask-b-to":ae()}],"mask-image-b-from-color":[{"mask-b-from":w()}],"mask-image-b-to-color":[{"mask-b-to":w()}],"mask-image-l-from-pos":[{"mask-l-from":ae()}],"mask-image-l-to-pos":[{"mask-l-to":ae()}],"mask-image-l-from-color":[{"mask-l-from":w()}],"mask-image-l-to-color":[{"mask-l-to":w()}],"mask-image-x-from-pos":[{"mask-x-from":ae()}],"mask-image-x-to-pos":[{"mask-x-to":ae()}],"mask-image-x-from-color":[{"mask-x-from":w()}],"mask-image-x-to-color":[{"mask-x-to":w()}],"mask-image-y-from-pos":[{"mask-y-from":ae()}],"mask-image-y-to-pos":[{"mask-y-to":ae()}],"mask-image-y-from-color":[{"mask-y-from":w()}],"mask-image-y-to-color":[{"mask-y-to":w()}],"mask-image-radial":[{"mask-radial":[Y,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":ae()}],"mask-image-radial-from-color":[{"mask-radial-from":w()}],"mask-image-radial-to-color":[{"mask-radial-to":w()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":y()}],"mask-image-conic-pos":[{"mask-conic":[oe]}],"mask-image-conic-from-pos":[{"mask-conic-from":ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":ae()}],"mask-image-conic-from-color":[{"mask-conic-from":w()}],"mask-image-conic-to-color":[{"mask-conic-to":w()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:L()}],"mask-size":[{mask:O()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Y,Q]}],filter:[{filter:["","none",Y,Q]}],blur:[{blur:de()}],brightness:[{brightness:[oe,Y,Q]}],contrast:[{contrast:[oe,Y,Q]}],"drop-shadow":[{"drop-shadow":["","none",p,Zt,Yt]}],"drop-shadow-color":[{"drop-shadow":w()}],grayscale:[{grayscale:["",oe,Y,Q]}],"hue-rotate":[{"hue-rotate":[oe,Y,Q]}],invert:[{invert:["",oe,Y,Q]}],saturate:[{saturate:[oe,Y,Q]}],sepia:[{sepia:["",oe,Y,Q]}],"backdrop-filter":[{"backdrop-filter":["","none",Y,Q]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[oe,Y,Q]}],"backdrop-contrast":[{"backdrop-contrast":[oe,Y,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":["",oe,Y,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[oe,Y,Q]}],"backdrop-invert":[{"backdrop-invert":["",oe,Y,Q]}],"backdrop-opacity":[{"backdrop-opacity":[oe,Y,Q]}],"backdrop-saturate":[{"backdrop-saturate":[oe,Y,Q]}],"backdrop-sepia":[{"backdrop-sepia":["",oe,Y,Q]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Y,Q]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[oe,"initial",Y,Q]}],ease:[{ease:["linear","initial",v,Y,Q]}],delay:[{delay:[oe,Y,Q]}],animate:[{animate:["none",S,Y,Q]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Y,Q]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:q()}],"scale-x":[{"scale-x":q()}],"scale-y":[{"scale-y":q()}],"scale-z":[{"scale-z":q()}],"scale-3d":["scale-3d"],skew:[{skew:ye()}],"skew-x":[{"skew-x":ye()}],"skew-y":[{"skew-y":ye()}],transform:[{transform:[Y,Q,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:se()}],"translate-x":[{"translate-x":se()}],"translate-y":[{"translate-y":se()}],"translate-z":[{"translate-z":se()}],"translate-none":["translate-none"],accent:[{accent:w()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:w()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Y,Q]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Y,Q]}],fill:[{fill:["none",...w()]}],"stroke-w":[{stroke:[oe,It,Ye,Hs]}],stroke:[{stroke:["none",...w()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},jl=tl(vl);function F(...t){return jl(un(t))}const wl=wr("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current"}},defaultVariants:{variant:"default"}}),wn=n.forwardRef(({className:t,variant:s,...r},a)=>e.jsx("div",{ref:a,role:"alert","data-slot":"alert",className:F(wl({variant:s}),t),...r}));wn.displayName="Alert";const Nl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"alert-title",className:F("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...s}));Nl.displayName="AlertTitle";const kl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"alert-description",className:F("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...s}));kl.displayName="AlertDescription";const Nn=wr("inline-flex touch-manipulation items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90 active:bg-primary/80",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 active:bg-destructive/80",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground active:bg-accent/80",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 active:bg-secondary/70",ghost:"hover:bg-accent hover:text-accent-foreground active:bg-accent/80",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3 text-sm",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),W=n.forwardRef(({className:t,variant:s,size:r,...a},o)=>e.jsx("button",{className:F(Nn({variant:s,size:r,className:t})),ref:o,...a}));W.displayName="Button";function kn({label:t,items:s,icon:r,ariaLabel:a,align:o="right",variant:i="outline",size:l="sm",className:c,triggerClassName:m,menuClassName:d,disabled:u,iconOnly:x=!1,portal:h=!1,header:p,onOpenChange:f}){const[b,g]=n.useState(!1),[v,S]=n.useState(null),k=n.useRef(null),y=n.useRef(null),P=n.useRef(null),E=n.useRef(!1),C=n.useRef(!1),T=n.useRef(!1),I=n.useId(),j=n.useCallback(M=>{g(M),M||S(null),f?.(M)},[f]);n.useEffect(()=>{if(!b)return;const M=H=>{const B=H.target;k.current&&!k.current.contains(B)&&!P.current?.contains(B)&&j(!1)},X=H=>{H.key==="Escape"&&(E.current=!0,j(!1))};return document.addEventListener("mousedown",M),document.addEventListener("keydown",X),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",X)}},[b,j]),n.useEffect(()=>{if(!b||!h)return;const M=()=>j(!1);return window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[b,h,j]),n.useEffect(()=>{if(b){if(T.current=!0,C.current){const M=P.current;(M?.querySelector('[role="menuitem"]:not([disabled])')??M)?.focus()}return}T.current&&(T.current=!1,E.current&&y.current?.focus(),E.current=!1)},[b]);const $=M=>{M.disabled||M.loading||(M.closeOnSelect!==!1&&(E.current=!0,j(!1)),M.onSelect())},G=()=>{if(b){j(!1);return}if(h&&y.current){const M=y.current.getBoundingClientRect(),X=260,H=(p?52:0)+s.reduce((B,w)=>B+(w.description?58:40)+(w.showDividerBefore?9:0),12);S({top:M.bottom+6+H<=window.innerHeight-8?M.bottom+6:Math.max(8,M.top-H-6),left:Math.max(8,Math.min(M.right-X,window.innerWidth-X-8))})}j(!0)},K=b&&(!h||v)&&e.jsxs("div",{ref:P,id:I,role:"menu",tabIndex:-1,className:F(h?"fixed z-[70]":"absolute top-full z-50 mt-2","min-w-[220px] rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lg","animate-in fade-in-0 zoom-in-95",!h&&(o==="right"?"right-0":"left-0"),d),style:h&&v?v:void 0,children:[p,s.map(M=>{const X=M.icon;return e.jsxs(n.Fragment,{children:[M.showDividerBefore&&e.jsx("div",{className:"mx-2 my-1 h-px bg-border"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:M.disabled||M.loading,onClick:()=>$(M),className:F("flex w-full items-start gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors","focus:outline-none focus-visible:bg-accent",M.disabled||M.loading?"cursor-not-allowed opacity-50":M.isDanger?"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950":"hover:bg-accent"),children:[M.loading?e.jsx(ve,{className:"mt-0.5 h-4 w-4 flex-shrink-0 animate-spin"}):X&&e.jsx(X,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-medium leading-5",children:M.label}),M.description&&e.jsx("span",{className:"mt-0.5 block text-xs leading-4 text-muted-foreground",children:M.description})]})]})]},M.key)})]});return e.jsxs("div",{ref:k,className:F("relative inline-flex",c),children:[e.jsxs(W,{ref:y,type:"button",variant:i,size:l,className:m,disabled:u,"aria-label":a||t,"aria-haspopup":"menu","aria-expanded":b,"aria-controls":b?I:void 0,onClick:M=>{C.current=M.detail===0,G()},children:[r&&e.jsx(r,{className:"h-4 w-4"}),!x&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:t}),e.jsx(ns,{className:F("h-4 w-4 transition-transform",b&&"rotate-180")})]})]}),h&&typeof document<"u"?ys.createPortal(K,document.body):K]})}const Sl=wr("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 Pe({className:t,variant:s,...r}){return e.jsx("div",{className:F(Sl({variant:s}),t),...r})}const Sn=n.createContext(null),Cn=()=>{const t=n.useContext(Sn);if(!t)throw new Error("Confirmation components must be used within Confirmation");return t},Cl=({className:t,approval:s="pending",children:r,...a})=>{const o=n.useMemo(()=>({approval:s}),[s]);return e.jsx(Sn.Provider,{value:o,children:e.jsx(wn,{className:F("flex flex-col gap-2",t),...a,children:r})})};Cl.displayName="Confirmation";const Pl=({className:t,...s})=>e.jsx("div",{"data-slot":"confirmation-title",className:F("text-muted-foreground inline text-sm",t),...s});Pl.displayName="ConfirmationTitle";const El=({children:t})=>{const{approval:s}=Cn();return s!=="pending"?null:e.jsx(e.Fragment,{children:t})};El.displayName="ConfirmationRequest";const Tl=({className:t,...s})=>{const{approval:r}=Cn();return r!=="pending"?null:e.jsx("div",{"data-slot":"confirmation-actions",className:F("flex items-center justify-end gap-2 self-end",t),...s})};Tl.displayName="ConfirmationActions";const Il=({variant:t="default",...s})=>e.jsx(W,{className:"h-8 px-3 text-sm",variant:t,type:"button",...s});Il.displayName="ConfirmationAction";const Rl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("rounded-xl border bg-card text-card-foreground shadow-sm",t),...s}));Rl.displayName="Card";const Al=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("flex flex-col space-y-1.5 p-4",t),...s}));Al.displayName="CardHeader";const Ll=n.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:F("font-semibold leading-none tracking-tight",t),...s}));Ll.displayName="CardTitle";const Ml=n.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:F("text-sm text-muted-foreground",t),...s}));Ml.displayName="CardDescription";const Fl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("p-4 pt-0",t),...s}));Fl.displayName="CardContent";const _l=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("flex items-center p-4 pt-0",t),...s}));_l.displayName="CardFooter";const Ol=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("ml-auto shrink-0",t),...s}));Ol.displayName="CardAction";const Pn=n.createContext(null);function En(){const t=n.useContext(Pn);if(!t)throw new Error("Collapsible components must be used within <Collapsible>");return t}const Tn=n.forwardRef(({defaultOpen:t=!1,open:s,onOpenChange:r,className:a,children:o,...i},l)=>{const[c,m]=n.useState(t),d=s!==void 0,u=d?s:c,x=n.useCallback(p=>{d||m(p),r?.(p)},[d,r]),h=n.useMemo(()=>({open:u,onOpenChange:x}),[u,x]);return e.jsx(Pn.Provider,{value:h,children:e.jsx("div",{ref:l,"data-state":u?"open":"closed",className:a,...i,children:o})})});Tn.displayName="Collapsible";const In=n.forwardRef(({onClick:t,children:s,className:r,...a},o)=>{const{open:i,onOpenChange:l}=En(),c=n.useCallback(m=>{l(!i),t?.(m)},[i,l,t]);return e.jsx("button",{ref:o,type:"button","aria-expanded":i,"data-state":i?"open":"closed",onClick:c,className:r,...a,children:s})});In.displayName="CollapsibleTrigger";const Rn=n.forwardRef(({className:t,children:s,...r},a)=>{const{open:o}=En();return e.jsx("div",{ref:a,"data-state":o?"open":"closed",className:F("grid transition-[grid-template-rows] duration-200 ease-out",o?"grid-rows-[1fr]":"grid-rows-[0fr]",t),...r,children:e.jsx("div",{className:"overflow-hidden",children:s})})});Rn.displayName="CollapsibleContent";const Dl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke,{ref:r,className:F("flex flex-col",t),...s}));Dl.displayName=ke.displayName;const $l=n.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3",children:[e.jsx(et,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),e.jsx(ke.Input,{ref:r,className:F("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));$l.displayName=ke.Input.displayName;const zl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.List,{ref:r,className:F("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));zl.displayName=ke.List.displayName;const Ul=n.forwardRef((t,s)=>e.jsx(ke.Empty,{ref:s,className:"py-6 text-center text-sm text-muted-foreground",...t}));Ul.displayName=ke.Empty.displayName;const Gl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.Group,{ref:r,className:F("overflow-hidden p-1 text-foreground","[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));Gl.displayName=ke.Group.displayName;const Vl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.Item,{ref:r,className:F("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none","data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground","data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",t),...s}));Vl.displayName=ke.Item.displayName;const Kl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.Separator,{ref:r,className:F("-mx-1 h-px bg-border",t),...s}));Kl.displayName=ke.Separator.displayName;function Bl({checked:t,onToggle:s,ariaLabel:r="Toggle dark mode"}){const{isDarkMode:a,toggleDarkMode:o}=br(),i=typeof t=="boolean"&&typeof s=="function",l=i?t:a,c=()=>{if(i&&s){s(!l);return}o()};return e.jsxs("button",{onClick:c,className:F("relative inline-flex h-7 w-12 flex-shrink-0 touch-manipulation cursor-pointer items-center rounded-full border-2 transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",l?"border-primary bg-primary":"border-border bg-muted"),role:"switch","aria-checked":l,"aria-label":r,children:[e.jsx("span",{className:"sr-only",children:r}),e.jsx("span",{className:F("flex h-5 w-5 transform items-center justify-center rounded-full shadow-sm transition-transform duration-200",l?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80"),children:l?e.jsx(ho,{className:"h-3 w-3 text-primary"}):e.jsx(go,{className:"h-3 w-3 text-white dark:text-background"})})]})}const An=n.createContext(null);function Ln(){const t=n.useContext(An);if(!t)throw new Error("Dialog components must be used within <Dialog>");return t}const Mn=({open:t,onOpenChange:s,defaultOpen:r=!1,children:a})=>{const[o,i]=n.useState(r),l=n.useRef(null),c=t!==void 0,m=c?t:o,d=n.useCallback(x=>{c||i(x),s?.(x)},[c,s]),u=n.useMemo(()=>({open:m,onOpenChange:d,triggerRef:l}),[m,d]);return e.jsx(An.Provider,{value:u,children:a})},Wl=n.forwardRef(({onClick:t,children:s,asChild:r,...a},o)=>{const{onOpenChange:i,triggerRef:l}=Ln(),c=n.useCallback(m=>{i(!0),t?.(m)},[i,t]);if(r&&n.isValidElement(s)){const m=s;return n.cloneElement(m,{onClick:d=>{i(!0),m.props.onClick?.(d)},ref:d=>{l.current=d,typeof o=="function"?o(d):o&&(o.current=d)}})}return e.jsx("button",{ref:m=>{l.current=m,typeof o=="function"?o(m):o&&(o.current=m)},type:"button",onClick:c,...a,children:s})});Wl.displayName="DialogTrigger";const Zr='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',kr=n.forwardRef(({className:t,children:s,onEscapeKeyDown:r,onPointerDownOutside:a,wrapperClassName:o,animationClassName:i,...l},c)=>{const{open:m,onOpenChange:d,triggerRef:u}=Ln(),x=n.useRef(null),h=n.useRef(null);return n.useEffect(()=>{m?h.current=document.activeElement:h.current&&((u.current||h.current)?.focus(),h.current=null)},[m,u]),n.useEffect(()=>{if(!m)return;const p=b=>{if(b.key==="Escape"){b.stopPropagation(),r?.(),d(!1);return}if(b.key==="Tab"&&x.current){const g=Array.from(x.current.querySelectorAll(Zr));if(g.length===0)return;const v=g[0],S=g[g.length-1];b.shiftKey&&document.activeElement===v?(b.preventDefault(),S.focus()):!b.shiftKey&&document.activeElement===S&&(b.preventDefault(),v.focus())}};document.addEventListener("keydown",p,!0);const f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p,!0),document.body.style.overflow=f}},[m,d,r]),n.useEffect(()=>{m&&x.current&&requestAnimationFrame(()=>{x.current?.querySelector(Zr)?.focus()})},[m]),m?ys.createPortal(e.jsxs("div",{className:F("fixed inset-0 z-50",o),children:[e.jsx("div",{className:"fixed inset-0 animate-dialog-overlay-show bg-black/50 backdrop-blur-sm",onClick:()=>{a?.(),d(!1)},"aria-hidden":!0}),e.jsx("div",{ref:p=>{x.current=p,typeof c=="function"?c(p):c&&(c.current=p)},role:"dialog","aria-modal":"true",className:F("fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2","rounded-xl border bg-popover text-popover-foreground shadow-lg",i??"animate-dialog-content-show",t),...l,children:s})]}),document.body):null});kr.displayName="DialogContent";const Sr=n.forwardRef(({className:t,...s},r)=>e.jsx("h2",{ref:r,className:F("sr-only",t),...s}));Sr.displayName="DialogTitle";const me=n.forwardRef(({className:t,type:s,...r},a)=>e.jsx("input",{type:s,className:F("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,...r}));me.displayName="Input";const Fn=n.forwardRef(({className:t,children:s,...r},a)=>e.jsx("div",{className:F(t,"relative overflow-hidden"),...r,children:e.jsx("div",{ref:a,className:"h-full w-full overflow-auto rounded-[inherit]",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:s})}));Fn.displayName="ScrollArea";const _n=n.memo(({children:t,className:s,as:r="span"})=>e.jsx(r,{className:F("animate-shimmer inline-block bg-[length:250%_100%] bg-clip-text text-transparent","bg-[linear-gradient(90deg,transparent_33%,hsl(var(--foreground))_50%,transparent_67%),linear-gradient(hsl(var(--muted-foreground)),hsl(var(--muted-foreground)))]",s),children:t}));_n.displayName="Shimmer";const On=n.createContext(null),Hl=()=>{const t=n.useContext(On);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Jl=1e3,ql=1e3,Ql=n.memo(({className:t,isStreaming:s=!1,open:r,defaultOpen:a,onOpenChange:o,duration:i,children:l,...c})=>{const m=a??s,d=a===!1,[u,x]=n.useState(m),h=r!==void 0,p=h?r:u,f=n.useCallback(E=>{h||x(E),o?.(E)},[h,o]),[b,g]=n.useState(i),v=n.useRef(s),[S,k]=n.useState(!1),y=n.useRef(null);n.useEffect(()=>{i!==void 0&&g(i)},[i]),n.useEffect(()=>{s?(v.current=!0,y.current===null&&(y.current=Date.now())):y.current!==null&&(g(Math.ceil((Date.now()-y.current)/ql)),y.current=null)},[s]),n.useEffect(()=>{s&&!p&&!d&&f(!0)},[s,p,f,d]),n.useEffect(()=>{if(v.current&&!s&&p&&!S){const E=setTimeout(()=>{f(!1),k(!0)},Jl);return()=>clearTimeout(E)}},[s,p,f,S]);const P=n.useMemo(()=>({duration:b,isOpen:p,isStreaming:s,setIsOpen:f}),[b,p,s,f]);return e.jsx(On.Provider,{value:P,children:e.jsx(Tn,{open:p,onOpenChange:f,className:F("not-prose",t),...c,children:l})})});Ql.displayName="Reasoning";const Yl=(t,s)=>t||s===0?e.jsx(_n,{children:"Thinking..."}):s===void 0?e.jsx("p",{children:"Thought for a few seconds"}):e.jsxs("p",{children:["Thought for ",s," seconds"]}),Zl=n.memo(({className:t,children:s,getThinkingMessage:r=Yl,...a})=>{const{isStreaming:o,isOpen:i,duration:l}=Hl();return e.jsx(In,{className:F("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",t),...a,children:s??e.jsxs(e.Fragment,{children:[e.jsx(fo,{className:"h-4 w-4"}),r(o,l),e.jsx(ns,{className:F("h-4 w-4 transition-transform",i?"rotate-180":"rotate-0")})]})})});Zl.displayName="ReasoningTrigger";const Xl=n.memo(({className:t,children:s,...r})=>e.jsx(Rn,{className:F("mt-4 text-sm text-muted-foreground",t),...r,children:s}));Xl.displayName="ReasoningContent";function ec(t){switch(t){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}}function He({children:t,content:s,position:r="top",className:a="",delay:o=350}){const[i,l]=n.useState(!1),c=n.useRef(null),m=n.useRef(!1),d=n.useRef(null),u=n.useRef(null),[x,h]=n.useState(null),p=n.useCallback(()=>{const k=d.current;if(!k)return;const y=k.getBoundingClientRect(),P=8,E={position:"fixed",zIndex:9999};switch(r){case"bottom":E.left=y.left+y.width/2,E.top=y.bottom+P,E.transform="translateX(-50%)";break;case"left":E.left=y.left-P,E.top=y.top+y.height/2,E.transform="translate(-100%, -50%)";break;case"right":E.left=y.right+P,E.top=y.top+y.height/2,E.transform="translateY(-50%)";break;default:E.left=y.left+y.width/2,E.top=y.top-P,E.transform="translate(-50%, -100%)";break}h(E)},[r]),f=()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},b=()=>{f(),c.current=window.setTimeout(()=>{l(!0)},o)},g=()=>{f(),l(!1)},v=()=>{f(),m.current=!1,c.current=window.setTimeout(()=>{m.current=!0,l(!0)},o)},S=()=>{f(),!m.current&&l(!1)};return n.useEffect(()=>()=>{f()},[]),n.useEffect(()=>{if(!i||typeof document>"u")return;const k=y=>{const P=y.target;P instanceof Node&&d.current?.contains(P)||(l(!1),m.current=!1)};return document.addEventListener("pointerdown",k,!0),()=>document.removeEventListener("pointerdown",k,!0)},[i]),n.useEffect(()=>{if(!i){h(null);return}const k=window.requestAnimationFrame(p),y=()=>p();return window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),()=>{window.cancelAnimationFrame(k),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[i,p]),s?e.jsxs("div",{ref:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:g,onTouchStart:v,onTouchEnd:S,onTouchCancel:S,children:[t,i&&typeof document<"u"&&ys.createPortal(e.jsxs("div",{ref:u,style:x||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:F("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",a),children:[s,e.jsx("div",{className:F("absolute w-0 h-0 border-4 border-transparent",ec(r))})]}),document.body)]}):e.jsx(e.Fragment,{children:t})}const Dn=n.createContext(null),tc=n.forwardRef(({className:t,status:s="ready",children:r,...a},o)=>{const i=n.useMemo(()=>({status:s}),[s]);return e.jsx(Dn.Provider,{value:i,children:e.jsx("form",{ref:o,"data-slot":"prompt-input",className:F("relative overflow-hidden rounded-xl border border-border/50 bg-card/80 shadow-sm backdrop-blur-sm transition-all duration-200 focus-within:border-primary/30 focus-within:shadow-md focus-within:ring-1 focus-within:ring-primary/15",t),...a,children:r})})});tc.displayName="PromptInput";const sc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-header",className:F("px-3 pt-3",t),...s}));sc.displayName="PromptInputHeader";const rc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-body",className:F("relative",t),...s}));rc.displayName="PromptInputBody";const ac=n.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{ref:r,"data-slot":"prompt-input-textarea",className:F("chat-input-placeholder block max-h-[40vh] w-full resize-none overflow-y-auto bg-transparent px-4 py-2 text-sm leading-6 text-foreground placeholder-muted-foreground/50 focus:outline-none sm:max-h-[300px]",t),...s}));ac.displayName="PromptInputTextarea";const nc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-footer",className:F("flex items-center justify-between border-t border-border/30 px-3 py-2",t),...s}));nc.displayName="PromptInputFooter";const oc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-tools",className:F("flex items-center gap-1",t),...s}));oc.displayName="PromptInputTools";const ic=n.forwardRef(({className:t,tooltip:s,children:r,...a},o)=>{const i=e.jsx(W,{ref:o,type:"button",variant:"ghost",size:"icon",className:F("h-8 w-8 [&_svg]:size-4",t),...a,children:r});return s?e.jsx(He,{content:s.shortcut?e.jsxs("span",{className:"flex items-center gap-1.5",children:[s.content,e.jsx("kbd",{className:"rounded bg-white/20 px-1 text-[10px]",children:s.shortcut})]}):s.content,position:s.side??"top",children:i}):i});ic.displayName="PromptInputButton";const lc=n.forwardRef(({className:t,status:s,children:r,...a},o)=>{const i=n.useContext(Dn),l=s??i?.status??"ready",c=l==="submitted"||l==="streaming";return e.jsx(W,{ref:o,type:c?"button":"submit",variant:"default",size:"icon",className:F("h-8 w-8 shrink-0 rounded-lg",t),...a,children:r??(c?e.jsx(bo,{className:"h-3.5 w-3.5 fill-current"}):e.jsx(yo,{className:"h-4 w-4"}))})});lc.displayName="PromptInputSubmit";function $n({children:t,className:s,...r}){return e.jsx("div",{className:F("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",s),...r,children:t})}function zn({isActive:t,onClick:s,children:r,className:a,...o}){return e.jsx("button",{type:"button",onClick:s,className:F("flex shrink-0 touch-manipulation items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium outline-none transition-all duration-150 focus-visible:ring-2 focus-visible:ring-primary/60 focus-visible:ring-offset-1 focus-visible:ring-offset-muted",t?"bg-background text-foreground shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:bg-background/50 hover:text-foreground active:bg-background/70",a),...o,children:r})}const Un=n.createContext(null);function Gn(){const t=n.useContext(Un);if(!t)throw new Error("QueueItem sub-components must be used within <QueueItem>");return t}const cc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"queue",role:"list",className:F("space-y-0.5",t),...s}));cc.displayName="Queue";const dc=n.forwardRef(({status:t="pending",className:s,children:r,...a},o)=>{const i=n.useMemo(()=>({status:t}),[t]);return e.jsx(Un.Provider,{value:i,children:e.jsx("div",{ref:o,"data-slot":"queue-item","data-status":t,role:"listitem",className:F("flex items-start gap-2 py-0.5",s),...a,children:r})})});dc.displayName="QueueItem";const uc=n.forwardRef(({className:t,...s},r)=>{const{status:a}=Gn();return e.jsxs("div",{ref:r,"data-slot":"queue-item-indicator","aria-hidden":"true",className:F("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",t),...s,children:[a==="completed"&&e.jsx("svg",{className:"h-3.5 w-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children: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"})}),a==="in_progress"&&e.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),a==="pending"&&e.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})})]})});uc.displayName="QueueItemIndicator";const mc=n.forwardRef(({className:t,children:s,...r},a)=>{const{status:o}=Gn();return e.jsx("div",{ref:a,"data-slot":"queue-item-content",className:F("min-w-0 flex-1 text-xs",o==="completed"&&"text-muted-foreground line-through",o==="in_progress"&&"font-medium text-foreground",o==="pending"&&"text-foreground",t),...r,children:s})});mc.displayName="QueueItemContent";const pc="https://github.com/CaineWind/wacli";function xc({updateAvailable:t,restartRequired:s,releaseInfo:r,latestVersion:a,currentVersion:o,onShowVersionModal:i,onShowSettings:l,t:c}){return e.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"px-2 py-1.5 md:px-2 md:py-1.5",children:e.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-amber-300/60 bg-amber-50/80 px-2.5 py-2 dark:border-amber-700/40 dark:bg-amber-900/15",children:[e.jsx(Oe,{className:"h-4 w-4 flex-shrink-0 text-amber-500 dark:text-amber-400"}),e.jsx("span",{className:"min-w-0 flex-1 text-xs font-medium text-amber-700 dark:text-amber-300",children:c("version.restartRequired")})]})})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:e.jsxs("button",{className:"group flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-blue-50/80 dark:hover:bg-blue-900/15",onClick:i,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Ir,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-normal text-blue-600 dark:text-blue-300",children:r?.title||`v${a}`}),e.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:c("version.updateAvailable")})]})]})}),e.jsx("div",{className:"px-3 py-2 md:hidden",children:e.jsxs("button",{className:"flex h-11 w-full items-center gap-3 rounded-xl border border-blue-200/60 bg-blue-50/80 px-3.5 transition-all active:scale-[0.98] dark:border-blue-700/40 dark:bg-blue-900/15",onClick:i,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Ir,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"block truncate text-sm font-normal text-blue-600 dark:text-blue-300",children:r?.title||`v${a}`}),e.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:c("version.updateAvailable")})]})]})})]}),e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:e.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",onClick:l,children:[e.jsx(as,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:c("actions.settings")})]})}),!he&&e.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:e.jsxs("a",{href:pc,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["WindCli v",o," – ",c("branding.openSource")]})}),e.jsx("div",{className:"px-3 py-3 md:hidden",children:e.jsxs("button",{className:"flex h-10 w-full items-center gap-3 rounded-xl bg-muted/40 px-3.5 transition-all hover:bg-muted/60 active:scale-[0.98]",onClick:l,children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-background/80",children:e.jsx(as,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-normal text-foreground",children:c("actions.settings")})]})})]})}const Xr="WINDCLI_GITHUB_STARS",ea="WINDCLI_HIDE_GITHUB_STAR",hc=3600*1e3,gc=(t,s)=>{const[r,a]=n.useState(null),[o,i]=n.useState(()=>{try{return localStorage.getItem(ea)==="true"}catch{return!1}});n.useEffect(()=>{if(o)return;try{const d=localStorage.getItem(Xr);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<hc){a(u.count);return}}}catch{}(async()=>{try{const d=await fetch(`https://api.github.com/repos/${t}/${s}`);if(!d.ok)return;const x=(await d.json()).stargazers_count;if(typeof x=="number"){a(x);try{localStorage.setItem(Xr,JSON.stringify({count:x,timestamp:Date.now()}))}catch{}}}catch{}})()},[t,s,o]);const l=n.useCallback(()=>{i(!0);try{localStorage.setItem(ea,"true")}catch{}},[]),c=r!==null?r>=1e3?`${(r/1e3).toFixed(1)}k`:`${r}`:null;return{starCount:r,formattedCount:c,isDismissed:o,dismiss:l}},fc="https://github.com/CaineWind/wacli";function bc({className:t}){return e.jsx("svg",{className:t,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})})}function yc(){const{formattedCount:t,isDismissed:s,dismiss:r}=gc("CaineWind","wacli");return he||s?null:e.jsxs("div",{className:"group/star relative hidden md:block",children:[e.jsxs("a",{href:fc,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[e.jsx(bc,{className:"h-3.5 w-3.5"}),e.jsx(os,{className:"h-3 w-3"}),e.jsx("span",{className:"font-normal",children:"Star"}),t&&e.jsx("span",{className:"border-l border-border/50 pl-1.5 tabular-nums",children:t})]}),e.jsx("button",{onClick:a=>{a.preventDefault(),a.stopPropagation(),r()},className:"absolute -right-1.5 -top-1.5 hidden h-4 w-4 items-center justify-center rounded-full border border-border/50 bg-muted text-muted-foreground transition-colors hover:text-foreground group-hover/star:flex","aria-label":"Dismiss",children:e.jsx(ge,{className:"h-2.5 w-2.5"})})]})}const vc=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl";function jc({isPWA:t,isMobile:s,isLoading:r,projectsCount:a,runningSessionsCount:o,archivedSessionsCount:i,isArchivedSessionsLoading:l,searchFilter:c,onSearchFilterChange:m,onClearSearchFilter:d,searchMode:u,onSearchModeChange:x,onRefresh:h,isRefreshing:p,onCreateProject:f,onCollapseSidebar:b,t:g}){const v=(a>0||o>0||i>0||l)&&!r,S=u==="conversations"?g("search.conversationsPlaceholder"):u==="archived"?g("search.archivedPlaceholder","Search archived sessions..."):u==="running"?g("search.runningPlaceholder","Search running sessions..."):g("projects.searchPlaceholder"),k=o>99?"99+":String(o),y=()=>e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("div",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-primary/90 shadow-sm",children:e.jsx("svg",{className:"h-3.5 w-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:"truncate text-sm font-bold tracking-tight text-foreground",style:{fontFamily:Qa},children:g("app.title")})]});return e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"hidden px-3 pb-2 pt-3 md:block",style:{},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[he?e.jsx("a",{href:"https://cloudcli.ai/dashboard",className:"flex min-w-0 items-center gap-2.5 transition-opacity hover:opacity-80",title:g("tooltips.viewEnvironments"),children:e.jsx(y,{})}):e.jsx(y,{}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:h,disabled:p,title:g("tooltips.refresh"),children:e.jsx(is,{className:`h-3.5 w-3.5 ${p?"animate-spin":""}`})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:f,title:g("tooltips.createProject"),children:e.jsx(Ee,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:b,title:g("tooltips.hideSidebar"),children:e.jsx(vo,{className:"h-3.5 w-3.5"})})]})]}),e.jsx(yc,{}),v&&e.jsxs("div",{className:"mt-2.5 space-y-2",children:[e.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[e.jsxs("button",{onClick:()=>x("projects"),"aria-pressed":u==="projects",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ht,{className:"h-3 w-3"}),g("search.modeProjects")]}),e.jsxs("button",{onClick:()=>x("conversations"),"aria-pressed":u==="conversations",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ft,{className:"h-3 w-3"}),g("search.modeConversations")]}),e.jsx(He,{content:g("search.runningTooltip","Running sessions"),position:"top",children:e.jsx("button",{onClick:()=>x("running"),"aria-pressed":u==="running","aria-label":g("search.runningTooltip","Running sessions"),title:g("search.runningTooltip","Running sessions"),className:F("flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="running"?"bg-background shadow-sm text-foreground ring-1 ring-emerald-500/15":"text-muted-foreground hover:text-foreground"),children:e.jsxs("span",{className:"relative flex h-3 w-3 items-center justify-center",children:[e.jsx(Xe,{className:F("h-3 w-3",o>0&&"text-emerald-500")}),o>0&&e.jsx("span",{className:"absolute -right-2.5 -top-2 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-emerald-500 px-0.5 text-[8px] font-semibold leading-none text-white shadow-sm ring-1 ring-background",children:k})]})})}),e.jsx(He,{content:g("search.archiveOnlyTooltip","Archive only"),position:"top",children:e.jsx("button",{onClick:()=>x("archived"),"aria-pressed":u==="archived","aria-label":g("search.archiveOnlyTooltip","Archive only"),title:g("search.archiveOnlyTooltip","Archive only"),className:F("flex items-center justify-center rounded-md px-2.5 py-1.5 text-xs font-normal transition-all",u==="archived"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:e.jsx(ls,{className:"h-3 w-3"})})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(et,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/50"}),e.jsx(me,{type:"text",placeholder:S,value:c,onChange:P=>m(P.target.value),className:"nav-search-input h-9 rounded-xl border-0 pl-9 pr-14 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),c?e.jsx("button",{onClick:d,"aria-label":g("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-0.5 hover:bg-accent",children:e.jsx(ge,{className:"h-3 w-3 text-muted-foreground"})}):e.jsxs("kbd",{"aria-hidden":!0,title:g("tooltips.openCommandPalette"),className:"pointer-events-none absolute right-2.5 top-1/2 hidden -translate-y-1/2 items-center gap-0.5 rounded border border-border/60 bg-muted/40 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground md:inline-flex",children:[vc,e.jsx("span",{children:"K"})]})]})]})]}),e.jsx("div",{className:"nav-divider hidden md:block"}),e.jsxs("div",{className:"p-3 pb-2 md:hidden",style:t&&s?{paddingTop:"16px"}:{},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[he?e.jsx("a",{href:"https://cloudcli.ai/dashboard",className:"flex min-w-0 items-center gap-2.5 transition-opacity active:opacity-70",title:g("tooltips.viewEnvironments"),children:e.jsx(y,{})}):e.jsx(y,{}),e.jsxs("div",{className:"flex flex-shrink-0 gap-1.5",children:[e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-muted/50 transition-all active:scale-95",onClick:h,disabled:p,children:e.jsx(is,{className:`h-4 w-4 text-muted-foreground ${p?"animate-spin":""}`})}),e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/90 text-primary-foreground transition-all active:scale-95",onClick:f,children:e.jsx(xr,{className:"h-4 w-4"})})]})]}),v&&e.jsxs("div",{className:"mt-2.5 space-y-2",children:[e.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[e.jsxs("button",{onClick:()=>x("projects"),"aria-pressed":u==="projects",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ht,{className:"h-3 w-3"}),g("search.modeProjects")]}),e.jsxs("button",{onClick:()=>x("conversations"),"aria-pressed":u==="conversations",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ft,{className:"h-3 w-3"}),g("search.modeConversations")]}),e.jsx(He,{content:g("search.runningTooltip","Running sessions"),position:"top",children:e.jsxs("button",{onClick:()=>x("running"),"aria-pressed":u==="running","aria-label":g("search.runningTooltip","Running sessions"),title:g("search.runningTooltip","Running sessions"),className:F("flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="running"?"bg-background shadow-sm text-foreground ring-1 ring-emerald-500/15":"text-muted-foreground hover:text-foreground"),children:[e.jsxs("span",{className:"relative flex h-3 w-3 items-center justify-center",children:[e.jsx(Xe,{className:F("h-3 w-3",o>0&&"text-emerald-500")}),o>0&&e.jsx("span",{className:"absolute -right-2.5 -top-2 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-emerald-500 px-0.5 text-[8px] font-semibold leading-none text-white shadow-sm ring-1 ring-background",children:k})]}),e.jsx("span",{className:"sr-only",children:g("search.modeRunning","Running")})]})}),e.jsx(He,{content:g("search.archiveOnlyTooltip","Archive only"),position:"top",children:e.jsx("button",{onClick:()=>x("archived"),"aria-pressed":u==="archived","aria-label":g("search.archiveOnlyTooltip","Archive only"),title:g("search.archiveOnlyTooltip","Archive only"),className:F("flex items-center justify-center rounded-md px-2.5 py-1.5 text-xs font-normal transition-all",u==="archived"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:e.jsx(ls,{className:"h-3 w-3"})})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(et,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),e.jsx(me,{type:"text",placeholder:S,value:c,onChange:P=>m(P.target.value),className:"nav-search-input h-10 rounded-xl border-0 pl-10 pr-9 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),c&&e.jsx("button",{onClick:d,"aria-label":g("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-1 hover:bg-accent",children:e.jsx(ge,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),e.jsx("div",{className:"nav-divider md:hidden"})]})}const ta="WindCli",wc=t=>t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session",Nc=(t,s)=>{if(s)return wc(s);const r=t?.displayName?.trim();return r?`${r} - ${ta}`:ta},sa={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},kc={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},Sc=t=>t==="fully-configured"?{icon:jo,colorClassName:"text-green-500 dark:text-green-400",backgroundClassName:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"}:t==="taskmaster-only"?{icon:as,colorClassName:"text-blue-500 dark:text-blue-400",backgroundClassName:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"}:t==="mcp-only"?{icon:Aa,colorClassName:"text-amber-500 dark:text-amber-400",backgroundClassName:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"}:{icon:ge,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function Cc({status:t="not-configured",size:s="sm",className:r="",showLabel:a=!1}){const o=Sc(t),i=o.icon;return a?e.jsxs("div",{className:F("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",o.backgroundClassName,o.colorClassName,r),title:o.title,children:[e.jsx(i,{className:sa[s]}),e.jsx("span",{className:"font-normal",children:o.label})]}):e.jsx("div",{className:F("inline-flex items-center justify-center rounded-full transition-colors",o.backgroundClassName,kc[s],r),title:o.title,children:e.jsx(i,{className:F(sa[s],o.colorClassName)})})}function Pc(t){if(!t||typeof document>"u")return!1;const s=document.createElement("textarea");s.value=t,s.setAttribute("readonly",""),s.style.position="fixed",s.style.opacity="0",s.style.pointerEvents="none",document.body.appendChild(s),s.focus(),s.select();let r=!1;try{r=document.execCommand("copy")}catch{r=!1}finally{document.body.removeChild(s)}return r}async function Cr(t){if(!t)return!1;let s=!1;try{typeof navigator<"u"&&navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(t),s=!0)}catch{s=!1}return s||(s=Pc(t)),s}const Ec={claude:"Claude",codex:"Codex",cursor:"Cursor",opencode:"OpenCode"};function Tc({project:t,session:s,selectedSession:r,isProcessing:a,needsAttention:o,currentTime:i,editingSession:l,editingSessionName:c,onEditingSessionNameChange:m,onStartEditingSession:d,onCancelEditingSession:u,onSaveEditingSession:x,onProjectSelect:h,onSessionSelect:p,onDeleteSession:f,t:b}){const g=Ri(s,i,b),v=r?.id===s.id,S=l===s.id,k=Rt(g.sessionTime,i),y=n.useRef(null),[P,E]=n.useState(!1),[C,T]=n.useState("idle"),[I,j]=n.useState(null),$=n.useRef(0),G=o&&!v,K=!G&&!a&&g.isActive,M=Ec[s.__provider];n.useEffect(()=>{if(!S||P)return;const te=q=>{const ye=y.current;ye&&!ye.contains(q.target)&&u()};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[S,P,u]);const X=()=>{h(t),p(s,t.projectId)},H=()=>{x(t.projectId,s.id,c,s.__provider)},B=()=>{f(t.projectId,s.id,g.sessionName,s.__provider)},w=async()=>{const te=++$.current;T("loading");try{const q=await ue.providerSessionId(s.id),se=(await q.json())?.data?.sessionId;if(!q.ok||typeof se!="string"||!se)throw new Error("Provider session ID is unavailable");if(te!==$.current)return;j(se),T("idle")}catch{if(te!==$.current)return;j(null),T("error")}},D=()=>{$.current+=1,T("idle"),j(null)},L=te=>{te?(j(null),w()):D()},O=te=>{E(te),L(te),!te&&S&&u()},U=()=>{d(s.id,g.sessionName)},N=()=>{H(),O(!1)},A=async()=>{if(!I){T("error");return}T("copying");const te=await Cr(I);T(te?"copied":"error")},ee=()=>{C==="error"&&!I?w():A()},V=C==="loading"||C==="copying",ae=C==="copied"?Fe:La,de=C==="loading"?`Loading ${M} session ID…`:C==="copied"?`${M} session ID copied`:C==="error"?I?`Couldn't copy ${M} session ID`:`${M} session ID unavailable`:`Copy ${M} session ID`;return e.jsxs("div",{className:"group relative",children:[(G||K)&&e.jsx("div",{className:"absolute left-0 top-1/2 -translate-x-1 -translate-y-1/2 transform",children:e.jsx(He,{content:G?b("tooltips.attentionRequiredIndicator",{defaultValue:"Session needs attention"}):b("tooltips.activeSessionIndicator"),position:"right",children:e.jsx("div",{role:"status","aria-label":G?b("tooltips.attentionRequiredIndicator",{defaultValue:"Session needs attention"}):b("tooltips.activeSessionIndicator"),className:F("h-2 w-2 animate-pulse rounded-full",G?"bg-amber-500":"bg-green-500")})})}),e.jsxs("div",{className:"md:hidden",children:[e.jsx("div",{className:F("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",v?"bg-primary/5 border-primary/20":"",!v&&a?"border-border/60 bg-muted/20":!v&&g.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:X,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:F("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",v?"bg-primary/10":"bg-muted/50"),children:e.jsx(_e,{provider:s.__provider,className:"h-3 w-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground",title:g.sessionName,children:g.sessionName}),a?e.jsx("span",{className:"ml-auto flex-shrink-0",children:e.jsx(He,{content:b("tooltips.processingSessionIndicator","Processing session"),position:"top",children:e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground",children:e.jsx(ve,{className:"h-3 w-3 animate-spin"})})})}):k&&e.jsx("span",{className:"ml-auto flex-shrink-0 text-[11px] text-muted-foreground",children:k})]}),e.jsx("div",{className:"mt-0.5 flex items-center",children:g.messageCount>0&&e.jsx(Pe,{variant:"secondary",className:"px-1 py-0 text-xs",children:g.messageCount})})]}),e.jsx("button",{type:"button","aria-label":`Session options for ${g.sessionName}`,"aria-haspopup":"dialog","aria-expanded":P,className:"ml-1 flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted active:scale-95",onClick:te=>{te.stopPropagation(),O(!0)},children:e.jsx(Rr,{className:"h-4 w-4"})})]})}),e.jsx(Mn,{open:P,onOpenChange:O,children:e.jsxs(kr,{"aria-describedby":"mobile-session-options-description",wrapperClassName:"md:hidden",animationClassName:"animate-bottom-sheet-content-show motion-reduce:animate-none",className:"bottom-0 left-0 top-auto max-w-none translate-x-0 translate-y-0 rounded-b-none rounded-t-2xl border-x-0 border-b-0 px-4 pb-safe-area-inset-bottom pt-3",children:[e.jsx(Sr,{children:"Session options"}),e.jsx("div",{className:"mx-auto mb-4 h-1 w-10 rounded-full bg-muted-foreground/30","aria-hidden":"true"}),e.jsxs("div",{className:"mb-4 flex items-center gap-3 px-1",children:[e.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-muted",children:e.jsx(_e,{provider:s.__provider,className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:g.sessionName,children:g.sessionName}),e.jsxs("p",{id:"mobile-session-options-description",className:"text-xs text-muted-foreground",children:[M," session"]})]})]}),S?e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsx("label",{htmlFor:`mobile-session-rename-${s.id}`,className:"block px-1 text-xs font-medium text-muted-foreground",children:"Session name"}),e.jsx("input",{id:`mobile-session-rename-${s.id}`,type:"text",value:c,onChange:te=>m(te.target.value),onKeyDown:te=>{te.stopPropagation(),te.key==="Enter"&&N()},className:"w-full rounded-xl border-2 border-primary/40 bg-background px-3 py-3 text-foreground shadow-sm focus:border-primary focus:outline-none",autoFocus:!0,autoComplete:"off",style:{fontSize:"16px"}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",onClick:N,className:"flex min-h-12 flex-1 items-center justify-center gap-2 rounded-xl bg-primary px-4 py-3 text-sm font-medium text-primary-foreground transition-transform active:scale-95",children:[e.jsx(Fe,{className:"h-5 w-5 flex-shrink-0"}),"Save"]}),e.jsxs("button",{type:"button",onClick:u,className:"flex min-h-12 flex-1 items-center justify-center gap-2 rounded-xl border border-border bg-muted/35 px-4 py-3 text-sm font-medium text-foreground transition-colors active:bg-muted",children:[e.jsx(ge,{className:"h-5 w-5 flex-shrink-0"}),"Cancel"]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:U,className:"flex min-h-12 w-full items-center gap-3 rounded-xl border border-border bg-muted/35 px-4 py-3 text-left text-foreground transition-colors active:bg-muted",children:[e.jsx(Ar,{className:"h-5 w-5 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Rename session"})]}),e.jsxs("button",{type:"button",onClick:ee,disabled:V,className:F("flex min-h-12 w-full items-center gap-3 rounded-xl border px-4 py-3 text-left transition-colors",C==="copied"?"border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300":C==="error"?"border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300":"border-border bg-muted/35 text-foreground active:bg-muted"),children:[V?e.jsx(ve,{className:"h-5 w-5 flex-shrink-0 animate-spin"}):e.jsx(ae,{className:"h-5 w-5 flex-shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-sm font-medium",children:de}),C==="error"&&e.jsx("span",{className:"mt-0.5 block text-xs",children:"Tap to try again."})]})]}),!a&&e.jsxs("button",{type:"button",onClick:()=>{O(!1),B()},className:"flex min-h-12 w-full items-center gap-3 rounded-xl px-4 py-3 text-left text-red-600 transition-colors active:bg-red-500/10 dark:text-red-400",children:[e.jsx(Te,{className:"h-5 w-5 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Archive or delete session"})]})]}),!S&&e.jsx("button",{type:"button",onClick:()=>O(!1),className:"mb-3 mt-2 min-h-11 w-full rounded-xl text-sm font-medium text-muted-foreground transition-colors active:bg-muted",children:"Cancel"})]})})]}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx("a",{href:`/session/${s.id}`,className:F(Nn({variant:"ghost"}),"h-auto w-full justify-start rounded-md border bg-card p-2 pr-11 text-left font-normal transition-all duration-150",v?"border-primary/20 bg-primary/5":"border-border/30",!v&&a?"border-border/60 bg-muted/20 hover:bg-muted/25":!v&&g.isActive?"border-green-500/30 bg-green-50/5 hover:bg-green-50/10 dark:bg-green-900/5 dark:hover:bg-green-900/10":"hover:bg-accent/50"),onClick:te=>{te.metaKey||te.ctrlKey||te.shiftKey||te.altKey||(te.preventDefault(),p(s,t.projectId))},children:e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[e.jsx("div",{className:F("flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/50"),children:e.jsx(_e,{provider:s.__provider,className:"h-3 w-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground",title:g.sessionName,children:g.sessionName}),a?e.jsx("span",{className:F("ml-auto flex-shrink-0 transition-opacity duration-200",S?"opacity-0":"group-hover:opacity-0"),children:e.jsx(He,{content:b("tooltips.processingSessionIndicator","Processing session"),position:"top",children:e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground",children:e.jsx(ve,{className:"h-3 w-3 animate-spin"})})})}):k&&e.jsx("span",{className:F("ml-auto flex-shrink-0 text-[11px] text-muted-foreground transition-opacity duration-200",S?"opacity-0":"group-hover:opacity-0"),children:k})]}),e.jsx("div",{className:"mt-0.5 flex items-center",children:g.messageCount>0&&e.jsx(Pe,{variant:"secondary",className:"px-1 py-0 text-xs",children:g.messageCount})})]})]})}),e.jsx("div",{ref:y,className:"absolute right-2 top-1/2 flex -translate-y-1/2 transform items-center gap-1 opacity-100 transition-all duration-200",children:S?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:c,onChange:te=>m(te.target.value),onKeyDown:te=>{te.stopPropagation(),te.key==="Enter"?H():te.key==="Escape"&&u()},onClick:te=>te.stopPropagation(),className:"w-32 rounded border border-border bg-background px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40",onClick:te=>{te.stopPropagation(),H()},title:b("tooltips.save"),children:e.jsx(Fe,{className:"h-3 w-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40",onClick:te=>{te.stopPropagation(),u()},title:b("tooltips.cancel"),children:e.jsx(ge,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}):e.jsx(kn,{label:"Session options",ariaLabel:`Session options for ${g.sessionName}`,icon:Rr,iconOnly:!0,portal:!0,variant:"ghost",size:"icon",onOpenChange:L,triggerClassName:"h-7 w-7 text-muted-foreground opacity-70 hover:bg-muted hover:opacity-100",menuClassName:"w-[260px] rounded-xl p-1.5 shadow-xl",header:e.jsxs("div",{className:"mb-1 border-b border-border px-3 py-2",children:[e.jsx("p",{className:"truncate text-xs font-medium text-foreground",title:g.sessionName,children:g.sessionName}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[M," session"]})]}),items:[{key:"rename",label:"Rename session",icon:Ar,onSelect:()=>d(s.id,g.sessionName)},{key:"copy",label:de,description:C==="error"?"Click to try again.":void 0,icon:ae,loading:V,closeOnSelect:!1,onSelect:ee},...a?[]:[{key:"delete",label:"Archive or delete session",icon:Te,isDanger:!0,showDividerBefore:!0,onSelect:B}]]})})]})]})}function Ic(){return e.jsx(e.Fragment,{children:Array.from({length:3}).map((t,s)=>e.jsx("div",{className:"rounded-md p-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"mt-0.5 h-3 w-3 animate-pulse rounded-full bg-muted"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${60+s*15}%`}}),e.jsx("div",{className:"h-2 w-1/2 animate-pulse rounded bg-muted"})]})]})},s))})}function Rc({project:t,isExpanded:s,sessions:r,selectedSession:a,initialSessionsLoaded:o,hasMoreSessions:i,isLoadingMoreSessions:l,activeSessions:c,attentionSessionIds:m,currentTime:d,editingSession:u,editingSessionName:x,onEditingSessionNameChange:h,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:b,onProjectSelect:g,onSessionSelect:v,onDeleteSession:S,onLoadMoreSessions:k,onNewSession:y,t:P}){if(!s)return null;const E=r.length>0;return e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[e.jsx("div",{className:"px-3 pb-1 pt-1 md:hidden",children:e.jsxs("button",{className:"flex h-8 w-full items-center justify-center gap-2 rounded-md bg-primary text-xs font-medium text-primary-foreground transition-all duration-150 hover:bg-primary/90 active:scale-[0.98]",onClick:()=>{g(t),y(t)},children:[e.jsx(Ee,{className:"h-3 w-3"}),P("sessions.newSession")]})}),e.jsxs(W,{variant:"default",size:"sm",className:"hidden h-8 w-full justify-start gap-2 bg-primary text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 md:flex",onClick:()=>y(t),children:[e.jsx(Ee,{className:"h-3 w-3"}),P("sessions.newSession")]}),o?E?e.jsxs(e.Fragment,{children:[r.map(C=>e.jsx(Tc,{project:t,session:C,selectedSession:a,isProcessing:c.has(C.id),needsAttention:m.has(C.id),currentTime:d,editingSession:u,editingSessionName:x,onEditingSessionNameChange:h,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:b,onProjectSelect:g,onSessionSelect:v,onDeleteSession:S,t:P},C.id)),i&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-full justify-center text-xs text-muted-foreground hover:text-foreground",onClick:()=>k(t.projectId),disabled:l,children:l?P("sessions.loadingSessions"):"Load more sessions"})]}):e.jsx("div",{className:"px-3 py-2 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:P("sessions.noSessions")})}):e.jsx(Ic,{})]})}const Ac=(t,s)=>{const r=Number(t.sessionMeta?.total??s.length);return String(r)};function Lc({project:t,selectedProject:s,selectedSession:r,isExpanded:a,isDeleting:o,isStarred:i,editingProject:l,editingName:c,sessions:m,initialSessionsLoaded:d,isLoadingMoreSessions:u,currentTime:x,editingSession:h,editingSessionName:p,tasksEnabled:f,mcpServerStatus:b,onEditingNameChange:g,onToggleProject:v,onProjectSelect:S,onToggleStarProject:k,onStartEditingProject:y,onCancelEditingProject:P,onSaveProjectName:E,onDeleteProject:C,onSessionSelect:T,onDeleteSession:I,onLoadMoreSessions:j,activeSessions:$,attentionSessionIds:G,onNewSession:K,onEditingSessionNameChange:M,onStartEditingSession:X,onCancelEditingSession:H,onSaveEditingSession:B,t:w}){const D=s?.projectId===t.projectId,L=l===t.projectId,O=Number(t.sessionMeta?.total??m.length),U=Ac(t,m),N=`${U} session${O===1?"":"s"}`,A=Mi(t,b),ee=n.useRef(null);n.useEffect(()=>{if(!L||!ee.current)return;let q=0;const ye=()=>{window.cancelAnimationFrame(q),q=window.requestAnimationFrame(()=>{ee.current?.scrollIntoView({block:"center",inline:"nearest"})})};return ye(),window.visualViewport?.addEventListener("resize",ye),()=>{window.cancelAnimationFrame(q),window.visualViewport?.removeEventListener("resize",ye)}},[L]);const V=()=>v(t.projectId),ae=()=>k(t.projectId),de=()=>{E(t.projectId)},te=()=>{s?.projectId!==t.projectId&&S(t),V()};return e.jsxs("div",{className:F("md:space-y-1",o&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"md:group group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:F("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",D&&"bg-primary/5 border-primary/20",i&&!D&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:V,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("button",{className:F("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",i?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:q=>{q.stopPropagation(),ae()},title:w(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(os,{className:F("w-4 h-4 transition-colors",i?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("div",{className:"min-w-0 flex-1",children:L?e.jsx("input",{ref:ee,type:"text",value:c,onChange:q=>g(q.target.value),className:"w-full rounded-lg border-2 border-primary/40 bg-background px-3 py-2 text-sm text-foreground shadow-sm transition-all duration-200 focus:border-primary focus:shadow-md focus:outline-none",placeholder:w("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:q=>q.stopPropagation(),onKeyDown:q=>{q.key==="Enter"&&de(),q.key==="Escape"&&P()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between",children:[e.jsx("h3",{className:"truncate text-sm font-normal text-foreground",children:t.displayName}),f&&e.jsx(Cc,{status:A,size:"xs",className:"ml-2 hidden flex-shrink-0 md:inline-flex"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:N})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:L?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-green-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-green-600",onClick:q=>{q.stopPropagation(),de()},children:e.jsx(Fe,{className:"h-4 w-4 text-white"})}),e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-gray-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-gray-600",onClick:q=>{q.stopPropagation(),P()},children:e.jsx(ge,{className:"h-4 w-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-red-200 bg-red-500/10 active:scale-90 dark:border-red-800 dark:bg-red-900/30",onClick:q=>{q.stopPropagation(),C(t)},children:e.jsx(Te,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 active:scale-90 dark:border-primary/30 dark:bg-primary/20",onClick:q=>{q.stopPropagation(),y(t)},children:e.jsx(ar,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-muted/30",children:a?e.jsx(ns,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(cs,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),e.jsxs(W,{variant:"ghost",className:F("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",D&&"bg-accent text-accent-foreground",i&&!D&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:te,children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:F("w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-all duration-200",i?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20":"opacity-40 hover:opacity-100 hover:bg-accent"),onClick:q=>{q.stopPropagation(),ae()},title:w(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(os,{className:F("w-3 h-3 transition-colors",i?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:L?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:c,onChange:q=>g(q.target.value),className:"w-full rounded border border-border bg-background px-2 py-1 text-sm text-foreground focus:ring-2 focus:ring-primary/20",placeholder:w("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:q=>{q.key==="Enter"&&de(),q.key==="Escape"&&P()}}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",title:t.fullPath,children:t.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"truncate text-sm font-normal text-foreground",title:t.displayName,children:t.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[U,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 flex-shrink-0 items-center gap-1",children:L?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:q=>{q.stopPropagation(),de()},children:e.jsx(Fe,{className:"h-3 w-3"})}),e.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-gray-500 transition-colors hover:bg-gray-50 hover:text-gray-700 dark:hover:bg-gray-800",onClick:q=>{q.stopPropagation(),P()},children:e.jsx(ge,{className:"h-3 w-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"touch:opacity-100 flex h-6 w-6 cursor-pointer items-center justify-center rounded opacity-0 transition-all duration-200 hover:bg-accent group-hover:opacity-100",onClick:q=>{q.stopPropagation(),y(t)},title:w("tooltips.renameProject"),children:e.jsx(ar,{className:"h-3 w-3"})}),e.jsx("div",{className:"touch:opacity-100 flex h-6 w-6 cursor-pointer items-center justify-center rounded opacity-0 transition-all duration-200 hover:bg-red-50 group-hover:opacity-100 dark:hover:bg-red-900/20",onClick:q=>{q.stopPropagation(),C(t)},title:w("tooltips.deleteProject"),children:e.jsx(Te,{className:"h-3 w-3 text-red-600 dark:text-red-400"})}),a?e.jsx(ns,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):e.jsx(cs,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),e.jsx(Rc,{project:t,isExpanded:a,sessions:m,selectedSession:r,initialSessionsLoaded:d,hasMoreSessions:!!t.sessionMeta?.hasMore,isLoadingMoreSessions:u,activeSessions:$,attentionSessionIds:G,currentTime:x,editingSession:h,editingSessionName:p,onEditingSessionNameChange:M,onStartEditingSession:X,onCancelEditingSession:H,onSaveEditingSession:B,onProjectSelect:S,onSessionSelect:T,onDeleteSession:I,onLoadMoreSessions:j,onNewSession:K,t:w})]})}function Mc({isLoading:t,loadingProgress:s,projectsCount:r,filteredProjectsCount:a,t:o}){return t?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:o("projects.loadingProjects")}),s&&s.total>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${s.current/s.total*100}%`}})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.current,"/",s.total," ",o("projects.projects")]}),s.currentProject&&e.jsx("p",{className:"mx-auto max-w-[200px] truncate text-xs text-muted-foreground/70",title:s.currentProject,children:s.currentProject.split("-").slice(-2).join("/")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:o("projects.fetchingProjects")})]}):r===0?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx(ht,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:o("projects.noProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o("projects.runClaudeCli")})]}):a===0?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx(et,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:o("projects.noMatchingProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o("projects.tryDifferentSearch")})]}):null}function ra({projects:t,filteredProjects:s,selectedProject:r,selectedSession:a,isLoading:o,loadingProgress:i,expandedProjects:l,editingProject:c,editingName:m,initialSessionsLoaded:d,currentTime:u,editingSession:x,editingSessionName:h,deletingProjects:p,tasksEnabled:f,mcpServerStatus:b,getProjectSessions:g,onLoadMoreSessions:v,loadingMoreProjects:S,activeSessions:k,attentionSessionIds:y,forceExpanded:P=!1,isProjectStarred:E,onEditingNameChange:C,onToggleProject:T,onProjectSelect:I,onToggleStarProject:j,onStartEditingProject:$,onCancelEditingProject:G,onSaveProjectName:K,onDeleteProject:M,onSessionSelect:X,onDeleteSession:H,onNewSession:B,onEditingSessionNameChange:w,onStartEditingSession:D,onCancelEditingSession:L,onSaveEditingSession:O,t:U}){const N=Nc(r,a),A=e.jsx(Mc,{isLoading:o,loadingProgress:i,projectsCount:t.length,filteredProjectsCount:s.length,t:U});n.useEffect(()=>{document.title=N},[N]);const ee=!o&&t.length>0&&s.length>0;return e.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:ee?s.map(V=>e.jsx(Lc,{project:V,selectedProject:r,selectedSession:a,isExpanded:P||l.has(V.projectId),isDeleting:p.has(V.projectId),isStarred:E(V.projectId),editingProject:c,editingName:m,sessions:g(V),initialSessionsLoaded:d.has(V.projectId),isLoadingMoreSessions:S.has(V.projectId),currentTime:u,editingSession:x,editingSessionName:h,tasksEnabled:f,mcpServerStatus:b,onEditingNameChange:C,onToggleProject:T,onProjectSelect:I,onToggleStarProject:j,onStartEditingProject:$,onCancelEditingProject:G,onSaveProjectName:K,onDeleteProject:M,onSessionSelect:X,onDeleteSession:H,onLoadMoreSessions:v,activeSessions:k,attentionSessionIds:y,onNewSession:B,onEditingSessionNameChange:w,onStartEditingSession:D,onCancelEditingSession:L,onSaveEditingSession:O,t:U},V.projectId)):A})}function Fc(){return e.jsx("div",{className:"space-y-1 px-1","aria-label":"Loading recent conversations",children:Array.from({length:8}).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-2 py-2.5",children:[e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md bg-muted"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${72-s*3}%`}}),e.jsx("div",{className:"h-2.5 w-1/2 animate-pulse rounded bg-muted/70"})]})]},s))})}function _c({conversations:t,total:s,hasMore:r,isLoading:a,isLoadingMore:o,hasError:i,selectedSession:l,currentTime:c,onConversationSelect:m,onLoadMore:d,onRetry:u,t:x}){return a&&t.length===0?e.jsx(Fc,{}):i&&t.length===0?e.jsxs("div",{className:"px-4 py-10 text-center",children:[e.jsx(ft,{className:"mx-auto mb-3 h-6 w-6 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:x("recent.loadFailed","Could not load recent conversations")}),e.jsx(W,{variant:"ghost",size:"sm",className:"mt-2",onClick:u,children:x("buttons.retry",{ns:"common",defaultValue:"Try again"})})]}):t.length===0?e.jsxs("div",{className:"px-4 py-10 text-center",children:[e.jsx(ft,{className:"mx-auto mb-3 h-6 w-6 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:x("recent.emptyTitle","No conversations yet")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:x("recent.emptyDescription","Your most recently updated conversations will appear here.")})]}):e.jsxs("div",{className:"px-1","data-testid":"recent-conversations-list",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5 pt-0.5",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:x("recent.title","Recent conversations")}),e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:s})]}),e.jsx("div",{className:"space-y-0.5",children:t.map(h=>{const p=String(l?.id??"")===h.sessionId,f=Rt(h.lastActivity,c),b=g=>{g.button!==0||g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||(g.preventDefault(),m(h.projectId,h.sessionId,h.provider))};return e.jsxs("a",{href:`/session/${h.sessionId}`,onClick:b,"data-testid":"recent-conversation-row",className:F("group flex min-w-0 items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",p?"bg-primary/10 text-foreground":"text-foreground hover:bg-accent/60"),children:[e.jsx("span",{className:F("flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md",p?"bg-primary/10":"bg-muted/60"),children:e.jsx(_e,{provider:h.provider,className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[13px] font-normal leading-4",children:h.sessionTitle}),e.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-[10px] leading-3 text-muted-foreground",children:[e.jsx("span",{className:"truncate",children:h.projectDisplayName}),f&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-shrink-0 text-muted-foreground/40",children:"·"}),e.jsx("time",{className:"flex-shrink-0 tabular-nums",dateTime:h.lastActivity??void 0,children:f})]})]})]}),e.jsx(cs,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/40 transition-transform group-hover:translate-x-0.5 group-hover:text-muted-foreground"})]},h.sessionId)})}),r&&e.jsx(W,{variant:"ghost",size:"sm",className:"mt-1 h-8 w-full text-xs text-muted-foreground",onClick:d,disabled:o,children:o?x("recent.loadingMore","Loading more..."):x("recent.loadMore","Load older conversations")})]})}function Oc({snippet:t,highlights:s}){const r=[];let a=0;for(const o of s)o.start>a&&r.push(t.slice(a,o.start)),r.push(e.jsx("mark",{className:"rounded-sm bg-yellow-200 px-0.5 text-foreground dark:bg-yellow-800",children:t.slice(o.start,o.end)},o.start)),a=o.end;return a<t.length&&r.push(t.slice(a)),e.jsx("span",{className:"min-w-0 flex-1 break-words text-xs leading-relaxed text-muted-foreground",children:r})}function Dc(t){const s=new Map;for(const r of t){const a=r.projectId??r.projectPath??`session:${r.sessionId}`,o=s.get(a);if(o){o.sessions.push(r),(!o.latestActivity||r.lastActivity&&r.lastActivity>o.latestActivity)&&(o.latestActivity=r.lastActivity);continue}s.set(a,{key:a,projectId:r.projectId,projectDisplayName:r.projectDisplayName,projectPath:r.projectPath,isProjectArchived:r.isProjectArchived,sessions:[r],latestActivity:r.lastActivity})}return[...s.values()].sort((r,a)=>{const o=r.latestActivity??"";return(a.latestActivity??"").localeCompare(o)})}function $c({isPWA:t,isMobile:s,isLoading:r,projects:a,runningSessionsCount:o,archivedProjects:i,archivedSessions:l,archivedSessionsCount:c,isArchivedSessionsLoading:m,recentConversations:d,recentConversationsTotal:u,recentConversationsHasMore:x,isRecentConversationsLoading:h,isLoadingMoreRecentConversations:p,recentConversationsError:f,searchFilter:b,onSearchFilterChange:g,onClearSearchFilter:v,searchMode:S,onSearchModeChange:k,conversationResults:y,isSearching:P,searchProgress:E,onRestoreArchivedProject:C,onLoadMoreRecentConversations:T,onRetryRecentConversations:I,onArchivedSessionClick:j,onRestoreArchivedSession:$,onDeleteArchivedSession:G,onConversationResultClick:K,onRefresh:M,isRefreshing:X,onCreateProject:H,onCollapseSidebar:B,updateAvailable:w,restartRequired:D,releaseInfo:L,latestVersion:O,currentVersion:U,onShowVersionModal:N,onShowSettings:A,projectListProps:ee,t:V}){const ae=S==="conversations"&&b.trim().length>=2,de=!!(y&&(y.titleResults.length>0||y.results.length>0)),te=Dc(l),q=i.length+l.length,ye=s&&!!(ee.editingProject||ee.editingSession);return e.jsxs("div",{className:"flex h-full flex-col bg-background/80 backdrop-blur-sm md:w-72 md:select-none",style:{},children:[e.jsx(jc,{isPWA:t,isMobile:s,isLoading:r,projectsCount:a.length,runningSessionsCount:o,archivedSessionsCount:c,isArchivedSessionsLoading:m,searchFilter:b,onSearchFilterChange:g,onClearSearchFilter:v,searchMode:S,onSearchModeChange:k,onRefresh:M,isRefreshing:X,onCreateProject:H,onCollapseSidebar:B,t:V}),e.jsx(Fn,{className:"flex-1 overflow-y-auto overscroll-contain md:px-1.5 md:py-2",children:ae?P&&!y?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V("search.searching")}),E&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground/60",children:[V("search.projectsScanned",{count:E.scannedProjects}),"/",E.totalProjects]})]}):!P&&y&&!de?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx(et,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:V("search.noResults")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V("search.tryDifferentQuery")})]}):y&&(de||P)?e.jsxs("div",{className:"space-y-4 px-2","aria-live":"polite",children:[y.titleResults.length>0&&e.jsxs("section",{className:"space-y-1","aria-labelledby":"session-title-results-heading",children:[e.jsxs("div",{className:"flex items-center justify-between px-1 py-0.5",children:[e.jsx("h3",{id:"session-title-results-heading",className:"text-[11px] font-medium text-muted-foreground",children:V("search.sessionTitles","Session")}),e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:y.titleResults.length})]}),y.titleResults.map(se=>{const ne=Rt(se.lastActivity,ee.currentTime);return e.jsxs("button",{type:"button",className:"group flex w-full min-w-0 items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors hover:bg-accent/60",onClick:()=>K(se.projectId,se.sessionId,se.provider),children:[e.jsx("span",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md bg-muted/60",children:e.jsx(_e,{provider:se.provider,className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[13px] font-normal leading-4 text-foreground",children:se.sessionTitle}),e.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-[10px] leading-3 text-muted-foreground",children:[e.jsx("span",{className:"truncate",children:se.projectDisplayName}),ne&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-shrink-0 text-muted-foreground/40",children:"·"}),e.jsx("time",{className:"flex-shrink-0 tabular-nums",dateTime:se.lastActivity??void 0,children:ne})]})]})]})]},`${se.provider}-${se.sessionId}`)})]}),(y.results.length>0||P)&&e.jsxs("section",{className:"space-y-3","aria-labelledby":"conversation-content-results-heading",children:[e.jsxs("div",{className:"flex items-center justify-between px-1 py-0.5",children:[e.jsx("h3",{id:"conversation-content-results-heading",className:"text-[11px] font-medium text-muted-foreground",children:V("search.conversationContents","Conversation contents")}),e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:V("search.matches",{count:y.totalMatches})})]}),P&&E&&e.jsxs("div",{className:"space-y-1.5 px-1",children:[e.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[e.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-[1.5px] border-muted-foreground/40 border-t-primary"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/60",children:[E.scannedProjects,"/",E.totalProjects]})]}),e.jsx("div",{className:"h-0.5 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-primary/60 transition-all duration-300",style:{width:`${E.totalProjects>0?Math.round(E.scannedProjects/E.totalProjects*100):0}%`}})})]}),y.results.map(se=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-1 py-1",children:[e.jsx(ht,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-xs font-normal text-foreground",children:se.projectDisplayName})]}),se.sessions.map(ne=>e.jsxs("button",{className:"w-full rounded-md px-2 py-2 text-left transition-colors hover:bg-accent/50",onClick:()=>K(se.projectId,ne.sessionId,ne.provider||ne.matches[0]?.provider||"claude",ne.matches[0]?.timestamp,ne.matches[0]?.snippet),children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[e.jsx(ft,{className:"h-3 w-3 flex-shrink-0 text-primary"}),e.jsx("span",{className:"truncate text-xs font-normal text-foreground",children:ne.sessionSummary}),ne.provider&&ne.provider!=="claude"&&e.jsx("span",{className:"flex-shrink-0 rounded bg-muted px-1 py-0.5 text-[9px] uppercase text-muted-foreground",children:ne.provider})]}),e.jsx("div",{className:"space-y-1 pl-4",children:ne.matches.map((re,Ie)=>e.jsxs("div",{className:"flex items-start gap-1",children:[e.jsx("span",{className:"mt-0.5 flex-shrink-0 text-[10px] font-normal uppercase text-muted-foreground/60",children:re.role==="user"?"U":"A"}),e.jsx(Oc,{snippet:re.snippet,highlights:re.highlights})]},Ie))})]},`${se.projectId??se.projectName}-${ne.sessionId}`))]},se.projectName))]})]}):null:S==="conversations"?e.jsx(_c,{conversations:d,total:u,hasMore:x,isLoading:h,isLoadingMore:p,hasError:f,selectedSession:ee.selectedSession,currentTime:ee.currentTime,onConversationSelect:K,onLoadMore:T,onRetry:I,t:V}):S==="running"?ee.filteredProjects.length===0?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg border border-border/70 bg-muted/50 md:mb-3",children:e.jsx(Xe,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:V("running.emptyTitle","No sessions running")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o>0?V("running.noMatchingSessions","No running sessions match this search."):V("running.emptyDescription","Active work will appear here while a provider is processing.")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"mx-2 flex items-center justify-between rounded-lg border border-border/60 bg-card/50 px-3 py-2 shadow-sm",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",children:e.jsx(Xe,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"truncate text-xs font-normal text-foreground",children:V("running.title","Running now")})]}),e.jsx("span",{className:"rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-normal text-emerald-700 dark:text-emerald-300",children:o})]}),e.jsx(ra,{...ee})]}):S==="archived"?m?e.jsxs("div",{className:"space-y-2 px-2 py-1","aria-live":"polite","aria-busy":"true",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-muted/70",children:e.jsx("div",{className:"h-3.5 w-3.5 animate-spin rounded-full border-[1.5px] border-muted-foreground/40 border-t-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-medium text-foreground",children:V("archived.loadingTitle","Loading archive...")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:V("archived.loadingDescription","Fetching hidden workspaces and sessions you can restore later.")})]})]}),[0,1].map(se=>e.jsx("div",{className:"animate-pulse rounded-xl border border-border/50 bg-card/40 p-3",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-muted"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx("div",{className:"h-3 w-2/3 rounded bg-muted"}),e.jsx("div",{className:"h-2.5 w-5/6 rounded bg-muted/70"})]})]})},se))]}):i.length===0&&te.length===0?e.jsx("div",{className:"px-3 py-8 text-center",children:e.jsxs("div",{className:"mx-auto max-w-[240px] rounded-2xl border border-dashed border-border/80 bg-muted/20 px-5 py-7",children:[e.jsx("div",{className:"mx-auto mb-3 flex h-10 w-10 items-center justify-center rounded-xl border border-border/70 bg-background shadow-sm",children:e.jsx(ls,{className:"h-[18px] w-[18px] text-muted-foreground"})}),e.jsx("h3",{className:"text-sm font-medium text-foreground",children:c>0?V("archived.noMatchingSessions","No matching archived items"):V("archived.emptyTitle","No archived items")}),e.jsx("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:c>0?V("archived.tryDifferentSearch","Try a different search term."):V("archived.emptyDescription","Archived workspaces and sessions will appear here when you hide them from the active list.")})]})}):e.jsxs("div",{className:"space-y-2.5 px-2 pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-1 pb-0.5 pt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-lg bg-muted/60 text-muted-foreground",children:e.jsx(ls,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xs font-medium leading-none text-foreground",children:V("archived.title","Archive")}),e.jsx("p",{className:"mt-1 text-[10px] leading-none text-muted-foreground",children:V("archived.restoreHint","Restore items whenever you need them")})]})]}),e.jsx("span",{className:"rounded-full border border-border/60 bg-muted/40 px-2 py-0.5 text-[10px] tabular-nums text-muted-foreground",title:q!==c?`${q} of ${c}`:void 0,children:q!==c?`${q}/${c}`:c})]}),i.map(se=>{const ne=gs(se);return e.jsxs("section",{className:"group/archive overflow-hidden rounded-xl border border-border/70 bg-card/45 shadow-[0_1px_0_hsl(var(--border)/0.2)] transition-colors hover:border-border",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-2.5 py-2.5",children:[e.jsx("span",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg border border-border/60 bg-muted/45 text-muted-foreground",children:e.jsx(ht,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("h3",{className:"truncate text-[13px] font-medium text-foreground",children:se.displayName}),ne.length>0&&e.jsx("span",{className:"flex-shrink-0 rounded-md bg-muted/60 px-1.5 py-0.5 text-[9px] tabular-nums text-muted-foreground",children:ne.length})]}),e.jsx("p",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/70",title:se.fullPath,children:se.fullPath})]}),e.jsxs("button",{className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-lg border border-emerald-600/15 bg-emerald-500/10 px-2 text-[10px] font-medium text-emerald-700 transition-all hover:border-emerald-600/25 hover:bg-emerald-500/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/40 dark:text-emerald-300",onClick:()=>C(se.projectId),title:V("archived.restoreProject","Restore workspace"),"aria-label":`${V("archived.restoreProject","Restore workspace")}: ${se.displayName}`,children:[e.jsx(Lr,{className:"h-3 w-3"}),V("archived.restoreAction","Restore")]})]}),ne.length>0&&e.jsx("div",{className:"border-t border-border/45 bg-muted/[0.08]",children:ne.map(re=>e.jsxs("button",{className:"flex w-full items-center gap-2.5 border-b border-border/35 px-2.5 py-2 text-left transition-colors last:border-b-0 hover:bg-accent/35 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>j({sessionId:String(re.id),provider:re.__provider,projectId:se.projectId,projectPath:se.fullPath,projectDisplayName:se.displayName,sessionTitle:typeof re.summary=="string"&&re.summary.trim().length>0?re.summary:typeof re.name=="string"&&re.name.trim().length>0?re.name:String(re.id),createdAt:typeof re.created_at=="string"?re.created_at:null,updatedAt:typeof re.updated_at=="string"?re.updated_at:null,lastActivity:typeof re.lastActivity=="string"?re.lastActivity:typeof re.updated_at=="string"?re.updated_at:typeof re.created_at=="string"?re.created_at:null,isProjectArchived:!0}),children:[e.jsx("span",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md bg-background/70",children:e.jsx(_e,{provider:re.__provider,className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-xs text-foreground",children:typeof re.summary=="string"&&re.summary.trim().length>0?re.summary:typeof re.name=="string"&&re.name.trim().length>0?re.name:String(re.id)}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] text-muted-foreground/70",children:[e.jsx("span",{className:"uppercase tracking-wide",children:re.__provider}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:Rt(typeof re.lastActivity=="string"?re.lastActivity:typeof re.updated_at=="string"?re.updated_at:typeof re.created_at=="string"?re.created_at:null,ee.currentTime)})]})]})]},String(re.id)))})]},se.projectId)}),te.map(se=>e.jsxs("section",{className:"group/archive overflow-hidden rounded-xl border border-border/70 bg-card/45 shadow-[0_1px_0_hsl(var(--border)/0.2)] transition-colors hover:border-border",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-2.5 py-2.5",children:[e.jsx("span",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg border border-border/60 bg-muted/45 text-muted-foreground",children:e.jsx(ht,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("h3",{className:"truncate text-[13px] font-medium text-foreground",children:se.projectDisplayName}),e.jsx("span",{className:"flex-shrink-0 rounded-md bg-muted/60 px-1.5 py-0.5 text-[9px] tabular-nums text-muted-foreground",children:se.sessions.length})]}),se.projectPath&&e.jsx("p",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/70",title:se.projectPath,children:se.projectPath})]})]}),e.jsx("div",{className:"border-t border-border/45 bg-muted/[0.08]",children:se.sessions.map(ne=>e.jsxs("div",{className:"group/session flex items-center gap-1 border-b border-border/35 px-2.5 py-2 last:border-b-0 hover:bg-accent/35",children:[e.jsxs("button",{className:"flex min-w-0 flex-1 items-center gap-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>j(ne),children:[e.jsx("span",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md bg-background/70",children:e.jsx(_e,{provider:ne.provider,className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-xs text-foreground",children:ne.sessionTitle}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] text-muted-foreground/70",children:[e.jsx("span",{className:"uppercase tracking-wide",children:ne.provider}),ne.lastActivity&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:Rt(ne.lastActivity,ee.currentTime)})]})]})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[e.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-emerald-500/10 hover:text-emerald-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/40 dark:hover:text-emerald-300",onClick:()=>$(ne.sessionId),title:V("archived.restore","Restore session"),"aria-label":`${V("archived.restore","Restore session")}: ${ne.sessionTitle}`,children:e.jsx(Lr,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/60 transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/40",onClick:()=>G(ne),title:V("archived.deletePermanently","Delete permanently"),"aria-label":`${V("archived.deletePermanently","Delete permanently")}: ${ne.sessionTitle}`,children:e.jsx(Te,{className:"h-3.5 w-3.5"})})]})]},ne.sessionId))})]},se.key))]}):e.jsx(ra,{...ee})}),!ye&&e.jsx(xc,{updateAvailable:w,restartRequired:D,releaseInfo:L,latestVersion:O,currentVersion:U,onShowVersionModal:N,onShowSettings:A,t:V})]})}const aa=[{id:"agents",labelKey:"mainTabs.agents",icon:Ma},{id:"appearance",labelKey:"mainTabs.appearance",icon:Fa},{id:"git",labelKey:"mainTabs.git",icon:Ft},{id:"api",labelKey:"mainTabs.apiTokens",icon:hr},{id:"voice",labelKey:"mainTabs.voice",icon:wo},{id:"tasks",labelKey:"mainTabs.tasks",icon:_a},{id:"browser",labelKey:"mainTabs.browser",icon:Oa},{id:"plugins",labelKey:"mainTabs.plugins",icon:No},{id:"notifications",labelKey:"mainTabs.notifications",icon:gr},{id:"about",labelKey:"mainTabs.about",icon:Da}];function zc({activeTab:t,onChange:s}){const{t:r}=ce("settings");return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"hidden w-56 flex-shrink-0 border-r border-border bg-muted/30 md:flex md:flex-col",children:e.jsx("nav",{className:"flex flex-col gap-1 p-3",children:aa.map(a=>{const o=a.icon,i=t===a.id;return e.jsxs("button",{onClick:()=>s(a.id),className:F("flex items-center gap-3 rounded-lg px-3 py-2.5 text-left text-sm font-medium transition-colors duration-150",i?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground active:bg-accent/50"),children:[e.jsx(o,{className:"h-4 w-4 flex-shrink-0"}),r(a.labelKey)]},a.id)})})}),e.jsx("div",{className:"flex-shrink-0 border-b border-border px-3 py-2 md:hidden",children:e.jsx($n,{className:"scrollbar-hide w-full overflow-x-auto",children:aa.map(a=>{const o=a.icon;return e.jsxs(zn,{isActive:t===a.id,onClick:()=>s(a.id),className:"flex-shrink-0",children:[e.jsx(o,{className:"h-3.5 w-3.5"}),r(a.labelKey)]},a.id)})})})]})}const Pr={claude:"Claude",cursor:"Cursor",codex:"Codex",opencode:"OpenCode"},vs={claude:["user","project","local"],cursor:["user","project"],codex:["user","project"],opencode:["user","project"]},js={claude:["stdio","http","sse"],cursor:["stdio","http"],codex:["stdio","http"],opencode:["stdio","http"]},Uc=["user","project"],Vn=["stdio","http"],Gc={claude:"bg-primary text-primary-foreground hover:bg-primary/90",cursor:"bg-primary text-primary-foreground hover:bg-primary/90",codex:"bg-primary text-primary-foreground hover:bg-primary/90",opencode:"bg-primary text-primary-foreground hover:bg-primary/90"},Er={claude:!1,cursor:!1,codex:!0,opencode:!1},Vc={name:"",scope:"user",workspacePath:"",transport:"stdio",command:"",args:[],env:{},cwd:"",url:"",headers:{},envVars:[],bearerTokenEnvVar:"",envHttpHeaders:{},importMode:"form",jsonInput:""},Kn=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Be=t=>typeof t=="string"&&t.trim()?t.trim():void 0,na=t=>Array.isArray(t)?t.filter(s=>typeof s=="string"):void 0,Js=t=>{if(!Kn(t))return;const s={};return Object.entries(t).forEach(([r,a])=>{typeof a=="string"&&(s[r]=a)}),Object.keys(s).length>0?s:void 0},qs=t=>Object.entries(t).map(([s,r])=>`${s}=${r}`).join(`
3
- `),Qs=t=>{const s={};return t.split(`
4
- `).forEach(r=>{const[a,...o]=r.split("=");a?.trim()&&(s[a.trim()]=o.join("=").trim())}),s},oa=t=>t.split(`
5
- `).map(s=>s.trim()).filter(Boolean),Kc=t=>{const s=String(t??"");return s.length<=4?"****":`${s.slice(0,2)}****${s.slice(-2)}`},Bc=t=>t==="user"||t==="local"||t==="project",Tr=t=>t==="stdio"||t==="http"||t==="sse",Bn=t=>t.fullPath||t.path||"",es=t=>t instanceof Error?t.message:"Unknown error",Wn=(t,s,r)=>{if(!(r?.supportedTransports??js[t]).includes(s))throw new Error(r?.unsupportedTransportMessage?.(s)??`${t} does not support ${s} MCP servers`)},Wc=(t,s,r)=>{const a=JSON.parse(s.jsonInput);if(!Kn(a))throw new Error("JSON configuration must be an object");const o=Be(a.transport)??Be(a.type),i=Tr(o)?o:void 0;if(!i)throw new Error("Missing required field: type");if(Wn(t,i,r),i==="stdio"&&!Be(a.command))throw new Error("stdio type requires a command field");if((i==="http"||i==="sse")&&!Be(a.url))throw new Error(`${i} type requires a url field`);return{name:s.name.trim(),scope:s.scope,workspacePath:s.scope==="user"?void 0:s.workspacePath,transport:i,command:Be(a.command),args:na(a.args)??[],env:Js(a.env)??{},cwd:r?.supportsWorkingDirectory??Er[t]?Be(a.cwd):void 0,url:Be(a.url),headers:Js(a.headers??a.http_headers)??{},envVars:r?.includeProviderSpecificFields??t==="codex"?na(a.envVars??a.env_vars)??[]:void 0,bearerTokenEnvVar:r?.includeProviderSpecificFields??t==="codex"?Be(a.bearerTokenEnvVar??a.bearer_token_env_var):void 0,envHttpHeaders:r?.includeProviderSpecificFields??t==="codex"?Js(a.envHttpHeaders??a.env_http_headers)??{}:void 0}},ia=(t,s,r)=>{if(s.importMode==="json")return Wc(t,s,r);Wn(t,s.transport,r);const a=r?.supportsWorkingDirectory??Er[t],o=r?.includeProviderSpecificFields??t==="codex";return{name:s.name.trim(),scope:s.scope,workspacePath:s.scope==="user"?void 0:s.workspacePath,transport:s.transport,command:s.transport==="stdio"?s.command.trim():void 0,args:s.transport==="stdio"?s.args:void 0,env:s.env,cwd:a&&s.cwd.trim()||void 0,url:s.transport!=="stdio"?s.url.trim():void 0,headers:s.transport!=="stdio"?s.headers:void 0,envVars:o?s.envVars:void 0,bearerTokenEnvVar:o&&s.bearerTokenEnvVar.trim()||void 0,envHttpHeaders:o?s.envHttpHeaders:void 0}},Hc=3e4,ct=new Map,ws=async t=>t.json(),Ns=(t,s)=>{if(!t||typeof t!="object")return s;const r=t,a=r.error;if(a&&typeof a=="object"){const i=a.message;if(typeof i=="string"&&i.trim())return i}if(typeof a=="string"&&a.trim())return a;const o=r.details;return typeof o=="string"&&o.trim()?o:s},Jc=(t,s="stdio")=>Tr(t)?t:s,qc=(t,s)=>Bc(t)?t:s,Qc=(t,s,r,a)=>{const o=Jc(r.transport,r.url?"http":"stdio");return{provider:t,name:String(r.name??""),scope:qc(r.scope,s),transport:o,command:r.command,args:r.args??[],env:r.env??{},cwd:r.cwd,url:r.url,headers:r.headers??{},envVars:r.envVars??[],bearerTokenEnvVar:r.bearerTokenEnvVar,envHttpHeaders:r.envHttpHeaders??{},workspacePath:a?.path||r.workspacePath,projectName:a?.name||r.projectName,projectDisplayName:a?.displayName||r.projectDisplayName}},Yc=t=>{const s=new Set;return t.reduce((r,a)=>{const o=Bn(a);return!o||s.has(o)||(s.add(o),r.push({name:a.projectId,displayName:a.displayName||a.projectId,path:o})),r},[])},la=async(t,s,r)=>{const a=new URLSearchParams({scope:s});r?.path&&a.set("workspacePath",r.path);const o=await z(`/api/providers/${t}/mcp/servers?${a.toString()}`),i=await ws(o);if(!o.ok||!i.success)throw new Error(Ns(i,`Failed to load ${t} MCP servers`));return(i.data.servers||[]).map(l=>Qc(t,s,l,r))},ca=async(t,s)=>{const r=new URLSearchParams({scope:s.scope});s.workspacePath&&r.set("workspacePath",s.workspacePath);const a=await z(`/api/providers/${t}/mcp/servers/${encodeURIComponent(s.name)}?${r.toString()}`,{method:"DELETE"}),o=await ws(a);if(!a.ok||!o.success)throw new Error(Ns(o,"Failed to delete MCP server"))},Zc=async(t,s)=>{const r=await z(`/api/providers/${t}/mcp/servers`,{method:"POST",body:JSON.stringify(s)}),a=await ws(r);if(!r.ok||!a.success)throw new Error(Ns(a,"Failed to save MCP server"))},Xc=async t=>{const s=await z("/api/providers/mcp/servers/global",{method:"POST",body:JSON.stringify(t)}),r=await ws(s);if(!s.ok||!r.success)throw new Error(Ns(r,"Failed to save MCP server to all providers"));return r.data.results||[]},ed=(t,s)=>t.name!==s.name||t.scope!==s.scope||(t.workspacePath||"")!==(s.workspacePath||""),da=t=>`${t.provider}:${t.scope}:${t.workspacePath||"global"}:${t.name}`,td=(t,s)=>{const r=s.map(a=>a.path).sort().join("|");return`${t}:${r}`},sd=t=>t.map(s=>`${Pr[s.provider]}: ${s.error||"Unknown error"}`).join("; "),ts=t=>{const s={user:0,project:1,local:2};return[...t].sort((r,a)=>{const o=s[r.scope]-s[a.scope];if(o!==0)return o;const i=(r.projectDisplayName||"").localeCompare(a.projectDisplayName||"");return i!==0?i:r.name.localeCompare(a.name)})},rd=(t,s)=>{const r=new Map;return t.forEach(a=>{r.set(da(a),a)}),s.forEach(a=>{r.set(da(a),a)}),ts([...r.values()])},ua=(t,s,r,a)=>{const o=t.filter(i=>i.scope!==r||(i.workspacePath||"")!==(a||""));return rd(o,s)};function ad({selectedProvider:t,currentProjects:s}){const[r,a]=n.useState([]),[o,i]=n.useState(!1),[l,c]=n.useState(null),[m,d]=n.useState(null),[u,x]=n.useState(null),[h,p]=n.useState(!1),[f,b]=n.useState(!1),[g,v]=n.useState(!1),[S,k]=n.useState(null),y=n.useRef(0),P=n.useMemo(()=>Yc(s),[s]),E=n.useMemo(()=>td(t,P),[P,t]),C=n.useCallback(async(X={})=>{const H=y.current+1;y.current=H;const B=ct.get(E);if(!X.force&&B&&Date.now()-B.updatedAt<Hc){a(B.servers),i(!1),p(!1),c(null);return}B&&!X.force?a(B.servers):a([]),i(!B),p(!1),c(null);const D=vs[t];let L=B&&!X.force?B.servers:[],O=null;if(D.includes("user"))try{const A=await la(t,"user");if(y.current!==H)return;L=ua(L,A,"user"),a(ts(L))}catch(A){O=es(A)}if(y.current!==H)return;i(!1);const U=[];if(P.forEach(A=>{D.includes("project")&&U.push({scope:"project",project:A}),D.includes("local")&&U.push({scope:"local",project:A})}),U.length===0){const A=ts(L);ct.set(E,{servers:A,updatedAt:Date.now()}),c(O);return}if(p(!0),await Promise.all(U.map(async({scope:A,project:ee})=>{try{const V=await la(t,A,ee);if(y.current!==H)return;L=ua(L,V,A,ee.path),a(L)}catch(V){O=O||es(V)}})),y.current!==H)return;const N=ts(L);ct.set(E,{servers:N,updatedAt:Date.now()}),a(N),c(O),p(!1)},[E,P,t]),T=n.useCallback(X=>{k(X||null),b(!0)},[]),I=n.useCallback(()=>{b(!1),k(null)},[]),j=n.useCallback(()=>{v(!0)},[]),$=n.useCallback(()=>{v(!1)},[]),G=n.useCallback(async(X,H)=>{const B=ia(t,X);if(B.scope!=="user"&&!B.workspacePath)throw new Error("Select a project for project-scoped MCP servers");await Zc(t,B),H&&ed(H,B)&&await ca(t,H),ct.delete(E),await C({force:!0}),x("success"),I()},[E,I,C,t]),K=n.useCallback(async X=>{const H=ia(t,X,{supportedTransports:Vn,supportsWorkingDirectory:!1,includeProviderSpecificFields:!1,unsupportedTransportMessage:D=>`Add MCP Server supports only stdio and http across all providers, not ${D}.`});if(H.scope==="local")throw new Error("Add MCP Server supports only user or project scope across all providers.");if(H.scope!=="user"&&!H.workspacePath)throw new Error("Select a project for project-scoped MCP servers");const B=await Xc(H);ct.clear(),await C({force:!0});const w=B.filter(D=>!D.created);if(w.length>0)throw x("error"),new Error(`Failed to add MCP server to all providers. ${sd(w)}`);x("success"),$()},[$,C,t]),M=n.useCallback(async X=>{if(window.confirm("Are you sure you want to delete this MCP server?")){d(null);try{await ca(t,X),ct.delete(E),await C({force:!0}),x("success")}catch(H){d(es(H)),x("error")}}},[E,C,t]);return n.useEffect(()=>{C()},[C]),n.useEffect(()=>{b(!1),v(!1),k(null),d(null),x(null)},[t]),n.useEffect(()=>{if(u===null)return;const X=window.setTimeout(()=>x(null),2e3);return()=>window.clearTimeout(X)},[u]),{servers:r,isLoading:o,isLoadingProjectScopes:h,loadError:l,deleteError:m,saveStatus:u,isFormOpen:f,isGlobalFormOpen:g,editingServer:S,openForm:T,openGlobalForm:j,closeForm:I,closeGlobalForm:$,submitForm:G,submitGlobalForm:K,deleteServer:M,refreshServers:C}}const ss=(t,s=vs[t],r=js[t])=>({...Vc,scope:s[0],transport:r[0],args:[],env:{},headers:{},envVars:[],envHttpHeaders:{}}),nd=(t,s,r,a)=>({...ss(t,r,a),name:s.name,scope:s.scope,workspacePath:s.workspacePath||"",transport:s.transport,command:s.command||"",args:s.args||[],env:s.env||{},cwd:s.cwd||"",url:s.url||"",headers:s.headers||{},envVars:s.envVars||[],bearerTokenEnvVar:s.bearerTokenEnvVar||"",envHttpHeaders:s.envHttpHeaders||{}}),Ys=t=>({args:t.args.join(`
6
- `),env:qs(t.env),headers:qs(t.headers),envVars:t.envVars.join(`
7
- `),envHttpHeaders:qs(t.envHttpHeaders)}),od=(t,s)=>t.includes(s)?s:t[0],id=(t,s)=>t.includes(s)?s:t[0];function ld({provider:t,isOpen:s,editingServer:r,currentProjects:a,supportedScopes:o=vs[t],supportedTransports:i=js[t],unsupportedTransportMessage:l,onSubmit:c}){const{t:m}=ce("settings"),[d,u]=n.useState(()=>ss(t,o,i)),[x,h]=n.useState(()=>Ys(ss(t,o,i))),[p,f]=n.useState(""),[b,g]=n.useState(!1),v=!!r;n.useEffect(()=>{if(!s)return;if(f(""),r){const K=nd(t,r,o,i);u(K),h(Ys(K));return}const G=ss(t,o,i);u(G),h(Ys(G))},[r,s,t,o,i]);const S=n.useMemo(()=>a.map(G=>({value:Bn(G),label:G.displayName||G.projectId})).filter(G=>G.value),[a]),k=(G,K)=>{u(M=>({...M,[G]:K}))},y=G=>{u(K=>({...K,scope:od(o,G),workspacePath:G==="user"?"":K.workspacePath}))},P=G=>{u(K=>({...K,transport:id(i,G)}))},E=G=>{if(!G.trim()){f("");return}try{const K=JSON.parse(G),M=K.transport||K.type;Tr(M)?i.includes(M)?M==="stdio"&&!K.command?f(m("mcpForm.validation.stdioRequiresCommand")):(M==="http"||M==="sse")&&!K.url?f(m("mcpForm.validation.httpRequiresUrl",{type:M})):f(""):f(l?.(M)??`${t} does not support ${M} MCP servers`):f(m("mcpForm.validation.missingType"))}catch{f(m("mcpForm.validation.invalidJson"))}},C=G=>{u(K=>({...K,jsonInput:G})),E(G)},T=(G,K)=>{h(M=>({...M,[G]:K}))},I=()=>({...d,args:oa(x.args),env:Qs(x.env),headers:Qs(x.headers),envVars:oa(x.envVars),envHttpHeaders:Qs(x.envHttpHeaders)}),j=n.useMemo(()=>!d.name.trim()||d.scope!=="user"&&!d.workspacePath.trim()?!1:d.importMode==="json"?!!d.jsonInput.trim()&&!p:d.transport==="stdio"?!!d.command.trim():!!d.url.trim(),[d,p]);return{formData:d,setFormData:u,multilineText:x,projectOptions:S,isEditing:v,isSubmitting:b,jsonValidationError:p,canSubmit:j,updateForm:k,updateScope:y,updateTransport:P,updateJsonInput:C,updateMultilineText:T,handleSubmit:async G=>{G.preventDefault(),g(!0);try{await c(I(),r)}catch(K){alert(`Error: ${es(K)}`)}finally{g(!1)}}}}const ma=(t,s)=>t==="user"?s==="global"?"User (All Providers)":"User (Global)":t==="local"?"Claude Local":s==="global"?"Project (All Providers)":"Project",cd=(t,s)=>t==="user"?s==="global"?"Writes to each provider user config and is available across projects on this machine":"Available across all projects on your machine":t==="local"?"Stored in Claude user settings for the selected project":s==="global"?"Writes to the selected project workspace for every provider":"Stored in the selected project workspace";function pa({provider:t,mode:s="provider",isOpen:r,editingServer:a,currentProjects:o,title:i,description:l,submitLabel:c,supportedScopes:m,supportedTransports:d,onClose:u,onSubmit:x}){const{t:h}=ce("settings"),p=s==="global",f=m??vs[t],b=d??js[t],{formData:g,multilineText:v,projectOptions:S,isEditing:k,isSubmitting:y,jsonValidationError:P,canSubmit:E,updateForm:C,updateScope:T,updateTransport:I,updateJsonInput:j,updateMultilineText:$,handleSubmit:G}=ld({provider:t,isOpen:r,editingServer:a,currentProjects:o,supportedScopes:f,supportedTransports:b,unsupportedTransportMessage:p?L=>`Add MCP Server supports only stdio and http across all providers, not ${L}.`:void 0,onSubmit:x});if(!r)return null;const K=Pr[t],M=i??h(k?"mcpForm.title.edit":"mcpForm.title.add"),X=c??`${h("mcpForm.actions.addServer")} to ${K}`,H=g.scope!=="user",B=g.transport==="http"||g.transport==="sse",w=!p&&Er[t],D=t==="codex"&&!p;return ys.createPortal(e.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-black/50 p-4",children:e.jsxs("div",{className:"max-h-[90vh] w-full max-w-2xl overflow-y-auto rounded-lg border border-border bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border p-4",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:M}),e.jsx(W,{variant:"ghost",size:"sm",onClick:u,children:e.jsx(ge,{className:"h-4 w-4"})})]}),e.jsxs("form",{onSubmit:G,className:"space-y-4 p-4",children:[l&&e.jsx("div",{className:"rounded-lg border border-border bg-muted/40 px-3 py-2 text-sm text-muted-foreground",children:l}),!k&&e.jsxs("div",{className:"mb-4 flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>C("importMode","form"),className:`rounded-lg px-4 py-2 font-medium transition-colors ${g.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"}`,children:h("mcpForm.importMode.form")}),e.jsx("button",{type:"button",onClick:()=>C("importMode","json"),className:`rounded-lg px-4 py-2 font-medium transition-colors ${g.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"}`,children:h("mcpForm.importMode.json")})]}),k&&e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-gray-900/50",children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-foreground",children:h("mcpForm.scope.label")}),e.jsxs("div",{className:"flex items-center gap-2",children:[g.scope==="user"?e.jsx(ds,{className:"h-4 w-4"}):e.jsx(Lt,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:ma(g.scope,s)}),g.workspacePath&&e.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["- ",g.workspacePath]})]}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:h("mcpForm.scope.cannotChange")})]}),!k&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-foreground",children:[h("mcpForm.scope.label")," *"]}),e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:f.map(L=>e.jsx("button",{type:"button",onClick:()=>T(L),className:`rounded-lg px-4 py-2 font-medium transition-colors ${g.scope===L?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[L==="user"?e.jsx(ds,{className:"h-4 w-4"}):e.jsx(Lt,{className:"h-4 w-4"}),e.jsx("span",{children:ma(L,s)})]})},L))}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:cd(g.scope,s)})]}),H&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-foreground",children:[h("mcpForm.fields.selectProject")," *"]}),e.jsxs("select",{value:g.workspacePath,onChange:L=>C("workspacePath",L.target.value),className:"w-full rounded-lg border border-gray-300 bg-gray-50 px-3 py-2 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100",required:!0,children:[e.jsx("option",{value:"",children:h("mcpForm.fields.selectProject")}),S.map(L=>e.jsx("option",{value:L.value,children:L.label},L.value))]}),g.workspacePath&&e.jsx("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:h("mcpForm.projectPath",{path:g.workspacePath})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:g.importMode==="json"?"md:col-span-2":"",children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-foreground",children:[h("mcpForm.fields.serverName")," *"]}),e.jsx(me,{value:g.name,onChange:L=>C("name",L.target.value),placeholder:h("mcpForm.placeholders.serverName"),required:!0})]}),g.importMode==="form"&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-foreground",children:[h("mcpForm.fields.transportType")," *"]}),e.jsx("select",{value:g.transport,onChange:L=>I(L.target.value),className:"w-full rounded-lg border border-gray-300 bg-gray-50 px-3 py-2 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100",children:b.map(L=>e.jsx("option",{value:L,children:L==="sse"?"SSE":L.toUpperCase()},L))})]})]}),g.importMode==="json"&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-foreground",children:[h("mcpForm.fields.jsonConfig")," *"]}),e.jsx("textarea",{value:g.jsonInput,onChange:L=>j(L.target.value),className:`w-full border px-3 py-2 ${P?"border-red-500":"border-gray-300 dark:border-gray-600"} rounded-lg bg-gray-50 font-mono text-sm text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:bg-gray-800 dark:text-gray-100`,rows:8,placeholder:`{
8
- "type": "stdio",
9
- "command": "npx",
10
- "args": ["@upstash/context7-mcp"]
11
- }`,required:!0}),P&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:P}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:[h("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"}']})]}),g.importMode==="form"&&g.transport==="stdio"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-foreground",children:[h("mcpForm.fields.command")," *"]}),e.jsx(me,{value:g.command,onChange:L=>C("command",L.target.value),placeholder:"npx @my-org/mcp-server",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-foreground",children:h("mcpForm.fields.arguments")}),e.jsx("textarea",{value:v.args,onChange:L=>$("args",L.target.value),className:"w-full rounded-lg border border-gray-300 bg-gray-50 px-3 py-2 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100",rows:3,placeholder:`--port
12
- 3000`})]}),w&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-foreground",children:"Working Directory"}),e.jsx(me,{value:g.cwd,onChange:L=>C("cwd",L.target.value),placeholder:"."})]})]}),g.importMode==="form"&&g.transport!=="stdio"&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-sm font-medium text-foreground",children:[h("mcpForm.fields.url")," *"]}),e.jsx(me,{value:g.url,onChange:L=>C("url",L.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),g.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-foreground",children:h("mcpForm.fields.envVars")}),e.jsx("textarea",{value:v.env,onChange:L=>$("env",L.target.value),className:"w-full rounded-lg border border-gray-300 bg-gray-50 px-3 py-2 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100",rows:3,placeholder:`API_KEY=your-key
13
- DEBUG=true`})]}),g.importMode==="form"&&B&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-foreground",children:h("mcpForm.fields.headers")}),e.jsx("textarea",{value:v.headers,onChange:L=>$("headers",L.target.value),className:"w-full rounded-lg border border-gray-300 bg-gray-50 px-3 py-2 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100",rows:3,placeholder:`Authorization=Bearer token
14
- X-API-Key=your-key`})]}),D&&g.importMode==="form"&&g.transport==="stdio"&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-foreground",children:"Environment Variable Names"}),e.jsx("textarea",{value:v.envVars,onChange:L=>$("envVars",L.target.value),className:"w-full rounded-lg border border-gray-300 bg-gray-50 px-3 py-2 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100",rows:3,placeholder:`GITHUB_TOKEN
15
- API_KEY`})]}),D&&g.importMode==="form"&&g.transport==="http"&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-foreground",children:"Bearer Token Environment Variable"}),e.jsx(me,{value:g.bearerTokenEnvVar,onChange:L=>C("bearerTokenEnvVar",L.target.value),placeholder:"MCP_TOKEN"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(W,{type:"button",variant:"outline",onClick:u,children:h("mcpForm.actions.cancel")}),e.jsx(W,{type:"submit",disabled:y||!E,className:"bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:y?h("mcpForm.actions.saving"):k?h("mcpForm.actions.updateServer"):X})]})]})]})}),document.body)}const dd=t=>t==="stdio"?e.jsx($a,{className:"h-4 w-4"}):t==="sse"?e.jsx(So,{className:"h-4 w-4"}):t==="http"?e.jsx(ds,{className:"h-4 w-4"}):e.jsx(nr,{className:"h-4 w-4"}),ud=t=>t==="user"?"user":t==="local"?"local":"project",md=t=>`${t.provider}:${t.scope}:${t.workspacePath||"global"}:${t.name}`,pd=t=>t.name.startsWith("cloudcli-");function dt({label:t,children:s}){return s?e.jsxs("div",{children:[t,":"," ",e.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:s})]}):null}function xd({selectedProvider:t,currentProjects:s}){const{t:r}=ce("settings"),{servers:a,isLoading:o,isLoadingProjectScopes:i,loadError:l,deleteError:c,saveStatus:m,isFormOpen:d,isGlobalFormOpen:u,editingServer:x,openForm:h,openGlobalForm:p,closeForm:f,closeGlobalForm:b,submitForm:g,submitGlobalForm:v,deleteServer:S}=ad({selectedProvider:t,currentProjects:s}),k=Pr[t],y=r(`mcpServers.description.${t}`,{defaultValue:`Model Context Protocol servers provide additional tools and data sources to ${k}`}),P="Add Global MCP Server",E=`Add ${k} MCP Server`,C="Add Global MCP Server writes one common stdio or HTTP server to Claude, Cursor, Codex, and OpenCode.",T=`${E} only changes ${k}.`;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx(nr,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-purple-500"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:r("mcpServers.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:y})]})]}),e.jsx(kn,{label:"Add MCP Server",icon:Ee,className:"w-full sm:w-auto",triggerClassName:`w-full sm:w-auto ${Gc[t]}`,items:[{key:"global",label:P,description:C,icon:ds,onSelect:p},{key:"provider",label:E,description:T,icon:nr,onSelect:()=>h()}]})]}),e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"min-h-4",children:[m==="success"&&e.jsx("span",{className:"animate-in fade-in text-xs text-muted-foreground",children:r("saveStatus.success")}),i&&e.jsx("span",{className:"animate-in fade-in text-xs text-muted-foreground",children:"Refreshing project scopes..."})]})}),(l||c)&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800/60 dark:bg-red-900/20 dark:text-red-200",children:c||l}),e.jsxs("div",{className:"space-y-2",children:[o&&a.length===0&&e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"Loading MCP servers..."}),a.map(j=>{const $=pd(j);return e.jsx("div",{className:"rounded-lg border border-border bg-card/50 p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[!$&&dd(j.transport),e.jsx("span",{className:"font-medium text-foreground",children:j.name}),!$&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{variant:"outline",className:"text-xs",children:j.transport||"stdio"}),e.jsx(Pe,{variant:"outline",className:"text-xs",children:ud(j.scope)}),j.projectDisplayName&&e.jsx(Pe,{variant:"outline",className:"max-w-full truncate text-xs",children:j.projectDisplayName})]}),$&&e.jsxs(Pe,{variant:"outline",className:"gap-1 text-xs text-muted-foreground",children:[e.jsx(ko,{className:"h-3 w-3"}),r("mcpServers.managed.badge",{defaultValue:"Managed"})]})]}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground",children:[!$&&e.jsxs(e.Fragment,{children:[e.jsx(dt,{label:r("mcpServers.config.command"),children:j.command||""}),e.jsx(dt,{label:r("mcpServers.config.url"),children:j.url||""}),e.jsx(dt,{label:r("mcpServers.config.args"),children:(j.args||[]).join(" ")}),e.jsx(dt,{label:"Cwd",children:j.cwd||""}),j.env&&Object.keys(j.env).length>0&&e.jsx(dt,{label:r("mcpServers.config.environment"),children:Object.entries(j.env).map(([G,K])=>`${G}=${Kc(K)}`).join(", ")}),j.envVars&&j.envVars.length>0&&e.jsx(dt,{label:"Env Vars",children:j.envVars.join(", ")})]}),$&&e.jsx("div",{className:"text-xs text-muted-foreground",children:r("mcpServers.managed.hint",{defaultValue:"Managed by WindCli."})})]})]}),!$&&e.jsxs("div",{className:"ml-4 flex items-center gap-2",children:[e.jsx(W,{onClick:()=>h(j),variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground",title:r("mcpServers.actions.edit"),children:e.jsx(ar,{className:"h-4 w-4"})}),e.jsx(W,{onClick:()=>S(j),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:r("mcpServers.actions.delete"),children:e.jsx(Te,{className:"h-4 w-4"})})]})]})},md(j))}),!o&&!i&&a.length===0&&e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:r("mcpServers.empty")})]}),t==="codex"&&e.jsxs("div",{className:"rounded-lg border border-border bg-muted/50 p-4",children:[e.jsx("h4",{className:"mb-2 font-medium text-foreground",children:r("mcpServers.help.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("mcpServers.help.description")})]}),e.jsx(pa,{provider:t,isOpen:d,editingServer:x,currentProjects:s,title:x?void 0:E,submitLabel:E,onClose:f,onSubmit:g}),e.jsx(pa,{provider:t,mode:"global",isOpen:u,editingServer:null,currentProjects:s,title:P,description:"Adds this MCP server to every provider: Claude, Cursor, Codex, and OpenCode. Only stdio and HTTP transports are supported because the same config must work across all providers.",submitLabel:P,supportedScopes:Uc,supportedTransports:Vn,onClose:b,onSubmit:j=>v(j)})]})}const hd=5*6e4,At=new Map,xa={user:0,plugin:1,repo:2,project:3,admin:4,system:5},Hn=async t=>t.json(),Jn=(t,s)=>{if(!t||typeof t!="object")return s;const r=t,a=r.error;if(a&&typeof a=="object"){const i=a.message;if(typeof i=="string"&&i.trim())return i}if(typeof a=="string"&&a.trim())return a;const o=r.details;return typeof o=="string"&&o.trim()?o:s},gd=t=>t==="user"||t==="project"||t==="plugin"||t==="repo"||t==="admin"||t==="system",fd=t=>gd(t)?t:"user",bd=t=>{const s=new Set;return t.reduce((a,o)=>{const i=o.fullPath||o.path||"";return!i||s.has(i)||(s.add(i),a.push({projectId:o.projectId,displayName:o.displayName||o.projectId,path:i})),a},[]).sort((a,o)=>a.path.localeCompare(o.path))},qn=(t,s,r)=>{const a=fd(s.scope),o=a==="project"||a==="repo";return{provider:t,name:String(s.name??""),description:String(s.description??""),command:String(s.command??""),scope:a,sourcePath:String(s.sourcePath??""),pluginName:typeof s.pluginName=="string"?s.pluginName:void 0,pluginId:typeof s.pluginId=="string"?s.pluginId:void 0,projectDisplayName:o?r?.displayName??s.projectDisplayName:s.projectDisplayName,projectPath:o?r?.path??s.projectPath:s.projectPath}},ha=t=>[t.provider,t.scope,t.command,t.sourcePath||"no-source-path",t.projectPath||"global"].join(":"),mr=t=>[...t].sort((s,r)=>{const a=xa[s.scope]-xa[r.scope];if(a!==0)return a;const o=(s.projectDisplayName||"").localeCompare(r.projectDisplayName||"");return o!==0?o:s.command.localeCompare(r.command)}),ga=(t,s)=>{const r=new Map;return t.forEach(a=>{r.set(ha(a),a)}),s.forEach(a=>{r.set(ha(a),a)}),mr([...r.values()])},fa=async(t,s)=>{const r=new URLSearchParams;s?.path&&r.set("workspacePath",s.path);const a=await z(`/api/providers/${t}/skills${r.toString()?`?${r.toString()}`:""}`),o=await Hn(a);if(!a.ok||!o.success)throw new Error(Jn(o,`Failed to load ${t} skills`));return(o.data.skills||[]).map(i=>qn(t,i,s))},yd=async(t,s)=>{const r=await z(`/api/providers/${t}/skills`,{method:"POST",body:JSON.stringify(s)}),a=await Hn(r);if(!r.ok||!a.success)throw new Error(Jn(a,"Failed to save skills"));return(a.data.skills||[]).map(o=>qn(t,o))},vd=(t,s)=>{const r=JSON.stringify(s);return`${t}:${r}`},jd=t=>{for(const s of[...At.keys()])s.startsWith(`${t}:`)&&At.delete(s)};function wd({selectedProvider:t,currentProjects:s}){const[r,a]=n.useState([]),[o,i]=n.useState(!1),[l,c]=n.useState(!1),[m,d]=n.useState(null),[u,x]=n.useState(null),h=n.useRef(0),p=JSON.stringify(bd(s)),f=n.useMemo(()=>JSON.parse(p),[p]),b=n.useMemo(()=>vd(t,f),[f,t]),g=n.useCallback(async(S={})=>{const k=h.current+1;h.current=k;const y=At.get(b);if(!S.force&&y&&Date.now()-y.updatedAt<hd){a(y.skills),i(!1),c(!1),d(null);return}a(y?y.skills:[]),i(!!S.force||!y),c(!1),d(null);let E=y&&!S.force?y.skills:[],C=null;try{const I=await fa(t);if(h.current!==k)return;E=ga(E,I),a(E)}catch(I){C=I instanceof Error?I.message:"Failed to load skills"}if(h.current!==k)return;if(i(!1),f.length===0){const I=mr(E);At.set(b,{skills:I,updatedAt:Date.now()}),a(I),d(C);return}if(c(!0),await Promise.all(f.map(async I=>{try{const j=await fa(t,I);if(h.current!==k)return;E=ga(E,j),a(E)}catch(j){C=C||(j instanceof Error?j.message:"Failed to load skills")}})),h.current!==k)return;const T=mr(E);At.set(b,{skills:T,updatedAt:Date.now()}),a(T),d(C),c(!1)},[b,f,t]),v=n.useCallback(async S=>{try{const k=await yd(t,S);return jd(t),await g({force:!0}),x("success"),k}catch(k){throw x("error"),k}},[g,t]);return n.useEffect(()=>(g(),()=>{h.current+=1}),[g]),n.useEffect(()=>{x(null)},[t]),n.useEffect(()=>{if(u===null)return;const S=window.setTimeout(()=>x(null),6e3);return()=>window.clearTimeout(S)},[u]),{skills:r,isLoading:o,isLoadingProjectScopes:l,loadError:m,saveStatus:u,addSkills:v,refreshSkills:g}}const pr=500,Nd=30*1024*1024,kd={claude:"Claude",codex:"Codex",cursor:"Cursor",opencode:"OpenCode"},Sd={claude:"~/.claude/skills/<skill-name>/SKILL.md",codex:"~/.agents/skills/<skill-name>/SKILL.md",cursor:"~/.cursor/skills/<skill-name>/SKILL.md"},Cd={user:"User",plugin:"Plugin",repo:"Repo",project:"Project",admin:"Admin",system:"System"},Pd={user:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",plugin:"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",repo:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",project:"border-orange-500/30 bg-orange-500/10 text-orange-700 dark:text-orange-300",admin:"border-rose-500/30 bg-rose-500/10 text-rose-700 dark:text-rose-300",system:"border-slate-500/30 bg-slate-500/10 text-slate-700 dark:text-slate-300"},Ed=["user","plugin","repo","project","admin","system"],Td=t=>Ed.map(s=>({scope:s,skills:t.filter(r=>r.scope===s)})).filter(s=>s.skills.length>0),Id=t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,Qn=t=>{const s=t;return(s.webkitRelativePath||s.path||t.name).replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")},Rd=t=>{const s=t.lastIndexOf("/");return s>=0?t.slice(0,s):""},Zs=t=>t.split("/").filter(Boolean).at(-1)||"skill",Ad=t=>new Promise((s,r)=>{const a=new FileReader;a.onload=()=>{const o=typeof a.result=="string"?a.result:"",i=o.indexOf(",");s(i>=0?o.slice(i+1):o)},a.onerror=()=>r(a.error??new Error(`Failed to read ${t.name}`)),a.readAsDataURL(t)}),Ld=t=>{if(t.length>pr)throw new Error(`A skill folder can contain up to ${pr} files.`);if(t.reduce((o,i)=>o+i.size,0)>Nd)throw new Error("Selected skill folders must be smaller than 30 MB in total.");const r=t.map(o=>({file:o,relativePath:Qn(o)})),a=r.filter(({relativePath:o})=>Zs(o).toLowerCase()==="skill.md").map(({relativePath:o})=>Rd(o)).sort((o,i)=>i.length-o.length);if(a.length===0)throw new Error("The selected folder does not contain a SKILL.md file.");return a.map(o=>{const i=r.filter(({relativePath:c})=>a.find(d=>{const u=c.toLowerCase(),x=`${d}/skill.md`.toLowerCase();return u===x||c.startsWith(`${d}/`)})===o),l=i.find(({relativePath:c})=>c.toLowerCase()===`${o}/skill.md`.toLowerCase());if(!l)throw new Error(`Could not read SKILL.md from ${Zs(o)}.`);return{id:`folder:${o}:${i.map(({file:c})=>c.lastModified).join(":")}`,name:Zs(o),size:i.reduce((c,{file:m})=>c+m.size,0),kind:"folder",skillFile:l.file,files:i.map(({file:c,relativePath:m})=>({file:c,relativePath:o?m.slice(o.length+1):m}))}})};function Md({selectedProvider:t,currentProjects:s}){const{t:r}=ce("settings"),{skills:a,isLoading:o,isLoadingProjectScopes:i,loadError:l,saveStatus:c,addSkills:m,refreshSkills:d}=wd({selectedProvider:t,currentProjects:s}),[u,x]=n.useState([]),[h,p]=n.useState(null),[f,b]=n.useState(!1),[g,v]=n.useState(!1),[S,k]=n.useState(""),[y,P]=n.useState(!1),[E,C]=n.useState(!1),T=n.useRef(null),I=n.useRef(null),j=kd[t],$=t==="opencode"?null:Sd[t];n.useEffect(()=>{x([]),p(null),b(!1),k(""),P(!1),C(!1),v(!1)},[t]);const G=n.useCallback(N=>{I.current=N,N&&(N.setAttribute("webkitdirectory",""),N.setAttribute("directory",""))},[]),K=n.useMemo(()=>{const N=S.trim().toLocaleLowerCase();return N?a.filter(A=>[A.command,A.name,A.description,A.scope,A.pluginName,A.projectDisplayName,A.sourcePath].filter(Boolean).some(ee=>ee?.toLocaleLowerCase().includes(N))):a},[S,a]),M=n.useMemo(()=>Td(K),[K]),X=n.useCallback(N=>{const A=Ld(N);x(ee=>{const V=new Map(ee.map(ae=>[ae.id,ae]));return A.forEach(ae=>V.set(ae.id,ae)),[...V.values()].slice(0,20)})},[]),H=n.useCallback(N=>{if(N.some(V=>Qn(V).includes("/"))){try{X(N),p(null)}catch(V){p(V instanceof Error?V.message:"Failed to read skill folder")}return}const ee=N.filter(V=>V.name.toLowerCase().endsWith(".md")).slice(0,20);if(ee.length===0){p("Drop one or more markdown files or a folder containing SKILL.md.");return}x(V=>{const ae=new Map(V.map(de=>[de.id,de]));return ee.forEach(de=>{const te=`${de.name}:${de.size}:${de.lastModified}`;ae.set(te,{id:te,name:de.name,size:de.size,kind:"markdown",skillFile:de,files:[{file:de,relativePath:"SKILL.md"}]})}),[...ae.values()].slice(0,20)}),p(null)},[X]),B=n.useCallback(N=>{if(N.length!==0)try{X(N),p(null)}catch(A){p(A instanceof Error?A.message:"Failed to read skill folder")}},[X]),{getRootProps:w,isDragActive:D}=Co({maxFiles:pr,noClick:!0,noKeyboard:!0,onDrop:H}),L=n.useCallback(async()=>{if(u.length===0){p("Add one or more markdown files first.");return}b(!0),p(null);try{const N=await Promise.all(u.map(async A=>({fileName:A.kind==="folder"?`${A.name}.md`:A.name,directoryName:A.kind==="folder"?A.name:void 0,content:await A.skillFile.text(),files:A.kind==="folder"?await Promise.all(A.files.filter(({relativePath:ee})=>ee.toLowerCase()!=="skill.md").map(async({file:ee,relativePath:V})=>({relativePath:V,content:await Ad(ee),encoding:"base64"}))):void 0})));await m({entries:N}),x([]),v(!0),P(!1)}catch(N){p(N instanceof Error?N.message:"Failed to import skills")}finally{b(!1)}},[m,u]),O=n.useCallback(N=>{if(N){p(null),C(!1),v(!1),P(!0);return}x([]),p(null),C(!1),v(!1),P(!1)},[]),U=e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{...w(),className:F("rounded-lg border border-dashed p-4 transition-colors sm:p-5",D?"border-foreground/40 bg-muted/35":"border-border/70 bg-muted/15 hover:border-foreground/25 hover:bg-muted/25"),children:[e.jsx("input",{ref:T,type:"file",accept:".md,text/markdown",multiple:!0,className:"hidden",onChange:N=>{H(Array.from(N.target.files??[])),N.target.value=""}}),e.jsx("input",{ref:G,type:"file",multiple:!0,className:"hidden",onChange:N=>{B(Array.from(N.target.files??[])),N.target.value=""}}),e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-4 text-center",children:[e.jsx(Vs,{className:"h-7 w-7 text-muted-foreground",strokeWidth:1.5}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Drop a skill folder or SKILL.md"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Folders can include scripts, references, and assets."})]}),e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row",children:[e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:()=>T.current?.click(),className:"w-full sm:w-auto",children:[e.jsx(Vs,{className:"h-4 w-4"}),"Choose Files"]}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:()=>I.current?.click(),className:"w-full sm:w-auto",children:[e.jsx(Mr,{className:"h-4 w-4"}),"Choose Folder"]})]})]})]}),u.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Ready to install"}),e.jsx("div",{className:"grid gap-2",children:u.map(N=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border/70 bg-background/70 px-3 py-2",children:[e.jsx("div",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md bg-muted/60 text-muted-foreground",children:N.kind==="folder"?e.jsx(Mr,{className:"h-4 w-4"}):e.jsx(Fr,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:N.name}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[N.kind==="folder"?`${N.files.length} files`:"Markdown file"," · ",Id(N.size)]})]}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground","aria-label":`Remove ${N.name}`,onClick:()=>{x(A=>A.filter(ee=>ee.id!==N.id))},children:e.jsx(ge,{className:"h-4 w-4"})})]},N.id))})]}),$&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("button",{type:"button",className:"text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",onClick:()=>C(N=>!N),children:E?"Hide install location":"Where will this install?"}),E&&e.jsx("div",{className:"rounded-lg border border-border/60 bg-muted/15 p-3",children:e.jsx("code",{className:"block whitespace-normal break-all text-xs text-foreground",children:$})})]})]});return e.jsxs("div",{className:"min-w-0 space-y-4 overflow-x-hidden",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border/70 bg-muted/20 text-muted-foreground",children:e.jsx(Po,{className:"h-4 w-4",strokeWidth:1.7})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:r("tabs.skills",{defaultValue:"Skills"})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Manage ",j," skills from local files, complete folders, and project-aware locations."]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative min-w-0 flex-1 sm:max-w-md",children:[e.jsx(et,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(me,{type:"text",value:S,onChange:N=>k(N.target.value),placeholder:"Search skills...","aria-label":"Search skills",className:"h-9 w-full pl-9 pr-9"}),S&&e.jsx("button",{type:"button",onClick:()=>k(""),"aria-label":"Clear skill search",className:"absolute right-1.5 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:e.jsx(ge,{className:"h-3.5 w-3.5"})})]}),e.jsxs(W,{type:"button",size:"sm",className:"w-full sm:w-auto",onClick:()=>O(!0),children:[e.jsx(Ee,{className:"h-4 w-4"}),"Add Skill"]}),e.jsxs(W,{onClick:()=>{d({force:!0})},variant:"outline",size:"sm",className:"w-full sm:w-auto",disabled:o||i,children:[e.jsx(is,{className:F("h-4 w-4",(o||i)&&"animate-spin")}),"Refresh"]})]}),i&&e.jsxs("div",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}),"Scanning project skills..."]})]}),e.jsx(Mn,{open:y,onOpenChange:O,children:e.jsxs(kr,{wrapperClassName:"z-[10000]",className:"flex h-[calc(100vh-2rem)] max-h-[760px] w-[calc(100vw-2rem)] max-w-4xl flex-col overflow-hidden p-0 sm:h-[720px]",children:[e.jsxs(Sr,{children:["Add ",j," Skill"]}),e.jsx("div",{className:"flex-shrink-0 border-b border-border/60 px-4 py-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border/70 bg-muted/20 text-muted-foreground",children:e.jsx(Vs,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"text-base font-medium text-foreground",children:["Add ",j," Skill"]}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Upload a SKILL.md file or a complete skill folder."})]}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground","aria-label":"Close add skill dialog",disabled:f,onClick:()=>O(!1),children:e.jsx(ge,{className:"h-4 w-4"})})]})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:U}),e.jsxs("div",{className:"flex flex-shrink-0 flex-col gap-3 border-t border-border/60 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"min-w-0 flex-1",children:h||l||g&&c==="success"?e.jsx("div",{className:F("max-h-24 overflow-y-auto whitespace-pre-wrap rounded-lg border px-3 py-2 text-sm",h||l?"border-red-200 bg-red-50 text-red-700 dark:border-red-800/60 dark:bg-red-900/20 dark:text-red-200":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:h||l||"Skills saved successfully."}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Folder uploads keep the selected folder name; standalone files use the `name` in `SKILL.md`."})}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center",children:[e.jsx(W,{type:"button",variant:"outline",size:"sm",className:"w-full sm:w-auto",disabled:f,onClick:()=>O(!1),children:"Cancel"}),e.jsxs(W,{type:"button",size:"sm",className:"w-full sm:w-auto",onClick:()=>{L()},disabled:f||u.length===0,children:[f?e.jsx(ve,{className:"h-4 w-4 animate-spin"}):e.jsx(Eo,{className:"h-4 w-4"}),"Install ",u.length>0?`${u.length} Skill${u.length===1?"":"s"}`:"Skill"]})]})]})]})}),!y&&(h||l)&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800/60 dark:bg-red-900/20 dark:text-red-200",children:h||l}),g&&c==="success"&&!y&&e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-3 py-1 text-xs font-medium text-emerald-700 dark:text-emerald-300",children:[e.jsx(To,{className:"h-4 w-4"}),"Skills saved successfully."]}),e.jsxs("div",{className:"space-y-5",children:[o&&a.length===0&&e.jsxs("div",{className:"flex min-h-[180px] items-center justify-center text-sm text-muted-foreground",children:["Loading ",j," skills…"]}),!o&&a.length===0&&e.jsxs("div",{className:"rounded-lg border border-dashed border-border/70 bg-muted/15 px-4 py-10 text-center",children:[e.jsx("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-lg border border-border/60 bg-background/80 text-muted-foreground",children:e.jsx(Fr,{className:"h-6 w-6"})}),e.jsx("div",{className:"mt-4 text-sm font-medium text-foreground",children:"No skills discovered yet"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Add a global skill above or create project-specific skill folders in your workspace."})]}),!o&&a.length>0&&K.length===0&&e.jsxs("div",{className:"rounded-lg border border-dashed border-border/70 bg-muted/15 px-4 py-10 text-center",children:[e.jsx(et,{className:"mx-auto h-6 w-6 text-muted-foreground"}),e.jsx("div",{className:"mt-3 text-sm font-medium text-foreground",children:"No matching skills"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Try a different command, name, scope, project, or source path."})]}),M.map(N=>e.jsxs("section",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{variant:"outline",className:F("rounded-full px-2.5 py-1 text-xs",Pd[N.scope]),children:Cd[N.scope]}),e.jsxs("span",{className:"text-xs uppercase tracking-[0.18em] text-muted-foreground",children:[N.skills.length," skill",N.skills.length===1?"":"s"]})]}),e.jsx("div",{className:"grid min-w-0 gap-3 lg:grid-cols-2",children:N.skills.map(A=>e.jsxs("div",{className:"min-w-0 rounded-lg border border-border bg-card/50 p-4",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("div",{className:"break-all font-mono text-sm font-semibold text-foreground",children:A.command}),e.jsx("div",{className:"text-sm text-muted-foreground",children:A.name})]}),e.jsx("p",{className:"mt-3 text-sm leading-relaxed text-muted-foreground",children:A.description||"No description provided in the skill front matter."}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[A.pluginName&&e.jsxs(Pe,{variant:"outline",className:"rounded-full bg-background/70",children:["Plugin: ",A.pluginName]}),A.projectDisplayName&&e.jsxs(Pe,{variant:"outline",className:"rounded-full bg-background/70",children:["Project: ",A.projectDisplayName]})]}),e.jsxs("div",{className:"mt-4 min-w-0 rounded-lg border border-border/60 bg-muted/20 px-3 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Source"}),e.jsx("code",{className:"mt-1 block whitespace-normal break-all text-xs text-foreground",children:A.sourcePath})]})]},`${A.command}:${A.sourcePath}:${A.projectPath||"global"}`))})]},N.scope))]})]})}const Fd={claude:{name:"Claude",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 active:bg-blue-800"},cursor:{name:"Cursor",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 active:bg-purple-800"},codex:{name:"Codex",bgClass:"bg-muted/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 active:bg-gray-950 dark:bg-gray-700 dark:hover:bg-gray-600 dark:active:bg-gray-500"},opencode:{name:"OpenCode",description:"OpenCode CLI assistant",bgClass:"bg-zinc-50 dark:bg-zinc-900/20",borderClass:"border-zinc-200 dark:border-zinc-700",textClass:"text-zinc-900 dark:text-zinc-100",subtextClass:"text-zinc-700 dark:text-zinc-300",buttonClass:"bg-zinc-900 hover:bg-zinc-800 active:bg-zinc-950 dark:bg-zinc-700 dark:hover:bg-zinc-600"}};function _d({agent:t,authStatus:s,onLogin:r}){const{t:a}=ce("settings"),o=Fd[t];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(_e,{provider:t,className:"h-6 w-6"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:o.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a(`agents.account.${t}.description`,{defaultValue:o.description||`${o.name} CLI assistant`})})]})]}),e.jsx("div",{className:`${o.bgClass} border ${o.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 ${o.textClass}`,children:a("agents.connectionStatus")}),e.jsx("div",{className:`text-sm ${o.subtextClass}`,children:s.loading?a("agents.authStatus.checkingAuth"):s.authenticated?a("agents.authStatus.loggedInAs",{email:s.email||a("agents.authStatus.authenticatedUser")}):a("agents.authStatus.notConnected")})]}),e.jsx("div",{children:s.loading?e.jsx(Pe,{variant:"secondary",className:"bg-muted",children:a("agents.authStatus.checking")}):s.authenticated?e.jsx(Pe,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:a("agents.authStatus.connected")}):e.jsx(Pe,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:a("agents.authStatus.disconnected")})})]}),s.method!=="api_key"&&e.jsx("div",{className:"border-t border-border/50 pt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:`font-medium ${o.textClass}`,children:s.authenticated?a("agents.login.reAuthenticate"):a("agents.login.title")}),e.jsx("div",{className:`text-sm ${o.subtextClass}`,children:s.authenticated?a("agents.login.reAuthDescription"):a("agents.login.description",{agent:o.name})})]}),e.jsxs(W,{onClick:r,className:`${o.buttonClass} text-white`,size:"sm",children:[e.jsx(Io,{className:"mr-2 h-4 w-4"}),s.authenticated?a("agents.login.reLoginButton"):a("agents.login.button")]})]})}),s.error&&e.jsx("div",{className:"border-t border-border/50 pt-4",children:e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:a("agents.error",{error:s.error})})})]})})]})}const Od=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],Dd=["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)"],fs=(t,s)=>{const r=s.trim();return!r||t.includes(r)?t:[...t,r]},bs=(t,s)=>t.filter(r=>r!==s);function $d({skipPermissions:t,onSkipPermissionsChange:s,allowedTools:r,onAllowedToolsChange:a,disallowedTools:o,onDisallowedToolsChange:i}){const{t:l}=ce("settings"),[c,m]=n.useState(""),[d,u]=n.useState(""),x=p=>{const f=fs(r,p);f.length!==r.length&&(a(f),m(""))},h=p=>{const f=fs(o,p);f.length!==o.length&&(i(f),u(""))};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(Oe,{className:"h-5 w-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:l("permissions.title")})]}),e.jsx("div",{className:"rounded-lg border border-orange-200 bg-orange-50 p-4 dark:border-orange-800 dark:bg-orange-900/20",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:p=>s(p.target.checked),className:"h-4 w-4 rounded border-input bg-card text-primary focus:ring-2 focus:ring-primary"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:l("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:l("permissions.skipPermissions.claudeDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fr,{className:"h-5 w-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:l("permissions.allowedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("permissions.allowedTools.description")}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(me,{value:c,onChange:p=>m(p.target.value),placeholder:l("permissions.allowedTools.placeholder"),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),x(c))},className:"h-10 flex-1"}),e.jsxs(W,{onClick:()=>x(c),disabled:!c.trim(),size:"sm",className:"h-10 px-4",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:l("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:l("permissions.allowedTools.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Od.map(p=>e.jsx(W,{variant:"outline",size:"sm",onClick:()=>x(p),disabled:r.includes(p),className:"h-8 text-xs",children:p},p))})]}),e.jsxs("div",{className:"space-y-2",children:[r.map(p=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-green-200 bg-green-50 p-3 dark:border-green-800 dark:bg-green-900/20",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:p}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>a(bs(r,p)),className:"text-green-600 hover:text-green-700",children:e.jsx(ge,{className:"h-4 w-4"})})]},p)),r.length===0&&e.jsx("div",{className:"py-6 text-center text-muted-foreground",children:l("permissions.allowedTools.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oe,{className:"h-5 w-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:l("permissions.blockedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("permissions.blockedTools.description")}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(me,{value:d,onChange:p=>u(p.target.value),placeholder:l("permissions.blockedTools.placeholder"),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),h(d))},className:"h-10 flex-1"}),e.jsxs(W,{onClick:()=>h(d),disabled:!d.trim(),size:"sm",className:"h-10 px-4",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:l("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[o.map(p=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-red-200 bg-red-50 p-3 dark:border-red-800 dark:bg-red-900/20",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:p}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>i(bs(o,p)),className:"text-red-600 hover:text-red-700",children:e.jsx(ge,{className:"h-4 w-4"})})]},p)),o.length===0&&e.jsx("div",{className:"py-6 text-center text-muted-foreground",children:l("permissions.blockedTools.empty")})]})]}),e.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-900/20",children:[e.jsx("h4",{className:"mb-2 font-medium text-blue-900 dark:text-blue-100",children:l("permissions.toolExamples.title")}),e.jsxs("ul",{className:"space-y-1 text-sm text-blue-800 dark:text-blue-200",children:[e.jsxs("li",{children:[e.jsx("code",{className:"rounded bg-blue-100 px-1 dark:bg-blue-800",children:'"Bash(git log:*)"'})," ",l("permissions.toolExamples.bashGitLog")]}),e.jsxs("li",{children:[e.jsx("code",{className:"rounded bg-blue-100 px-1 dark:bg-blue-800",children:'"Bash(git diff:*)"'})," ",l("permissions.toolExamples.bashGitDiff")]}),e.jsxs("li",{children:[e.jsx("code",{className:"rounded bg-blue-100 px-1 dark:bg-blue-800",children:'"Write"'})," ",l("permissions.toolExamples.write")]}),e.jsxs("li",{children:[e.jsx("code",{className:"rounded bg-blue-100 px-1 dark:bg-blue-800",children:'"Bash(rm:*)"'})," ",l("permissions.toolExamples.bashRm")]})]})]})]})}function zd({skipPermissions:t,onSkipPermissionsChange:s,allowedCommands:r,onAllowedCommandsChange:a,disallowedCommands:o,onDisallowedCommandsChange:i}){const{t:l}=ce("settings"),[c,m]=n.useState(""),[d,u]=n.useState(""),x=p=>{const f=fs(r,p);f.length!==r.length&&(a(f),m(""))},h=p=>{const f=fs(o,p);f.length!==o.length&&(i(f),u(""))};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(Oe,{className:"h-5 w-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:l("permissions.title")})]}),e.jsx("div",{className:"rounded-lg border border-orange-200 bg-orange-50 p-4 dark:border-orange-800 dark:bg-orange-900/20",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:p=>s(p.target.checked),className:"h-4 w-4 rounded border-input bg-card text-primary focus:ring-2 focus:ring-primary"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:l("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:l("permissions.skipPermissions.cursorDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fr,{className:"h-5 w-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:l("permissions.allowedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("permissions.allowedCommands.description")}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(me,{value:c,onChange:p=>m(p.target.value),placeholder:l("permissions.allowedCommands.placeholder"),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),x(c))},className:"h-10 flex-1"}),e.jsxs(W,{onClick:()=>x(c),disabled:!c.trim(),size:"sm",className:"h-10 px-4",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:l("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:l("permissions.allowedCommands.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Dd.map(p=>e.jsx(W,{variant:"outline",size:"sm",onClick:()=>x(p),disabled:r.includes(p),className:"h-8 text-xs",children:p},p))})]}),e.jsxs("div",{className:"space-y-2",children:[r.map(p=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-green-200 bg-green-50 p-3 dark:border-green-800 dark:bg-green-900/20",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:p}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>a(bs(r,p)),className:"text-green-600 hover:text-green-700",children:e.jsx(ge,{className:"h-4 w-4"})})]},p)),r.length===0&&e.jsx("div",{className:"py-6 text-center text-muted-foreground",children:l("permissions.allowedCommands.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oe,{className:"h-5 w-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:l("permissions.blockedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("permissions.blockedCommands.description")}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(me,{value:d,onChange:p=>u(p.target.value),placeholder:l("permissions.blockedCommands.placeholder"),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),h(d))},className:"h-10 flex-1"}),e.jsxs(W,{onClick:()=>h(d),disabled:!d.trim(),size:"sm",className:"h-10 px-4",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:l("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[o.map(p=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-red-200 bg-red-50 p-3 dark:border-red-800 dark:bg-red-900/20",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:p}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>i(bs(o,p)),className:"text-red-600 hover:text-red-700",children:e.jsx(ge,{className:"h-4 w-4"})})]},p)),o.length===0&&e.jsx("div",{className:"py-6 text-center text-muted-foreground",children:l("permissions.blockedCommands.empty")})]})]}),e.jsxs("div",{className:"rounded-lg border border-purple-200 bg-purple-50 p-4 dark:border-purple-800 dark:bg-purple-900/20",children:[e.jsx("h4",{className:"mb-2 font-medium text-purple-900 dark:text-purple-100",children:l("permissions.shellExamples.title")}),e.jsxs("ul",{className:"space-y-1 text-sm text-purple-800 dark:text-purple-200",children:[e.jsxs("li",{children:[e.jsx("code",{className:"rounded bg-purple-100 px-1 dark:bg-purple-800",children:'"Shell(ls)"'})," ",l("permissions.shellExamples.ls")]}),e.jsxs("li",{children:[e.jsx("code",{className:"rounded bg-purple-100 px-1 dark:bg-purple-800",children:'"Shell(git status)"'})," ",l("permissions.shellExamples.gitStatus")]}),e.jsxs("li",{children:[e.jsx("code",{className:"rounded bg-purple-100 px-1 dark:bg-purple-800",children:'"Shell(npm install)"'})," ",l("permissions.shellExamples.npmInstall")]}),e.jsxs("li",{children:[e.jsx("code",{className:"rounded bg-purple-100 px-1 dark:bg-purple-800",children:'"Shell(rm -rf)"'})," ",l("permissions.shellExamples.rmRf")]})]})]})]})}function Ud({permissionMode:t,onPermissionModeChange:s}){const{t:r}=ce("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(fr,{className:"h-5 w-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:r("permissions.codex.permissionMode")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("permissions.codex.description")}),e.jsx("div",{className:`cursor-pointer rounded-lg border p-4 transition-all ${t==="default"?"border-border bg-accent":"border-border bg-card/50 active:border-border active:bg-accent/50"}`,onClick:()=>s("default"),children:e.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="default",onChange:()=>s("default"),className:"mt-1 h-4 w-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:r("permissions.codex.modes.default.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:r("permissions.codex.modes.default.description")})]})]})}),e.jsx("div",{className:`cursor-pointer rounded-lg border p-4 transition-all ${t==="acceptEdits"?"border-green-400 bg-green-50 dark:border-green-600 dark:bg-green-900/20":"border-border bg-card/50 active:border-border active:bg-accent/50"}`,onClick:()=>s("acceptEdits"),children:e.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="acceptEdits",onChange:()=>s("acceptEdits"),className:"mt-1 h-4 w-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:r("permissions.codex.modes.acceptEdits.title")}),e.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:r("permissions.codex.modes.acceptEdits.description")})]})]})}),e.jsx("div",{className:`cursor-pointer rounded-lg border p-4 transition-all ${t==="bypassPermissions"?"border-orange-400 bg-orange-50 dark:border-orange-600 dark:bg-orange-900/20":"border-border bg-card/50 active:border-border active:bg-accent/50"}`,onClick:()=>s("bypassPermissions"),children:e.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="bypassPermissions",onChange:()=>s("bypassPermissions"),className:"mt-1 h-4 w-4 text-orange-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium text-orange-900 dark:text-orange-100",children:[r("permissions.codex.modes.bypassPermissions.title"),e.jsx(Oe,{className:"h-4 w-4"})]}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:r("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:r("permissions.codex.technicalDetails")}),e.jsxs("div",{className:"mt-2 space-y-2 rounded-lg bg-muted/50 p-3 text-xs text-muted-foreground",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[r("permissions.codex.modes.default.title"),":"]})," ",r("permissions.codex.technicalInfo.default")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[r("permissions.codex.modes.acceptEdits.title"),":"]})," ",r("permissions.codex.technicalInfo.acceptEdits")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[r("permissions.codex.modes.bypassPermissions.title"),":"]})," ",r("permissions.codex.technicalInfo.bypassPermissions")]}),e.jsx("p",{className:"text-xs opacity-75",children:r("permissions.codex.technicalInfo.overrideNote")})]})]})]})})}function Xs(t){return t.agent==="claude"?e.jsx($d,{...t}):t.agent==="cursor"?e.jsx(zd,{...t}):e.jsx(Ud,{...t})}function Gd({selectedAgent:t,selectedCategory:s,agentContextById:r,claudePermissions:a,onClaudePermissionsChange:o,cursorPermissions:i,onCursorPermissionsChange:l,codexPermissionMode:c,onCodexPermissionModeChange:m,projects:d}){return e.jsxs("div",{className:"min-w-0 flex-1 overflow-y-auto overflow-x-hidden p-3 md:p-4",children:[s==="account"&&e.jsx(_d,{agent:t,authStatus:r[t].authStatus,onLogin:r[t].onLogin}),s==="permissions"&&t==="claude"&&e.jsx(Xs,{agent:"claude",skipPermissions:a.skipPermissions,onSkipPermissionsChange:u=>{o({...a,skipPermissions:u})},allowedTools:a.allowedTools,onAllowedToolsChange:u=>{o({...a,allowedTools:u})},disallowedTools:a.disallowedTools,onDisallowedToolsChange:u=>{o({...a,disallowedTools:u})}}),s==="permissions"&&t==="cursor"&&e.jsx(Xs,{agent:"cursor",skipPermissions:i.skipPermissions,onSkipPermissionsChange:u=>{l({...i,skipPermissions:u})},allowedCommands:i.allowedCommands,onAllowedCommandsChange:u=>{l({...i,allowedCommands:u})},disallowedCommands:i.disallowedCommands,onDisallowedCommandsChange:u=>{l({...i,disallowedCommands:u})}}),s==="permissions"&&t==="codex"&&e.jsx(Xs,{agent:"codex",permissionMode:c,onPermissionModeChange:m}),s==="mcp"&&e.jsx(xd,{selectedProvider:t,currentProjects:d.map(u=>({projectId:u.name,displayName:u.displayName,fullPath:u.fullPath,path:u.path}))}),s==="skills"&&t!=="opencode"&&e.jsx(Md,{selectedProvider:t,currentProjects:d.map(u=>({projectId:u.name,displayName:u.displayName,fullPath:u.fullPath,path:u.path}))})]})}function Vd({categories:t,selectedAgent:s,selectedCategory:r,onSelectCategory:a}){const{t:o}=ce("settings");return e.jsx("div",{className:"flex-shrink-0 border-b border-border",children:e.jsx("div",{role:"tablist",className:"flex overflow-x-auto px-2 md:px-4",children:t.map(i=>e.jsxs("button",{role:"tab","aria-selected":r===i,onClick:()=>a(i),className:F("whitespace-nowrap border-b-2 px-4 py-3 text-sm font-medium touch-manipulation transition-colors duration-150",r===i?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"),children:[i==="account"&&o("tabs.account"),i==="permissions"&&o("tabs.permissions"),i==="mcp"&&o("tabs.mcpServers"),i==="skills"&&o("tabs.skills",{defaultValue:s==="opencode"?"Shared Skills":"Skills"})]},i))})})}const Kd={claude:"Claude",cursor:"Cursor",codex:"Codex",opencode:"OpenCode"};function Bd({agents:t,selectedAgent:s,onSelectAgent:r,agentContextById:a}){return e.jsx("div",{className:"flex-shrink-0 border-b border-border px-3 py-2 md:px-4 md:py-3",children:e.jsx($n,{className:"w-full md:w-auto",children:t.map(o=>{const i=o==="claude"?"bg-blue-500":o==="cursor"?"bg-purple-500":o==="opencode"?"bg-zinc-500":"bg-foreground/60";return e.jsxs(zn,{isActive:s===o,onClick:()=>r(o),className:"min-w-0 flex-1 justify-center md:flex-initial",children:[e.jsx(_e,{provider:o,className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:Kd[o]}),a[o].authStatus.authenticated&&e.jsx("span",{className:`h-1.5 w-1.5 flex-shrink-0 rounded-full ${i}`})]},o)})})})}function Wd({providerAuthStatus:t,onProviderLogin:s,claudePermissions:r,onClaudePermissionsChange:a,cursorPermissions:o,onCursorPermissionsChange:i,codexPermissionMode:l,onCodexPermissionModeChange:c,projects:m}){const[d,u]=n.useState("claude"),[x,h]=n.useState("account"),p=n.useMemo(()=>d==="opencode"?["account","permissions","mcp"]:["account","permissions","mcp","skills"],[d]),f=n.useMemo(()=>["claude","cursor","codex","opencode"],[]),b=n.useMemo(()=>({claude:{authStatus:t.claude,onLogin:()=>s("claude")},cursor:{authStatus:t.cursor,onLogin:()=>s("cursor")},codex:{authStatus:t.codex,onLogin:()=>s("codex")},opencode:{authStatus:t.opencode,onLogin:()=>s("opencode")}}),[s,t.claude,t.codex,t.cursor,t.opencode]);return n.useEffect(()=>{p.includes(x)||h(p[0]??"account")},[x,p]),e.jsxs("div",{className:"-mx-4 -mb-4 -mt-2 flex min-h-[300px] min-w-0 flex-col overflow-hidden md:-mx-6 md:-mb-6 md:-mt-2 md:min-h-[500px]",children:[e.jsx(Bd,{agents:f,selectedAgent:d,onSelectAgent:u,agentContextById:b}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[e.jsx(Vd,{categories:p,selectedAgent:d,selectedCategory:x,onSelectCategory:h}),e.jsx(Gd,{selectedAgent:d,selectedCategory:x,agentContextById:b,claudePermissions:r,onClaudePermissionsChange:a,cursorPermissions:o,onCursorPermissionsChange:i,codexPermissionMode:l,onCodexPermissionModeChange:c,projects:m})]})]})}const ba=[{value:"en",label:"English",nativeName:"English"},{value:"fr",label:"French",nativeName:"Français"},{value:"es",label:"Spanish",nativeName:"Español"},{value:"ko",label:"Korean",nativeName:"한국어"},{value:"zh-CN",label:"Simplified Chinese",nativeName:"简体中文"},{value:"zh-TW",label:"Traditional Chinese",nativeName:"繁體中文"},{value:"ja",label:"Japanese",nativeName:"日本語"},{value:"ru",label:"Russian",nativeName:"Русский"},{value:"de",label:"German",nativeName:"Deutsch"},{value:"tr",label:"Turkish",nativeName:"Türkçe"},{value:"it",label:"Italian",nativeName:"Italiano"}];function Hd({compact:t=!1}){const{i18n:s,t:r}=ce("settings"),a=o=>{const i=o.target.value;s.changeLanguage(i)};return t?e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-transparent bg-muted/50 p-3 transition-colors hover:border-border hover:bg-accent",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-foreground",children:[e.jsx(Ro,{className:"h-4 w-4 text-muted-foreground"}),r("account.language")]}),e.jsx("select",{value:s.language,onChange:a,className:"w-auto min-w-[120px] max-w-[160px] rounded-lg border border-input bg-card p-2 text-sm text-foreground focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary",children:ba.map(o=>e.jsx("option",{value:o.value,children:o.nativeName},o.value))})]}):e.jsxs("div",{className:"flex items-center justify-between px-4 py-3.5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:r("account.languageLabel")}),e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:r("account.languageDescription")})]}),e.jsx("select",{value:s.language,onChange:a,className:"w-36 rounded-lg border border-input bg-card p-2 text-sm text-foreground focus:border-primary focus:ring-1 focus:ring-primary",children:ba.map(o=>e.jsx("option",{value:o.value,children:o.nativeName},o.value))})]})}function Je({children:t,className:s,divided:r}){return e.jsx("div",{className:F("rounded-xl border border-border bg-card/50",r&&"divide-y divide-border",s),children:t})}function We({label:t,description:s,children:r,className:a}){return e.jsxs("div",{className:F("flex items-center justify-between gap-4 px-4 py-4",a),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:t}),s&&e.jsx("div",{className:"mt-0.5 text-sm text-muted-foreground",children:s})]}),e.jsx("div",{className:"flex-shrink-0",children:r})]})}function Me({title:t,description:s,children:r,className:a}){return e.jsxs("div",{className:F("space-y-3",a),children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-muted-foreground",children:t}),s&&e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s})]}),r]})}function gt({checked:t,onChange:s,ariaLabel:r,disabled:a}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":r,disabled:a,onClick:()=>s(!t),className:F("relative inline-flex h-7 w-12 flex-shrink-0 touch-manipulation cursor-pointer items-center rounded-full border-2 transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",t?"border-primary bg-primary":"border-border bg-muted",a&&"cursor-not-allowed opacity-50"),children:e.jsx("span",{className:F("pointer-events-none inline-block h-5 w-5 rounded-full shadow-sm transition-transform duration-200",t?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80")})})}function Jd({projectSortOrder:t,onProjectSortOrderChange:s,codeEditorSettings:r,onCodeEditorWordWrapChange:a,onCodeEditorShowMinimapChange:o,onCodeEditorLineNumbersChange:i,onCodeEditorFontSizeChange:l}){const{t:c}=ce("settings");return e.jsxs("div",{className:"space-y-8",children:[e.jsx(Me,{title:c("appearanceSettings.darkMode.label"),children:e.jsx(Je,{children:e.jsx(We,{label:c("appearanceSettings.darkMode.label"),description:c("appearanceSettings.darkMode.description"),children:e.jsx(Bl,{ariaLabel:c("appearanceSettings.darkMode.label")})})})}),e.jsx(Me,{title:c("mainTabs.appearance"),children:e.jsx(Je,{children:e.jsx(Hd,{})})}),e.jsx(Me,{title:c("appearanceSettings.projectSorting.label"),children:e.jsx(Je,{children:e.jsx(We,{label:c("appearanceSettings.projectSorting.label"),description:c("appearanceSettings.projectSorting.description"),children:e.jsxs("select",{value:t,onChange:m=>s(m.target.value),className:"w-full touch-manipulation rounded-lg border border-input bg-card p-2.5 text-sm text-foreground focus:border-primary focus:ring-1 focus:ring-primary sm:w-36",children:[e.jsx("option",{value:"name",children:c("appearanceSettings.projectSorting.alphabetical")}),e.jsx("option",{value:"date",children:c("appearanceSettings.projectSorting.recentActivity")})]})})})}),e.jsx(Me,{title:c("appearanceSettings.codeEditor.title"),children:e.jsxs(Je,{divided:!0,children:[e.jsx(We,{label:c("appearanceSettings.codeEditor.wordWrap.label"),description:c("appearanceSettings.codeEditor.wordWrap.description"),children:e.jsx(gt,{checked:r.wordWrap,onChange:a,ariaLabel:c("appearanceSettings.codeEditor.wordWrap.label")})}),e.jsx(We,{label:c("appearanceSettings.codeEditor.showMinimap.label"),description:c("appearanceSettings.codeEditor.showMinimap.description"),children:e.jsx(gt,{checked:r.showMinimap,onChange:o,ariaLabel:c("appearanceSettings.codeEditor.showMinimap.label")})}),e.jsx(We,{label:c("appearanceSettings.codeEditor.lineNumbers.label"),description:c("appearanceSettings.codeEditor.lineNumbers.description"),children:e.jsx(gt,{checked:r.lineNumbers,onChange:i,ariaLabel:c("appearanceSettings.codeEditor.lineNumbers.label")})}),e.jsx(We,{label:c("appearanceSettings.codeEditor.fontSize.label"),description:c("appearanceSettings.codeEditor.fontSize.description"),children:e.jsxs("select",{value:r.fontSize,onChange:m=>l(m.target.value),className:"w-full touch-manipulation rounded-lg border border-input bg-card p-2.5 text-sm text-foreground focus:border-primary focus:ring-1 focus:ring-primary sm:w-28",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"})]})})]})})]})}const ut=(t,s)=>t?.error||s;function qd({confirmDeleteApiKeyText:t,confirmDeleteGithubCredentialText:s}){const[r,a]=n.useState([]),[o,i]=n.useState([]),[l,c]=n.useState(!0),[m,d]=n.useState(!1),[u,x]=n.useState(""),[h,p]=n.useState(!1),[f,b]=n.useState(""),[g,v]=n.useState(""),[S,k]=n.useState(""),[y,P]=n.useState({}),[E,C]=n.useState(null),[T,I]=n.useState(null),j=n.useCallback(async()=>{try{c(!0);const[U,N]=await Promise.all([z("/api/settings/api-keys"),z("/api/settings/credentials?type=github_token")]),[A,ee]=await Promise.all([U.json(),N.json()]);a(A.apiKeys||[]),i(ee.credentials||[])}catch(U){console.error("Error fetching settings:",U)}finally{c(!1)}},[]),$=n.useCallback(async()=>{if(u.trim())try{const U=await z("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:u.trim()})}),N=await U.json();if(!U.ok||!N.success){console.error("Error creating API key:",ut(N,"Failed to create API key"));return}N.apiKey&&I(N.apiKey),x(""),d(!1),await j()}catch(U){console.error("Error creating API key:",U)}},[j,u]),G=n.useCallback(async U=>{if(window.confirm(t))try{const N=await z(`/api/settings/api-keys/${U}`,{method:"DELETE"});if(!N.ok){const A=await N.json();console.error("Error deleting API key:",ut(A,"Failed to delete API key"));return}await j()}catch(N){console.error("Error deleting API key:",N)}},[t,j]),K=n.useCallback(async(U,N)=>{try{const A=await z(`/api/settings/api-keys/${U}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!N})});if(!A.ok){const ee=await A.json();console.error("Error toggling API key:",ut(ee,"Failed to toggle API key"));return}await j()}catch(A){console.error("Error toggling API key:",A)}},[j]),M=n.useCallback(async()=>{if(!(!f.trim()||!g.trim()))try{const U=await z("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:f.trim(),credentialType:"github_token",credentialValue:g,description:S.trim()})}),N=await U.json();if(!U.ok||!N.success){console.error("Error creating GitHub credential:",ut(N,"Failed to create GitHub credential"));return}b(""),v(""),k(""),p(!1),P(A=>({...A,new:!1})),await j()}catch(U){console.error("Error creating GitHub credential:",U)}},[j,S,f,g]),X=n.useCallback(async U=>{if(window.confirm(s))try{const N=await z(`/api/settings/credentials/${U}`,{method:"DELETE"});if(!N.ok){const A=await N.json();console.error("Error deleting GitHub credential:",ut(A,"Failed to delete GitHub credential"));return}await j()}catch(N){console.error("Error deleting GitHub credential:",N)}},[s,j]),H=n.useCallback(async(U,N)=>{try{const A=await z(`/api/settings/credentials/${U}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!N})});if(!A.ok){const ee=await A.json();console.error("Error toggling GitHub credential:",ut(ee,"Failed to toggle GitHub credential"));return}await j()}catch(A){console.error("Error toggling GitHub credential:",A)}},[j]),B=n.useCallback(async(U,N)=>{try{await Cr(U),C(N),window.setTimeout(()=>C(null),2e3)}catch(A){console.error("Failed to copy to clipboard:",A)}},[]),w=n.useCallback(()=>{I(null)},[]),D=n.useCallback(()=>{d(!1),x("")},[]),L=n.useCallback(()=>{p(!1),b(""),v(""),k(""),P(U=>({...U,new:!1}))},[]),O=n.useCallback(()=>{P(U=>({...U,new:!U.new}))},[]);return n.useEffect(()=>{j()},[j]),{apiKeys:r,githubCredentials:o,loading:l,showNewKeyForm:m,setShowNewKeyForm:d,newKeyName:u,setNewKeyName:x,showNewGithubForm:h,setShowNewGithubForm:p,newGithubName:f,setNewGithubName:b,newGithubToken:g,setNewGithubToken:v,newGithubDescription:S,setNewGithubDescription:k,showToken:y,copiedKey:E,newlyCreatedKey:T,createApiKey:$,deleteApiKey:G,toggleApiKey:K,createGithubCredential:M,deleteGithubCredential:X,toggleGithubCredential:H,copyToClipboard:B,dismissNewlyCreatedKey:w,cancelNewApiKeyForm:D,cancelNewGithubForm:L,toggleNewGithubTokenVisibility:O}}function Qd({apiKeys:t,showNewKeyForm:s,newKeyName:r,onShowNewKeyFormChange:a,onNewKeyNameChange:o,onCreateApiKey:i,onCancelCreateApiKey:l,onToggleApiKey:c,onDeleteApiKey:m}){const{t:d}=ce("settings");return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:d("apiKeys.title")})]}),e.jsxs(W,{size:"sm",onClick:()=>a(!s),children:[e.jsx(Ee,{className:"mr-1 h-4 w-4"}),d("apiKeys.newButton")]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"mb-2 text-sm text-muted-foreground",children:d("apiKeys.description")}),e.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary hover:underline",children:[d("apiKeys.apiDocsLink"),e.jsx(Mt,{className:"h-3 w-3"})]})]}),s&&e.jsxs("div",{className:"mb-4 rounded-lg border bg-card p-4",children:[e.jsx(me,{placeholder:d("apiKeys.form.placeholder"),value:r,onChange:u=>o(u.target.value),className:"mb-2"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{onClick:i,children:d("apiKeys.form.createButton")}),e.jsx(W,{variant:"outline",onClick:l,children:d("apiKeys.form.cancelButton")})]})]}),e.jsx("div",{className:"space-y-2",children:t.length===0?e.jsx("p",{className:"text-sm italic text-muted-foreground",children:d("apiKeys.empty")}):t.map(u=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:u.key_name}),e.jsx("code",{className:"text-xs text-muted-foreground",children:u.api_key}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[d("apiKeys.list.created")," ",new Date(u.created_at).toLocaleDateString(),u.last_used?` - ${d("apiKeys.list.lastUsed")} ${new Date(u.last_used).toLocaleDateString()}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{size:"sm",variant:u.is_active?"outline":"secondary",onClick:()=>c(u.id,u.is_active),children:u.is_active?d("apiKeys.status.active"):d("apiKeys.status.inactive")}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>m(u.id),children:e.jsx(Te,{className:"h-4 w-4"})})]})]},u.id))})]})}function Yd({githubCredentials:t,showNewGithubForm:s,showNewTokenPlainText:r,newGithubName:a,newGithubToken:o,newGithubDescription:i,onShowNewGithubFormChange:l,onNewGithubNameChange:c,onNewGithubTokenChange:m,onNewGithubDescriptionChange:d,onToggleNewTokenVisibility:u,onCreateGithubCredential:x,onCancelCreateGithubCredential:h,onToggleGithubCredential:p,onDeleteGithubCredential:f}){const{t:b}=ce("settings");return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(za,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:b("apiKeys.github.title")})]}),e.jsxs(W,{size:"sm",onClick:()=>l(!s),children:[e.jsx(Ee,{className:"mr-1 h-4 w-4"}),b("apiKeys.github.addButton")]})]}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:b("apiKeys.github.descriptionAlt")}),s&&e.jsxs("div",{className:"mb-4 space-y-3 rounded-lg border bg-card p-4",children:[e.jsx(me,{placeholder:b("apiKeys.github.form.namePlaceholder"),value:a,onChange:g=>c(g.target.value)}),e.jsxs("div",{className:"relative",children:[e.jsx(me,{type:r?"text":"password",placeholder:b("apiKeys.github.form.tokenPlaceholder"),value:o,onChange:g=>m(g.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:u,"aria-label":r?"Hide token":"Show token",className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:r?e.jsx(us,{className:"h-4 w-4"}):e.jsx(Ua,{className:"h-4 w-4"})})]}),e.jsx(me,{placeholder:b("apiKeys.github.form.descriptionPlaceholder"),value:i,onChange:g=>d(g.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(W,{onClick:x,children:b("apiKeys.github.form.addButton")}),e.jsx(W,{variant:"outline",onClick:h,children:b("apiKeys.github.form.cancelButton")})]}),e.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"block text-xs text-primary hover:underline",children:b("apiKeys.github.form.howToCreate")})]}),e.jsx("div",{className:"space-y-2",children:t.length===0?e.jsx("p",{className:"text-sm italic text-muted-foreground",children:b("apiKeys.github.empty")}):t.map(g=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:g.credential_name}),g.description&&e.jsx("div",{className:"text-xs text-muted-foreground",children:g.description}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[b("apiKeys.github.added")," ",new Date(g.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{size:"sm",variant:g.is_active?"outline":"secondary",onClick:()=>p(g.id,g.is_active),children:g.is_active?b("apiKeys.status.active"):b("apiKeys.status.inactive")}),e.jsx(W,{size:"sm",variant:"ghost",onClick:()=>f(g.id),children:e.jsx(Te,{className:"h-4 w-4"})})]})]},g.id))})]})}function Zd({apiKey:t,copiedKey:s,onCopy:r,onDismiss:a}){const{t:o}=ce("settings");return e.jsxs("div",{className:"rounded-lg border border-yellow-500/20 bg-yellow-500/10 p-4",children:[e.jsx("h4",{className:"mb-2 font-semibold text-yellow-500",children:o("apiKeys.newKey.alertTitle")}),e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:o("apiKeys.newKey.alertMessage")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 break-all rounded bg-background/50 px-3 py-2 font-mono text-sm",children:t.apiKey}),e.jsx(W,{size:"sm",variant:"outline",onClick:()=>r(t.apiKey,"new"),children:s==="new"?e.jsx(Fe,{className:"h-4 w-4"}):e.jsx(La,{className:"h-4 w-4"})})]}),e.jsx(W,{size:"sm",variant:"ghost",className:"mt-3",onClick:a,children:o("apiKeys.newKey.iveSavedIt")})]})}function Xd(){const{t}=ce("settings"),{apiKeys:s,githubCredentials:r,loading:a,showNewKeyForm:o,setShowNewKeyForm:i,newKeyName:l,setNewKeyName:c,showNewGithubForm:m,setShowNewGithubForm:d,newGithubName:u,setNewGithubName:x,newGithubToken:h,setNewGithubToken:p,newGithubDescription:f,setNewGithubDescription:b,showToken:g,copiedKey:v,newlyCreatedKey:S,createApiKey:k,deleteApiKey:y,toggleApiKey:P,createGithubCredential:E,deleteGithubCredential:C,toggleGithubCredential:T,copyToClipboard:I,dismissNewlyCreatedKey:j,cancelNewApiKeyForm:$,cancelNewGithubForm:G,toggleNewGithubTokenVisibility:K}=qd({confirmDeleteApiKeyText:t("apiKeys.confirmDelete"),confirmDeleteGithubCredentialText:t("apiKeys.github.confirmDelete")});return a?e.jsx("div",{className:"text-muted-foreground",children:t("apiKeys.loading")}):e.jsxs("div",{className:"space-y-8",children:[S&&e.jsx(Zd,{apiKey:S,copiedKey:v,onCopy:I,onDismiss:j}),e.jsx(Qd,{apiKeys:s,showNewKeyForm:o,newKeyName:l,onShowNewKeyFormChange:i,onNewKeyNameChange:c,onCreateApiKey:k,onCancelCreateApiKey:$,onToggleApiKey:P,onDeleteApiKey:y}),e.jsx(Yd,{githubCredentials:r,showNewGithubForm:m,showNewTokenPlainText:!!g.new,newGithubName:u,newGithubToken:h,newGithubDescription:f,onShowNewGithubFormChange:d,onNewGithubNameChange:x,onNewGithubTokenChange:p,onNewGithubDescriptionChange:b,onToggleNewTokenVisibility:K,onCreateGithubCredential:E,onCancelCreateGithubCredential:G,onToggleGithubCredential:T,onDeleteGithubCredential:C})]})}const Yn="voiceConfig",eu="voice-config:sync",pt={baseUrl:"",apiKey:"",sttModel:"",ttsModel:"",ttsVoice:"",ttsFormat:""};function Zn(){try{const t=localStorage.getItem(Yn);if(!t)return{...pt};const s=JSON.parse(t);if(!s||typeof s!="object"||Array.isArray(s))return{...pt};const r={...pt};for(const a of Object.keys(pt))typeof s[a]=="string"&&(r[a]=s[a]);return r}catch{return{...pt}}}function _m(){if(typeof window>"u")return{};const t=Zn(),s={};return t.apiKey&&(s["x-voice-api-key"]=t.apiKey),t.sttModel&&(s["x-voice-stt-model"]=t.sttModel),t.ttsModel&&(s["x-voice-tts-model"]=t.ttsModel),t.ttsVoice&&(s["x-voice-tts-voice"]=t.ttsVoice),t.ttsFormat.trim()&&(s["x-voice-tts-format"]=t.ttsFormat.trim()),s}function tu(){const[t,s]=n.useState(()=>typeof window>"u"?{...pt}:Zn());return{config:t,update:a=>{s(o=>{const i={...o,...a};try{const l={...i};i.ttsFormat.trim()?l.ttsFormat=i.ttsFormat.trim():delete l.ttsFormat,localStorage.setItem(Yn,JSON.stringify(l)),window.dispatchEvent(new Event(eu))}catch{}return i})}}}const su="w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring";function mt({label:t,...s}){return e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),e.jsx("input",{className:su,...s})]})}function ru(){const{t}=ce("settings"),{preferences:s,setPreference:r}=rn(),{config:a,update:o}=tu(),i=s.voiceEnabled;return e.jsxs("div",{className:"space-y-8",children:[e.jsx(Me,{title:t("voiceSettings.title"),description:t("voiceSettings.description"),children:e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-border p-3",children:[e.jsxs("div",{className:"pr-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:t("voiceSettings.enable")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t("voiceSettings.enableDescription")})]}),e.jsx(gt,{checked:i,onChange:l=>r("voiceEnabled",l),ariaLabel:t("voiceSettings.enable")})]})}),i&&e.jsx(Me,{title:t("voiceSettings.backendTitle"),description:t("voiceSettings.backendDescription"),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(mt,{label:t("voiceSettings.baseUrl"),placeholder:"https://api.openai.com/v1",value:a.baseUrl,onChange:l=>o({baseUrl:l.target.value})}),e.jsx(mt,{label:t("voiceSettings.apiKey"),type:"password",autoComplete:"off",placeholder:"sk-…",value:a.apiKey,onChange:l=>o({apiKey:l.target.value})}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-4",children:[e.jsx(mt,{label:t("voiceSettings.sttModel"),placeholder:"whisper-1",value:a.sttModel,onChange:l=>o({sttModel:l.target.value})}),e.jsx(mt,{label:t("voiceSettings.ttsModel"),placeholder:"tts-1",value:a.ttsModel,onChange:l=>o({ttsModel:l.target.value})}),e.jsx(mt,{label:t("voiceSettings.voice"),placeholder:"alloy",value:a.ttsVoice,onChange:l=>o({ttsVoice:l.target.value})}),e.jsx(mt,{label:t("voiceSettings.format"),placeholder:"mp3",value:a.ttsFormat,onChange:l=>o({ttsFormat:l.target.value})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("voiceSettings.note")})]})})]})}function au(){const[t,s]=n.useState(""),[r,a]=n.useState(""),[o,i]=n.useState(!1),[l,c]=n.useState(!1),[m,d]=n.useState(null),u=n.useRef(null),x=n.useCallback(()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null),d(null)},[]),h=n.useCallback(async()=>{try{i(!0);const f=await z("/api/user/git-config");if(!f.ok)return;const b=await f.json();s(b.gitName||""),a(b.gitEmail||"")}catch(f){console.error("Error loading git config:",f)}finally{i(!1)}},[]),p=n.useCallback(async()=>{try{c(!0);const f=await z("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:t,gitEmail:r})});if(f.ok){d("success"),u.current=window.setTimeout(()=>{d(null),u.current=null},3e3);return}const b=await f.json();console.error("Failed to save git config:",b.error),d("error")}catch(f){console.error("Error saving git config:",f),d("error")}finally{c(!1)}},[r,t]);return n.useEffect(()=>{h()},[h]),n.useEffect(()=>()=>{u.current!==null&&window.clearTimeout(u.current)},[]),{gitName:t,setGitName:s,gitEmail:r,setGitEmail:a,isLoading:o,isSaving:l,saveStatus:m,clearSaveStatus:x,saveGitConfig:p}}function nu(){const{t}=ce("settings"),{gitName:s,setGitName:r,gitEmail:a,setGitEmail:o,isLoading:i,isSaving:l,saveStatus:c,saveGitConfig:m}=au();return e.jsx("div",{className:"space-y-8",children:e.jsx(Me,{title:t("git.title"),description:t("git.description"),children:e.jsx(Je,{className:"p-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-name",className:"mb-2 block text-sm font-medium text-foreground",children:t("git.name.label")}),e.jsx(me,{id:"settings-git-name",type:"text",value:s,onChange:d=>r(d.target.value),placeholder:"John Doe",disabled:i,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:"mb-2 block text-sm font-medium text-foreground",children:t("git.email.label")}),e.jsx(me,{id:"settings-git-email",type:"email",value:a,onChange:d=>o(d.target.value),placeholder:"john@example.com",disabled:i,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(W,{onClick:m,disabled:l||!s.trim()||!a.trim(),children:t(l?"git.actions.saving":"git.actions.save")}),c==="success"&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[e.jsx(Fe,{className:"h-4 w-4"}),t("git.status.success")]})]})]})})})})}async function Xt(t){const s=await t.json();if(!t.ok||s.success===!1)throw new Error(s.error||s.details||`Request failed (${t.status})`);return s}function ou(){const[t,s]=n.useState(null),[r,a]=n.useState(null),[o,i]=n.useState(!0),[l,c]=n.useState(!0),[m,d]=n.useState(!1),[u,x]=n.useState(!1),[h,p]=n.useState(null),f=n.useCallback(async()=>{const P=await z("/api/browser-use/settings"),E=await Xt(P);s(E.data.settings)},[]),b=n.useCallback(async()=>{const P=await z("/api/browser-use/status"),E=await Xt(P);a(E.data)},[]);n.useEffect(()=>{p(null),i(!0),c(!0),f().catch(P=>p(P instanceof Error?P.message:"Failed to load Browser settings")).finally(()=>i(!1)),b().catch(P=>p(P instanceof Error?P.message:"Failed to load Browser status")).finally(()=>c(!1))},[f,b]);const g=async P=>{d(!0),p(null);try{const E=await z("/api/browser-use/settings",{method:"PUT",body:JSON.stringify(P)}),C=await Xt(E);s(C.data.settings),window.dispatchEvent(new Event("browserUseSettingsChanged")),c(!0),await b()}catch(E){p(E instanceof Error?E.message:"Failed to save Browser settings")}finally{c(!1),d(!1)}},v=async()=>{x(!0),p(null);try{const P=await z("/api/browser-use/runtime/install",{method:"POST"});await Xt(P),c(!0),await b()}catch(P){p(P instanceof Error?P.message:"Failed to install browser runtime")}finally{c(!1),x(!1)}},S=t?.enabled===!0,k=!!(S&&r&&(!r.playwrightInstalled||!r.chromiumInstalled)),y=P=>l&&!r?"checking...":P?"installed":"missing";return e.jsx("div",{className:"space-y-8",children:e.jsx(Me,{title:"Browser",description:"Allow agents to create guarded Playwright browser sessions that you can monitor from the Browser tab.",children:e.jsxs(Je,{divided:!0,children:[e.jsx(We,{label:"Enable Browser",description:"Registers Browser for supported agents. Agents can create browser sessions; you can watch, stop, and delete them.",children:o&&!t?e.jsx(ve,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(gt,{checked:S,onChange:P=>{g({enabled:P})},ariaLabel:"Enable Browser",disabled:m})}),e.jsxs("div",{className:"space-y-4 px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"rounded-md border border-border px-2 py-1",children:["Playwright: ",y(r?.playwrightInstalled)]}),e.jsxs("span",{className:"rounded-md border border-border px-2 py-1",children:["Chromium: ",y(r?.chromiumInstalled)]}),e.jsxs("span",{className:"rounded-md border border-border px-2 py-1",children:["Status: ",l&&!r?"checking...":r?.available?"ready":S?"setup required":"disabled"]})]}),k&&e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Browser runtime required"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r?.message||"Install the browser runtime before agents can create Browser sessions."})]}),e.jsxs(W,{type:"button",size:"sm",onClick:()=>{v()},disabled:u||r?.installInProgress,className:"flex-shrink-0",children:[u||r?.installInProgress?e.jsx(ve,{className:"h-4 w-4 animate-spin"}):e.jsx(Ga,{className:"h-4 w-4"}),u||r?.installInProgress?"Installing...":"Install Runtime"]})]}),h&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-200",children:h})]})]})})})}const Xn="notificationSoundEnabled",ya=typeof window<"u"?window.AudioContext||window.webkitAudioContext:void 0;let er=null;const iu=()=>typeof localStorage>"u"?!0:localStorage.getItem(Xn)!=="false",lu=t=>{typeof localStorage>"u"||localStorage.setItem(Xn,String(t))},cu=()=>ya?(er||(er=new ya),er):null,va=(t,s,r,a,o)=>{const i=t.createOscillator(),l=t.createGain();i.type="sine",i.frequency.setValueAtTime(s,r),l.gain.setValueAtTime(1e-4,r),l.gain.exponentialRampToValueAtTime(o,r+.015),l.gain.exponentialRampToValueAtTime(1e-4,r+a),i.connect(l),l.connect(t.destination),i.start(r),i.stop(r+a+.02)},du=async({force:t=!1}={})=>{if(!t&&!iu())return;const s=cu();if(s)try{s.state==="suspended"&&await s.resume();const r=s.currentTime;va(s,740,r,.12,.075),va(s,988,r+.11,.16,.06)}catch(r){console.warn("Unable to play notification sound:",r)}},uu=(t={})=>du(t);function mu({notificationPreferences:t,onNotificationPreferencesChange:s,pushPermission:r,isPushSubscribed:a,isPushLoading:o,onEnablePush:i,onDisablePush:l,isDesktop:c=!1,desktopNotifications:m=null,onEnableDesktopNotifications:d,onDisableDesktopNotifications:u}){const{t:x}=ce("settings"),h=r!=="unsupported",p=r==="denied";return e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(gr,{className:"h-5 w-5 text-blue-600"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:x("notifications.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x("notifications.description")})]}),c?e.jsxs("div",{className:"space-y-4 rounded-lg border border-border bg-card p-4",children:[e.jsx("h4",{className:"font-medium text-foreground",children:x("notifications.desktop.title",{defaultValue:"Notify this desktop app"})}),m?.supported===!1?e.jsx("p",{className:"text-sm text-muted-foreground",children:x("notifications.desktop.unsupported",{defaultValue:"Desktop notifications are not supported on this system."})}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>{m?.enabled?u?.():d?.()},className:`inline-flex items-center gap-2 rounded-md px-4 py-2 text-sm font-medium transition-colors ${m?.enabled?"bg-red-100 text-red-700 hover:bg-red-200 dark:bg-red-900/30 dark:text-red-400 dark:hover:bg-red-900/50":"bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600"}`,children:[m?.enabled?e.jsx(_r,{className:"h-4 w-4"}):e.jsx(Or,{className:"h-4 w-4"}),m?.enabled?x("notifications.desktop.disable",{defaultValue:"Disable desktop notifications"}):x("notifications.desktop.enable",{defaultValue:"Enable desktop notifications"})]}),m?.enabled&&e.jsx("span",{className:"text-sm text-green-600 dark:text-green-400",children:x("notifications.desktop.enabled",{defaultValue:"Desktop notifications are enabled"})})]}),m?.lastError&&e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:m.lastError})]})]}):e.jsxs("div",{className:"space-y-4 rounded-lg border border-border bg-card p-4",children:[e.jsx("h4",{className:"font-medium text-foreground",children:x("notifications.webPush.title")}),h?p?e.jsx("p",{className:"text-sm text-muted-foreground",children:x("notifications.webPush.denied")}):e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{type:"button",disabled:o,onClick:()=>{a?l():i()},className:`inline-flex items-center gap-2 rounded-md px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${a?"bg-red-100 text-red-700 hover:bg-red-200 dark:bg-red-900/30 dark:text-red-400 dark:hover:bg-red-900/50":"bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600"}`,children:[o?e.jsx(ve,{className:"h-4 w-4 animate-spin"}):a?e.jsx(_r,{className:"h-4 w-4"}):e.jsx(Or,{className:"h-4 w-4"}),x(o?"notifications.webPush.loading":a?"notifications.webPush.disable":"notifications.webPush.enable")]}),a&&e.jsx("span",{className:"text-sm text-green-600 dark:text-green-400",children:x("notifications.webPush.enabled")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:x("notifications.webPush.unsupported")})]}),e.jsxs("div",{className:"space-y-4 rounded-lg border border-border bg-card p-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ao,{className:"h-4 w-4 text-blue-600"}),e.jsx("h4",{className:"font-medium text-foreground",children:x("notifications.sound.title",{defaultValue:"Sound"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x("notifications.sound.description",{defaultValue:"Play a short tone when a chat run finishes."})})]}),e.jsxs("label",{className:"flex shrink-0 items-center gap-2 text-sm text-foreground",children:[e.jsx("input",{type:"checkbox",checked:t.channels.sound,onChange:f=>s({...t,channels:{...t.channels,sound:f.target.checked}}),className:"h-4 w-4"}),x("notifications.sound.enabled",{defaultValue:"Enabled"})]})]}),e.jsxs(W,{type:"button",variant:"outline",size:"sm",onClick:()=>{uu({force:!0})},children:[e.jsx(Lo,{className:"h-4 w-4"}),x("notifications.sound.test",{defaultValue:"Test sound"})]})]}),e.jsxs("div",{className:"space-y-4 rounded-lg border border-border bg-card p-4",children:[e.jsx("h4",{className:"font-medium text-foreground",children:x("notifications.events.title")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[e.jsx("input",{type:"checkbox",checked:t.events.actionRequired,onChange:f=>s({...t,events:{...t.events,actionRequired:f.target.checked}}),className:"h-4 w-4"}),x("notifications.events.actionRequired")]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[e.jsx("input",{type:"checkbox",checked:t.events.stop,onChange:f=>s({...t,events:{...t.events,stop:f.target.checked}}),className:"h-4 w-4"}),x("notifications.events.stop")]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[e.jsx("input",{type:"checkbox",checked:t.events.error,onChange:f=>s({...t,events:{...t.events,error:f.target.checked}}),className:"h-4 w-4"}),x("notifications.events.error")]})]})]})]})}function pu(){const{t}=ce("settings"),{tasksEnabled:s,setTasksEnabled:r,isTaskMasterInstalled:a,isCheckingInstallation:o}=Za();return e.jsx("div",{className:"space-y-8",children:e.jsx(Me,{title:t("mainTabs.tasks"),children:o?e.jsx(Je,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("tasks.checking")})]})}):e.jsxs(e.Fragment,{children:[!a&&e.jsx("div",{className:"rounded-xl border border-orange-200 bg-orange-50 p-4 dark:border-orange-800/50 dark:bg-orange-950/30",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-orange-100 dark:bg-orange-900/50",children:e.jsx("svg",{className:"h-4 w-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:"mb-2 font-medium text-orange-900 dark:text-orange-100",children:t("tasks.notInstalled.title")}),e.jsxs("div",{className:"space-y-3 text-sm text-orange-800 dark:text-orange-200",children:[e.jsx("p",{children:t("tasks.notInstalled.description")}),e.jsx("div",{className:"rounded-lg bg-orange-100 p-3 font-mono text-sm dark:bg-orange-900/40",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-sm font-medium text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:[e.jsx("svg",{className:"h-4 w-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:"h-3 w-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-inside list-decimal 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(Je,{children:e.jsx(We,{label:t("tasks.settings.enableLabel"),description:t("tasks.settings.enableDescription"),children:e.jsx(gt,{checked:s,onChange:r,ariaLabel:t("tasks.settings.enableLabel")})})})]})})})}const tr=new Map,xu=["script","foreignObject","iframe","object","embed","link","meta","style","animate","set","animateTransform","animateMotion"],hu=["href","xlink:href","src","style"];function gu(t){const s=Vo.sanitize(t,{USE_PROFILES:{svg:!0,svgFilters:!0},FORBID_TAGS:xu,FORBID_ATTR:hu});if(!s)return null;try{const r=new DOMParser().parseFromString(s,"image/svg+xml"),a=r.documentElement;return!a||a.nodeName.toLowerCase()!=="svg"||r.querySelector("parsererror")?null:s}catch{return null}}function fu({pluginName:t,iconFile:s,className:r}){const a=s?`/api/plugins/${encodeURIComponent(t)}/assets/${encodeURIComponent(s)}`:"",[o,i]=n.useState(a?tr.get(a)??null:null);return n.useEffect(()=>{!a||tr.has(a)||z(a).then(l=>{if(l.ok)return l.text()}).then(l=>{if(!l)return;const c=gu(l);c&&(tr.set(a,c),i(c))}).catch(()=>{})},[a]),o?e.jsx("span",{className:r,dangerouslySetInnerHTML:{__html:o}}):e.jsx("span",{className:r})}const eo="https://github.com/cloudcli-ai/cloudcli-plugin-starter",bu="https://github.com/cloudcli-ai/cloudcli-plugin-terminal",yu="https://github.com/grostim/cloudcli-cron",vu="https://github.com/satsuki19980613/cloudcli-claude-watch",ju="https://github.com/jakeefr/cloudcli-plugin-prism",wu="https://github.com/strykereye2/cloudcli-plugin-session-manager",Nu="https://github.com/NightmareAway/cloudcli-plugin-token-cost-calculator",ku="https://github.com/TadMSTR/cloudcli-plugin-task-queue",Su="https://github.com/szmidtpiotr/claude-github-issue",Cu="https://github.com/HandyS11/cloudcli-plugin-claude-usage",Pu="https://github.com/dongwook-chan/cloudcli-plugin-codex-usage",ja=[{id:"project-stats",translationKey:"starterPlugin",repoUrl:eo,installedNames:["project-stats"],icon:or,source:"official"},{id:"web-terminal",translationKey:"terminalPlugin",repoUrl:bu,installedNames:["web-terminal"],icon:$a,source:"official"}],Eu=[{id:"cloudcli-claude-watch",translationKey:"claudeWatchPlugin",repoUrl:vu,installedNames:["cloudcli-claude-watch"],icon:Xe,source:"unofficial"},{id:"workspace-scheduled-prompts",translationKey:"scheduledPromptPlugin",repoUrl:yu,installedNames:["workspace-scheduled-prompts"],icon:Mo,source:"unofficial"},{id:"prism",translationKey:"prismCloudCLI",repoUrl:ju,installedNames:["prism"],icon:Xe,source:"unofficial"},{id:"session-manager",translationKey:"sessionManagerPlugin",repoUrl:wu,installedNames:["session-manager"],icon:Xe,source:"unofficial"},{id:"token-cost-calculator",translationKey:"tokenCostCalculatorPlugin",repoUrl:Nu,installedNames:["token-cost-calculator"],icon:Fo,source:"unofficial"},{id:"task-queue",translationKey:"taskQueuePlugin",repoUrl:ku,installedNames:["task-queue"],icon:_o,source:"unofficial"},{id:"claude-github-issue",translationKey:"githubIssuesBoardPlugin",repoUrl:Su,installedNames:["claude-github-issue"],icon:za,source:"unofficial"},{id:"claude-usage",translationKey:"claudeUsagePlugin",repoUrl:Cu,installedNames:["claude-usage"],icon:or,source:"unofficial"},{id:"codex-usage",translationKey:"codexUsagePlugin",repoUrl:Pu,installedNames:["codex-usage"],icon:or,source:"unofficial"}];function Tu(t){return t.replace(/^https?:\/\/(www\.)?github\.com\//,"")}function wa(t){return t?.replace(/\.git$/,"").replace(/\/$/,"").toLowerCase()??null}function Na(t,s){return s.installedNames.includes(t.name)||wa(t.repoUrl)===wa(s.repoUrl)}function Iu({checked:t,onChange:s,ariaLabel:r}){return e.jsxs("label",{className:"relative inline-flex cursor-pointer select-none items-center",children:[e.jsx("input",{type:"checkbox",className:"peer sr-only",checked:t,onChange:a=>s(a.target.checked),"aria-label":r}),e.jsx("div",{className:`
16
- relative h-5 w-9 rounded-full bg-muted transition-colors
17
- duration-200 after:absolute
18
- after:left-[2px] after:top-[2px] after:h-4 after:w-4
19
- after:rounded-full after:bg-white after:shadow-sm after:transition-transform after:duration-200
20
- after:content-[''] peer-checked:bg-emerald-500
21
- peer-checked:after:translate-x-4
22
- `})]})}function Ru({running:t,t:s}){return t?e.jsxs("span",{className:"relative flex items-center gap-1.5",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-emerald-600 dark:text-emerald-400",children:s("pluginSettings.runningStatus")})]}):null}function Au({plugin:t,index:s,onToggle:r,onUpdate:a,onUninstall:o,updating:i,confirmingUninstall:l,onCancelUninstall:c,updateError:m}){const{t:d}=ce("settings"),u=t.enabled?"bg-emerald-500":"bg-muted-foreground/20";return e.jsxs("div",{className:"relative flex overflow-hidden rounded-lg border border-border bg-card transition-opacity duration-200",style:{opacity:t.enabled?1:.65,animationDelay:`${s*40}ms`},children:[e.jsx("div",{className:`w-[3px] flex-shrink-0 ${u} transition-colors duration-300`}),e.jsxs("div",{className:"min-w-0 flex-1 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("div",{className:"h-5 w-5 flex-shrink-0 text-foreground/80",children:e.jsx(fu,{pluginName:t.name,iconFile:t.icon,className:"h-5 w-5 [&>svg]:h-full [&>svg]:w-full"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold leading-none text-foreground",children:t.displayName}),e.jsxs("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:["v",t.version]}),e.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.slot}),e.jsx(Ru,{running:!!t.serverRunning,t:d})]}),t.description&&e.jsx("p",{className:"mt-1 text-sm leading-snug text-muted-foreground",children:t.description}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[t.author&&e.jsx("span",{className:"text-xs text-muted-foreground/60",children:t.author}),t.repoUrl&&e.jsxs("a",{href:t.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground/60 transition-colors hover:text-foreground",children:[e.jsx(Ft,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[200px] truncate",children:t.repoUrl.replace(/^https?:\/\/(www\.)?github\.com\//,"")})]})]})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-2",children:[e.jsx("button",{onClick:a,disabled:i||!t.repoUrl,title:t.repoUrl?d("pluginSettings.pullLatest"):d("pluginSettings.noGitRemote"),"aria-label":d("pluginSettings.pullLatest"),className:"rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40",children:i?e.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(is,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:o,title:d(l?"pluginSettings.confirmUninstall":"pluginSettings.uninstallPlugin"),"aria-label":d("pluginSettings.uninstallPlugin"),className:`rounded p-1.5 transition-colors ${l?"bg-red-50 text-red-500 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/30":"text-muted-foreground hover:bg-muted hover:text-red-500"}`,children:e.jsx(Te,{className:"h-3.5 w-3.5"})}),e.jsx(Iu,{checked:t.enabled,onChange:r,ariaLabel:`${t.enabled?d("pluginSettings.disable"):d("pluginSettings.enable")} ${t.displayName}`})]})]}),l&&e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 rounded border border-red-200 bg-red-50 px-3 py-2 dark:border-red-800/50 dark:bg-red-950/30",children:[e.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:d("pluginSettings.confirmUninstallMessage",{name:t.displayName})}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:c,className:"rounded border border-border px-2.5 py-1 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:d("pluginSettings.cancel")}),e.jsx("button",{onClick:o,className:"rounded border border-red-300 px-2.5 py-1 text-sm font-medium text-red-600 transition-colors hover:bg-red-100 dark:border-red-700 dark:text-red-400 dark:hover:bg-red-900/30",children:d("pluginSettings.remove")})]})]}),m&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-sm text-red-500",children:[e.jsx($o,{className:"h-3.5 w-3.5 flex-shrink-0"}),e.jsx("span",{children:m})]})]})]})}function ka({title:t,description:s,children:r}){return e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground/70",children:s})]}),e.jsx("div",{className:"space-y-2",children:r})]})}function Sa({recommendation:t,onInstall:s,disabled:r,installing:a}){const{t:o}=ce("settings"),i=t.icon,l=t.source==="official",c=l?"bg-blue-500/30":"bg-amber-500/40",m=l?"hover:border-blue-400 dark:hover:border-blue-500":"hover:border-amber-400 dark:hover:border-amber-500",d=l?"text-blue-500":"text-amber-500";return e.jsxs("div",{className:`relative flex overflow-hidden rounded-lg border border-dashed border-border bg-card transition-all duration-200 ${m}`,children:[e.jsx("div",{className:`w-[3px] flex-shrink-0 ${c}`}),e.jsx("div",{className:"min-w-0 flex-1 p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("div",{className:`h-5 w-5 flex-shrink-0 ${d}`,children:e.jsx(i,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold leading-none text-foreground",children:o(`pluginSettings.${t.translationKey}.name`)}),e.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:o("pluginSettings.tab")})]}),e.jsx("p",{className:"mt-1 text-sm leading-snug text-muted-foreground",children:o(`pluginSettings.${t.translationKey}.description`)}),e.jsxs("a",{href:t.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 text-xs text-muted-foreground/60 transition-colors hover:text-foreground",children:[e.jsx(Ft,{className:"h-3 w-3"}),Tu(t.repoUrl)]})]})]}),e.jsxs("button",{onClick:s,disabled:r,className:"flex flex-shrink-0 items-center gap-1.5 rounded-md bg-foreground px-4 py-2 text-sm font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-50",children:[a?e.jsx(ve,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ga,{className:"h-3.5 w-3.5"}),o(a?"pluginSettings.installing":`pluginSettings.${t.translationKey}.install`)]})]})})]})}function Lu(){const{t}=ce("settings"),{plugins:s,loading:r,installPlugin:a,uninstallPlugin:o,updatePlugin:i,togglePlugin:l}=tn(),[c,m]=n.useState(""),[d,u]=n.useState(!1),[x,h]=n.useState(null),[p,f]=n.useState(null),[b,g]=n.useState(null),[v,S]=n.useState(new Set),[k,y]=n.useState({}),P=async w=>{S(L=>new Set(L).add(w)),y(L=>{const O={...L};return delete O[w],O});const D=await i(w);D.success||y(L=>({...L,[w]:D.error||t("pluginSettings.updateFailed")})),S(L=>{const O=new Set(L);return O.delete(w),O})},E=async()=>{if(!c.trim())return;u(!0),f(null);const w=await a(c.trim());w.success?m(""):f(w.error||t("pluginSettings.installFailed")),u(!1)},C=async w=>{if(!x){h(w.id),f(null);try{const D=await a(w.repoUrl);D.success||f(D.error||t("pluginSettings.installFailed"))}finally{h(null)}}},T=async w=>{if(b!==w){g(w);return}const D=await o(w);D.success||f(D.error||t("pluginSettings.uninstallFailed")),g(null)},I=w=>s.some(D=>Na(D,w)),j=w=>ja.some(D=>Na(w,D)),$=s.filter(j),G=s.filter(w=>!j(w)),K=ja.filter(w=>!I(w)),M=Eu.filter(w=>!I(w)),X=$.length>0||K.length>0,H=G.length>0||M.length>0,B=(w,D)=>{const L=async O=>{const U=await l(w.name,O);U.success||f(U.error||t("pluginSettings.toggleFailed"))};return e.jsx(Au,{plugin:w,index:D,onToggle:O=>{L(O)},onUpdate:()=>{P(w.name)},onUninstall:()=>{T(w.name)},updating:v.has(w.name),confirmingUninstall:b===w.name,onCancelUninstall:()=>g(null),updateError:k[w.name]??null},w.name)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 text-base font-semibold text-foreground",children:t("pluginSettings.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("pluginSettings.description")})]}),e.jsxs("div",{className:"flex items-center gap-0 overflow-hidden rounded-lg border border-border bg-card",children:[e.jsx("span",{className:"flex-shrink-0 pl-3 pr-1 text-muted-foreground/40",children:e.jsx(Ft,{className:"h-3.5 w-3.5"})}),e.jsx("input",{type:"text",value:c,onChange:w=>{m(w.target.value),f(null)},placeholder:t("pluginSettings.installPlaceholder"),"aria-label":t("pluginSettings.installAriaLabel"),className:"flex-1 bg-transparent px-2 py-2.5 text-sm text-foreground placeholder:text-muted-foreground/40 focus:outline-none",onKeyDown:w=>{w.key==="Enter"&&E()}}),e.jsx("button",{onClick:E,disabled:d||!c.trim(),className:"flex-shrink-0 border-l border-border bg-foreground px-4 py-2.5 text-sm font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-30",children:d?e.jsx(ve,{className:"h-4 w-4 animate-spin"}):t("pluginSettings.installButton")})]}),p&&e.jsx("p",{className:"-mt-4 text-sm text-red-500",children:p}),e.jsxs("p",{className:"-mt-4 flex items-start gap-1.5 text-xs leading-snug text-muted-foreground/50",children:[e.jsx(Oo,{className:"mt-px h-3 w-3 flex-shrink-0"}),e.jsx("span",{children:t("pluginSettings.securityWarning")})]}),r?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[e.jsx(ve,{className:"h-4 w-4 animate-spin"}),t("pluginSettings.scanningPlugins")]}):e.jsxs("div",{className:"space-y-4",children:[X&&e.jsxs(ka,{title:t("pluginSettings.sections.officialTitle"),description:t("pluginSettings.sections.officialDescription"),children:[$.map((w,D)=>B(w,D)),K.map(w=>e.jsx(Sa,{recommendation:w,onInstall:()=>{C(w)},disabled:!!x,installing:x===w.id},w.id))]}),H&&e.jsxs(ka,{title:t("pluginSettings.sections.unofficialTitle"),description:t("pluginSettings.sections.unofficialDescription"),children:[G.map((w,D)=>B(w,$.length+D)),M.map(w=>e.jsx(Sa,{recommendation:w,onInstall:()=>{C(w)},disabled:!!x,installing:x===w.id},w.id))]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 border-t border-border/50 pt-2",children:[e.jsx(Do,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/40"}),e.jsx("span",{className:"text-xs text-muted-foreground/60",children:t("pluginSettings.starterPluginLabel")}),e.jsx("span",{className:"text-muted-foreground/20",children:"·"}),e.jsxs("a",{href:eo,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground/60 transition-colors hover:text-foreground",children:[t("pluginSettings.starter")," ",e.jsx(Mt,{className:"h-2.5 w-2.5"})]}),e.jsx("span",{className:"text-muted-foreground/20",children:"·"}),e.jsxs("a",{href:"https://cloudcli.ai/docs/plugin-overview",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground/60 transition-colors hover:text-foreground",children:[t("pluginSettings.docs")," ",e.jsx(Mt,{className:"h-2.5 w-2.5"})]})]})]})}const rs="https://github.com/CaineWind/wacli",Mu=`${rs}/blob/main/docs/README.md`;function Ca({className:t}){return e.jsx("svg",{className:t,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})})}function Fu(){const{t}=ce("settings"),{updateAvailable:s,latestVersion:r,currentVersion:a,releaseInfo:o}=sn("CaineWind","wacli"),i=o?.htmlUrl||`${rs}/releases`;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-primary/90 shadow-sm",children:e.jsx(ft,{className:"h-5 w-5 text-primary-foreground"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base font-semibold text-foreground",style:{fontFamily:Qa},children:"WindCli"}),e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:["v",a]}),s&&r&&e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 rounded-full bg-green-500/10 px-2 py-0.5 text-[10px] font-medium text-green-600 transition-colors hover:bg-green-500/20 dark:text-green-400",children:[t("apiKeys.version.updateAvailable",{version:r}),e.jsx(Mt,{className:"h-2.5 w-2.5"})]})]}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"Open-source AI coding assistant interface"})]})]}),e.jsxs("a",{href:rs,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 rounded-lg border border-border/60 bg-background px-3.5 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[e.jsx(Ca,{className:"h-4 w-4"}),e.jsx(os,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Star on GitHub"})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[e.jsxs("a",{href:rs,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(Ca,{className:"h-4 w-4"}),"GitHub"]}),e.jsxs("a",{href:Mu,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(Mt,{className:"h-3.5 w-3.5"}),"Docs"]})]}),e.jsx("div",{className:"border-t border-border/50 pt-4",children:e.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Licensed under AGPL-3.0"})})]})}const Om=[{id:"agents",label:"Agents",keywords:"agents subagents claude code",icon:Ma},{id:"appearance",label:"Appearance",keywords:"appearance theme dark light language",icon:Fa},{id:"git",label:"Git",keywords:"git github commits",icon:Ft},{id:"api",label:"API Tokens",keywords:"api tokens auth keys",icon:zo},{id:"tasks",label:"Tasks",keywords:"tasks taskmaster",icon:_a},{id:"browser",label:"Browser",keywords:"browser playwright chromium automation",icon:Oa},{id:"notifications",label:"Notifications",keywords:"notifications alerts push",icon:gr},{id:"plugins",label:"Plugins",keywords:"plugins extensions integrations",icon:Uo},{id:"about",label:"About",keywords:"about version info",icon:Da}],_u={fontSize:"14"},Ou={allowedCommands:[],disallowedCommands:[],skipPermissions:!1},Du=["agents","appearance","git","api","tasks","browser","notifications","plugins","about"],Pa=t=>t==="tools"?"agents":Du.includes(t)?t:"agents",sr=(t,s)=>{if(!t)return s;try{return JSON.parse(t)}catch{return s}},$u=t=>t==="acceptEdits"||t==="bypassPermissions"?t:"default",zu=()=>({wordWrap:localStorage.getItem("codeEditorWordWrap")==="true",showMinimap:localStorage.getItem("codeEditorShowMinimap")!=="false",lineNumbers:localStorage.getItem("codeEditorLineNumbers")!=="false",fontSize:localStorage.getItem("codeEditorFontSize")??_u.fontSize}),Uu=async t=>t.json(),Ea=()=>({allowedTools:[],disallowedTools:[],skipPermissions:!1}),Ta=()=>({...Ou}),xt=()=>({channels:{inApp:!0,webPush:!1,desktop:!1,sound:!0},events:{actionRequired:!0,stop:!0,error:!0}}),Gu=t=>{const s=xt();return{channels:{inApp:t?.channels?.inApp??s.channels.inApp,webPush:t?.channels?.webPush??s.channels.webPush,desktop:t?.channels?.desktop??s.channels.desktop,sound:t?.channels?.sound??s.channels.sound},events:{actionRequired:t?.events?.actionRequired??s.events.actionRequired,stop:t?.events?.stop??s.events.stop,error:t?.events?.error??s.events.error}}};function Vu({isOpen:t,initialTab:s}){const{isDarkMode:r,toggleDarkMode:a}=br(),o=n.useRef(null),[i,l]=n.useState(()=>Pa(s)),[c,m]=n.useState(null),[d,u]=n.useState("name"),[x,h]=n.useState(()=>zu()),[p,f]=n.useState(()=>Ea()),[b,g]=n.useState(()=>Ta()),[v,S]=n.useState(()=>xt()),[k,y]=n.useState("default"),[P,E]=n.useState(!1),[C,T]=n.useState(""),{providerAuthStatus:I,checkProviderAuthStatus:j,refreshProviderAuthStatuses:$}=ri(),G=n.useCallback(async()=>{try{const D=sr(localStorage.getItem("claude-settings"),{});f({allowedTools:D.allowedTools||[],disallowedTools:D.disallowedTools||[],skipPermissions:!!D.skipPermissions}),u(D.projectSortOrder==="date"?"date":"name");const L=sr(localStorage.getItem("cursor-tools-settings"),{});g({allowedCommands:L.allowedCommands||[],disallowedCommands:L.disallowedCommands||[],skipPermissions:!!L.skipPermissions});const O=sr(localStorage.getItem("codex-settings"),{});y($u(O.permissionMode));try{const U=await z("/api/settings/notification-preferences");if(U.ok){const N=await Uu(U);N.success&&N.preferences?S(Gu(N.preferences)):S(xt())}else S(xt())}catch{S(xt())}}catch(D){console.error("Error loading settings:",D),f(Ea()),g(Ta()),S(xt()),y("default"),u("name")}},[]),K=n.useCallback(D=>{T(D),E(!0)},[]),M=n.useCallback(D=>{C&&(async()=>{const L=await j(C);D!==0&&console.warn(`Login process exited with code ${D}; refreshing auth status before setting save status.`),m(L.authenticated?"success":"error")})()},[j,C]),X=n.useCallback(async()=>{m(null);try{const D=new Date().toISOString();if(localStorage.setItem("claude-settings",JSON.stringify({allowedTools:p.allowedTools,disallowedTools:p.disallowedTools,skipPermissions:p.skipPermissions,projectSortOrder:d,lastUpdated:D})),localStorage.setItem("cursor-tools-settings",JSON.stringify({allowedCommands:b.allowedCommands,disallowedCommands:b.disallowedCommands,skipPermissions:b.skipPermissions,lastUpdated:D})),localStorage.setItem("codex-settings",JSON.stringify({permissionMode:k,lastUpdated:D})),!(await z("/api/settings/notification-preferences",{method:"PUT",body:JSON.stringify(v)})).ok)throw new Error("Failed to save notification preferences");m("success")}catch(D){console.error("Error saving settings:",D),m("error")}},[p.allowedTools,p.disallowedTools,p.skipPermissions,k,b.allowedCommands,b.disallowedCommands,b.skipPermissions,v,d]),H=n.useCallback((D,L)=>{h(O=>({...O,[D]:L}))},[]);n.useEffect(()=>{t&&(l(Pa(s)),G(),$())},[s,t,G,$]),n.useEffect(()=>{lu(v.channels.sound)},[v.channels.sound]),n.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",String(x.wordWrap)),localStorage.setItem("codeEditorShowMinimap",String(x.showMinimap)),localStorage.setItem("codeEditorLineNumbers",String(x.lineNumbers)),localStorage.setItem("codeEditorFontSize",x.fontSize),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[x]);const B=n.useRef(null),w=n.useRef(!0);return n.useEffect(()=>{if(w.current){w.current=!1;return}return B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{X()},500),()=>{B.current!==null&&window.clearTimeout(B.current)}},[X]),n.useEffect(()=>{if(c===null)return;const D=window.setTimeout(()=>m(null),2e3);return()=>window.clearTimeout(D)},[c]),n.useEffect(()=>{t&&(w.current=!0)},[t]),n.useEffect(()=>()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null),B.current!==null&&(window.clearTimeout(B.current),B.current=null)},[]),{activeTab:i,setActiveTab:l,isDarkMode:r,toggleDarkMode:a,saveStatus:c,projectSortOrder:d,setProjectSortOrder:u,codeEditorSettings:x,updateCodeEditorSetting:H,claudePermissions:p,setClaudePermissions:f,cursorPermissions:b,setCursorPermissions:g,notificationPreferences:v,setNotificationPreferences:S,codexPermissionMode:k,setCodexPermissionMode:y,providerAuthStatus:I,openLoginForProvider:K,showLoginModal:P,setShowLoginModal:E,loginProvider:C,handleLoginComplete:M}}function Ku(t){const s="=".repeat((4-t.length%4)%4),r=(t+s).replace(/-/g,"+").replace(/_/g,"/"),a=window.atob(r),o=new Uint8Array(a.length);for(let i=0;i<a.length;++i)o[i]=a.charCodeAt(i);return o}function Bu(){const[t,s]=n.useState(()=>typeof window>"u"||window.cloudcliDesktopNotifications||!("Notification"in window)||!("serviceWorker"in navigator)?"unsupported":Notification.permission),[r,a]=n.useState(!1),[o,i]=n.useState(!1);n.useEffect(()=>{t!=="unsupported"&&navigator.serviceWorker.ready.then(m=>{m.pushManager.getSubscription().then(d=>{a(d!==null)})}).catch(()=>{})},[t]);const l=n.useCallback(async()=>{if(t!=="unsupported"){i(!0);try{const m=await Notification.requestPermission();if(s(m),m!=="granted")return;const d=await z("/api/settings/push/vapid-public-key"),{publicKey:u}=await d.json(),p=(await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Ku(u).buffer})).toJSON();await z("/api/settings/push/subscribe",{method:"POST",body:JSON.stringify({endpoint:p.endpoint,keys:p.keys})}),a(!0)}catch(m){console.error("Push subscribe failed:",m)}finally{i(!1)}}},[t]),c=n.useCallback(async()=>{i(!0);try{const d=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(d){const u=d.endpoint;await d.unsubscribe(),await z("/api/settings/push/unsubscribe",{method:"POST",body:JSON.stringify({endpoint:u})})}a(!1)}catch(m){console.error("Push unsubscribe failed:",m)}finally{i(!1)}},[]);return{permission:t,isSubscribed:r,isLoading:o,subscribe:l,unsubscribe:c}}function Wu({isOpen:t,onClose:s,projects:r=[],initialTab:a="agents"}){const{t:o}=ce("settings"),i=n.useMemo(()=>typeof window>"u"?null:window.cloudcliDesktopNotifications||null,[]),[l,c]=n.useState(null),{activeTab:m,setActiveTab:d,saveStatus:u,projectSortOrder:x,setProjectSortOrder:h,codeEditorSettings:p,updateCodeEditorSetting:f,claudePermissions:b,setClaudePermissions:g,notificationPreferences:v,setNotificationPreferences:S,cursorPermissions:k,setCursorPermissions:y,codexPermissionMode:P,setCodexPermissionMode:E,providerAuthStatus:C,openLoginForProvider:T,showLoginModal:I,setShowLoginModal:j,loginProvider:$,handleLoginComplete:G}=Vu({isOpen:t,initialTab:a}),{permission:K,isSubscribed:M,isLoading:X,subscribe:H,unsubscribe:B}=Bu(),w=async()=>{await H(),S({...v,channels:{...v.channels,webPush:!0}})},D=async()=>{await B(),S({...v,channels:{...v.channels,webPush:!1}})};n.useEffect(()=>{if(!i)return;let N=!0;i.getState().then(ee=>{N&&c(ee?.desktopNotifications||null)}).catch(()=>{});const A=i.onStateUpdated?.(ee=>{N&&c(ee?.desktopNotifications||null)});return()=>{N=!1,A?.()}},[i]);const L=async()=>{if(!i)return;const N=await i.update({enabled:!0});c(N?.desktopNotifications||null),S({...v,channels:{...v.channels,desktop:!0}})},O=async()=>{if(!i)return;const N=await i.update({enabled:!1});c(N?.desktopNotifications||null),S({...v,channels:{...v.channels,desktop:!1}})};if(!t)return null;const U=!!($&&C[$].authenticated);return e.jsxs("div",{className:"modal-backdrop fixed inset-0 z-[9999] flex items-center justify-center bg-background/80 backdrop-blur-sm md:p-4",children:[e.jsxs("div",{className:"flex h-full w-full flex-col overflow-hidden border border-border bg-background shadow-2xl md:h-[90vh] md:max-w-4xl md:rounded-xl",children:[e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between border-b border-border px-4 py-3 md:px-5",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:o("title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[u==="success"&&e.jsx("span",{className:"animate-in fade-in text-xs text-muted-foreground",children:o("saveStatus.success")}),e.jsx(W,{variant:"ghost",size:"sm",onClick:s,className:"h-10 w-10 touch-manipulation p-0 text-muted-foreground hover:text-foreground active:bg-accent/50",children:e.jsx(ge,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col md:flex-row",children:[e.jsx(zc,{activeTab:m,onChange:d}),e.jsx("main",{className:"min-w-0 flex-1 overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"settings-content-enter min-w-0 space-y-6 overflow-x-hidden p-4 pb-safe-area-inset-bottom md:space-y-8 md:p-6",children:[m==="appearance"&&e.jsx(Jd,{projectSortOrder:x,onProjectSortOrderChange:h,codeEditorSettings:p,onCodeEditorWordWrapChange:N=>f("wordWrap",N),onCodeEditorShowMinimapChange:N=>f("showMinimap",N),onCodeEditorLineNumbersChange:N=>f("lineNumbers",N),onCodeEditorFontSizeChange:N=>f("fontSize",N)}),m==="git"&&e.jsx(nu,{}),m==="agents"&&e.jsx(Wd,{providerAuthStatus:C,onProviderLogin:T,claudePermissions:b,onClaudePermissionsChange:g,cursorPermissions:k,onCursorPermissionsChange:y,codexPermissionMode:P,onCodexPermissionModeChange:E,projects:r}),m==="tasks"&&e.jsx(pu,{}),m==="browser"&&e.jsx(ou,{}),m==="notifications"&&e.jsx(mu,{notificationPreferences:v,onNotificationPreferencesChange:S,pushPermission:K,isPushSubscribed:M,isPushLoading:X,onEnablePush:w,onDisablePush:D,isDesktop:!!i,desktopNotifications:l,onEnableDesktopNotifications:L,onDisableDesktopNotifications:O}),m==="api"&&e.jsx(Xd,{}),m==="voice"&&e.jsx(ru,{}),m==="plugins"&&e.jsx(Lu,{}),m==="about"&&e.jsx(Fu,{})]},m)})]})]}),e.jsx(ui,{isOpen:I,onClose:()=>j(!1),provider:$||"claude",onComplete:G,isAuthenticated:U},$||"claude")]})}const Hu=30;function Ju({isOpen:t,onClose:s,releaseInfo:r,currentVersion:a,latestVersion:o,installMode:i}){const{t:l}=ce("common"),c=i==="npm"?l("versionUpdate.npmUpgradeCommand"):he?"npm run update:platform":"git checkout main && git pull && npm install",[m,d]=n.useState(!1),[u,x]=n.useState(""),[h,p]=n.useState(""),[f,b]=n.useState(null);n.useEffect(()=>{if(!he||f===null)return;if(f<=0){window.location.reload();return}const v=window.setTimeout(()=>{b(S=>S===null?null:Math.max(S-1,0))},1e3);return()=>window.clearTimeout(v)},[f]);const g=n.useCallback(async()=>{d(!0),x(`Starting update...
23
- `),b(he?Hu:null),p("");try{const v=await z("/api/system/update",{method:"POST"}),S=await v.text();let k=null;try{k=JSON.parse(S)}catch{k=null}if(!k){if(he)x(y=>y+`
24
- Update started. The server appears to be restarting to apply it.
25
- `);else{b(null);const y=`The update endpoint returned an unexpected response (HTTP ${v.status}). Update manually with the command below.`;p(y),x(P=>P+`
26
- ❌ Update failed: `+y+`
27
- `)}return}v.ok?(x(y=>y+(k.output||"")+`
28
- `),x(y=>y+`
29
- ✅ Update completed successfully!
30
- `),he||x(y=>y+`Please restart the server to apply changes.
31
- `)):(b(null),p(k.error||"Update failed"),x(y=>y+`
32
- ❌ Update failed: `+(k.error||"Unknown error")+`
33
- `))}catch(v){he?x(S=>S+`
34
- Connection to the server was interrupted — it is likely restarting to apply the update.
35
- `):(b(null),p(v.message),x(S=>S+`
36
- ❌ Update failed: `+v.message+`
37
- `))}finally{d(!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:s,"aria-label":l("versionUpdate.ariaLabels.closeModal")}),e.jsxs("div",{className:"relative mx-4 max-h-[90vh] w-full max-w-2xl space-y-4 overflow-y-auto rounded-lg border border-gray-200 bg-white p-6 shadow-xl dark:border-gray-700 dark:bg-gray-800",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:"flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100 dark:bg-blue-900/30",children:e.jsx("svg",{className:"h-5 w-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:l("versionUpdate.title")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:r?.title||l("versionUpdate.newVersionReady")})]})]}),e.jsx("button",{onClick:s,className:"rounded-md p-2 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",children:e.jsx("svg",{className:"h-5 w-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 items-center justify-between rounded-lg bg-gray-50 p-3 dark:bg-gray-700/50",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:l("versionUpdate.currentVersion")}),e.jsx("span",{className:"font-mono text-sm text-gray-900 dark:text-white",children:a})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-700 dark:bg-blue-900/20",children:[e.jsx("span",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:l("versionUpdate.latestVersion")}),e.jsx("span",{className:"font-mono text-sm text-blue-900 dark:text-blue-100",children:o})]})]}),r?.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:l("versionUpdate.whatsNew")}),r?.htmlUrl&&e.jsxs("a",{href:r.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 hover:underline dark:text-blue-400 dark:hover:text-blue-300",children:[l("versionUpdate.viewFullRelease"),e.jsx("svg",{className:"h-3 w-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:"max-h-64 overflow-y-auto rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-600 dark:bg-gray-700/50",children:e.jsx("div",{className:"prose prose-sm max-w-none text-sm text-gray-700 dark:prose-invert dark:text-gray-300",children:e.jsx(Ko,{remarkPlugins:[Bo],components:qu,children:Qu(r.body)})})})]}),(u||h)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:l("versionUpdate.updateProgress")}),e.jsx("div",{className:"max-h-48 overflow-y-auto rounded-lg border border-gray-700 bg-gray-900 p-4 dark:bg-gray-950",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs text-green-400",children:u})}),he&&f!==null&&e.jsx("div",{className:"rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-xs text-blue-700 dark:border-blue-900/40 dark:bg-blue-900/20 dark:text-blue-200",children:f===0?"Refreshing the window now...":`This will refresh the window in ${f} ${f===1?"second":"seconds"}. If the update doesn't apply, RESTART the environment.`}),h&&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:h})]}),!m&&!u&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:l("versionUpdate.manualUpgrade")}),e.jsx("div",{className:"rounded-lg border bg-gray-100 p-3 dark:bg-gray-800",children:e.jsx("code",{className:"font-mono text-sm text-gray-800 dark:text-gray-200",children:c})}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:l("versionUpdate.manualUpgradeHint")})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx("button",{onClick:s,className:"flex-1 rounded-md bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",children:l(u?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!u&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>Cr(c),className:"flex-1 rounded-md bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",children:l("versionUpdate.buttons.copyCommand")}),e.jsx("button",{onClick:g,disabled:m,className:"flex flex-1 items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:bg-blue-400",children:m?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),l("versionUpdate.buttons.updating")]}):l("versionUpdate.buttons.updateNow")})]})]})]})]}):null}const qu={a:({href:t,children:s})=>e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline dark:text-blue-400",children:s})},Qu=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,`
38
-
39
- `).trim():"";function Yu({message:t}){return e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-red-200 bg-red-50 p-4 dark:border-red-800 dark:bg-red-900/20",children:[e.jsx(Aa,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-red-600 dark:text-red-400"}),e.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:t})]})}const Zu=["git@","ssh://"],Xu=/^[A-Za-z]:\\?$/,to=t=>{const s=t.trim();return Zu.some(r=>s.startsWith(r))},so=t=>t.trim().length>0&&!to(t),Ia=t=>t.trim().length>0,em=t=>{const s=t.trim(),r=Math.max(s.lastIndexOf("/"),s.lastIndexOf("\\"));return r===2&&/^[A-Za-z]:/.test(s)?`${s.slice(0,2)}\\`:r>0?s.slice(0,r):"~"},tm=t=>{if(t==="~"||t==="/"||Xu.test(t))return null;const s=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return s<=0?"/":s===2&&/^[A-Za-z]:/.test(t)?`${t.slice(0,2)}\\`:t.slice(0,s)},sm=(t,s)=>{const r=t.trim().replace(/[\\/]+$/,""),a=r.includes("\\")&&!r.includes("/")?"\\":"/";return`${r}${a}${s.trim()}`},rr=(t,s)=>`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${t===s?t==="none"?"bg-green-500 text-white":"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`;function rm({tokenMode:t,selectedGithubToken:s,newGithubToken:r,availableTokens:a,loadingTokens:o,tokenLoadError:i,onTokenModeChange:l,onSelectedGithubTokenChange:c,onNewGithubTokenChange:m}){const{t:d}=ce();return e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-900/50",children:[e.jsxs("div",{className:"mb-4 flex items-start gap-3",children:[e.jsx(hr,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-gray-600 dark:text-gray-400"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"mb-1 font-medium text-gray-900 dark:text-white",children:d("projectWizard.step2.githubAuth")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:d("projectWizard.step2.githubAuthHelp")})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(ve,{className:"h-4 w-4 animate-spin"}),d("projectWizard.step2.loadingTokens")]}),!o&&i&&e.jsx("p",{className:"mb-3 text-sm text-red-600 dark:text-red-400",children:i}),!o&&a.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 grid grid-cols-3 gap-2",children:[e.jsx("button",{onClick:()=>l("stored"),className:rr(t,"stored"),children:d("projectWizard.step2.storedToken")}),e.jsx("button",{onClick:()=>l("new"),className:rr(t,"new"),children:d("projectWizard.step2.newToken")}),e.jsx("button",{onClick:()=>{l("none"),c(""),m("")},className:rr(t,"none"),children:d("projectWizard.step2.nonePublic")})]}),t==="stored"?e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300",children:d("projectWizard.step2.selectToken")}),e.jsxs("select",{value:s,onChange:u=>c(u.target.value),className:"w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm dark:border-gray-600 dark:bg-gray-800",children:[e.jsx("option",{value:"",children:d("projectWizard.step2.selectTokenPlaceholder")}),a.map(u=>e.jsx("option",{value:String(u.id),children:u.credential_name},u.id))]})]}):t==="new"?e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300",children:d("projectWizard.step2.newToken")}),e.jsx(me,{type:"password",value:r,onChange:u=>m(u.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:d("projectWizard.step2.tokenHelp")})]}):null]}),!o&&a.length===0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-800 dark:bg-blue-900/20",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:d("projectWizard.step2.publicRepoInfo")})}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300",children:d("projectWizard.step2.optionalTokenPublic")}),e.jsx(me,{type:"password",value:r,onChange:u=>{const x=u.target.value;m(x),l(x.trim()?"new":"none")},placeholder:d("projectWizard.step2.tokenPublicPlaceholder"),className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:d("projectWizard.step2.noTokensHelp")})]})]})]})}const ks=async t=>await t.json(),am=t=>{if(typeof t.details=="string"&&t.details.trim().length>0)return t.details;if(typeof t.error=="string"&&t.error.trim().length>0)return t.error;if(t.error&&typeof t.error=="object"){const s=t.error;if(typeof s.details=="string"&&s.details.trim().length>0)return s.details;if(typeof s.message=="string"&&s.message.trim().length>0)return s.message;if(s.details&&typeof s.details=="object"&&typeof s.details.projectPath=="string")return`Project path already exists: ${s.details.projectPath}`}return typeof t.message=="string"&&t.message.trim().length>0?t.message:null},nm=async()=>{const t=await ue.get("/settings/credentials?type=github_token"),s=await ks(t);if(!t.ok)throw new Error(s.error||"Failed to load GitHub tokens");return(s.credentials||[]).filter(r=>r.is_active)},ro=async t=>{const s=`/file-tree/browse-filesystem?path=${encodeURIComponent(t)}`,r=await ue.get(s),a=await ks(r);if(!r.ok)throw new Error(a.error||"Failed to browse filesystem");return{path:a.path||t,suggestions:a.suggestions||[]}},om=async t=>{const s=await ue.createFolder(t),r=await ks(s);if(!s.ok)throw new Error(r.error||"Failed to create folder");return r.path||t},im=async t=>{const s=await ue.createProject(t),r=await ks(s);if(!s.ok)throw new Error(am(r)||"Failed to create project");return r.project},lm=({workspacePath:t,githubUrl:s,tokenMode:r,selectedGithubToken:a,newGithubToken:o})=>{const i=new URLSearchParams({path:t.trim(),githubUrl:s.trim()});r==="stored"&&a&&i.set("githubTokenId",a),r==="new"&&o.trim()&&i.set("newGithubToken",o.trim());const l=vr();return l&&i.set("token",l),i.toString()},cm=(t,s)=>new Promise((r,a)=>{const o=lm(t),i=new EventSource(`/api/projects/clone-progress?${o}`);let l=!1;const c=m=>{l||(l=!0,i.close(),m())};i.onmessage=m=>{try{const d=JSON.parse(m.data);if(d.type==="progress"&&d.message){s.onProgress(d.message);return}if(d.type==="complete"){c(()=>r(d.project));return}d.type==="error"&&c(()=>a(new Error(d.message||"Failed to clone repository")))}catch(d){console.error("Error parsing clone progress event:",d)}},i.onerror=()=>{c(()=>a(new Error("Connection lost during clone")))}});function dm({isOpen:t,autoAdvanceOnSelect:s,onClose:r,onFolderSelected:a}){const[o,i]=n.useState("~"),[l,c]=n.useState([]),[m,d]=n.useState(!1),[u,x]=n.useState(!1),[h,p]=n.useState(!1),[f,b]=n.useState(""),[g,v]=n.useState(!1),[S,k]=n.useState(null),y=n.useCallback(async j=>{d(!0),k(null);try{const $=await ro(j);i($.path),c($.suggestions)}catch($){k($ instanceof Error?$.message:"Failed to load folders")}finally{d(!1)}},[]);n.useEffect(()=>{t&&y("~")},[t,y]);const P=n.useMemo(()=>l.filter(j=>u||!j.name.startsWith(".")).sort((j,$)=>j.name.toLowerCase().localeCompare($.name.toLowerCase())),[l,u]),E=()=>{p(!1),b("")},C=()=>{k(null),E(),r()},T=n.useCallback(async()=>{if(f.trim()){v(!0),k(null);try{const j=sm(o,f),$=await om(j);E(),await y($)}catch(j){k(j instanceof Error?j.message:"Failed to create folder")}finally{v(!1)}}},[o,y,f]),I=tm(o);return t?e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/50 p-4 backdrop-blur-sm",children:e.jsxs("div",{className:"flex max-h-[80vh] w-full max-w-2xl flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-800",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-blue-100 dark:bg-blue-900/50",children:e.jsx(Lt,{className:"h-4 w-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:()=>x(j=>!j),className:`rounded-md p-2 transition-colors ${u?"bg-blue-50 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400":"text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300"}`,title:u?"Hide hidden folders":"Show hidden folders",children:u?e.jsx(Ua,{className:"h-5 w-5"}):e.jsx(us,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>p(j=>!j),className:`rounded-md p-2 transition-colors ${h?"bg-blue-50 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400":"text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300"}`,title:"Create new folder",children:e.jsx(Ee,{className:"h-5 w-5"})}),e.jsx("button",{onClick:C,className:"rounded-md p-2 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",children:e.jsx(ge,{className:"h-5 w-5"})})]})]}),h&&e.jsx("div",{className:"border-b border-gray-200 bg-blue-50 px-4 py-3 dark:border-gray-700 dark:bg-blue-900/20",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{type:"text",value:f,onChange:j=>b(j.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:j=>{j.key==="Enter"&&T(),j.key==="Escape"&&E()},autoFocus:!0}),e.jsx(W,{size:"sm",onClick:T,disabled:!f.trim()||g,children:g?e.jsx(ve,{className:"h-4 w-4 animate-spin"}):"Create"}),e.jsx(W,{size:"sm",variant:"ghost",onClick:E,children:"Cancel"})]})}),S&&e.jsx("div",{className:"px-4 pt-3",children:e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:S})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:m?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ve,{className:"h-6 w-6 animate-spin text-gray-400"})}):e.jsxs("div",{className:"space-y-1",children:[I&&e.jsxs("button",{onClick:()=>y(I),className:"flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700",children:[e.jsx(Lt,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),P.length===0?e.jsx("div",{className:"py-8 text-center text-gray-500 dark:text-gray-400",children:"No subfolders found"}):P.map(j=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>y(j.path),className:"flex flex-1 items-center gap-3 rounded-lg px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700",children:[e.jsx(xr,{className:"h-5 w-5 text-blue-500"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:j.name})]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>a(j.path,s),className:"px-3 text-xs",children:"Select"})]},j.path))]})}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 px-4 py-3 dark:bg-gray-900/50",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),e.jsx("code",{className:"flex-1 truncate font-mono text-sm text-gray-900 dark:text-white",children:o})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[e.jsx(W,{variant:"outline",onClick:C,children:"Cancel"}),e.jsx(W,{variant:"outline",onClick:()=>a(o,s),children:"Use this folder"})]})]})]})}):null}function um({value:t,disabled:s=!1,onChange:r,onAdvanceToConfirm:a}){const[o,i]=n.useState([]),[l,c]=n.useState(!1),[m,d]=n.useState(!1);n.useEffect(()=>{if(t.trim().length<=2){i([]),c(!1);return}const h=window.setTimeout(async()=>{try{const p=em(t),f=await ro(p),b=t.toLowerCase(),g=f.suggestions.filter(v=>{const S=v.path.toLowerCase();return S.startsWith(b)&&S!==b}).slice(0,5);i(g),c(g.length>0)}catch(p){console.error("Failed to load path suggestions:",p)}},200);return()=>{window.clearTimeout(h)}},[t]);const u=n.useCallback(h=>{r(h.path),c(!1)},[r]),x=n.useCallback((h,p)=>{r(h),d(!1),p&&a()},[a,r]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(me,{type:"text",value:t,onChange:h=>r(h.target.value),placeholder:"/path/to/project/workspace",className:"w-full",disabled:s}),l&&o.length>0&&e.jsx("div",{className:"absolute z-10 mt-1 max-h-60 w-full overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:o.map(h=>e.jsxs("button",{onClick:()=>u(h),className:"w-full px-4 py-2 text-left text-sm hover:bg-gray-100 dark:hover:bg-gray-700",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:h.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:h.path})]},h.path))})]}),e.jsx(W,{type:"button",variant:"outline",onClick:()=>d(!0),className:"px-3",title:"Browse folders",disabled:s,children:e.jsx(Lt,{className:"h-4 w-4"})})]}),e.jsx(dm,{isOpen:m,autoAdvanceOnSelect:!1,onClose:()=>d(!1),onFolderSelected:x})]})}function mm({workspacePath:t,githubUrl:s,tokenMode:r,selectedGithubToken:a,newGithubToken:o,availableTokens:i,loadingTokens:l,tokenLoadError:c,isCreating:m,onWorkspacePathChange:d,onGithubUrlChange:u,onTokenModeChange:x,onSelectedGithubTokenChange:h,onNewGithubTokenChange:p,onAdvanceToConfirm:f}){const{t:b}=ce(),g=so(s);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300",children:b("projectWizard.step2.newPath")}),e.jsx(um,{value:t,disabled:m,onChange:d,onAdvanceToConfirm:f}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:b("projectWizard.step2.newHelp")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300",children:b("projectWizard.step2.githubUrl")}),e.jsx(me,{type:"text",value:s,onChange:v=>u(v.target.value),placeholder:"https://github.com/username/repository",className:"w-full",disabled:m}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:b("projectWizard.step2.githubHelp")})]}),g&&e.jsx(rm,{tokenMode:r,selectedGithubToken:a,newGithubToken:o,availableTokens:i,loadingTokens:l,tokenLoadError:c,onTokenModeChange:x,onSelectedGithubTokenChange:h,onNewGithubTokenChange:p})]})}function pm({formState:t,selectedTokenName:s,isCreating:r,cloneProgress:a}){const{t:o}=ce(),i=n.useMemo(()=>t.tokenMode==="stored"&&t.selectedGithubToken?`${o("projectWizard.step3.usingStoredToken")} ${s||"Unknown"}`:t.tokenMode==="new"&&t.newGithubToken.trim()?o("projectWizard.step3.usingProvidedToken"):to(t.githubUrl)?o("projectWizard.step3.sshKey",{defaultValue:"SSH Key"}):o("projectWizard.step3.noAuthentication"),[t,s,o]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-900/50",children:[e.jsx("h4",{className:"mb-3 text-sm font-semibold text-gray-900 dark:text-white",children:o("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:o("projectWizard.step3.path")}),e.jsx("span",{className:"break-all font-mono text-xs text-gray-900 dark:text-white",children:t.workspacePath})]}),t.githubUrl&&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:o("projectWizard.step3.cloneFrom")}),e.jsx("span",{className:"break-all font-mono text-xs text-gray-900 dark:text-white",children:t.githubUrl})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:o("projectWizard.step3.authentication")}),e.jsx("span",{className:"text-xs text-gray-900 dark:text-white",children:i})]})]})]})]}),e.jsx("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-900/20",children:r&&a?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:o("projectWizard.step3.cloningRepository",{defaultValue:"Cloning repository..."})}),e.jsx("code",{className:"block whitespace-pre-wrap break-all font-mono text-xs text-blue-700 dark:text-blue-300",children:a})]}):e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:t.githubUrl?o("projectWizard.step3.newWithClone"):o("projectWizard.step3.newEmpty")})})]})}function xm({step:t,isCreating:s,isCloneWorkflow:r,onClose:a,onBack:o,onNext:i,onCreate:l}){const{t:c}=ce();return e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-200 p-6 dark:border-gray-700",children:[e.jsx(W,{variant:"outline",onClick:t===1?a:o,disabled:s,children:t===1?c("projectWizard.buttons.cancel"):e.jsxs(e.Fragment,{children:[e.jsx(Go,{className:"mr-1 h-4 w-4"}),c("projectWizard.buttons.back")]})}),e.jsx(W,{onClick:t===2?l:i,disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-2 h-4 w-4 animate-spin"}),r?c("projectWizard.buttons.cloning",{defaultValue:"Cloning..."}):c("projectWizard.buttons.creating")]}):t===2?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{className:"mr-1 h-4 w-4"}),c("projectWizard.buttons.createProject")]}):e.jsxs(e.Fragment,{children:[c("projectWizard.buttons.next"),e.jsx(cs,{className:"ml-1 h-4 w-4"})]})})]})}function hm({step:t}){const{t:s}=ce(),r=[1,2];return e.jsx("div",{className:"px-6 pb-2 pt-4",children:e.jsx("div",{className:"flex items-center justify-between",children:r.map(a=>e.jsxs(n.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium ${a<t?"bg-green-500 text-white":a===t?"bg-blue-500 text-white":"bg-gray-200 text-gray-500 dark:bg-gray-700"}`,children:a<t?e.jsx(Fe,{className:"h-4 w-4"}):a}),e.jsx("span",{className:"hidden text-sm font-medium text-gray-700 dark:text-gray-300 sm:inline",children:s(a===1?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),a<2&&e.jsx("div",{className:`mx-2 h-1 flex-1 rounded ${a<t?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},a))})})}const gm=({shouldLoad:t,selectedTokenId:s,onAutoSelectToken:r})=>{const[a,o]=n.useState([]),[i,l]=n.useState(!1),[c,m]=n.useState(null),d=n.useRef(!1);n.useEffect(()=>{if(!t||d.current)return;let x=!1;return(async()=>{l(!0),m(null);try{const p=await nm();if(x)return;o(p),d.current=!0,p.length>0&&!s&&r(String(p[0].id))}catch(p){x||m(p instanceof Error?p.message:"Failed to load GitHub tokens")}finally{x||l(!1)}})(),()=>{x=!0}},[r,s,t]);const u=n.useMemo(()=>a.find(x=>String(x.id)===s)?.credential_name||null,[s,a]);return{tokens:a,loading:i,loadError:c,selectedTokenName:u}},fm={workspacePath:"",githubUrl:"",tokenMode:"stored",selectedGithubToken:"",newGithubToken:""};function bm({onClose:t,onProjectCreated:s}){const{t:r}=ce(),[a,o]=n.useState(1),[i,l]=n.useState(fm),[c,m]=n.useState(!1),[d,u]=n.useState(null),[x,h]=n.useState(""),p=a===1&&so(i.githubUrl),f=n.useCallback(I=>{l(j=>({...j,selectedGithubToken:I}))},[]),{tokens:b,loading:g,loadError:v,selectedTokenName:S}=gm({shouldLoad:p,selectedTokenId:i.selectedGithubToken,onAutoSelectToken:f}),k=n.useCallback((I,j)=>{l($=>({...$,[I]:j}))},[]),y=n.useCallback(I=>k("tokenMode",I),[k]),P=n.useCallback(()=>{if(u(null),a===1){if(!i.workspacePath.trim()){u(r("projectWizard.errors.providePath"));return}o(2)}},[i.workspacePath,a,r]),E=n.useCallback(()=>{u(null),o(I=>I>1?I-1:I)},[]),C=n.useCallback(async()=>{m(!0),u(null),h("");try{if(Ia(i.githubUrl)){const $=await cm({workspacePath:i.workspacePath,githubUrl:i.githubUrl,tokenMode:i.tokenMode,selectedGithubToken:i.selectedGithubToken,newGithubToken:i.newGithubToken},{onProgress:h});s?.($),t();return}const j=await im({path:i.workspacePath.trim()});s?.(j),t()}catch(I){const j=I instanceof Error?I.message:r("projectWizard.errors.failedToCreate");u(j)}finally{m(!1)}},[i,t,s,r]),T=n.useMemo(()=>Ia(i.githubUrl),[i.githubUrl]);return e.jsx("div",{className:"fixed bottom-0 left-0 right-0 top-0 z-[60] flex items-center justify-center bg-black/50 p-0 backdrop-blur-sm sm:p-4",children:e.jsxs("div",{className:"h-full w-full overflow-y-auto rounded-none border-0 border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-800 sm:h-auto sm:max-w-2xl sm:rounded-lg sm:border",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-6 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-blue-100 dark:bg-blue-900/50",children:e.jsx(xr,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("projectWizard.title")})]}),e.jsx("button",{onClick:t,className:"rounded-md p-2 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",disabled:c,children:e.jsx(ge,{className:"h-5 w-5"})})]}),e.jsx(hm,{step:a}),e.jsxs("div",{className:"min-h-[300px] space-y-6 p-6",children:[d&&e.jsx(Yu,{message:d}),a===1&&e.jsx(mm,{workspacePath:i.workspacePath,githubUrl:i.githubUrl,tokenMode:i.tokenMode,selectedGithubToken:i.selectedGithubToken,newGithubToken:i.newGithubToken,availableTokens:b,loadingTokens:g,tokenLoadError:v,isCreating:c,onWorkspacePathChange:I=>k("workspacePath",I),onGithubUrlChange:I=>k("githubUrl",I),onTokenModeChange:y,onSelectedGithubTokenChange:I=>k("selectedGithubToken",I),onNewGithubTokenChange:I=>k("newGithubToken",I),onAdvanceToConfirm:()=>o(2)}),a===2&&e.jsx(pm,{formState:i,selectedTokenName:S,isCreating:c,cloneProgress:x})]}),e.jsx(xm,{step:a,isCreating:c,isCloneWorkflow:T,onClose:t,onBack:E,onNext:P,onCreate:C})]})})}const ym=Wu;function vm(t){return e.jsx(ym,{...t})}function jm({projects:t,showSettings:s,settingsInitialTab:r,onCloseSettings:a,showNewProject:o,onCloseNewProject:i,onProjectCreated:l,deleteConfirmation:c,onCancelDeleteProject:m,onConfirmDeleteProject:d,sessionDeleteConfirmation:u,onCancelDeleteSession:x,onConfirmDeleteSession:h,showVersionModal:p,onCloseVersionModal:f,releaseInfo:b,currentVersion:g,latestVersion:v,installMode:S,t:k}){const y=n.useMemo(()=>t.map(Fi),[t]);return e.jsxs(e.Fragment,{children:[o&&qt.createPortal(e.jsx(bm,{onClose:i,onProjectCreated:l}),document.body),s&&qt.createPortal(e.jsx(vm,{isOpen:s,onClose:a,projects:y,initialTab:r}),document.body),c&&qt.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-md overflow-hidden rounded-xl border border-border bg-card shadow-2xl",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-orange-100 dark:bg-orange-900/30",children:e.jsx(Oe,{className:"h-6 w-6 text-orange-600 dark:text-orange-400"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"mb-2 text-lg font-semibold text-foreground",children:k("deleteConfirmation.deleteProject")}),e.jsxs("p",{className:"mb-1 text-sm text-muted-foreground",children:[k("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:c.project.displayName||c.project.projectId}),"?"]}),c.sessionCount>0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:k("deleteConfirmation.sessionCount",{count:c.sessionCount})})]})]})}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-border bg-muted/30 p-4",children:[e.jsxs(W,{variant:"outline",className:"w-full justify-start",onClick:()=>d(!1),children:[e.jsx(us,{className:"mr-2 h-4 w-4"}),k("deleteConfirmation.archiveProject","Archive project")]}),e.jsxs(W,{variant:"destructive",className:"w-full justify-start bg-red-600 text-white hover:bg-red-700",onClick:()=>d(!0),children:[e.jsx(Te,{className:"mr-2 h-4 w-4"}),k("deleteConfirmation.deleteAllData")]}),e.jsx(W,{variant:"ghost",className:"w-full",onClick:m,children:k("actions.cancel")})]})]})}),document.body),u&&qt.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-md overflow-hidden rounded-xl border border-border bg-card shadow-2xl",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30",children:e.jsx(Oe,{className:"h-6 w-6 text-red-600 dark:text-red-400"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"mb-2 text-lg font-semibold text-foreground",children:k("deleteConfirmation.deleteSession")}),e.jsxs("p",{className:"mb-1 text-sm text-muted-foreground",children:[k("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:u.sessionTitle||k("sessions.unnamed")}),"?"]}),e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:u.isArchived?k("deleteConfirmation.archivedSessionNotice","This session is already archived. You can keep it hidden or delete it permanently."):k("deleteConfirmation.archiveSessionNotice","Archive keeps the session out of the active list while preserving its history.")})]})]})}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-border bg-muted/30 p-4",children:[!u.isArchived&&e.jsxs(W,{variant:"outline",className:"w-full justify-start",onClick:()=>h(!1),children:[e.jsx(us,{className:"mr-2 h-4 w-4"}),k("deleteConfirmation.archiveSession","Archive session")]}),e.jsxs(W,{variant:"destructive",className:"w-full justify-start bg-red-600 text-white hover:bg-red-700",onClick:()=>h(!0),children:[e.jsx(Te,{className:"mr-2 h-4 w-4"}),k("deleteConfirmation.deleteSessionPermanently","Delete permanently")]}),e.jsx(W,{variant:"ghost",className:"w-full",onClick:x,children:k("actions.cancel")})]})]})}),document.body),e.jsx(Ju,{isOpen:p,onClose:f,releaseInfo:b,currentVersion:g,latestVersion:v,installMode:S})]})}function Dm({projects:t,selectedProject:s,selectedSession:r,activeSessions:a,attentionSessionIds:o,onProjectSelect:i,onSessionSelect:l,onNewSession:c,onSessionDelete:m,onLoadMoreSessions:d,onProjectDelete:u,isLoading:x,loadingProgress:h,onRefresh:p,onShowSettings:f,showSettings:b,settingsInitialTab:g,onCloseSettings:v,isMobile:S}){const{t:k}=ce(["sidebar","common"]),{isPWA:y}=yi({trackMobile:!1}),{updateAvailable:P,restartRequired:E,latestVersion:C,currentVersion:T,releaseInfo:I,installMode:j}=sn("siteboon","claudecodeui"),{preferences:$,setPreference:G}=rn(),{sidebarVisible:K}=$,{mcpServerStatus:M}=zi(),{tasksEnabled:X}=Za(),H=an(),{isSidebarCollapsed:B,expandedProjects:w,editingProject:D,showNewProject:L,editingName:O,initialSessionsLoaded:U,currentTime:N,isRefreshing:A,editingSession:ee,editingSessionName:V,searchFilter:ae,searchMode:de,setSearchMode:te,conversationResults:q,isSearching:ye,searchProgress:se,clearConversationResults:ne,runningSessionsCount:re,deletingProjects:Ie,deleteConfirmation:Ss,sessionDeleteConfirmation:Re,showVersionModal:De,filteredProjects:Cs,archivedProjects:tt,archivedSessions:Ps,archivedSessionsCount:Es,isArchivedSessionsLoading:_t,recentConversations:vt,recentConversationsTotal:Ts,recentConversationsHasMore:Is,isRecentConversationsLoading:Rs,isLoadingMoreRecentConversations:jt,recentConversationsError:As,reloadRecentConversations:Ls,loadMoreRecentConversations:Ot,toggleProject:wt,handleSessionClick:qe,toggleStarProject:Ms,isProjectStarred:Dt,getProjectSessions:Se,loadingMoreProjects:Fs,loadMoreSessionsForProject:$e,startEditing:st,cancelEditing:_s,saveProjectName:$t,showDeleteSessionConfirmation:Ce,confirmDeleteSession:rt,requestProjectDelete:we,confirmDeleteProject:at,handleProjectSelect:Nt,openArchivedSession:zt,restoreArchivedProject:Os,restoreArchivedSession:nt,refreshProjects:Ds,updateSessionSummary:Ne,collapseSidebar:ze,expandSidebar:kt,setShowNewProject:Ut,setEditingName:$s,setEditingSession:Gt,setEditingSessionName:Ue,setSearchFilter:Vt,setDeleteConfirmation:zs,setSessionDeleteConfirmation:St,setShowVersionModal:Ct}=_i({projects:t,selectedProject:s,selectedSession:r,activeSessions:a,isLoading:x,isMobile:S,t:k,onRefresh:p,onProjectSelect:i,onSessionSelect:l,onSessionDelete:m,onLoadMoreSessions:d,onProjectDelete:u,setSidebarVisible:pe=>G("sidebarVisible",pe),sidebarVisible:K});n.useEffect(()=>{typeof document>"u"||(document.documentElement.classList.toggle("pwa-mode",y),document.body.classList.toggle("pwa-mode",y))},[y]);const Kt=()=>{H.refreshProjects()},ot={projects:t,filteredProjects:Cs,selectedProject:s,selectedSession:r,isLoading:x,loadingProgress:h,expandedProjects:w,editingProject:D,editingName:O,initialSessionsLoaded:U,currentTime:N,editingSession:ee,editingSessionName:V,deletingProjects:Ie,tasksEnabled:X,mcpServerStatus:M,getProjectSessions:Se,loadingMoreProjects:Fs,activeSessions:a,attentionSessionIds:o,forceExpanded:de==="running",isProjectStarred:Dt,onEditingNameChange:$s,onToggleProject:wt,onProjectSelect:Nt,onToggleStarProject:Ms,onStartEditingProject:st,onCancelEditingProject:_s,onSaveProjectName:pe=>{$t(pe)},onDeleteProject:we,onSessionSelect:qe,onDeleteSession:Ce,onLoadMoreSessions:$e,onNewSession:c,onEditingSessionNameChange:Ue,onStartEditingSession:(pe,Ge)=>{Gt(pe),Ue(Ge)},onCancelEditingSession:()=>{Gt(null),Ue("")},onSaveEditingSession:(pe,Ge,Pt,Et)=>{Ne(pe,Ge,Pt,Et)},t:k};return e.jsxs(e.Fragment,{children:[e.jsx(jm,{projects:t,showSettings:b,settingsInitialTab:g,onCloseSettings:v,showNewProject:L,onCloseNewProject:()=>Ut(!1),onProjectCreated:Kt,deleteConfirmation:Ss,onCancelDeleteProject:()=>zs(null),onConfirmDeleteProject:at,sessionDeleteConfirmation:Re,onCancelDeleteSession:()=>St(null),onConfirmDeleteSession:rt,showVersionModal:De,onCloseVersionModal:()=>Ct(!1),releaseInfo:I,currentVersion:T,latestVersion:C,installMode:j,t:k}),B?e.jsx(Ui,{onExpand:kt,onShowSettings:f,updateAvailable:P,restartRequired:E,onShowVersionModal:()=>Ct(!0),t:k}):e.jsx(e.Fragment,{children:e.jsx($c,{isPWA:y,isMobile:S,isLoading:x,projects:t,runningSessionsCount:re,archivedProjects:tt,archivedSessions:Ps,archivedSessionsCount:Es,isArchivedSessionsLoading:_t,recentConversations:vt,recentConversationsTotal:Ts,recentConversationsHasMore:Is,isRecentConversationsLoading:Rs,isLoadingMoreRecentConversations:jt,recentConversationsError:As,searchFilter:ae,onSearchFilterChange:Vt,onClearSearchFilter:()=>Vt(""),searchMode:de,onSearchModeChange:pe=>{te(pe),pe==="projects"&&ne()},conversationResults:q,isSearching:ye,searchProgress:se,onRestoreArchivedProject:Os,onLoadMoreRecentConversations:Ot,onRetryRecentConversations:Ls,onArchivedSessionClick:zt,onRestoreArchivedSession:nt,onDeleteArchivedSession:pe=>{Ce(pe.projectId,pe.sessionId,pe.sessionTitle,pe.provider,{isArchived:!0})},onConversationResultClick:(pe,Ge,Pt,Et,Us)=>{const Gs=Pt||"claude",Qe=pe?t.find(Ht=>Ht.projectId===pe):null,Bt={__searchTargetTimestamp:Et||null,__searchTargetSnippet:Us||null},Wt={id:Ge,__provider:Gs,__projectId:pe??void 0,...Bt};if(Qe){Nt(Qe);const Jt=Se(Qe).find(Tt=>Tt.id===Ge);qe(Jt?{...Jt,...Bt}:Wt,Qe.projectId)}else qe(Wt,pe??"")},onRefresh:()=>{Ds()},isRefreshing:A,onCreateProject:()=>Ut(!0),onCollapseSidebar:ze,updateAvailable:P,restartRequired:E,releaseInfo:I,latestVersion:C,currentVersion:T,onShowVersionModal:()=>Ct(!0),onShowSettings:f,projectListProps:ot,t:k})})]})}function Ra(t,s,r){return{theme:t?"dark":"light",project:s?{name:s.projectId,path:s.fullPath||s.path||""}:null,session:r?{id:r.id,title:r.title||r.name||r.id}:null}}function wm({pluginName:t,selectedProject:s,selectedSession:r}){const a=n.useRef(null),{isDarkMode:o}=br(),{plugins:i}=tn(),l=n.useRef(Ra(o,s,r)),c=n.useRef(new Set),m=n.useRef(null),d=i.find(u=>u.name===t);return n.useEffect(()=>{const u=Ra(o,s,r);l.current=u;for(const x of c.current)try{x(u)}catch{}},[o,s,r]),n.useEffect(()=>{if(!a.current||!d?.enabled)return;let u=!0;const x=a.current,h=d?.entry??"index.js",p=c.current;return(async()=>{try{const f=`/api/plugins/${encodeURIComponent(t)}/assets/${encodeURIComponent(h)}`,b=await z(f);if(!b.ok)throw new Error(`Failed to fetch plugin (HTTP ${b.status})`);const g=await b.text(),v=new Blob([g],{type:"application/javascript"}),S=URL.createObjectURL(v),k=await import(S).finally(()=>URL.revokeObjectURL(S));if(!u||!a.current)return;m.current=k;const y={get context(){return l.current},onContextChange(P){return p.add(P),()=>p.delete(P)},async rpc(P,E,C){const T=String(E).replace(/^\//,""),I=await z(`/api/plugins/${encodeURIComponent(t)}/rpc/${T}`,{method:P||"GET",...C!==void 0?{body:JSON.stringify(C)}:{}});if(!I.ok)throw new Error(`RPC error ${I.status}`);return I.json()}};if(await k.mount?.(x,y),!u){try{k.unmount?.(x)}catch{}m.current=null;return}}catch(f){if(!u)return;if(console.error(`[Plugin:${t}] Failed to load:`,f),a.current){const b=document.createElement("div");b.style.cssText="padding:16px;font-size:13px;color:#dc2626",b.textContent=`Plugin failed to load: ${String(f)}`,a.current.replaceChildren(b)}}})(),()=>{u=!1;try{m.current?.unmount?.(x)}catch{}p.clear(),m.current=null}},[t,d?.entry,d?.enabled]),e.jsx("div",{ref:a,className:"h-full w-full overflow-auto"})}const $m=Object.freeze(Object.defineProperty({__proto__:null,default:wm},Symbol.toStringTag,{value:"Module"}));export{nc as $,Sr as A,W as B,Tn as C,Mn as D,Dl as E,$l as F,zl as G,Ul as H,me as I,Gl as J,Vl as K,_e as L,Cl as M,Pl as N,El as O,ic as P,cc as Q,Ql as R,_n as S,Tl as T,Il as U,eu as V,tc as W,sc as X,rc as Y,ac as Z,oi as _,z as a,oc as a0,lc as a1,Za as a2,gi as a3,He as a4,vr as a5,he as a6,Wa as a7,yr as a8,Fn as a9,ri as aa,ui as ab,Qa as ac,qa as ad,tn as ae,$n as af,zn as ag,fu as ah,wc as ai,rn as aj,Mm as ak,Om as al,Bl as am,Hd as an,yi as ao,Lm as ap,Fm as aq,Dm as ar,ba as as,Em as at,Tm as au,Rm as av,Am as aw,Im as ax,$m as ay,uu as b,ue as c,In as d,Rn as e,F as f,Cr as g,an as h,dc as i,uc as j,mc as k,Rl as l,Al as m,Ll as n,Fl as o,du as p,_l as q,Zn as r,Zl as s,Xl as t,br as u,_m as v,zi as w,Pe as x,Wl as y,kr as z};