zen-code 4.8.5 → 4.9.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 (423) hide show
  1. package/dist/app.js +156 -163
  2. package/dist/{chunk-pbe0n109.js → chunk-02vv5584.js} +1 -1
  3. package/dist/{chunk-k8ygzjvv.js → chunk-13nyfrmm.js} +1 -1
  4. package/dist/chunk-1edvf7b5.js +1 -0
  5. package/dist/chunk-1rmnbdef.js +1 -0
  6. package/dist/{chunk-dv9rvc0a.js → chunk-1ttywx0y.js} +1 -1
  7. package/dist/{chunk-pp1gnpdp.js → chunk-1y82m5kn.js} +4 -4
  8. package/dist/{chunk-v5mgjgc4.js → chunk-30sq2w0d.js} +5 -5
  9. package/dist/chunk-32ase1cw.js +2 -0
  10. package/dist/chunk-3490ntd8.js +1 -0
  11. package/dist/{chunk-8cbtae81.js → chunk-3pcybja5.js} +1 -1
  12. package/dist/{chunk-rayth86k.js → chunk-4nsg4vcd.js} +1 -1
  13. package/dist/{chunk-j7f3n1aj.js → chunk-5rr85f28.js} +1 -1
  14. package/dist/{chunk-xf4jswm4.js → chunk-5x8nxw0t.js} +1 -1
  15. package/dist/chunk-6rfc36jg.js +1 -0
  16. package/dist/{chunk-jfecjzq0.js → chunk-76h8pe7x.js} +2 -2
  17. package/dist/{chunk-ya599ak5.js → chunk-7kdvr78m.js} +2 -2
  18. package/dist/{chunk-a36ttbrq.js → chunk-8g2zdcy0.js} +2 -2
  19. package/dist/chunk-8z38ybz7.js +1 -0
  20. package/dist/{chunk-cpvvtyt1.js → chunk-98f6hg43.js} +2 -2
  21. package/dist/chunk-9dahn9h7.js +3 -0
  22. package/dist/chunk-9k5d9vf1.js +1 -0
  23. package/dist/{chunk-7en8vahs.js → chunk-b52b0t16.js} +1 -1
  24. package/dist/chunk-b8dxq9rq.js +1 -0
  25. package/dist/{chunk-3j3wmx6g.js → chunk-cggjws6a.js} +1 -1
  26. package/dist/chunk-cjqarwdn.js +1 -0
  27. package/dist/chunk-cs73xbzz.js +1 -0
  28. package/dist/{chunk-crrspdy9.js → chunk-cyexd09c.js} +2 -2
  29. package/dist/{chunk-a51szmhp.js → chunk-ep2es95e.js} +1 -1
  30. package/dist/chunk-f8ewggk1.js +1 -0
  31. package/dist/{chunk-gs9s59d4.js → chunk-g377vrpj.js} +3 -3
  32. package/dist/{chunk-hps6tv25.js → chunk-g7pm00z7.js} +2 -2
  33. package/dist/chunk-gcm4jp0d.js +26 -0
  34. package/dist/{chunk-mrapdjm5.js → chunk-heasksrr.js} +2 -2
  35. package/dist/chunk-hfve7nf5.js +2 -0
  36. package/dist/chunk-j7a40ww9.js +2 -0
  37. package/dist/chunk-j9aysaeb.js +1 -0
  38. package/dist/{chunk-6mcx89fj.js → chunk-jbf8ve63.js} +1 -1
  39. package/dist/{chunk-j3tfxj8n.js → chunk-jfhc5c0d.js} +1 -1
  40. package/dist/{chunk-ydkkycp3.js → chunk-jxsfzfac.js} +2 -2
  41. package/dist/{chunk-nr26055z.js → chunk-kba8akjs.js} +1 -1
  42. package/dist/chunk-m76ya904.js +1 -0
  43. package/dist/{chunk-45bkb77s.js → chunk-mjzeawnq.js} +2 -2
  44. package/dist/{chunk-558jjzha.js → chunk-mmq834zt.js} +1 -1
  45. package/dist/chunk-ns6tjjkq.js +1 -0
  46. package/dist/{chunk-zssv316b.js → chunk-nwy6n6b6.js} +87 -87
  47. package/dist/chunk-qd305hg1.js +1 -0
  48. package/dist/chunk-qez6ejd4.js +1 -0
  49. package/dist/{chunk-7wxg0yef.js → chunk-r2h3x9zv.js} +1 -1
  50. package/dist/{chunk-m0e2jefq.js → chunk-rncpxz1b.js} +2 -2
  51. package/dist/chunk-rz3b356n.js +1 -0
  52. package/dist/{chunk-k4ftjnx7.js → chunk-trjpzw1n.js} +1 -1
  53. package/dist/{chunk-7khrhe0x.js → chunk-va71tsw3.js} +3 -3
  54. package/dist/{chunk-eemwtwb1.js → chunk-wn43r152.js} +1 -1
  55. package/dist/{chunk-hbhwzk5x.js → chunk-xhnvpygg.js} +1 -1
  56. package/dist/chunk-xkz5z0zn.js +1 -0
  57. package/dist/chunk-zwxjkwqd.js +26 -0
  58. package/dist/chunk-zz32kgt2.js +1 -0
  59. package/dist/cli.js +1 -1
  60. package/dist/nonInteractive.js +3 -3
  61. package/dist/zen-keyboard.js +1 -1
  62. package/package.json +4 -4
  63. package/dist/chunk-06dj0dnz.js +0 -1
  64. package/dist/chunk-0cbmnyee.js +0 -1
  65. package/dist/chunk-0cknr23d.js +0 -1
  66. package/dist/chunk-0jtrg9s1.js +0 -1
  67. package/dist/chunk-0k9tc7ys.js +0 -1
  68. package/dist/chunk-0kan91hr.js +0 -1
  69. package/dist/chunk-0kvk3r1g.js +0 -1
  70. package/dist/chunk-0teh8cbt.js +0 -2
  71. package/dist/chunk-0x0r76m6.js +0 -1
  72. package/dist/chunk-11ctp51v.js +0 -2
  73. package/dist/chunk-154dd94d.js +0 -2
  74. package/dist/chunk-17g5e3tb.js +0 -1
  75. package/dist/chunk-1b02dwxw.js +0 -1
  76. package/dist/chunk-1ck3yagm.js +0 -1
  77. package/dist/chunk-1fmdjx58.js +0 -1
  78. package/dist/chunk-1m8bmdzc.js +0 -1
  79. package/dist/chunk-1tj3j2rd.js +0 -1
  80. package/dist/chunk-1xdz3wdt.js +0 -1
  81. package/dist/chunk-1xjj19pz.js +0 -1
  82. package/dist/chunk-1z3yy9vz.js +0 -1
  83. package/dist/chunk-1zbnmy0p.js +0 -1
  84. package/dist/chunk-21gm4tm7.js +0 -1
  85. package/dist/chunk-2215g4qb.js +0 -2
  86. package/dist/chunk-250846sw.js +0 -1
  87. package/dist/chunk-2a6kan82.js +0 -1
  88. package/dist/chunk-2cfemb9q.js +0 -1
  89. package/dist/chunk-2evyqqz7.js +0 -2
  90. package/dist/chunk-2f9mf6mw.js +0 -2
  91. package/dist/chunk-2mrbrsta.js +0 -1
  92. package/dist/chunk-2tg0fzzw.js +0 -2
  93. package/dist/chunk-2yk5xgha.js +0 -1
  94. package/dist/chunk-2z60cf4h.js +0 -1
  95. package/dist/chunk-2zqq58q6.js +0 -2
  96. package/dist/chunk-3009w43m.js +0 -1
  97. package/dist/chunk-3acyh64g.js +0 -25
  98. package/dist/chunk-3b8scss4.js +0 -1
  99. package/dist/chunk-3d8rzv4d.js +0 -1
  100. package/dist/chunk-3emyjvqg.js +0 -1
  101. package/dist/chunk-3fp2k4jh.js +0 -26
  102. package/dist/chunk-3rew4tyk.js +0 -1
  103. package/dist/chunk-3s3b7nzy.js +0 -1
  104. package/dist/chunk-3w98g1h4.js +0 -1
  105. package/dist/chunk-3x564va6.js +0 -2
  106. package/dist/chunk-4agrg21g.js +0 -1
  107. package/dist/chunk-4asb3qnd.js +0 -1
  108. package/dist/chunk-4k15drqf.js +0 -1
  109. package/dist/chunk-4vhwsrc0.js +0 -1
  110. package/dist/chunk-4yddzp8e.js +0 -1
  111. package/dist/chunk-53agfxhn.js +0 -1
  112. package/dist/chunk-54kyvbh7.js +0 -1
  113. package/dist/chunk-56q8b04m.js +0 -1
  114. package/dist/chunk-59vj8mx3.js +0 -1
  115. package/dist/chunk-5bvkhjg1.js +0 -1
  116. package/dist/chunk-5m8gh94n.js +0 -1
  117. package/dist/chunk-5n57csbz.js +0 -1
  118. package/dist/chunk-5n6g25gc.js +0 -1
  119. package/dist/chunk-5rmyjm7a.js +0 -1
  120. package/dist/chunk-5wkah698.js +0 -1
  121. package/dist/chunk-6180vb4q.js +0 -2
  122. package/dist/chunk-63ncy5kr.js +0 -1
  123. package/dist/chunk-66sfgeag.js +0 -1
  124. package/dist/chunk-6ag9x0z1.js +0 -1
  125. package/dist/chunk-6bhkrdb2.js +0 -1
  126. package/dist/chunk-6cs4tf5a.js +0 -1
  127. package/dist/chunk-6czm9v10.js +0 -1
  128. package/dist/chunk-6dm27qn5.js +0 -1
  129. package/dist/chunk-6eyx9kb0.js +0 -1
  130. package/dist/chunk-6fsb1bxc.js +0 -1
  131. package/dist/chunk-6qbdcv3t.js +0 -1
  132. package/dist/chunk-6qyeer8n.js +0 -1
  133. package/dist/chunk-6r5npryc.js +0 -1
  134. package/dist/chunk-6rhb6xym.js +0 -1
  135. package/dist/chunk-6vhg46d2.js +0 -1
  136. package/dist/chunk-6yb36qx6.js +0 -1
  137. package/dist/chunk-72cdrnwv.js +0 -1
  138. package/dist/chunk-731nq1br.js +0 -1
  139. package/dist/chunk-748hk53z.js +0 -1
  140. package/dist/chunk-774cjjgt.js +0 -1
  141. package/dist/chunk-77chzpqs.js +0 -1
  142. package/dist/chunk-77qt7n70.js +0 -1
  143. package/dist/chunk-7cenjy4r.js +0 -2
  144. package/dist/chunk-7d4h6qkf.js +0 -1
  145. package/dist/chunk-7k80bxbe.js +0 -1
  146. package/dist/chunk-7khjf5c1.js +0 -1
  147. package/dist/chunk-7m0c57rj.js +0 -1
  148. package/dist/chunk-7n5b43s8.js +0 -1
  149. package/dist/chunk-7pwrx1pp.js +0 -1
  150. package/dist/chunk-7v4352jx.js +0 -1
  151. package/dist/chunk-7w75nxwb.js +0 -1
  152. package/dist/chunk-7wa89vcy.js +0 -1
  153. package/dist/chunk-7yf45m28.js +0 -1
  154. package/dist/chunk-7z7g35xf.js +0 -1
  155. package/dist/chunk-82xzyhyv.js +0 -1
  156. package/dist/chunk-87w9rexn.js +0 -1
  157. package/dist/chunk-8arg48f8.js +0 -1
  158. package/dist/chunk-8ee7jvcr.js +0 -1
  159. package/dist/chunk-8gm5e25z.js +0 -1
  160. package/dist/chunk-8jhmnz2v.js +0 -1
  161. package/dist/chunk-8qh81vdm.js +0 -1
  162. package/dist/chunk-8vr1wy0r.js +0 -1
  163. package/dist/chunk-917pj3vx.js +0 -1
  164. package/dist/chunk-91gd665t.js +0 -1
  165. package/dist/chunk-92pjraxh.js +0 -2
  166. package/dist/chunk-9ft87v6s.js +0 -2
  167. package/dist/chunk-9h0v5e0k.js +0 -2
  168. package/dist/chunk-9hnbyswz.js +0 -1
  169. package/dist/chunk-9hznfyjs.js +0 -1
  170. package/dist/chunk-9mjq1xxc.js +0 -1
  171. package/dist/chunk-9nb6v3q0.js +0 -2
  172. package/dist/chunk-9phx46cq.js +0 -2
  173. package/dist/chunk-9rmve4r4.js +0 -1
  174. package/dist/chunk-9xaygaay.js +0 -2
  175. package/dist/chunk-a4vdvjsr.js +0 -1
  176. package/dist/chunk-ae57mcvq.js +0 -1
  177. package/dist/chunk-aeajq5ft.js +0 -1
  178. package/dist/chunk-aekjcqbv.js +0 -1
  179. package/dist/chunk-ah557n6f.js +0 -1
  180. package/dist/chunk-am5r5ynh.js +0 -1
  181. package/dist/chunk-asdze5kz.js +0 -1
  182. package/dist/chunk-av215sh3.js +0 -1
  183. package/dist/chunk-b1czvr4n.js +0 -1
  184. package/dist/chunk-b3g51e2m.js +0 -1
  185. package/dist/chunk-b4qvb571.js +0 -1
  186. package/dist/chunk-bba2g9qj.js +0 -1
  187. package/dist/chunk-be8bz8xh.js +0 -1
  188. package/dist/chunk-bh05aqrf.js +0 -2
  189. package/dist/chunk-bjctrgpr.js +0 -1
  190. package/dist/chunk-bjqn0pzz.js +0 -1
  191. package/dist/chunk-bnrv5f66.js +0 -2
  192. package/dist/chunk-bqzvv2dy.js +0 -1
  193. package/dist/chunk-bs9fj12n.js +0 -1
  194. package/dist/chunk-bwcdkk1e.js +0 -2
  195. package/dist/chunk-bz79zq7h.js +0 -1
  196. package/dist/chunk-bzanqq7a.js +0 -1
  197. package/dist/chunk-cayjw3gk.js +0 -1
  198. package/dist/chunk-ceb97hw6.js +0 -1
  199. package/dist/chunk-ctet86gc.js +0 -1
  200. package/dist/chunk-ctp90f8y.js +0 -1
  201. package/dist/chunk-cv5akzkw.js +0 -1
  202. package/dist/chunk-d9hpz80s.js +0 -2
  203. package/dist/chunk-denz6x2z.js +0 -1
  204. package/dist/chunk-dnpybaez.js +0 -1
  205. package/dist/chunk-dp2418kp.js +0 -1
  206. package/dist/chunk-dpa9tgf6.js +0 -2
  207. package/dist/chunk-dxg8cctv.js +0 -2
  208. package/dist/chunk-dz0229fs.js +0 -1
  209. package/dist/chunk-e8pjcdmj.js +0 -1
  210. package/dist/chunk-edkft0pe.js +0 -1
  211. package/dist/chunk-ejh8spnd.js +0 -1
  212. package/dist/chunk-emjqnzzj.js +0 -1
  213. package/dist/chunk-er06b5kx.js +0 -2
  214. package/dist/chunk-esskh0ge.js +0 -1
  215. package/dist/chunk-ewx6fr7a.js +0 -1
  216. package/dist/chunk-ewxacd5v.js +0 -1
  217. package/dist/chunk-ez2xn1tq.js +0 -1
  218. package/dist/chunk-ezh4rq18.js +0 -1
  219. package/dist/chunk-f1gz54zs.js +0 -1
  220. package/dist/chunk-f2p8rps5.js +0 -1
  221. package/dist/chunk-f3mf8qk2.js +0 -1
  222. package/dist/chunk-f51sey9j.js +0 -1
  223. package/dist/chunk-f8c6jyrc.js +0 -1
  224. package/dist/chunk-fb70a9sy.js +0 -1
  225. package/dist/chunk-fd4dk58v.js +0 -1
  226. package/dist/chunk-fdhzjb42.js +0 -1
  227. package/dist/chunk-fftvnc8t.js +0 -1
  228. package/dist/chunk-ffzytaw1.js +0 -1
  229. package/dist/chunk-fm3k6prw.js +0 -1
  230. package/dist/chunk-fs5s90mk.js +0 -1
  231. package/dist/chunk-fvhtfw18.js +0 -1
  232. package/dist/chunk-g3p0vcay.js +0 -2
  233. package/dist/chunk-gaw2bhff.js +0 -1
  234. package/dist/chunk-gbrg4c7y.js +0 -1
  235. package/dist/chunk-gkhxerej.js +0 -1
  236. package/dist/chunk-gps0pyf7.js +0 -1
  237. package/dist/chunk-gsnrqmzp.js +0 -1
  238. package/dist/chunk-gvjvbwk6.js +0 -1
  239. package/dist/chunk-gxc7a8cz.js +0 -1
  240. package/dist/chunk-h06hyckd.js +0 -1
  241. package/dist/chunk-h0b5na4r.js +0 -1
  242. package/dist/chunk-h1bjeyn7.js +0 -1
  243. package/dist/chunk-h5y1vfrx.js +0 -1
  244. package/dist/chunk-hgkaxnh7.js +0 -1
  245. package/dist/chunk-hgs9vzm2.js +0 -1
  246. package/dist/chunk-hjs9ffqg.js +0 -1
  247. package/dist/chunk-hmtm22t7.js +0 -1
  248. package/dist/chunk-hraqhe5e.js +0 -1
  249. package/dist/chunk-hsq3vxna.js +0 -2
  250. package/dist/chunk-htns6qnb.js +0 -1
  251. package/dist/chunk-hv4arqm5.js +0 -1
  252. package/dist/chunk-hzqb4sy6.js +0 -1
  253. package/dist/chunk-j0szwqey.js +0 -1
  254. package/dist/chunk-j6s60n91.js +0 -1
  255. package/dist/chunk-j9za9ext.js +0 -1
  256. package/dist/chunk-ja5m6q40.js +0 -1
  257. package/dist/chunk-jdvv96q7.js +0 -1
  258. package/dist/chunk-jsqwhbbt.js +0 -1
  259. package/dist/chunk-jyrs3ysr.js +0 -1
  260. package/dist/chunk-jz8tmenz.js +0 -1
  261. package/dist/chunk-k17n7dpm.js +0 -1
  262. package/dist/chunk-k1yv7tpj.js +0 -1
  263. package/dist/chunk-k626mmdc.js +0 -1
  264. package/dist/chunk-ka0pqrag.js +0 -1
  265. package/dist/chunk-kbgd9vsz.js +0 -1
  266. package/dist/chunk-kc6rwv2m.js +0 -1
  267. package/dist/chunk-kc8375a8.js +0 -1
  268. package/dist/chunk-kgj1ssyj.js +0 -1
  269. package/dist/chunk-kk4w0prd.js +0 -1
  270. package/dist/chunk-kkks4cbp.js +0 -1
  271. package/dist/chunk-kq7y5ybe.js +0 -1
  272. package/dist/chunk-kqemj8nq.js +0 -1
  273. package/dist/chunk-kr6cv1mp.js +0 -1
  274. package/dist/chunk-kvb035wf.js +0 -2
  275. package/dist/chunk-kx3dsqc5.js +0 -1
  276. package/dist/chunk-kys8sc0j.js +0 -1
  277. package/dist/chunk-m0vtra47.js +0 -1
  278. package/dist/chunk-m9xdbw2j.js +0 -1
  279. package/dist/chunk-mft6e1b3.js +0 -1
  280. package/dist/chunk-mfyvxat8.js +0 -1
  281. package/dist/chunk-mjfe9s8t.js +0 -1
  282. package/dist/chunk-mns6edxc.js +0 -1
  283. package/dist/chunk-mp159559.js +0 -2
  284. package/dist/chunk-mrbn4knm.js +0 -1
  285. package/dist/chunk-ms3sqsez.js +0 -1
  286. package/dist/chunk-mtyqtnv0.js +0 -1
  287. package/dist/chunk-mvb82v3n.js +0 -1
  288. package/dist/chunk-n08dw2ke.js +0 -1
  289. package/dist/chunk-n0sxg10w.js +0 -1
  290. package/dist/chunk-n3xjke41.js +0 -1
  291. package/dist/chunk-n6v7menj.js +0 -1
  292. package/dist/chunk-n8apqh5d.js +0 -1
  293. package/dist/chunk-n8f65qbg.js +0 -1
  294. package/dist/chunk-n92ey5c2.js +0 -1
  295. package/dist/chunk-na5z94zg.js +0 -2
  296. package/dist/chunk-nbkkf36e.js +0 -1
  297. package/dist/chunk-ndk5mkc1.js +0 -1
  298. package/dist/chunk-nks89eba.js +0 -1
  299. package/dist/chunk-nrkhbe10.js +0 -1
  300. package/dist/chunk-nvnw7mcb.js +0 -1
  301. package/dist/chunk-nwx5cbjc.js +0 -1
  302. package/dist/chunk-ny61b4ve.js +0 -1
  303. package/dist/chunk-p7ha3t1f.js +0 -1
  304. package/dist/chunk-pc3w4gkp.js +0 -1
  305. package/dist/chunk-pcwsyc9b.js +0 -1
  306. package/dist/chunk-pj843s6s.js +0 -1
  307. package/dist/chunk-pm5gceg0.js +0 -1
  308. package/dist/chunk-pqq81gzv.js +0 -1
  309. package/dist/chunk-pt1m6xh9.js +0 -1
  310. package/dist/chunk-pvzfgkkq.js +0 -1
  311. package/dist/chunk-pz4hhw24.js +0 -1
  312. package/dist/chunk-pz5xskrk.js +0 -1
  313. package/dist/chunk-q0z3nkep.js +0 -1
  314. package/dist/chunk-q6m1k4fq.js +0 -1
  315. package/dist/chunk-q9w8vj93.js +0 -2
  316. package/dist/chunk-qd2hkayk.js +0 -1
  317. package/dist/chunk-qf60gd6x.js +0 -1
  318. package/dist/chunk-qpwtcr53.js +0 -1
  319. package/dist/chunk-qrr2ytkg.js +0 -2
  320. package/dist/chunk-qzy0w65x.js +0 -1
  321. package/dist/chunk-r5crgj5q.js +0 -1
  322. package/dist/chunk-r5psjv6v.js +0 -1
  323. package/dist/chunk-r9dm0gyn.js +0 -1
  324. package/dist/chunk-r9qyzgns.js +0 -1
  325. package/dist/chunk-raq8eqd9.js +0 -1
  326. package/dist/chunk-rbebjqfq.js +0 -1
  327. package/dist/chunk-rc81vkve.js +0 -1
  328. package/dist/chunk-rg8hdkt2.js +0 -1
  329. package/dist/chunk-rgc9k4rf.js +0 -2
  330. package/dist/chunk-rqvxk3e5.js +0 -2
  331. package/dist/chunk-rsb82wcd.js +0 -1
  332. package/dist/chunk-rt7af3wp.js +0 -1
  333. package/dist/chunk-rx707y69.js +0 -1
  334. package/dist/chunk-s22hm2jp.js +0 -1
  335. package/dist/chunk-s2wchktz.js +0 -1
  336. package/dist/chunk-s5yace4y.js +0 -1
  337. package/dist/chunk-sd65hz9x.js +0 -1
  338. package/dist/chunk-sdhd2kpk.js +0 -1
  339. package/dist/chunk-sepabvgd.js +0 -1
  340. package/dist/chunk-sk4n2anv.js +0 -1
  341. package/dist/chunk-sq9spyfd.js +0 -1
  342. package/dist/chunk-sv97fsr8.js +0 -1
  343. package/dist/chunk-sw6b067z.js +0 -1
  344. package/dist/chunk-sz3tq28n.js +0 -2
  345. package/dist/chunk-t07nqvz2.js +0 -1
  346. package/dist/chunk-t4vfr2g0.js +0 -1
  347. package/dist/chunk-t6x8a62a.js +0 -1
  348. package/dist/chunk-t8djp78p.js +0 -1
  349. package/dist/chunk-tj729ry3.js +0 -1
  350. package/dist/chunk-tjj6zd94.js +0 -2
  351. package/dist/chunk-tkp1zzgb.js +0 -1
  352. package/dist/chunk-tq142qfa.js +0 -1
  353. package/dist/chunk-tq7jpqr7.js +0 -1
  354. package/dist/chunk-tqh0rjpp.js +0 -1
  355. package/dist/chunk-tx117rah.js +0 -1
  356. package/dist/chunk-v3t7hcht.js +0 -1
  357. package/dist/chunk-v9qb0fer.js +0 -1
  358. package/dist/chunk-vcsqkf9c.js +0 -1
  359. package/dist/chunk-vd8byz1r.js +0 -2
  360. package/dist/chunk-vg853h8j.js +0 -1
  361. package/dist/chunk-vgeyt962.js +0 -1
  362. package/dist/chunk-vkfgx6sa.js +0 -2
  363. package/dist/chunk-vqpam6p8.js +0 -1
  364. package/dist/chunk-vrv07424.js +0 -1
  365. package/dist/chunk-vsydmxfh.js +0 -1
  366. package/dist/chunk-vtxyeepe.js +0 -2
  367. package/dist/chunk-vwhxfs9r.js +0 -1
  368. package/dist/chunk-vy4ecvry.js +0 -1
  369. package/dist/chunk-w46ermgd.js +0 -1
  370. package/dist/chunk-w5qvj179.js +0 -1
  371. package/dist/chunk-w93s735t.js +0 -1
  372. package/dist/chunk-wb08g5z8.js +0 -1
  373. package/dist/chunk-wb43p5km.js +0 -1
  374. package/dist/chunk-wb6xn1kx.js +0 -1
  375. package/dist/chunk-wbg38h5j.js +0 -1
  376. package/dist/chunk-wcyrmfpn.js +0 -1
  377. package/dist/chunk-wd17hcv5.js +0 -1
  378. package/dist/chunk-wdm62dbr.js +0 -1
  379. package/dist/chunk-we3jwpsb.js +0 -2
  380. package/dist/chunk-wgamcpyt.js +0 -1
  381. package/dist/chunk-whdmep96.js +0 -1
  382. package/dist/chunk-wkc7w10f.js +0 -1
  383. package/dist/chunk-wkf1j21b.js +0 -1
  384. package/dist/chunk-wm3z6khn.js +0 -1
  385. package/dist/chunk-wqvqvv9e.js +0 -1
  386. package/dist/chunk-wvmnb75v.js +0 -1
  387. package/dist/chunk-wy3eznsy.js +0 -2
  388. package/dist/chunk-wznpd7sd.js +0 -1
  389. package/dist/chunk-x01t9e3q.js +0 -1
  390. package/dist/chunk-x8z2fzz8.js +0 -1
  391. package/dist/chunk-xa4apmpd.js +0 -1
  392. package/dist/chunk-xcea0hn5.js +0 -2
  393. package/dist/chunk-xf7ypd1b.js +0 -1
  394. package/dist/chunk-xhjrdhgk.js +0 -1
  395. package/dist/chunk-xjgnj3p0.js +0 -1
  396. package/dist/chunk-xjwkmvfz.js +0 -1
  397. package/dist/chunk-xkc2ktrh.js +0 -1
  398. package/dist/chunk-xm9015v4.js +0 -1
  399. package/dist/chunk-xnx0j1hw.js +0 -1
  400. package/dist/chunk-y0e2ymas.js +0 -1
  401. package/dist/chunk-y3c3xgca.js +0 -1
  402. package/dist/chunk-y6mvs6yw.js +0 -1
  403. package/dist/chunk-y6z502pz.js +0 -1
  404. package/dist/chunk-ycthcn27.js +0 -1
  405. package/dist/chunk-ydc7pd3b.js +0 -1
  406. package/dist/chunk-yhxvqyz4.js +0 -1
  407. package/dist/chunk-ymmavdfp.js +0 -2
  408. package/dist/chunk-ynnaxz2z.js +0 -1
  409. package/dist/chunk-ywa5z7d9.js +0 -1
  410. package/dist/chunk-ywbbf9eh.js +0 -1
  411. package/dist/chunk-yzk3bfzn.js +0 -1
  412. package/dist/chunk-z0wdan61.js +0 -1
  413. package/dist/chunk-z5z774pp.js +0 -1
  414. package/dist/chunk-z88rcc8t.js +0 -1
  415. package/dist/chunk-zag96nyc.js +0 -2
  416. package/dist/chunk-zh77yp9z.js +0 -1
  417. package/dist/chunk-zjemnf8v.js +0 -1
  418. package/dist/chunk-zmsq5xc7.js +0 -1
  419. package/dist/chunk-zqxrtejz.js +0 -1
  420. package/dist/chunk-zt78xjtr.js +0 -2
  421. package/dist/chunk-zv9ac3c0.js +0 -2
  422. package/dist/chunk-zx19re81.js +0 -2
  423. package/dist/chunk-zytr7a4n.js +0 -1
package/dist/app.js CHANGED
@@ -1,52 +1,52 @@
1
- import{Y as _5,Z as A5}from"./chunk-rqvxk3e5.js";import{$ as V1,_ as r}from"./chunk-v5mgjgc4.js";import{aa as eY,ba as t,ca as ZZ,da as FZ,ea as PJ,fa as WZ,ga as b1}from"./chunk-45bkb77s.js";import{ha as a8,ia as Z5,ja as VJ,ka as c4,la as t0,ma as T1,na as z1,oa as uY,pa as xZ,qa as l0}from"./chunk-6czm9v10.js";import{ra as g8,sa as J8,ta as r8,va as U1,wa as Q1,xa as TZ}from"./chunk-m0e2jefq.js";import{ya as UZ,za as f1}from"./chunk-ymmavdfp.js";import{Aa as U8,Ba as RW,Da as z8,Ea as xY,Ga as gY}from"./chunk-7khrhe0x.js";import{Ia as d0,Ja as lY,Ka as cZ,Ma as dZ,Na as iY,Oa as F4}from"./chunk-154dd94d.js";import"./chunk-mrapdjm5.js";import"./chunk-ydkkycp3.js";import{Ya as N4,Za as U4}from"./chunk-pbe0n109.js";import{$a as _,_a as g,ab as O,bb as K8,cb as yY,eb as d8,fb as W4,gb as uZ,hb as I,ib as iZ,kb as u4,mb as D1,nb as BJ}from"./chunk-zssv316b.js";import{ub as R8}from"./chunk-hps6tv25.js";import{vb as J5}from"./chunk-pp1gnpdp.js";import{Ab as Y5,xb as G5,yb as W5,zb as $5}from"./chunk-xf4jswm4.js";import"./chunk-3fp2k4jh.js";import"./chunk-k8ygzjvv.js";import"./chunk-j7f3n1aj.js";import"./chunk-crrspdy9.js";import"./chunk-7wxg0yef.js";import"./chunk-dv9rvc0a.js";import"./chunk-3j3wmx6g.js";import{lc as P,nc as B7,oc as q$,pc as q}from"./chunk-nr26055z.js";class x8{renderers=new Map;register(Z,Y){this.renderers.set(Z,Y)}get(Z){return this.renderers.get(Z)}has(Z){return this.renderers.has(Z)}list(){return Array.from(this.renderers.keys())}unregister(Z){this.renderers.delete(Z)}clear(){this.renderers.clear()}}var D4;var n0=q$(()=>{D4=new x8});var G8=P(I(),1),j1=new U8({defaultOptions:{queries:{retry:(Z,Y)=>{if(Y instanceof TypeError&&Y.message.includes("fetch"))return Z<2;return!1},refetchOnWindowFocus:!1,refetchOnMount:!0,refetchOnReconnect:!1,staleTime:300000,gcTime:600000,networkMode:"online"},mutations:{retry:1,networkMode:"online"}}});function H8({children:Z}){return G8.jsxDEV(z8,{client:j1,children:Z},void 0,!1,void 0,this)}var O8={async search(Z){let Y=Object.entries(d0).map(([$,K])=>({assistant_id:$,graph_id:$,config:{},metadata:{},version:1,name:$,description:"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()}));if(Z?.graphId)Y=Y.filter(($)=>$.graph_id===Z.graphId);if(Z?.metadata&&Object.keys(Z.metadata).length>0)Y=Y.filter(($)=>{return Object.entries(Z.metadata).every(([K,U])=>{return $.metadata&&$.metadata[K]===U})});if(Z?.sortBy)Y.sort(($,K)=>{let U=$[Z.sortBy],W=K[Z.sortBy],z=U<W?-1:U>W?1:0;return Z.sortOrder==="desc"?-z:z});let X=Z?.offset??0,J=Z?.limit;return J?Y.slice(X,X+J):Y.slice(X)},async count(Z){return(await this.search(Z)).length},async get(Z){if(!Object.entries(d0).find(([X,J])=>X===Z))throw Error(`Assistant not found: ${Z}`);return{assistant_id:Z,graph_id:Z,config:{},created_at:new Date().toISOString(),updated_at:new Date().toISOString(),metadata:{},version:1,name:Z,description:""}},async delete(Z){throw Error("Deleting assistants is not supported. Assistants are generated from registered graphs.")},async update(Z,Y){throw Error("Updating assistants is not supported. Assistants are generated from registered graphs.")},async getGraph(Z,Y){let X={};return(await(await cZ(Z,X)).getGraphAsync({...X,xray:Y?.xray??void 0})).toJSON()},async getSchemas(Z){let X=(await cZ(Z,{})).builder;return console.log(X),{graph_id:Z,state_schema:X._inputDefinition,input_schema:X._inputDefinition,output_schema:X._outputDefinition,config_schema:X._configSchema,context_schema:X._configSchema}},async getVersions(Z,Y){let X=await this.get(Z),J=Y?.offset??0,Q=Y?.limit;return Q?[X].slice(J,J+Q):[X].slice(J)},async setLatest(Z,Y){let X=await this.get(Z);return X.version=Y,X},async create(Z){if(console.warn("⚠️ Creating assistants is not supported. Assistants are generated from registered graphs. Returning mock data."),!Object.keys(d0).includes(Z.graphId)){if(Z.ifExists==="raise")throw Error(`Graph not found: ${Z.graphId}`)}return{assistant_id:Z.assistantId||Z.graphId,graph_id:Z.graphId,name:Z.name||Z.graphId,description:Z.description||"",metadata:Z.metadata||{},config:Z.config||{},version:1,created_at:new Date().toISOString(),updated_at:new Date().toISOString()}}},cY=()=>{let Z=()=>{return dZ.globalThreadsManager};return{assistants:O8,get threads(){return dZ.globalThreadsManager},runs:{list(Y,X){return Z().listRuns(Y,X)},async cancel(Y,X,J,Q){return await dZ.globalMessageQueue.cancelQueue(X)},async*stream(Y,X,J){J.config={...J.config??{},configurable:{...J.config?.configurable??{},graph_id:X,thread_id:Y}};let Q=Z();for await(let $ of F4(Q,Q.createRun(Y,X,J),J,{attempt:0,getGraph:cZ}))yield $},async*joinStream(Y,X,J){let Q=J&&typeof J==="object"&&"signal"in J?J:{},$=(J instanceof AbortSignal?J:Q.signal)||new AbortController().signal,K=null,U=null;try{K=await dZ.globalMessageQueue.getQueue(X);let W=await K.getAll();for(let z of W){if($.aborted)return;if(yield{id:z.id,event:z.event,data:z.data},z.event==="__stream_end__"||z.event==="__stream_error__"||z.event==="__stream_cancel__")return}U=K.onDataReceive();for await(let z of U){if($.aborted)break;let{event:H,data:G}=z;if(yield{id:z.id,event:H,data:G},z.event==="__stream_end__"||z.event==="__stream_error__"||z.event==="__stream_cancel__")break}}catch(W){if(!(W instanceof Error)||!W.message.includes("does not exist"))console.warn("Join stream failed:",W)}finally{if(U)try{await U.return(void 0)}catch(W){}}}}}};import{entrypoint as p2,getPreviousState as d2,getConfig as c2,Command as l2}from"@langchain/langgraph";import{schemaMetaRegistry as r2}from"@langchain/langgraph/zod";import{z as QZ}from"zod";var x4=(Z,Y)=>Z.constructor.name===Y.name,BZ=new Map;BZ.set(QZ.ZodBoolean.name,()=>!1),BZ.set(QZ.ZodNumber.name,()=>0),BZ.set(QZ.ZodString.name,()=>""),BZ.set(QZ.ZodArray.name,()=>[]),BZ.set(QZ.ZodRecord.name,()=>({})),BZ.set(QZ.ZodDefault.name,(Z)=>Z.def.defaultValue),BZ.set(QZ.ZodPipe.name,(Z)=>N0(Z.def.in)),BZ.set(QZ.ZodOptional.name,(Z)=>x4(Z.def.innerType,QZ.ZodDefault)?Z.def.innerType.def.defaultValue:void 0),BZ.set(QZ.ZodTuple.name,(Z)=>{let Y=[];for(let X of Z.def.items)Y.push(N0(X));return Y}),BZ.set(QZ.ZodPipe.name,(Z)=>N0(Z.def.in)),BZ.set(QZ.ZodUnion.name,(Z)=>N0(Z.def.options[0])),BZ.set(QZ.ZodObject.name,(Z)=>g4(Z)),BZ.set(QZ.ZodRecord.name,(Z)=>g4(Z)),BZ.set(QZ.ZodIntersection.name,(Z)=>g4(Z));function N0(Z){let Y=Z.constructor.name;if(!BZ.has(Y)){console.warn("getSchemaDefaultForField: Unhandled type",Z.constructor.name);return}return BZ.get(Y)(Z)}function g4(Z){if(x4(Z,QZ.ZodRecord))return{};if(x4(Z,QZ.ZodPipe))return g4(Z.def.in);if(x4(Z,QZ.ZodIntersection))return{...g4(Z.def.left),...g4(Z.def.right)};if(x4(Z,QZ.ZodUnion)){for(let Y of Z.def.options)if(x4(Y,QZ.ZodObject))return g4(Y);return console.warn("getSchemaDefaultObject: No object found in union, returning empty object"),{}}return x4(Z,QZ.ZodObject)?Object.fromEntries(Object.entries(Z.shape).map(([Y,X])=>[Y,N0(X)]).filter((Y)=>Y[1]!==void 0)):(console.warn(`getSchemaDefaultObject: Expected object schema, got ${Z.constructor.name}`),{})}import{tool as a2,HumanMessage as s2}from"langchain";import{z as M4}from"zod";var e2=M4.object({task_store:M4.record(M4.string(),M4.any()).default({})}),ZU=M4.object({task_id:M4.string().optional().describe("The task id to ask the subagent, if not provided, will use the tool call id"),subagent_id:M4.string(),task_description:M4.string().describe("Describe the user state and what you want the subagent to do."),data_transfer:M4.any().optional().describe("Data to transfer to the subagent.")});import A from"zod";var x=cY(),S1=A.object({thread_id:A.string().optional(),thread_ts:A.string().optional()}).catchall(A.unknown()),Y0=A.object({tags:A.array(A.string()).optional(),recursion_limit:A.number().int().optional(),configurable:S1.optional()}).catchall(A.unknown()).describe("The configuration of an assistant.");A.object({assistant_id:A.string(),graph_id:A.string(),config:Y0,created_at:A.string(),updated_at:A.string(),metadata:A.object({}).catchall(A.any())});var K4=A.object({source:A.union([A.literal("input"),A.literal("loop"),A.literal("update"),A.string()]).optional(),step:A.number().optional(),writes:A.any().nullable().optional(),parents:A.any().optional()}).catchall(A.unknown()),q8=A.object({node:A.string(),input:A.unknown().optional()}),rY=A.object({update:A.union([A.any(),A.array(A.tuple([A.string(),A.any()]))]).nullable().optional(),resume:A.unknown().optional(),goto:A.union([q8,A.array(q8),A.string(),A.array(A.string())]).optional()});A.object({limit:A.number().int().optional(),offset:A.number().int().optional()});var DZ=A.object({thread_id:A.string()}),_0=A.object({thread_id:A.string(),run_id:A.string()}),y1=A.object({graph_id:A.string().optional(),metadata:K4.optional(),limit:A.number().int().optional(),offset:A.number().int().optional(),sort_by:A.enum(["assistant_id","graph_id","name","created_at","updated_at"]).optional(),sort_order:A.enum(["asc","desc"]).optional()}),k1=A.object({graph_id:A.string().optional(),metadata:K4.optional()}),h1=A.object({xray:A.union([A.string(),A.boolean(),A.number()]).optional()}),F8=A.object({name:A.string().optional(),description:A.string().optional(),metadata:K4.optional(),config:Y0.optional()}).optional(),x1=A.object({assistant_id:A.string().optional(),graph_id:A.string().describe("The ID of graph to create an assistant from."),name:A.string().optional(),description:A.string().optional(),metadata:K4.optional(),config:Y0.optional(),if_exists:A.enum(["raise","do_nothing"]).optional()}),g1=A.object({assistant_id:A.union([A.string(),A.string()]),checkpoint_id:A.string().optional(),input:A.any().optional(),command:rY.optional(),metadata:K4.optional(),config:Y0.optional(),webhook:A.string().optional(),interrupt_before:A.union([A.literal("*"),A.array(A.string())]).optional(),interrupt_after:A.union([A.literal("*"),A.array(A.string())]).optional(),on_disconnect:A.enum(["cancel","continue"]).optional().default("continue"),multitask_strategy:A.enum(["reject","rollback","interrupt","enqueue"]).optional(),stream_mode:A.array(A.enum(["values","messages","messages-tuple","updates","events","debug","custom"])).optional(),stream_subgraphs:A.boolean().optional(),stream_resumable:A.boolean().optional(),after_seconds:A.number().optional(),if_not_exists:A.enum(["create","reject"]).optional(),on_completion:A.enum(["complete","continue"]).optional(),feedback_keys:A.array(A.string()).optional(),langsmith_tracer:A.unknown().optional()}).describe("Payload for creating a stateful run."),u1=A.object({limit:A.coerce.number().int().optional().default(10),offset:A.coerce.number().int().optional().default(0),status:A.enum(["pending","running","error","success","timeout","interrupted"]).optional()}),m1=A.object({wait:A.coerce.boolean().optional().default(!1),action:A.enum(["interrupt","rollback"]).optional().default("interrupt")}),p1=A.object({cancel_on_disconnect:A.coerce.boolean().optional().default(!1),last_event_id:A.string().optional(),stream_mode:A.enum(["values","messages","messages-tuple","updates","events","debug","custom"]).optional()}),d1=A.object({thread_id:A.string().describe("The ID of thread. If not provided, an ID is generated.").optional(),metadata:K4.optional(),if_exists:A.union([A.literal("raise"),A.literal("do_nothing")]).optional()}).describe("Payload for creating a thread."),M8=A.object({ids:A.array(A.string()).describe("List of thread IDs to include. Others are excluded.").optional(),metadata:K4.describe("Metadata to search for.").optional(),status:A.enum(["idle","busy","interrupted","error"]).describe("Filter by thread status.").optional(),values:A.any().describe("Filter by thread values.").optional(),limit:A.number().int().gte(1).lte(1000).describe("Maximum number to return.").optional(),offset:A.number().int().gte(0).describe("Offset to start from.").optional(),sort_by:A.enum(["thread_id","status","created_at","updated_at"]).describe("Sort by field.").optional(),sort_order:A.enum(["asc","desc"]).describe("Sort order.").optional(),select:A.array(A.enum(["thread_id","created_at","updated_at","metadata","config","context","status","values","interrupts"])).describe("Specify which fields to return. If not provided, all fields are returned.").optional(),without_details:A.boolean().describe("Whether to return values.").optional()}).describe("Payload for listing threads.");A.object({values:A.union([A.record(A.string(),A.unknown()),A.array(A.record(A.string(),A.unknown()))]).nullish()}).describe("Payload for adding state to a thread.");var c1=A.object({metadata:K4.optional(),status:A.enum(["idle","busy","interrupted","error"]).optional(),values:A.any().optional()}).describe("Payload for patching a thread."),N8=A.object({assistant_id:A.string(),input:A.any().optional(),command:rY.optional(),metadata:K4.optional(),config:Y0.optional(),webhook:A.string().optional(),interrupt_before:A.union([A.literal("*"),A.array(A.string())]).optional(),interrupt_after:A.union([A.literal("*"),A.array(A.string())]).optional(),on_disconnect:A.enum(["cancel","continue"]).optional().default("continue"),multitask_strategy:A.enum(["reject","rollback","interrupt","enqueue"]).optional(),stream_mode:A.array(A.enum(["values","messages","messages-tuple","updates","events","debug","custom"])).optional(),stream_subgraphs:A.boolean().optional(),stream_resumable:A.boolean().optional(),after_seconds:A.number().optional(),if_not_exists:A.enum(["create","reject"]).optional(),on_completion:A.enum(["complete","continue"]).optional(),feedback_keys:A.array(A.string()).optional(),langsmith_tracer:A.unknown().optional()}).describe("Payload for creating a run (background/wait)."),l1=A.object({cancel_on_disconnect:A.coerce.boolean().optional().default(!1)}),i1=A.object({cancel_on_disconnect:A.coerce.boolean().optional().default(!1)}),c0=A.object({assistant_id:A.string().describe("The assistant ID or graph name to run."),input:A.any().optional().describe("The input to the graph."),command:rY.optional(),metadata:K4.optional().describe("Metadata to assign to the run."),config:Y0.optional(),context:A.object({}).catchall(A.any()).optional().describe("Static context added to the assistant."),webhook:A.string().optional(),interrupt_before:A.union([A.literal("*"),A.array(A.string())]).optional(),interrupt_after:A.union([A.literal("*"),A.array(A.string())]).optional(),stream_mode:A.union([A.enum(["values","messages","messages-tuple","tasks","checkpoints","updates","events","debug","custom"]),A.array(A.enum(["values","messages","messages-tuple","tasks","checkpoints","updates","events","debug","custom"]))]).optional().default(["values"]),feedback_keys:A.array(A.string()).optional(),stream_subgraphs:A.boolean().optional().default(!1),stream_resumable:A.boolean().optional().default(!1)}).describe("Payload for creating a stateless run."),r1=A.array(c0).min(1).describe("Payload for creating a batch of stateless runs."),o1=A.object({action:A.enum(["interrupt","rollback"]).optional().default("interrupt").describe("Action to take when cancelling the run."),wait:A.coerce.boolean().optional().default(!1)}),n1=A.union([A.object({status:A.enum(["pending","running","all"]).describe("Filter runs by status to cancel.")}),A.object({thread_id:A.string().describe("The ID of the thread containing runs to cancel.")}),A.object({run_ids:A.array(A.string()).min(1).describe("List of run IDs to cancel.")})]);function KZ(Z,Y){let X=Y.split("/").filter(($)=>$),J=new URL(Z).pathname.split("/").filter(($)=>$),Q={};return X.forEach(($,K)=>{if($.startsWith(":")){let U=$.slice(1);Q[U]=J[K]}}),Q}function lZ(Z){let Y=new URL(Z).searchParams,X={};return Y.forEach((J,Q)=>{if(!isNaN(Number(J))&&J!=="")X[Q]=Number(J);else if(J==="true"||J==="false")X[Q]=J==="true";else X[Q]=J}),X}function S(Z,Y){let X=Z.safeParse(Y);if(!X.success)throw new oY(X.error.issues);return X.data}class oY extends Error{errors;constructor(Z){super("Validation failed");this.name="ValidationError",this.errors=Z}}function m(Z,Y=200,X){return new Response(JSON.stringify(Z),{status:Y,headers:{"Content-Type":"application/json",...X}})}function k(Z,Y=500){if(Z instanceof oY)return m({error:"Validation Error",details:Z.errors},400);return m({error:Z instanceof Error?Z.message:"Unknown error"},Y)}function nY(Z){let Y,X=!1,J=new AbortController,Q=new ReadableStream({async start($){Y=$;let K=new TextEncoder,U={signal:J.signal,writeSSE:async({data:W,event:z,id:H})=>{if(X||J.signal.aborted)return;try{let G="";if(H)G+=`id: ${H}
2
- `;if(z)G+=`event: ${z}
3
- `;G+=`data: ${W}
1
+ import{d as u4,e as x4}from"./chunk-j7a40ww9.js";import{f as g,g as VZ}from"./chunk-30sq2w0d.js";import{i as G$,j as u$,k as V1,m as I1,n as x$,o as Y0}from"./chunk-32ase1cw.js";import{p as a$,q as l,r as n,s as K1,t as L6,u as Z1,v as hZ}from"./chunk-mjzeawnq.js";import"./chunk-heasksrr.js";import{A as q$,B as EZ,C as HZ,D as j$,E as k1,F as U$,x as f4,y as P3,z as S0}from"./chunk-cs73xbzz.js";import{G as O4,H as v6,I as q4,K as zZ,L as _Z,M as B1}from"./chunk-rncpxz1b.js";import{N as t,O as gZ}from"./chunk-hfve7nf5.js";import{P as T6,Q as xY,S as D6,T as y$,V as T$}from"./chunk-va71tsw3.js";import"./chunk-jxsfzfac.js";import{ca as J0,da as r1}from"./chunk-02vv5584.js";import{ea as D,fa as z,ga as G,ha as k6,ia as S$,ka as NZ,la as R4,ma as H4,na as o1,oa as y1,pa as M,qa as h1,sa as P0,ua as DZ,va as L3}from"./chunk-nwy6n6b6.js";import{Ca as r6}from"./chunk-g7pm00z7.js";import{Da as S4}from"./chunk-1y82m5kn.js";import{Fa as h4,Ga as T4,Ha as k4,Ia as C4,Ka as s3}from"./chunk-5x8nxw0t.js";import"./chunk-zwxjkwqd.js";import"./chunk-13nyfrmm.js";import"./chunk-5rr85f28.js";import"./chunk-cggjws6a.js";import"./chunk-cyexd09c.js";import"./chunk-r2h3x9zv.js";import"./chunk-1ttywx0y.js";import{ub as A,xb as M8,yb as T1}from"./chunk-kba8akjs.js";class G4{renderers=new Map;register($,Z){this.renderers.set($,Z)}get($){return this.renderers.get($)}has($){return this.renderers.has($)}list(){return Array.from(this.renderers.keys())}unregister($){this.renderers.delete($)}clear(){this.renderers.clear()}}var A0;var F$=M8(()=>{A0=new G4});var pZ=A(D(),1);var j6=A(M(),1),mZ=new T6({defaultOptions:{queries:{retry:($,Z)=>{if(Z instanceof TypeError&&Z.message.includes("fetch"))return $<2;return!1},refetchOnWindowFocus:!1,refetchOnMount:!0,refetchOnReconnect:!1,staleTime:300000,gcTime:600000,networkMode:"online"},mutations:{retry:1,networkMode:"online"}}});function V6({children:$}){return j6.jsxDEV(D6,{client:mZ,children:$},void 0,!1,void 0,this)}async function h6($,Z,Y,J){let X={threadId:Z,graphId:Y,runId:J};try{let Q=(await $.get(Z)).values;if(!Q?.messages||!Array.isArray(Q.messages)||Q.messages.length===0)return;let _=await I1.getTitleGenerator()(Q,{thread_id:Z,graph_id:Y,run_id:J});if(_){if(!await $.setTitleIfNull(Z,_))return}}catch(K){console.warn("Failed to generate thread title:",{...X,error:K instanceof Error?K.message:String(K)})}}var E6={async search($){let Z=Object.entries(G$).map(([K,Q])=>({assistant_id:K,graph_id:K,config:{},metadata:{},version:1,name:K,description:"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()}));if($?.graphId)Z=Z.filter((K)=>K.graph_id===$.graphId);if($?.metadata&&Object.keys($.metadata).length>0)Z=Z.filter((K)=>{return Object.entries($.metadata).every(([Q,W])=>{return K.metadata&&K.metadata[Q]===W})});if($?.sortBy)Z.sort((K,Q)=>{let W=K[$.sortBy],_=Q[$.sortBy],O=W<_?-1:W>_?1:0;return $.sortOrder==="desc"?-O:O});let Y=$?.offset??0,J=$?.limit;return J?Z.slice(Y,Y+J):Z.slice(Y)},async count($){return(await this.search($)).length},async get($){if(!Object.entries(G$).find(([Y,J])=>Y===$))throw Error(`Assistant not found: ${$}`);return{assistant_id:$,graph_id:$,config:{},created_at:new Date().toISOString(),updated_at:new Date().toISOString(),metadata:{},version:1,name:$,description:""}},async delete($){throw Error("Deleting assistants is not supported. Assistants are generated from registered graphs.")},async update($,Z){throw Error("Updating assistants is not supported. Assistants are generated from registered graphs.")},async getGraph($,Z){let Y={};return(await(await V1($,Y)).getGraphAsync({...Y,xray:Z?.xray??void 0})).toJSON()},async getSchemas($){let Y=(await V1($,{})).builder;return console.log(Y),{graph_id:$,state_schema:Y._inputDefinition,input_schema:Y._inputDefinition,output_schema:Y._outputDefinition,config_schema:Y._configSchema,context_schema:Y._configSchema}},async getVersions($,Z){let Y=await this.get($),J=Z?.offset??0,X=Z?.limit;return X?[Y].slice(J,J+X):[Y].slice(J)},async setLatest($,Z){let Y=await this.get($);return Y.version=Z,Y},async create($){if(console.warn("⚠️ Creating assistants is not supported. Assistants are generated from registered graphs. Returning mock data."),!Object.keys(G$).includes($.graphId)){if($.ifExists==="raise")throw Error(`Graph not found: ${$.graphId}`)}return{assistant_id:$.assistantId||$.graphId,graph_id:$.graphId,name:$.name||$.graphId,description:$.description||"",metadata:$.metadata||{},config:$.config||{},version:1,created_at:new Date().toISOString(),updated_at:new Date().toISOString()}}},c$=()=>{let $=()=>{return I1.globalThreadsManager};return{assistants:E6,get threads(){return I1.globalThreadsManager},runs:{list(Z,Y){return $().listRuns(Z,Y)},async cancel(Z,Y,J,X){return await I1.globalMessageQueue.cancelQueue(Y)},async*stream(Z,Y,J){J.config={...J.config??{},configurable:{...J.config?.configurable??{},graph_id:Y,thread_id:Z}};let X=$(),K=X.createRun(Z,Y,J);try{for await(let W of Y0(X,K,J,{attempt:0,getGraph:V1}))yield W;let Q=await K;await h6(X,Z,Y,Q.run_id)}catch(Q){try{let W=await K;await h6(X,Z,Y,W.run_id)}catch{}throw Q}},async*joinStream(Z,Y,J){let X=J&&typeof J==="object"&&"signal"in J?J:{},K=(J instanceof AbortSignal?J:X.signal)||new AbortController().signal,Q=null,W=null;try{Q=await I1.globalMessageQueue.getQueue(Y);let _=await Q.getAll();for(let O of _){if(K.aborted)return;if(yield{id:O.id,event:O.event,data:O.data},O.event==="__stream_end__"||O.event==="__stream_error__"||O.event==="__stream_cancel__")return}W=Q.onDataReceive();for await(let O of W){if(K.aborted)break;let{event:N,data:U}=O;if(yield{id:O.id,event:N,data:U},O.event==="__stream_end__"||O.event==="__stream_error__"||O.event==="__stream_cancel__")break}}catch(_){if(!(_ instanceof Error)||!_.message.includes("does not exist"))console.warn("Join stream failed:",_)}finally{if(W)try{await W.return(void 0)}catch(_){}}}}}};import{entrypoint as bX,getPreviousState as BX,getConfig as PX,Command as fX}from"@langchain/langgraph";import{schemaMetaRegistry as vX}from"@langchain/langgraph/zod";import{z as s}from"zod";var b0=($,Z)=>$.constructor.name===Z.name,O1=new Map;O1.set(s.ZodBoolean.name,()=>!1),O1.set(s.ZodNumber.name,()=>0),O1.set(s.ZodString.name,()=>""),O1.set(s.ZodArray.name,()=>[]),O1.set(s.ZodRecord.name,()=>({})),O1.set(s.ZodDefault.name,($)=>$.def.defaultValue),O1.set(s.ZodPipe.name,($)=>a0($.def.in)),O1.set(s.ZodOptional.name,($)=>b0($.def.innerType,s.ZodDefault)?$.def.innerType.def.defaultValue:void 0),O1.set(s.ZodTuple.name,($)=>{let Z=[];for(let Y of $.def.items)Z.push(a0(Y));return Z}),O1.set(s.ZodPipe.name,($)=>a0($.def.in)),O1.set(s.ZodUnion.name,($)=>a0($.def.options[0])),O1.set(s.ZodObject.name,($)=>B0($)),O1.set(s.ZodRecord.name,($)=>B0($)),O1.set(s.ZodIntersection.name,($)=>B0($));function a0($){let Z=$.constructor.name;if(!O1.has(Z)){console.warn("getSchemaDefaultForField: Unhandled type",$.constructor.name);return}return O1.get(Z)($)}function B0($){if(b0($,s.ZodRecord))return{};if(b0($,s.ZodPipe))return B0($.def.in);if(b0($,s.ZodIntersection))return{...B0($.def.left),...B0($.def.right)};if(b0($,s.ZodUnion)){for(let Z of $.def.options)if(b0(Z,s.ZodObject))return B0(Z);return console.warn("getSchemaDefaultObject: No object found in union, returning empty object"),{}}return b0($,s.ZodObject)?Object.fromEntries(Object.entries($.shape).map(([Z,Y])=>[Z,a0(Y)]).filter((Z)=>Z[1]!==void 0)):(console.warn(`getSchemaDefaultObject: Expected object schema, got ${$.constructor.name}`),{})}import{tool as kX,HumanMessage as yX}from"langchain";import{z as X0}from"zod";var DX=X0.object({task_store:X0.record(X0.string(),X0.any()).default({})}),VX=X0.object({task_id:X0.string().optional().describe("The task id to ask the subagent, if not provided, will use the tool call id"),subagent_id:X0.string(),task_description:X0.string().describe("Describe the user state and what you want the subagent to do."),data_transfer:X0.any().optional().describe("Data to transfer to the subagent.")});import H from"zod";var V=c$(),cZ=H.object({thread_id:H.string().optional(),thread_ts:H.string().optional()}).catchall(H.unknown()),h0=H.object({tags:H.array(H.string()).optional(),recursion_limit:H.number().int().optional(),configurable:cZ.optional()}).catchall(H.unknown()).describe("The configuration of an assistant.");H.object({assistant_id:H.string(),graph_id:H.string(),config:h0,created_at:H.string(),updated_at:H.string(),metadata:H.object({}).catchall(H.any())});var i1=H.object({source:H.union([H.literal("input"),H.literal("loop"),H.literal("update"),H.string()]).optional(),step:H.number().optional(),writes:H.any().nullable().optional(),parents:H.any().optional()}).catchall(H.unknown()),g6=H.object({node:H.string(),input:H.unknown().optional()}),d$=H.object({update:H.union([H.any(),H.array(H.tuple([H.string(),H.any()]))]).nullable().optional(),resume:H.unknown().optional(),goto:H.union([g6,H.array(g6),H.string(),H.array(H.string())]).optional()});H.object({limit:H.number().int().optional(),offset:H.number().int().optional()});var q1=H.object({thread_id:H.string()}),s0=H.object({thread_id:H.string(),run_id:H.string()}),uZ=H.object({graph_id:H.string().optional(),metadata:i1.optional(),limit:H.number().int().optional(),offset:H.number().int().optional(),sort_by:H.enum(["assistant_id","graph_id","name","created_at","updated_at"]).optional(),sort_order:H.enum(["asc","desc"]).optional()}),xZ=H.object({graph_id:H.string().optional(),metadata:i1.optional()}),dZ=H.object({xray:H.union([H.string(),H.boolean(),H.number()]).optional()}),p6=H.object({name:H.string().optional(),description:H.string().optional(),metadata:i1.optional(),config:h0.optional()}).optional(),lZ=H.object({assistant_id:H.string().optional(),graph_id:H.string().describe("The ID of graph to create an assistant from."),name:H.string().optional(),description:H.string().optional(),metadata:i1.optional(),config:h0.optional(),if_exists:H.enum(["raise","do_nothing"]).optional()}),iZ=H.object({assistant_id:H.union([H.string(),H.string()]),checkpoint_id:H.string().optional(),input:H.any().optional(),command:d$.optional(),metadata:i1.optional(),config:h0.optional(),webhook:H.string().optional(),interrupt_before:H.union([H.literal("*"),H.array(H.string())]).optional(),interrupt_after:H.union([H.literal("*"),H.array(H.string())]).optional(),on_disconnect:H.enum(["cancel","continue"]).optional().default("continue"),multitask_strategy:H.enum(["reject","rollback","interrupt","enqueue"]).optional(),stream_mode:H.array(H.enum(["values","messages","messages-tuple","updates","events","debug","custom"])).optional(),stream_subgraphs:H.boolean().optional(),stream_resumable:H.boolean().optional(),after_seconds:H.number().optional(),if_not_exists:H.enum(["create","reject"]).optional(),on_completion:H.enum(["complete","continue"]).optional(),feedback_keys:H.array(H.string()).optional(),langsmith_tracer:H.unknown().optional()}).describe("Payload for creating a stateful run."),oZ=H.object({limit:H.coerce.number().int().optional().default(10),offset:H.coerce.number().int().optional().default(0),status:H.enum(["pending","running","error","success","timeout","interrupted"]).optional()}),rZ=H.object({wait:H.coerce.boolean().optional().default(!1),action:H.enum(["interrupt","rollback"]).optional().default("interrupt")}),nZ=H.object({cancel_on_disconnect:H.coerce.boolean().optional().default(!1),last_event_id:H.string().optional(),stream_mode:H.enum(["values","messages","messages-tuple","updates","events","debug","custom"]).optional()}),aZ=H.object({thread_id:H.string().describe("The ID of thread. If not provided, an ID is generated.").optional(),metadata:i1.optional(),if_exists:H.union([H.literal("raise"),H.literal("do_nothing")]).optional()}).describe("Payload for creating a thread."),m6=H.object({ids:H.array(H.string()).describe("List of thread IDs to include. Others are excluded.").optional(),metadata:i1.describe("Metadata to search for.").optional(),status:H.enum(["idle","busy","interrupted","error"]).describe("Filter by thread status.").optional(),values:H.any().describe("Filter by thread values.").optional(),limit:H.number().int().gte(1).lte(1000).describe("Maximum number to return.").optional(),offset:H.number().int().gte(0).describe("Offset to start from.").optional(),sort_by:H.enum(["thread_id","status","created_at","updated_at"]).describe("Sort by field.").optional(),sort_order:H.enum(["asc","desc"]).describe("Sort order.").optional(),select:H.array(H.enum(["thread_id","created_at","updated_at","metadata","config","context","status","values","interrupts","title"])).describe("Specify which fields to return. If not provided, all fields are returned.").optional(),without_details:H.boolean().describe("Whether to return values.").optional()}).describe("Payload for listing threads.");H.object({values:H.union([H.record(H.string(),H.unknown()),H.array(H.record(H.string(),H.unknown()))]).nullish()}).describe("Payload for adding state to a thread.");var sZ=H.object({metadata:i1.optional(),status:H.enum(["idle","busy","interrupted","error"]).optional(),values:H.any().optional()}).describe("Payload for patching a thread."),c6=H.object({assistant_id:H.string(),input:H.any().optional(),command:d$.optional(),metadata:i1.optional(),config:h0.optional(),webhook:H.string().optional(),interrupt_before:H.union([H.literal("*"),H.array(H.string())]).optional(),interrupt_after:H.union([H.literal("*"),H.array(H.string())]).optional(),on_disconnect:H.enum(["cancel","continue"]).optional().default("continue"),multitask_strategy:H.enum(["reject","rollback","interrupt","enqueue"]).optional(),stream_mode:H.array(H.enum(["values","messages","messages-tuple","updates","events","debug","custom"])).optional(),stream_subgraphs:H.boolean().optional(),stream_resumable:H.boolean().optional(),after_seconds:H.number().optional(),if_not_exists:H.enum(["create","reject"]).optional(),on_completion:H.enum(["complete","continue"]).optional(),feedback_keys:H.array(H.string()).optional(),langsmith_tracer:H.unknown().optional()}).describe("Payload for creating a run (background/wait)."),tZ=H.object({cancel_on_disconnect:H.coerce.boolean().optional().default(!1)}),eZ=H.object({cancel_on_disconnect:H.coerce.boolean().optional().default(!1)}),O$=H.object({assistant_id:H.string().describe("The assistant ID or graph name to run."),input:H.any().optional().describe("The input to the graph."),command:d$.optional(),metadata:i1.optional().describe("Metadata to assign to the run."),config:h0.optional(),context:H.object({}).catchall(H.any()).optional().describe("Static context added to the assistant."),webhook:H.string().optional(),interrupt_before:H.union([H.literal("*"),H.array(H.string())]).optional(),interrupt_after:H.union([H.literal("*"),H.array(H.string())]).optional(),stream_mode:H.union([H.enum(["values","messages","messages-tuple","tasks","checkpoints","updates","events","debug","custom"]),H.array(H.enum(["values","messages","messages-tuple","tasks","checkpoints","updates","events","debug","custom"]))]).optional().default(["values"]),feedback_keys:H.array(H.string()).optional(),stream_subgraphs:H.boolean().optional().default(!1),stream_resumable:H.boolean().optional().default(!1)}).describe("Payload for creating a stateless run."),$2=H.array(O$).min(1).describe("Payload for creating a batch of stateless runs."),Z2=H.object({action:H.enum(["interrupt","rollback"]).optional().default("interrupt").describe("Action to take when cancelling the run."),wait:H.coerce.boolean().optional().default(!1)}),Y2=H.union([H.object({status:H.enum(["pending","running","all"]).describe("Filter runs by status to cancel.")}),H.object({thread_id:H.string().describe("The ID of the thread containing runs to cancel.")}),H.object({run_ids:H.array(H.string()).min(1).describe("List of run IDs to cancel.")})]);function $1($,Z){let Y=Z.split("/").filter((K)=>K),J=new URL($).pathname.split("/").filter((K)=>K),X={};return Y.forEach((K,Q)=>{if(K.startsWith(":")){let W=K.slice(1);X[W]=J[Q]}}),X}function j1($){let Z=new URL($).searchParams,Y={};return Z.forEach((J,X)=>{if(!isNaN(Number(J))&&J!=="")Y[X]=Number(J);else if(J==="true"||J==="false")Y[X]=J==="true";else Y[X]=J}),Y}function y($,Z){let Y=$.safeParse(Z);if(!Y.success)throw new l$(Y.error.issues);return Y.data}class l$ extends Error{errors;constructor($){super("Validation failed");this.name="ValidationError",this.errors=$}}function h($,Z=200,Y){return new Response(JSON.stringify($),{status:Z,headers:{"Content-Type":"application/json",...Y}})}function T($,Z=500){if($ instanceof l$)return h({error:"Validation Error",details:$.errors},400);return h({error:$ instanceof Error?$.message:"Unknown error"},Z)}function i$($){let Z,Y=!1,J=new AbortController,X=new ReadableStream({async start(K){Z=K;let Q=new TextEncoder,W={signal:J.signal,writeSSE:async({data:_,event:O,id:N})=>{if(Y||J.signal.aborted)return;try{let U="";if(N)U+=`id: ${N}
2
+ `;if(O)U+=`event: ${O}
3
+ `;U+=`data: ${_}
4
4
 
5
- `,Y.enqueue(K.encode(G))}catch(G){if(!X&&!J.signal.aborted)throw G}},close:()=>{if(!X){X=!0;try{Y.close()}catch(W){}}}};try{await Z(U)}catch(W){if(!J.signal.aborted)console.error("SSE stream error:",W)}finally{if(!X){X=!0;try{Y.close()}catch(W){}}}},cancel(){if(X=!0,!J.signal.aborted)J.abort("Client disconnected")}});return new Response(Q,{headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}})}function aY(Z,Y=process.env.HEARTBEAT_INTERVAL?parseInt(process.env.HEARTBEAT_INTERVAL):1500){return async(X)=>{let J=null,Q=!1,$=()=>{if(J)clearInterval(J),J=null},K=()=>{$(),J=setInterval(async()=>{if(X.signal.aborted||Q){$();return}try{await X.writeSSE({event:"ping",data:"{}"})}catch(z){$()}},Y)},U=()=>{$()};X.signal.addEventListener("abort",U);let W={signal:X.signal,writeSSE:async(z)=>{if(X.signal.aborted)return;if($(),await X.writeSSE(z),!X.signal.aborted)K()},close:()=>{$(),X.close()}};K();try{await Z(W)}finally{Q=!0,$(),X.signal.removeEventListener("abort",U)}}}async function a1(Z,Y){try{let X=await Z.json(),J=S(y1,X),Q=await x.assistants.search(FZ(J));return m(Q,200,{"X-Pagination-Total":"0"})}catch(X){return k(X)}}async function s1(Z,Y){try{let X=await Z.json(),J=S(k1,X),Q=await x.assistants.count(FZ(J));return m(Q)}catch(X){return k(X)}}async function t1(Z,Y){try{let Q=new URL(Z.url).pathname.split("/").filter((K)=>K)[1],$=await x.assistants.get(Q);return m($)}catch(X){return k(X)}}async function e1(Z,Y){try{let Q=new URL(Z.url).pathname.split("/").filter(($)=>$)[1];return await x.assistants.delete(Q),m({})}catch(X){return k(X)}}async function ZQ(Z,Y){try{let Q=new URL(Z.url).pathname.split("/").filter((W)=>W)[1],$=await Z.json(),K=S(F8,$),U=await x.assistants.update(Q,FZ(K));return m(U)}catch(X){return k(X)}}async function YQ(Z,Y){try{let Q=new URL(Z.url).pathname.split("/").filter((W)=>W)[1],$=lZ(Z.url),{xray:K}=S(h1,$),U=await x.assistants.getGraph(Q,{xray:K!==void 0?K==="true":void 0});return m(U)}catch(X){return k(X)}}async function XQ(Z,Y){return k({},501)}async function JQ(Z,Y){return k({},501)}async function QQ(Z,Y){try{let Q=new URL(Z.url).pathname.split("/").filter((K)=>K)[1],$=await x.assistants.getSchemas(Q);return m($)}catch(X){return k(X)}}async function $Q(Z,Y){try{let Q=new URL(Z.url).pathname.split("/").filter((W)=>W)[1],$=await Z.json(),K=S(F8,$),U=await x.assistants.getVersions(Q,FZ(K));return m(U)}catch(X){return k(X)}}async function KQ(Z,Y){try{let Q=new URL(Z.url).pathname.split("/").filter((W)=>W)[1],$=lZ(Z.url),K=$.version?parseInt($.version):1,U=await x.assistants.setLatest(Q,K);return m(U)}catch(X){return k(X)}}async function WQ(Z,Y){try{let X=await Z.json(),J=S(x1,X),Q=await x.assistants.create(FZ(J));return m(Q)}catch(X){return k(X)}}async function UQ(Z,Y){try{let X=await Z.json(),J=S(d1,X),Q=await x.threads.create(FZ(J));return m(Q)}catch(X){return k(X)}}async function zQ(Z,Y){try{let X=await Z.json(),J=S(M8,X),Q=await x.threads.search(FZ(J));return m(Q,200,{"X-Pagination-Total":Q.length.toString()})}catch(X){return k(X)}}async function HQ(Z,Y){try{let X=await Z.json(),J=S(M8.partial(),X),Q=await x.threads.count(FZ(J));return m(Q)}catch(X){return k(X)}}async function GQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id"),{thread_id:J}=S(DZ,X),Q=await x.threads.get(J);return m(Q)}catch(X){return k(X)}}async function OQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id"),{thread_id:J}=S(DZ,X),Q=await Z.json(),$=S(c1,Q),K=await x.threads.patch(J,FZ($));return m(K)}catch(X){return k(X)}}async function qQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id"),{thread_id:J}=S(DZ,X);return await x.threads.delete(J),new Response(null,{status:204})}catch(X){return k(X)}}async function FQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/state"),{thread_id:J}=S(DZ,X),Q=lZ(Z.url),$={subgraphs:Q.subgraphs==="true"||Q.subgraphs===!0},K=await x.threads.getState(J,$);return m(K)}catch(X){return k(X)}}async function MQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/state"),{thread_id:J}=S(DZ,X),Q=await Z.json(),$=await x.threads.updateState(J,FZ(Q));return m($)}catch(X){return k(X)}}async function NQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/state/checkpoint"),{thread_id:J}=S(DZ,X),Q=await Z.json(),$=lZ(Z.url),K={subgraphs:$.subgraphs==="true"||$.subgraphs===!0,...Q},U=await x.threads.getState(J,K);return m(U)}catch(X){return k(X)}}async function _Q(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/history"),{thread_id:J}=S(DZ,X),Q=lZ(Z.url),$={limit:Q.limit?parseInt(Q.limit,10):void 0,before:Q.before},K=await x.threads.getStateHistory(J,$);return m(K)}catch(X){return k(X)}}async function AQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/history"),{thread_id:J}=S(DZ,X),Q=await Z.json(),$={limit:Q.limit,before:Q.before},K=await x.threads.getStateHistory(J,$);return m(K)}catch(X){return k(X)}}async function wQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/copy"),{thread_id:J}=S(DZ,X),Q=await x.threads.copy(J);return m(Q)}catch(X){return k(X)}}async function BQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/stream"),{thread_id:J}=S(DZ,X),Q=lZ(Z.url),$={lastEventId:Z.headers.get("Last-Event-ID")||Q.last_event_id,streamModes:Q.stream_modes?Array.isArray(Q.stream_modes)?Q.stream_modes:[Q.stream_modes]:void 0};return new Response(`data: {"status": "stream_ready"}
5
+ `,Z.enqueue(Q.encode(U))}catch(U){if(!Y&&!J.signal.aborted)throw U}},close:()=>{if(!Y){Y=!0;try{Z.close()}catch(_){}}}};try{await $(W)}catch(_){if(!J.signal.aborted)console.error("SSE stream error:",_)}finally{if(!Y){Y=!0;try{Z.close()}catch(_){}}}},cancel(){if(Y=!0,!J.signal.aborted)J.abort("Client disconnected")}});return new Response(X,{headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}})}function o$($,Z=process.env.HEARTBEAT_INTERVAL?parseInt(process.env.HEARTBEAT_INTERVAL):1500){return async(Y)=>{let J=null,X=!1,K=()=>{if(J)clearInterval(J),J=null},Q=()=>{K(),J=setInterval(async()=>{if(Y.signal.aborted||X){K();return}try{await Y.writeSSE({event:"ping",data:"{}"})}catch(O){K()}},Z)},W=()=>{K()};Y.signal.addEventListener("abort",W);let _={signal:Y.signal,writeSSE:async(O)=>{if(Y.signal.aborted)return;if(K(),await Y.writeSSE(O),!Y.signal.aborted)Q()},close:()=>{K(),Y.close()}};Q();try{await $(_)}finally{X=!0,K(),Y.signal.removeEventListener("abort",W)}}}async function X2($,Z){try{let Y=await $.json(),J=y(uZ,Y),X=await V.assistants.search(K1(J));return h(X,200,{"X-Pagination-Total":"0"})}catch(Y){return T(Y)}}async function J2($,Z){try{let Y=await $.json(),J=y(xZ,Y),X=await V.assistants.count(K1(J));return h(X)}catch(Y){return T(Y)}}async function K2($,Z){try{let X=new URL($.url).pathname.split("/").filter((Q)=>Q)[1],K=await V.assistants.get(X);return h(K)}catch(Y){return T(Y)}}async function Q2($,Z){try{let X=new URL($.url).pathname.split("/").filter((K)=>K)[1];return await V.assistants.delete(X),h({})}catch(Y){return T(Y)}}async function W2($,Z){try{let X=new URL($.url).pathname.split("/").filter((_)=>_)[1],K=await $.json(),Q=y(p6,K),W=await V.assistants.update(X,K1(Q));return h(W)}catch(Y){return T(Y)}}async function _2($,Z){try{let X=new URL($.url).pathname.split("/").filter((_)=>_)[1],K=j1($.url),{xray:Q}=y(dZ,K),W=await V.assistants.getGraph(X,{xray:Q!==void 0?Q==="true":void 0});return h(W)}catch(Y){return T(Y)}}async function G2($,Z){return T({},501)}async function O2($,Z){return T({},501)}async function U2($,Z){try{let X=new URL($.url).pathname.split("/").filter((Q)=>Q)[1],K=await V.assistants.getSchemas(X);return h(K)}catch(Y){return T(Y)}}async function N2($,Z){try{let X=new URL($.url).pathname.split("/").filter((_)=>_)[1],K=await $.json(),Q=y(p6,K),W=await V.assistants.getVersions(X,K1(Q));return h(W)}catch(Y){return T(Y)}}async function z2($,Z){try{let X=new URL($.url).pathname.split("/").filter((_)=>_)[1],K=j1($.url),Q=K.version?parseInt(K.version):1,W=await V.assistants.setLatest(X,Q);return h(W)}catch(Y){return T(Y)}}async function H2($,Z){try{let Y=await $.json(),J=y(lZ,Y),X=await V.assistants.create(K1(J));return h(X)}catch(Y){return T(Y)}}async function F2($,Z){try{let Y=await $.json(),J=y(aZ,Y),X=await V.threads.create(K1(J));return h(X)}catch(Y){return T(Y)}}async function L2($,Z){try{let Y=await $.json(),J=y(m6,Y),X=await V.threads.search(K1(J));return h(X,200,{"X-Pagination-Total":X.length.toString()})}catch(Y){return T(Y)}}async function A2($,Z){try{let Y=await $.json(),J=y(m6.partial(),Y),X=await V.threads.count(K1(J));return h(X)}catch(Y){return T(Y)}}async function q2($,Z){try{let Y=$1($.url,"/threads/:thread_id"),{thread_id:J}=y(q1,Y),X=await V.threads.get(J);return h(X)}catch(Y){return T(Y)}}async function w2($,Z){try{let Y=$1($.url,"/threads/:thread_id"),{thread_id:J}=y(q1,Y),X=await $.json(),K=y(sZ,X),Q=await V.threads.patch(J,K1(K));return h(Q)}catch(Y){return T(Y)}}async function M2($,Z){try{let Y=$1($.url,"/threads/:thread_id"),{thread_id:J}=y(q1,Y);return await V.threads.delete(J),new Response(null,{status:204})}catch(Y){return T(Y)}}async function R2($,Z){try{let Y=$1($.url,"/threads/:thread_id/state"),{thread_id:J}=y(q1,Y),X=j1($.url),K={subgraphs:X.subgraphs==="true"||X.subgraphs===!0},Q=await V.threads.getState(J,K);return h(Q)}catch(Y){return T(Y)}}async function b2($,Z){try{let Y=$1($.url,"/threads/:thread_id/state"),{thread_id:J}=y(q1,Y),X=await $.json(),K=await V.threads.updateState(J,K1(X));return h(K)}catch(Y){return T(Y)}}async function B2($,Z){try{let Y=$1($.url,"/threads/:thread_id/state/checkpoint"),{thread_id:J}=y(q1,Y),X=await $.json(),K=j1($.url),Q={subgraphs:K.subgraphs==="true"||K.subgraphs===!0,...X},W=await V.threads.getState(J,Q);return h(W)}catch(Y){return T(Y)}}async function P2($,Z){try{let Y=$1($.url,"/threads/:thread_id/history"),{thread_id:J}=y(q1,Y),X=j1($.url),K={limit:X.limit?parseInt(X.limit,10):void 0,before:X.before},Q=await V.threads.getStateHistory(J,K);return h(Q)}catch(Y){return T(Y)}}async function f2($,Z){try{let Y=$1($.url,"/threads/:thread_id/history"),{thread_id:J}=y(q1,Y),X=await $.json(),K={limit:X.limit,before:X.before},Q=await V.threads.getStateHistory(J,K);return h(Q)}catch(Y){return T(Y)}}async function C2($,Z){try{let Y=$1($.url,"/threads/:thread_id/copy"),{thread_id:J}=y(q1,Y),X=await V.threads.copy(J);return h(X)}catch(Y){return T(Y)}}async function v2($,Z){try{let Y=$1($.url,"/threads/:thread_id/stream"),{thread_id:J}=y(q1,Y),X=j1($.url),K={lastEventId:$.headers.get("Last-Event-ID")||X.last_event_id,streamModes:X.stream_modes?Array.isArray(X.stream_modes)?X.stream_modes:[X.stream_modes]:void 0};return new Response(`data: {"status": "stream_ready"}
6
6
 
7
- `,{headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}})}catch(X){return k(X)}}async function LQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/runs/stream"),{thread_id:J}=S(DZ,X),Q=await Z.json(),$=S(g1,Q);return nY(aY(async(K)=>{$.config=$.config||{},$.config.configurable=$.config.configurable||{};let U=Y?.langgraph_context;if(U)Object.assign($.config.configurable,U);let W=null,z=!1,H=()=>{z=!0};K.signal.addEventListener("abort",H);try{W=x.runs.stream(J,$.assistant_id,FZ($));for await(let{event:G,data:F}of W){if(z||K.signal.aborted)break;await K.writeSSE({data:iY(F)??"",event:G})}}catch(G){if(!K.signal.aborted&&!z)throw G}finally{if(K.signal.removeEventListener("abort",H),W){try{await W.return(void 0)}catch(G){}W=null}}}))}catch(X){return k(X)}}async function PQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/runs/:run_id/stream"),{thread_id:J,run_id:Q}=S(_0,X),$=lZ(Z.url),{cancel_on_disconnect:K,last_event_id:U,stream_mode:W}=S(p1,$);return nY(aY(async(z)=>{let H=new AbortController,G=null,F=!1,M=[],N=()=>{H.abort("Client disconnected")};if(Z.signal)Z.signal.addEventListener("abort",N),M.push({signal:Z.signal,handler:N});let w=()=>{F=!0,H.abort("SSE stream closed")};z.signal.addEventListener("abort",w),M.push({signal:z.signal,handler:w});try{G=x.runs.joinStream(J,Q,{signal:H.signal,cancelOnDisconnect:K,lastEventId:U,streamMode:W?[W]:void 0});for await(let{event:L,data:B,id:C}of G){if(F||z.signal.aborted||H.signal.aborted)break;await z.writeSSE({data:iY(B)??"",event:L,id:C})}}catch(L){if(!(H.signal.aborted||z.signal.aborted)&&!(L instanceof Error&&L.message.includes("user cancel")))console.error("Join stream error:",L),await z.writeSSE({event:"error",data:JSON.stringify({error:L instanceof Error?L.message:"Unknown error"})})}finally{for(let{signal:L,handler:B}of M)try{L.removeEventListener("abort",B)}catch(C){}if(G){try{await G.return(void 0)}catch(L){}G=null}}}))}catch(X){return k(X)}}async function RQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/runs"),{thread_id:J}=S(DZ,X),Q=lZ(Z.url),{limit:$,offset:K,status:U}=S(u1,Q),W=await x.runs.list(J,{limit:$,offset:K,status:U});return m(W)}catch(X){return k(X)}}async function CQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/runs/:run_id/cancel"),{thread_id:J,run_id:Q}=S(_0,X),$=lZ(Z.url),{wait:K,action:U}=S(m1,$),W=x.runs.cancel(J,Q,K,U);if(K)await W;return new Response(null,{status:K?204:202})}catch(X){return k(X)}}async function IQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/runs"),{thread_id:J}=S(DZ,X),Q=await Z.json(),$=S(N8,Q),K=FZ($);K.config=K.config||{},K.config.configurable=K.config.configurable||{};let U=Y?.langgraph_context;if(U)Object.assign(K.config.configurable,U);K.config.configurable.graph_id=$.assistant_id,K.config.configurable.thread_id=J;let W=x.threads,z=await W.createRun(J,$.assistant_id,K);return(async()=>{let H=!1;try{for await(let G of F4(W,z,K,{attempt:0,getGraph:cZ}));}catch(G){console.error("Background run error:",G)}finally{if(!H){H=!0;try{await dZ.globalMessageQueue.removeQueue(z.run_id)}catch(G){}}}})(),m(z,200,{"Content-Location":`/threads/${J}/runs/${z.run_id}`})}catch(X){return k(X)}}async function vQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/runs/wait"),{thread_id:J}=S(DZ,X),Q=await Z.json(),$=S(N8,Q),K=lZ(Z.url),{cancel_on_disconnect:U}=S(l1,K),W=FZ($);W.config=W.config||{},W.config.configurable=W.config.configurable||{};let z=Y?.langgraph_context;if(z)Object.assign(W.config.configurable,z);W.config.configurable.graph_id=$.assistant_id,W.config.configurable.thread_id=J;let H=x.threads,G=await H.createRun(J,$.assistant_id,W),F={};for await(let{event:M,data:N}of F4(H,G,W,{attempt:0,getGraph:cZ}))if(M==="end"||M==="writes/value"){if(N&&typeof N==="object")Object.assign(F,N)}return m(F,200,{"Content-Location":`/threads/${J}/runs/${G.run_id}`})}catch(X){return k(X)}}async function DQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/runs/:run_id"),{thread_id:J,run_id:Q}=S(_0,X),K=(await x.runs.list(J,{limit:1000})).find((U)=>U.run_id===Q);if(!K)return k(Error("Run not found"),404);return m(K)}catch(X){return k(X)}}async function VQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/runs/:run_id"),{thread_id:J,run_id:Q}=S(_0,X);return await x.threads.updateRun(Q,{status:"deleted"}),new Response(null,{status:204})}catch(X){return k(X)}}async function EQ(Z,Y){try{let X=KZ(Z.url,"/threads/:thread_id/runs/:run_id/join"),{thread_id:J,run_id:Q}=S(_0,X),$=lZ(Z.url),{cancel_on_disconnect:K}=S(i1,$),W=(await x.runs.list(J,{limit:1000})).find((G)=>G.run_id===Q);if(!W)return k(Error("Run not found"),404);if(W.status==="success"||W.status==="error")return m({});let z=new AbortController;if(K){let G=()=>{z.abort("Client disconnected")};Z.signal?.addEventListener("abort",G)}let H={};for await(let{event:G,data:F}of x.runs.joinStream(J,Q,{signal:z.signal,cancelOnDisconnect:K}))if(G.event==="end"||G.event==="writes/value"){if(F&&typeof F==="object")Object.assign(H,F)}return m(H)}catch(X){return k(X)}}async function bQ(Z,Y){try{let X=await Z.json(),J=S(c0,X),Q=FZ(J);Q.config=Q.config||{},Q.config.configurable=Q.config.configurable||{};let $=Y?.langgraph_context;if($)Object.assign(Q.config.configurable,$);let K=x.threads,U=await K.create({metadata:{...Q.metadata,temporary:!0}});Q.config.configurable.graph_id=J.assistant_id,Q.config.configurable.thread_id=U.thread_id,Q.temporary=!0;let W=await K.createRun(U.thread_id,J.assistant_id,Q);return(async()=>{let z=!1;try{for await(let H of F4(K,W,Q,{attempt:0,getGraph:cZ}));}catch(H){console.error("Stateless run error:",H)}finally{try{await K.delete(U.thread_id)}catch(H){console.error("Error cleaning up temporary thread:",H)}if(!z){z=!0;try{await dZ.globalMessageQueue.removeQueue(W.run_id)}catch(H){}}}})(),m(W,200,{"Content-Location":`/threads/${U.thread_id}/runs/${W.run_id}`})}catch(X){return k(X)}}async function TQ(Z,Y){try{let X=await Z.json(),J=S(c0,X),Q=FZ(J);Q.config=Q.config||{},Q.config.configurable=Q.config.configurable||{};let $=Y?.langgraph_context;if($)Object.assign(Q.config.configurable,$);let K=x.threads,U=await K.create({metadata:{...Q.metadata,temporary:!0}});Q.config.configurable.graph_id=J.assistant_id,Q.config.configurable.thread_id=U.thread_id,Q.temporary=!0;let W=await K.createRun(U.thread_id,J.assistant_id,Q);return nY(aY(async(z)=>{try{for await(let H of F4(K,W,Q,{attempt:0,getGraph:cZ}))await z.writeSSE({data:JSON.stringify(H),event:"data"})}catch(H){if(H instanceof Error&&H.name!=="AbortError")throw console.error("Stream error:",H),H}finally{try{await K.delete(U.thread_id)}catch(H){console.error("Error cleaning up temporary thread:",H)}}}))}catch(X){return k(X)}}async function fQ(Z,Y){try{let X=await Z.json(),J=S(c0,X),Q=FZ(J);Q.config=Q.config||{},Q.config.configurable=Q.config.configurable||{};let $=Y?.langgraph_context;if($)Object.assign(Q.config.configurable,$);let K=x.threads,U=await K.create({metadata:{...Q.metadata,temporary:!0}});Q.config.configurable.graph_id=J.assistant_id,Q.config.configurable.thread_id=U.thread_id,Q.temporary=!0;let W=await K.createRun(U.thread_id,J.assistant_id,Q),z={};try{for await(let{event:H,data:G}of F4(K,W,Q,{attempt:0,getGraph:cZ}))if(H==="end"||H==="writes/value"){if(G&&typeof G==="object")Object.assign(z,G)}}finally{try{await K.delete(U.thread_id)}catch(H){console.error("Error cleaning up temporary thread:",H)}}return m(z,200,{"Content-Location":`/threads/${U.thread_id}/runs/${W.run_id}`})}catch(X){return k(X)}}async function jQ(Z,Y){try{let X=await Z.json(),J=S(r1,X),Q=x.threads,$=[],K=J.map(async(W)=>{try{let z=FZ(W);z.config=z.config||{},z.config.configurable=z.config.configurable||{};let H=Y?.langgraph_context;if(H)Object.assign(z.config.configurable,H);let G=await Q.create({metadata:{...z.metadata,temporary:!0}});z.config.configurable.graph_id=W.assistant_id,z.config.configurable.thread_id=G.thread_id,z.temporary=!0;let F=await Q.createRun(G.thread_id,W.assistant_id,z);return(async()=>{let M=!1;try{for await(let N of F4(Q,F,z,{attempt:0,getGraph:cZ}));}catch(N){console.error("Batch run error:",N)}finally{try{await Q.delete(G.thread_id)}catch(N){console.error("Error cleaning up temporary thread:",N)}if(!M){M=!0;try{await dZ.globalMessageQueue.removeQueue(F.run_id)}catch(N){}}}})(),{thread_id:G.thread_id,run_id:F.run_id}}catch(z){return console.error("Batch run creation error:",z),{error:(z instanceof Error?z.message:"Unknown error")||"Unknown error"}}}),U=await Promise.all(K);return $.push(...U),m($,200)}catch(X){return k(X)}}async function SQ(Z,Y){try{let X=await Z.json(),J=S(n1,X),Q=new URL(Z.url),$=S(o1,{action:Q.searchParams.get("action")||"interrupt"}),K=x.threads,U=[];if("run_ids"in J&&J.run_ids)for(let W of J.run_ids)try{console.warn(`Cancel by run_id ${W} not fully implemented yet`)}catch(z){console.error(`Error cancelling run ${W}:`,z)}else if("thread_id"in J&&J.thread_id){let W=J.thread_id;try{let z=await K.listRuns(W,{limit:1000,offset:0});for(let H of z)try{x.runs.cancel(W,H.run_id,$.wait,$.action),U.push(H.run_id)}catch(G){console.error(`Error cancelling run ${H.run_id}:`,G)}}catch(z){console.error(`Error listing runs for thread ${W}:`,z)}}else if("status"in J&&J.status)console.warn(`Cancel by status ${J.status} not fully implemented yet`);return new Response(null,{status:204})}catch(X){return k(X)}}var yQ=[{method:"POST",pattern:/^\/assistants\/search$/,handler:a1},{method:"POST",pattern:/^\/assistants\/count$/,handler:s1},{method:"GET",pattern:/^\/assistants\/[^/]+$/,handler:t1},{method:"DELETE",pattern:/^\/assistants\/[^/]+$/,handler:e1},{method:"PATCH",pattern:/^\/assistants\/[^/]+$/,handler:ZQ},{method:"GET",pattern:/^\/assistants\/[^/]+\/graph$/,handler:YQ},{method:"GET",pattern:/^\/assistants\/[^/]+\/subgraphs$/,handler:XQ},{method:"GET",pattern:/^\/assistants\/[^/]+\/subgraphs\/[^/]+$/,handler:JQ},{method:"GET",pattern:/^\/assistants\/[^/]+\/schemas$/,handler:QQ},{method:"POST",pattern:/^\/assistants\/[^/]+\/versions$/,handler:$Q},{method:"POST",pattern:/^\/assistants\/[^/]+\/latest$/,handler:KQ},{method:"POST",pattern:/^\/assistants$/,handler:WQ},{method:"POST",pattern:/^\/threads$/,handler:UQ},{method:"POST",pattern:/^\/threads\/search$/,handler:zQ},{method:"POST",pattern:/^\/threads\/count$/,handler:HQ},{method:"GET",pattern:/^\/threads\/[^/]+$/,handler:GQ},{method:"PATCH",pattern:/^\/threads\/[^/]+$/,handler:OQ},{method:"DELETE",pattern:/^\/threads\/[^/]+$/,handler:qQ},{method:"GET",pattern:/^\/threads\/[^/]+\/state$/,handler:FQ},{method:"POST",pattern:/^\/threads\/[^/]+\/state$/,handler:MQ},{method:"POST",pattern:/^\/threads\/[^/]+\/state\/checkpoint$/,handler:NQ},{method:"GET",pattern:/^\/threads\/[^/]+\/history$/,handler:_Q},{method:"POST",pattern:/^\/threads\/[^/]+\/history$/,handler:AQ},{method:"POST",pattern:/^\/threads\/[^/]+\/copy$/,handler:wQ},{method:"GET",pattern:/^\/threads\/[^/]+\/stream$/,handler:BQ},{method:"POST",pattern:/^\/threads\/[^/]+\/runs$/,handler:IQ},{method:"POST",pattern:/^\/threads\/[^/]+\/runs\/stream$/,handler:LQ},{method:"POST",pattern:/^\/threads\/[^/]+\/runs\/wait$/,handler:vQ},{method:"POST",pattern:/^\/threads\/[^/]+\/runs\/[^/]+\/cancel$/,handler:CQ},{method:"GET",pattern:/^\/threads\/[^/]+\/runs$/,handler:RQ},{method:"GET",pattern:/^\/threads\/[^/]+\/runs\/[^/]+$/,handler:DQ},{method:"DELETE",pattern:/^\/threads\/[^/]+\/runs\/[^/]+$/,handler:VQ},{method:"GET",pattern:/^\/threads\/[^/]+\/runs\/[^/]+\/join$/,handler:EQ},{method:"GET",pattern:/^\/threads\/[^/]+\/runs\/[^/]+\/stream$/,handler:PQ},{method:"POST",pattern:/^\/runs$/,handler:bQ},{method:"POST",pattern:/^\/runs\/stream$/,handler:TQ},{method:"POST",pattern:/^\/runs\/wait$/,handler:fQ},{method:"POST",pattern:/^\/runs\/batch$/,handler:jQ},{method:"POST",pattern:/^\/runs\/cancel$/,handler:SQ}],kQ=(Z)=>{let Y=new URL(Z.url).pathname.toString(),X="";if(Y.includes("/threads"))X=Y.split("/threads")[0];else if(Y.includes("/assistants"))X=Y.split("/assistants")[0];return new Request(Z.url.replace(X,""),{method:Z.method,headers:Z.headers,body:Z.body,duplex:Z.duplex})};async function _8(Z,Y={}){Z=kQ(Z);try{await dZ.initGlobal();let J=new URL(Z.url).pathname,Q=Z.method;for(let $ of yQ)if($.method===Q&&$.pattern.test(J))return await $.handler(Z,Y);return new Response("Not Found",{status:404})}catch(X){return console.error("Request error:",X),k(X)}}import{execa as w8}from"execa";import hQ from"extract-zip";import xQ from"fs-extra";import*as A0 from"node:os";import{dirname as B8,join as gQ}from"node:path";import{pipeline as uQ}from"node:stream/promises";import{fileURLToPath as mQ}from"node:url";import{pathExists as A8}from"path-exists";import{temporaryFile as pQ}from"tempy";import{xdgCache as dQ}from"xdg-basedir";var{mkdir:tY,createWriteStream:cQ,move:lQ}=xQ,L8=B8(mQ(import.meta.url)),iQ="microsoft/ripgrep-prebuilt",sY=process.env.RIPGREP_VERSION||"v15.0.0",rQ=()=>{let Z=process.env.npm_config_arch||A0.arch(),Y=process.env.platform||A0.platform();switch(Y){case"darwin":switch(Z){case"arm64":return"aarch64-apple-darwin.tar.gz";default:return"x86_64-apple-darwin.tar.gz"}case"win32":switch(Z){case"x64":return"x86_64-pc-windows-msvc.zip";case"arm":return"aarch64-pc-windows-msvc.zip";default:return"i686-pc-windows-msvc.zip"}case"linux":switch(Z){case"x64":return"x86_64-unknown-linux-musl.tar.gz";case"arm":case"armv7l":return"arm-unknown-linux-gnueabihf.tar.gz";case"arm64":return"aarch64-unknown-linux-gnu.tar.gz";case"ppc64":return"powerpc64le-unknown-linux-gnu.tar.gz";case"s390x":return"s390x-unknown-linux-gnu.tar.gz";default:return"i686-unknown-linux-musl.tar.gz"}default:throw Error("Unknown platform: "+Y)}},oQ=async(Z,Y)=>{try{let X=pQ(),J=await fetch(Z);if(!J.ok)throw Error(`HTTP ${J.status}: ${J.statusText}`);await uQ(J.body,cQ(X)),await tY(B8(Y),{recursive:!0}),await lQ(X,Y)}catch(X){throw console.error(`Failed to download "${Z}"`),X}},nQ=async(Z,Y)=>{try{await tY(Y,{recursive:!0}),await hQ(Z,{dir:Y})}catch(X){throw console.error(`Failed to unzip "${Z}"`),X}},aQ=async(Z,Y)=>{try{await tY(Y,{recursive:!0}),await w8("tar",["xvf",Z,"-C",Y])}catch(X){throw console.error(`Failed to extract "${Z}"`),X}},sQ=async(Z)=>{if(Z==="android")try{return await w8("pkg",["install","ripgrep","-y"]),!0}catch(Y){return console.info("Could not install ripgrep via pkg. Falling back to download."),!1}return!1},tQ=gQ(L8,`rg${process.platform==="win32"?".exe":""}`),P8=async(Z)=>{if(await A8(tQ)){console.log("rg cached");return}let Y=process.env.platform||A0.platform();if(Y==="android"){if(await sQ(Y))return}let X=rQ(),Q=`${process.env.RIPGREP_PREBUILT_BINARIES_MIRROR||`https://v6.gh-proxy.org/https://github.com/${iQ}/releases/download`}/${sY}/ripgrep-${sY}-${X}`,$=`${dQ}/vscode-ripgrep/ripgrep-${sY}-${X}`,K=Z??L8;if(!await A8($))await oQ(Q,$);else console.info(`File ${$} has been cached`);if($.endsWith(".tar.gz"))await aQ($,K);else if($.endsWith(".zip"))await nQ($,K);else throw Error(`Invalid downloadPath ${$}`)};await P8();lY("code",R8);var C8=(Z,Y={})=>{return _8(new Request(Z,Y),{})};import eQ from"openai";import Z$ from"@anthropic-ai/sdk";import{GoogleGenerativeAI as Y$}from"@google/generative-ai";var X$=async()=>{if(!process.env.ANTHROPIC_API_KEY)return[];let Z=[];try{for await(let Y of new Z$().beta.models.list())Z.push({id:Y.id,name:Y.display_name,provider:"anthropic"})}catch(Y){console.error("Failed to fetch Anthropic models:",Y)}return Z},J$=async()=>{if(!process.env.OPENAI_API_KEY)return[];try{return await new eQ().models.list().then((Z)=>Z.data.map((Y)=>{return{id:Y.id,name:Y.id,provider:"openai"}}).sort((Y,X)=>Y.id.localeCompare(X.id)))}catch(Z){return console.error("Failed to fetch OpenAI models:",Z),[]}},Q$=async()=>{let Z=process.env.GEMINI_API_KEY;if(!Z)return[];let Y=[{id:"gemini-2.5-flash-preview-06-17",name:"Gemini 2.5 Flash Preview (06-17)",provider:"gemini"},{id:"gemini-2.5-pro-preview-06-05",name:"Gemini 2.5 Pro Preview (06-05)",provider:"gemini"},{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",provider:"gemini"},{id:"gemini-2.0-flash-lite",name:"Gemini 2.0 Flash Lite",provider:"gemini"},{id:"gemini-1.5-flash",name:"Gemini 1.5 Flash",provider:"gemini"},{id:"gemini-1.5-flash-8b",name:"Gemini 1.5 Flash 8B",provider:"gemini"},{id:"gemini-1.5-pro",name:"Gemini 1.5 Pro",provider:"gemini"},{id:"gemini-1.0-pro",name:"Gemini 1.0 Pro",provider:"gemini"},{id:"gemini-2.0-flash-exp",name:"Gemini 2.0 Flash Experimental",provider:"gemini"},{id:"gemini-exp-1206",name:"Gemini Experimental 1206",provider:"gemini"},{id:"gemini-2.5-pro-exp-03-25",name:"Gemini 2.5 Pro Experimental (03-25)",provider:"gemini"},{id:"gemini-2.5-flash-preview-05-20",name:"Gemini 2.5 Flash Preview (05-20)",provider:"gemini"}];try{return await new Y$(Z).getGenerativeModel({model:"gemini-1.5-flash"}),Y}catch(X){return console.error("Failed to verify Gemini API key:",X),[]}},I8=async()=>{return(await Promise.all([X$().catch(()=>[]),J$().catch(()=>[]),Q$().catch(()=>[])])).flat()};var i0=P(g(),1);function v8({tools:Z,setTools:Y}){let X=i0.useRef(!1);i0.useEffect(()=>{if(!X.current)Y(Z),X.current=!0},[Z,Y])}var V8=P(g(),1);function D8(Z){if(!Z)return{isValid:!1,needsSetup:!0,reason:"未找到配置文件"};if(!Z.providers||Z.providers.length===0)return{isValid:!1,needsSetup:!0,reason:"未配置任何 Provider"};let Y=Z.providers.find((X)=>X.id===Z.provider_id);if(!Y)return{isValid:!1,needsSetup:!0,reason:`Provider "${Z.provider_id}" 不存在`,invalidProviderRef:!0};if(!Y.apiKey||Y.apiKey.trim()==="")return{isValid:!1,needsSetup:!0,reason:`Provider "${Z.provider_id}" 未配置 API Key`,missingApiKey:!0};return{isValid:!0,needsSetup:!1}}function E8({config:Z}){return V8.useMemo(()=>{if(!Z)return{validation:null,needsSetup:!0,isValid:!1};let Y=D8(Z);return{validation:Y,needsSetup:Y.needsSetup,isValid:!Y.needsSetup}},[Z])}var b8=P(g(),1);function T8({shouldFocus:Z}){let Y=W4();b8.useEffect(()=>{if(Z)Y.focus("global-input")},[Z,Y])}var gZ=P(g(),1);function f8(){let[Z,Y]=gZ.useState("chat"),X=W4(),J=gZ.useCallback(()=>{Y("history")},[]),Q=gZ.useCallback(()=>{Y("knowledge")},[]),$=gZ.useCallback(()=>{Y("settings")},[]),K=gZ.useCallback(()=>{Y("model-provider")},[]),U=gZ.useCallback(()=>{Y("agent")},[]),W=gZ.useCallback(()=>{Y("task")},[]),z=gZ.useCallback(()=>{Y("mcp")},[]),H=gZ.useCallback(()=>{Y("process")},[]),G=gZ.useCallback(()=>{Y("chat"),X.focus("global-input")},[X]);return{activeView:Z,isChatView:Z==="chat",switchToHistory:J,switchToKnowledge:Q,switchToSettings:$,switchToModelProvider:K,switchToAgent:U,switchToTask:W,switchToMcp:z,switchToProcess:H,closePanel:G}}var r0=P(g(),1);function $$(Z){let Y=`# 任务:${Z.title}
7
+ `,{headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}})}catch(Y){return T(Y)}}async function S2($,Z){try{let Y=$1($.url,"/threads/:thread_id/runs/stream"),{thread_id:J}=y(q1,Y),X=await $.json(),K=y(iZ,X);return i$(o$(async(Q)=>{K.config=K.config||{},K.config.configurable=K.config.configurable||{};let W=Z?.langgraph_context;if(W)Object.assign(K.config.configurable,W);let _=null,O=!1,N=()=>{O=!0};Q.signal.addEventListener("abort",N);try{_=V.runs.stream(J,K.assistant_id,K1(K));for await(let{event:U,data:F}of _){if(O||Q.signal.aborted)break;await Q.writeSSE({data:x$(F)??"",event:U})}}catch(U){if(!Q.signal.aborted&&!O)throw U}finally{if(Q.signal.removeEventListener("abort",N),_){try{await _.return(void 0)}catch(U){}_=null}}}))}catch(Y){return T(Y)}}async function I2($,Z){try{let Y=$1($.url,"/threads/:thread_id/runs/:run_id/stream"),{thread_id:J,run_id:X}=y(s0,Y),K=j1($.url),{cancel_on_disconnect:Q,last_event_id:W,stream_mode:_}=y(nZ,K);return i$(o$(async(O)=>{let N=new AbortController,U=null,F=!1,L=[],q=()=>{N.abort("Client disconnected")};if($.signal)$.signal.addEventListener("abort",q),L.push({signal:$.signal,handler:q});let w=()=>{F=!0,N.abort("SSE stream closed")};O.signal.addEventListener("abort",w),L.push({signal:O.signal,handler:w});try{U=V.runs.joinStream(J,X,{signal:N.signal,cancelOnDisconnect:Q,lastEventId:W,streamMode:_?[_]:void 0});for await(let{event:R,data:P,id:S}of U){if(F||O.signal.aborted||N.signal.aborted)break;await O.writeSSE({data:x$(P)??"",event:R,id:S})}}catch(R){if(!(N.signal.aborted||O.signal.aborted)&&!(R instanceof Error&&R.message.includes("user cancel")))console.error("Join stream error:",R),await O.writeSSE({event:"error",data:JSON.stringify({error:R instanceof Error?R.message:"Unknown error"})})}finally{for(let{signal:R,handler:P}of L)try{R.removeEventListener("abort",P)}catch(S){}if(U){try{await U.return(void 0)}catch(R){}U=null}}}))}catch(Y){return T(Y)}}async function k2($,Z){try{let Y=$1($.url,"/threads/:thread_id/runs"),{thread_id:J}=y(q1,Y),X=j1($.url),{limit:K,offset:Q,status:W}=y(oZ,X),_=await V.runs.list(J,{limit:K,offset:Q,status:W});return h(_)}catch(Y){return T(Y)}}async function y2($,Z){try{let Y=$1($.url,"/threads/:thread_id/runs/:run_id/cancel"),{thread_id:J,run_id:X}=y(s0,Y),K=j1($.url),{wait:Q,action:W}=y(rZ,K),_=V.runs.cancel(J,X,Q,W);if(Q)await _;return new Response(null,{status:Q?204:202})}catch(Y){return T(Y)}}async function T2($,Z){try{let Y=$1($.url,"/threads/:thread_id/runs"),{thread_id:J}=y(q1,Y),X=await $.json(),K=y(c6,X),Q=K1(K);Q.config=Q.config||{},Q.config.configurable=Q.config.configurable||{};let W=Z?.langgraph_context;if(W)Object.assign(Q.config.configurable,W);Q.config.configurable.graph_id=K.assistant_id,Q.config.configurable.thread_id=J;let _=V.threads,O=await _.createRun(J,K.assistant_id,Q);return(async()=>{let N=!1;try{for await(let U of Y0(_,O,Q,{attempt:0,getGraph:V1}));}catch(U){console.error("Background run error:",U)}finally{if(!N){N=!0;try{await I1.globalMessageQueue.removeQueue(O.run_id)}catch(U){}}}})(),h(O,200,{"Content-Location":`/threads/${J}/runs/${O.run_id}`})}catch(Y){return T(Y)}}async function D2($,Z){try{let Y=$1($.url,"/threads/:thread_id/runs/wait"),{thread_id:J}=y(q1,Y),X=await $.json(),K=y(c6,X),Q=j1($.url),{cancel_on_disconnect:W}=y(tZ,Q),_=K1(K);_.config=_.config||{},_.config.configurable=_.config.configurable||{};let O=Z?.langgraph_context;if(O)Object.assign(_.config.configurable,O);_.config.configurable.graph_id=K.assistant_id,_.config.configurable.thread_id=J;let N=V.threads,U=await N.createRun(J,K.assistant_id,_),F={};for await(let{event:L,data:q}of Y0(N,U,_,{attempt:0,getGraph:V1}))if(L==="end"||L==="writes/value"){if(q&&typeof q==="object")Object.assign(F,q)}return h(F,200,{"Content-Location":`/threads/${J}/runs/${U.run_id}`})}catch(Y){return T(Y)}}async function V2($,Z){try{let Y=$1($.url,"/threads/:thread_id/runs/:run_id"),{thread_id:J,run_id:X}=y(s0,Y),Q=(await V.runs.list(J,{limit:1000})).find((W)=>W.run_id===X);if(!Q)return T(Error("Run not found"),404);return h(Q)}catch(Y){return T(Y)}}async function j2($,Z){try{let Y=$1($.url,"/threads/:thread_id/runs/:run_id"),{thread_id:J,run_id:X}=y(s0,Y);return await V.threads.updateRun(X,{status:"deleted"}),new Response(null,{status:204})}catch(Y){return T(Y)}}async function h2($,Z){try{let Y=$1($.url,"/threads/:thread_id/runs/:run_id/join"),{thread_id:J,run_id:X}=y(s0,Y),K=j1($.url),{cancel_on_disconnect:Q}=y(eZ,K),_=(await V.runs.list(J,{limit:1000})).find((U)=>U.run_id===X);if(!_)return T(Error("Run not found"),404);if(_.status==="success"||_.status==="error")return h({});let O=new AbortController;if(Q){let U=()=>{O.abort("Client disconnected")};$.signal?.addEventListener("abort",U)}let N={};for await(let{event:U,data:F}of V.runs.joinStream(J,X,{signal:O.signal,cancelOnDisconnect:Q}))if(U.event==="end"||U.event==="writes/value"){if(F&&typeof F==="object")Object.assign(N,F)}return h(N)}catch(Y){return T(Y)}}async function E2($,Z){try{let Y=await $.json(),J=y(O$,Y),X=K1(J);X.config=X.config||{},X.config.configurable=X.config.configurable||{};let K=Z?.langgraph_context;if(K)Object.assign(X.config.configurable,K);let Q=V.threads,W=await Q.create({metadata:{...X.metadata,temporary:!0}});X.config.configurable.graph_id=J.assistant_id,X.config.configurable.thread_id=W.thread_id,X.temporary=!0;let _=await Q.createRun(W.thread_id,J.assistant_id,X);return(async()=>{let O=!1;try{for await(let N of Y0(Q,_,X,{attempt:0,getGraph:V1}));}catch(N){console.error("Stateless run error:",N)}finally{try{await Q.delete(W.thread_id)}catch(N){console.error("Error cleaning up temporary thread:",N)}if(!O){O=!0;try{await I1.globalMessageQueue.removeQueue(_.run_id)}catch(N){}}}})(),h(_,200,{"Content-Location":`/threads/${W.thread_id}/runs/${_.run_id}`})}catch(Y){return T(Y)}}async function g2($,Z){try{let Y=await $.json(),J=y(O$,Y),X=K1(J);X.config=X.config||{},X.config.configurable=X.config.configurable||{};let K=Z?.langgraph_context;if(K)Object.assign(X.config.configurable,K);let Q=V.threads,W=await Q.create({metadata:{...X.metadata,temporary:!0}});X.config.configurable.graph_id=J.assistant_id,X.config.configurable.thread_id=W.thread_id,X.temporary=!0;let _=await Q.createRun(W.thread_id,J.assistant_id,X);return i$(o$(async(O)=>{try{for await(let N of Y0(Q,_,X,{attempt:0,getGraph:V1}))await O.writeSSE({data:JSON.stringify(N),event:"data"})}catch(N){if(N instanceof Error&&N.name!=="AbortError")throw console.error("Stream error:",N),N}finally{try{await Q.delete(W.thread_id)}catch(N){console.error("Error cleaning up temporary thread:",N)}}}))}catch(Y){return T(Y)}}async function p2($,Z){try{let Y=await $.json(),J=y(O$,Y),X=K1(J);X.config=X.config||{},X.config.configurable=X.config.configurable||{};let K=Z?.langgraph_context;if(K)Object.assign(X.config.configurable,K);let Q=V.threads,W=await Q.create({metadata:{...X.metadata,temporary:!0}});X.config.configurable.graph_id=J.assistant_id,X.config.configurable.thread_id=W.thread_id,X.temporary=!0;let _=await Q.createRun(W.thread_id,J.assistant_id,X),O={};try{for await(let{event:N,data:U}of Y0(Q,_,X,{attempt:0,getGraph:V1}))if(N==="end"||N==="writes/value"){if(U&&typeof U==="object")Object.assign(O,U)}}finally{try{await Q.delete(W.thread_id)}catch(N){console.error("Error cleaning up temporary thread:",N)}}return h(O,200,{"Content-Location":`/threads/${W.thread_id}/runs/${_.run_id}`})}catch(Y){return T(Y)}}async function m2($,Z){try{let Y=await $.json(),J=y($2,Y),X=V.threads,K=[],Q=J.map(async(_)=>{try{let O=K1(_);O.config=O.config||{},O.config.configurable=O.config.configurable||{};let N=Z?.langgraph_context;if(N)Object.assign(O.config.configurable,N);let U=await X.create({metadata:{...O.metadata,temporary:!0}});O.config.configurable.graph_id=_.assistant_id,O.config.configurable.thread_id=U.thread_id,O.temporary=!0;let F=await X.createRun(U.thread_id,_.assistant_id,O);return(async()=>{let L=!1;try{for await(let q of Y0(X,F,O,{attempt:0,getGraph:V1}));}catch(q){console.error("Batch run error:",q)}finally{try{await X.delete(U.thread_id)}catch(q){console.error("Error cleaning up temporary thread:",q)}if(!L){L=!0;try{await I1.globalMessageQueue.removeQueue(F.run_id)}catch(q){}}}})(),{thread_id:U.thread_id,run_id:F.run_id}}catch(O){return console.error("Batch run creation error:",O),{error:(O instanceof Error?O.message:"Unknown error")||"Unknown error"}}}),W=await Promise.all(Q);return K.push(...W),h(K,200)}catch(Y){return T(Y)}}async function c2($,Z){try{let Y=await $.json(),J=y(Y2,Y),X=new URL($.url),K=y(Z2,{action:X.searchParams.get("action")||"interrupt"}),Q=V.threads,W=[];if("run_ids"in J&&J.run_ids)for(let _ of J.run_ids)try{console.warn(`Cancel by run_id ${_} not fully implemented yet`)}catch(O){console.error(`Error cancelling run ${_}:`,O)}else if("thread_id"in J&&J.thread_id){let _=J.thread_id;try{let O=await Q.listRuns(_,{limit:1000,offset:0});for(let N of O)try{V.runs.cancel(_,N.run_id,K.wait,K.action),W.push(N.run_id)}catch(U){console.error(`Error cancelling run ${N.run_id}:`,U)}}catch(O){console.error(`Error listing runs for thread ${_}:`,O)}}else if("status"in J&&J.status)console.warn(`Cancel by status ${J.status} not fully implemented yet`);return new Response(null,{status:204})}catch(Y){return T(Y)}}var u2=[{method:"POST",pattern:/^\/assistants\/search$/,handler:X2},{method:"POST",pattern:/^\/assistants\/count$/,handler:J2},{method:"GET",pattern:/^\/assistants\/[^/]+$/,handler:K2},{method:"DELETE",pattern:/^\/assistants\/[^/]+$/,handler:Q2},{method:"PATCH",pattern:/^\/assistants\/[^/]+$/,handler:W2},{method:"GET",pattern:/^\/assistants\/[^/]+\/graph$/,handler:_2},{method:"GET",pattern:/^\/assistants\/[^/]+\/subgraphs$/,handler:G2},{method:"GET",pattern:/^\/assistants\/[^/]+\/subgraphs\/[^/]+$/,handler:O2},{method:"GET",pattern:/^\/assistants\/[^/]+\/schemas$/,handler:U2},{method:"POST",pattern:/^\/assistants\/[^/]+\/versions$/,handler:N2},{method:"POST",pattern:/^\/assistants\/[^/]+\/latest$/,handler:z2},{method:"POST",pattern:/^\/assistants$/,handler:H2},{method:"POST",pattern:/^\/threads$/,handler:F2},{method:"POST",pattern:/^\/threads\/search$/,handler:L2},{method:"POST",pattern:/^\/threads\/count$/,handler:A2},{method:"GET",pattern:/^\/threads\/[^/]+$/,handler:q2},{method:"PATCH",pattern:/^\/threads\/[^/]+$/,handler:w2},{method:"DELETE",pattern:/^\/threads\/[^/]+$/,handler:M2},{method:"GET",pattern:/^\/threads\/[^/]+\/state$/,handler:R2},{method:"POST",pattern:/^\/threads\/[^/]+\/state$/,handler:b2},{method:"POST",pattern:/^\/threads\/[^/]+\/state\/checkpoint$/,handler:B2},{method:"GET",pattern:/^\/threads\/[^/]+\/history$/,handler:P2},{method:"POST",pattern:/^\/threads\/[^/]+\/history$/,handler:f2},{method:"POST",pattern:/^\/threads\/[^/]+\/copy$/,handler:C2},{method:"GET",pattern:/^\/threads\/[^/]+\/stream$/,handler:v2},{method:"POST",pattern:/^\/threads\/[^/]+\/runs$/,handler:T2},{method:"POST",pattern:/^\/threads\/[^/]+\/runs\/stream$/,handler:S2},{method:"POST",pattern:/^\/threads\/[^/]+\/runs\/wait$/,handler:D2},{method:"POST",pattern:/^\/threads\/[^/]+\/runs\/[^/]+\/cancel$/,handler:y2},{method:"GET",pattern:/^\/threads\/[^/]+\/runs$/,handler:k2},{method:"GET",pattern:/^\/threads\/[^/]+\/runs\/[^/]+$/,handler:V2},{method:"DELETE",pattern:/^\/threads\/[^/]+\/runs\/[^/]+$/,handler:j2},{method:"GET",pattern:/^\/threads\/[^/]+\/runs\/[^/]+\/join$/,handler:h2},{method:"GET",pattern:/^\/threads\/[^/]+\/runs\/[^/]+\/stream$/,handler:I2},{method:"POST",pattern:/^\/runs$/,handler:E2},{method:"POST",pattern:/^\/runs\/stream$/,handler:g2},{method:"POST",pattern:/^\/runs\/wait$/,handler:p2},{method:"POST",pattern:/^\/runs\/batch$/,handler:m2},{method:"POST",pattern:/^\/runs\/cancel$/,handler:c2}],x2=($)=>{let Z=new URL($.url).pathname.toString(),Y="";if(Z.includes("/threads"))Y=Z.split("/threads")[0];else if(Z.includes("/assistants"))Y=Z.split("/assistants")[0];return new Request($.url.replace(Y,""),{method:$.method,headers:$.headers,body:$.body,duplex:$.duplex})};async function u6($,Z={}){$=x2($);try{await I1.initGlobal();let J=new URL($.url).pathname,X=$.method;for(let K of u2)if(K.method===X&&K.pattern.test(J))return await K.handler($,Z);return new Response("Not Found",{status:404})}catch(Y){return console.error("Request error:",Y),T(Y)}}import{execa as d6}from"execa";import d2 from"extract-zip";import l2 from"fs-extra";import*as t0 from"node:os";import{dirname as l6,join as i2}from"node:path";import{pipeline as o2}from"node:stream/promises";import{fileURLToPath as r2}from"node:url";import{pathExists as x6}from"path-exists";import{temporaryFile as n2}from"tempy";import{xdgCache as a2}from"xdg-basedir";var{mkdir:n$,createWriteStream:s2,move:t2}=l2,i6=l6(r2(import.meta.url)),e2="microsoft/ripgrep-prebuilt",r$=process.env.RIPGREP_VERSION||"v15.0.0",$8=()=>{let $=process.env.npm_config_arch||t0.arch(),Z=process.env.platform||t0.platform();switch(Z){case"darwin":switch($){case"arm64":return"aarch64-apple-darwin.tar.gz";default:return"x86_64-apple-darwin.tar.gz"}case"win32":switch($){case"x64":return"x86_64-pc-windows-msvc.zip";case"arm":return"aarch64-pc-windows-msvc.zip";default:return"i686-pc-windows-msvc.zip"}case"linux":switch($){case"x64":return"x86_64-unknown-linux-musl.tar.gz";case"arm":case"armv7l":return"arm-unknown-linux-gnueabihf.tar.gz";case"arm64":return"aarch64-unknown-linux-gnu.tar.gz";case"ppc64":return"powerpc64le-unknown-linux-gnu.tar.gz";case"s390x":return"s390x-unknown-linux-gnu.tar.gz";default:return"i686-unknown-linux-musl.tar.gz"}default:throw Error("Unknown platform: "+Z)}},Z8=async($,Z)=>{try{let Y=n2(),J=await fetch($);if(!J.ok)throw Error(`HTTP ${J.status}: ${J.statusText}`);await o2(J.body,s2(Y)),await n$(l6(Z),{recursive:!0}),await t2(Y,Z)}catch(Y){throw console.error(`Failed to download "${$}"`),Y}},Y8=async($,Z)=>{try{await n$(Z,{recursive:!0}),await d2($,{dir:Z})}catch(Y){throw console.error(`Failed to unzip "${$}"`),Y}},X8=async($,Z)=>{try{await n$(Z,{recursive:!0}),await d6("tar",["xvf",$,"-C",Z])}catch(Y){throw console.error(`Failed to extract "${$}"`),Y}},J8=async($)=>{if($==="android")try{return await d6("pkg",["install","ripgrep","-y"]),!0}catch(Z){return console.info("Could not install ripgrep via pkg. Falling back to download."),!1}return!1},K8=i2(i6,`rg${process.platform==="win32"?".exe":""}`),o6=async($)=>{if(await x6(K8)){console.log("rg cached");return}let Z=process.env.platform||t0.platform();if(Z==="android"){if(await J8(Z))return}let Y=$8(),X=`${process.env.RIPGREP_PREBUILT_BINARIES_MIRROR||`https://v6.gh-proxy.org/https://github.com/${e2}/releases/download`}/${r$}/ripgrep-${r$}-${Y}`,K=`${a2}/vscode-ripgrep/ripgrep-${r$}-${Y}`,Q=$??i6;if(!await x6(K))await Z8(X,K);else console.info(`File ${K} has been cached`);if(K.endsWith(".tar.gz"))await X8(K,Q);else if(K.endsWith(".zip"))await Y8(K,Q);else throw Error(`Invalid downloadPath ${K}`)};await o6();u$("code",r6);var n6=($,Z={})=>{return u6(new Request($,Z),{})};import Q8 from"openai";import W8 from"@anthropic-ai/sdk";import{GoogleGenerativeAI as _8}from"@google/generative-ai";var G8=async()=>{if(!process.env.ANTHROPIC_API_KEY)return[];let $=[];try{for await(let Z of new W8().beta.models.list())$.push({id:Z.id,name:Z.display_name,provider:"anthropic"})}catch(Z){console.error("Failed to fetch Anthropic models:",Z)}return $},O8=async()=>{if(!process.env.OPENAI_API_KEY)return[];try{return await new Q8().models.list().then(($)=>$.data.map((Z)=>{return{id:Z.id,name:Z.id,provider:"openai"}}).sort((Z,Y)=>Z.id.localeCompare(Y.id)))}catch($){return console.error("Failed to fetch OpenAI models:",$),[]}},U8=async()=>{let $=process.env.GEMINI_API_KEY;if(!$)return[];let Z=[{id:"gemini-2.5-flash-preview-06-17",name:"Gemini 2.5 Flash Preview (06-17)",provider:"gemini"},{id:"gemini-2.5-pro-preview-06-05",name:"Gemini 2.5 Pro Preview (06-05)",provider:"gemini"},{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash",provider:"gemini"},{id:"gemini-2.0-flash-lite",name:"Gemini 2.0 Flash Lite",provider:"gemini"},{id:"gemini-1.5-flash",name:"Gemini 1.5 Flash",provider:"gemini"},{id:"gemini-1.5-flash-8b",name:"Gemini 1.5 Flash 8B",provider:"gemini"},{id:"gemini-1.5-pro",name:"Gemini 1.5 Pro",provider:"gemini"},{id:"gemini-1.0-pro",name:"Gemini 1.0 Pro",provider:"gemini"},{id:"gemini-2.0-flash-exp",name:"Gemini 2.0 Flash Experimental",provider:"gemini"},{id:"gemini-exp-1206",name:"Gemini Experimental 1206",provider:"gemini"},{id:"gemini-2.5-pro-exp-03-25",name:"Gemini 2.5 Pro Experimental (03-25)",provider:"gemini"},{id:"gemini-2.5-flash-preview-05-20",name:"Gemini 2.5 Flash Preview (05-20)",provider:"gemini"}];try{return await new _8($).getGenerativeModel({model:"gemini-1.5-flash"}),Z}catch(Y){return console.error("Failed to verify Gemini API key:",Y),[]}},a6=async()=>{return(await Promise.all([G8().catch(()=>[]),O8().catch(()=>[]),U8().catch(()=>[])])).flat()};var N$=A(D(),1);function s6({tools:$,setTools:Z}){let Y=N$.useRef(!1);N$.useEffect(()=>{if(!Y.current)Z($),Y.current=!0},[$,Z])}var e6=A(D(),1);function t6($){if(!$)return{isValid:!1,needsSetup:!0,reason:"未找到配置文件"};if(!$.providers||$.providers.length===0)return{isValid:!1,needsSetup:!0,reason:"未配置任何 Provider"};let Z=$.providers.find((Y)=>Y.id===$.provider_id);if(!Z)return{isValid:!1,needsSetup:!0,reason:`Provider "${$.provider_id}" 不存在`,invalidProviderRef:!0};if(!Z.apiKey||Z.apiKey.trim()==="")return{isValid:!1,needsSetup:!0,reason:`Provider "${$.provider_id}" 未配置 API Key`,missingApiKey:!0};return{isValid:!0,needsSetup:!1}}function $4({config:$}){return e6.useMemo(()=>{if(!$)return{validation:null,needsSetup:!0,isValid:!1};let Z=t6($);return{validation:Z,needsSetup:Z.needsSetup,isValid:!Z.needsSetup}},[$])}var Z4=A(D(),1);function Y4({shouldFocus:$}){let Z=o1();Z4.useEffect(()=>{if($)Z.focus("global-input")},[$,Z])}var b1=A(D(),1);function X4(){let[$,Z]=b1.useState("chat"),Y=o1(),J=b1.useCallback(()=>{Z("history")},[]),X=b1.useCallback(()=>{Z("knowledge")},[]),K=b1.useCallback(()=>{Z("settings")},[]),Q=b1.useCallback(()=>{Z("model-provider")},[]),W=b1.useCallback(()=>{Z("agent")},[]),_=b1.useCallback(()=>{Z("task")},[]),O=b1.useCallback(()=>{Z("mcp")},[]),N=b1.useCallback(()=>{Z("process")},[]),U=b1.useCallback(()=>{Z("errors")},[]),F=b1.useCallback(()=>{Z("chat"),Y.focus("global-input")},[Y]);return{activeView:$,isChatView:$==="chat",switchToHistory:J,switchToKnowledge:X,switchToSettings:K,switchToModelProvider:Q,switchToAgent:W,switchToTask:_,switchToMcp:O,switchToProcess:N,switchToErrors:U,closePanel:F}}var z$=A(D(),1);function N8($){let Z=`# 任务:${$.title}
8
8
 
9
- `;if(Y+=`**描述:**
10
- ${Z.description}
9
+ `;if(Z+=`**描述:**
10
+ ${$.description}
11
11
 
12
- `,Z.agentType)Y+=`**建议 Agent 类型:** ${Z.agentType}
12
+ `,$.agentType)Z+=`**建议 Agent 类型:** ${$.agentType}
13
13
 
14
- `;if(Z.estimatedTime)Y+=`**预估时间:** ${Z.estimatedTime}
14
+ `;if($.estimatedTime)Z+=`**预估时间:** ${$.estimatedTime}
15
15
 
16
- `;if(Z.complexity)Y+=`**复杂度:** ${Z.complexity}
16
+ `;if($.complexity)Z+=`**复杂度:** ${$.complexity}
17
17
 
18
- `;if(Z.dependencies&&Z.dependencies.length>0)Y+=`**依赖任务:**
19
- ${Z.dependencies.map((X)=>`- ${X}`).join(`
18
+ `;if($.dependencies&&$.dependencies.length>0)Z+=`**依赖任务:**
19
+ ${$.dependencies.map((Y)=>`- ${Y}`).join(`
20
20
  `)}
21
21
 
22
- `;if(Z.acceptanceCriteria&&Z.acceptanceCriteria.length>0)Y+=`**验收标准:**
23
- ${Z.acceptanceCriteria.map((X,J)=>`${J+1}. ${X}`).join(`
22
+ `;if($.acceptanceCriteria&&$.acceptanceCriteria.length>0)Z+=`**验收标准:**
23
+ ${$.acceptanceCriteria.map((Y,J)=>`${J+1}. ${Y}`).join(`
24
24
  `)}
25
25
 
26
- `;if(Z.children&&Z.children.length>0)Y+=`**子任务:**
27
- `,Z.children.forEach((X,J)=>{if(Y+=`
28
- ### 子任务 ${J+1}: ${X.title}
29
- `,Y+=`${X.description}
30
- `,X.acceptanceCriteria&&X.acceptanceCriteria.length>0)Y+=`验收标准:
31
- ${X.acceptanceCriteria.map((Q)=>`- ${Q}`).join(`
26
+ `;if($.children&&$.children.length>0)Z+=`**子任务:**
27
+ `,$.children.forEach((Y,J)=>{if(Z+=`
28
+ ### 子任务 ${J+1}: ${Y.title}
29
+ `,Z+=`${Y.description}
30
+ `,Y.acceptanceCriteria&&Y.acceptanceCriteria.length>0)Z+=`验收标准:
31
+ ${Y.acceptanceCriteria.map((X)=>`- ${X}`).join(`
32
32
  `)}
33
- `}),Y+=`
34
- `;return Y.trim()}function j8(Z){let{sendMessage:Y,createNewChat:X}=WZ(),{extraParams:J}=UZ(),{closePanel:Q}=Z,$=r0.useMemo(()=>{return{...J,is_in_task:!0}},[J]);return{handleExecuteTask:r0.useCallback((U)=>{let z=[{type:"human",content:`${$$(U)}
33
+ `}),Z+=`
34
+ `;return Z.trim()}function J4($){let{sendMessage:Z,createNewChat:Y}=Z1(),{extraParams:J}=t(),{closePanel:X}=$,K=z$.useMemo(()=>{return{...J,is_in_task:!0}},[J]);return{handleExecuteTask:z$.useCallback((W)=>{let O=[{type:"human",content:`${N8(W)}
35
35
 
36
- 请你先写一个 TODO LIST 然后开始这个任务,最后完成任务的时候,使用 commit_task`}];X(U4).then(()=>{return Y(z,{extraParams:$,metadata:U4})}).then(()=>{N4("任务已发送给 Agent"),Q()}).catch((H)=>{console.error("Task execution failed:",H),N4("任务执行失败")})},[Y,X,$,Q])}}var o0=P(g(),1),k8=P(I(),1),S8=o0.createContext(void 0),X0=()=>{let Z=o0.useContext(S8);if(Z===void 0)throw Error("useChatPanel must be used within ChatPanelProvider. Make sure your component is a child of ChatController.");return Z},y8=({children:Z,value:Y})=>{return k8.jsxDEV(S8.Provider,{value:Y,children:Z},void 0,!1,void 0,this)};var p4=P(g(),1);var h8=(Z)=>{return Z.additional_kwargs?.reasoning_content||Array.isArray(Z.content)&&Z.content.find((Y)=>Y.type==="thinking")?.thinking},J0=(Z)=>{return typeof Z.content==="string"?Z.content:Z.content?.filter((Y)=>{return Y.type==="text"}).map((Y)=>Y.text).join("")};n0();var ZX=P(g(),1),s=P(I(),1),F$={approve:"green",reject:"red",edit:"yellow",modify:"cyan"},M$=(Z)=>{return F$[Z.toLowerCase()]||"white"},u8=({request:Z,allowedDecisions:Y=["approve","edit","reject"],onApprove:X,onEdit:J,onReject:Q,autoFocus:$=!0})=>{let[K,U]=ZX.useState("approve"),{value:W,setTrue:z,setFalse:H}=g8(!1),[G,F]=ZX.useState(""),M=W4(),N=Z.messageIndex,w=Z.description;uZ((V,d)=>{if(W&&d.escape)B()},{isActive:W});let L=()=>{if(!G.trim())return;if(K==="edit")try{let V=JSON.parse(G);J(V)}catch(V){console.error("Invalid JSON:",V);return}else{let V=`User rejected to run this tool, reason: ${G}`;Q(V)}H(),F("")},B=()=>{H(),F("")},C=([V])=>{if(V==="approve"){X(),M.focus("global-input");return}if(U(V),z(),V==="edit")F(JSON.stringify(Z.toolCall.args,null,2));else F("")},R=Y.map((V)=>({label:V,value:V}));return W?(()=>{let V=M$(K),d=K==="edit";return s.jsxDEV(_,{flexDirection:"column",paddingX:1,marginTop:0,children:[s.jsxDEV(_,{flexDirection:"column",marginBottom:1,children:[s.jsxDEV(O,{color:V,bold:!0,children:[K.toUpperCase()," MODE - ",Z.toolCall.name]},void 0,!0,void 0,this),N!==void 0&&s.jsxDEV(O,{color:"gray",dimColor:!0,children:["Message Index: ",N]},void 0,!0,void 0,this),w&&s.jsxDEV(O,{color:"gray",dimColor:!0,children:["Description: ",w]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),d?s.jsxDEV(_,{flexDirection:"column",marginTop:0,children:[s.jsxDEV(O,{color:"yellow",dimColor:!0,children:"Editing action arguments (JSON format):"},void 0,!1,void 0,this),s.jsxDEV(_,{paddingX:1,children:s.jsxDEV(iZ,{value:G,onChange:F,onSubmit:L,placeholder:"Enter JSON...",autoFocus:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):s.jsxDEV(_,{flexDirection:"column",marginTop:0,children:[s.jsxDEV(O,{color:"cyan",dimColor:!0,children:"Enter additional message for this action:"},void 0,!1,void 0,this),s.jsxDEV(_,{padding:1,children:s.jsxDEV(iZ,{value:G,onChange:F,onSubmit:L,placeholder:"Enter message...",autoFocus:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),s.jsxDEV(_,{marginTop:0,children:s.jsxDEV(O,{color:"gray",children:[s.jsxDEV(O,{color:V,bold:!0,children:"↵"},void 0,!1,void 0,this)," ","Submit |",s.jsxDEV(O,{color:"red",bold:!0,children:[" ","Esc"]},void 0,!0,void 0,this)," ","Cancel"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)})():(()=>s.jsxDEV(_,{flexDirection:"column",paddingX:1,children:[s.jsxDEV(_,{flexDirection:"column",marginBottom:1,children:[s.jsxDEV(O,{color:"cyan",bold:!0,children:Z.toolCall.name},void 0,!1,void 0,this),N!==void 0&&s.jsxDEV(O,{color:"gray",dimColor:!0,children:["Message Index: ",N]},void 0,!0,void 0,this),w&&s.jsxDEV(O,{color:"gray",dimColor:!0,children:["Description: ",w]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),s.jsxDEV(_,{children:s.jsxDEV(u4,{singleSelect:!0,options:R,onSubmit:C,autoFocus:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this))()};var a0=P(g(),1),m8=P(I(),1),YX={type:"approval",render(Z,Y){let{content:X,metadata:J}=Z,Q=W4(),$=a0.useCallback(()=>{Y({state:"submitted",result:{status:"approved"}}),Q.focus("global-input")},[Y,Q]),K=a0.useCallback((z)=>{Y({state:"edited",result:{status:"edited",editedArgs:z}}),Q.focus("global-input")},[Y,Q]),U=a0.useCallback((z)=>{Y({state:"cancelled",result:{status:"rejected",message:z}}),Q.focus("global-input")},[Y,Q]),W={id:Z.id,toolCall:X.toolCall,status:Z.state==="submitted"?"approved":Z.state==="edited"?"edited":Z.state==="cancelled"?"rejected":"pending",createdAt:Z.createdAt,messageIndex:J.messageIndex,description:J.description};return m8.jsxDEV(u8,{request:W,allowedDecisions:["approve","edit","reject"],onApprove:$,onEdit:K,onReject:U,autoFocus:!0},Z.id,!1,void 0,this)},defaultConfig:{layout:{border:!1,padding:0},interaction:{autoSubmit:!1,allowSkip:!1}}};var XX=P(g(),1);var N$={title:{maxWidth:60,ellipsis:"…"},description:{maxWidth:80,ellipsis:"…"},optionLabel:{maxWidth:50,ellipsis:"…"},tabLabel:{maxWidth:30,ellipsis:"…"},fullTitle:{maxWidth:80,ellipsis:"…"}},_$=(Z,Y=20,X="…")=>{if(!Z)return"";if(Z.length<=Y)return Z;return Z.substring(0,Y-X.length)+X},Q0=(Z,Y)=>{let X=N$[Y];return _$(Z,X.maxWidth,X.ellipsis)};var _4=P(I(),1),A$=(Z)=>{return Q0(Z,"optionLabel")},JX={type:"selection",render(Z,Y){let{content:X,metadata:J,result:Q}=Z,[$,K]=XX.useState(Q?.selected||[]),[U,W]=XX.useState(Q?.customInput||""),z=X.options.map((L)=>({label:A$(L.label),value:L.value})),H=(L,B)=>{Y({result:{selected:L??$,customInput:B??U}})},G=(L)=>{K(L),H(L,void 0)},F=(L)=>{W(L),H(void 0,L)},M=()=>{Y({state:"submitted",result:{selected:$,customInput:U}})},N=J?.title?Q0(J.title,"title"):null,w=J?.description?Q0(J.description,"description"):null;return _4.jsxDEV(_,{flexDirection:"column",paddingX:1,children:[N&&_4.jsxDEV(_,{marginBottom:1,children:_4.jsxDEV(O,{color:"cyan",bold:!0,children:N},void 0,!1,void 0,this)},void 0,!1,void 0,this),w&&_4.jsxDEV(_,{marginBottom:1,children:_4.jsxDEV(O,{dimColor:!0,children:w},void 0,!1,void 0,this)},void 0,!1,void 0,this),_4.jsxDEV(u4,{options:z,singleSelect:X.singleSelect,values:$,onChange:G,onSubmit:M,autoFocus:!0},void 0,!1,void 0,this),X.allowCustomInput&&_4.jsxDEV(_,{marginTop:1,flexDirection:"column",children:_4.jsxDEV(iZ,{value:U,onChange:F,onSubmit:M,placeholder:X.placeholder||"Type custom option...",autoFocus:!1},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},validate(Z){if(Z.options.length===0)return"At least one option is required";if(Z.singleSelect&&Z.maxSelections&&Z.maxSelections>1)return"Single select cannot have maxSelections > 1";return},defaultConfig:{layout:{border:!0,padding:1},interaction:{autoSubmit:!1}}};var p8=P(g(),1);var z4=P(I(),1),QX={type:"input",render(Z,Y){let{content:X,metadata:J}=Z,[Q,$]=p8.useState(X.defaultValue||""),K=()=>{Y({state:"submitted",result:{value:Q}})};return z4.jsxDEV(_,{flexDirection:"column",paddingX:1,children:[J?.title&&z4.jsxDEV(_,{marginBottom:1,children:z4.jsxDEV(O,{color:"cyan",bold:!0,children:J.title},void 0,!1,void 0,this)},void 0,!1,void 0,this),J?.description&&z4.jsxDEV(_,{marginBottom:1,children:z4.jsxDEV(O,{dimColor:!0,children:J.description},void 0,!1,void 0,this)},void 0,!1,void 0,this),z4.jsxDEV(_,{children:[z4.jsxDEV(iZ,{value:Q,onChange:$,onSubmit:K,placeholder:X.placeholder,autoFocus:!0},void 0,!1,void 0,this),")"]},void 0,!0,void 0,this),X.maxLength&&z4.jsxDEV(_,{marginTop:1,children:z4.jsxDEV(O,{dimColor:!0,children:["Max length: ",X.maxLength]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},validate(Z){if(Z.validation?.pattern&&Z.defaultValue){if(!Z.validation.pattern.test(Z.defaultValue))return"Input does not match required pattern"}if(Z.validation?.minLength&&Z.defaultValue&&Z.defaultValue.length<Z.validation.minLength)return`Input must be at least ${Z.validation.minLength} characters`;return},defaultConfig:{layout:{border:!0,padding:1},interaction:{autoSubmit:!1}}};var m4=P(I(),1),$X={type:"confirm",render(Z,Y){let{content:X,metadata:J}=Z,Q=()=>{Y({state:"submitted",result:{confirmed:!0}})},$=()=>{Y({state:"cancelled",result:{confirmed:!1}})},K=[{label:X.confirmLabel||"Confirm",value:"confirm"},{label:X.cancelLabel||"Cancel",value:"cancel"}],U=([W])=>{if(W==="confirm")Q();else $()};return m4.jsxDEV(_,{flexDirection:"column",paddingX:1,children:[J?.title&&m4.jsxDEV(_,{marginBottom:1,children:m4.jsxDEV(O,{color:X.danger?"red":"cyan",bold:!0,children:J.title},void 0,!1,void 0,this)},void 0,!1,void 0,this),m4.jsxDEV(_,{marginBottom:1,children:m4.jsxDEV(O,{children:X.message},void 0,!1,void 0,this)},void 0,!1,void 0,this),m4.jsxDEV(u4,{options:K,singleSelect:!0,onSubmit:U,autoFocus:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},defaultConfig:{layout:{border:!0,padding:1},interaction:{autoSubmit:!1}}};var w$=P(g(),1);var B$=P(I(),1);var H4=P(g(),1);var $0=P(g(),1);var zZ=P(I(),1),c8=({items:Z,defaultIndex:Y=0,onChange:X,disabled:J=!1,autoFocus:Q=!0,variant:$="line"})=>{let{isFocused:K}=d8({autoFocus:Q}),[U,W]=$0.useState(Y),z=$0.default.useMemo(()=>`tabs-${Math.random().toString(36).substring(2,9)}`,[]),H=$0.useCallback((M)=>{if(M<0||M>=Z.length||Z[M].disabled)return;W(M),X?.(M,Z[M])},[Z,X]);uZ((M,N)=>{if(J)return;if(N.leftArrow)H(U-1);else if(N.rightArrow)H(U+1)},{isActive:!J});let G=()=>{return Z.map((M,N)=>{let w=N===U,L=K&&!J,B;if($==="line")B=zZ.jsxDEV(_,{marginRight:1,children:[zZ.jsxDEV(O,{color:M.disabled?"gray":w?L?"green":"cyan":"gray",bold:w&&L,children:M.label},void 0,!1,void 0,this),w&&zZ.jsxDEV(O,{color:L?"green":"cyan",children:"_"},void 0,!1,void 0,this)]},`${z}-${M.id}`,!0,void 0,this);else if($==="enclosed"){let C=N===0||w?"┌":"─",R=N===Z.length-1||w?"┐":"─",D=N===0||w?"│":" ",f=N===Z.length-1||w?"│":" ",V=w?"─":" ",d=w?" ":"",l=M.disabled?"gray":w?L?"green":"cyan":"gray";B=zZ.jsxDEV(_,{children:zZ.jsxDEV(_,{flexDirection:"column",children:[zZ.jsxDEV(_,{children:[zZ.jsxDEV(O,{color:l,children:C},void 0,!1,void 0,this),zZ.jsxDEV(O,{color:l,bold:w&&L,children:[d,M.label,d]},void 0,!0,void 0,this),zZ.jsxDEV(O,{color:l,children:R},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w&&zZ.jsxDEV(_,{children:[zZ.jsxDEV(O,{color:l,children:D},void 0,!1,void 0,this),zZ.jsxDEV(O,{color:l,children:V.repeat(M.label.length+2)},void 0,!1,void 0,this),zZ.jsxDEV(O,{color:l,children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},`${z}-${M.id}`,!1,void 0,this)}else{let C=w?"●":"○";B=zZ.jsxDEV(_,{marginRight:2,children:zZ.jsxDEV(O,{color:M.disabled?"gray":w?L?"green":"cyan":"gray",bold:w&&L,children:[C," ",M.label]},void 0,!0,void 0,this)},`${z}-${M.id}`,!1,void 0,this)}return B})},F=()=>{let M=Z[U];if(!M?.content)return null;return zZ.jsxDEV(_,{marginTop:1,paddingX:2,paddingY:1,flexDirection:"column",children:M.content},void 0,!1,void 0,this)};return zZ.jsxDEV(_,{flexDirection:"column",flexGrow:1,children:[zZ.jsxDEV(_,{children:G()},void 0,!1,void 0,this),Z.some((M)=>M.content)&&F()]},void 0,!0,void 0,this)};var l8=P(g(),1);var i8=P(I(),1),KX=({interaction:Z,renderer:Y,onChange:X})=>{let J=l8.useMemo(()=>{return{layout:{border:!1,padding:0,...Y.defaultConfig?.layout,...Z.config.layout},interaction:{autoSubmit:!1,allowSkip:!1,showPreview:!0,...Y.defaultConfig?.interaction,...Z.config.interaction},style:{...Y.defaultConfig?.style,...Z.config.style}}},[Z.config,Y.defaultConfig]),Q=J.style.backgroundColor;return i8.jsxDEV(_,{backgroundColor:Q,paddingX:J.layout.padding,marginBottom:1,flexDirection:"column",children:Y.render({...Z,config:J},X)},void 0,!1,void 0,this)};n0();var A4=P(I(),1),L$=(Z)=>{return Q0(Z,"fullTitle")},WX=()=>{let Z=xZ(),[Y,X]=H4.useState(null),{focusNext:J,focus:Q}=W4(),$=H4.useMemo(()=>{return Z.getInteractions()},[Z.getInteractions()]);H4.useEffect(()=>{if($.length>0&&!Y)X($[0].id)},[$,Y]);let K=H4.useMemo(()=>{return $.map((G)=>{let F={idle:"\uD83D\uDD04",active:"\uD83D\uDD04",submitted:"✅",edited:"⛔",cancelled:"\uD83D\uDEAB"}[G.state]||"",M=L$(G.metadata.title||G.content.type);return{id:G.id,label:`${F} ${M}`,content:null}})},[$]),U=H4.useCallback((G,F)=>{X(F.id)},[]),W=H4.useCallback((G)=>{if($.every((w)=>w.state==="submitted"||w.state==="edited"||w.state==="cancelled")){Q("global-input");return}let N=($.findIndex((w)=>w.id===G)+1)%$.length;X($[N].id)},[$,Q]),z=r8(()=>{J()});TZ(z,Y?100:null);let H=()=>{if(!Y)return null;let G=$.find((M)=>M.id===Y);if(!G)return null;let F=D4.get(G.content.type);if(!F)return A4.jsxDEV(_,{paddingX:1,children:A4.jsxDEV(O,{color:"red",children:["Unknown renderer: ",G.content.type]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return A4.jsxDEV(KX,{interaction:G,renderer:F,onChange:(M)=>{if(Z.updateInteraction(G.id,M),M.state==="submitted"||M.state==="edited"||M.state==="cancelled")W(G.id)}},G.id,!1,void 0,this)};if($.length===0)return null;return A4.jsxDEV(_,{flexDirection:"column",borderColor:"cyan",borderStyle:"single",width:"100%",children:[A4.jsxDEV(_,{justifyContent:"space-between",paddingX:1,marginBottom:1,children:A4.jsxDEV(O,{color:"cyan",bold:!0,children:["Interactions (",$.length,")"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),A4.jsxDEV(_,{paddingX:1,marginBottom:1,children:A4.jsxDEV(c8,{items:K,defaultIndex:K.findIndex((G)=>G.id===Y),onChange:U,autoFocus:!0,variant:"line"},Y,!1,void 0,this)},void 0,!1,void 0,this),H()]},void 0,!0,void 0,this)};n0();function o8(){D4.register("approval",YX),D4.register("selection",JX),D4.register("input",QX),D4.register("confirm",$X)}o8();var K0=P(I(),1);import{z as V4}from"zod";var P$=V4.object({label:V4.string().min(1).max(50).describe("选项显示文本,简洁明了(1-50 字符)")}),R$=V4.object({description:V4.string().min(1).describe("向用户提出的问题,清晰具体,包含必要的上下文"),type:V4.enum(["single_select","multi_select"]).describe("选择类型:single_select(单选)或 multi_select(多选)"),options:V4.array(P$).min(2).max(6).describe("选项列表,至少 2 个,最多 6 个"),allow_custom_input:V4.boolean().default(!0).describe("是否允许用户输入自定义文本,默认 true"),placeholder:V4.string().optional().describe("自定义输入框的占位符文本")}),C$=({tool:Z})=>{let{addInteraction:Y,getInteractions:X,updateInteraction:J}=xZ(),[Q,$]=p4.useState(null),K=p4.useRef(!1),U=Z.getInputRepaired();if(p4.useEffect(()=>{if(Z.state==="interrupted"&&!Q&&!K.current){let z={type:"selection",options:U.options?.map((G,F)=>({label:G.label,value:G.label}))||[],singleSelect:U.type==="single_select",allowCustomInput:U.allow_custom_input??!0,placeholder:U.placeholder},H=Y(z,{tool:Z,metadata:{title:U.description||"请选择一个选项",groupKey:"user-input"}});$(H.id)}},[Z,Q,Y,U]),p4.useEffect(()=>{if(!Q||K.current)return;let W=()=>{let G=X().find((F)=>F.id===Q);if(G&&(G.state==="submitted"||G.state==="edited"||G.state==="cancelled")&&!G.resultSent){K.current=!0;let F=G.result,M="";if(F){if(F.selected&&F.selected.length>0)M+=`User selected:
36
+ 请你先写一个 TODO LIST 然后开始这个任务,最后完成任务的时候,使用 commit_task`}];Y(r1).then(()=>{return Z(O,{extraParams:K,metadata:r1})}).then(()=>{J0("任务已发送给 Agent"),X()}).catch((N)=>{console.error("Task execution failed:",N),J0("任务执行失败")})},[Z,Y,K,X])}}var H$=A(D(),1),W4=A(M(),1),K4=H$.createContext(void 0),E0=()=>{let $=H$.useContext(K4);if($===void 0)throw Error("useChatPanel must be used within ChatPanelProvider. Make sure your component is a child of ChatController.");return $},Q4=({children:$,value:Z})=>{return W4.jsxDEV(K4.Provider,{value:Z,children:$},void 0,!1,void 0,this)};var C0=A(D(),1);var _4=($)=>{return $.additional_kwargs?.reasoning_content||Array.isArray($.content)&&$.content.find((Z)=>Z.type==="thinking")?.thinking},g0=($)=>{return typeof $.content==="string"?$.content:$.content?.filter((Z)=>{return Z.type==="text"}).map((Z)=>Z.text).join("")};F$();var s$=A(D(),1),d=A(M(),1),R8={approve:"green",reject:"red",edit:"yellow",modify:"cyan"},b8=($)=>{return R8[$.toLowerCase()]||"white"},U4=({request:$,allowedDecisions:Z=["approve","edit","reject"],onApprove:Y,onEdit:J,onReject:X,autoFocus:K=!0})=>{let[Q,W]=s$.useState("approve"),{value:_,setTrue:O,setFalse:N}=O4(!1),[U,F]=s$.useState(""),L=o1(),q=$.messageIndex,w=$.description;y1((v,i)=>{if(_&&i.escape)P()},{isActive:_});let R=()=>{if(!U.trim())return;if(Q==="edit")try{let v=JSON.parse(U);J(v)}catch(v){console.error("Invalid JSON:",v);return}else{let v=`User rejected to run this tool, reason: ${U}`;X(v)}N(),F("")},P=()=>{N(),F("")},S=([v])=>{if(v==="approve"){Y(),L.focus("global-input");return}if(W(v),O(),v==="edit")F(JSON.stringify($.toolCall.args,null,2));else F("")},u=Z.map((v)=>({label:v,value:v}));return _?(()=>{let v=b8(Q),i=Q==="edit";return d.jsxDEV(z,{flexDirection:"column",paddingX:1,marginTop:0,children:[d.jsxDEV(z,{flexDirection:"column",marginBottom:1,children:[d.jsxDEV(G,{color:v,bold:!0,children:[Q.toUpperCase()," MODE - ",$.toolCall.name]},void 0,!0,void 0,this),q!==void 0&&d.jsxDEV(G,{color:"gray",dimColor:!0,children:["Message Index: ",q]},void 0,!0,void 0,this),w&&d.jsxDEV(G,{color:"gray",dimColor:!0,children:["Description: ",w]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),i?d.jsxDEV(z,{flexDirection:"column",marginTop:0,children:[d.jsxDEV(G,{color:"yellow",dimColor:!0,children:"Editing action arguments (JSON format):"},void 0,!1,void 0,this),d.jsxDEV(z,{paddingX:1,children:d.jsxDEV(h1,{value:U,onChange:F,onSubmit:R,placeholder:"Enter JSON...",autoFocus:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):d.jsxDEV(z,{flexDirection:"column",marginTop:0,children:[d.jsxDEV(G,{color:"cyan",dimColor:!0,children:"Enter additional message for this action:"},void 0,!1,void 0,this),d.jsxDEV(z,{padding:1,children:d.jsxDEV(h1,{value:U,onChange:F,onSubmit:R,placeholder:"Enter message...",autoFocus:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),d.jsxDEV(z,{marginTop:0,children:d.jsxDEV(G,{color:"gray",children:[d.jsxDEV(G,{color:v,bold:!0,children:"↵"},void 0,!1,void 0,this)," ","Submit |",d.jsxDEV(G,{color:"red",bold:!0,children:[" ","Esc"]},void 0,!0,void 0,this)," ","Cancel"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)})():(()=>d.jsxDEV(z,{flexDirection:"column",paddingX:1,children:[d.jsxDEV(z,{flexDirection:"column",marginBottom:1,children:[d.jsxDEV(G,{color:"cyan",bold:!0,children:$.toolCall.name},void 0,!1,void 0,this),q!==void 0&&d.jsxDEV(G,{color:"gray",dimColor:!0,children:["Message Index: ",q]},void 0,!0,void 0,this),w&&d.jsxDEV(G,{color:"gray",dimColor:!0,children:["Description: ",w]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),d.jsxDEV(z,{children:d.jsxDEV(P0,{singleSelect:!0,options:u,onSubmit:S,autoFocus:K},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this))()};var L$=A(D(),1),N4=A(M(),1),t$={type:"approval",render($,Z){let{content:Y,metadata:J}=$,X=o1(),K=L$.useCallback(()=>{Z({state:"submitted",result:{status:"approved"}}),X.focus("global-input")},[Z,X]),Q=L$.useCallback((O)=>{Z({state:"edited",result:{status:"edited",editedArgs:O}}),X.focus("global-input")},[Z,X]),W=L$.useCallback((O)=>{Z({state:"cancelled",result:{status:"rejected",message:O}}),X.focus("global-input")},[Z,X]),_={id:$.id,toolCall:Y.toolCall,status:$.state==="submitted"?"approved":$.state==="edited"?"edited":$.state==="cancelled"?"rejected":"pending",createdAt:$.createdAt,messageIndex:J.messageIndex,description:J.description};return N4.jsxDEV(U4,{request:_,allowedDecisions:["approve","edit","reject"],onApprove:K,onEdit:Q,onReject:W,autoFocus:!0},$.id,!1,void 0,this)},defaultConfig:{layout:{border:!1,padding:0},interaction:{autoSubmit:!1,allowSkip:!1}}};var e$=A(D(),1);var B8={title:{maxWidth:60,ellipsis:"…"},description:{maxWidth:80,ellipsis:"…"},optionLabel:{maxWidth:50,ellipsis:"…"},tabLabel:{maxWidth:30,ellipsis:"…"},fullTitle:{maxWidth:80,ellipsis:"…"}},P8=($,Z=20,Y="…")=>{if(!$)return"";if($.length<=Z)return $;return $.substring(0,Z-Y.length)+Y},p0=($,Z)=>{let Y=B8[Z];return P8($,Y.maxWidth,Y.ellipsis)};var K0=A(M(),1),f8=($)=>{return p0($,"optionLabel")},$6={type:"selection",render($,Z){let{content:Y,metadata:J,result:X}=$,[K,Q]=e$.useState(X?.selected||[]),[W,_]=e$.useState(X?.customInput||""),O=Y.options.map((R)=>({label:f8(R.label),value:R.value})),N=(R,P)=>{Z({result:{selected:R??K,customInput:P??W}})},U=(R)=>{Q(R),N(R,void 0)},F=(R)=>{_(R),N(void 0,R)},L=()=>{Z({state:"submitted",result:{selected:K,customInput:W}})},q=J?.title?p0(J.title,"title"):null,w=J?.description?p0(J.description,"description"):null;return K0.jsxDEV(z,{flexDirection:"column",paddingX:1,children:[q&&K0.jsxDEV(z,{marginBottom:1,children:K0.jsxDEV(G,{color:"cyan",bold:!0,children:q},void 0,!1,void 0,this)},void 0,!1,void 0,this),w&&K0.jsxDEV(z,{marginBottom:1,children:K0.jsxDEV(G,{dimColor:!0,children:w},void 0,!1,void 0,this)},void 0,!1,void 0,this),K0.jsxDEV(P0,{options:O,singleSelect:Y.singleSelect,values:K,onChange:U,onSubmit:L,autoFocus:!0},void 0,!1,void 0,this),Y.allowCustomInput&&K0.jsxDEV(z,{marginTop:1,flexDirection:"column",children:K0.jsxDEV(h1,{value:W,onChange:F,onSubmit:L,placeholder:Y.placeholder||"Type custom option...",autoFocus:!1},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},validate($){if($.options.length===0)return"At least one option is required";if($.singleSelect&&$.maxSelections&&$.maxSelections>1)return"Single select cannot have maxSelections > 1";return},defaultConfig:{layout:{border:!1,padding:1},interaction:{autoSubmit:!1}}};var z4=A(D(),1);var n1=A(M(),1),Z6={type:"input",render($,Z){let{content:Y,metadata:J}=$,[X,K]=z4.useState(Y.defaultValue||""),Q=()=>{Z({state:"submitted",result:{value:X}})};return n1.jsxDEV(z,{flexDirection:"column",paddingX:1,children:[J?.title&&n1.jsxDEV(z,{marginBottom:1,children:n1.jsxDEV(G,{color:"cyan",bold:!0,children:J.title},void 0,!1,void 0,this)},void 0,!1,void 0,this),J?.description&&n1.jsxDEV(z,{marginBottom:1,children:n1.jsxDEV(G,{dimColor:!0,children:J.description},void 0,!1,void 0,this)},void 0,!1,void 0,this),n1.jsxDEV(z,{children:[n1.jsxDEV(h1,{value:X,onChange:K,onSubmit:Q,placeholder:Y.placeholder,autoFocus:!0},void 0,!1,void 0,this),")"]},void 0,!0,void 0,this),Y.maxLength&&n1.jsxDEV(z,{marginTop:1,children:n1.jsxDEV(G,{dimColor:!0,children:["Max length: ",Y.maxLength]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},validate($){if($.validation?.pattern&&$.defaultValue){if(!$.validation.pattern.test($.defaultValue))return"Input does not match required pattern"}if($.validation?.minLength&&$.defaultValue&&$.defaultValue.length<$.validation.minLength)return`Input must be at least ${$.validation.minLength} characters`;return},defaultConfig:{layout:{border:!1,padding:1},interaction:{autoSubmit:!1}}};var f0=A(M(),1),Y6={type:"confirm",render($,Z){let{content:Y,metadata:J}=$,X=()=>{Z({state:"submitted",result:{confirmed:!0}})},K=()=>{Z({state:"cancelled",result:{confirmed:!1}})},Q=[{label:Y.confirmLabel||"Confirm",value:"confirm"},{label:Y.cancelLabel||"Cancel",value:"cancel"}],W=([_])=>{if(_==="confirm")X();else K()};return f0.jsxDEV(z,{flexDirection:"column",paddingX:1,children:[J?.title&&f0.jsxDEV(z,{marginBottom:1,children:f0.jsxDEV(G,{color:Y.danger?"red":"cyan",bold:!0,children:J.title},void 0,!1,void 0,this)},void 0,!1,void 0,this),f0.jsxDEV(z,{marginBottom:1,children:f0.jsxDEV(G,{children:Y.message},void 0,!1,void 0,this)},void 0,!1,void 0,this),f0.jsxDEV(P0,{options:Q,singleSelect:!0,onSubmit:W,autoFocus:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},defaultConfig:{layout:{border:!1,padding:1},interaction:{autoSubmit:!1}}};var C8=A(D(),1);var v8=A(M(),1);var a1=A(D(),1);var m0=A(D(),1);var Y1=A(M(),1),F4=({items:$,defaultIndex:Z=0,onChange:Y,disabled:J=!1,autoFocus:X=!0,variant:K="line"})=>{let{isFocused:Q}=H4({autoFocus:X}),[W,_]=m0.useState(Z),O=m0.default.useMemo(()=>`tabs-${Math.random().toString(36).substring(2,9)}`,[]),N=m0.useCallback((L)=>{if(L<0||L>=$.length||$[L].disabled)return;_(L),Y?.(L,$[L])},[$,Y]);y1((L,q)=>{if(J)return;if(q.leftArrow)N(W-1);else if(q.rightArrow)N(W+1)},{isActive:!J});let U=()=>{return $.map((L,q)=>{let w=q===W,R=Q&&!J,P;if(K==="line")P=Y1.jsxDEV(z,{marginRight:1,children:[Y1.jsxDEV(G,{color:L.disabled?"gray":w?R?"green":"cyan":"gray",bold:w&&R,children:L.label},void 0,!1,void 0,this),w&&Y1.jsxDEV(G,{color:R?"green":"cyan",children:"_"},void 0,!1,void 0,this)]},`${O}-${L.id}`,!0,void 0,this);else if(K==="enclosed"){let S=q===0||w?"┌":"─",u=q===$.length-1||w?"┐":"─",m=q===0||w?"│":" ",e=q===$.length-1||w?"│":" ",v=w?"─":" ",i=w?" ":"",r=L.disabled?"gray":w?R?"green":"cyan":"gray";P=Y1.jsxDEV(z,{children:Y1.jsxDEV(z,{flexDirection:"column",children:[Y1.jsxDEV(z,{children:[Y1.jsxDEV(G,{color:r,children:S},void 0,!1,void 0,this),Y1.jsxDEV(G,{color:r,bold:w&&R,children:[i,L.label,i]},void 0,!0,void 0,this),Y1.jsxDEV(G,{color:r,children:u},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w&&Y1.jsxDEV(z,{children:[Y1.jsxDEV(G,{color:r,children:m},void 0,!1,void 0,this),Y1.jsxDEV(G,{color:r,children:v.repeat(L.label.length+2)},void 0,!1,void 0,this),Y1.jsxDEV(G,{color:r,children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},`${O}-${L.id}`,!1,void 0,this)}else{let S=w?"●":"○";P=Y1.jsxDEV(z,{marginRight:2,children:Y1.jsxDEV(G,{color:L.disabled?"gray":w?R?"green":"cyan":"gray",bold:w&&R,children:[S," ",L.label]},void 0,!0,void 0,this)},`${O}-${L.id}`,!1,void 0,this)}return P})},F=()=>{let L=$[W];if(!L?.content)return null;return Y1.jsxDEV(z,{marginTop:1,paddingX:2,paddingY:1,flexDirection:"column",children:L.content},void 0,!1,void 0,this)};return Y1.jsxDEV(z,{flexDirection:"column",flexGrow:1,children:[Y1.jsxDEV(z,{children:U()},void 0,!1,void 0,this),$.some((L)=>L.content)&&F()]},void 0,!0,void 0,this)};var L4=A(D(),1);var A4=A(M(),1),X6=({interaction:$,renderer:Z,onChange:Y})=>{let J=L4.useMemo(()=>{return{layout:{border:!1,padding:0,...Z.defaultConfig?.layout,...$.config.layout},interaction:{autoSubmit:!1,allowSkip:!1,showPreview:!0,...Z.defaultConfig?.interaction,...$.config.interaction},style:{...Z.defaultConfig?.style,...$.config.style}}},[$.config,Z.defaultConfig]),X=J.style.backgroundColor;return A4.jsxDEV(z,{backgroundColor:X,paddingX:J.layout.padding,marginBottom:1,flexDirection:"column",children:Z.render({...$,config:J},Y)},void 0,!1,void 0,this)};F$();var Q0=A(M(),1),S8=($)=>{return p0($,"fullTitle")},J6=()=>{let $=k1(),[Z,Y]=a1.useState(null),{focusNext:J,focus:X}=o1(),K=a1.useMemo(()=>{return $.getInteractions()},[$.getInteractions()]);a1.useEffect(()=>{if(K.length>0&&!Z)Y(K[0].id)},[K,Z]);let Q=a1.useMemo(()=>{return K.map((U)=>{let F={idle:"\uD83D\uDD04",active:"\uD83D\uDD04",submitted:"✅",edited:"⛔",cancelled:"\uD83D\uDEAB"}[U.state]||"",L=S8(U.metadata.title||U.content.type);return{id:U.id,label:`${F} ${L}`,content:null}})},[K]),W=a1.useCallback((U,F)=>{Y(F.id)},[]),_=a1.useCallback((U)=>{if(K.every((w)=>w.state==="submitted"||w.state==="edited"||w.state==="cancelled")){X("global-input");return}let q=(K.findIndex((w)=>w.id===U)+1)%K.length;Y(K[q].id)},[K,X]),O=q4(()=>{J()});B1(O,Z?100:null);let N=()=>{if(!Z)return null;let U=K.find((L)=>L.id===Z);if(!U)return null;let F=A0.get(U.content.type);if(!F)return Q0.jsxDEV(z,{paddingX:1,children:Q0.jsxDEV(G,{color:"red",children:["Unknown renderer: ",U.content.type]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return Q0.jsxDEV(X6,{interaction:U,renderer:F,onChange:(L)=>{if($.updateInteraction(U.id,L),L.state==="submitted"||L.state==="edited"||L.state==="cancelled")_(U.id)}},U.id,!1,void 0,this)};if(K.length===0)return null;return Q0.jsxDEV(z,{flexDirection:"column",width:"100%",children:[Q0.jsxDEV(z,{justifyContent:"space-between",paddingX:1,marginBottom:1,children:Q0.jsxDEV(G,{color:"cyan",bold:!0,children:["Interactions (",K.length,")"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Q0.jsxDEV(z,{paddingX:1,marginBottom:1,children:Q0.jsxDEV(F4,{items:Q,defaultIndex:Q.findIndex((U)=>U.id===Z),onChange:W,autoFocus:!0,variant:"line"},Z,!1,void 0,this)},void 0,!1,void 0,this),N()]},void 0,!0,void 0,this)};F$();function w4(){A0.register("approval",t$),A0.register("selection",$6),A0.register("input",Z6),A0.register("confirm",Y6)}w4();var c0=A(M(),1);import{z as q0}from"zod";var I8=q0.object({label:q0.string().min(1).max(50).describe("选项显示文本,简洁明了(1-50 字符)")}),k8=q0.object({description:q0.string().min(1).describe("向用户提出的问题,清晰具体,包含必要的上下文"),type:q0.enum(["single_select","multi_select"]).describe("选择类型:single_select(单选)或 multi_select(多选)"),options:q0.array(I8).min(2).max(6).describe("选项列表,至少 2 个,最多 6 个"),allow_custom_input:q0.boolean().default(!0).describe("是否允许用户输入自定义文本,默认 true"),placeholder:q0.string().optional().describe("自定义输入框的占位符文本")}),y8=({tool:$})=>{let{addInteraction:Z,getInteractions:Y,updateInteraction:J}=k1(),[X,K]=C0.useState(null),Q=C0.useRef(!1),W=$.getInputRepaired();if(C0.useEffect(()=>{if($.state==="interrupted"&&!X&&!Q.current){let O=(Array.isArray(W.options)?W.options:[]).map((L)=>{let q=L&&typeof L==="object"&&typeof L.label==="string"?L.label:String(L??"");return{label:q,value:q}}),N=W.type==="single_select",U={type:"selection",options:O,singleSelect:N,allowCustomInput:typeof W.allow_custom_input==="boolean"?W.allow_custom_input:!0,placeholder:typeof W.placeholder==="string"?W.placeholder:void 0},F=Z(U,{tool:$,metadata:{title:typeof W.description==="string"&&W.description?W.description:"请选择一个选项",groupKey:"user-input"}});K(F.id)}},[$,X,Z,W]),C0.useEffect(()=>{if(!X||Q.current)return;let _=()=>{let U=Y().find((F)=>F.id===X);if(U&&(U.state==="submitted"||U.state==="edited"||U.state==="cancelled")&&!U.resultSent){Q.current=!0;let F=U.result,L="";if(F){if(F.selected&&F.selected.length>0)L+=`User selected:
37
37
  ${F.selected.join(`
38
- - `)}`;if(F.customInput&&F.customInput.trim())M+=(M?`
39
- `:"")+`User Custom Input: ${F.customInput}`}Z.sendResumeData({type:"respond",message:M||"User made a selection"}),J(Q,{resultSent:!0})}};W();let z=setInterval(W,100);return()=>clearInterval(z)},[Q,X,J,Z]),Z.state==="interrupted"&&!Z.output)return K0.jsxDEV(_,{flexDirection:"column",children:K0.jsxDEV(_,{paddingX:1,children:K0.jsxDEV(O,{color:"yellow",children:"⏳ 等待用户选择..."},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(Z.output)return K0.jsxDEV(O,{color:"yellow",children:Z.output},void 0,!1,void 0,this);return null},n8=t({name:"ask_user_questions",description:"Ask the user a question with selectable options",parameters:R$,handler:ZZ.waitForUIDone,render(Z){return K0.jsxDEV(C$,{tool:Z},void 0,!1,void 0,this)}});var d4=P(g(),1);var w0=P(I(),1),W0=({content:Z,maxLines:Y=10,borderColor:X="cyan",borderStyle:J="single",marginTop:Q=0,paddingX:$=0,showOmittedInfo:K=!0})=>{if(!Z)return null;let{width:U}=a8(),W=Z.split(`
40
- `).map((G)=>G.slice(0,U-10)),z=Math.max(0,W.length-Y),H=W.slice(-Y).join(`
41
- `);return w0.jsxDEV(_,{flexDirection:"column",width:U-5,children:w0.jsxDEV(_,{borderStyle:J,borderColor:X,borderLeft:!1,borderRight:!1,flexDirection:"column",paddingX:$,marginTop:Q,children:[K&&z>0&&w0.jsxDEV(O,{color:"gray",dimColor:!0,children:["... ",z," lines omitted ..."]},void 0,!0,void 0,this),w0.jsxDEV(O,{dimColor:!0,children:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)};var VZ=P(I(),1),I$=({tool:Z})=>{let{addInteraction:Y,getInteractions:X,updateInteraction:J}=xZ(),[Q,$]=d4.useState(null),K=d4.useRef(!1),U=Z.getHumanInTheLoopData();if(d4.useEffect(()=>{if(U?.reviewConfig&&Z.state==="interrupted"&&!Q&&!K.current){let z=Z.getInputRepaired()?.description,H={type:"approval",toolCall:{name:Z.message.name,args:Z.getInputRepaired()},editableFields:["args"]},G=Y(H,{tool:Z,metadata:{title:`Approve ${Z.message.name}`,description:z,groupKey:"approvals"}});$(G.id)}},[U,Z,Q,Y]),d4.useEffect(()=>{if(!Q||K.current)return;let z=()=>{let F=X().find((M)=>M.id===Q);if(F&&(F.state==="submitted"||F.state==="edited"||F.state==="cancelled")&&!F.resultSent){K.current=!0;let M=F.result;if(M){if(M.status==="approved")Z.sendResumeData({type:"approve"});else if(M.status==="edited"){let N={name:Z.message.name,args:M.editedArgs};Z.sendResumeData({type:"edit",edited_action:N})}else if(M.status==="rejected"){let N=M.message||"User rejected to run this tool";Z.sendResumeData({type:"reject",message:N})}}J(Q,{resultSent:!0})}};z();let H=setInterval(z,100);return()=>clearInterval(H)},[Q,X,J,Z]),U?.reviewConfig&&Q&&!Z.output)return VZ.jsxDEV(_,{flexDirection:"column",children:VZ.jsxDEV(_,{paddingX:1,paddingY:1,children:VZ.jsxDEV(O,{color:"yellow",children:"⏳ Wait for Approval"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return VZ.jsxDEV(_,{flexDirection:"column",children:(()=>{if(!Z.output)return null;return VZ.jsxDEV(W0,{content:Z.output,maxLines:5,borderColor:"cyan"},void 0,!1,void 0,this)})()},void 0,!1,void 0,this)},v$=({tool:Z})=>{let X=Z.getInputRepaired()?.command||"",J=X.length>50?X.substring(0,50)+"...":X;return VZ.jsxDEV(_,{paddingX:1,children:[VZ.jsxDEV(O,{color:"magenta",children:"Run "},void 0,!1,void 0,this),VZ.jsxDEV(O,{dimColor:!0,children:"("},void 0,!1,void 0,this),VZ.jsxDEV(O,{color:"magenta",children:J},void 0,!1,void 0,this),VZ.jsxDEV(O,{dimColor:!0,children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},s8=t({name:"terminal",description:"",parameters:{},handler:ZZ.waitForUIDone,render(Z){return VZ.jsxDEV(_,{flexDirection:"column",children:[VZ.jsxDEV(v$,{tool:Z},void 0,!1,void 0,this),VZ.jsxDEV(I$,{tool:Z},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}});import{diff_match_patch as D$}from"diff-match-patch";function V$(Z,Y,X){if(Z===Y)return[{type:"unchanged",content:Z,lineNumbers:{old:1,new:1}}];let J=new D$,Q=J.diff_main(Z,Y);J.diff_cleanupSemantic(Q);let $=[],K=1,U=1,W=[];for(let[L,B]of Q){if(B==="")continue;let C=B.split(`
42
- `),R=B.endsWith(`
43
- `);for(let D=0;D<C.length;D++){let f=C[D];if(f===""&&(D<C.length-1||!R))continue;let V={type:L===0?"unchanged":L===-1?"added":"removed",content:f};if(L===0)V.lineNumbers={old:K,new:U},K++,U++;else if(L===-1)V.lineNumbers={new:U},U++;else if(L===1)V.lineNumbers={old:K},K++;W.push(V)}}if(!X?.maxLines)return W;let z=X.maxLines,H=X.contextLines||3,G=W.map((L,B)=>L.type!=="unchanged"?B:-1).filter((L)=>L!==-1);if(G.length===0||W.length<=z)return W;let F=[],M=0,N=[],w=[];for(let L=0;L<G.length;L++)if(w.length===0)w.push(G[L]);else{let B=w[w.length-1];if(G[L]-B<=1)w.push(G[L]);else N.push([...w]),w=[G[L]]}if(w.length>0)N.push(w);for(let L of N){if(M>=z)break;let B=L[0],C=L[L.length-1],R=Math.max(0,B-H),D=Math.min(W.length-1,C+H),f=D-R+1;if(M+f>z&&M>0){F.push({type:"unchanged",content:"..."});break}for(let V=R;V<=D;V++){if(M>=z){if(V<D)F.push({type:"unchanged",content:"..."});break}F.push(W[V]),M++}if(L===N[N.length-1]&&M<W.length){let V=W.length-D-1;if(V>0)F.push({type:"unchanged",content:`... (${V} more lines)`})}}return F}function t8(Z,Y=1000){return Z=Z||"",Z.length>Y||Z.split(`
44
- `).length>50}function e8(Z,Y,X){let J=t8(Z)||t8(Y),$=X!==void 0&&"maxLines"in X?X.maxLines:J?10:20,K=X?.contextLines??(J?1:3);return V$(Z,Y,{maxLines:$,contextLines:K})}var U0=P(I(),1),E$=["sky","primary"];function b$(Z){let Y=Z%2;return c4(E$[Y])}function T$(Z){let Y=[];if(Z.startsWith("/"))Y.push({type:"separator",value:"/"}),Z=Z.slice(1);let X=Z.split("/");return X.forEach((J,Q)=>{if(J)Y.push({type:"segment",value:J});if(Q<X.length-1)Y.push({type:"separator",value:"/"})}),Y}var f$=({path:Z,color:Y="cyan",line:X,rainbow:J=!1})=>{let Q=Z5(Z)??"",$=X!==void 0?`:${X}`:"";if(!J)return U0.jsxDEV(O,{color:c4(Y),children:[Q,$]},void 0,!0,void 0,this);let K=T$(Q),U=-1;for(let z=K.length-1;z>=0;z--)if(K[z].type==="segment"){U=z;break}let W=0;return U0.jsxDEV(O,{children:[K.map((z,H)=>{if(z.type==="separator")return U0.jsxDEV(O,{dimColor:!0,color:"gray",children:z.value},`sep-${H}`,!1,void 0,this);let G=H===U,F=b$(W);return W++,U0.jsxDEV(O,{color:F,dimColor:!G,children:z.value},`seg-${H}`,!1,void 0,this)}),$&&U0.jsxDEV(O,{color:"gray",children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},fZ=f$;var HZ=P(I(),1),j$=Y5.schema,X5=t({name:"edit_file",description:"Performs exact string replacements in files with diff visualization",parameters:j$.shape,handler:ZZ.waitForUIDone,render(Z){let Y=Z.getInputRepaired(),X=Z.output,J=Y.old_string&&Y.new_string&&Y.old_string!==Y.new_string,Q=0,$=0;if(J){let K=e8(Y.old_string,Y.new_string,{maxLines:void 0});for(let U of K){if(U.type==="removed")Q++;if(U.type==="added")$++}}return HZ.jsxDEV(_,{flexDirection:"column",paddingX:1,children:[HZ.jsxDEV(_,{children:[HZ.jsxDEV(O,{color:"yellow",children:"Edit "},void 0,!1,void 0,this),HZ.jsxDEV(O,{dimColor:!0,children:"("},void 0,!1,void 0,this),HZ.jsxDEV(fZ,{path:Y.file_path,rainbow:!0},void 0,!1,void 0,this),HZ.jsxDEV(O,{dimColor:!0,children:")"},void 0,!1,void 0,this),J&&HZ.jsxDEV(HZ.Fragment,{children:[HZ.jsxDEV(O,{color:"gray",children:" ("},void 0,!1,void 0,this),HZ.jsxDEV(O,{color:"red",children:["-",Q]},void 0,!0,void 0,this),HZ.jsxDEV(O,{color:"gray",children:"/"},void 0,!1,void 0,this),HZ.jsxDEV(O,{color:"green",children:["+",$]},void 0,!0,void 0,this),HZ.jsxDEV(O,{color:"gray",children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),X&&X.startsWith("Error:")&&HZ.jsxDEV(_,{marginTop:0,marginLeft:1,marginBottom:1,children:HZ.jsxDEV(O,{color:"red",children:X},void 0,!1,void 0,this)},void 0,!1,void 0,this),!X&&HZ.jsxDEV(_,{marginTop:0,children:HZ.jsxDEV(O,{color:"gray",children:"Press Enter to confirm, Ctrl+C to cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}});var rZ=P(I(),1),S$={pending:"gray",in_progress:"yellow",completed:"green"},y$={pending:"○",in_progress:"◐",completed:"✓"},Q5=t({name:"todo_write",description:"Use this tool to create and manage a structured task list",parameters:J5.shape,handler:ZZ.waitForUIDone,render(Z){let Y=Z.getInputRepaired();if(!Y||!Y.todos||!Array.isArray(Y.todos))return rZ.jsxDEV(_,{flexDirection:"column",borderStyle:"round",borderColor:"red",children:rZ.jsxDEV(O,{color:"red",children:"Error: Invalid todo data structure"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let X=Y.todos;return rZ.jsxDEV(_,{flexDirection:"column",paddingY:1,children:rZ.jsxDEV(_,{flexDirection:"column",marginTop:0,children:(()=>{if(X.length===0)return rZ.jsxDEV(_,{paddingX:1,children:rZ.jsxDEV(O,{color:"gray",children:"No tasks in todo list"},void 0,!1,void 0,this)},void 0,!1,void 0,this);return rZ.jsxDEV(_,{flexDirection:"column",marginTop:0,children:X.map((Q,$)=>rZ.jsxDEV(_,{paddingX:1,paddingY:0,children:[rZ.jsxDEV(O,{color:S$[Q.status],bold:!0,children:[y$[Q.status]," "]},void 0,!0,void 0,this),rZ.jsxDEV(O,{color:Q.status==="in_progress"?"white":"gray",children:[$+1,". ",Q.content]},void 0,!0,void 0,this)]},Q.id,!0,void 0,this))},void 0,!1,void 0,this)})()},void 0,!1,void 0,this)},void 0,!1,void 0,this)}});var oZ=P(I(),1),k$=$5.schema,K5=t({name:"read_file",description:"Reads a file from the local filesystem",parameters:k$.shape,handler:ZZ.waitForUIDone,render(Z){let Y=Z.getInputRepaired(),X=Z.output;if(!X)return oZ.jsxDEV(oZ.Fragment,{},void 0,!1,void 0,this);let Q=X.split(`
45
- `).length;return oZ.jsxDEV(_,{flexDirection:"column",paddingX:1,children:oZ.jsxDEV(_,{children:[oZ.jsxDEV(O,{color:"blue",children:"Read "},void 0,!1,void 0,this),oZ.jsxDEV(O,{dimColor:!0,children:"("},void 0,!1,void 0,this),oZ.jsxDEV(fZ,{path:Y.file_path,rainbow:!0},void 0,!1,void 0,this),oZ.jsxDEV(O,{dimColor:!0,children:")"},void 0,!1,void 0,this),oZ.jsxDEV(O,{color:"gray",dimColor:!0,children:[" ","(",Q," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}});var nZ=P(I(),1),h$=W5.schema,U5=t({name:"glob_files",description:"Find files by name patterns",parameters:h$.shape,handler:ZZ.waitForUIDone,render(Z){let Y=Z.getInputRepaired(),X=Z.output;if(!X)return nZ.jsxDEV(nZ.Fragment,{},void 0,!1,void 0,this);let Q=X.split(`
46
- `).filter(Boolean).length;return nZ.jsxDEV(_,{flexDirection:"column",paddingX:1,children:nZ.jsxDEV(O,{children:[nZ.jsxDEV(O,{color:"cyan",children:"Glob "},void 0,!1,void 0,this),nZ.jsxDEV(O,{dimColor:!0,children:"("},void 0,!1,void 0,this),nZ.jsxDEV(fZ,{path:Y.pattern,rainbow:!0},void 0,!1,void 0,this),nZ.jsxDEV(O,{dimColor:!0,children:")"},void 0,!1,void 0,this),nZ.jsxDEV(O,{color:"gray",dimColor:!0,children:[" ","(",Q," files)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}});var _Z=P(I(),1),z5=t({name:"search_files_rg",description:"Ripgrep - fast text search tool",parameters:{},handler:ZZ.waitForUIDone,render(Z){let Y=Z.getInputRepaired(),X=Z.output;if(!X)return _Z.jsxDEV(_Z.Fragment,{},void 0,!1,void 0,this);let Q=X.split(`
47
- `).filter(Boolean).length,$=Y.pattern,K=Y.path;if(!$){let W=(Y.args||[]).filter((z)=>!z.startsWith("-"));if(W.length>0){if(K=W[W.length-1],W.length>1)$=W[W.length-2]}}return _Z.jsxDEV(_,{flexDirection:"column",paddingX:1,children:_Z.jsxDEV(O,{children:[_Z.jsxDEV(O,{color:"magenta",children:"Ripgrep "},void 0,!1,void 0,this),$&&_Z.jsxDEV(_Z.Fragment,{children:[_Z.jsxDEV(O,{dimColor:!0,children:"("},void 0,!1,void 0,this),_Z.jsxDEV(fZ,{path:$,color:"magenta"},void 0,!1,void 0,this),_Z.jsxDEV(O,{dimColor:!0,children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),K&&K!=="./"&&_Z.jsxDEV(_Z.Fragment,{children:[_Z.jsxDEV(O,{dimColor:!0,children:" in "},void 0,!1,void 0,this),_Z.jsxDEV(fZ,{path:K,rainbow:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_Z.jsxDEV(O,{color:"gray",dimColor:!0,children:[" ","(",Q," matches)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}});import{z as s0}from"zod";var G4=P(I(),1),x$=s0.object({description:s0.string().optional(),file_path:s0.string(),content:s0.string()}),H5=t({name:"write_file",description:"Writes a file to the local filesystem",parameters:x$.shape,handler:ZZ.waitForUIDone,render(Z){let Y=Z.getInputRepaired(),X=Z.output,J=Y.content?.split(`
48
- `)?.length;return G4.jsxDEV(_,{flexDirection:"column",paddingX:1,children:[G4.jsxDEV(_,{children:[G4.jsxDEV(O,{color:"green",children:"Write "},void 0,!1,void 0,this),G4.jsxDEV(O,{dimColor:!0,children:"("},void 0,!1,void 0,this),G4.jsxDEV(fZ,{path:Y.file_path,rainbow:!0},void 0,!1,void 0,this),G4.jsxDEV(O,{dimColor:!0,children:")"},void 0,!1,void 0,this),G4.jsxDEV(O,{dimColor:!0,children:[" (",J," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),X&&X.startsWith("Error:")&&G4.jsxDEV(_,{marginTop:0,marginLeft:1,marginBottom:1,children:G4.jsxDEV(O,{color:"red",children:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}});var PZ=P(I(),1),g$=G5.schema,O5=t({name:"folder_operations",description:"Unified folder operations tool supporting create, list, delete, and existence check",parameters:g$.shape,render(Z){let Y=Z.getInputRepaired(),X=Z.output;if(!X)return PZ.jsxDEV(PZ.Fragment,{},void 0,!1,void 0,this);let Q={create:"green",list:"blue",exists:"yellow",delete:"red"}[Y?.operation]||"cyan",K=X.split(`
49
- `).map((U,W)=>{if(U.match(/\d+ \w+|[\d-]+ [\d:]+/))return PZ.jsxDEV(O,{dimColor:!0,children:U},W,!1,void 0,this);if(U.includes("✓")||U.includes("successfully")||U.includes("created")||U.includes("deleted"))return PZ.jsxDEV(O,{color:"green",children:U},W,!1,void 0,this);if(U.includes("✗")||U.includes("Error")||U.includes("not found")||U.includes("failed"))return PZ.jsxDEV(O,{color:"red",children:U},W,!1,void 0,this);if(U.startsWith("/")||U.includes("/:"))return PZ.jsxDEV(O,{color:"cyan",children:U},W,!1,void 0,this);return PZ.jsxDEV(O,{children:U},W,!1,void 0,this)});return PZ.jsxDEV(_,{flexDirection:"column",paddingX:1,children:PZ.jsxDEV(_,{children:[PZ.jsxDEV(O,{bold:!0,color:Q,children:[Y.operation,"Folder"]},void 0,!0,void 0,this),PZ.jsxDEV(O,{dimColor:!0,children:" ("},void 0,!1,void 0,this),PZ.jsxDEV(fZ,{path:Y.folder_path,rainbow:!0},void 0,!1,void 0,this),PZ.jsxDEV(O,{dimColor:!0,children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}});import{z as u$}from"zod";var MZ=P(I(),1),m$=u$.object({}),q5=t({name:"load_mcp_tools",description:`加载并查询所有可用的 MCP 工具列表。
38
+ - `)}`;if(F.customInput&&F.customInput.trim())L+=(L?`
39
+ `:"")+`User Custom Input: ${F.customInput}`}$.sendResumeData({type:"respond",message:L||"User made a selection"}),J(X,{resultSent:!0})}};_();let O=setInterval(_,100);return()=>clearInterval(O)},[X,Y,J,$]),$.state==="interrupted"&&!$.output)return c0.jsxDEV(z,{flexDirection:"column",children:c0.jsxDEV(z,{paddingX:1,children:c0.jsxDEV(G,{color:"yellow",children:"⏳ 等待用户选择..."},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.output)return c0.jsxDEV(G,{color:"yellow",children:$.output},void 0,!1,void 0,this);return null},M4=l({name:"ask_user_questions",description:"Ask the user a question with selectable options",parameters:k8,handler:n.waitForUIDone,render($){return c0.jsxDEV(y8,{tool:$},void 0,!1,void 0,this)}});var v0=A(D(),1);var e0=A(M(),1),u0=({content:$,maxLines:Z=10,borderColor:Y="cyan",borderStyle:J="single",marginTop:X=0,paddingX:K=0,showOmittedInfo:Q=!0})=>{let{stdout:W}=R4();if(!$)return null;let _=W.columns,O=$.split(`
40
+ `).map((F)=>F.slice(0,_-10)),N=Math.max(0,O.length-Z),U=O.slice(-Z).join(`
41
+ `);return e0.jsxDEV(z,{flexDirection:"column",width:_-5,children:e0.jsxDEV(z,{borderStyle:J,borderColor:Y,borderLeft:!1,borderRight:!1,flexDirection:"column",paddingX:K,marginTop:X,children:[Q&&N>0&&e0.jsxDEV(G,{color:"gray",dimColor:!0,children:["... ",N," lines omitted ..."]},void 0,!0,void 0,this),e0.jsxDEV(G,{dimColor:!0,children:U},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)};var w1=A(M(),1),T8=({tool:$})=>{let{addInteraction:Z,getInteractions:Y,updateInteraction:J}=k1(),[X,K]=v0.useState(null),Q=v0.useRef(!1),W=$.getHumanInTheLoopData();if(v0.useEffect(()=>{if(W?.reviewConfig&&$.state==="interrupted"&&!X&&!Q.current){let O=$.getInputRepaired()?.description,N={type:"approval",toolCall:{name:$.message.name,args:$.getInputRepaired()},editableFields:["args"]},U=Z(N,{tool:$,metadata:{title:`Approve ${$.message.name}`,description:O,groupKey:"approvals"}});K(U.id)}},[W,$,X,Z]),v0.useEffect(()=>{if(!X||Q.current)return;let O=()=>{let F=Y().find((L)=>L.id===X);if(F&&(F.state==="submitted"||F.state==="edited"||F.state==="cancelled")&&!F.resultSent){Q.current=!0;let L=F.result;if(L){if(L.status==="approved")$.sendResumeData({type:"approve"});else if(L.status==="edited"){let q={name:$.message.name,args:L.editedArgs};$.sendResumeData({type:"edit",edited_action:q})}else if(L.status==="rejected"){let q=L.message||"User rejected to run this tool";$.sendResumeData({type:"reject",message:q})}}J(X,{resultSent:!0})}};O();let N=setInterval(O,100);return()=>clearInterval(N)},[X,Y,J,$]),W?.reviewConfig&&X&&!$.output)return w1.jsxDEV(z,{flexDirection:"column",children:w1.jsxDEV(z,{paddingX:1,paddingY:1,children:w1.jsxDEV(G,{color:"yellow",children:"⏳ Wait for Approval"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return w1.jsxDEV(z,{flexDirection:"column",children:(()=>{if(!$.output)return null;return w1.jsxDEV(u0,{content:$.output,maxLines:5,borderColor:"cyan"},void 0,!1,void 0,this)})()},void 0,!1,void 0,this)},D8=({tool:$})=>{let Z=$.getInputRepaired(),Y=typeof Z?.command==="string"?Z.command:String(Z?.command??""),J=Y.length>50?Y.substring(0,50)+"...":Y;return w1.jsxDEV(z,{paddingX:1,children:[w1.jsxDEV(G,{color:"magenta",children:"Run "},void 0,!1,void 0,this),w1.jsxDEV(G,{dimColor:!0,children:"("},void 0,!1,void 0,this),w1.jsxDEV(G,{color:"magenta",children:J},void 0,!1,void 0,this),w1.jsxDEV(G,{dimColor:!0,children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},b4=l({name:"terminal",description:"",parameters:{},handler:n.waitForUIDone,render($){return w1.jsxDEV(z,{flexDirection:"column",children:[w1.jsxDEV(D8,{tool:$},void 0,!1,void 0,this),w1.jsxDEV(T8,{tool:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}});import{diff_match_patch as V8}from"diff-match-patch";function j8($,Z,Y){if($===Z)return[{type:"unchanged",content:$,lineNumbers:{old:1,new:1}}];let J=new V8,X=J.diff_main($,Z);J.diff_cleanupSemantic(X);let K=[],Q=1,W=1,_=[];for(let[R,P]of X){if(P==="")continue;let S=P.split(`
42
+ `),u=P.endsWith(`
43
+ `);for(let m=0;m<S.length;m++){let e=S[m];if(e===""&&(m<S.length-1||!u))continue;let v={type:R===0?"unchanged":R===-1?"added":"removed",content:e};if(R===0)v.lineNumbers={old:Q,new:W},Q++,W++;else if(R===-1)v.lineNumbers={new:W},W++;else if(R===1)v.lineNumbers={old:Q},Q++;_.push(v)}}if(!Y?.maxLines)return _;let O=Y.maxLines,N=Y.contextLines||3,U=_.map((R,P)=>R.type!=="unchanged"?P:-1).filter((R)=>R!==-1);if(U.length===0||_.length<=O)return _;let F=[],L=0,q=[],w=[];for(let R=0;R<U.length;R++)if(w.length===0)w.push(U[R]);else{let P=w[w.length-1];if(U[R]-P<=1)w.push(U[R]);else q.push([...w]),w=[U[R]]}if(w.length>0)q.push(w);for(let R of q){if(L>=O)break;let P=R[0],S=R[R.length-1],u=Math.max(0,P-N),m=Math.min(_.length-1,S+N),e=m-u+1;if(L+e>O&&L>0){F.push({type:"unchanged",content:"..."});break}for(let v=u;v<=m;v++){if(L>=O){if(v<m)F.push({type:"unchanged",content:"..."});break}F.push(_[v]),L++}if(R===q[q.length-1]&&L<_.length){let v=_.length-m-1;if(v>0)F.push({type:"unchanged",content:`... (${v} more lines)`})}}return F}function B4($,Z=1000){return $=$||"",$.length>Z||$.split(`
44
+ `).length>50}function P4($,Z,Y){let J=B4($)||B4(Z),K=Y!==void 0&&"maxLines"in Y?Y.maxLines:J?10:20,Q=Y?.contextLines??(J?1:3);return j8($,Z,{maxLines:K,contextLines:Q})}var x0=A(M(),1),h8=["sky","primary"];function E8($){let Z=$%2;return S0(h8[Z])}function g8($){let Z=[];if($.startsWith("/"))Z.push({type:"separator",value:"/"}),$=$.slice(1);let Y=$.split("/");return Y.forEach((J,X)=>{if(J)Z.push({type:"segment",value:J});if(X<Y.length-1)Z.push({type:"separator",value:"/"})}),Z}var p8=({path:$,color:Z="cyan",line:Y,rainbow:J=!1})=>{let X=f4($)??"",K=Y!==void 0?`:${Y}`:"";if(!J)return x0.jsxDEV(G,{color:S0(Z),children:[X,K]},void 0,!0,void 0,this);let Q=g8(X),W=-1;for(let O=Q.length-1;O>=0;O--)if(Q[O].type==="segment"){W=O;break}let _=0;return x0.jsxDEV(G,{children:[Q.map((O,N)=>{if(O.type==="separator")return x0.jsxDEV(G,{dimColor:!0,color:"gray",children:O.value},`sep-${N}`,!1,void 0,this);let U=N===W,F=E8(_);return _++,x0.jsxDEV(G,{color:F,dimColor:!U,children:O.value},`seg-${N}`,!1,void 0,this)}),K&&x0.jsxDEV(G,{color:"gray",children:K},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},P1=p8;var X1=A(M(),1),m8=C4.schema,v4=l({name:"edit_file",description:"Performs exact string replacements in files with diff visualization",parameters:m8.shape,handler:n.waitForUIDone,render($){let Z=$.getInputRepaired(),Y=$.output,J=typeof Z?.file_path==="string"?Z.file_path:String(Z?.file_path??""),X=typeof Z?.old_string==="string"?Z.old_string:"",K=typeof Z?.new_string==="string"?Z.new_string:"",Q=X.length>0&&K.length>0&&X!==K,W=typeof Y==="string"?Y:"",_=0,O=0;if(Q){let N=P4(X,K,{maxLines:void 0});for(let U of N){if(U.type==="removed")_++;if(U.type==="added")O++}}return X1.jsxDEV(z,{flexDirection:"column",paddingX:1,children:[X1.jsxDEV(z,{children:[X1.jsxDEV(G,{color:"yellow",children:"Edit "},void 0,!1,void 0,this),X1.jsxDEV(G,{dimColor:!0,children:"("},void 0,!1,void 0,this),X1.jsxDEV(P1,{path:J,rainbow:!0},void 0,!1,void 0,this),X1.jsxDEV(G,{dimColor:!0,children:")"},void 0,!1,void 0,this),Q&&X1.jsxDEV(X1.Fragment,{children:[X1.jsxDEV(G,{color:"gray",children:" ("},void 0,!1,void 0,this),X1.jsxDEV(G,{color:"red",children:["-",_]},void 0,!0,void 0,this),X1.jsxDEV(G,{color:"gray",children:"/"},void 0,!1,void 0,this),X1.jsxDEV(G,{color:"green",children:["+",O]},void 0,!0,void 0,this),X1.jsxDEV(G,{color:"gray",children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W&&W.startsWith("Error:")&&X1.jsxDEV(z,{marginTop:0,marginLeft:1,marginBottom:1,children:X1.jsxDEV(G,{color:"red",children:W},void 0,!1,void 0,this)},void 0,!1,void 0,this),!W&&X1.jsxDEV(z,{marginTop:0,children:X1.jsxDEV(G,{color:"gray",children:"Press Enter to confirm, Ctrl+C to cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}});var E1=A(M(),1),c8=["pending","in_progress","completed"],u8={pending:"gray",in_progress:"yellow",completed:"green"},x8={pending:"○",in_progress:"◐",completed:"✓"};function d8($,Z){let Y=$&&typeof $==="object"?$:{},J=typeof Y.id==="string"?Y.id:String(Z),X=typeof Y.content==="string"?Y.content:String(Y.content??""),K=c8.includes(Y.status)?Y.status:"pending";return{id:J,content:X,status:K}}var I4=l({name:"todo_write",description:"Use this tool to create and manage a structured task list",parameters:S4.shape,handler:n.waitForUIDone,render($){let Z=$.getInputRepaired(),J=(Z&&Array.isArray(Z.todos)?Z.todos:[]).map(d8);if(!Z)return E1.jsxDEV(z,{flexDirection:"column",borderStyle:"round",borderColor:"red",children:E1.jsxDEV(G,{color:"red",children:"Error: Invalid todo data structure"},void 0,!1,void 0,this)},void 0,!1,void 0,this);return E1.jsxDEV(z,{flexDirection:"column",paddingY:1,children:E1.jsxDEV(z,{flexDirection:"column",marginTop:0,children:(()=>{if(J.length===0)return E1.jsxDEV(z,{paddingX:1,children:E1.jsxDEV(G,{color:"gray",children:"No tasks in todo list"},void 0,!1,void 0,this)},void 0,!1,void 0,this);return E1.jsxDEV(z,{flexDirection:"column",marginTop:0,children:J.map((K,Q)=>E1.jsxDEV(z,{paddingX:1,paddingY:0,children:[E1.jsxDEV(G,{color:u8[K.status],bold:!0,children:[x8[K.status]," "]},void 0,!0,void 0,this),E1.jsxDEV(G,{color:K.status==="in_progress"?"white":"gray",children:[Q+1,". ",K.content]},void 0,!0,void 0,this)]},K.id,!0,void 0,this))},void 0,!1,void 0,this)})()},void 0,!1,void 0,this)},void 0,!1,void 0,this)}});var g1=A(M(),1),l8=k4.schema,y4=l({name:"read_file",description:"Reads a file from the local filesystem",parameters:l8.shape,handler:n.waitForUIDone,render($){let Z=$.getInputRepaired(),Y=$.output;if(!Y)return g1.jsxDEV(g1.Fragment,{},void 0,!1,void 0,this);let K=(typeof Y==="string"?Y:String(Y??"")).split(`
45
+ `).length,Q=typeof Z?.file_path==="string"?Z.file_path:String(Z?.file_path??"");return g1.jsxDEV(z,{flexDirection:"column",paddingX:1,children:g1.jsxDEV(z,{children:[g1.jsxDEV(G,{color:"blue",children:"Read "},void 0,!1,void 0,this),g1.jsxDEV(G,{dimColor:!0,children:"("},void 0,!1,void 0,this),g1.jsxDEV(P1,{path:Q,rainbow:!0},void 0,!1,void 0,this),g1.jsxDEV(G,{dimColor:!0,children:")"},void 0,!1,void 0,this),g1.jsxDEV(G,{color:"gray",dimColor:!0,children:[" ","(",K," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}});var p1=A(M(),1),i8=T4.schema,D4=l({name:"glob_files",description:"Find files by name patterns",parameters:i8.shape,handler:n.waitForUIDone,render($){let Z=$.getInputRepaired(),Y=$.output;if(!Y)return p1.jsxDEV(p1.Fragment,{},void 0,!1,void 0,this);let X=Y.split(`
46
+ `).filter(Boolean).length,K=typeof Z?.pattern==="string"?Z.pattern:String(Z?.pattern??"");return p1.jsxDEV(z,{flexDirection:"column",paddingX:1,children:p1.jsxDEV(G,{children:[p1.jsxDEV(G,{color:"cyan",children:"Glob "},void 0,!1,void 0,this),p1.jsxDEV(G,{dimColor:!0,children:"("},void 0,!1,void 0,this),p1.jsxDEV(P1,{path:K,rainbow:!0},void 0,!1,void 0,this),p1.jsxDEV(G,{dimColor:!0,children:")"},void 0,!1,void 0,this),p1.jsxDEV(G,{color:"gray",dimColor:!0,children:[" ","(",X," files)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}});import{z as I0}from"zod";var _1=A(M(),1),o8=I0.object({args:I0.array(I0.string()).optional().describe("ripgrep 参数数组,格式为 [OPTIONS...] PATTERN [PATH...]"),pattern:I0.string().optional().describe("搜索模式(结构化参数)"),path:I0.string().optional().describe("搜索路径(结构化参数)"),description:I0.string().optional().describe("操作描述"),head_limit:I0.number().optional().describe("限制输出行数")}),V4=l({name:"search_files_rg",description:"Ripgrep - fast text search tool",parameters:o8.shape,handler:n.waitForUIDone,render($){let Z=$.getInputRepaired(),Y=$.output;if(!Y)return _1.jsxDEV(_1.Fragment,{},void 0,!1,void 0,this);let K=(typeof Y==="string"?Y:String(Y??"")).split(`
47
+ `).filter(Boolean).length,Q=typeof Z?.pattern==="string"?Z.pattern:void 0,W=typeof Z?.path==="string"?Z.path:void 0;if(!Q&&Z?.args){let N=(Array.isArray(Z.args)?Z.args:[]).filter((U)=>typeof U==="string").filter((U)=>!U.startsWith("-"));if(N.length>0){if(W=N[N.length-1],N.length>1)Q=N[N.length-2]}}return _1.jsxDEV(z,{flexDirection:"column",paddingX:1,children:_1.jsxDEV(G,{children:[_1.jsxDEV(G,{color:"magenta",children:"Ripgrep "},void 0,!1,void 0,this),Q&&_1.jsxDEV(_1.Fragment,{children:[_1.jsxDEV(G,{dimColor:!0,children:"("},void 0,!1,void 0,this),_1.jsxDEV(P1,{path:Q,color:"magenta"},void 0,!1,void 0,this),_1.jsxDEV(G,{dimColor:!0,children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W&&W!=="./"&&_1.jsxDEV(_1.Fragment,{children:[_1.jsxDEV(G,{dimColor:!0,children:" in "},void 0,!1,void 0,this),_1.jsxDEV(P1,{path:W,rainbow:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_1.jsxDEV(G,{color:"gray",dimColor:!0,children:[" ","(",K," matches)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}});import{z as A$}from"zod";var s1=A(M(),1),r8=A$.object({description:A$.string().optional(),file_path:A$.string(),content:A$.string()}),j4=l({name:"write_file",description:"Writes a file to the local filesystem",parameters:r8.shape,handler:n.waitForUIDone,render($){let Z=$.getInputRepaired(),Y=$.output,J=typeof Z?.content==="string"?Z.content:String(Z?.content??""),X=typeof Z?.file_path==="string"?Z.file_path:String(Z?.file_path??""),K=J.split(`
48
+ `).length,Q=typeof Y==="string"?Y:"";return s1.jsxDEV(z,{flexDirection:"column",paddingX:1,children:[s1.jsxDEV(z,{children:[s1.jsxDEV(G,{color:"green",children:"Write "},void 0,!1,void 0,this),s1.jsxDEV(G,{dimColor:!0,children:"("},void 0,!1,void 0,this),s1.jsxDEV(P1,{path:X,rainbow:!0},void 0,!1,void 0,this),s1.jsxDEV(G,{dimColor:!0,children:")"},void 0,!1,void 0,this),s1.jsxDEV(G,{dimColor:!0,children:[" (",K," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q&&Q.startsWith("Error:")&&s1.jsxDEV(z,{marginTop:0,marginLeft:1,marginBottom:1,children:s1.jsxDEV(G,{color:"red",children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}});var N1=A(M(),1),n8=h4.schema,E4=l({name:"folder_operations",description:"Unified folder operations tool supporting create, list, delete, and existence check",parameters:n8.shape,render($){let Z=$.getInputRepaired(),Y=$.output;if(!Y)return N1.jsxDEV(N1.Fragment,{},void 0,!1,void 0,this);let J=typeof Y==="string"?Y:String(Y??""),X=typeof Z?.operation==="string"?Z.operation:String(Z?.operation??""),K=typeof Z?.folder_path==="string"?Z.folder_path:String(Z?.folder_path??""),W={create:"green",list:"blue",exists:"yellow",delete:"red"}[X]??"cyan",O=J.split(`
49
+ `).map((N,U)=>{if(N.match(/\d+ \w+|[\d-]+ [\d:]+/))return N1.jsxDEV(G,{dimColor:!0,children:N},U,!1,void 0,this);if(N.includes("✓")||N.includes("successfully")||N.includes("created")||N.includes("deleted"))return N1.jsxDEV(G,{color:"green",children:N},U,!1,void 0,this);if(N.includes("✗")||N.includes("Error")||N.includes("not found")||N.includes("failed"))return N1.jsxDEV(G,{color:"red",children:N},U,!1,void 0,this);if(N.startsWith("/")||N.includes("/:"))return N1.jsxDEV(G,{color:"cyan",children:N},U,!1,void 0,this);return N1.jsxDEV(G,{children:N},U,!1,void 0,this)});return N1.jsxDEV(z,{flexDirection:"column",paddingX:1,children:N1.jsxDEV(z,{children:[N1.jsxDEV(G,{bold:!0,color:W,children:[X,"Folder"]},void 0,!0,void 0,this),N1.jsxDEV(G,{dimColor:!0,children:" ("},void 0,!1,void 0,this),N1.jsxDEV(P1,{path:K,rainbow:!0},void 0,!1,void 0,this),N1.jsxDEV(G,{dimColor:!0,children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}});import{z as a8}from"zod";var Q1=A(M(),1),s8=a8.object({}),g4=l({name:"load_mcp_tools",description:`加载并查询所有可用的 MCP 工具列表。
50
50
 
51
51
  返回:
52
52
  - tools: MCP 工具列表,每个工具包含 name, description, schema
@@ -57,7 +57,7 @@ ${F.selected.join(`
57
57
  - 获取工具的参数格式
58
58
  - 检查 MCP 连接状态
59
59
 
60
- 重要:工具列表是动态的,建议在需要时调用此命令获取最新信息。`,parameters:m$.shape,handler:ZZ.waitForUIDone,render(Z){let Y=Z.output,X=null;try{X=JSON.parse(Y)}catch(J){}return MZ.jsxDEV(_,{flexDirection:"column",children:[MZ.jsxDEV(_,{children:MZ.jsxDEV(O,{color:"blue",bold:!0,children:"load_mcp_tools"},void 0,!1,void 0,this)},void 0,!1,void 0,this),X?.status&&MZ.jsxDEV(_,{flexDirection:"column",marginTop:1,children:[MZ.jsxDEV(O,{color:"green",children:"✓ MCP 已连接"},void 0,!1,void 0,this),X.status.servers&&X.status.servers.length>0&&MZ.jsxDEV(_,{marginLeft:2,children:MZ.jsxDEV(O,{color:"gray",children:["服务器: ",X.status.servers.join(", ")]},void 0,!0,void 0,this)},void 0,!1,void 0,this),X.status.toolCount!==void 0&&MZ.jsxDEV(_,{marginLeft:2,children:MZ.jsxDEV(O,{color:"gray",children:["工具数量: ",X.status.toolCount]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X?.tools&&X.tools.length>0&&MZ.jsxDEV(_,{flexDirection:"column",marginTop:1,children:[MZ.jsxDEV(O,{color:"gray",dimColor:!0,children:["可用工具 (",X.tools.length,"):"]},void 0,!0,void 0,this),X.tools.slice(0,5).map((J,Q)=>MZ.jsxDEV(_,{marginLeft:2,children:[MZ.jsxDEV(O,{color:"cyan",children:J.name},void 0,!1,void 0,this),J.description&&MZ.jsxDEV(O,{color:"gray",dimColor:!0,children:[" ","- ",J.description.slice(0,50),J.description.length>50?"...":""]},void 0,!0,void 0,this)]},Q,!0,void 0,this)),X.tools.length>5&&MZ.jsxDEV(_,{marginLeft:2,children:MZ.jsxDEV(O,{color:"gray",dimColor:!0,children:["... 还有 ",X.tools.length-5," 个工具"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y&&MZ.jsxDEV(W0,{content:Y,maxLines:10,borderColor:"gray"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}});import{z as l4}from"zod";var EZ=P(I(),1),p$=l4.object({commands:l4.array(l4.object({name:l4.string().describe("MCP 工具名称"),args:l4.record(l4.string(),l4.any()).describe("工具参数,JSON 对象格式")})).describe("要执行的 MCP 工具列表")}),F5=t({name:"execute_mcp_tool",description:`执行一个或多个 MCP 工具。
60
+ 重要:工具列表是动态的,建议在需要时调用此命令获取最新信息。`,parameters:s8.shape,handler:n.waitForUIDone,render($){let Z=$.output,Y=typeof Z==="string"?Z:"",J=null;try{J=JSON.parse(Y)}catch(W){}let X=Array.isArray(J?.tools)?J.tools:[],K=Array.isArray(J?.status?.servers)?J.status.servers.filter((W)=>typeof W==="string"):[],Q=typeof J?.status?.toolCount==="number"?J.status.toolCount:void 0;return Q1.jsxDEV(z,{flexDirection:"column",children:[Q1.jsxDEV(z,{children:Q1.jsxDEV(G,{color:"blue",bold:!0,children:"load_mcp_tools"},void 0,!1,void 0,this)},void 0,!1,void 0,this),J?.status&&Q1.jsxDEV(z,{flexDirection:"column",marginTop:1,children:[Q1.jsxDEV(G,{color:"green",children:"✓ MCP 已连接"},void 0,!1,void 0,this),K.length>0&&Q1.jsxDEV(z,{marginLeft:2,children:Q1.jsxDEV(G,{color:"gray",children:["服务器: ",K.join(", ")]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Q!==void 0&&Q1.jsxDEV(z,{marginLeft:2,children:Q1.jsxDEV(G,{color:"gray",children:["工具数量: ",Q]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X.length>0&&Q1.jsxDEV(z,{flexDirection:"column",marginTop:1,children:[Q1.jsxDEV(G,{color:"gray",dimColor:!0,children:["可用工具 (",X.length,"):"]},void 0,!0,void 0,this),X.slice(0,5).map((W,_)=>{let O=typeof W?.name==="string"?W.name:String(W?.name??""),N=typeof W?.description==="string"?W.description:"";return Q1.jsxDEV(z,{marginLeft:2,children:[Q1.jsxDEV(G,{color:"cyan",children:O},void 0,!1,void 0,this),N&&Q1.jsxDEV(G,{color:"gray",dimColor:!0,children:[" ","- ",N.slice(0,50),N.length>50?"...":""]},void 0,!0,void 0,this)]},_,!0,void 0,this)}),X.length>5&&Q1.jsxDEV(z,{marginLeft:2,children:Q1.jsxDEV(G,{color:"gray",dimColor:!0,children:["... 还有 ",X.length-5," 个工具"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y&&Q1.jsxDEV(u0,{content:Y,maxLines:10,borderColor:"gray"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}});import{z as k0}from"zod";var M1=A(M(),1),t8=k0.object({commands:k0.array(k0.object({name:k0.string().describe("MCP 工具名称"),args:k0.record(k0.string(),k0.any()).describe("工具参数,JSON 对象格式")})).describe("要执行的 MCP 工具列表")}),p4=l({name:"execute_mcp_tool",description:`执行一个或多个 MCP 工具。
61
61
 
62
62
  使用格式:
63
63
  - commands: MCP 工具数组,每个工具包含 name 和 args
@@ -69,124 +69,112 @@ ${F.selected.join(`
69
69
  重要:
70
70
  - 所有工具独立执行,失败不影响其他工具
71
71
  - 返回结果按命令顺序排列
72
- - 适合批量执行 MCP 相关操作`,parameters:p$.shape,handler:ZZ.waitForUIDone,render(Z){let Y=Z.getInputRepaired(),X=Z.output,J=null;try{J=JSON.parse(X)}catch(Q){}return EZ.jsxDEV(_,{flexDirection:"column",children:[EZ.jsxDEV(_,{children:EZ.jsxDEV(O,{color:"blue",bold:!0,children:"execute_mcp_tool"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y?.commands&&Y.commands.length>0&&EZ.jsxDEV(_,{flexDirection:"column",marginTop:1,children:[EZ.jsxDEV(O,{color:"gray",dimColor:!0,children:["执行 ",Y.commands.length," 个 MCP 工具:"]},void 0,!0,void 0,this),Y.commands.map((Q,$)=>EZ.jsxDEV(_,{marginLeft:2,children:[EZ.jsxDEV(O,{color:"yellow",children:[$+1,"."]},void 0,!0,void 0,this),EZ.jsxDEV(O,{color:"cyan",children:Q.name},void 0,!1,void 0,this)]},$,!0,void 0,this))]},void 0,!0,void 0,this),J?.results&&EZ.jsxDEV(_,{flexDirection:"column",marginTop:1,children:J.results.map((Q,$)=>EZ.jsxDEV(_,{marginLeft:2,children:Q.error?EZ.jsxDEV(O,{color:"red",children:["✗ ",Q.tool]},void 0,!0,void 0,this):EZ.jsxDEV(O,{color:"green",children:["✓ ",Q.tool]},void 0,!0,void 0,this)},$,!1,void 0,this))},void 0,!1,void 0,this),X&&EZ.jsxDEV(W0,{content:X,maxLines:10,borderColor:"gray"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}});var O4=P(I(),1);import{z as z0}from"zod";var d$=z0.object({task_id:z0.string().optional().describe("The task id to ask the subagent"),subagent_id:z0.string().describe("The id of subagent to use"),subagent_type:z0.string().describe("The type of subagent to use (general-purpose, statusline-setup, output-style-setup)"),task_description:z0.string().describe("Describe what you want the subagent to do"),data_transfer:z0.any().optional().describe("Data to transfer to the subagent")}),c$=({tool:Z})=>{let Y=Z.getInputRepaired();return O4.jsxDEV(_,{paddingX:1,flexDirection:"column",children:O4.jsxDEV(_,{children:[O4.jsxDEV(O,{color:"yellow",children:"Task "},void 0,!1,void 0,this),O4.jsxDEV(O,{dimColor:!0,children:"("},void 0,!1,void 0,this),O4.jsxDEV(O,{color:"cyan",children:Y.subagent_id},void 0,!1,void 0,this),O4.jsxDEV(O,{dimColor:!0,children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},l$=({tool:Z})=>{let Y=Z.getInputRepaired(),X=Z.output;return O4.jsxDEV(_,{flexDirection:"column",children:O4.jsxDEV(c$,{tool:Z},void 0,!1,void 0,this)},void 0,!1,void 0,this)},M5=t({name:"task",description:"Launch a subagent to handle complex tasks autonomously",parameters:d$.shape,handler:ZZ.waitForUIDone,render(Z){return O4.jsxDEV(l$,{tool:Z},void 0,!1,void 0,this)}});var N5=[s8,n8,X5,Q5,K5,U5,z5,H5,O5,q5,F5,M5];var e=P(g(),1);var b=P(I(),1),i$=({validation:Z,onComplete:Y})=>{let{config:X,updateConfig:J}=UZ(),[Q,$]=e.useState("welcome"),[K,U]=e.useState(!1),[W,z]=e.useState(null),[H,G]=e.useState(0),[F,M]=e.useState(null),N=e.useRef(!0),w=e.useRef([]),L=e.useRef(H),B=X?.providers||[];e.useEffect(()=>{w.current=B},[B]),e.useEffect(()=>{L.current=H},[H]);let C=B[H],R=e.useCallback(()=>M(null),[]);TZ(R,F?3000:null);let D=e.useCallback(()=>{N.current=!0,z(null),U(!0),M(null)},[]),f=e.useCallback(()=>{let u=w.current,n=L.current,i=u[n];if(!i)return;N.current=!1,z(i),U(!0),M(null)},[]),V=e.useCallback(()=>{U(!1),z(null),M(null)},[]),d=e.useCallback(async(u)=>{let n=w.current,i=N.current,Q4=i?[...n,u]:n.map(($4)=>$4.id===u.id?u:$4);if(await J({providers:Q4}),M(i?`已添加 Provider: ${u.id}`:`已更新 Provider: ${u.id}`),i){let $4=Q4.findIndex((hZ)=>hZ.id===u.id);G($4>=0?$4:0)}V()},[J,V]),l=e.useCallback(()=>{if(!C||!C.apiKey){M("请先配置 Provider 的 API Key");return}J({provider_id:C.id,provider_type:C.type}).then(()=>{$("model")})},[C,J]);if(uZ((u,n)=>{if(n.return||u===" ")$("provider")},{isActive:Q==="welcome"}),uZ((u,n)=>{if(K)return;if(n.upArrow)G((i)=>i>0?i-1:B.length-1);else if(n.downArrow)G((i)=>i<B.length-1?i+1:0);else if(u==="n"||u==="N")D();else if((u==="e"||u==="E"||n.return)&&C)f();else if(u==="s"||u==="S")l()},{isActive:Q==="provider"}),Q==="welcome")return b.jsxDEV(_,{flexDirection:"column",paddingX:2,paddingY:1,width:"100%",children:[b.jsxDEV(_,{marginBottom:1,children:b.jsxDEV(O,{bold:!0,color:"cyan",children:"欢迎使用 Zen Code"},void 0,!1,void 0,this)},void 0,!1,void 0,this),b.jsxDEV(_,{marginBottom:1,children:b.jsxDEV(O,{color:"yellow",children:Z.reason||"需要进行初始配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),b.jsxDEV(_,{flexDirection:"column",marginBottom:1,children:[b.jsxDEV(O,{dimColor:!0,children:"接下来将引导你完成:"},void 0,!1,void 0,this),b.jsxDEV(O,{dimColor:!0,children:" 1. 配置 Provider(API 服务提供商)"},void 0,!1,void 0,this),b.jsxDEV(O,{dimColor:!0,children:" 2. 选择 Model(AI 模型)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b.jsxDEV(_,{children:b.jsxDEV(O,{color:"green",bold:!0,children:"按 Enter 开始配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(Q==="provider")return b.jsxDEV(_,{flexDirection:"column",width:"100%",children:[b.jsxDEV(_,{paddingX:2,paddingY:1,children:b.jsxDEV(O,{bold:!0,color:"cyan",children:"步骤 1/2: Provider 配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),K?b.jsxDEV(A5,{provider:W||void 0,onCancel:V,onSave:d},void 0,!1,void 0,this):b.jsxDEV(b.Fragment,{children:b.jsxDEV(_,{flexDirection:"column",paddingX:2,gap:1,children:[B.length===0?b.jsxDEV(_,{paddingY:1,children:b.jsxDEV(O,{color:"yellow",children:"未配置任何 Provider,请按 'n' 新增"},void 0,!1,void 0,this)},void 0,!1,void 0,this):B.map((u,n)=>{let i=!!u.apiKey,Q4=i?"green":"yellow";return b.jsxDEV(_,{marginBottom:0,gap:1,children:[b.jsxDEV(O,{color:n===H?"cyan":"gray",bold:n===H,children:n===H?">":" "},void 0,!1,void 0,this),b.jsxDEV(O,{bold:n===H,color:n===H?"cyan":void 0,children:u.id},void 0,!1,void 0,this),b.jsxDEV(O,{color:"gray",dimColor:n!==H,children:[" ",u.type]},void 0,!0,void 0,this),b.jsxDEV(O,{color:Q4,dimColor:n!==H,children:[" ","[",i?"已配置":"未配置","]"]},void 0,!0,void 0,this)]},u.id,!0,void 0,this)}),b.jsxDEV(_,{marginTop:1,children:[b.jsxDEV(O,{color:"gray",dimColor:!0,children:[b.jsxDEV(O,{color:"cyan",children:"↑↓"},void 0,!1,void 0,this)," 导航 ",b.jsxDEV(O,{color:"cyan",children:"n"},void 0,!1,void 0,this)," 新增"," ",b.jsxDEV(O,{color:"cyan",children:"e/Enter"},void 0,!1,void 0,this)," 编辑"," "]},void 0,!0,void 0,this),B.some((u)=>u.apiKey)&&b.jsxDEV(O,{children:[b.jsxDEV(O,{color:"green",children:"s"},void 0,!1,void 0,this)," 下一步"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),F&&b.jsxDEV(_,{paddingX:2,paddingY:0,children:b.jsxDEV(O,{color:"green",children:F},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(Q==="model")return b.jsxDEV(r$,{onComplete:Y,onBack:()=>$("provider")},void 0,!1,void 0,this);return null},r$=({onComplete:Z,onBack:Y})=>{let{config:X,updateConfig:J}=UZ(),[Q,$]=e.useState(0),K=e.useMemo(()=>{return X?.providers.find((G)=>G.id===X.provider_id)||null},[X?.providers,X?.provider_id]),{data:U=[],isLoading:W,error:z}=_5({provider:K,enabled:!!K?.apiKey}),H=U[Q];if(uZ((G,F)=>{if(F.upArrow)$((M)=>M>0?M-1:U.length-1);else if(F.downArrow)$((M)=>M<U.length-1?M+1:0);else if(F.escape||G==="b"||G==="B")Y();else if((F.return||G===" ")&&H)J({model_id:H.id}).then(()=>{Z()})},{isActive:!W&&!z&&X!==null}),W)return b.jsxDEV(_,{flexDirection:"column",paddingX:2,paddingY:1,children:[b.jsxDEV(O,{bold:!0,color:"cyan",children:"步骤 2/2: Model 选择"},void 0,!1,void 0,this),b.jsxDEV(_,{marginTop:1,children:b.jsxDEV(O,{color:"gray",children:"加载模型列表中..."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(z)return b.jsxDEV(_,{flexDirection:"column",paddingX:2,paddingY:1,children:[b.jsxDEV(O,{bold:!0,color:"cyan",children:"步骤 2/2: Model 选择"},void 0,!1,void 0,this),b.jsxDEV(_,{marginTop:1,children:b.jsxDEV(O,{color:"red",children:["加载失败: ",z.message]},void 0,!0,void 0,this)},void 0,!1,void 0,this),b.jsxDEV(_,{marginTop:1,children:b.jsxDEV(O,{color:"gray",dimColor:!0,children:["按 ",b.jsxDEV(O,{color:"cyan",children:"Esc"},void 0,!1,void 0,this)," 返回上一步"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return b.jsxDEV(_,{flexDirection:"column",width:"100%",children:[b.jsxDEV(_,{paddingX:2,paddingY:1,children:[b.jsxDEV(O,{bold:!0,color:"cyan",children:"步骤 2/2: Model 选择"},void 0,!1,void 0,this),K&&b.jsxDEV(O,{dimColor:!0,children:[" ","- ",K.id," (",K.type,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),b.jsxDEV(_,{flexDirection:"column",paddingX:2,gap:0,children:U.map((G,F)=>b.jsxDEV(_,{marginBottom:0,gap:1,children:[b.jsxDEV(O,{color:F===Q?"cyan":"gray",bold:F===Q,children:F===Q?">":" "},void 0,!1,void 0,this),b.jsxDEV(O,{bold:F===Q,color:F===Q?"cyan":void 0,children:G.id},void 0,!1,void 0,this),G.name!==G.id&&b.jsxDEV(O,{dimColor:F!==Q,children:["(",G.name,")"]},void 0,!0,void 0,this)]},G.id,!0,void 0,this))},void 0,!1,void 0,this),b.jsxDEV(_,{marginTop:1,paddingX:2,children:b.jsxDEV(O,{color:"gray",dimColor:!0,children:[b.jsxDEV(O,{color:"cyan",children:"↑↓"},void 0,!1,void 0,this)," 导航 ",b.jsxDEV(O,{color:"cyan",children:"Enter/Space"},void 0,!1,void 0,this)," 确认"," ",b.jsxDEV(O,{color:"cyan",children:"Esc/B"},void 0,!1,void 0,this)," 返回"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},w5=i$;var H0=P(I(),1),o$=({children:Z})=>{let{extraParams:Y,toggleCompactMode:X,config:J}=UZ(),{setTools:Q,loading:$}=WZ(),{hasPendingInteractions:K}=xZ();v8({tools:N5,setTools:Q});let{needsSetup:U,validation:W}=E8({config:J});T8({shouldFocus:!$});let z=f8(),{isChatView:H}=z,{handleExecuteTask:G}=j8({closePanel:z.closePanel});if(uZ((M,N)=>{if(N.ctrl&&M==="o"&&H&&!$)X();else if(N.ctrl&&M==="z"&&globalThis.Bun)import("v8").then((w)=>{w.writeHeapSnapshot("my-application.heapsnapshot")})},{isActive:H}),U&&W)return H0.jsxDEV(r,{name:"SetupWizard",fallback:null,children:H0.jsxDEV(w5,{validation:W,onComplete:z.closePanel},void 0,!1,void 0,this)},void 0,!1,void 0,this);let F={activeView:z.activeView,isChatView:z.isChatView,switchToHistory:z.switchToHistory,switchToKnowledge:z.switchToKnowledge,switchToSettings:z.switchToSettings,switchToModelProvider:z.switchToModelProvider,switchToAgent:z.switchToAgent,switchToTask:z.switchToTask,switchToMcp:z.switchToMcp,switchToProcess:z.switchToProcess,closePanel:z.closePanel,handleExecuteTask:G,hasPendingInteractions:K};return H0.jsxDEV(r,{name:"ChatPanelContext",fallback:null,children:H0.jsxDEV(y8,{value:F,children:Z},void 0,!1,void 0,this)},void 0,!1,void 0,this)},B5=({children:Z})=>{return H0.jsxDEV(o$,{children:Z},void 0,!1,void 0,this)};var H1=P(g(),1);var kY=P(g(),1);var w4=P(I(),1),n$=({content:Z,messageNumber:Y})=>{let X=t0(),J=()=>{if(typeof Z==="string")return w4.jsxDEV(O,{color:"white",children:Z},void 0,!1,void 0,this);if(Array.isArray(Z))return Z.filter((Q)=>Q.type==="text").map((Q,$)=>w4.jsxDEV(O,{color:"white",children:Q.text},void 0,!1,void 0,this));return w4.jsxDEV(O,{color:"white",children:JSON.stringify(Z)},void 0,!1,void 0,this)};return w4.jsxDEV(_,{flexDirection:"column",children:[w4.jsxDEV(_,{children:w4.jsxDEV(O,{color:c4("amber"),children:[Y," ",X]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w4.jsxDEV(_,{children:w4.jsxDEV(O,{color:"gray",children:["└─ ",J()]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},e0=n$;var E=P(RW(),1);function zX(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var r4=zX();function D5(Z){r4=Z}var R0={exec:()=>null};function p(Z,Y=""){let X=typeof Z=="string"?Z:Z.source,J={replace:(Q,$)=>{let K=typeof $=="string"?$:$.source;return K=K.replace(RZ.caret,"$1"),X=X.replace(Q,K),J},getRegex:()=>new RegExp(X,Y)};return J}var a$=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),RZ={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:(Z)=>new RegExp(`^( {0,3}${Z})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(Z)=>new RegExp(`^ {0,${Math.min(3,Z-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(Z)=>new RegExp(`^ {0,${Math.min(3,Z-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(Z)=>new RegExp(`^ {0,${Math.min(3,Z-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(Z)=>new RegExp(`^ {0,${Math.min(3,Z-1)}}#`),htmlBeginRegex:(Z)=>new RegExp(`^ {0,${Math.min(3,Z-1)}}<(?:[a-z].*>|!--)`,"i")},s$=/^(?:[ \t]*(?:\n|$))+/,t$=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,e$=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,C0=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ZK=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,HX=/(?:[*+-]|\d{1,9}[.)])/,V5=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,E5=p(V5).replace(/bull/g,HX).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),YK=p(V5).replace(/bull/g,HX).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),GX=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,XK=/^[^\n]+/,OX=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,JK=p(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",OX).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),QK=p(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,HX).getRegex(),QY="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",qX=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$K=p("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",qX).replace("tag",QY).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),b5=p(GX).replace("hr",C0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",QY).getRegex(),KK=p(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",b5).getRegex(),FX={blockquote:KK,code:t$,def:JK,fences:e$,heading:ZK,hr:C0,html:$K,lheading:E5,list:QK,newline:s$,paragraph:b5,table:R0,text:XK},L5=p("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",C0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",QY).getRegex(),WK={...FX,lheading:YK,table:L5,paragraph:p(GX).replace("hr",C0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",L5).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",QY).getRegex()},UK={...FX,html:p(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",qX).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:R0,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:p(GX).replace("hr",C0).replace("heading",` *#{1,6} *[^
73
- ]`).replace("lheading",E5).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},zK=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,HK=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,T5=/^( {2,}|\\)\n(?!\s*$)/,GK=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,$Y=/[\p{P}\p{S}]/u,MX=/[\s\p{P}\p{S}]/u,f5=/[^\s\p{P}\p{S}]/u,OK=p(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,MX).getRegex(),j5=/(?!~)[\p{P}\p{S}]/u,qK=/(?!~)[\s\p{P}\p{S}]/u,FK=/(?:[^\s\p{P}\p{S}]|~)/u,MK=p(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",a$?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),S5=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,NK=p(S5,"u").replace(/punct/g,$Y).getRegex(),_K=p(S5,"u").replace(/punct/g,j5).getRegex(),y5="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",AK=p(y5,"gu").replace(/notPunctSpace/g,f5).replace(/punctSpace/g,MX).replace(/punct/g,$Y).getRegex(),wK=p(y5,"gu").replace(/notPunctSpace/g,FK).replace(/punctSpace/g,qK).replace(/punct/g,j5).getRegex(),BK=p("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,f5).replace(/punctSpace/g,MX).replace(/punct/g,$Y).getRegex(),LK=p(/\\(punct)/,"gu").replace(/punct/g,$Y).getRegex(),PK=p(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),RK=p(qX).replace("(?:-->|$)","-->").getRegex(),CK=p("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",RK).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),YY=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,IK=p(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",YY).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),k5=p(/^!?\[(label)\]\[(ref)\]/).replace("label",YY).replace("ref",OX).getRegex(),h5=p(/^!?\[(ref)\](?:\[\])?/).replace("ref",OX).getRegex(),vK=p("reflink|nolink(?!\\()","g").replace("reflink",k5).replace("nolink",h5).getRegex(),P5=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,NX={_backpedal:R0,anyPunctuation:LK,autolink:PK,blockSkip:MK,br:T5,code:HK,del:R0,emStrongLDelim:NK,emStrongRDelimAst:AK,emStrongRDelimUnd:BK,escape:zK,link:IK,nolink:h5,punctuation:OK,reflink:k5,reflinkSearch:vK,tag:CK,text:GK,url:R0},DK={...NX,link:p(/^!?\[(label)\]\((.*?)\)/).replace("label",YY).getRegex(),reflink:p(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",YY).getRegex()},UX={...NX,emStrongRDelimAst:wK,emStrongLDelim:_K,url:p(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",P5).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:p(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",P5).getRegex()},VK={...UX,br:p(T5).replace("{2,}","*").getRegex(),text:p(UX.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ZY={normal:FX,gfm:WK,pedantic:UK},B0={normal:NX,gfm:UX,breaks:VK,pedantic:DK},EK={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},R5=(Z)=>EK[Z];function q4(Z,Y){if(Y){if(RZ.escapeTest.test(Z))return Z.replace(RZ.escapeReplace,R5)}else if(RZ.escapeTestNoEncode.test(Z))return Z.replace(RZ.escapeReplaceNoEncode,R5);return Z}function C5(Z){try{Z=encodeURI(Z).replace(RZ.percentDecode,"%")}catch{return null}return Z}function I5(Z,Y){let X=Z.replace(RZ.findPipe,($,K,U)=>{let W=!1,z=K;for(;--z>=0&&U[z]==="\\";)W=!W;return W?"|":" |"}),J=X.split(RZ.splitPipe),Q=0;if(J[0].trim()||J.shift(),J.length>0&&!J.at(-1)?.trim()&&J.pop(),Y)if(J.length>Y)J.splice(Y);else for(;J.length<Y;)J.push("");for(;Q<J.length;Q++)J[Q]=J[Q].trim().replace(RZ.slashPipe,"|");return J}function L0(Z,Y,X){let J=Z.length;if(J===0)return"";let Q=0;for(;Q<J;){let $=Z.charAt(J-Q-1);if($===Y&&!X)Q++;else if($!==Y&&X)Q++;else break}return Z.slice(0,J-Q)}function bK(Z,Y){if(Z.indexOf(Y[1])===-1)return-1;let X=0;for(let J=0;J<Z.length;J++)if(Z[J]==="\\")J++;else if(Z[J]===Y[0])X++;else if(Z[J]===Y[1]&&(X--,X<0))return J;return X>0?-2:-1}function v5(Z,Y,X,J,Q){let $=Y.href,K=Y.title||null,U=Z[1].replace(Q.other.outputLinkReplace,"$1");J.state.inLink=!0;let W={type:Z[0].charAt(0)==="!"?"image":"link",raw:X,href:$,title:K,text:U,tokens:J.inlineTokens(U)};return J.state.inLink=!1,W}function TK(Z,Y,X){let J=Z.match(X.other.indentCodeCompensation);if(J===null)return Y;let Q=J[1];return Y.split(`
74
- `).map(($)=>{let K=$.match(X.other.beginningSpace);if(K===null)return $;let[U]=K;return U.length>=Q.length?$.slice(Q.length):$}).join(`
75
- `)}var XY=class{options;rules;lexer;constructor(Z){this.options=Z||r4}space(Z){let Y=this.rules.block.newline.exec(Z);if(Y&&Y[0].length>0)return{type:"space",raw:Y[0]}}code(Z){let Y=this.rules.block.code.exec(Z);if(Y){let X=Y[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:Y[0],codeBlockStyle:"indented",text:this.options.pedantic?X:L0(X,`
76
- `)}}}fences(Z){let Y=this.rules.block.fences.exec(Z);if(Y){let X=Y[0],J=TK(X,Y[3]||"",this.rules);return{type:"code",raw:X,lang:Y[2]?Y[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):Y[2],text:J}}}heading(Z){let Y=this.rules.block.heading.exec(Z);if(Y){let X=Y[2].trim();if(this.rules.other.endingHash.test(X)){let J=L0(X,"#");(this.options.pedantic||!J||this.rules.other.endingSpaceChar.test(J))&&(X=J.trim())}return{type:"heading",raw:Y[0],depth:Y[1].length,text:X,tokens:this.lexer.inline(X)}}}hr(Z){let Y=this.rules.block.hr.exec(Z);if(Y)return{type:"hr",raw:L0(Y[0],`
77
- `)}}blockquote(Z){let Y=this.rules.block.blockquote.exec(Z);if(Y){let X=L0(Y[0],`
72
+ - 适合批量执行 MCP 相关操作`,parameters:t8.shape,handler:n.waitForUIDone,render($){let Z=$.getInputRepaired(),Y=$.output,J=typeof Y==="string"?Y:"",X=null;try{X=JSON.parse(J)}catch(Q){}let K=Array.isArray(Z?.commands)?Z.commands:[];return M1.jsxDEV(z,{flexDirection:"column",children:[M1.jsxDEV(z,{children:M1.jsxDEV(G,{color:"blue",bold:!0,children:"execute_mcp_tool"},void 0,!1,void 0,this)},void 0,!1,void 0,this),K.length>0&&M1.jsxDEV(z,{flexDirection:"column",marginTop:1,children:[M1.jsxDEV(G,{color:"gray",dimColor:!0,children:["执行 ",K.length," 个 MCP 工具:"]},void 0,!0,void 0,this),K.map((Q,W)=>{let _=Q&&typeof Q==="object"&&typeof Q.name==="string"?Q.name:String(Q?.name??"");return M1.jsxDEV(z,{marginLeft:2,children:[M1.jsxDEV(G,{color:"yellow",children:[W+1,"."]},void 0,!0,void 0,this),M1.jsxDEV(G,{color:"cyan",children:_},void 0,!1,void 0,this)]},W,!0,void 0,this)})]},void 0,!0,void 0,this),Array.isArray(X?.results)&&M1.jsxDEV(z,{flexDirection:"column",marginTop:1,children:X.results.map((Q,W)=>M1.jsxDEV(z,{marginLeft:2,children:Q?.error?M1.jsxDEV(G,{color:"red",children:["✗ ",typeof Q.tool==="string"?Q.tool:""]},void 0,!0,void 0,this):M1.jsxDEV(G,{color:"green",children:["✓ ",typeof Q.tool==="string"?Q.tool:""]},void 0,!0,void 0,this)},W,!1,void 0,this))},void 0,!1,void 0,this),J&&M1.jsxDEV(u0,{content:J,maxLines:10,borderColor:"gray"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}});var t1=A(M(),1);import{z as d0}from"zod";var e8=d0.object({task_id:d0.string().optional().describe("The task id to ask the subagent"),subagent_id:d0.string().describe("The id of subagent to use"),subagent_type:d0.string().describe("The type of subagent to use (general-purpose, statusline-setup, output-style-setup)"),task_description:d0.string().describe("Describe what you want the subagent to do"),data_transfer:d0.any().optional().describe("Data to transfer to the subagent")}),$Y=({tool:$})=>{let Z=$.getInputRepaired(),Y=typeof Z?.subagent_id==="string"?Z.subagent_id:String(Z?.subagent_id??"");return t1.jsxDEV(z,{paddingX:1,flexDirection:"column",children:t1.jsxDEV(z,{children:[t1.jsxDEV(G,{color:"yellow",children:"Task "},void 0,!1,void 0,this),t1.jsxDEV(G,{dimColor:!0,children:"("},void 0,!1,void 0,this),t1.jsxDEV(G,{color:"cyan",children:Y},void 0,!1,void 0,this),t1.jsxDEV(G,{dimColor:!0,children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},ZY=({tool:$})=>{return t1.jsxDEV(z,{flexDirection:"column",children:t1.jsxDEV($Y,{tool:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},m4=l({name:"task",description:"Launch a subagent to handle complex tasks autonomously",parameters:e8.shape,handler:n.waitForUIDone,render($){return t1.jsxDEV(ZY,{tool:$},void 0,!1,void 0,this)}});var c4=[b4,M4,v4,I4,y4,D4,V4,j4,E4,g4,p4,m4];var o=A(D(),1);var b=A(M(),1),YY=({validation:$,onComplete:Z})=>{let{config:Y,updateConfig:J}=t(),[X,K]=o.useState("welcome"),[Q,W]=o.useState(!1),[_,O]=o.useState(null),[N,U]=o.useState(0),[F,L]=o.useState(null),q=o.useRef(!0),w=o.useRef([]),R=o.useRef(N),P=Y?.providers||[];o.useEffect(()=>{w.current=P},[P]),o.useEffect(()=>{R.current=N},[N]);let S=P[N],u=o.useCallback(()=>L(null),[]);B1(u,F?3000:null);let m=o.useCallback(()=>{q.current=!0,O(null),W(!0),L(null)},[]),e=o.useCallback(()=>{let I=w.current,j=R.current,x=I[j];if(!x)return;q.current=!1,O(x),W(!0),L(null)},[]),v=o.useCallback(()=>{W(!1),O(null),L(null)},[]),i=o.useCallback(async(I)=>{let j=w.current,x=q.current,A1=x?[...j,I]:j.map((F0)=>F0.id===I.id?I:F0);if(await J({providers:A1}),L(x?`已添加 Provider: ${I.id}`:`已更新 Provider: ${I.id}`),x){let F0=A1.findIndex((p$)=>p$.id===I.id);U(F0>=0?F0:0)}v()},[J,v]),r=o.useCallback(()=>{if(!S||!S.apiKey){L("请先配置 Provider 的 API Key");return}J({provider_id:S.id,provider_type:S.type}).then(()=>{K("model")})},[S,J]);if(y1((I,j)=>{if(j.return||I===" ")K("provider")},{isActive:X==="welcome"}),y1((I,j)=>{if(Q)return;if(j.upArrow)U((x)=>x>0?x-1:P.length-1);else if(j.downArrow)U((x)=>x<P.length-1?x+1:0);else if(I==="n"||I==="N")m();else if((I==="e"||I==="E"||j.return)&&S)e();else if(I==="s"||I==="S")r()},{isActive:X==="provider"}),X==="welcome")return b.jsxDEV(z,{flexDirection:"column",paddingX:2,paddingY:1,width:"100%",children:[b.jsxDEV(z,{marginBottom:1,children:b.jsxDEV(G,{bold:!0,color:"cyan",children:"欢迎使用 Zen Code"},void 0,!1,void 0,this)},void 0,!1,void 0,this),b.jsxDEV(z,{marginBottom:1,children:b.jsxDEV(G,{color:"yellow",children:$.reason||"需要进行初始配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),b.jsxDEV(z,{flexDirection:"column",marginBottom:1,children:[b.jsxDEV(G,{dimColor:!0,children:"接下来将引导你完成:"},void 0,!1,void 0,this),b.jsxDEV(G,{dimColor:!0,children:" 1. 配置 Provider(API 服务提供商)"},void 0,!1,void 0,this),b.jsxDEV(G,{dimColor:!0,children:" 2. 选择 Model(AI 模型)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b.jsxDEV(z,{children:b.jsxDEV(G,{color:"green",bold:!0,children:"按 Enter 开始配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(X==="provider")return b.jsxDEV(z,{flexDirection:"column",width:"100%",children:[b.jsxDEV(z,{paddingX:2,paddingY:1,children:b.jsxDEV(G,{bold:!0,color:"cyan",children:"步骤 1/2: Provider 配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q?b.jsxDEV(x4,{provider:_||void 0,onCancel:v,onSave:i},void 0,!1,void 0,this):b.jsxDEV(b.Fragment,{children:b.jsxDEV(z,{flexDirection:"column",paddingX:2,gap:1,children:[P.length===0?b.jsxDEV(z,{paddingY:1,children:b.jsxDEV(G,{color:"yellow",children:"未配置任何 Provider,请按 'n' 新增"},void 0,!1,void 0,this)},void 0,!1,void 0,this):P.map((I,j)=>{let x=!!I.apiKey,A1=x?"green":"yellow";return b.jsxDEV(z,{marginBottom:0,gap:1,children:[b.jsxDEV(G,{color:j===N?"cyan":"gray",bold:j===N,children:j===N?">":" "},void 0,!1,void 0,this),b.jsxDEV(G,{bold:j===N,color:j===N?"cyan":void 0,children:I.id},void 0,!1,void 0,this),b.jsxDEV(G,{color:"gray",dimColor:j!==N,children:[" ",I.type]},void 0,!0,void 0,this),b.jsxDEV(G,{color:A1,dimColor:j!==N,children:[" ","[",x?"已配置":"未配置","]"]},void 0,!0,void 0,this)]},I.id,!0,void 0,this)}),b.jsxDEV(z,{marginTop:1,children:[b.jsxDEV(G,{color:"gray",dimColor:!0,children:[b.jsxDEV(G,{color:"cyan",children:"↑↓"},void 0,!1,void 0,this)," 导航 ",b.jsxDEV(G,{color:"cyan",children:"n"},void 0,!1,void 0,this)," 新增"," ",b.jsxDEV(G,{color:"cyan",children:"e/Enter"},void 0,!1,void 0,this)," 编辑"," "]},void 0,!0,void 0,this),P.some((I)=>I.apiKey)&&b.jsxDEV(G,{children:[b.jsxDEV(G,{color:"green",children:"s"},void 0,!1,void 0,this)," 下一步"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),F&&b.jsxDEV(z,{paddingX:2,paddingY:0,children:b.jsxDEV(G,{color:"green",children:F},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(X==="model")return b.jsxDEV(XY,{onComplete:Z,onBack:()=>K("provider")},void 0,!1,void 0,this);return null},XY=({onComplete:$,onBack:Z})=>{let{config:Y,updateConfig:J}=t(),[X,K]=o.useState(0),Q=o.useMemo(()=>{return Y?.providers.find((U)=>U.id===Y.provider_id)||null},[Y?.providers,Y?.provider_id]),{data:W=[],isLoading:_,error:O}=u4({provider:Q,enabled:!!Q?.apiKey}),N=W[X];if(y1((U,F)=>{if(F.upArrow)K((L)=>L>0?L-1:W.length-1);else if(F.downArrow)K((L)=>L<W.length-1?L+1:0);else if(F.escape||U==="b"||U==="B")Z();else if((F.return||U===" ")&&N)J({model_id:N.id}).then(()=>{$()})},{isActive:!_&&!O&&Y!==null}),_)return b.jsxDEV(z,{flexDirection:"column",paddingX:2,paddingY:1,children:[b.jsxDEV(G,{bold:!0,color:"cyan",children:"步骤 2/2: Model 选择"},void 0,!1,void 0,this),b.jsxDEV(z,{marginTop:1,children:b.jsxDEV(G,{color:"gray",children:"加载模型列表中..."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(O)return b.jsxDEV(z,{flexDirection:"column",paddingX:2,paddingY:1,children:[b.jsxDEV(G,{bold:!0,color:"cyan",children:"步骤 2/2: Model 选择"},void 0,!1,void 0,this),b.jsxDEV(z,{marginTop:1,children:b.jsxDEV(G,{color:"red",children:["加载失败: ",O.message]},void 0,!0,void 0,this)},void 0,!1,void 0,this),b.jsxDEV(z,{marginTop:1,children:b.jsxDEV(G,{color:"gray",dimColor:!0,children:["按 ",b.jsxDEV(G,{color:"cyan",children:"Esc"},void 0,!1,void 0,this)," 返回上一步"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return b.jsxDEV(z,{flexDirection:"column",width:"100%",children:[b.jsxDEV(z,{paddingX:2,paddingY:1,children:[b.jsxDEV(G,{bold:!0,color:"cyan",children:"步骤 2/2: Model 选择"},void 0,!1,void 0,this),Q&&b.jsxDEV(G,{dimColor:!0,children:[" ","- ",Q.id," (",Q.type,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),b.jsxDEV(z,{flexDirection:"column",paddingX:2,gap:0,children:W.map((U,F)=>b.jsxDEV(z,{marginBottom:0,gap:1,children:[b.jsxDEV(G,{color:F===X?"cyan":"gray",bold:F===X,children:F===X?">":" "},void 0,!1,void 0,this),b.jsxDEV(G,{bold:F===X,color:F===X?"cyan":void 0,children:U.id},void 0,!1,void 0,this),U.name!==U.id&&b.jsxDEV(G,{dimColor:F!==X,children:["(",U.name,")"]},void 0,!0,void 0,this)]},U.id,!0,void 0,this))},void 0,!1,void 0,this),b.jsxDEV(z,{marginTop:1,paddingX:2,children:b.jsxDEV(G,{color:"gray",dimColor:!0,children:[b.jsxDEV(G,{color:"cyan",children:"↑↓"},void 0,!1,void 0,this)," 导航 ",b.jsxDEV(G,{color:"cyan",children:"Enter/Space"},void 0,!1,void 0,this)," 确认"," ",b.jsxDEV(G,{color:"cyan",children:"Esc/B"},void 0,!1,void 0,this)," 返回"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},d4=YY;var l0=A(M(),1),JY=({children:$})=>{let{extraParams:Z,toggleCompactMode:Y,config:J}=t(),{setTools:X,loading:K}=Z1(),{hasPendingInteractions:Q}=k1();s6({tools:c4,setTools:X});let{needsSetup:W,validation:_}=$4({config:J});Y4({shouldFocus:!K});let O=X4(),{isChatView:N}=O,{handleExecuteTask:U}=J4({closePanel:O.closePanel});if(y1((L,q)=>{if(q.ctrl&&L==="o"&&N&&!K)Y();else if(q.ctrl&&L==="z"&&globalThis.Bun)import("v8").then((w)=>{w.writeHeapSnapshot("my-application.heapsnapshot")})},{isActive:N}),W&&_)return l0.jsxDEV(g,{name:"SetupWizard",fallback:null,children:l0.jsxDEV(d4,{validation:_,onComplete:O.closePanel},void 0,!1,void 0,this)},void 0,!1,void 0,this);let F={activeView:O.activeView,isChatView:O.isChatView,switchToHistory:O.switchToHistory,switchToKnowledge:O.switchToKnowledge,switchToSettings:O.switchToSettings,switchToModelProvider:O.switchToModelProvider,switchToAgent:O.switchToAgent,switchToTask:O.switchToTask,switchToMcp:O.switchToMcp,switchToProcess:O.switchToProcess,switchToErrors:O.switchToErrors,closePanel:O.closePanel,handleExecuteTask:U,hasPendingInteractions:Q};return l0.jsxDEV(g,{name:"ChatPanelContext",fallback:null,children:l0.jsxDEV(Q4,{value:F,children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},l4=({children:$})=>{return l0.jsxDEV(JY,{children:$},void 0,!1,void 0,this)};var FZ=A(D(),1);var I$=A(D(),1);var W0=A(M(),1),KY=({content:$,messageNumber:Z})=>{let Y=q$(),J=()=>{if(typeof $==="string")return W0.jsxDEV(G,{color:"white",children:$},void 0,!1,void 0,this);if(Array.isArray($))return $.filter((X)=>X.type==="text").map((X,K)=>W0.jsxDEV(G,{color:"white",children:X.text},void 0,!1,void 0,this));return W0.jsxDEV(G,{color:"white",children:JSON.stringify($)},void 0,!1,void 0,this)};return W0.jsxDEV(z,{flexDirection:"column",children:[W0.jsxDEV(z,{children:W0.jsxDEV(G,{color:S0("amber"),children:[Z," ",Y]},void 0,!0,void 0,this)},void 0,!1,void 0,this),W0.jsxDEV(z,{children:W0.jsxDEV(G,{color:"gray",children:["└─ ",J()]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},w$=KY;var B=A(xY(),1);function Q6(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var T0=Q6();function t4($){T0=$}var X$={exec:()=>null};function E($,Z=""){let Y=typeof $=="string"?$:$.source,J={replace:(X,K)=>{let Q=typeof K=="string"?K:K.source;return Q=Q.replace(z1.caret,"$1"),Y=Y.replace(X,Q),J},getRegex:()=>new RegExp(Y,Z)};return J}var QY=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),z1={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:($)=>new RegExp(`^( {0,3}${$})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}#`),htmlBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}<(?:[a-z].*>|!--)`,"i")},WY=/^(?:[ \t]*(?:\n|$))+/,_Y=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,GY=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,J$=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,OY=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,W6=/(?:[*+-]|\d{1,9}[.)])/,e4=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,$3=E(e4).replace(/bull/g,W6).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),UY=E(e4).replace(/bull/g,W6).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),_6=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,NY=/^[^\n]+/,G6=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,zY=E(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",G6).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),HY=E(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,W6).getRegex(),P$="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",O6=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,FY=E("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",O6).replace("tag",P$).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Z3=E(_6).replace("hr",J$).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",P$).getRegex(),LY=E(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Z3).getRegex(),U6={blockquote:LY,code:_Y,def:zY,fences:GY,heading:OY,hr:J$,html:FY,lheading:$3,list:HY,newline:WY,paragraph:Z3,table:X$,text:NY},i4=E("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",J$).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",P$).getRegex(),AY={...U6,lheading:UY,table:i4,paragraph:E(_6).replace("hr",J$).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",i4).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",P$).getRegex()},qY={...U6,html:E(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",O6).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:X$,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:E(_6).replace("hr",J$).replace("heading",` *#{1,6} *[^
73
+ ]`).replace("lheading",$3).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},wY=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,MY=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Y3=/^( {2,}|\\)\n(?!\s*$)/,RY=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,f$=/[\p{P}\p{S}]/u,N6=/[\s\p{P}\p{S}]/u,X3=/[^\s\p{P}\p{S}]/u,bY=E(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,N6).getRegex(),J3=/(?!~)[\p{P}\p{S}]/u,BY=/(?!~)[\s\p{P}\p{S}]/u,PY=/(?:[^\s\p{P}\p{S}]|~)/u,fY=E(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",QY?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),K3=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,CY=E(K3,"u").replace(/punct/g,f$).getRegex(),vY=E(K3,"u").replace(/punct/g,J3).getRegex(),Q3="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",SY=E(Q3,"gu").replace(/notPunctSpace/g,X3).replace(/punctSpace/g,N6).replace(/punct/g,f$).getRegex(),IY=E(Q3,"gu").replace(/notPunctSpace/g,PY).replace(/punctSpace/g,BY).replace(/punct/g,J3).getRegex(),kY=E("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,X3).replace(/punctSpace/g,N6).replace(/punct/g,f$).getRegex(),yY=E(/\\(punct)/,"gu").replace(/punct/g,f$).getRegex(),TY=E(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),DY=E(O6).replace("(?:-->|$)","-->").getRegex(),VY=E("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",DY).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),R$=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,jY=E(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",R$).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),W3=E(/^!?\[(label)\]\[(ref)\]/).replace("label",R$).replace("ref",G6).getRegex(),_3=E(/^!?\[(ref)\](?:\[\])?/).replace("ref",G6).getRegex(),hY=E("reflink|nolink(?!\\()","g").replace("reflink",W3).replace("nolink",_3).getRegex(),o4=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,z6={_backpedal:X$,anyPunctuation:yY,autolink:TY,blockSkip:fY,br:Y3,code:MY,del:X$,emStrongLDelim:CY,emStrongRDelimAst:SY,emStrongRDelimUnd:kY,escape:wY,link:jY,nolink:_3,punctuation:bY,reflink:W3,reflinkSearch:hY,tag:VY,text:RY,url:X$},EY={...z6,link:E(/^!?\[(label)\]\((.*?)\)/).replace("label",R$).getRegex(),reflink:E(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",R$).getRegex()},K6={...z6,emStrongRDelimAst:IY,emStrongLDelim:vY,url:E(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",o4).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:E(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",o4).getRegex()},gY={...K6,br:E(Y3).replace("{2,}","*").getRegex(),text:E(K6.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},M$={normal:U6,gfm:AY,pedantic:qY},$$={normal:z6,gfm:K6,breaks:gY,pedantic:EY},pY={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},r4=($)=>pY[$];function e1($,Z){if(Z){if(z1.escapeTest.test($))return $.replace(z1.escapeReplace,r4)}else if(z1.escapeTestNoEncode.test($))return $.replace(z1.escapeReplaceNoEncode,r4);return $}function n4($){try{$=encodeURI($).replace(z1.percentDecode,"%")}catch{return null}return $}function a4($,Z){let Y=$.replace(z1.findPipe,(K,Q,W)=>{let _=!1,O=Q;for(;--O>=0&&W[O]==="\\";)_=!_;return _?"|":" |"}),J=Y.split(z1.splitPipe),X=0;if(J[0].trim()||J.shift(),J.length>0&&!J.at(-1)?.trim()&&J.pop(),Z)if(J.length>Z)J.splice(Z);else for(;J.length<Z;)J.push("");for(;X<J.length;X++)J[X]=J[X].trim().replace(z1.slashPipe,"|");return J}function Z$($,Z,Y){let J=$.length;if(J===0)return"";let X=0;for(;X<J;){let K=$.charAt(J-X-1);if(K===Z&&!Y)X++;else if(K!==Z&&Y)X++;else break}return $.slice(0,J-X)}function mY($,Z){if($.indexOf(Z[1])===-1)return-1;let Y=0;for(let J=0;J<$.length;J++)if($[J]==="\\")J++;else if($[J]===Z[0])Y++;else if($[J]===Z[1]&&(Y--,Y<0))return J;return Y>0?-2:-1}function s4($,Z,Y,J,X){let K=Z.href,Q=Z.title||null,W=$[1].replace(X.other.outputLinkReplace,"$1");J.state.inLink=!0;let _={type:$[0].charAt(0)==="!"?"image":"link",raw:Y,href:K,title:Q,text:W,tokens:J.inlineTokens(W)};return J.state.inLink=!1,_}function cY($,Z,Y){let J=$.match(Y.other.indentCodeCompensation);if(J===null)return Z;let X=J[1];return Z.split(`
74
+ `).map((K)=>{let Q=K.match(Y.other.beginningSpace);if(Q===null)return K;let[W]=Q;return W.length>=X.length?K.slice(X.length):K}).join(`
75
+ `)}var b$=class{options;rules;lexer;constructor($){this.options=$||T0}space($){let Z=this.rules.block.newline.exec($);if(Z&&Z[0].length>0)return{type:"space",raw:Z[0]}}code($){let Z=this.rules.block.code.exec($);if(Z){let Y=Z[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:Z[0],codeBlockStyle:"indented",text:this.options.pedantic?Y:Z$(Y,`
76
+ `)}}}fences($){let Z=this.rules.block.fences.exec($);if(Z){let Y=Z[0],J=cY(Y,Z[3]||"",this.rules);return{type:"code",raw:Y,lang:Z[2]?Z[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):Z[2],text:J}}}heading($){let Z=this.rules.block.heading.exec($);if(Z){let Y=Z[2].trim();if(this.rules.other.endingHash.test(Y)){let J=Z$(Y,"#");(this.options.pedantic||!J||this.rules.other.endingSpaceChar.test(J))&&(Y=J.trim())}return{type:"heading",raw:Z[0],depth:Z[1].length,text:Y,tokens:this.lexer.inline(Y)}}}hr($){let Z=this.rules.block.hr.exec($);if(Z)return{type:"hr",raw:Z$(Z[0],`
77
+ `)}}blockquote($){let Z=this.rules.block.blockquote.exec($);if(Z){let Y=Z$(Z[0],`
78
78
  `).split(`
79
- `),J="",Q="",$=[];for(;X.length>0;){let K=!1,U=[],W;for(W=0;W<X.length;W++)if(this.rules.other.blockquoteStart.test(X[W]))U.push(X[W]),K=!0;else if(!K)U.push(X[W]);else break;X=X.slice(W);let z=U.join(`
80
- `),H=z.replace(this.rules.other.blockquoteSetextReplace,`
79
+ `),J="",X="",K=[];for(;Y.length>0;){let Q=!1,W=[],_;for(_=0;_<Y.length;_++)if(this.rules.other.blockquoteStart.test(Y[_]))W.push(Y[_]),Q=!0;else if(!Q)W.push(Y[_]);else break;Y=Y.slice(_);let O=W.join(`
80
+ `),N=O.replace(this.rules.other.blockquoteSetextReplace,`
81
81
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");J=J?`${J}
82
- ${z}`:z,Q=Q?`${Q}
83
- ${H}`:H;let G=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(H,$,!0),this.lexer.state.top=G,X.length===0)break;let F=$.at(-1);if(F?.type==="code")break;if(F?.type==="blockquote"){let M=F,N=M.raw+`
84
- `+X.join(`
85
- `),w=this.blockquote(N);$[$.length-1]=w,J=J.substring(0,J.length-M.raw.length)+w.raw,Q=Q.substring(0,Q.length-M.text.length)+w.text;break}else if(F?.type==="list"){let M=F,N=M.raw+`
86
- `+X.join(`
87
- `),w=this.list(N);$[$.length-1]=w,J=J.substring(0,J.length-F.raw.length)+w.raw,Q=Q.substring(0,Q.length-M.raw.length)+w.raw,X=N.substring($.at(-1).raw.length).split(`
88
- `);continue}}return{type:"blockquote",raw:J,tokens:$,text:Q}}}list(Z){let Y=this.rules.block.list.exec(Z);if(Y){let X=Y[1].trim(),J=X.length>1,Q={type:"list",raw:"",ordered:J,start:J?+X.slice(0,-1):"",loose:!1,items:[]};X=J?`\\d{1,9}\\${X.slice(-1)}`:`\\${X}`,this.options.pedantic&&(X=J?X:"[*+-]");let $=this.rules.other.listItemRegex(X),K=!1;for(;Z;){let W=!1,z="",H="";if(!(Y=$.exec(Z))||this.rules.block.hr.test(Z))break;z=Y[0],Z=Z.substring(z.length);let G=Y[2].split(`
89
- `,1)[0].replace(this.rules.other.listReplaceTabs,(B)=>" ".repeat(3*B.length)),F=Z.split(`
90
- `,1)[0],M=!G.trim(),N=0;if(this.options.pedantic?(N=2,H=G.trimStart()):M?N=Y[1].length+1:(N=Y[2].search(this.rules.other.nonSpaceChar),N=N>4?1:N,H=G.slice(N),N+=Y[1].length),M&&this.rules.other.blankLine.test(F)&&(z+=F+`
91
- `,Z=Z.substring(F.length+1),W=!0),!W){let B=this.rules.other.nextBulletRegex(N),C=this.rules.other.hrRegex(N),R=this.rules.other.fencesBeginRegex(N),D=this.rules.other.headingBeginRegex(N),f=this.rules.other.htmlBeginRegex(N);for(;Z;){let V=Z.split(`
92
- `,1)[0],d;if(F=V,this.options.pedantic?(F=F.replace(this.rules.other.listReplaceNesting," "),d=F):d=F.replace(this.rules.other.tabCharGlobal," "),R.test(F)||D.test(F)||f.test(F)||B.test(F)||C.test(F))break;if(d.search(this.rules.other.nonSpaceChar)>=N||!F.trim())H+=`
93
- `+d.slice(N);else{if(M||G.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||R.test(G)||D.test(G)||C.test(G))break;H+=`
94
- `+F}!M&&!F.trim()&&(M=!0),z+=V+`
95
- `,Z=Z.substring(V.length+1),G=d.slice(N)}}Q.loose||(K?Q.loose=!0:this.rules.other.doubleBlankLine.test(z)&&(K=!0));let w=null,L;this.options.gfm&&(w=this.rules.other.listIsTask.exec(H),w&&(L=w[0]!=="[ ] ",H=H.replace(this.rules.other.listReplaceTask,""))),Q.items.push({type:"list_item",raw:z,task:!!w,checked:L,loose:!1,text:H,tokens:[]}),Q.raw+=z}let U=Q.items.at(-1);if(U)U.raw=U.raw.trimEnd(),U.text=U.text.trimEnd();else return;Q.raw=Q.raw.trimEnd();for(let W=0;W<Q.items.length;W++)if(this.lexer.state.top=!1,Q.items[W].tokens=this.lexer.blockTokens(Q.items[W].text,[]),!Q.loose){let z=Q.items[W].tokens.filter((G)=>G.type==="space"),H=z.length>0&&z.some((G)=>this.rules.other.anyLine.test(G.raw));Q.loose=H}if(Q.loose)for(let W=0;W<Q.items.length;W++)Q.items[W].loose=!0;return Q}}html(Z){let Y=this.rules.block.html.exec(Z);if(Y)return{type:"html",block:!0,raw:Y[0],pre:Y[1]==="pre"||Y[1]==="script"||Y[1]==="style",text:Y[0]}}def(Z){let Y=this.rules.block.def.exec(Z);if(Y){let X=Y[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),J=Y[2]?Y[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",Q=Y[3]?Y[3].substring(1,Y[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):Y[3];return{type:"def",tag:X,raw:Y[0],href:J,title:Q}}}table(Z){let Y=this.rules.block.table.exec(Z);if(!Y||!this.rules.other.tableDelimiter.test(Y[2]))return;let X=I5(Y[1]),J=Y[2].replace(this.rules.other.tableAlignChars,"").split("|"),Q=Y[3]?.trim()?Y[3].replace(this.rules.other.tableRowBlankLine,"").split(`
96
- `):[],$={type:"table",raw:Y[0],header:[],align:[],rows:[]};if(X.length===J.length){for(let K of J)this.rules.other.tableAlignRight.test(K)?$.align.push("right"):this.rules.other.tableAlignCenter.test(K)?$.align.push("center"):this.rules.other.tableAlignLeft.test(K)?$.align.push("left"):$.align.push(null);for(let K=0;K<X.length;K++)$.header.push({text:X[K],tokens:this.lexer.inline(X[K]),header:!0,align:$.align[K]});for(let K of Q)$.rows.push(I5(K,$.header.length).map((U,W)=>({text:U,tokens:this.lexer.inline(U),header:!1,align:$.align[W]})));return $}}lheading(Z){let Y=this.rules.block.lheading.exec(Z);if(Y)return{type:"heading",raw:Y[0],depth:Y[2].charAt(0)==="="?1:2,text:Y[1],tokens:this.lexer.inline(Y[1])}}paragraph(Z){let Y=this.rules.block.paragraph.exec(Z);if(Y){let X=Y[1].charAt(Y[1].length-1)===`
97
- `?Y[1].slice(0,-1):Y[1];return{type:"paragraph",raw:Y[0],text:X,tokens:this.lexer.inline(X)}}}text(Z){let Y=this.rules.block.text.exec(Z);if(Y)return{type:"text",raw:Y[0],text:Y[0],tokens:this.lexer.inline(Y[0])}}escape(Z){let Y=this.rules.inline.escape.exec(Z);if(Y)return{type:"escape",raw:Y[0],text:Y[1]}}tag(Z){let Y=this.rules.inline.tag.exec(Z);if(Y)return!this.lexer.state.inLink&&this.rules.other.startATag.test(Y[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(Y[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(Y[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(Y[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:Y[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:Y[0]}}link(Z){let Y=this.rules.inline.link.exec(Z);if(Y){let X=Y[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(X)){if(!this.rules.other.endAngleBracket.test(X))return;let $=L0(X.slice(0,-1),"\\");if((X.length-$.length)%2===0)return}else{let $=bK(Y[2],"()");if($===-2)return;if($>-1){let K=(Y[0].indexOf("!")===0?5:4)+Y[1].length+$;Y[2]=Y[2].substring(0,$),Y[0]=Y[0].substring(0,K).trim(),Y[3]=""}}let J=Y[2],Q="";if(this.options.pedantic){let $=this.rules.other.pedanticHrefTitle.exec(J);$&&(J=$[1],Q=$[3])}else Q=Y[3]?Y[3].slice(1,-1):"";return J=J.trim(),this.rules.other.startAngleBracket.test(J)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(X)?J=J.slice(1):J=J.slice(1,-1)),v5(Y,{href:J&&J.replace(this.rules.inline.anyPunctuation,"$1"),title:Q&&Q.replace(this.rules.inline.anyPunctuation,"$1")},Y[0],this.lexer,this.rules)}}reflink(Z,Y){let X;if((X=this.rules.inline.reflink.exec(Z))||(X=this.rules.inline.nolink.exec(Z))){let J=(X[2]||X[1]).replace(this.rules.other.multipleSpaceGlobal," "),Q=Y[J.toLowerCase()];if(!Q){let $=X[0].charAt(0);return{type:"text",raw:$,text:$}}return v5(X,Q,X[0],this.lexer,this.rules)}}emStrong(Z,Y,X=""){let J=this.rules.inline.emStrongLDelim.exec(Z);if(!J||J[3]&&X.match(this.rules.other.unicodeAlphaNumeric))return;if(!(J[1]||J[2])||!X||this.rules.inline.punctuation.exec(X)){let Q=[...J[0]].length-1,$,K,U=Q,W=0,z=J[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(z.lastIndex=0,Y=Y.slice(-1*Z.length+Q);(J=z.exec(Y))!=null;){if($=J[1]||J[2]||J[3]||J[4]||J[5]||J[6],!$)continue;if(K=[...$].length,J[3]||J[4]){U+=K;continue}else if((J[5]||J[6])&&Q%3&&!((Q+K)%3)){W+=K;continue}if(U-=K,U>0)continue;K=Math.min(K,K+U+W);let H=[...J[0]][0].length,G=Z.slice(0,Q+J.index+H+K);if(Math.min(Q,K)%2){let M=G.slice(1,-1);return{type:"em",raw:G,text:M,tokens:this.lexer.inlineTokens(M)}}let F=G.slice(2,-2);return{type:"strong",raw:G,text:F,tokens:this.lexer.inlineTokens(F)}}}}codespan(Z){let Y=this.rules.inline.code.exec(Z);if(Y){let X=Y[2].replace(this.rules.other.newLineCharGlobal," "),J=this.rules.other.nonSpaceChar.test(X),Q=this.rules.other.startingSpaceChar.test(X)&&this.rules.other.endingSpaceChar.test(X);return J&&Q&&(X=X.substring(1,X.length-1)),{type:"codespan",raw:Y[0],text:X}}}br(Z){let Y=this.rules.inline.br.exec(Z);if(Y)return{type:"br",raw:Y[0]}}del(Z){let Y=this.rules.inline.del.exec(Z);if(Y)return{type:"del",raw:Y[0],text:Y[2],tokens:this.lexer.inlineTokens(Y[2])}}autolink(Z){let Y=this.rules.inline.autolink.exec(Z);if(Y){let X,J;return Y[2]==="@"?(X=Y[1],J="mailto:"+X):(X=Y[1],J=X),{type:"link",raw:Y[0],text:X,href:J,tokens:[{type:"text",raw:X,text:X}]}}}url(Z){let Y;if(Y=this.rules.inline.url.exec(Z)){let X,J;if(Y[2]==="@")X=Y[0],J="mailto:"+X;else{let Q;do Q=Y[0],Y[0]=this.rules.inline._backpedal.exec(Y[0])?.[0]??"";while(Q!==Y[0]);X=Y[0],Y[1]==="www."?J="http://"+Y[0]:J=Y[0]}return{type:"link",raw:Y[0],text:X,href:J,tokens:[{type:"text",raw:X,text:X}]}}}inlineText(Z){let Y=this.rules.inline.text.exec(Z);if(Y){let X=this.lexer.state.inRawBlock;return{type:"text",raw:Y[0],text:Y[0],escaped:X}}}},aZ=class Z{tokens;options;state;tokenizer;inlineQueue;constructor(Y){this.tokens=[],this.tokens.links=Object.create(null),this.options=Y||r4,this.options.tokenizer=this.options.tokenizer||new XY,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let X={other:RZ,block:ZY.normal,inline:B0.normal};this.options.pedantic?(X.block=ZY.pedantic,X.inline=B0.pedantic):this.options.gfm&&(X.block=ZY.gfm,this.options.breaks?X.inline=B0.breaks:X.inline=B0.gfm),this.tokenizer.rules=X}static get rules(){return{block:ZY,inline:B0}}static lex(Y,X){return new Z(X).lex(Y)}static lexInline(Y,X){return new Z(X).inlineTokens(Y)}lex(Y){Y=Y.replace(RZ.carriageReturn,`
98
- `),this.blockTokens(Y,this.tokens);for(let X=0;X<this.inlineQueue.length;X++){let J=this.inlineQueue[X];this.inlineTokens(J.src,J.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(Y,X=[],J=!1){for(this.options.pedantic&&(Y=Y.replace(RZ.tabCharGlobal," ").replace(RZ.spaceLine,""));Y;){let Q;if(this.options.extensions?.block?.some((K)=>(Q=K.call({lexer:this},Y,X))?(Y=Y.substring(Q.raw.length),X.push(Q),!0):!1))continue;if(Q=this.tokenizer.space(Y)){Y=Y.substring(Q.raw.length);let K=X.at(-1);Q.raw.length===1&&K!==void 0?K.raw+=`
99
- `:X.push(Q);continue}if(Q=this.tokenizer.code(Y)){Y=Y.substring(Q.raw.length);let K=X.at(-1);K?.type==="paragraph"||K?.type==="text"?(K.raw+=(K.raw.endsWith(`
82
+ ${O}`:O,X=X?`${X}
83
+ ${N}`:N;let U=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(N,K,!0),this.lexer.state.top=U,Y.length===0)break;let F=K.at(-1);if(F?.type==="code")break;if(F?.type==="blockquote"){let L=F,q=L.raw+`
84
+ `+Y.join(`
85
+ `),w=this.blockquote(q);K[K.length-1]=w,J=J.substring(0,J.length-L.raw.length)+w.raw,X=X.substring(0,X.length-L.text.length)+w.text;break}else if(F?.type==="list"){let L=F,q=L.raw+`
86
+ `+Y.join(`
87
+ `),w=this.list(q);K[K.length-1]=w,J=J.substring(0,J.length-F.raw.length)+w.raw,X=X.substring(0,X.length-L.raw.length)+w.raw,Y=q.substring(K.at(-1).raw.length).split(`
88
+ `);continue}}return{type:"blockquote",raw:J,tokens:K,text:X}}}list($){let Z=this.rules.block.list.exec($);if(Z){let Y=Z[1].trim(),J=Y.length>1,X={type:"list",raw:"",ordered:J,start:J?+Y.slice(0,-1):"",loose:!1,items:[]};Y=J?`\\d{1,9}\\${Y.slice(-1)}`:`\\${Y}`,this.options.pedantic&&(Y=J?Y:"[*+-]");let K=this.rules.other.listItemRegex(Y),Q=!1;for(;$;){let _=!1,O="",N="";if(!(Z=K.exec($))||this.rules.block.hr.test($))break;O=Z[0],$=$.substring(O.length);let U=Z[2].split(`
89
+ `,1)[0].replace(this.rules.other.listReplaceTabs,(P)=>" ".repeat(3*P.length)),F=$.split(`
90
+ `,1)[0],L=!U.trim(),q=0;if(this.options.pedantic?(q=2,N=U.trimStart()):L?q=Z[1].length+1:(q=Z[2].search(this.rules.other.nonSpaceChar),q=q>4?1:q,N=U.slice(q),q+=Z[1].length),L&&this.rules.other.blankLine.test(F)&&(O+=F+`
91
+ `,$=$.substring(F.length+1),_=!0),!_){let P=this.rules.other.nextBulletRegex(q),S=this.rules.other.hrRegex(q),u=this.rules.other.fencesBeginRegex(q),m=this.rules.other.headingBeginRegex(q),e=this.rules.other.htmlBeginRegex(q);for(;$;){let v=$.split(`
92
+ `,1)[0],i;if(F=v,this.options.pedantic?(F=F.replace(this.rules.other.listReplaceNesting," "),i=F):i=F.replace(this.rules.other.tabCharGlobal," "),u.test(F)||m.test(F)||e.test(F)||P.test(F)||S.test(F))break;if(i.search(this.rules.other.nonSpaceChar)>=q||!F.trim())N+=`
93
+ `+i.slice(q);else{if(L||U.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||u.test(U)||m.test(U)||S.test(U))break;N+=`
94
+ `+F}!L&&!F.trim()&&(L=!0),O+=v+`
95
+ `,$=$.substring(v.length+1),U=i.slice(q)}}X.loose||(Q?X.loose=!0:this.rules.other.doubleBlankLine.test(O)&&(Q=!0));let w=null,R;this.options.gfm&&(w=this.rules.other.listIsTask.exec(N),w&&(R=w[0]!=="[ ] ",N=N.replace(this.rules.other.listReplaceTask,""))),X.items.push({type:"list_item",raw:O,task:!!w,checked:R,loose:!1,text:N,tokens:[]}),X.raw+=O}let W=X.items.at(-1);if(W)W.raw=W.raw.trimEnd(),W.text=W.text.trimEnd();else return;X.raw=X.raw.trimEnd();for(let _=0;_<X.items.length;_++)if(this.lexer.state.top=!1,X.items[_].tokens=this.lexer.blockTokens(X.items[_].text,[]),!X.loose){let O=X.items[_].tokens.filter((U)=>U.type==="space"),N=O.length>0&&O.some((U)=>this.rules.other.anyLine.test(U.raw));X.loose=N}if(X.loose)for(let _=0;_<X.items.length;_++)X.items[_].loose=!0;return X}}html($){let Z=this.rules.block.html.exec($);if(Z)return{type:"html",block:!0,raw:Z[0],pre:Z[1]==="pre"||Z[1]==="script"||Z[1]==="style",text:Z[0]}}def($){let Z=this.rules.block.def.exec($);if(Z){let Y=Z[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),J=Z[2]?Z[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",X=Z[3]?Z[3].substring(1,Z[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):Z[3];return{type:"def",tag:Y,raw:Z[0],href:J,title:X}}}table($){let Z=this.rules.block.table.exec($);if(!Z||!this.rules.other.tableDelimiter.test(Z[2]))return;let Y=a4(Z[1]),J=Z[2].replace(this.rules.other.tableAlignChars,"").split("|"),X=Z[3]?.trim()?Z[3].replace(this.rules.other.tableRowBlankLine,"").split(`
96
+ `):[],K={type:"table",raw:Z[0],header:[],align:[],rows:[]};if(Y.length===J.length){for(let Q of J)this.rules.other.tableAlignRight.test(Q)?K.align.push("right"):this.rules.other.tableAlignCenter.test(Q)?K.align.push("center"):this.rules.other.tableAlignLeft.test(Q)?K.align.push("left"):K.align.push(null);for(let Q=0;Q<Y.length;Q++)K.header.push({text:Y[Q],tokens:this.lexer.inline(Y[Q]),header:!0,align:K.align[Q]});for(let Q of X)K.rows.push(a4(Q,K.header.length).map((W,_)=>({text:W,tokens:this.lexer.inline(W),header:!1,align:K.align[_]})));return K}}lheading($){let Z=this.rules.block.lheading.exec($);if(Z)return{type:"heading",raw:Z[0],depth:Z[2].charAt(0)==="="?1:2,text:Z[1],tokens:this.lexer.inline(Z[1])}}paragraph($){let Z=this.rules.block.paragraph.exec($);if(Z){let Y=Z[1].charAt(Z[1].length-1)===`
97
+ `?Z[1].slice(0,-1):Z[1];return{type:"paragraph",raw:Z[0],text:Y,tokens:this.lexer.inline(Y)}}}text($){let Z=this.rules.block.text.exec($);if(Z)return{type:"text",raw:Z[0],text:Z[0],tokens:this.lexer.inline(Z[0])}}escape($){let Z=this.rules.inline.escape.exec($);if(Z)return{type:"escape",raw:Z[0],text:Z[1]}}tag($){let Z=this.rules.inline.tag.exec($);if(Z)return!this.lexer.state.inLink&&this.rules.other.startATag.test(Z[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(Z[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(Z[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(Z[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:Z[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:Z[0]}}link($){let Z=this.rules.inline.link.exec($);if(Z){let Y=Z[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(Y)){if(!this.rules.other.endAngleBracket.test(Y))return;let K=Z$(Y.slice(0,-1),"\\");if((Y.length-K.length)%2===0)return}else{let K=mY(Z[2],"()");if(K===-2)return;if(K>-1){let Q=(Z[0].indexOf("!")===0?5:4)+Z[1].length+K;Z[2]=Z[2].substring(0,K),Z[0]=Z[0].substring(0,Q).trim(),Z[3]=""}}let J=Z[2],X="";if(this.options.pedantic){let K=this.rules.other.pedanticHrefTitle.exec(J);K&&(J=K[1],X=K[3])}else X=Z[3]?Z[3].slice(1,-1):"";return J=J.trim(),this.rules.other.startAngleBracket.test(J)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(Y)?J=J.slice(1):J=J.slice(1,-1)),s4(Z,{href:J&&J.replace(this.rules.inline.anyPunctuation,"$1"),title:X&&X.replace(this.rules.inline.anyPunctuation,"$1")},Z[0],this.lexer,this.rules)}}reflink($,Z){let Y;if((Y=this.rules.inline.reflink.exec($))||(Y=this.rules.inline.nolink.exec($))){let J=(Y[2]||Y[1]).replace(this.rules.other.multipleSpaceGlobal," "),X=Z[J.toLowerCase()];if(!X){let K=Y[0].charAt(0);return{type:"text",raw:K,text:K}}return s4(Y,X,Y[0],this.lexer,this.rules)}}emStrong($,Z,Y=""){let J=this.rules.inline.emStrongLDelim.exec($);if(!J||J[3]&&Y.match(this.rules.other.unicodeAlphaNumeric))return;if(!(J[1]||J[2])||!Y||this.rules.inline.punctuation.exec(Y)){let X=[...J[0]].length-1,K,Q,W=X,_=0,O=J[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(O.lastIndex=0,Z=Z.slice(-1*$.length+X);(J=O.exec(Z))!=null;){if(K=J[1]||J[2]||J[3]||J[4]||J[5]||J[6],!K)continue;if(Q=[...K].length,J[3]||J[4]){W+=Q;continue}else if((J[5]||J[6])&&X%3&&!((X+Q)%3)){_+=Q;continue}if(W-=Q,W>0)continue;Q=Math.min(Q,Q+W+_);let N=[...J[0]][0].length,U=$.slice(0,X+J.index+N+Q);if(Math.min(X,Q)%2){let L=U.slice(1,-1);return{type:"em",raw:U,text:L,tokens:this.lexer.inlineTokens(L)}}let F=U.slice(2,-2);return{type:"strong",raw:U,text:F,tokens:this.lexer.inlineTokens(F)}}}}codespan($){let Z=this.rules.inline.code.exec($);if(Z){let Y=Z[2].replace(this.rules.other.newLineCharGlobal," "),J=this.rules.other.nonSpaceChar.test(Y),X=this.rules.other.startingSpaceChar.test(Y)&&this.rules.other.endingSpaceChar.test(Y);return J&&X&&(Y=Y.substring(1,Y.length-1)),{type:"codespan",raw:Z[0],text:Y}}}br($){let Z=this.rules.inline.br.exec($);if(Z)return{type:"br",raw:Z[0]}}del($){let Z=this.rules.inline.del.exec($);if(Z)return{type:"del",raw:Z[0],text:Z[2],tokens:this.lexer.inlineTokens(Z[2])}}autolink($){let Z=this.rules.inline.autolink.exec($);if(Z){let Y,J;return Z[2]==="@"?(Y=Z[1],J="mailto:"+Y):(Y=Z[1],J=Y),{type:"link",raw:Z[0],text:Y,href:J,tokens:[{type:"text",raw:Y,text:Y}]}}}url($){let Z;if(Z=this.rules.inline.url.exec($)){let Y,J;if(Z[2]==="@")Y=Z[0],J="mailto:"+Y;else{let X;do X=Z[0],Z[0]=this.rules.inline._backpedal.exec(Z[0])?.[0]??"";while(X!==Z[0]);Y=Z[0],Z[1]==="www."?J="http://"+Z[0]:J=Z[0]}return{type:"link",raw:Z[0],text:Y,href:J,tokens:[{type:"text",raw:Y,text:Y}]}}}inlineText($){let Z=this.rules.inline.text.exec($);if(Z){let Y=this.lexer.state.inRawBlock;return{type:"text",raw:Z[0],text:Z[0],escaped:Y}}}},m1=class ${tokens;options;state;tokenizer;inlineQueue;constructor(Z){this.tokens=[],this.tokens.links=Object.create(null),this.options=Z||T0,this.options.tokenizer=this.options.tokenizer||new b$,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let Y={other:z1,block:M$.normal,inline:$$.normal};this.options.pedantic?(Y.block=M$.pedantic,Y.inline=$$.pedantic):this.options.gfm&&(Y.block=M$.gfm,this.options.breaks?Y.inline=$$.breaks:Y.inline=$$.gfm),this.tokenizer.rules=Y}static get rules(){return{block:M$,inline:$$}}static lex(Z,Y){return new $(Y).lex(Z)}static lexInline(Z,Y){return new $(Y).inlineTokens(Z)}lex(Z){Z=Z.replace(z1.carriageReturn,`
98
+ `),this.blockTokens(Z,this.tokens);for(let Y=0;Y<this.inlineQueue.length;Y++){let J=this.inlineQueue[Y];this.inlineTokens(J.src,J.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(Z,Y=[],J=!1){for(this.options.pedantic&&(Z=Z.replace(z1.tabCharGlobal," ").replace(z1.spaceLine,""));Z;){let X;if(this.options.extensions?.block?.some((Q)=>(X=Q.call({lexer:this},Z,Y))?(Z=Z.substring(X.raw.length),Y.push(X),!0):!1))continue;if(X=this.tokenizer.space(Z)){Z=Z.substring(X.raw.length);let Q=Y.at(-1);X.raw.length===1&&Q!==void 0?Q.raw+=`
99
+ `:Y.push(X);continue}if(X=this.tokenizer.code(Z)){Z=Z.substring(X.raw.length);let Q=Y.at(-1);Q?.type==="paragraph"||Q?.type==="text"?(Q.raw+=(Q.raw.endsWith(`
100
100
  `)?"":`
101
- `)+Q.raw,K.text+=`
102
- `+Q.text,this.inlineQueue.at(-1).src=K.text):X.push(Q);continue}if(Q=this.tokenizer.fences(Y)){Y=Y.substring(Q.raw.length),X.push(Q);continue}if(Q=this.tokenizer.heading(Y)){Y=Y.substring(Q.raw.length),X.push(Q);continue}if(Q=this.tokenizer.hr(Y)){Y=Y.substring(Q.raw.length),X.push(Q);continue}if(Q=this.tokenizer.blockquote(Y)){Y=Y.substring(Q.raw.length),X.push(Q);continue}if(Q=this.tokenizer.list(Y)){Y=Y.substring(Q.raw.length),X.push(Q);continue}if(Q=this.tokenizer.html(Y)){Y=Y.substring(Q.raw.length),X.push(Q);continue}if(Q=this.tokenizer.def(Y)){Y=Y.substring(Q.raw.length);let K=X.at(-1);K?.type==="paragraph"||K?.type==="text"?(K.raw+=(K.raw.endsWith(`
101
+ `)+X.raw,Q.text+=`
102
+ `+X.text,this.inlineQueue.at(-1).src=Q.text):Y.push(X);continue}if(X=this.tokenizer.fences(Z)){Z=Z.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.heading(Z)){Z=Z.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.hr(Z)){Z=Z.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.blockquote(Z)){Z=Z.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.list(Z)){Z=Z.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.html(Z)){Z=Z.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.def(Z)){Z=Z.substring(X.raw.length);let Q=Y.at(-1);Q?.type==="paragraph"||Q?.type==="text"?(Q.raw+=(Q.raw.endsWith(`
103
103
  `)?"":`
104
- `)+Q.raw,K.text+=`
105
- `+Q.raw,this.inlineQueue.at(-1).src=K.text):this.tokens.links[Q.tag]||(this.tokens.links[Q.tag]={href:Q.href,title:Q.title},X.push(Q));continue}if(Q=this.tokenizer.table(Y)){Y=Y.substring(Q.raw.length),X.push(Q);continue}if(Q=this.tokenizer.lheading(Y)){Y=Y.substring(Q.raw.length),X.push(Q);continue}let $=Y;if(this.options.extensions?.startBlock){let K=1/0,U=Y.slice(1),W;this.options.extensions.startBlock.forEach((z)=>{W=z.call({lexer:this},U),typeof W=="number"&&W>=0&&(K=Math.min(K,W))}),K<1/0&&K>=0&&($=Y.substring(0,K+1))}if(this.state.top&&(Q=this.tokenizer.paragraph($))){let K=X.at(-1);J&&K?.type==="paragraph"?(K.raw+=(K.raw.endsWith(`
104
+ `)+X.raw,Q.text+=`
105
+ `+X.raw,this.inlineQueue.at(-1).src=Q.text):this.tokens.links[X.tag]||(this.tokens.links[X.tag]={href:X.href,title:X.title},Y.push(X));continue}if(X=this.tokenizer.table(Z)){Z=Z.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.lheading(Z)){Z=Z.substring(X.raw.length),Y.push(X);continue}let K=Z;if(this.options.extensions?.startBlock){let Q=1/0,W=Z.slice(1),_;this.options.extensions.startBlock.forEach((O)=>{_=O.call({lexer:this},W),typeof _=="number"&&_>=0&&(Q=Math.min(Q,_))}),Q<1/0&&Q>=0&&(K=Z.substring(0,Q+1))}if(this.state.top&&(X=this.tokenizer.paragraph(K))){let Q=Y.at(-1);J&&Q?.type==="paragraph"?(Q.raw+=(Q.raw.endsWith(`
106
106
  `)?"":`
107
- `)+Q.raw,K.text+=`
108
- `+Q.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=K.text):X.push(Q),J=$.length!==Y.length,Y=Y.substring(Q.raw.length);continue}if(Q=this.tokenizer.text(Y)){Y=Y.substring(Q.raw.length);let K=X.at(-1);K?.type==="text"?(K.raw+=(K.raw.endsWith(`
107
+ `)+X.raw,Q.text+=`
108
+ `+X.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=Q.text):Y.push(X),J=K.length!==Z.length,Z=Z.substring(X.raw.length);continue}if(X=this.tokenizer.text(Z)){Z=Z.substring(X.raw.length);let Q=Y.at(-1);Q?.type==="text"?(Q.raw+=(Q.raw.endsWith(`
109
109
  `)?"":`
110
- `)+Q.raw,K.text+=`
111
- `+Q.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=K.text):X.push(Q);continue}if(Y){let K="Infinite loop on byte: "+Y.charCodeAt(0);if(this.options.silent){console.error(K);break}else throw Error(K)}}return this.state.top=!0,X}inline(Y,X=[]){return this.inlineQueue.push({src:Y,tokens:X}),X}inlineTokens(Y,X=[]){let J=Y,Q=null;if(this.tokens.links){let W=Object.keys(this.tokens.links);if(W.length>0)for(;(Q=this.tokenizer.rules.inline.reflinkSearch.exec(J))!=null;)W.includes(Q[0].slice(Q[0].lastIndexOf("[")+1,-1))&&(J=J.slice(0,Q.index)+"["+"a".repeat(Q[0].length-2)+"]"+J.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(Q=this.tokenizer.rules.inline.anyPunctuation.exec(J))!=null;)J=J.slice(0,Q.index)+"++"+J.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let $;for(;(Q=this.tokenizer.rules.inline.blockSkip.exec(J))!=null;)$=Q[2]?Q[2].length:0,J=J.slice(0,Q.index+$)+"["+"a".repeat(Q[0].length-$-2)+"]"+J.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);J=this.options.hooks?.emStrongMask?.call({lexer:this},J)??J;let K=!1,U="";for(;Y;){K||(U=""),K=!1;let W;if(this.options.extensions?.inline?.some((H)=>(W=H.call({lexer:this},Y,X))?(Y=Y.substring(W.raw.length),X.push(W),!0):!1))continue;if(W=this.tokenizer.escape(Y)){Y=Y.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.tag(Y)){Y=Y.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.link(Y)){Y=Y.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.reflink(Y,this.tokens.links)){Y=Y.substring(W.raw.length);let H=X.at(-1);W.type==="text"&&H?.type==="text"?(H.raw+=W.raw,H.text+=W.text):X.push(W);continue}if(W=this.tokenizer.emStrong(Y,J,U)){Y=Y.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.codespan(Y)){Y=Y.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.br(Y)){Y=Y.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.del(Y)){Y=Y.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.autolink(Y)){Y=Y.substring(W.raw.length),X.push(W);continue}if(!this.state.inLink&&(W=this.tokenizer.url(Y))){Y=Y.substring(W.raw.length),X.push(W);continue}let z=Y;if(this.options.extensions?.startInline){let H=1/0,G=Y.slice(1),F;this.options.extensions.startInline.forEach((M)=>{F=M.call({lexer:this},G),typeof F=="number"&&F>=0&&(H=Math.min(H,F))}),H<1/0&&H>=0&&(z=Y.substring(0,H+1))}if(W=this.tokenizer.inlineText(z)){Y=Y.substring(W.raw.length),W.raw.slice(-1)!=="_"&&(U=W.raw.slice(-1)),K=!0;let H=X.at(-1);H?.type==="text"?(H.raw+=W.raw,H.text+=W.text):X.push(W);continue}if(Y){let H="Infinite loop on byte: "+Y.charCodeAt(0);if(this.options.silent){console.error(H);break}else throw Error(H)}}return X}},JY=class{options;parser;constructor(Z){this.options=Z||r4}space(Z){return""}code({text:Z,lang:Y,escaped:X}){let J=(Y||"").match(RZ.notSpaceStart)?.[0],Q=Z.replace(RZ.endingNewline,"")+`
112
- `;return J?'<pre><code class="language-'+q4(J)+'">'+(X?Q:q4(Q,!0))+`</code></pre>
113
- `:"<pre><code>"+(X?Q:q4(Q,!0))+`</code></pre>
114
- `}blockquote({tokens:Z}){return`<blockquote>
115
- ${this.parser.parse(Z)}</blockquote>
116
- `}html({text:Z}){return Z}def(Z){return""}heading({tokens:Z,depth:Y}){return`<h${Y}>${this.parser.parseInline(Z)}</h${Y}>
117
- `}hr(Z){return`<hr>
118
- `}list(Z){let{ordered:Y,start:X}=Z,J="";for(let K=0;K<Z.items.length;K++){let U=Z.items[K];J+=this.listitem(U)}let Q=Y?"ol":"ul",$=Y&&X!==1?' start="'+X+'"':"";return"<"+Q+$+`>
119
- `+J+"</"+Q+`>
120
- `}listitem(Z){let Y="";if(Z.task){let X=this.checkbox({checked:!!Z.checked});Z.loose?Z.tokens[0]?.type==="paragraph"?(Z.tokens[0].text=X+" "+Z.tokens[0].text,Z.tokens[0].tokens&&Z.tokens[0].tokens.length>0&&Z.tokens[0].tokens[0].type==="text"&&(Z.tokens[0].tokens[0].text=X+" "+q4(Z.tokens[0].tokens[0].text),Z.tokens[0].tokens[0].escaped=!0)):Z.tokens.unshift({type:"text",raw:X+" ",text:X+" ",escaped:!0}):Y+=X+" "}return Y+=this.parser.parse(Z.tokens,!!Z.loose),`<li>${Y}</li>
121
- `}checkbox({checked:Z}){return"<input "+(Z?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:Z}){return`<p>${this.parser.parseInline(Z)}</p>
122
- `}table(Z){let Y="",X="";for(let Q=0;Q<Z.header.length;Q++)X+=this.tablecell(Z.header[Q]);Y+=this.tablerow({text:X});let J="";for(let Q=0;Q<Z.rows.length;Q++){let $=Z.rows[Q];X="";for(let K=0;K<$.length;K++)X+=this.tablecell($[K]);J+=this.tablerow({text:X})}return J&&(J=`<tbody>${J}</tbody>`),`<table>
110
+ `)+X.raw,Q.text+=`
111
+ `+X.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=Q.text):Y.push(X);continue}if(Z){let Q="Infinite loop on byte: "+Z.charCodeAt(0);if(this.options.silent){console.error(Q);break}else throw Error(Q)}}return this.state.top=!0,Y}inline(Z,Y=[]){return this.inlineQueue.push({src:Z,tokens:Y}),Y}inlineTokens(Z,Y=[]){let J=Z,X=null;if(this.tokens.links){let _=Object.keys(this.tokens.links);if(_.length>0)for(;(X=this.tokenizer.rules.inline.reflinkSearch.exec(J))!=null;)_.includes(X[0].slice(X[0].lastIndexOf("[")+1,-1))&&(J=J.slice(0,X.index)+"["+"a".repeat(X[0].length-2)+"]"+J.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(X=this.tokenizer.rules.inline.anyPunctuation.exec(J))!=null;)J=J.slice(0,X.index)+"++"+J.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let K;for(;(X=this.tokenizer.rules.inline.blockSkip.exec(J))!=null;)K=X[2]?X[2].length:0,J=J.slice(0,X.index+K)+"["+"a".repeat(X[0].length-K-2)+"]"+J.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);J=this.options.hooks?.emStrongMask?.call({lexer:this},J)??J;let Q=!1,W="";for(;Z;){Q||(W=""),Q=!1;let _;if(this.options.extensions?.inline?.some((N)=>(_=N.call({lexer:this},Z,Y))?(Z=Z.substring(_.raw.length),Y.push(_),!0):!1))continue;if(_=this.tokenizer.escape(Z)){Z=Z.substring(_.raw.length),Y.push(_);continue}if(_=this.tokenizer.tag(Z)){Z=Z.substring(_.raw.length),Y.push(_);continue}if(_=this.tokenizer.link(Z)){Z=Z.substring(_.raw.length),Y.push(_);continue}if(_=this.tokenizer.reflink(Z,this.tokens.links)){Z=Z.substring(_.raw.length);let N=Y.at(-1);_.type==="text"&&N?.type==="text"?(N.raw+=_.raw,N.text+=_.text):Y.push(_);continue}if(_=this.tokenizer.emStrong(Z,J,W)){Z=Z.substring(_.raw.length),Y.push(_);continue}if(_=this.tokenizer.codespan(Z)){Z=Z.substring(_.raw.length),Y.push(_);continue}if(_=this.tokenizer.br(Z)){Z=Z.substring(_.raw.length),Y.push(_);continue}if(_=this.tokenizer.del(Z)){Z=Z.substring(_.raw.length),Y.push(_);continue}if(_=this.tokenizer.autolink(Z)){Z=Z.substring(_.raw.length),Y.push(_);continue}if(!this.state.inLink&&(_=this.tokenizer.url(Z))){Z=Z.substring(_.raw.length),Y.push(_);continue}let O=Z;if(this.options.extensions?.startInline){let N=1/0,U=Z.slice(1),F;this.options.extensions.startInline.forEach((L)=>{F=L.call({lexer:this},U),typeof F=="number"&&F>=0&&(N=Math.min(N,F))}),N<1/0&&N>=0&&(O=Z.substring(0,N+1))}if(_=this.tokenizer.inlineText(O)){Z=Z.substring(_.raw.length),_.raw.slice(-1)!=="_"&&(W=_.raw.slice(-1)),Q=!0;let N=Y.at(-1);N?.type==="text"?(N.raw+=_.raw,N.text+=_.text):Y.push(_);continue}if(Z){let N="Infinite loop on byte: "+Z.charCodeAt(0);if(this.options.silent){console.error(N);break}else throw Error(N)}}return Y}},B$=class{options;parser;constructor($){this.options=$||T0}space($){return""}code({text:$,lang:Z,escaped:Y}){let J=(Z||"").match(z1.notSpaceStart)?.[0],X=$.replace(z1.endingNewline,"")+`
112
+ `;return J?'<pre><code class="language-'+e1(J)+'">'+(Y?X:e1(X,!0))+`</code></pre>
113
+ `:"<pre><code>"+(Y?X:e1(X,!0))+`</code></pre>
114
+ `}blockquote({tokens:$}){return`<blockquote>
115
+ ${this.parser.parse($)}</blockquote>
116
+ `}html({text:$}){return $}def($){return""}heading({tokens:$,depth:Z}){return`<h${Z}>${this.parser.parseInline($)}</h${Z}>
117
+ `}hr($){return`<hr>
118
+ `}list($){let{ordered:Z,start:Y}=$,J="";for(let Q=0;Q<$.items.length;Q++){let W=$.items[Q];J+=this.listitem(W)}let X=Z?"ol":"ul",K=Z&&Y!==1?' start="'+Y+'"':"";return"<"+X+K+`>
119
+ `+J+"</"+X+`>
120
+ `}listitem($){let Z="";if($.task){let Y=this.checkbox({checked:!!$.checked});$.loose?$.tokens[0]?.type==="paragraph"?($.tokens[0].text=Y+" "+$.tokens[0].text,$.tokens[0].tokens&&$.tokens[0].tokens.length>0&&$.tokens[0].tokens[0].type==="text"&&($.tokens[0].tokens[0].text=Y+" "+e1($.tokens[0].tokens[0].text),$.tokens[0].tokens[0].escaped=!0)):$.tokens.unshift({type:"text",raw:Y+" ",text:Y+" ",escaped:!0}):Z+=Y+" "}return Z+=this.parser.parse($.tokens,!!$.loose),`<li>${Z}</li>
121
+ `}checkbox({checked:$}){return"<input "+($?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:$}){return`<p>${this.parser.parseInline($)}</p>
122
+ `}table($){let Z="",Y="";for(let X=0;X<$.header.length;X++)Y+=this.tablecell($.header[X]);Z+=this.tablerow({text:Y});let J="";for(let X=0;X<$.rows.length;X++){let K=$.rows[X];Y="";for(let Q=0;Q<K.length;Q++)Y+=this.tablecell(K[Q]);J+=this.tablerow({text:Y})}return J&&(J=`<tbody>${J}</tbody>`),`<table>
123
123
  <thead>
124
- `+Y+`</thead>
124
+ `+Z+`</thead>
125
125
  `+J+`</table>
126
- `}tablerow({text:Z}){return`<tr>
127
- ${Z}</tr>
128
- `}tablecell(Z){let Y=this.parser.parseInline(Z.tokens),X=Z.header?"th":"td";return(Z.align?`<${X} align="${Z.align}">`:`<${X}>`)+Y+`</${X}>
129
- `}strong({tokens:Z}){return`<strong>${this.parser.parseInline(Z)}</strong>`}em({tokens:Z}){return`<em>${this.parser.parseInline(Z)}</em>`}codespan({text:Z}){return`<code>${q4(Z,!0)}</code>`}br(Z){return"<br>"}del({tokens:Z}){return`<del>${this.parser.parseInline(Z)}</del>`}link({href:Z,title:Y,tokens:X}){let J=this.parser.parseInline(X),Q=C5(Z);if(Q===null)return J;Z=Q;let $='<a href="'+Z+'"';return Y&&($+=' title="'+q4(Y)+'"'),$+=">"+J+"</a>",$}image({href:Z,title:Y,text:X,tokens:J}){J&&(X=this.parser.parseInline(J,this.parser.textRenderer));let Q=C5(Z);if(Q===null)return q4(X);Z=Q;let $=`<img src="${Z}" alt="${X}"`;return Y&&($+=` title="${q4(Y)}"`),$+=">",$}text(Z){return"tokens"in Z&&Z.tokens?this.parser.parseInline(Z.tokens):("escaped"in Z)&&Z.escaped?Z.text:q4(Z.text)}},_X=class{strong({text:Z}){return Z}em({text:Z}){return Z}codespan({text:Z}){return Z}del({text:Z}){return Z}html({text:Z}){return Z}text({text:Z}){return Z}link({text:Z}){return""+Z}image({text:Z}){return""+Z}br(){return""}},sZ=class Z{options;renderer;textRenderer;constructor(Y){this.options=Y||r4,this.options.renderer=this.options.renderer||new JY,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new _X}static parse(Y,X){return new Z(X).parse(Y)}static parseInline(Y,X){return new Z(X).parseInline(Y)}parse(Y,X=!0){let J="";for(let Q=0;Q<Y.length;Q++){let $=Y[Q];if(this.options.extensions?.renderers?.[$.type]){let U=$,W=this.options.extensions.renderers[U.type].call({parser:this},U);if(W!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(U.type)){J+=W||"";continue}}let K=$;switch(K.type){case"space":{J+=this.renderer.space(K);continue}case"hr":{J+=this.renderer.hr(K);continue}case"heading":{J+=this.renderer.heading(K);continue}case"code":{J+=this.renderer.code(K);continue}case"table":{J+=this.renderer.table(K);continue}case"blockquote":{J+=this.renderer.blockquote(K);continue}case"list":{J+=this.renderer.list(K);continue}case"html":{J+=this.renderer.html(K);continue}case"def":{J+=this.renderer.def(K);continue}case"paragraph":{J+=this.renderer.paragraph(K);continue}case"text":{let U=K,W=this.renderer.text(U);for(;Q+1<Y.length&&Y[Q+1].type==="text";)U=Y[++Q],W+=`
130
- `+this.renderer.text(U);X?J+=this.renderer.paragraph({type:"paragraph",raw:W,text:W,tokens:[{type:"text",raw:W,text:W,escaped:!0}]}):J+=W;continue}default:{let U='Token with "'+K.type+'" type was not found.';if(this.options.silent)return console.error(U),"";throw Error(U)}}}return J}parseInline(Y,X=this.renderer){let J="";for(let Q=0;Q<Y.length;Q++){let $=Y[Q];if(this.options.extensions?.renderers?.[$.type]){let U=this.options.extensions.renderers[$.type].call({parser:this},$);if(U!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes($.type)){J+=U||"";continue}}let K=$;switch(K.type){case"escape":{J+=X.text(K);break}case"html":{J+=X.html(K);break}case"link":{J+=X.link(K);break}case"image":{J+=X.image(K);break}case"strong":{J+=X.strong(K);break}case"em":{J+=X.em(K);break}case"codespan":{J+=X.codespan(K);break}case"br":{J+=X.br(K);break}case"del":{J+=X.del(K);break}case"text":{J+=X.text(K);break}default:{let U='Token with "'+K.type+'" type was not found.';if(this.options.silent)return console.error(U),"";throw Error(U)}}}return J}},P0=class{options;block;constructor(Z){this.options=Z||r4}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(Z){return Z}postprocess(Z){return Z}processAllTokens(Z){return Z}emStrongMask(Z){return Z}provideLexer(){return this.block?aZ.lex:aZ.lexInline}provideParser(){return this.block?sZ.parse:sZ.parseInline}},fK=class{defaults=zX();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=sZ;Renderer=JY;TextRenderer=_X;Lexer=aZ;Tokenizer=XY;Hooks=P0;constructor(...Z){this.use(...Z)}walkTokens(Z,Y){let X=[];for(let J of Z)switch(X=X.concat(Y.call(this,J)),J.type){case"table":{let Q=J;for(let $ of Q.header)X=X.concat(this.walkTokens($.tokens,Y));for(let $ of Q.rows)for(let K of $)X=X.concat(this.walkTokens(K.tokens,Y));break}case"list":{let Q=J;X=X.concat(this.walkTokens(Q.items,Y));break}default:{let Q=J;this.defaults.extensions?.childTokens?.[Q.type]?this.defaults.extensions.childTokens[Q.type].forEach(($)=>{let K=Q[$].flat(1/0);X=X.concat(this.walkTokens(K,Y))}):Q.tokens&&(X=X.concat(this.walkTokens(Q.tokens,Y)))}}return X}use(...Z){let Y=this.defaults.extensions||{renderers:{},childTokens:{}};return Z.forEach((X)=>{let J={...X};if(J.async=this.defaults.async||J.async||!1,X.extensions&&(X.extensions.forEach((Q)=>{if(!Q.name)throw Error("extension name required");if("renderer"in Q){let $=Y.renderers[Q.name];$?Y.renderers[Q.name]=function(...K){let U=Q.renderer.apply(this,K);return U===!1&&(U=$.apply(this,K)),U}:Y.renderers[Q.name]=Q.renderer}if("tokenizer"in Q){if(!Q.level||Q.level!=="block"&&Q.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let $=Y[Q.level];$?$.unshift(Q.tokenizer):Y[Q.level]=[Q.tokenizer],Q.start&&(Q.level==="block"?Y.startBlock?Y.startBlock.push(Q.start):Y.startBlock=[Q.start]:Q.level==="inline"&&(Y.startInline?Y.startInline.push(Q.start):Y.startInline=[Q.start]))}"childTokens"in Q&&Q.childTokens&&(Y.childTokens[Q.name]=Q.childTokens)}),J.extensions=Y),X.renderer){let Q=this.defaults.renderer||new JY(this.defaults);for(let $ in X.renderer){if(!($ in Q))throw Error(`renderer '${$}' does not exist`);if(["options","parser"].includes($))continue;let K=$,U=X.renderer[K],W=Q[K];Q[K]=(...z)=>{let H=U.apply(Q,z);return H===!1&&(H=W.apply(Q,z)),H||""}}J.renderer=Q}if(X.tokenizer){let Q=this.defaults.tokenizer||new XY(this.defaults);for(let $ in X.tokenizer){if(!($ in Q))throw Error(`tokenizer '${$}' does not exist`);if(["options","rules","lexer"].includes($))continue;let K=$,U=X.tokenizer[K],W=Q[K];Q[K]=(...z)=>{let H=U.apply(Q,z);return H===!1&&(H=W.apply(Q,z)),H}}J.tokenizer=Q}if(X.hooks){let Q=this.defaults.hooks||new P0;for(let $ in X.hooks){if(!($ in Q))throw Error(`hook '${$}' does not exist`);if(["options","block"].includes($))continue;let K=$,U=X.hooks[K],W=Q[K];P0.passThroughHooks.has($)?Q[K]=(z)=>{if(this.defaults.async&&P0.passThroughHooksRespectAsync.has($))return(async()=>{let G=await U.call(Q,z);return W.call(Q,G)})();let H=U.call(Q,z);return W.call(Q,H)}:Q[K]=(...z)=>{if(this.defaults.async)return(async()=>{let G=await U.apply(Q,z);return G===!1&&(G=await W.apply(Q,z)),G})();let H=U.apply(Q,z);return H===!1&&(H=W.apply(Q,z)),H}}J.hooks=Q}if(X.walkTokens){let Q=this.defaults.walkTokens,$=X.walkTokens;J.walkTokens=function(K){let U=[];return U.push($.call(this,K)),Q&&(U=U.concat(Q.call(this,K))),U}}this.defaults={...this.defaults,...J}}),this}setOptions(Z){return this.defaults={...this.defaults,...Z},this}lexer(Z,Y){return aZ.lex(Z,Y??this.defaults)}parser(Z,Y){return sZ.parse(Z,Y??this.defaults)}parseMarkdown(Z){return(Y,X)=>{let J={...X},Q={...this.defaults,...J},$=this.onError(!!Q.silent,!!Q.async);if(this.defaults.async===!0&&J.async===!1)return $(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof Y>"u"||Y===null)return $(Error("marked(): input parameter is undefined or null"));if(typeof Y!="string")return $(Error("marked(): input parameter is of type "+Object.prototype.toString.call(Y)+", string expected"));if(Q.hooks&&(Q.hooks.options=Q,Q.hooks.block=Z),Q.async)return(async()=>{let K=Q.hooks?await Q.hooks.preprocess(Y):Y,U=await(Q.hooks?await Q.hooks.provideLexer():Z?aZ.lex:aZ.lexInline)(K,Q),W=Q.hooks?await Q.hooks.processAllTokens(U):U;Q.walkTokens&&await Promise.all(this.walkTokens(W,Q.walkTokens));let z=await(Q.hooks?await Q.hooks.provideParser():Z?sZ.parse:sZ.parseInline)(W,Q);return Q.hooks?await Q.hooks.postprocess(z):z})().catch($);try{Q.hooks&&(Y=Q.hooks.preprocess(Y));let K=(Q.hooks?Q.hooks.provideLexer():Z?aZ.lex:aZ.lexInline)(Y,Q);Q.hooks&&(K=Q.hooks.processAllTokens(K)),Q.walkTokens&&this.walkTokens(K,Q.walkTokens);let U=(Q.hooks?Q.hooks.provideParser():Z?sZ.parse:sZ.parseInline)(K,Q);return Q.hooks&&(U=Q.hooks.postprocess(U)),U}catch(K){return $(K)}}}onError(Z,Y){return(X)=>{if(X.message+=`
131
- Please report this to https://github.com/markedjs/marked.`,Z){let J="<p>An error occurred:</p><pre>"+q4(X.message+"",!0)+"</pre>";return Y?Promise.resolve(J):J}if(Y)return Promise.reject(X);throw X}}},i4=new fK;function c(Z,Y){return i4.parse(Z,Y)}c.options=c.setOptions=function(Z){return i4.setOptions(Z),c.defaults=i4.defaults,D5(c.defaults),c};c.getDefaults=zX;c.defaults=r4;c.use=function(...Z){return i4.use(...Z),c.defaults=i4.defaults,D5(c.defaults),c};c.walkTokens=function(Z,Y){return i4.walkTokens(Z,Y)};c.parseInline=i4.parseInline;c.Parser=sZ;c.parser=sZ.parse;c.Renderer=JY;c.TextRenderer=_X;c.Lexer=aZ;c.lexer=aZ.lex;c.Tokenizer=XY;c.Hooks=P0;c.parse=c;var{options:lG,setOptions:iG,use:rG,walkTokens:oG,parseInline:nG}=c;var aG=sZ.parse,sG=aZ.lex;var pZ=P(g(),1);class YZ extends Error{constructor(Z){super(Z);this.name="ShikiError"}}function jK(Z){return IX(Z)}function IX(Z){if(Array.isArray(Z))return SK(Z);if(Z instanceof RegExp)return Z;if(typeof Z==="object")return yK(Z);return Z}function SK(Z){let Y=[];for(let X=0,J=Z.length;X<J;X++)Y[X]=IX(Z[X]);return Y}function yK(Z){let Y={};for(let X in Z)Y[X]=IX(Z[X]);return Y}function i5(Z,...Y){return Y.forEach((X)=>{for(let J in X)Z[J]=X[J]}),Z}function r5(Z){let Y=~Z.lastIndexOf("/")||~Z.lastIndexOf("\\");if(Y===0)return Z;else if(~Y===Z.length-1)return r5(Z.substring(0,Z.length-1));else return Z.substr(~Y+1)}var AX=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,KY=class{static hasCaptures(Z){if(Z===null)return!1;return AX.lastIndex=0,AX.test(Z)}static replaceCaptures(Z,Y,X){return Z.replace(AX,(J,Q,$,K)=>{let U=X[parseInt(Q||$,10)];if(U){let W=Y.substring(U.start,U.end);while(W[0]===".")W=W.substring(1);switch(K){case"downcase":return W.toLowerCase();case"upcase":return W.toUpperCase();default:return W}}else return J})}};function o5(Z,Y){if(Z<Y)return-1;if(Z>Y)return 1;return 0}function n5(Z,Y){if(Z===null&&Y===null)return 0;if(!Z)return-1;if(!Y)return 1;let X=Z.length,J=Y.length;if(X===J){for(let Q=0;Q<X;Q++){let $=o5(Z[Q],Y[Q]);if($!==0)return $}return 0}return X-J}function x5(Z){if(/^#[0-9a-f]{6}$/i.test(Z))return!0;if(/^#[0-9a-f]{8}$/i.test(Z))return!0;if(/^#[0-9a-f]{3}$/i.test(Z))return!0;if(/^#[0-9a-f]{4}$/i.test(Z))return!0;return!1}function a5(Z){return Z.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var s5=class{constructor(Z){this.fn=Z}cache=new Map;get(Z){if(this.cache.has(Z))return this.cache.get(Z);let Y=this.fn(Z);return this.cache.set(Z,Y),Y}},D0=class{constructor(Z,Y,X){this._colorMap=Z,this._defaults=Y,this._root=X}static createFromRawTheme(Z,Y){return this.createFromParsedTheme(xK(Z),Y)}static createFromParsedTheme(Z,Y){return uK(Z,Y)}_cachedMatchRoot=new s5((Z)=>this._root.match(Z));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(Z){if(Z===null)return this._defaults;let Y=Z.scopeName,J=this._cachedMatchRoot.get(Y).find((Q)=>kK(Z.parent,Q.parentScopes));if(!J)return null;return new t5(J.fontStyle,J.foreground,J.background)}},wX=class Z{constructor(Y,X){this.parent=Y,this.scopeName=X}static push(Y,X){for(let J of X)Y=new Z(Y,J);return Y}static from(...Y){let X=null;for(let J=0;J<Y.length;J++)X=new Z(X,Y[J]);return X}push(Y){return new Z(this,Y)}getSegments(){let Y=this,X=[];while(Y)X.push(Y.scopeName),Y=Y.parent;return X.reverse(),X}toString(){return this.getSegments().join(" ")}extends(Y){if(this===Y)return!0;if(this.parent===null)return!1;return this.parent.extends(Y)}getExtensionIfDefined(Y){let X=[],J=this;while(J&&J!==Y)X.push(J.scopeName),J=J.parent;return J===Y?X.reverse():void 0}};function kK(Z,Y){if(Y.length===0)return!0;for(let X=0;X<Y.length;X++){let J=Y[X],Q=!1;if(J===">"){if(X===Y.length-1)return!1;J=Y[++X],Q=!0}while(Z){if(hK(Z.scopeName,J))break;if(Q)return!1;Z=Z.parent}if(!Z)return!1;Z=Z.parent}return!0}function hK(Z,Y){return Y===Z||Z.startsWith(Y)&&Z[Y.length]==="."}var t5=class{constructor(Z,Y,X){this.fontStyle=Z,this.foregroundId=Y,this.backgroundId=X}};function xK(Z){if(!Z)return[];if(!Z.settings||!Array.isArray(Z.settings))return[];let Y=Z.settings,X=[],J=0;for(let Q=0,$=Y.length;Q<$;Q++){let K=Y[Q];if(!K.settings)continue;let U;if(typeof K.scope==="string"){let G=K.scope;G=G.replace(/^[,]+/,""),G=G.replace(/[,]+$/,""),U=G.split(",")}else if(Array.isArray(K.scope))U=K.scope;else U=[""];let W=-1;if(typeof K.settings.fontStyle==="string"){W=0;let G=K.settings.fontStyle.split(" ");for(let F=0,M=G.length;F<M;F++)switch(G[F]){case"italic":W=W|1;break;case"bold":W=W|2;break;case"underline":W=W|4;break;case"strikethrough":W=W|8;break}}let z=null;if(typeof K.settings.foreground==="string"&&x5(K.settings.foreground))z=K.settings.foreground;let H=null;if(typeof K.settings.background==="string"&&x5(K.settings.background))H=K.settings.background;for(let G=0,F=U.length;G<F;G++){let N=U[G].trim().split(" "),w=N[N.length-1],L=null;if(N.length>1)L=N.slice(0,N.length-1),L.reverse();X[J++]=new gK(w,L,Q,W,z,H)}}return X}var gK=class{constructor(Z,Y,X,J,Q,$){this.scope=Z,this.parentScopes=Y,this.index=X,this.fontStyle=J,this.foreground=Q,this.background=$}},GZ=((Z)=>{return Z[Z.NotSet=-1]="NotSet",Z[Z.None=0]="None",Z[Z.Italic=1]="Italic",Z[Z.Bold=2]="Bold",Z[Z.Underline=4]="Underline",Z[Z.Strikethrough=8]="Strikethrough",Z})(GZ||{});function uK(Z,Y){Z.sort((W,z)=>{let H=o5(W.scope,z.scope);if(H!==0)return H;if(H=n5(W.parentScopes,z.parentScopes),H!==0)return H;return W.index-z.index});let X=0,J="#000000",Q="#ffffff";while(Z.length>=1&&Z[0].scope===""){let W=Z.shift();if(W.fontStyle!==-1)X=W.fontStyle;if(W.foreground!==null)J=W.foreground;if(W.background!==null)Q=W.background}let $=new mK(Y),K=new t5(X,$.getId(J),$.getId(Q)),U=new dK(new LX(0,null,-1,0,0),[]);for(let W=0,z=Z.length;W<z;W++){let H=Z[W];U.insert(0,H.scope,H.parentScopes,H.fontStyle,$.getId(H.foreground),$.getId(H.background))}return new D0($,K,U)}var mK=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(Z){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(Z)){this._isFrozen=!0;for(let Y=0,X=Z.length;Y<X;Y++)this._color2id[Z[Y]]=Y,this._id2color[Y]=Z[Y]}else this._isFrozen=!1}getId(Z){if(Z===null)return 0;Z=Z.toUpperCase();let Y=this._color2id[Z];if(Y)return Y;if(this._isFrozen)throw Error(`Missing color in color map - ${Z}`);return Y=++this._lastColorId,this._color2id[Z]=Y,this._id2color[Y]=Z,Y}getColorMap(){return this._id2color.slice(0)}},pK=Object.freeze([]),LX=class Z{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(Y,X,J,Q,$){this.scopeDepth=Y,this.parentScopes=X||pK,this.fontStyle=J,this.foreground=Q,this.background=$}clone(){return new Z(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(Y){let X=[];for(let J=0,Q=Y.length;J<Q;J++)X[J]=Y[J].clone();return X}acceptOverwrite(Y,X,J,Q){if(this.scopeDepth>Y)console.log("how did this happen?");else this.scopeDepth=Y;if(X!==-1)this.fontStyle=X;if(J!==0)this.foreground=J;if(Q!==0)this.background=Q}},dK=class Z{constructor(Y,X=[],J={}){this._mainRule=Y,this._children=J,this._rulesWithParentScopes=X}_rulesWithParentScopes;static _cmpBySpecificity(Y,X){if(Y.scopeDepth!==X.scopeDepth)return X.scopeDepth-Y.scopeDepth;let J=0,Q=0;while(!0){if(Y.parentScopes[J]===">")J++;if(X.parentScopes[Q]===">")Q++;if(J>=Y.parentScopes.length||Q>=X.parentScopes.length)break;let $=X.parentScopes[Q].length-Y.parentScopes[J].length;if($!==0)return $;J++,Q++}return X.parentScopes.length-Y.parentScopes.length}match(Y){if(Y!==""){let J=Y.indexOf("."),Q,$;if(J===-1)Q=Y,$="";else Q=Y.substring(0,J),$=Y.substring(J+1);if(this._children.hasOwnProperty(Q))return this._children[Q].match($)}let X=this._rulesWithParentScopes.concat(this._mainRule);return X.sort(Z._cmpBySpecificity),X}insert(Y,X,J,Q,$,K){if(X===""){this._doInsertHere(Y,J,Q,$,K);return}let U=X.indexOf("."),W,z;if(U===-1)W=X,z="";else W=X.substring(0,U),z=X.substring(U+1);let H;if(this._children.hasOwnProperty(W))H=this._children[W];else H=new Z(this._mainRule.clone(),LX.cloneArr(this._rulesWithParentScopes)),this._children[W]=H;H.insert(Y+1,z,J,Q,$,K)}_doInsertHere(Y,X,J,Q,$){if(X===null){this._mainRule.acceptOverwrite(Y,J,Q,$);return}for(let K=0,U=this._rulesWithParentScopes.length;K<U;K++){let W=this._rulesWithParentScopes[K];if(n5(W.parentScopes,X)===0){W.acceptOverwrite(Y,J,Q,$);return}}if(J===-1)J=this._mainRule.fontStyle;if(Q===0)Q=this._mainRule.foreground;if($===0)$=this._mainRule.background;this._rulesWithParentScopes.push(new LX(Y,X,J,Q,$))}},o4=class Z{static toBinaryStr(Y){return Y.toString(2).padStart(32,"0")}static print(Y){let X=Z.getLanguageId(Y),J=Z.getTokenType(Y),Q=Z.getFontStyle(Y),$=Z.getForeground(Y),K=Z.getBackground(Y);console.log({languageId:X,tokenType:J,fontStyle:Q,foreground:$,background:K})}static getLanguageId(Y){return(Y&255)>>>0}static getTokenType(Y){return(Y&768)>>>8}static containsBalancedBrackets(Y){return(Y&1024)!==0}static getFontStyle(Y){return(Y&30720)>>>11}static getForeground(Y){return(Y&16744448)>>>15}static getBackground(Y){return(Y&4278190080)>>>24}static set(Y,X,J,Q,$,K,U){let W=Z.getLanguageId(Y),z=Z.getTokenType(Y),H=Z.containsBalancedBrackets(Y)?1:0,G=Z.getFontStyle(Y),F=Z.getForeground(Y),M=Z.getBackground(Y);if(X!==0)W=X;if(J!==8)z=lK(J);if(Q!==null)H=Q?1:0;if($!==-1)G=$;if(K!==0)F=K;if(U!==0)M=U;return(W<<0|z<<8|H<<10|G<<11|F<<15|M<<24)>>>0}};function cK(Z){return Z}function lK(Z){return Z}function UY(Z,Y){let X=[],J=iK(Z),Q=J.next();while(Q!==null){let W=0;if(Q.length===2&&Q.charAt(1)===":"){switch(Q.charAt(0)){case"R":W=1;break;case"L":W=-1;break;default:console.log(`Unknown priority ${Q} in scope selector`)}Q=J.next()}let z=K();if(X.push({matcher:z,priority:W}),Q!==",")break;Q=J.next()}return X;function $(){if(Q==="-"){Q=J.next();let W=$();return(z)=>!!W&&!W(z)}if(Q==="("){Q=J.next();let W=U();if(Q===")")Q=J.next();return W}if(g5(Q)){let W=[];do W.push(Q),Q=J.next();while(g5(Q));return(z)=>Y(W,z)}return null}function K(){let W=[],z=$();while(z)W.push(z),z=$();return(H)=>W.every((G)=>G(H))}function U(){let W=[],z=K();while(z){if(W.push(z),Q==="|"||Q===",")do Q=J.next();while(Q==="|"||Q===",");else break;z=K()}return(H)=>W.some((G)=>G(H))}}function g5(Z){return!!Z&&!!Z.match(/[\w\.:]+/)}function iK(Z){let Y=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,X=Y.exec(Z);return{next:()=>{if(!X)return null;let J=X[0];return X=Y.exec(Z),J}}}function e5(Z){if(typeof Z.dispose==="function")Z.dispose()}var V0=class{constructor(Z){this.scopeName=Z}toKey(){return this.scopeName}},rK=class{constructor(Z,Y){this.scopeName=Z,this.ruleName=Y}toKey(){return`${this.scopeName}#${this.ruleName}`}},oK=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(Z){let Y=Z.toKey();if(this._seenReferenceKeys.has(Y))return;this._seenReferenceKeys.add(Y),this._references.push(Z)}},nK=class{constructor(Z,Y){this.repo=Z,this.initialScopeName=Y,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new V0(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let Z=this.Q;this.Q=[];let Y=new oK;for(let X of Z)aK(X,this.initialScopeName,this.repo,Y);for(let X of Y.references)if(X instanceof V0){if(this.seenFullScopeRequests.has(X.scopeName))continue;this.seenFullScopeRequests.add(X.scopeName),this.Q.push(X)}else{if(this.seenFullScopeRequests.has(X.scopeName))continue;if(this.seenPartialScopeRequests.has(X.toKey()))continue;this.seenPartialScopeRequests.add(X.toKey()),this.Q.push(X)}}};function aK(Z,Y,X,J){let Q=X.lookup(Z.scopeName);if(!Q){if(Z.scopeName===Y)throw Error(`No grammar provided for <${Y}>`);return}let $=X.lookup(Y);if(Z instanceof V0)WY({baseGrammar:$,selfGrammar:Q},J);else PX(Z.ruleName,{baseGrammar:$,selfGrammar:Q,repository:Q.repository},J);let K=X.injections(Z.scopeName);if(K)for(let U of K)J.add(new V0(U))}function PX(Z,Y,X){if(Y.repository&&Y.repository[Z]){let J=Y.repository[Z];zY([J],Y,X)}}function WY(Z,Y){if(Z.selfGrammar.patterns&&Array.isArray(Z.selfGrammar.patterns))zY(Z.selfGrammar.patterns,{...Z,repository:Z.selfGrammar.repository},Y);if(Z.selfGrammar.injections)zY(Object.values(Z.selfGrammar.injections),{...Z,repository:Z.selfGrammar.repository},Y)}function zY(Z,Y,X){for(let J of Z){if(X.visitedRule.has(J))continue;X.visitedRule.add(J);let Q=J.repository?i5({},Y.repository,J.repository):Y.repository;if(Array.isArray(J.patterns))zY(J.patterns,{...Y,repository:Q},X);let $=J.include;if(!$)continue;let K=Z6($);switch(K.kind){case 0:WY({...Y,selfGrammar:Y.baseGrammar},X);break;case 1:WY(Y,X);break;case 2:PX(K.ruleName,{...Y,repository:Q},X);break;case 3:case 4:let U=K.scopeName===Y.selfGrammar.scopeName?Y.selfGrammar:K.scopeName===Y.baseGrammar.scopeName?Y.baseGrammar:void 0;if(U){let W={baseGrammar:Y.baseGrammar,selfGrammar:U,repository:Q};if(K.kind===4)PX(K.ruleName,W,X);else WY(W,X)}else if(K.kind===4)X.add(new rK(K.scopeName,K.ruleName));else X.add(new V0(K.scopeName));break}}}var sK=class{kind=0},tK=class{kind=1},eK=class{constructor(Z){this.ruleName=Z}kind=2},Z7=class{constructor(Z){this.scopeName=Z}kind=3},Y7=class{constructor(Z,Y){this.scopeName=Z,this.ruleName=Y}kind=4};function Z6(Z){if(Z==="$base")return new sK;else if(Z==="$self")return new tK;let Y=Z.indexOf("#");if(Y===-1)return new Z7(Z);else if(Y===0)return new eK(Z.substring(1));else{let X=Z.substring(0,Y),J=Z.substring(Y+1);return new Y7(X,J)}}var X7=/\\(\d+)/,u5=/\\(\d+)/g,$O=Symbol("RuleId"),J7=-1,Y6=-2;function X6(Z){return Z}function J6(Z){return Z}var T0=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(Z,Y,X,J){this.$location=Z,this.id=Y,this._name=X||null,this._nameIsCapturing=KY.hasCaptures(this._name),this._contentName=J||null,this._contentNameIsCapturing=KY.hasCaptures(this._contentName)}get debugName(){let Z=this.$location?`${r5(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${Z}`}getName(Z,Y){if(!this._nameIsCapturing||this._name===null||Z===null||Y===null)return this._name;return KY.replaceCaptures(this._name,Z,Y)}getContentName(Z,Y){if(!this._contentNameIsCapturing||this._contentName===null)return this._contentName;return KY.replaceCaptures(this._contentName,Z,Y)}},Q7=class extends T0{retokenizeCapturedWithRuleId;constructor(Z,Y,X,J,Q){super(Z,Y,X,J);this.retokenizeCapturedWithRuleId=Q}dispose(){}collectPatterns(Z,Y){throw Error("Not supported!")}compile(Z,Y){throw Error("Not supported!")}compileAG(Z,Y,X,J){throw Error("Not supported!")}},$7=class extends T0{_match;captures;_cachedCompiledPatterns;constructor(Z,Y,X,J,Q){super(Z,Y,X,null);this._match=new E0(J,this.id),this.captures=Q,this._cachedCompiledPatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(Z,Y){Y.push(this._match)}compile(Z,Y){return this._getCachedCompiledPatterns(Z).compile(Z)}compileAG(Z,Y,X,J){return this._getCachedCompiledPatterns(Z).compileAG(Z,X,J)}_getCachedCompiledPatterns(Z){if(!this._cachedCompiledPatterns)this._cachedCompiledPatterns=new b0,this.collectPatterns(Z,this._cachedCompiledPatterns);return this._cachedCompiledPatterns}},m5=class extends T0{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(Z,Y,X,J,Q){super(Z,Y,X,J);this.patterns=Q.patterns,this.hasMissingPatterns=Q.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null}collectPatterns(Z,Y){for(let X of this.patterns)Z.getRule(X).collectPatterns(Z,Y)}compile(Z,Y){return this._getCachedCompiledPatterns(Z).compile(Z)}compileAG(Z,Y,X,J){return this._getCachedCompiledPatterns(Z).compileAG(Z,X,J)}_getCachedCompiledPatterns(Z){if(!this._cachedCompiledPatterns)this._cachedCompiledPatterns=new b0,this.collectPatterns(Z,this._cachedCompiledPatterns);return this._cachedCompiledPatterns}},RX=class extends T0{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(Z,Y,X,J,Q,$,K,U,W,z){super(Z,Y,X,J);this._begin=new E0(Q,this.id),this.beginCaptures=$,this._end=new E0(K?K:"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=U,this.applyEndPatternLast=W||!1,this.patterns=z.patterns,this.hasMissingPatterns=z.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(Z,Y){return this._end.resolveBackReferences(Z,Y)}collectPatterns(Z,Y){Y.push(this._begin)}compile(Z,Y){return this._getCachedCompiledPatterns(Z,Y).compile(Z)}compileAG(Z,Y,X,J){return this._getCachedCompiledPatterns(Z,Y).compileAG(Z,X,J)}_getCachedCompiledPatterns(Z,Y){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new b0;for(let X of this.patterns)Z.getRule(X).collectPatterns(Z,this._cachedCompiledPatterns);if(this.applyEndPatternLast)this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end);else this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}if(this._end.hasBackReferences)if(this.applyEndPatternLast)this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,Y);else this._cachedCompiledPatterns.setSource(0,Y);return this._cachedCompiledPatterns}},HY=class extends T0{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(Z,Y,X,J,Q,$,K,U,W){super(Z,Y,X,J);this._begin=new E0(Q,this.id),this.beginCaptures=$,this.whileCaptures=U,this._while=new E0(K,Y6),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=W.patterns,this.hasMissingPatterns=W.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null;if(this._cachedCompiledWhilePatterns)this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(Z,Y){return this._while.resolveBackReferences(Z,Y)}collectPatterns(Z,Y){Y.push(this._begin)}compile(Z,Y){return this._getCachedCompiledPatterns(Z).compile(Z)}compileAG(Z,Y,X,J){return this._getCachedCompiledPatterns(Z).compileAG(Z,X,J)}_getCachedCompiledPatterns(Z){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new b0;for(let Y of this.patterns)Z.getRule(Y).collectPatterns(Z,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(Z,Y){return this._getCachedCompiledWhilePatterns(Z,Y).compile(Z)}compileWhileAG(Z,Y,X,J){return this._getCachedCompiledWhilePatterns(Z,Y).compileAG(Z,X,J)}_getCachedCompiledWhilePatterns(Z,Y){if(!this._cachedCompiledWhilePatterns)this._cachedCompiledWhilePatterns=new b0,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while);if(this._while.hasBackReferences)this._cachedCompiledWhilePatterns.setSource(0,Y?Y:"￿");return this._cachedCompiledWhilePatterns}},Q6=class Z{static createCaptureRule(Y,X,J,Q,$){return Y.registerRule((K)=>{return new Q7(X,K,J,Q,$)})}static getCompiledRuleId(Y,X,J){if(!Y.id)X.registerRule((Q)=>{if(Y.id=Q,Y.match)return new $7(Y.$vscodeTextmateLocation,Y.id,Y.name,Y.match,Z._compileCaptures(Y.captures,X,J));if(typeof Y.begin>"u"){if(Y.repository)J=i5({},J,Y.repository);let $=Y.patterns;if(typeof $>"u"&&Y.include)$=[{include:Y.include}];return new m5(Y.$vscodeTextmateLocation,Y.id,Y.name,Y.contentName,Z._compilePatterns($,X,J))}if(Y.while)return new HY(Y.$vscodeTextmateLocation,Y.id,Y.name,Y.contentName,Y.begin,Z._compileCaptures(Y.beginCaptures||Y.captures,X,J),Y.while,Z._compileCaptures(Y.whileCaptures||Y.captures,X,J),Z._compilePatterns(Y.patterns,X,J));return new RX(Y.$vscodeTextmateLocation,Y.id,Y.name,Y.contentName,Y.begin,Z._compileCaptures(Y.beginCaptures||Y.captures,X,J),Y.end,Z._compileCaptures(Y.endCaptures||Y.captures,X,J),Y.applyEndPatternLast,Z._compilePatterns(Y.patterns,X,J))});return Y.id}static _compileCaptures(Y,X,J){let Q=[];if(Y){let $=0;for(let K in Y){if(K==="$vscodeTextmateLocation")continue;let U=parseInt(K,10);if(U>$)$=U}for(let K=0;K<=$;K++)Q[K]=null;for(let K in Y){if(K==="$vscodeTextmateLocation")continue;let U=parseInt(K,10),W=0;if(Y[K].patterns)W=Z.getCompiledRuleId(Y[K],X,J);Q[U]=Z.createCaptureRule(X,Y[K].$vscodeTextmateLocation,Y[K].name,Y[K].contentName,W)}}return Q}static _compilePatterns(Y,X,J){let Q=[];if(Y)for(let $=0,K=Y.length;$<K;$++){let U=Y[$],W=-1;if(U.include){let z=Z6(U.include);switch(z.kind){case 0:case 1:W=Z.getCompiledRuleId(J[U.include],X,J);break;case 2:let H=J[z.ruleName];if(H)W=Z.getCompiledRuleId(H,X,J);break;case 3:case 4:let G=z.scopeName,F=z.kind===4?z.ruleName:null,M=X.getExternalGrammar(G,J);if(M)if(F){let N=M.repository[F];if(N)W=Z.getCompiledRuleId(N,X,M.repository)}else W=Z.getCompiledRuleId(M.repository.$self,X,M.repository);break}}else W=Z.getCompiledRuleId(U,X,J);if(W!==-1){let z=X.getRule(W),H=!1;if(z instanceof m5||z instanceof RX||z instanceof HY){if(z.hasMissingPatterns&&z.patterns.length===0)H=!0}if(H)continue;Q.push(W)}}return{patterns:Q,hasMissingPatterns:(Y?Y.length:0)!==Q.length}}},E0=class Z{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(Y,X){if(Y&&typeof Y==="string"){let J=Y.length,Q=0,$=[],K=!1;for(let U=0;U<J;U++)if(Y.charAt(U)==="\\"){if(U+1<J){let z=Y.charAt(U+1);if(z==="z")$.push(Y.substring(Q,U)),$.push("$(?!\\n)(?<!\\n)"),Q=U+2;else if(z==="A"||z==="G")K=!0;U++}}if(this.hasAnchor=K,Q===0)this.source=Y;else $.push(Y.substring(Q,J)),this.source=$.join("")}else this.hasAnchor=!1,this.source=Y;if(this.hasAnchor)this._anchorCache=this._buildAnchorCache();else this._anchorCache=null;if(this.ruleId=X,typeof this.source==="string")this.hasBackReferences=X7.test(this.source);else this.hasBackReferences=!1}clone(){return new Z(this.source,this.ruleId)}setSource(Y){if(this.source===Y)return;if(this.source=Y,this.hasAnchor)this._anchorCache=this._buildAnchorCache()}resolveBackReferences(Y,X){if(typeof this.source!=="string")throw Error("This method should only be called if the source is a string");let J=X.map((Q)=>{return Y.substring(Q.start,Q.end)});return u5.lastIndex=0,this.source.replace(u5,(Q,$)=>{return a5(J[parseInt($,10)]||"")})}_buildAnchorCache(){if(typeof this.source!=="string")throw Error("This method should only be called if the source is a string");let Y=[],X=[],J=[],Q=[],$,K,U,W;for($=0,K=this.source.length;$<K;$++)if(U=this.source.charAt($),Y[$]=U,X[$]=U,J[$]=U,Q[$]=U,U==="\\"){if($+1<K){if(W=this.source.charAt($+1),W==="A")Y[$+1]="￿",X[$+1]="￿",J[$+1]="A",Q[$+1]="A";else if(W==="G")Y[$+1]="￿",X[$+1]="G",J[$+1]="￿",Q[$+1]="G";else Y[$+1]=W,X[$+1]=W,J[$+1]=W,Q[$+1]=W;$++}}return{A0_G0:Y.join(""),A0_G1:X.join(""),A1_G0:J.join(""),A1_G1:Q.join("")}}resolveAnchors(Y,X){if(!this.hasAnchor||!this._anchorCache||typeof this.source!=="string")return this.source;if(Y)if(X)return this._anchorCache.A1_G1;else return this._anchorCache.A1_G0;else if(X)return this._anchorCache.A0_G1;else return this._anchorCache.A0_G0}},b0=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){if(this._cached)this._cached.dispose(),this._cached=null;if(this._anchorCache.A0_G0)this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null;if(this._anchorCache.A0_G1)this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null;if(this._anchorCache.A1_G0)this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null;if(this._anchorCache.A1_G1)this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null}push(Z){this._items.push(Z),this._hasAnchors=this._hasAnchors||Z.hasAnchor}unshift(Z){this._items.unshift(Z),this._hasAnchors=this._hasAnchors||Z.hasAnchor}length(){return this._items.length}setSource(Z,Y){if(this._items[Z].source!==Y)this._disposeCaches(),this._items[Z].setSource(Y)}compile(Z){if(!this._cached){let Y=this._items.map((X)=>X.source);this._cached=new p5(Z,Y,this._items.map((X)=>X.ruleId))}return this._cached}compileAG(Z,Y,X){if(!this._hasAnchors)return this.compile(Z);else if(Y)if(X){if(!this._anchorCache.A1_G1)this._anchorCache.A1_G1=this._resolveAnchors(Z,Y,X);return this._anchorCache.A1_G1}else{if(!this._anchorCache.A1_G0)this._anchorCache.A1_G0=this._resolveAnchors(Z,Y,X);return this._anchorCache.A1_G0}else if(X){if(!this._anchorCache.A0_G1)this._anchorCache.A0_G1=this._resolveAnchors(Z,Y,X);return this._anchorCache.A0_G1}else{if(!this._anchorCache.A0_G0)this._anchorCache.A0_G0=this._resolveAnchors(Z,Y,X);return this._anchorCache.A0_G0}}_resolveAnchors(Z,Y,X){let J=this._items.map((Q)=>Q.resolveAnchors(Y,X));return new p5(Z,J,this._items.map((Q)=>Q.ruleId))}},p5=class{constructor(Z,Y,X){this.regExps=Y,this.rules=X,this.scanner=Z.createOnigScanner(Y)}scanner;dispose(){if(typeof this.scanner.dispose==="function")this.scanner.dispose()}toString(){let Z=[];for(let Y=0,X=this.rules.length;Y<X;Y++)Z.push(" - "+this.rules[Y]+": "+this.regExps[Y]);return Z.join(`
132
- `)}findNextMatchSync(Z,Y,X){let J=this.scanner.findNextMatchSync(Z,Y,X);if(!J)return null;return{ruleId:this.rules[J.index],captureIndices:J.captureIndices}}},BX=class{constructor(Z,Y){this.languageId=Z,this.tokenType=Y}},K7=class Z{_defaultAttributes;_embeddedLanguagesMatcher;constructor(Y,X){this._defaultAttributes=new BX(Y,8),this._embeddedLanguagesMatcher=new W7(Object.entries(X||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(Y){if(Y===null)return Z._NULL_SCOPE_METADATA;return this._getBasicScopeAttributes.get(Y)}static _NULL_SCOPE_METADATA=new BX(0,0);_getBasicScopeAttributes=new s5((Y)=>{let X=this._scopeToLanguage(Y),J=this._toStandardTokenType(Y);return new BX(X,J)});_scopeToLanguage(Y){return this._embeddedLanguagesMatcher.match(Y)||0}_toStandardTokenType(Y){let X=Y.match(Z.STANDARD_TOKEN_TYPE_REGEXP);if(!X)return 8;switch(X[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},W7=class{values;scopesRegExp;constructor(Z){if(Z.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(Z);let Y=Z.map(([X,J])=>a5(X));Y.sort(),Y.reverse(),this.scopesRegExp=new RegExp(`^((${Y.join(")|(")}))($|\\.)`,"")}}match(Z){if(!this.scopesRegExp)return;let Y=Z.match(this.scopesRegExp);if(!Y)return;return this.values.get(Y[1])}},KO={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},$6=!1,d5=class{constructor(Z,Y){this.stack=Z,this.stoppedEarly=Y}};function K6(Z,Y,X,J,Q,$,K,U){let W=Y.content.length,z=!1,H=-1;if(K){let M=U7(Z,Y,X,J,Q,$);Q=M.stack,J=M.linePos,X=M.isFirstLine,H=M.anchorPosition}let G=Date.now();while(!z){if(U!==0){if(Date.now()-G>U)return new d5(Q,!0)}F()}return new d5(Q,!1);function F(){let M=z7(Z,Y,X,J,Q,H);if(!M){$.produce(Q,W),z=!0;return}let{captureIndices:N,matchedRuleId:w}=M,L=N&&N.length>0?N[0].end>J:!1;if(w===J7){let B=Q.getRule(Z);$.produce(Q,N[0].start),Q=Q.withContentNameScopesList(Q.nameScopesList),I0(Z,Y,X,Q,$,B.endCaptures,N),$.produce(Q,N[0].end);let C=Q;if(Q=Q.parent,H=C.getAnchorPos(),!L&&C.getEnterPos()===J){Q=C,$.produce(Q,W),z=!0;return}}else{let B=Z.getRule(w);$.produce(Q,N[0].start);let C=Q,R=B.getName(Y.content,N),D=Q.contentNameScopesList.pushAttributed(R,Z);if(Q=Q.push(w,J,H,N[0].end===W,null,D,D),B instanceof RX){let f=B;I0(Z,Y,X,Q,$,f.beginCaptures,N),$.produce(Q,N[0].end),H=N[0].end;let V=f.getContentName(Y.content,N),d=D.pushAttributed(V,Z);if(Q=Q.withContentNameScopesList(d),f.endHasBackReferences)Q=Q.withEndRule(f.getEndWithResolvedBackReferences(Y.content,N));if(!L&&C.hasSameRuleAs(Q)){Q=Q.pop(),$.produce(Q,W),z=!0;return}}else if(B instanceof HY){let f=B;I0(Z,Y,X,Q,$,f.beginCaptures,N),$.produce(Q,N[0].end),H=N[0].end;let V=f.getContentName(Y.content,N),d=D.pushAttributed(V,Z);if(Q=Q.withContentNameScopesList(d),f.whileHasBackReferences)Q=Q.withEndRule(f.getWhileWithResolvedBackReferences(Y.content,N));if(!L&&C.hasSameRuleAs(Q)){Q=Q.pop(),$.produce(Q,W),z=!0;return}}else if(I0(Z,Y,X,Q,$,B.captures,N),$.produce(Q,N[0].end),Q=Q.pop(),!L){Q=Q.safePop(),$.produce(Q,W),z=!0;return}}if(N[0].end>J)J=N[0].end,X=!1}}function U7(Z,Y,X,J,Q,$){let K=Q.beginRuleCapturedEOL?0:-1,U=[];for(let W=Q;W;W=W.pop()){let z=W.getRule(Z);if(z instanceof HY)U.push({rule:z,stack:W})}for(let W=U.pop();W;W=U.pop()){let{ruleScanner:z,findOptions:H}=O7(W.rule,Z,W.stack.endRule,X,J===K),G=z.findNextMatchSync(Y,J,H);if(G){if(G.ruleId!==Y6){Q=W.stack.pop();break}if(G.captureIndices&&G.captureIndices.length){if($.produce(W.stack,G.captureIndices[0].start),I0(Z,Y,X,W.stack,$,W.rule.whileCaptures,G.captureIndices),$.produce(W.stack,G.captureIndices[0].end),K=G.captureIndices[0].end,G.captureIndices[0].end>J)J=G.captureIndices[0].end,X=!1}}else{Q=W.stack.pop();break}}return{stack:Q,linePos:J,anchorPosition:K,isFirstLine:X}}function z7(Z,Y,X,J,Q,$){let K=H7(Z,Y,X,J,Q,$),U=Z.getInjections();if(U.length===0)return K;let W=G7(U,Z,Y,X,J,Q,$);if(!W)return K;if(!K)return W;let z=K.captureIndices[0].start,H=W.captureIndices[0].start;if(H<z||W.priorityMatch&&H===z)return W;return K}function H7(Z,Y,X,J,Q,$){let K=Q.getRule(Z),{ruleScanner:U,findOptions:W}=W6(K,Z,Q.endRule,X,J===$),z=U.findNextMatchSync(Y,J,W);if(z)return{captureIndices:z.captureIndices,matchedRuleId:z.ruleId};return null}function G7(Z,Y,X,J,Q,$,K){let U=Number.MAX_VALUE,W=null,z,H=0,G=$.contentNameScopesList.getScopeNames();for(let F=0,M=Z.length;F<M;F++){let N=Z[F];if(!N.matcher(G))continue;let w=Y.getRule(N.ruleId),{ruleScanner:L,findOptions:B}=W6(w,Y,null,J,Q===K),C=L.findNextMatchSync(X,Q,B);if(!C)continue;let R=C.captureIndices[0].start;if(R>=U)continue;if(U=R,W=C.captureIndices,z=C.ruleId,H=N.priority,U===Q)break}if(W)return{priorityMatch:H===-1,captureIndices:W,matchedRuleId:z};return null}function W6(Z,Y,X,J,Q){if($6){let K=Z.compile(Y,X),U=U6(J,Q);return{ruleScanner:K,findOptions:U}}return{ruleScanner:Z.compileAG(Y,X,J,Q),findOptions:0}}function O7(Z,Y,X,J,Q){if($6){let K=Z.compileWhile(Y,X),U=U6(J,Q);return{ruleScanner:K,findOptions:U}}return{ruleScanner:Z.compileWhileAG(Y,X,J,Q),findOptions:0}}function U6(Z,Y){let X=0;if(!Z)X|=1;if(!Y)X|=4;return X}function I0(Z,Y,X,J,Q,$,K){if($.length===0)return;let U=Y.content,W=Math.min($.length,K.length),z=[],H=K[0].end;for(let G=0;G<W;G++){let F=$[G];if(F===null)continue;let M=K[G];if(M.length===0)continue;if(M.start>H)break;while(z.length>0&&z[z.length-1].endPos<=M.start)Q.produceFromScopes(z[z.length-1].scopes,z[z.length-1].endPos),z.pop();if(z.length>0)Q.produceFromScopes(z[z.length-1].scopes,M.start);else Q.produce(J,M.start);if(F.retokenizeCapturedWithRuleId){let w=F.getName(U,K),L=J.contentNameScopesList.pushAttributed(w,Z),B=F.getContentName(U,K),C=L.pushAttributed(B,Z),R=J.push(F.retokenizeCapturedWithRuleId,M.start,-1,!1,null,L,C),D=Z.createOnigString(U.substring(0,M.end));K6(Z,D,X&&M.start===0,M.start,R,Q,!1,0),e5(D);continue}let N=F.getName(U,K);if(N!==null){let L=(z.length>0?z[z.length-1].scopes:J.contentNameScopesList).pushAttributed(N,Z);z.push(new q7(L,M.end))}}while(z.length>0)Q.produceFromScopes(z[z.length-1].scopes,z[z.length-1].endPos),z.pop()}var q7=class{scopes;endPos;constructor(Z,Y){this.scopes=Z,this.endPos=Y}};function F7(Z,Y,X,J,Q,$,K,U){return new N7(Z,Y,X,J,Q,$,K,U)}function c5(Z,Y,X,J,Q){let $=UY(Y,GY),K=Q6.getCompiledRuleId(X,J,Q.repository);for(let U of $)Z.push({debugSelector:Y,matcher:U.matcher,ruleId:K,grammar:Q,priority:U.priority})}function GY(Z,Y){if(Y.length<Z.length)return!1;let X=0;return Z.every((J)=>{for(let Q=X;Q<Y.length;Q++)if(M7(Y[Q],J))return X=Q+1,!0;return!1})}function M7(Z,Y){if(!Z)return!1;if(Z===Y)return!0;let X=Y.length;return Z.length>X&&Z.substr(0,X)===Y&&Z[X]==="."}var N7=class{constructor(Z,Y,X,J,Q,$,K,U){if(this._rootScopeName=Z,this.balancedBracketSelectors=$,this._onigLib=U,this._basicScopeAttributesProvider=new K7(X,J),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=K,this._grammar=l5(Y,null),this._injections=null,this._tokenTypeMatchers=[],Q)for(let W of Object.keys(Q)){let z=UY(W,GY);for(let H of z)this._tokenTypeMatchers.push({matcher:H.matcher,type:Q[W]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let Z of this._ruleId2desc)if(Z)Z.dispose()}createOnigScanner(Z){return this._onigLib.createOnigScanner(Z)}createOnigString(Z){return this._onigLib.createOnigString(Z)}getMetadataForScope(Z){return this._basicScopeAttributesProvider.getBasicScopeAttributes(Z)}_collectInjections(){let Z={lookup:(Q)=>{if(Q===this._rootScopeName)return this._grammar;return this.getExternalGrammar(Q)},injections:(Q)=>{return this._grammarRepository.injections(Q)}},Y=[],X=this._rootScopeName,J=Z.lookup(X);if(J){let Q=J.injections;if(Q)for(let K in Q)c5(Y,K,Q[K],this,J);let $=this._grammarRepository.injections(X);if($)$.forEach((K)=>{let U=this.getExternalGrammar(K);if(U){let W=U.injectionSelector;if(W)c5(Y,W,U,this,U)}})}return Y.sort((Q,$)=>Q.priority-$.priority),Y}getInjections(){if(this._injections===null)this._injections=this._collectInjections();return this._injections}registerRule(Z){let Y=++this._lastRuleId,X=Z(X6(Y));return this._ruleId2desc[Y]=X,X}getRule(Z){return this._ruleId2desc[J6(Z)]}getExternalGrammar(Z,Y){if(this._includedGrammars[Z])return this._includedGrammars[Z];else if(this._grammarRepository){let X=this._grammarRepository.lookup(Z);if(X)return this._includedGrammars[Z]=l5(X,Y&&Y.$base),this._includedGrammars[Z]}return}tokenizeLine(Z,Y,X=0){let J=this._tokenize(Z,Y,!1,X);return{tokens:J.lineTokens.getResult(J.ruleStack,J.lineLength),ruleStack:J.ruleStack,stoppedEarly:J.stoppedEarly}}tokenizeLine2(Z,Y,X=0){let J=this._tokenize(Z,Y,!0,X);return{tokens:J.lineTokens.getBinaryResult(J.ruleStack,J.lineLength),ruleStack:J.ruleStack,stoppedEarly:J.stoppedEarly}}_tokenize(Z,Y,X,J){if(this._rootId===-1)this._rootId=Q6.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections();let Q;if(!Y||Y===CX.NULL){Q=!0;let z=this._basicScopeAttributesProvider.getDefaultAttributes(),H=this.themeProvider.getDefaults(),G=o4.set(0,z.languageId,z.tokenType,null,H.fontStyle,H.foregroundId,H.backgroundId),F=this.getRule(this._rootId).getName(null,null),M;if(F)M=v0.createRootAndLookUpScopeName(F,G,this);else M=v0.createRoot("unknown",G);Y=new CX(null,this._rootId,-1,-1,!1,null,M,M)}else Q=!1,Y.reset();Z=Z+`
133
- `;let $=this.createOnigString(Z),K=$.content.length,U=new A7(X,Z,this._tokenTypeMatchers,this.balancedBracketSelectors),W=K6(this,$,Q,0,Y,U,!0,J);return e5($),{lineLength:K,lineTokens:U,ruleStack:W.stack,stoppedEarly:W.stoppedEarly}}};function l5(Z,Y){return Z=jK(Z),Z.repository=Z.repository||{},Z.repository.$self={$vscodeTextmateLocation:Z.$vscodeTextmateLocation,patterns:Z.patterns,name:Z.scopeName},Z.repository.$base=Y||Z.repository.$self,Z}var v0=class Z{constructor(Y,X,J){this.parent=Y,this.scopePath=X,this.tokenAttributes=J}static fromExtension(Y,X){let J=Y,Q=Y?.scopePath??null;for(let $ of X)Q=wX.push(Q,$.scopeNames),J=new Z(J,Q,$.encodedTokenAttributes);return J}static createRoot(Y,X){return new Z(null,new wX(null,Y),X)}static createRootAndLookUpScopeName(Y,X,J){let Q=J.getMetadataForScope(Y),$=new wX(null,Y),K=J.themeProvider.themeMatch($),U=Z.mergeAttributes(X,Q,K);return new Z(null,$,U)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(Y){return Z.equals(this,Y)}static equals(Y,X){do{if(Y===X)return!0;if(!Y&&!X)return!0;if(!Y||!X)return!1;if(Y.scopeName!==X.scopeName||Y.tokenAttributes!==X.tokenAttributes)return!1;Y=Y.parent,X=X.parent}while(!0)}static mergeAttributes(Y,X,J){let Q=-1,$=0,K=0;if(J!==null)Q=J.fontStyle,$=J.foregroundId,K=J.backgroundId;return o4.set(Y,X.languageId,X.tokenType,null,Q,$,K)}pushAttributed(Y,X){if(Y===null)return this;if(Y.indexOf(" ")===-1)return Z._pushAttributed(this,Y,X);let J=Y.split(/ /g),Q=this;for(let $ of J)Q=Z._pushAttributed(Q,$,X);return Q}static _pushAttributed(Y,X,J){let Q=J.getMetadataForScope(X),$=Y.scopePath.push(X),K=J.themeProvider.themeMatch($),U=Z.mergeAttributes(Y.tokenAttributes,Q,K);return new Z(Y,$,U)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(Y){let X=[],J=this;while(J&&J!==Y)X.push({encodedTokenAttributes:J.tokenAttributes,scopeNames:J.scopePath.getExtensionIfDefined(J.parent?.scopePath??null)}),J=J.parent;return J===Y?X.reverse():void 0}},CX=class Z{constructor(Y,X,J,Q,$,K,U,W){this.parent=Y,this.ruleId=X,this.beginRuleCapturedEOL=$,this.endRule=K,this.nameScopesList=U,this.contentNameScopesList=W,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=J,this._anchorPos=Q}_stackElementBrand=void 0;static NULL=new Z(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(Y){if(Y===null)return!1;return Z._equals(this,Y)}static _equals(Y,X){if(Y===X)return!0;if(!this._structuralEquals(Y,X))return!1;return v0.equals(Y.contentNameScopesList,X.contentNameScopesList)}static _structuralEquals(Y,X){do{if(Y===X)return!0;if(!Y&&!X)return!0;if(!Y||!X)return!1;if(Y.depth!==X.depth||Y.ruleId!==X.ruleId||Y.endRule!==X.endRule)return!1;Y=Y.parent,X=X.parent}while(!0)}clone(){return this}static _reset(Y){while(Y)Y._enterPos=-1,Y._anchorPos=-1,Y=Y.parent}reset(){Z._reset(this)}pop(){return this.parent}safePop(){if(this.parent)return this.parent;return this}push(Y,X,J,Q,$,K,U){return new Z(this,Y,X,J,Q,$,K,U)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(Y){return Y.getRule(this.ruleId)}toString(){let Y=[];return this._writeString(Y,0),"["+Y.join(",")+"]"}_writeString(Y,X){if(this.parent)X=this.parent._writeString(Y,X);return Y[X++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,X}withContentNameScopesList(Y){if(this.contentNameScopesList===Y)return this;return this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,Y)}withEndRule(Y){if(this.endRule===Y)return this;return new Z(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,Y,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(Y){let X=this;while(X&&X._enterPos===Y._enterPos){if(X.ruleId===Y.ruleId)return!0;X=X.parent}return!1}toStateStackFrame(){return{ruleId:J6(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(Y,X){let J=v0.fromExtension(Y?.nameScopesList??null,X.nameScopesList);return new Z(Y,X6(X.ruleId),X.enterPos??-1,X.anchorPos??-1,X.beginRuleCapturedEOL,X.endRule,J,v0.fromExtension(J,X.contentNameScopesList))}},_7=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(Z,Y){this.balancedBracketScopes=Z.flatMap((X)=>{if(X==="*")return this.allowAny=!0,[];return UY(X,GY).map((J)=>J.matcher)}),this.unbalancedBracketScopes=Y.flatMap((X)=>UY(X,GY).map((J)=>J.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(Z){for(let Y of this.unbalancedBracketScopes)if(Y(Z))return!1;for(let Y of this.balancedBracketScopes)if(Y(Z))return!0;return this.allowAny}},A7=class{constructor(Z,Y,X,J){this.balancedBracketSelectors=J,this._emitBinaryTokens=Z,this._tokenTypeOverrides=X,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(Z,Y){this.produceFromScopes(Z.contentNameScopesList,Y)}produceFromScopes(Z,Y){if(this._lastTokenEndIndex>=Y)return;if(this._emitBinaryTokens){let J=Z?.tokenAttributes??0,Q=!1;if(this.balancedBracketSelectors?.matchesAlways)Q=!0;if(this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let $=Z?.getScopeNames()??[];for(let K of this._tokenTypeOverrides)if(K.matcher($))J=o4.set(J,0,cK(K.type),null,-1,0,0);if(this.balancedBracketSelectors)Q=this.balancedBracketSelectors.match($)}if(Q)J=o4.set(J,0,8,Q,-1,0,0);if(this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===J){this._lastTokenEndIndex=Y;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(J),this._lastTokenEndIndex=Y;return}let X=Z?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:Y,scopes:X}),this._lastTokenEndIndex=Y}getResult(Z,Y){if(this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===Y-1)this._tokens.pop();if(this._tokens.length===0)this._lastTokenEndIndex=-1,this.produce(Z,Y),this._tokens[this._tokens.length-1].startIndex=0;return this._tokens}getBinaryResult(Z,Y){if(this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===Y-1)this._binaryTokens.pop(),this._binaryTokens.pop();if(this._binaryTokens.length===0)this._lastTokenEndIndex=-1,this.produce(Z,Y),this._binaryTokens[this._binaryTokens.length-2]=0;let X=new Uint32Array(this._binaryTokens.length);for(let J=0,Q=this._binaryTokens.length;J<Q;J++)X[J]=this._binaryTokens[J];return X}},w7=class{constructor(Z,Y){this._onigLib=Y,this._theme=Z}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let Z of this._grammars.values())Z.dispose()}setTheme(Z){this._theme=Z}getColorMap(){return this._theme.getColorMap()}addGrammar(Z,Y){if(this._rawGrammars.set(Z.scopeName,Z),Y)this._injectionGrammars.set(Z.scopeName,Y)}lookup(Z){return this._rawGrammars.get(Z)}injections(Z){return this._injectionGrammars.get(Z)}getDefaults(){return this._theme.getDefaults()}themeMatch(Z){return this._theme.match(Z)}grammarForScopeName(Z,Y,X,J,Q){if(!this._grammars.has(Z)){let $=this._rawGrammars.get(Z);if(!$)return null;this._grammars.set(Z,F7(Z,$,Y,X,J,Q,this,this._onigLib))}return this._grammars.get(Z)}},z6=class{_options;_syncRegistry;_ensureGrammarCache;constructor(Z){this._options=Z,this._syncRegistry=new w7(D0.createFromRawTheme(Z.theme,Z.colorMap),Z.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(Z,Y){this._syncRegistry.setTheme(D0.createFromRawTheme(Z,Y))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(Z,Y,X){return this.loadGrammarWithConfiguration(Z,Y,{embeddedLanguages:X})}loadGrammarWithConfiguration(Z,Y,X){return this._loadGrammar(Z,Y,X.embeddedLanguages,X.tokenTypes,new _7(X.balancedBracketSelectors||[],X.unbalancedBracketSelectors||[]))}loadGrammar(Z){return this._loadGrammar(Z,0,null,null,null)}_loadGrammar(Z,Y,X,J,Q){let $=new nK(this._syncRegistry,Z);while($.Q.length>0)$.Q.map((K)=>this._loadSingleGrammar(K.scopeName)),$.processQueue();return this._grammarForScopeName(Z,Y,X,J,Q)}_loadSingleGrammar(Z){if(!this._ensureGrammarCache.has(Z))this._doLoadSingleGrammar(Z),this._ensureGrammarCache.set(Z,!0)}_doLoadSingleGrammar(Z){let Y=this._options.loadGrammar(Z);if(Y){let X=typeof this._options.getInjections==="function"?this._options.getInjections(Z):void 0;this._syncRegistry.addGrammar(Y,X)}}addGrammar(Z,Y=[],X=0,J=null){return this._syncRegistry.addGrammar(Z,Y),this._grammarForScopeName(Z.scopeName,X,J)}_grammarForScopeName(Z,Y=0,X=null,J=null,Q=null){return this._syncRegistry.grammarForScopeName(Z,Y,X,J,Q)}},OY=CX.NULL;var H6=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class E4{constructor(Z,Y,X){if(this.normal=Y,this.property=Z,X)this.space=X}}E4.prototype.normal={};E4.prototype.property={};E4.prototype.space=void 0;function vX(Z,Y){let X={},J={};for(let Q of Z)Object.assign(X,Q.property),Object.assign(J,Q.normal);return new E4(X,J,Y)}function f0(Z){return Z.toLowerCase()}class AZ{constructor(Z,Y){this.attribute=Y,this.property=Z}}AZ.prototype.attribute="";AZ.prototype.booleanish=!1;AZ.prototype.boolean=!1;AZ.prototype.commaOrSpaceSeparated=!1;AZ.prototype.commaSeparated=!1;AZ.prototype.defined=!1;AZ.prototype.mustUseProperty=!1;AZ.prototype.number=!1;AZ.prototype.overloadedBoolean=!1;AZ.prototype.property="";AZ.prototype.spaceSeparated=!1;AZ.prototype.space=void 0;var j0={};B7(j0,{spaceSeparated:()=>o,overloadedBoolean:()=>qY,number:()=>v,commaSeparated:()=>b4,commaOrSpaceSeparated:()=>bZ,booleanish:()=>XZ,boolean:()=>y});var L7=0,y=n4(),XZ=n4(),qY=n4(),v=n4(),o=n4(),b4=n4(),bZ=n4();function n4(){return 2**++L7}var DX=Object.keys(j0);class G0 extends AZ{constructor(Z,Y,X,J){let Q=-1;super(Z,Y);if(G6(this,"space",J),typeof X==="number")while(++Q<DX.length){let $=DX[Q];G6(this,DX[Q],(X&j0[$])===j0[$])}}}G0.prototype.defined=!0;function G6(Z,Y,X){if(X)Z[Y]=X}function mZ(Z){let Y={},X={};for(let[J,Q]of Object.entries(Z.properties)){let $=new G0(J,Z.transform(Z.attributes||{},J),Q,Z.space);if(Z.mustUseProperty&&Z.mustUseProperty.includes(J))$.mustUseProperty=!0;Y[J]=$,X[f0(J)]=J,X[f0($.attribute)]=J}return new E4(Y,X,Z.space)}var VX=mZ({properties:{ariaActiveDescendant:null,ariaAtomic:XZ,ariaAutoComplete:null,ariaBusy:XZ,ariaChecked:XZ,ariaColCount:v,ariaColIndex:v,ariaColSpan:v,ariaControls:o,ariaCurrent:null,ariaDescribedBy:o,ariaDetails:null,ariaDisabled:XZ,ariaDropEffect:o,ariaErrorMessage:null,ariaExpanded:XZ,ariaFlowTo:o,ariaGrabbed:XZ,ariaHasPopup:null,ariaHidden:XZ,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:o,ariaLevel:v,ariaLive:null,ariaModal:XZ,ariaMultiLine:XZ,ariaMultiSelectable:XZ,ariaOrientation:null,ariaOwns:o,ariaPlaceholder:null,ariaPosInSet:v,ariaPressed:XZ,ariaReadOnly:XZ,ariaRelevant:null,ariaRequired:XZ,ariaRoleDescription:o,ariaRowCount:v,ariaRowIndex:v,ariaRowSpan:v,ariaSelected:XZ,ariaSetSize:v,ariaSort:null,ariaValueMax:v,ariaValueMin:v,ariaValueNow:v,ariaValueText:null,role:null},transform(Z,Y){return Y==="role"?Y:"aria-"+Y.slice(4).toLowerCase()}});function FY(Z,Y){return Y in Z?Z[Y]:Y}function MY(Z,Y){return FY(Z,Y.toLowerCase())}var O6=mZ({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:b4,acceptCharset:o,accessKey:o,action:null,allow:null,allowFullScreen:y,allowPaymentRequest:y,allowUserMedia:y,alt:null,as:null,async:y,autoCapitalize:null,autoComplete:o,autoFocus:y,autoPlay:y,blocking:o,capture:null,charSet:null,checked:y,cite:null,className:o,cols:v,colSpan:null,content:null,contentEditable:XZ,controls:y,controlsList:o,coords:v|b4,crossOrigin:null,data:null,dateTime:null,decoding:null,default:y,defer:y,dir:null,dirName:null,disabled:y,download:qY,draggable:XZ,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:y,formTarget:null,headers:o,height:v,hidden:qY,high:v,href:null,hrefLang:null,htmlFor:o,httpEquiv:o,id:null,imageSizes:null,imageSrcSet:null,inert:y,inputMode:null,integrity:null,is:null,isMap:y,itemId:null,itemProp:o,itemRef:o,itemScope:y,itemType:o,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:y,low:v,manifest:null,max:null,maxLength:v,media:null,method:null,min:null,minLength:v,multiple:y,muted:y,name:null,nonce:null,noModule:y,noValidate:y,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:y,optimum:v,pattern:null,ping:o,placeholder:null,playsInline:y,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:y,referrerPolicy:null,rel:o,required:y,reversed:y,rows:v,rowSpan:v,sandbox:o,scope:null,scoped:y,seamless:y,selected:y,shadowRootClonable:y,shadowRootDelegatesFocus:y,shadowRootMode:null,shape:null,size:v,sizes:null,slot:null,span:v,spellCheck:XZ,src:null,srcDoc:null,srcLang:null,srcSet:null,start:v,step:null,style:null,tabIndex:v,target:null,title:null,translate:null,type:null,typeMustMatch:y,useMap:null,value:XZ,width:v,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:o,axis:null,background:null,bgColor:null,border:v,borderColor:null,bottomMargin:v,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:y,declare:y,event:null,face:null,frame:null,frameBorder:null,hSpace:v,leftMargin:v,link:null,longDesc:null,lowSrc:null,marginHeight:v,marginWidth:v,noResize:y,noHref:y,noShade:y,noWrap:y,object:null,profile:null,prompt:null,rev:null,rightMargin:v,rules:null,scheme:null,scrolling:XZ,standby:null,summary:null,text:null,topMargin:v,valueType:null,version:null,vAlign:null,vLink:null,vSpace:v,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:y,disableRemotePlayback:y,prefix:null,property:null,results:v,security:null,unselectable:null},space:"html",transform:MY});var q6=mZ({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:bZ,accentHeight:v,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:v,amplitude:v,arabicForm:null,ascent:v,attributeName:null,attributeType:null,azimuth:v,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:v,by:null,calcMode:null,capHeight:v,className:o,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:v,diffuseConstant:v,direction:null,display:null,dur:null,divisor:v,dominantBaseline:null,download:y,dx:null,dy:null,edgeMode:null,editable:null,elevation:v,enableBackground:null,end:null,event:null,exponent:v,externalResourcesRequired:null,fill:null,fillOpacity:v,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:b4,g2:b4,glyphName:b4,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:v,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:v,horizOriginX:v,horizOriginY:v,id:null,ideographic:v,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:v,k:v,k1:v,k2:v,k3:v,k4:v,kernelMatrix:bZ,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:v,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:v,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:v,overlineThickness:v,paintOrder:null,panose1:null,path:null,pathLength:v,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:o,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:v,pointsAtY:v,pointsAtZ:v,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:bZ,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:bZ,rev:bZ,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:bZ,requiredFeatures:bZ,requiredFonts:bZ,requiredFormats:bZ,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:v,specularExponent:v,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:v,strikethroughThickness:v,string:null,stroke:null,strokeDashArray:bZ,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:v,strokeOpacity:v,strokeWidth:null,style:null,surfaceScale:v,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:bZ,tabIndex:v,tableValues:null,target:null,targetX:v,targetY:v,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:bZ,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:v,underlineThickness:v,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:v,values:null,vAlphabetic:v,vMathematical:v,vectorEffect:null,vHanging:v,vIdeographic:v,version:null,vertAdvY:v,vertOriginX:v,vertOriginY:v,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:v,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:FY});var EX=mZ({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(Z,Y){return"xlink:"+Y.slice(5).toLowerCase()}});var bX=mZ({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:MY});var TX=mZ({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(Z,Y){return"xml:"+Y.slice(3).toLowerCase()}});var P7=/[A-Z]/g,F6=/-[a-z]/g,R7=/^data[-\w.:]+$/i;function fX(Z,Y){let X=f0(Y),J=Y,Q=AZ;if(X in Z.normal)return Z.property[Z.normal[X]];if(X.length>4&&X.slice(0,4)==="data"&&R7.test(Y)){if(Y.charAt(4)==="-"){let $=Y.slice(5).replace(F6,I7);J="data"+$.charAt(0).toUpperCase()+$.slice(1)}else{let $=Y.slice(4);if(!F6.test($)){let K=$.replace(P7,C7);if(K.charAt(0)!=="-")K="-"+K;Y="data"+K}}Q=G0}return new Q(J,Y)}function C7(Z){return"-"+Z.toLowerCase()}function I7(Z){return Z.charAt(1).toUpperCase()}var M6=vX([VX,O6,EX,bX,TX],"html"),NY=vX([VX,q6,EX,bX,TX],"svg");var N6={}.hasOwnProperty;function _6(Z,Y){let X=Y||{};function J(Q,...$){let{invalid:K,handlers:U}=J;if(Q&&N6.call(Q,Z)){let W=String(Q[Z]);K=N6.call(U,W)?U[W]:J.unknown}if(K)return K.call(this,Q,...$)}return J.handlers=X.handlers||{},J.invalid=X.invalid,J.unknown=X.unknown,J}var v7=/["&'<>`]/g,D7=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,V7=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,E7=/[|\\{}()[\]^$+*?.]/g,A6=new WeakMap;function w6(Z,Y){if(Z=Z.replace(Y.subset?b7(Y.subset):v7,J),Y.subset||Y.escapeOnly)return Z;return Z.replace(D7,X).replace(V7,J);function X(Q,$,K){return Y.format((Q.charCodeAt(0)-55296)*1024+Q.charCodeAt(1)-56320+65536,K.charCodeAt($+2),Y)}function J(Q,$,K){return Y.format(Q.charCodeAt(0),K.charCodeAt($+1),Y)}}function b7(Z){let Y=A6.get(Z);if(!Y)Y=T7(Z),A6.set(Z,Y);return Y}function T7(Z){let Y=[],X=-1;while(++X<Z.length)Y.push(Z[X].replace(E7,"\\$&"));return new RegExp("(?:"+Y.join("|")+")","g")}var f7=/[\dA-Fa-f]/;function B6(Z,Y,X){let J="&#x"+Z.toString(16).toUpperCase();return X&&Y&&!f7.test(String.fromCharCode(Y))?J:J+";"}var j7=/\d/;function L6(Z,Y,X){let J="&#"+String(Z);return X&&Y&&!j7.test(String.fromCharCode(Y))?J:J+";"}var P6=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];var _Y={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"};var R6=["cent","copy","divide","gt","lt","not","para","times"];var C6={}.hasOwnProperty,jX={},AY;for(AY in _Y)if(C6.call(_Y,AY))jX[_Y[AY]]=AY;var S7=/[^\dA-Za-z]/;function I6(Z,Y,X,J){let Q=String.fromCharCode(Z);if(C6.call(jX,Q)){let $=jX[Q],K="&"+$;if(X&&P6.includes($)&&!R6.includes($)&&(!J||Y&&Y!==61&&S7.test(String.fromCharCode(Y))))return K;return K+";"}return""}function v6(Z,Y,X){let J=B6(Z,Y,X.omitOptionalSemicolons),Q;if(X.useNamedReferences||X.useShortestReferences)Q=I6(Z,Y,X.omitOptionalSemicolons,X.attribute);if((X.useShortestReferences||!Q)&&X.useShortestReferences){let $=L6(Z,Y,X.omitOptionalSemicolons);if($.length<J.length)J=$}return Q&&(!X.useShortestReferences||Q.length<J.length)?Q:J}function B4(Z,Y){return w6(Z,Object.assign({format:v6},Y))}var y7=/^>|^->|<!--|-->|--!>|<!-$/g,k7=[">"],h7=["<",">"];function D6(Z,Y,X,J){return J.settings.bogusComments?"<?"+B4(Z.value,Object.assign({},J.settings.characterReferences,{subset:k7}))+">":"<!--"+Z.value.replace(y7,Q)+"-->";function Q($){return B4($,Object.assign({},J.settings.characterReferences,{subset:h7}))}}function V6(Z,Y,X,J){return"<!"+(J.settings.upperDoctype?"DOCTYPE":"doctype")+(J.settings.tightDoctype?"":" ")+"html>"}function SX(Z,Y){let X=String(Z);if(typeof Y!=="string")throw TypeError("Expected character");let J=0,Q=X.indexOf(Y);while(Q!==-1)J++,Q=X.indexOf(Y,Q+Y.length);return J}function E6(Z,Y){let X=Y||{};return(Z[Z.length-1]===""?[...Z,""]:Z).join((X.padRight?" ":"")+","+(X.padLeft===!1?"":" ")).trim()}function b6(Z){return Z.join(" ").trim()}var x7=/[ \t\n\f\r]/g;function a4(Z){return typeof Z==="object"?Z.type==="text"?T6(Z.value):!1:T6(Z)}function T6(Z){return Z.replace(x7,"")===""}var $Z=f6(1),yX=f6(-1),g7=[];function f6(Z){return Y;function Y(X,J,Q){let $=X?X.children:g7,K=(J||0)+Z,U=$[K];if(!Q)while(U&&a4(U))K+=Z,U=$[K];return U}}var u7={}.hasOwnProperty;function wY(Z){return Y;function Y(X,J,Q){return u7.call(Z,X.tagName)&&Z[X.tagName](X,J,Q)}}var S0=wY({body:p7,caption:kX,colgroup:kX,dd:i7,dt:l7,head:kX,html:m7,li:c7,optgroup:r7,option:o7,p:d7,rp:j6,rt:j6,tbody:a7,td:S6,tfoot:s7,th:S6,thead:n7,tr:t7});function kX(Z,Y,X){let J=$Z(X,Y,!0);return!J||J.type!=="comment"&&!(J.type==="text"&&a4(J.value.charAt(0)))}function m7(Z,Y,X){let J=$Z(X,Y);return!J||J.type!=="comment"}function p7(Z,Y,X){let J=$Z(X,Y);return!J||J.type!=="comment"}function d7(Z,Y,X){let J=$Z(X,Y);return J?J.type==="element"&&(J.tagName==="address"||J.tagName==="article"||J.tagName==="aside"||J.tagName==="blockquote"||J.tagName==="details"||J.tagName==="div"||J.tagName==="dl"||J.tagName==="fieldset"||J.tagName==="figcaption"||J.tagName==="figure"||J.tagName==="footer"||J.tagName==="form"||J.tagName==="h1"||J.tagName==="h2"||J.tagName==="h3"||J.tagName==="h4"||J.tagName==="h5"||J.tagName==="h6"||J.tagName==="header"||J.tagName==="hgroup"||J.tagName==="hr"||J.tagName==="main"||J.tagName==="menu"||J.tagName==="nav"||J.tagName==="ol"||J.tagName==="p"||J.tagName==="pre"||J.tagName==="section"||J.tagName==="table"||J.tagName==="ul"):!X||!(X.type==="element"&&(X.tagName==="a"||X.tagName==="audio"||X.tagName==="del"||X.tagName==="ins"||X.tagName==="map"||X.tagName==="noscript"||X.tagName==="video"))}function c7(Z,Y,X){let J=$Z(X,Y);return!J||J.type==="element"&&J.tagName==="li"}function l7(Z,Y,X){let J=$Z(X,Y);return Boolean(J&&J.type==="element"&&(J.tagName==="dt"||J.tagName==="dd"))}function i7(Z,Y,X){let J=$Z(X,Y);return!J||J.type==="element"&&(J.tagName==="dt"||J.tagName==="dd")}function j6(Z,Y,X){let J=$Z(X,Y);return!J||J.type==="element"&&(J.tagName==="rp"||J.tagName==="rt")}function r7(Z,Y,X){let J=$Z(X,Y);return!J||J.type==="element"&&J.tagName==="optgroup"}function o7(Z,Y,X){let J=$Z(X,Y);return!J||J.type==="element"&&(J.tagName==="option"||J.tagName==="optgroup")}function n7(Z,Y,X){let J=$Z(X,Y);return Boolean(J&&J.type==="element"&&(J.tagName==="tbody"||J.tagName==="tfoot"))}function a7(Z,Y,X){let J=$Z(X,Y);return!J||J.type==="element"&&(J.tagName==="tbody"||J.tagName==="tfoot")}function s7(Z,Y,X){return!$Z(X,Y)}function t7(Z,Y,X){let J=$Z(X,Y);return!J||J.type==="element"&&J.tagName==="tr"}function S6(Z,Y,X){let J=$Z(X,Y);return!J||J.type==="element"&&(J.tagName==="td"||J.tagName==="th")}var y6=wY({body:Y9,colgroup:X9,head:Z9,html:e7,tbody:J9});function e7(Z){let Y=$Z(Z,-1);return!Y||Y.type!=="comment"}function Z9(Z){let Y=new Set;for(let J of Z.children)if(J.type==="element"&&(J.tagName==="base"||J.tagName==="title")){if(Y.has(J.tagName))return!1;Y.add(J.tagName)}let X=Z.children[0];return!X||X.type==="element"}function Y9(Z){let Y=$Z(Z,-1,!0);return!Y||Y.type!=="comment"&&!(Y.type==="text"&&a4(Y.value.charAt(0)))&&!(Y.type==="element"&&(Y.tagName==="meta"||Y.tagName==="link"||Y.tagName==="script"||Y.tagName==="style"||Y.tagName==="template"))}function X9(Z,Y,X){let J=yX(X,Y),Q=$Z(Z,-1,!0);if(X&&J&&J.type==="element"&&J.tagName==="colgroup"&&S0(J,X.children.indexOf(J),X))return!1;return Boolean(Q&&Q.type==="element"&&Q.tagName==="col")}function J9(Z,Y,X){let J=yX(X,Y),Q=$Z(Z,-1);if(X&&J&&J.type==="element"&&(J.tagName==="thead"||J.tagName==="tbody")&&S0(J,X.children.indexOf(J),X))return!1;return Boolean(Q&&Q.type==="element"&&Q.tagName==="tr")}var BY={name:[[`
134
- \f\r &/=>`.split(""),`
135
- \f\r "&'/=>\``.split("")],[`\x00
136
- \f\r "&'/<=>`.split(""),`\x00
137
- \f\r "&'/<=>\``.split("")]],unquoted:[[`
138
- \f\r &>`.split(""),`\x00
139
- \f\r "&'<=>\``.split("")],[`\x00
140
- \f\r "&'<=>\``.split(""),`\x00
141
- \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\x00&'".split(""),"\x00\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\x00"&'.split(""),"\x00\"&'`".split("")]]};function k6(Z,Y,X,J){let Q=J.schema,$=Q.space==="svg"?!1:J.settings.omitOptionalTags,K=Q.space==="svg"?J.settings.closeEmptyElements:J.settings.voids.includes(Z.tagName.toLowerCase()),U=[],W;if(Q.space==="html"&&Z.tagName==="svg")J.schema=NY;let z=Q9(J,Z.properties),H=J.all(Q.space==="html"&&Z.tagName==="template"?Z.content:Z);if(J.schema=Q,H)K=!1;if(z||!$||!y6(Z,Y,X)){if(U.push("<",Z.tagName,z?" "+z:""),K&&(Q.space==="svg"||J.settings.closeSelfClosing)){if(W=z.charAt(z.length-1),!J.settings.tightSelfClosing||W==="/"||W&&W!=='"'&&W!=="'")U.push(" ");U.push("/")}U.push(">")}if(U.push(H),!K&&(!$||!S0(Z,Y,X)))U.push("</"+Z.tagName+">");return U.join("")}function Q9(Z,Y){let X=[],J=-1,Q;if(Y){for(Q in Y)if(Y[Q]!==null&&Y[Q]!==void 0){let $=$9(Z,Q,Y[Q]);if($)X.push($)}}while(++J<X.length){let $=Z.settings.tightAttributes?X[J].charAt(X[J].length-1):void 0;if(J!==X.length-1&&$!=='"'&&$!=="'")X[J]+=" "}return X.join("")}function $9(Z,Y,X){let J=fX(Z.schema,Y),Q=Z.settings.allowParseErrors&&Z.schema.space==="html"?0:1,$=Z.settings.allowDangerousCharacters?0:1,K=Z.quote,U;if(J.overloadedBoolean&&(X===J.attribute||X===""))X=!0;else if((J.boolean||J.overloadedBoolean)&&(typeof X!=="string"||X===J.attribute||X===""))X=Boolean(X);if(X===null||X===void 0||X===!1||typeof X==="number"&&Number.isNaN(X))return"";let W=B4(J.attribute,Object.assign({},Z.settings.characterReferences,{subset:BY.name[Q][$]}));if(X===!0)return W;if(X=Array.isArray(X)?(J.commaSeparated?E6:b6)(X,{padLeft:!Z.settings.tightCommaSeparatedLists}):String(X),Z.settings.collapseEmptyAttributes&&!X)return W;if(Z.settings.preferUnquoted)U=B4(X,Object.assign({},Z.settings.characterReferences,{attribute:!0,subset:BY.unquoted[Q][$]}));if(U!==X){if(Z.settings.quoteSmart&&SX(X,K)>SX(X,Z.alternative))K=Z.alternative;U=K+B4(X,Object.assign({},Z.settings.characterReferences,{subset:(K==="'"?BY.single:BY.double)[Q][$],attribute:!0}))+K}return W+(U?"="+U:U)}var K9=["<","&"];function LY(Z,Y,X,J){return X&&X.type==="element"&&(X.tagName==="script"||X.tagName==="style")?Z.value:B4(Z.value,Object.assign({},J.settings.characterReferences,{subset:K9}))}function h6(Z,Y,X,J){return J.settings.allowDangerousHtml?Z.value:LY(Z,Y,X,J)}function x6(Z,Y,X,J){return J.all(Z)}var g6=_6("type",{invalid:W9,unknown:U9,handlers:{comment:D6,doctype:V6,element:k6,raw:h6,root:x6,text:LY}});function W9(Z){throw Error("Expected node, not `"+Z+"`")}function U9(Z){throw Error("Cannot compile unknown node `"+Z.type+"`")}var z9={},H9={},G9=[];function hX(Z,Y){let X=Y||z9,J=X.quote||'"',Q=J==='"'?"'":'"';if(J!=='"'&&J!=="'")throw Error("Invalid quote `"+J+"`, expected `'` or `\"`");return{one:O9,all:q9,settings:{omitOptionalTags:X.omitOptionalTags||!1,allowParseErrors:X.allowParseErrors||!1,allowDangerousCharacters:X.allowDangerousCharacters||!1,quoteSmart:X.quoteSmart||!1,preferUnquoted:X.preferUnquoted||!1,tightAttributes:X.tightAttributes||!1,upperDoctype:X.upperDoctype||!1,tightDoctype:X.tightDoctype||!1,bogusComments:X.bogusComments||!1,tightCommaSeparatedLists:X.tightCommaSeparatedLists||!1,tightSelfClosing:X.tightSelfClosing||!1,collapseEmptyAttributes:X.collapseEmptyAttributes||!1,allowDangerousHtml:X.allowDangerousHtml||!1,voids:X.voids||H6,characterReferences:X.characterReferences||H9,closeSelfClosing:X.closeSelfClosing||!1,closeEmptyElements:X.closeEmptyElements||!1},schema:X.space==="svg"?NY:M6,quote:J,alternative:Q}.one(Array.isArray(Z)?{type:"root",children:Z}:Z,void 0,void 0)}function O9(Z,Y,X){return g6(Z,Y,X,this)}function q9(Z){let Y=[],X=Z&&Z.children||G9,J=-1;while(++J<X.length)Y[J]=this.one(X[J],J,Z);return Y.join("")}function PY(Z,Y){let X=typeof Z==="string"?{}:{...Z.colorReplacements},J=typeof Z==="string"?Z:Z.name;for(let[Q,$]of Object.entries(Y?.colorReplacements||{}))if(typeof $==="string")X[Q]=$;else if(Q===J)Object.assign(X,$);return X}function T4(Z,Y){if(!Z)return Z;return Y?.[Z?.toLowerCase()]||Z}function F9(Z){return Array.isArray(Z)?Z:[Z]}async function i6(Z){return Promise.resolve(typeof Z==="function"?Z():Z).then((Y)=>Y.default||Y)}function mX(Z){return!Z||["plaintext","txt","text","plain"].includes(Z)}function r6(Z){return Z==="ansi"||mX(Z)}function pX(Z){return Z==="none"}function o6(Z){return pX(Z)}function n6(Z,Y){if(!Y)return Z;if(Z.properties||={},Z.properties.class||=[],typeof Z.properties.class==="string")Z.properties.class=Z.properties.class.split(/\s+/g);if(!Array.isArray(Z.properties.class))Z.properties.class=[];let X=Array.isArray(Y)?Y:Y.split(/\s+/g);for(let J of X)if(J&&!Z.properties.class.includes(J))Z.properties.class.push(J);return Z}function DY(Z,Y=!1){if(Z.length===0)return[["",0]];let X=Z.split(/(\r?\n)/g),J=0,Q=[];for(let $=0;$<X.length;$+=2){let K=Y?X[$]+(X[$+1]||""):X[$];Q.push([K,J]),J+=X[$].length,J+=X[$+1]?.length||0}return Q}function M9(Z){let Y=DY(Z,!0).map(([Q])=>Q);function X(Q){if(Q===Z.length)return{line:Y.length-1,character:Y[Y.length-1].length};let $=Q,K=0;for(let U of Y){if($<U.length)break;$-=U.length,K++}return{line:K,character:$}}function J(Q,$){let K=0;for(let U=0;U<Q;U++)K+=Y[U].length;return K+=$,K}return{lines:Y,indexToPos:X,posToIndex:J}}function a6(Z,Y,X){let J=new Set;for(let $ of Z.matchAll(/:?lang=["']([^"']+)["']/g)){let K=$[1].toLowerCase().trim();if(K)J.add(K)}for(let $ of Z.matchAll(/(?:```|~~~)([\w-]+)/g)){let K=$[1].toLowerCase().trim();if(K)J.add(K)}for(let $ of Z.matchAll(/\\begin\{([\w-]+)\}/g)){let K=$[1].toLowerCase().trim();if(K)J.add(K)}for(let $ of Z.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let K=$[1].toLowerCase().trim(),U=K.includes("/")?K.split("/").pop():K;if(U)J.add(U)}if(!X)return Array.from(J);let Q=X.getBundledLanguages();return Array.from(J).filter(($)=>$&&Q[$])}var dX="light-dark()",N9=["color","background-color"];function _9(Z,Y){let X=0,J=[];for(let Q of Y){if(Q>X)J.push({...Z,content:Z.content.slice(X,Q),offset:Z.offset+X});X=Q}if(X<Z.content.length)J.push({...Z,content:Z.content.slice(X),offset:Z.offset+X});return J}function A9(Z,Y){let X=Array.from(Y instanceof Set?Y:new Set(Y)).sort((J,Q)=>J-Q);if(!X.length)return Z;return Z.map((J)=>{return J.flatMap((Q)=>{let $=X.filter((K)=>Q.offset<K&&K<Q.offset+Q.content.length).map((K)=>K-Q.offset).sort((K,U)=>K-U);if(!$.length)return Q;return _9(Q,$)})})}function w9(Z,Y,X,J,Q="css-vars"){let $={content:Z.content,explanation:Z.explanation,offset:Z.offset},K=Y.map((H)=>RY(Z.variants[H])),U=new Set(K.flatMap((H)=>Object.keys(H))),W={},z=(H,G)=>{let F=G==="color"?"":G==="background-color"?"-bg":`-${G}`;return X+Y[H]+(G==="color"?"":F)};return K.forEach((H,G)=>{for(let F of U){let M=H[F]||"inherit";if(G===0&&J&&N9.includes(F))if(J===dX&&K.length>1){let N=Y.findIndex((C)=>C==="light"),w=Y.findIndex((C)=>C==="dark");if(N===-1||w===-1)throw new YZ('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let L=K[N][F]||"inherit",B=K[w][F]||"inherit";if(W[F]=`light-dark(${L}, ${B})`,Q==="css-vars")W[z(G,F)]=M}else W[F]=M;else if(Q==="css-vars")W[z(G,F)]=M}}),$.htmlStyle=W,$}function RY(Z){let Y={};if(Z.color)Y.color=Z.color;if(Z.bgColor)Y["background-color"]=Z.bgColor;if(Z.fontStyle){if(Z.fontStyle&GZ.Italic)Y["font-style"]="italic";if(Z.fontStyle&GZ.Bold)Y["font-weight"]="bold";let X=[];if(Z.fontStyle&GZ.Underline)X.push("underline");if(Z.fontStyle&GZ.Strikethrough)X.push("line-through");if(X.length)Y["text-decoration"]=X.join(" ")}return Y}function uX(Z){if(typeof Z==="string")return Z;return Object.entries(Z).map(([Y,X])=>`${Y}:${X}`).join(";")}var s6=new WeakMap;function VY(Z,Y){s6.set(Z,Y)}function k0(Z){return s6.get(Z)}class O0{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(Z,Y){return new O0(Object.fromEntries(F9(Y).map((X)=>[X,OY])),Z)}constructor(...Z){if(Z.length===2){let[Y,X]=Z;this.lang=X,this._stacks=Y}else{let[Y,X,J]=Z;this.lang=X,this._stacks={[J]:Y}}}getInternalStack(Z=this.theme){return this._stacks[Z]}getScopes(Z=this.theme){return B9(this._stacks[Z])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function B9(Z){let Y=[],X=new Set;function J(Q){if(X.has(Q))return;X.add(Q);let $=Q?.nameScopesList?.scopeName;if($)Y.push($);if(Q.parent)J(Q.parent)}return J(Z),Y}function L9(Z,Y){if(!(Z instanceof O0))throw new YZ("Invalid grammar state");return Z.getInternalStack(Y)}function P9(){let Z=new WeakMap;function Y(X){if(!Z.has(X.meta)){let J=function(K){if(typeof K==="number"){if(K<0||K>X.source.length)throw new YZ(`Invalid decoration offset: ${K}. Code length: ${X.source.length}`);return{...Q.indexToPos(K),offset:K}}else{let U=Q.lines[K.line];if(U===void 0)throw new YZ(`Invalid decoration position ${JSON.stringify(K)}. Lines length: ${Q.lines.length}`);let W=K.character;if(W<0)W=U.length+W;if(W<0||W>U.length)throw new YZ(`Invalid decoration position ${JSON.stringify(K)}. Line ${K.line} length: ${U.length}`);return{...K,character:W,offset:Q.posToIndex(K.line,W)}}},Q=M9(X.source),$=(X.options.decorations||[]).map((K)=>({...K,start:J(K.start),end:J(K.end)}));R9($),Z.set(X.meta,{decorations:$,converter:Q,source:X.source})}return Z.get(X.meta)}return{name:"shiki:decorations",tokens(X){if(!this.options.decorations?.length)return;let Q=Y(this).decorations.flatMap((K)=>[K.start.offset,K.end.offset]);return A9(X,Q)},code(X){if(!this.options.decorations?.length)return;let J=Y(this),Q=Array.from(X.children).filter((H)=>H.type==="element"&&H.tagName==="span");if(Q.length!==J.converter.lines.length)throw new YZ(`Number of lines in code element (${Q.length}) does not match the number of lines in the source (${J.converter.lines.length}). Failed to apply decorations.`);function $(H,G,F,M){let N=Q[H],w="",L=-1,B=-1;if(G===0)L=0;if(F===0)B=0;if(F===Number.POSITIVE_INFINITY)B=N.children.length;if(L===-1||B===-1)for(let R=0;R<N.children.length;R++){if(w+=t6(N.children[R]),L===-1&&w.length===G)L=R+1;if(B===-1&&w.length===F)B=R+1}if(L===-1)throw new YZ(`Failed to find start index for decoration ${JSON.stringify(M.start)}`);if(B===-1)throw new YZ(`Failed to find end index for decoration ${JSON.stringify(M.end)}`);let C=N.children.slice(L,B);if(!M.alwaysWrap&&C.length===N.children.length)U(N,M,"line");else if(!M.alwaysWrap&&C.length===1&&C[0].type==="element")U(C[0],M,"token");else{let R={type:"element",tagName:"span",properties:{},children:C};U(R,M,"wrapper"),N.children.splice(L,C.length,R)}}function K(H,G){Q[H]=U(Q[H],G,"line")}function U(H,G,F){let M=G.properties||{},N=G.transform||((w)=>w);if(H.tagName=G.tagName||"span",H.properties={...H.properties,...M,class:H.properties.class},G.properties?.class)n6(H,G.properties.class);return H=N(H,F)||H,H}let W=[],z=J.decorations.sort((H,G)=>G.start.offset-H.start.offset||H.end.offset-G.end.offset);for(let H of z){let{start:G,end:F}=H;if(G.line===F.line)$(G.line,G.character,F.character,H);else if(G.line<F.line){$(G.line,G.character,Number.POSITIVE_INFINITY,H);for(let M=G.line+1;M<F.line;M++)W.unshift(()=>K(M,H));$(F.line,0,F.character,H)}}W.forEach((H)=>H())}}}function R9(Z){for(let Y=0;Y<Z.length;Y++){let X=Z[Y];if(X.start.offset>X.end.offset)throw new YZ(`Invalid decoration range: ${JSON.stringify(X.start)} - ${JSON.stringify(X.end)}`);for(let J=Y+1;J<Z.length;J++){let Q=Z[J],$=X.start.offset<=Q.start.offset&&Q.start.offset<X.end.offset,K=X.start.offset<Q.end.offset&&Q.end.offset<=X.end.offset,U=Q.start.offset<=X.start.offset&&X.start.offset<Q.end.offset,W=Q.start.offset<X.end.offset&&X.end.offset<=Q.end.offset;if($||K||U||W){if($&&K)continue;if(U&&W)continue;if(U&&X.start.offset===X.end.offset)continue;if(K&&Q.start.offset===Q.end.offset)continue;throw new YZ(`Decorations ${JSON.stringify(X.start)} and ${JSON.stringify(Q.start)} intersect.`)}}}}function t6(Z){if(Z.type==="text")return Z.value;if(Z.type==="element")return Z.children.map(t6).join("");return""}var C9=[P9()];function CY(Z){let Y=I9(Z.transformers||[]);return[...Y.pre,...Y.normal,...Y.post,...C9]}function I9(Z){let Y=[],X=[],J=[];for(let Q of Z)switch(Q.enforce){case"pre":Y.push(Q);break;case"post":X.push(Q);break;default:J.push(Q)}return{pre:Y,post:X,normal:J}}var s4=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],xX={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function v9(Z,Y){let X=Z.indexOf("\x1B",Y);if(X!==-1){if(Z[X+1]==="["){let J=Z.indexOf("m",X);if(J!==-1)return{sequence:Z.substring(X+2,J).split(";"),startPosition:X,position:J+1}}}return{position:Z.length}}function u6(Z){let Y=Z.shift();if(Y==="2"){let X=Z.splice(0,3).map((J)=>Number.parseInt(J));if(X.length!==3||X.some((J)=>Number.isNaN(J)))return;return{type:"rgb",rgb:X}}else if(Y==="5"){let X=Z.shift();if(X)return{type:"table",index:Number(X)}}}function D9(Z){let Y=[];while(Z.length>0){let X=Z.shift();if(!X)continue;let J=Number.parseInt(X);if(Number.isNaN(J))continue;if(J===0)Y.push({type:"resetAll"});else if(J<=9){if(xX[J])Y.push({type:"setDecoration",value:xX[J]})}else if(J<=29){let Q=xX[J-20];if(Q){if(Y.push({type:"resetDecoration",value:Q}),Q==="dim")Y.push({type:"resetDecoration",value:"bold"})}}else if(J<=37)Y.push({type:"setForegroundColor",value:{type:"named",name:s4[J-30]}});else if(J===38){let Q=u6(Z);if(Q)Y.push({type:"setForegroundColor",value:Q})}else if(J===39)Y.push({type:"resetForegroundColor"});else if(J<=47)Y.push({type:"setBackgroundColor",value:{type:"named",name:s4[J-40]}});else if(J===48){let Q=u6(Z);if(Q)Y.push({type:"setBackgroundColor",value:Q})}else if(J===49)Y.push({type:"resetBackgroundColor"});else if(J===53)Y.push({type:"setDecoration",value:"overline"});else if(J===55)Y.push({type:"resetDecoration",value:"overline"});else if(J>=90&&J<=97)Y.push({type:"setForegroundColor",value:{type:"named",name:s4[J-90+8]}});else if(J>=100&&J<=107)Y.push({type:"setBackgroundColor",value:{type:"named",name:s4[J-100+8]}})}return Y}function V9(){let Z=null,Y=null,X=new Set;return{parse(J){let Q=[],$=0;do{let K=v9(J,$),U=K.sequence?J.substring($,K.startPosition):J.substring($);if(U.length>0)Q.push({value:U,foreground:Z,background:Y,decorations:new Set(X)});if(K.sequence){let W=D9(K.sequence);for(let z of W)if(z.type==="resetAll")Z=null,Y=null,X.clear();else if(z.type==="resetForegroundColor")Z=null;else if(z.type==="resetBackgroundColor")Y=null;else if(z.type==="resetDecoration")X.delete(z.value);for(let z of W)if(z.type==="setForegroundColor")Z=z.value;else if(z.type==="setBackgroundColor")Y=z.value;else if(z.type==="setDecoration")X.add(z.value)}$=K.position}while($<J.length);return Q}}}var E9={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function b9(Z=E9){function Y(U){return Z[U]}function X(U){return`#${U.map((W)=>Math.max(0,Math.min(W,255)).toString(16).padStart(2,"0")).join("")}`}let J;function Q(){if(J)return J;J=[];for(let z=0;z<s4.length;z++)J.push(Y(s4[z]));let U=[0,95,135,175,215,255];for(let z=0;z<6;z++)for(let H=0;H<6;H++)for(let G=0;G<6;G++)J.push(X([U[z],U[H],U[G]]));let W=8;for(let z=0;z<24;z++,W+=10)J.push(X([W,W,W]));return J}function $(U){return Q()[U]}function K(U){switch(U.type){case"named":return Y(U.name);case"rgb":return X(U.rgb);case"table":return $(U.index)}}return{value:K}}var T9={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function f9(Z,Y,X){let J=PY(Z,X),Q=DY(Y),$=Object.fromEntries(s4.map((W)=>{let z=`terminal.ansi${W[0].toUpperCase()}${W.substring(1)}`,H=Z.colors?.[z];return[W,H||T9[W]]})),K=b9($),U=V9();return Q.map((W)=>U.parse(W[0]).map((z)=>{let H,G;if(z.decorations.has("reverse"))H=z.background?K.value(z.background):Z.bg,G=z.foreground?K.value(z.foreground):Z.fg;else H=z.foreground?K.value(z.foreground):Z.fg,G=z.background?K.value(z.background):void 0;if(H=T4(H,J),G=T4(G,J),z.decorations.has("dim"))H=j9(H);let F=GZ.None;if(z.decorations.has("bold"))F|=GZ.Bold;if(z.decorations.has("italic"))F|=GZ.Italic;if(z.decorations.has("underline"))F|=GZ.Underline;if(z.decorations.has("strikethrough"))F|=GZ.Strikethrough;return{content:z.value,offset:W[1],color:H,bgColor:G,fontStyle:F}}))}function j9(Z){let Y=Z.match(/#([0-9a-f]{3,8})/i);if(Y){let J=Y[1];if(J.length===8){let Q=Math.round(Number.parseInt(J.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${J.slice(0,6)}${Q}`}else if(J.length===6)return`#${J}80`;else if(J.length===4){let Q=J[0],$=J[1],K=J[2],U=J[3],W=Math.round(Number.parseInt(`${U}${U}`,16)/2).toString(16).padStart(2,"0");return`#${Q}${Q}${$}${$}${K}${K}${W}`}else if(J.length===3){let Q=J[0],$=J[1],K=J[2];return`#${Q}${Q}${$}${$}${K}${K}80`}}let X=Z.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);if(X)return`var(${X[1]}-dim)`;return Z}function cX(Z,Y,X={}){let{theme:J=Z.getLoadedThemes()[0]}=X,Q=Z.resolveLangAlias(X.lang||"text");if(mX(Q)||pX(J))return DY(Y).map((W)=>[{content:W[0],offset:W[1]}]);let{theme:$,colorMap:K}=Z.setTheme(J);if(Q==="ansi")return f9($,Y,X);let U=Z.getLanguage(X.lang||"text");if(X.grammarState){if(X.grammarState.lang!==U.name)throw new YZ(`Grammar state language "${X.grammarState.lang}" does not match highlight language "${U.name}"`);if(!X.grammarState.themes.includes($.name))throw new YZ(`Grammar state themes "${X.grammarState.themes}" do not contain highlight theme "${$.name}"`)}return y9(Y,U,$,K,X)}function S9(...Z){if(Z.length===2)return k0(Z[1]);let[Y,X,J={}]=Z,{lang:Q="text",theme:$=Y.getLoadedThemes()[0]}=J;if(mX(Q)||pX($))throw new YZ("Plain language does not have grammar state");if(Q==="ansi")throw new YZ("ANSI language does not have grammar state");let{theme:K,colorMap:U}=Y.setTheme($),W=Y.getLanguage(Q);return new O0(lX(X,W,K,U,J).stateStack,W.name,K.name)}function y9(Z,Y,X,J,Q){let $=lX(Z,Y,X,J,Q),K=new O0($.stateStack,Y.name,X.name);return VY($.tokens,K),$.tokens}function lX(Z,Y,X,J,Q){let $=PY(X,Q),{tokenizeMaxLineLength:K=0,tokenizeTimeLimit:U=500}=Q,W=DY(Z),z=Q.grammarState?L9(Q.grammarState,X.name)??OY:Q.grammarContextCode!=null?lX(Q.grammarContextCode,Y,X,J,{...Q,grammarState:void 0,grammarContextCode:void 0}).stateStack:OY,H=[],G=[];for(let F=0,M=W.length;F<M;F++){let[N,w]=W[F];if(N===""){H=[],G.push([]);continue}if(K>0&&N.length>=K){H=[],G.push([{content:N,offset:w,color:"",fontStyle:0}]);continue}let L,B,C;if(Q.includeExplanation)L=Y.tokenizeLine(N,z,U),B=L.tokens,C=0;let R=Y.tokenizeLine2(N,z,U),D=R.tokens.length/2;for(let f=0;f<D;f++){let V=R.tokens[2*f],d=f+1<D?R.tokens[2*f+2]:N.length;if(V===d)continue;let l=R.tokens[2*f+1],u=T4(J[o4.getForeground(l)],$),n=o4.getFontStyle(l),i={content:N.substring(V,d),offset:w+V,color:u,fontStyle:n};if(Q.includeExplanation){let Q4=[];if(Q.includeExplanation!=="scopeName")for(let hZ of X.settings){let h4;switch(typeof hZ.scope){case"string":h4=hZ.scope.split(/,/).map((m0)=>m0.trim());break;case"object":h4=hZ.scope;break;default:continue}Q4.push({settings:hZ,selectors:h4.map((m0)=>m0.split(/ /))})}i.explanation=[];let $4=0;while(V+$4<d){let hZ=B[C],h4=N.substring(hZ.startIndex,hZ.endIndex);$4+=h4.length,i.explanation.push({content:h4,scopes:Q.includeExplanation==="scopeName"?k9(hZ.scopes):h9(Q4,hZ.scopes)}),C+=1}}H.push(i)}G.push(H),H=[],z=R.ruleStack}return{tokens:G,stateStack:z}}function k9(Z){return Z.map((Y)=>({scopeName:Y}))}function h9(Z,Y){let X=[];for(let J=0,Q=Y.length;J<Q;J++){let $=Y[J];X[J]={scopeName:$,themeMatches:g9(Z,$,Y.slice(0,J))}}return X}function m6(Z,Y){return Z===Y||Y.substring(0,Z.length)===Z&&Y[Z.length]==="."}function x9(Z,Y,X){if(!m6(Z[Z.length-1],Y))return!1;let J=Z.length-2,Q=X.length-1;while(J>=0&&Q>=0){if(m6(Z[J],X[Q]))J-=1;Q-=1}if(J===-1)return!0;return!1}function g9(Z,Y,X){let J=[];for(let{selectors:Q,settings:$}of Z)for(let K of Q)if(x9(K,Y,X)){J.push($);break}return J}function e6(Z,Y,X){let J=Object.entries(X.themes).filter((W)=>W[1]).map((W)=>({color:W[0],theme:W[1]})),Q=J.map((W)=>{let z=cX(Z,Y,{...X,theme:W.theme}),H=k0(z),G=typeof W.theme==="string"?W.theme:W.theme.name;return{tokens:z,state:H,theme:G}}),$=u9(...Q.map((W)=>W.tokens)),K=$[0].map((W,z)=>W.map((H,G)=>{let F={content:H.content,variants:{},offset:H.offset};if("includeExplanation"in X&&X.includeExplanation)F.explanation=H.explanation;return $.forEach((M,N)=>{let{content:w,explanation:L,offset:B,...C}=M[z][G];F.variants[J[N].color]=C}),F})),U=Q[0].state?new O0(Object.fromEntries(Q.map((W)=>[W.theme,W.state?.getInternalStack(W.theme)])),Q[0].state.lang):void 0;if(U)VY(K,U);return K}function u9(...Z){let Y=Z.map(()=>[]),X=Z.length;for(let J=0;J<Z[0].length;J++){let Q=Z.map((W)=>W[J]),$=Y.map(()=>[]);Y.forEach((W,z)=>W.push($[z]));let K=Q.map(()=>0),U=Q.map((W)=>W[0]);while(U.every((W)=>W)){let W=Math.min(...U.map((z)=>z.content.length));for(let z=0;z<X;z++){let H=U[z];if(H.content.length===W)$[z].push(H),K[z]+=1,U[z]=Q[z][K[z]];else $[z].push({...H,content:H.content.slice(0,W)}),U[z]={...H,content:H.content.slice(W),offset:H.offset+W}}}}return Y}function IY(Z,Y,X){let J,Q,$,K,U,W;if("themes"in X){let{defaultColor:z="light",cssVariablePrefix:H="--shiki-",colorsRendering:G="css-vars"}=X,F=Object.entries(X.themes).filter((B)=>B[1]).map((B)=>({color:B[0],theme:B[1]})).sort((B,C)=>B.color===z?-1:C.color===z?1:0);if(F.length===0)throw new YZ("`themes` option must not be empty");let M=e6(Z,Y,X);if(W=k0(M),z&&dX!==z&&!F.find((B)=>B.color===z))throw new YZ(`\`themes\` option must contain the defaultColor key \`${z}\``);let N=F.map((B)=>Z.getTheme(B.theme)),w=F.map((B)=>B.color);if($=M.map((B)=>B.map((C)=>w9(C,w,H,z,G))),W)VY($,W);let L=F.map((B)=>PY(B.theme,X));Q=p6(F,N,L,H,z,"fg",G),J=p6(F,N,L,H,z,"bg",G),K=`shiki-themes ${N.map((B)=>B.name).join(" ")}`,U=z?void 0:[Q,J].join(";")}else if("theme"in X){let z=PY(X.theme,X);$=cX(Z,Y,X);let H=Z.getTheme(X.theme);J=T4(H.bg,z),Q=T4(H.fg,z),K=H.name,W=k0($)}else throw new YZ("Invalid options, either `theme` or `themes` must be provided");return{tokens:$,fg:Q,bg:J,themeName:K,rootStyle:U,grammarState:W}}function p6(Z,Y,X,J,Q,$,K){return Z.map((U,W)=>{let z=T4(Y[W][$],X[W])||"inherit",H=`${J+U.color}${$==="bg"?"-bg":""}:${z}`;if(W===0&&Q){if(Q===dX&&Z.length>1){let G=Z.findIndex((w)=>w.color==="light"),F=Z.findIndex((w)=>w.color==="dark");if(G===-1||F===-1)throw new YZ('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let M=T4(Y[G][$],X[G])||"inherit",N=T4(Y[F][$],X[F])||"inherit";return`light-dark(${M}, ${N});${H}`}return z}if(K==="css-vars")return H;return null}).filter((U)=>!!U).join(";")}function vY(Z,Y,X,J={meta:{},options:X,codeToHast:(Q,$)=>vY(Z,Q,$),codeToTokens:(Q,$)=>IY(Z,Q,$)}){let Q=Y;for(let N of CY(X))Q=N.preprocess?.call(J,Q,X)||Q;let{tokens:$,fg:K,bg:U,themeName:W,rootStyle:z,grammarState:H}=IY(Z,Q,X),{mergeWhitespaces:G=!0,mergeSameStyleTokens:F=!1}=X;if(G===!0)$=p9($);else if(G==="never")$=d9($);if(F)$=c9($);let M={...J,get source(){return Q}};for(let N of CY(X))$=N.tokens?.call(M,$)||$;return m9($,{...X,fg:K,bg:U,themeName:W,rootStyle:X.rootStyle===!1?!1:X.rootStyle??z},M,H)}function m9(Z,Y,X,J=k0(Z)){let Q=CY(Y),$=[],K={type:"root",children:[]},{structure:U="classic",tabindex:W="0"}=Y,z={class:`shiki ${Y.themeName||""}`};if(Y.rootStyle!==!1)if(Y.rootStyle!=null)z.style=Y.rootStyle;else z.style=`background-color:${Y.bg};color:${Y.fg}`;if(W!==!1&&W!=null)z.tabindex=W.toString();for(let[w,L]of Object.entries(Y.meta||{}))if(!w.startsWith("_"))z[w]=L;let H={type:"element",tagName:"pre",properties:z,children:[],data:Y.data},G={type:"element",tagName:"code",properties:{},children:$},F=[],M={...X,structure:U,addClassToHast:n6,get source(){return X.source},get tokens(){return Z},get options(){return Y},get root(){return K},get pre(){return H},get code(){return G},get lines(){return F}};if(Z.forEach((w,L)=>{if(L){if(U==="inline")K.children.push({type:"element",tagName:"br",properties:{},children:[]});else if(U==="classic")$.push({type:"text",value:`
142
- `})}let B={type:"element",tagName:"span",properties:{class:"line"},children:[]},C=0;for(let R of w){let D={type:"element",tagName:"span",properties:{...R.htmlAttrs},children:[{type:"text",value:R.content}]},f=uX(R.htmlStyle||RY(R));if(f)D.properties.style=f;for(let V of Q)D=V?.span?.call(M,D,L+1,C,B,R)||D;if(U==="inline")K.children.push(D);else if(U==="classic")B.children.push(D);C+=R.content.length}if(U==="classic"){for(let R of Q)B=R?.line?.call(M,B,L+1)||B;F.push(B),$.push(B)}else if(U==="inline")F.push(B)}),U==="classic"){for(let w of Q)G=w?.code?.call(M,G)||G;H.children.push(G);for(let w of Q)H=w?.pre?.call(M,H)||H;K.children.push(H)}else if(U==="inline"){let w=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let R of K.children)if(R.type==="element"&&R.tagName==="br")w.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]};else if(R.type==="element"||R.type==="text")L.children.push(R);w.push(L);let C={type:"element",tagName:"code",properties:{},children:w};for(let R of Q)C=R?.code?.call(M,C)||C;K.children=[];for(let R=0;R<C.children.length;R++){if(R>0)K.children.push({type:"element",tagName:"br",properties:{},children:[]});let D=C.children[R];if(D.type==="element")K.children.push(...D.children)}}let N=K;for(let w of Q)N=w?.root?.call(M,N)||N;if(J)VY(N,J);return N}function p9(Z){return Z.map((Y)=>{let X=[],J="",Q;return Y.forEach(($,K)=>{let W=!($.fontStyle&&($.fontStyle&GZ.Underline||$.fontStyle&GZ.Strikethrough));if(W&&$.content.match(/^\s+$/)&&Y[K+1]){if(Q===void 0)Q=$.offset;J+=$.content}else if(J){if(W)X.push({...$,offset:Q,content:J+$.content});else X.push({content:J,offset:Q},$);Q=void 0,J=""}else X.push($)}),X})}function d9(Z){return Z.map((Y)=>{return Y.flatMap((X)=>{if(X.content.match(/^\s+$/))return X;let J=X.content.match(/^(\s*)(.*?)(\s*)$/);if(!J)return X;let[,Q,$,K]=J;if(!Q&&!K)return X;let U=[{...X,offset:X.offset+Q.length,content:$}];if(Q)U.unshift({content:Q,offset:X.offset});if(K)U.push({content:K,offset:X.offset+Q.length+$.length});return U})})}function c9(Z){return Z.map((Y)=>{let X=[];for(let J of Y){if(X.length===0){X.push({...J});continue}let Q=X[X.length-1],$=uX(Q.htmlStyle||RY(Q)),K=uX(J.htmlStyle||RY(J)),U=Q.fontStyle&&(Q.fontStyle&GZ.Underline||Q.fontStyle&GZ.Strikethrough),W=J.fontStyle&&(J.fontStyle&GZ.Underline||J.fontStyle&GZ.Strikethrough);if(!U&&!W&&$===K)Q.content+=J.content;else X.push({...J})}return X})}var l9=hX;function i9(Z,Y,X){let J={meta:{},options:X,codeToHast:($,K)=>vY(Z,$,K),codeToTokens:($,K)=>IY(Z,$,K)},Q=l9(vY(Z,Y,X,J));for(let $ of CY(X))Q=$.postprocess?.call(J,Q,X)||Q;return Q}var d6={light:"#333333",dark:"#bbbbbb"},c6={light:"#fffffe",dark:"#1e1e1e"},l6="__shiki_resolved";function iX(Z){if(Z?.[l6])return Z;let Y={...Z};if(Y.tokenColors&&!Y.settings)Y.settings=Y.tokenColors,delete Y.tokenColors;Y.type||="dark",Y.colorReplacements={...Y.colorReplacements},Y.settings||=[];let{bg:X,fg:J}=Y;if(!X||!J){let U=Y.settings?Y.settings.find((W)=>!W.name&&!W.scope):void 0;if(U?.settings?.foreground)J=U.settings.foreground;if(U?.settings?.background)X=U.settings.background;if(!J&&Y?.colors?.["editor.foreground"])J=Y.colors["editor.foreground"];if(!X&&Y?.colors?.["editor.background"])X=Y.colors["editor.background"];if(!J)J=Y.type==="light"?d6.light:d6.dark;if(!X)X=Y.type==="light"?c6.light:c6.dark;Y.fg=J,Y.bg=X}if(!(Y.settings[0]&&Y.settings[0].settings&&!Y.settings[0].scope))Y.settings.unshift({settings:{foreground:Y.fg,background:Y.bg}});let Q=0,$=new Map;function K(U){if($.has(U))return $.get(U);Q+=1;let W=`#${Q.toString(16).padStart(8,"0").toLowerCase()}`;if(Y.colorReplacements?.[`#${W}`])return K(U);return $.set(U,W),W}Y.settings=Y.settings.map((U)=>{let W=U.settings?.foreground&&!U.settings.foreground.startsWith("#"),z=U.settings?.background&&!U.settings.background.startsWith("#");if(!W&&!z)return U;let H={...U,settings:{...U.settings}};if(W){let G=K(U.settings.foreground);Y.colorReplacements[G]=U.settings.foreground,H.settings.foreground=G}if(z){let G=K(U.settings.background);Y.colorReplacements[G]=U.settings.background,H.settings.background=G}return H});for(let U of Object.keys(Y.colors||{}))if(U==="editor.foreground"||U==="editor.background"||U.startsWith("terminal.ansi")){if(!Y.colors[U]?.startsWith("#")){let W=K(Y.colors[U]);Y.colorReplacements[W]=Y.colors[U],Y.colors[U]=W}}return Object.defineProperty(Y,l6,{enumerable:!1,writable:!1,value:!0}),Y}async function ZJ(Z){return Array.from(new Set((await Promise.all(Z.filter((Y)=>!r6(Y)).map(async(Y)=>await i6(Y).then((X)=>Array.isArray(X)?X:[X])))).flat()))}async function YJ(Z){return(await Promise.all(Z.map(async(X)=>o6(X)?null:iX(await i6(X))))).filter((X)=>!!X)}var gX=3,r9=!1;function o9(Z,Y=3){if(!gX)return;if(typeof gX==="number"&&Y>gX)return;if(r9)throw Error(`[SHIKI DEPRECATE]: ${Z}`);else console.trace(`[SHIKI DEPRECATE]: ${Z}`)}class t4 extends Error{constructor(Z){super(Z);this.name="ShikiError"}}function XJ(Z,Y){if(!Y)return Z;if(Y[Z]){let X=new Set([Z]);while(Y[Z]){if(Z=Y[Z],X.has(Z))throw new t4(`Circular alias \`${Array.from(X).join(" -> ")} -> ${Z}\``);X.add(Z)}}return Z}class JJ extends z6{constructor(Z,Y,X,J={}){super(Z);this._resolver=Z,this._themes=Y,this._langs=X,this._alias=J,this._themes.map((Q)=>this.loadTheme(Q)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(Z){if(typeof Z==="string")return this._resolvedThemes.get(Z);else return this.loadTheme(Z)}loadTheme(Z){let Y=iX(Z);if(Y.name)this._resolvedThemes.set(Y.name,Y),this._loadedThemesCache=null;return Y}getLoadedThemes(){if(!this._loadedThemesCache)this._loadedThemesCache=[...this._resolvedThemes.keys()];return this._loadedThemesCache}setTheme(Z){let Y=this._textmateThemeCache.get(Z);if(!Y)Y=D0.createFromRawTheme(Z),this._textmateThemeCache.set(Z,Y);this._syncRegistry.setTheme(Y)}getGrammar(Z){return Z=XJ(Z,this._alias),this._resolvedGrammars.get(Z)}loadLanguage(Z){if(this.getGrammar(Z.name))return;let Y=new Set([...this._langMap.values()].filter((Q)=>Q.embeddedLangsLazy?.includes(Z.name)));this._resolver.addLanguage(Z);let X={balancedBracketSelectors:Z.balancedBracketSelectors||["*"],unbalancedBracketSelectors:Z.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(Z.scopeName,Z);let J=this.loadGrammarWithConfiguration(Z.scopeName,1,X);if(J.name=Z.name,this._resolvedGrammars.set(Z.name,J),Z.aliases)Z.aliases.forEach((Q)=>{this._alias[Q]=Z.name});if(this._loadedLanguagesCache=null,Y.size)for(let Q of Y)this._resolvedGrammars.delete(Q.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(Q.scopeName),this._syncRegistry?._grammars?.delete(Q.scopeName),this.loadLanguage(this._langMap.get(Q.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(Z){for(let J of Z)this.resolveEmbeddedLanguages(J);let Y=Array.from(this._langGraph.entries()),X=Y.filter(([J,Q])=>!Q);if(X.length){let J=Y.filter(([Q,$])=>{if(!$)return!1;return($.embeddedLanguages||$.embeddedLangs)?.some((U)=>X.map(([W])=>W).includes(U))}).filter((Q)=>!X.includes(Q));throw new t4(`Missing languages ${X.map(([Q])=>`\`${Q}\``).join(", ")}, required by ${J.map(([Q])=>`\`${Q}\``).join(", ")}`)}for(let[J,Q]of Y)this._resolver.addLanguage(Q);for(let[J,Q]of Y)this.loadLanguage(Q)}getLoadedLanguages(){if(!this._loadedLanguagesCache)this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])];return this._loadedLanguagesCache}resolveEmbeddedLanguages(Z){this._langMap.set(Z.name,Z),this._langGraph.set(Z.name,Z);let Y=Z.embeddedLanguages??Z.embeddedLangs;if(Y)for(let X of Y)this._langGraph.set(X,this._langMap.get(X))}}class QJ{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(Z,Y){this._onigLib={createOnigScanner:(X)=>Z.createScanner(X),createOnigString:(X)=>Z.createString(X)},Y.forEach((X)=>this.addLanguage(X))}get onigLib(){return this._onigLib}getLangRegistration(Z){return this._langs.get(Z)}loadGrammar(Z){return this._scopeToLang.get(Z)}addLanguage(Z){if(this._langs.set(Z.name,Z),Z.aliases)Z.aliases.forEach((Y)=>{this._langs.set(Y,Z)});if(this._scopeToLang.set(Z.scopeName,Z),Z.injectTo)Z.injectTo.forEach((Y)=>{if(!this._injections.get(Y))this._injections.set(Y,[]);this._injections.get(Y).push(Z.scopeName)})}getInjections(Z){let Y=Z.split("."),X=[];for(let J=1;J<=Y.length;J++){let Q=Y.slice(0,J).join(".");X=[...X,...this._injections.get(Q)||[]]}return X}}var y0=0;function n9(Z){if(y0+=1,Z.warnings!==!1&&y0>=10&&y0%10===0)console.warn(`[Shiki] ${y0} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let Y=!1;if(!Z.engine)throw new t4("`engine` option is required for synchronous mode");let X=(Z.langs||[]).flat(1),J=(Z.themes||[]).flat(1).map(iX),Q=new QJ(Z.engine,X),$=new JJ(Q,J,X,Z.langAlias),K;function U(R){return XJ(R,Z.langAlias)}function W(R){B();let D=$.getGrammar(typeof R==="string"?R:R.name);if(!D)throw new t4(`Language \`${R}\` not found, you may need to load it first`);return D}function z(R){if(R==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};B();let D=$.getTheme(R);if(!D)throw new t4(`Theme \`${R}\` not found, you may need to load it first`);return D}function H(R){B();let D=z(R);if(K!==R)$.setTheme(D),K=R;let f=$.getColorMap();return{theme:D,colorMap:f}}function G(){return B(),$.getLoadedThemes()}function F(){return B(),$.getLoadedLanguages()}function M(...R){B(),$.loadLanguages(R.flat(1))}async function N(...R){return M(await ZJ(R))}function w(...R){B();for(let D of R.flat(1))$.loadTheme(D)}async function L(...R){return B(),w(await YJ(R))}function B(){if(Y)throw new t4("Shiki instance has been disposed")}function C(){if(Y)return;Y=!0,$.dispose(),y0-=1}return{setTheme:H,getTheme:z,getLanguage:W,getLoadedThemes:G,getLoadedLanguages:F,resolveLangAlias:U,loadLanguage:N,loadLanguageSync:M,loadTheme:L,loadThemeSync:w,dispose:C,[Symbol.dispose]:C}}async function a9(Z){if(!Z.engine)o9("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[Y,X,J]=await Promise.all([YJ(Z.themes||[]),ZJ(Z.langs||[]),Z.engine]);return n9({...Z,themes:Y,langs:X,engine:J})}async function s9(Z){let Y=await a9(Z);return{getLastGrammarState:(...X)=>S9(Y,...X),codeToTokensBase:(X,J)=>cX(Y,X,J),codeToTokensWithThemes:(X,J)=>e6(Y,X,J),codeToTokens:(X,J)=>IY(Y,X,J),codeToHast:(X,J)=>vY(Y,X,J),codeToHtml:(X,J)=>i9(Y,X,J),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...Y,getInternalContext:()=>Y}}function $J(Z){let{langs:Y,themes:X,engine:J}=Z;async function Q($){function K(G){if(typeof G==="string"){if(G=$.langAlias?.[G]||G,r6(G))return[];let F=Y[G];if(!F)throw new YZ(`Language \`${G}\` is not included in this bundle. You may want to load it from external source.`);return F}return G}function U(G){if(o6(G))return"none";if(typeof G==="string"){let F=X[G];if(!F)throw new YZ(`Theme \`${G}\` is not included in this bundle. You may want to load it from external source.`);return F}return G}let W=($.themes??[]).map((G)=>U(G)),z=($.langs??[]).map((G)=>K(G)),H=await s9({engine:$.engine??J(),...$,themes:W,langs:z});return{...H,loadLanguage(...G){return H.loadLanguage(...G.map(K))},loadTheme(...G){return H.loadTheme(...G.map(U))},getBundledLanguages(){return Y},getBundledThemes(){return X}}}return Q}function t9(Z){let Y;async function X(J={}){if(!Y){Y=Z({...J,themes:[],langs:[]});let Q=await Y;return await Promise.all([Q.loadTheme(...J.themes||[]),Q.loadLanguage(...J.langs||[])]),Q}else{let Q=await Y;return await Promise.all([Q.loadTheme(...J.themes||[]),Q.loadLanguage(...J.langs||[])]),Q}}return X}function KJ(Z,Y){let X=t9(Z);async function J(Q,$){let K=await X({langs:[$.lang],themes:"theme"in $?[$.theme]:Object.values($.themes)}),U=await Y?.guessEmbeddedLanguages?.(Q,$.lang,K);if(U)await K.loadLanguage(...U);return K}return{getSingletonHighlighter(Q){return X(Q)},async codeToHtml(Q,$){return(await J(Q,$)).codeToHtml(Q,$)},async codeToHast(Q,$){return(await J(Q,$)).codeToHast(Q,$)},async codeToTokens(Q,$){return(await J(Q,$)).codeToTokens(Q,$)},async codeToTokensBase(Q,$){return(await J(Q,$)).codeToTokensBase(Q,$)},async codeToTokensWithThemes(Q,$){return(await J(Q,$)).codeToTokensWithThemes(Q,$)},async getLastGrammarState(Q,$){return(await X({langs:[$.lang],themes:[$.theme]})).getLastGrammarState(Q,$)}}}var WJ=[{id:"abap",name:"ABAP",import:()=>import("./chunk-qf60gd6x.js")},{id:"actionscript-3",name:"ActionScript",import:()=>import("./chunk-1ck3yagm.js")},{id:"ada",name:"Ada",import:()=>import("./chunk-xm9015v4.js")},{id:"angular-html",name:"Angular HTML",import:()=>import("./chunk-k17n7dpm.js")},{id:"angular-ts",name:"Angular TypeScript",import:()=>import("./chunk-ah557n6f.js")},{id:"apache",name:"Apache Conf",import:()=>import("./chunk-n08dw2ke.js")},{id:"apex",name:"Apex",import:()=>import("./chunk-2z60cf4h.js")},{id:"apl",name:"APL",import:()=>import("./chunk-fs5s90mk.js")},{id:"applescript",name:"AppleScript",import:()=>import("./chunk-5n6g25gc.js")},{id:"ara",name:"Ara",import:()=>import("./chunk-zytr7a4n.js")},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:()=>import("./chunk-gaw2bhff.js")},{id:"asm",name:"Assembly",import:()=>import("./chunk-f1gz54zs.js")},{id:"astro",name:"Astro",import:()=>import("./chunk-raq8eqd9.js")},{id:"awk",name:"AWK",import:()=>import("./chunk-y0e2ymas.js")},{id:"ballerina",name:"Ballerina",import:()=>import("./chunk-gsnrqmzp.js")},{id:"bat",name:"Batch File",aliases:["batch"],import:()=>import("./chunk-17g5e3tb.js")},{id:"beancount",name:"Beancount",import:()=>import("./chunk-mvb82v3n.js")},{id:"berry",name:"Berry",aliases:["be"],import:()=>import("./chunk-fftvnc8t.js")},{id:"bibtex",name:"BibTeX",import:()=>import("./chunk-6qyeer8n.js")},{id:"bicep",name:"Bicep",import:()=>import("./chunk-xkc2ktrh.js")},{id:"blade",name:"Blade",import:()=>import("./chunk-n6v7menj.js")},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:()=>import("./chunk-j6s60n91.js")},{id:"c",name:"C",import:()=>import("./chunk-sq9spyfd.js")},{id:"c3",name:"C3",import:()=>import("./chunk-wd17hcv5.js")},{id:"cadence",name:"Cadence",aliases:["cdc"],import:()=>import("./chunk-8vr1wy0r.js")},{id:"cairo",name:"Cairo",import:()=>import("./chunk-wbg38h5j.js")},{id:"clarity",name:"Clarity",import:()=>import("./chunk-pc3w4gkp.js")},{id:"clojure",name:"Clojure",aliases:["clj"],import:()=>import("./chunk-hgkaxnh7.js")},{id:"cmake",name:"CMake",import:()=>import("./chunk-ewx6fr7a.js")},{id:"cobol",name:"COBOL",import:()=>import("./chunk-1m8bmdzc.js")},{id:"codeowners",name:"CODEOWNERS",import:()=>import("./chunk-56q8b04m.js")},{id:"codeql",name:"CodeQL",aliases:["ql"],import:()=>import("./chunk-h06hyckd.js")},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:()=>import("./chunk-fd4dk58v.js")},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:()=>import("./chunk-tkp1zzgb.js")},{id:"coq",name:"Coq",import:()=>import("./chunk-kkks4cbp.js")},{id:"cpp",name:"C++",aliases:["c++"],import:()=>import("./chunk-731nq1br.js")},{id:"crystal",name:"Crystal",import:()=>import("./chunk-r5crgj5q.js")},{id:"csharp",name:"C#",aliases:["c#","cs"],import:()=>import("./chunk-2yk5xgha.js")},{id:"css",name:"CSS",import:()=>import("./chunk-7w75nxwb.js")},{id:"csv",name:"CSV",import:()=>import("./chunk-f2p8rps5.js")},{id:"cue",name:"CUE",import:()=>import("./chunk-jyrs3ysr.js")},{id:"cypher",name:"Cypher",aliases:["cql"],import:()=>import("./chunk-w93s735t.js")},{id:"d",name:"D",import:()=>import("./chunk-sk4n2anv.js")},{id:"dart",name:"Dart",import:()=>import("./chunk-ctet86gc.js")},{id:"dax",name:"DAX",import:()=>import("./chunk-zh77yp9z.js")},{id:"desktop",name:"Desktop",import:()=>import("./chunk-77chzpqs.js")},{id:"diff",name:"Diff",import:()=>import("./chunk-vrv07424.js")},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:()=>import("./chunk-pqq81gzv.js")},{id:"dotenv",name:"dotEnv",import:()=>import("./chunk-f3mf8qk2.js")},{id:"dream-maker",name:"Dream Maker",import:()=>import("./chunk-rbebjqfq.js")},{id:"edge",name:"Edge",import:()=>import("./chunk-z88rcc8t.js")},{id:"elixir",name:"Elixir",import:()=>import("./chunk-s5yace4y.js")},{id:"elm",name:"Elm",import:()=>import("./chunk-0kvk3r1g.js")},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:()=>import("./chunk-kgj1ssyj.js")},{id:"erb",name:"ERB",import:()=>import("./chunk-y6mvs6yw.js")},{id:"erlang",name:"Erlang",aliases:["erl"],import:()=>import("./chunk-21gm4tm7.js")},{id:"fennel",name:"Fennel",import:()=>import("./chunk-1tj3j2rd.js")},{id:"fish",name:"Fish",import:()=>import("./chunk-6vhg46d2.js")},{id:"fluent",name:"Fluent",aliases:["ftl"],import:()=>import("./chunk-x8z2fzz8.js")},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:()=>import("./chunk-yhxvqyz4.js")},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:()=>import("./chunk-vqpam6p8.js")},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:()=>import("./chunk-t6x8a62a.js")},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:()=>import("./chunk-f8c6jyrc.js")},{id:"gdscript",name:"GDScript",aliases:["gd"],import:()=>import("./chunk-82xzyhyv.js")},{id:"gdshader",name:"GDShader",import:()=>import("./chunk-wcyrmfpn.js")},{id:"genie",name:"Genie",import:()=>import("./chunk-gbrg4c7y.js")},{id:"gherkin",name:"Gherkin",import:()=>import("./chunk-ywbbf9eh.js")},{id:"git-commit",name:"Git Commit Message",import:()=>import("./chunk-hv4arqm5.js")},{id:"git-rebase",name:"Git Rebase Message",import:()=>import("./chunk-nks89eba.js")},{id:"gleam",name:"Gleam",import:()=>import("./chunk-3s3b7nzy.js")},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:()=>import("./chunk-wkc7w10f.js")},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:()=>import("./chunk-wznpd7sd.js")},{id:"glsl",name:"GLSL",import:()=>import("./chunk-p7ha3t1f.js")},{id:"gn",name:"GN",import:()=>import("./chunk-nwx5cbjc.js")},{id:"gnuplot",name:"Gnuplot",import:()=>import("./chunk-bz79zq7h.js")},{id:"go",name:"Go",import:()=>import("./chunk-pm5gceg0.js")},{id:"graphql",name:"GraphQL",aliases:["gql"],import:()=>import("./chunk-mns6edxc.js")},{id:"groovy",name:"Groovy",import:()=>import("./chunk-hzqb4sy6.js")},{id:"hack",name:"Hack",import:()=>import("./chunk-wb43p5km.js")},{id:"haml",name:"Ruby Haml",import:()=>import("./chunk-ez2xn1tq.js")},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:()=>import("./chunk-2a6kan82.js")},{id:"haskell",name:"Haskell",aliases:["hs"],import:()=>import("./chunk-tx117rah.js")},{id:"haxe",name:"Haxe",import:()=>import("./chunk-0cbmnyee.js")},{id:"hcl",name:"HashiCorp HCL",import:()=>import("./chunk-wvmnb75v.js")},{id:"hjson",name:"Hjson",import:()=>import("./chunk-1xjj19pz.js")},{id:"hlsl",name:"HLSL",import:()=>import("./chunk-rx707y69.js")},{id:"html",name:"HTML",import:()=>import("./chunk-1fmdjx58.js")},{id:"html-derivative",name:"HTML (Derivative)",import:()=>import("./chunk-bqzvv2dy.js")},{id:"http",name:"HTTP",import:()=>import("./chunk-1zbnmy0p.js")},{id:"hurl",name:"Hurl",import:()=>import("./chunk-k1yv7tpj.js")},{id:"hxml",name:"HXML",import:()=>import("./chunk-6eyx9kb0.js")},{id:"hy",name:"Hy",import:()=>import("./chunk-91gd665t.js")},{id:"imba",name:"Imba",import:()=>import("./chunk-m0vtra47.js")},{id:"ini",name:"INI",aliases:["properties"],import:()=>import("./chunk-zjemnf8v.js")},{id:"java",name:"Java",import:()=>import("./chunk-j0szwqey.js")},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:()=>import("./chunk-rg8hdkt2.js")},{id:"jinja",name:"Jinja",import:()=>import("./chunk-ywa5z7d9.js")},{id:"jison",name:"Jison",import:()=>import("./chunk-5rmyjm7a.js")},{id:"json",name:"JSON",import:()=>import("./chunk-sw6b067z.js")},{id:"json5",name:"JSON5",import:()=>import("./chunk-8ee7jvcr.js")},{id:"jsonc",name:"JSON with Comments",import:()=>import("./chunk-b4qvb571.js")},{id:"jsonl",name:"JSON Lines",import:()=>import("./chunk-1xdz3wdt.js")},{id:"jsonnet",name:"Jsonnet",import:()=>import("./chunk-4agrg21g.js")},{id:"jssm",name:"JSSM",aliases:["fsl"],import:()=>import("./chunk-xa4apmpd.js")},{id:"jsx",name:"JSX",import:()=>import("./chunk-ndk5mkc1.js")},{id:"julia",name:"Julia",aliases:["jl"],import:()=>import("./chunk-kq7y5ybe.js")},{id:"kdl",name:"KDL",import:()=>import("./chunk-k626mmdc.js")},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:()=>import("./chunk-vsydmxfh.js")},{id:"kusto",name:"Kusto",aliases:["kql"],import:()=>import("./chunk-xhjrdhgk.js")},{id:"latex",name:"LaTeX",import:()=>import("./chunk-2cfemb9q.js")},{id:"lean",name:"Lean 4",aliases:["lean4"],import:()=>import("./chunk-ka0pqrag.js")},{id:"less",name:"Less",import:()=>import("./chunk-9mjq1xxc.js")},{id:"liquid",name:"Liquid",import:()=>import("./chunk-6yb36qx6.js")},{id:"llvm",name:"LLVM IR",import:()=>import("./chunk-vy4ecvry.js")},{id:"log",name:"Log file",import:()=>import("./chunk-917pj3vx.js")},{id:"logo",name:"Logo",import:()=>import("./chunk-1z3yy9vz.js")},{id:"lua",name:"Lua",import:()=>import("./chunk-esskh0ge.js")},{id:"luau",name:"Luau",import:()=>import("./chunk-jz8tmenz.js")},{id:"make",name:"Makefile",aliases:["makefile"],import:()=>import("./chunk-y6z502pz.js")},{id:"markdown",name:"Markdown",aliases:["md"],import:()=>import("./chunk-sepabvgd.js")},{id:"marko",name:"Marko",import:()=>import("./chunk-bzanqq7a.js")},{id:"matlab",name:"MATLAB",import:()=>import("./chunk-pz5xskrk.js")},{id:"mdc",name:"MDC",import:()=>import("./chunk-dz0229fs.js")},{id:"mdx",name:"MDX",import:()=>import("./chunk-xf7ypd1b.js")},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:()=>import("./chunk-t4vfr2g0.js")},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:()=>import("./chunk-vwhxfs9r.js")},{id:"mojo",name:"Mojo",import:()=>import("./chunk-h1bjeyn7.js")},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:()=>import("./chunk-2mrbrsta.js")},{id:"move",name:"Move",import:()=>import("./chunk-7k80bxbe.js")},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:()=>import("./chunk-av215sh3.js")},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:()=>import("./chunk-6cs4tf5a.js")},{id:"nginx",name:"Nginx",import:()=>import("./chunk-wkf1j21b.js")},{id:"nim",name:"Nim",import:()=>import("./chunk-mrbn4knm.js")},{id:"nix",name:"Nix",import:()=>import("./chunk-ydc7pd3b.js")},{id:"nushell",name:"nushell",aliases:["nu"],import:()=>import("./chunk-kk4w0prd.js")},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:()=>import("./chunk-kys8sc0j.js")},{id:"objective-cpp",name:"Objective-C++",import:()=>import("./chunk-s2wchktz.js")},{id:"ocaml",name:"OCaml",import:()=>import("./chunk-gxc7a8cz.js")},{id:"odin",name:"Odin",import:()=>import("./chunk-mfyvxat8.js")},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:()=>import("./chunk-kc8375a8.js")},{id:"pascal",name:"Pascal",import:()=>import("./chunk-htns6qnb.js")},{id:"perl",name:"Perl",import:()=>import("./chunk-z5z774pp.js")},{id:"php",name:"PHP",import:()=>import("./chunk-n8apqh5d.js")},{id:"pkl",name:"Pkl",import:()=>import("./chunk-fvhtfw18.js")},{id:"plsql",name:"PL/SQL",import:()=>import("./chunk-bs9fj12n.js")},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:()=>import("./chunk-06dj0dnz.js")},{id:"polar",name:"Polar",import:()=>import("./chunk-9hnbyswz.js")},{id:"postcss",name:"PostCSS",import:()=>import("./chunk-rc81vkve.js")},{id:"powerquery",name:"PowerQuery",import:()=>import("./chunk-3d8rzv4d.js")},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:()=>import("./chunk-hgs9vzm2.js")},{id:"prisma",name:"Prisma",import:()=>import("./chunk-vgeyt962.js")},{id:"prolog",name:"Prolog",import:()=>import("./chunk-ceb97hw6.js")},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:()=>import("./chunk-0jtrg9s1.js")},{id:"pug",name:"Pug",aliases:["jade"],import:()=>import("./chunk-ctp90f8y.js")},{id:"puppet",name:"Puppet",import:()=>import("./chunk-7v4352jx.js")},{id:"purescript",name:"PureScript",import:()=>import("./chunk-ny61b4ve.js")},{id:"python",name:"Python",aliases:["py"],import:()=>import("./chunk-mtyqtnv0.js")},{id:"qml",name:"QML",import:()=>import("./chunk-gps0pyf7.js")},{id:"qmldir",name:"QML Directory",import:()=>import("./chunk-4k15drqf.js")},{id:"qss",name:"Qt Style Sheets",import:()=>import("./chunk-66sfgeag.js")},{id:"r",name:"R",import:()=>import("./chunk-3rew4tyk.js")},{id:"racket",name:"Racket",import:()=>import("./chunk-sdhd2kpk.js")},{id:"raku",name:"Raku",aliases:["perl6"],import:()=>import("./chunk-tj729ry3.js")},{id:"razor",name:"ASP.NET Razor",import:()=>import("./chunk-ms3sqsez.js")},{id:"reg",name:"Windows Registry Script",import:()=>import("./chunk-87w9rexn.js")},{id:"regexp",name:"RegExp",aliases:["regex"],import:()=>import("./chunk-xnx0j1hw.js")},{id:"rel",name:"Rel",import:()=>import("./chunk-3w98g1h4.js")},{id:"riscv",name:"RISC-V",import:()=>import("./chunk-ynnaxz2z.js")},{id:"ron",name:"RON",import:()=>import("./chunk-v9qb0fer.js")},{id:"rosmsg",name:"ROS Interface",import:()=>import("./chunk-qpwtcr53.js")},{id:"rst",name:"reStructuredText",import:()=>import("./chunk-5n57csbz.js")},{id:"ruby",name:"Ruby",aliases:["rb"],import:()=>import("./chunk-zmsq5xc7.js")},{id:"rust",name:"Rust",aliases:["rs"],import:()=>import("./chunk-bjqn0pzz.js")},{id:"sas",name:"SAS",import:()=>import("./chunk-0x0r76m6.js")},{id:"sass",name:"Sass",import:()=>import("./chunk-x01t9e3q.js")},{id:"scala",name:"Scala",import:()=>import("./chunk-7pwrx1pp.js")},{id:"scheme",name:"Scheme",import:()=>import("./chunk-ejh8spnd.js")},{id:"scss",name:"SCSS",import:()=>import("./chunk-am5r5ynh.js")},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:()=>import("./chunk-5bvkhjg1.js")},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:()=>import("./chunk-ezh4rq18.js")},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:()=>import("./chunk-h5y1vfrx.js")},{id:"shellsession",name:"Shell Session",aliases:["console"],import:()=>import("./chunk-kx3dsqc5.js")},{id:"smalltalk",name:"Smalltalk",import:()=>import("./chunk-yzk3bfzn.js")},{id:"solidity",name:"Solidity",import:()=>import("./chunk-qd2hkayk.js")},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:()=>import("./chunk-6qbdcv3t.js")},{id:"sparql",name:"SPARQL",import:()=>import("./chunk-wb08g5z8.js")},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:()=>import("./chunk-0kan91hr.js")},{id:"sql",name:"SQL",import:()=>import("./chunk-nvnw7mcb.js")},{id:"ssh-config",name:"SSH Config",import:()=>import("./chunk-r5psjv6v.js")},{id:"stata",name:"Stata",import:()=>import("./chunk-cayjw3gk.js")},{id:"stylus",name:"Stylus",aliases:["styl"],import:()=>import("./chunk-pt1m6xh9.js")},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:()=>import("./chunk-tq7jpqr7.js")},{id:"svelte",name:"Svelte",import:()=>import("./chunk-emjqnzzj.js")},{id:"swift",name:"Swift",import:()=>import("./chunk-be8bz8xh.js")},{id:"system-verilog",name:"SystemVerilog",import:()=>import("./chunk-n92ey5c2.js")},{id:"systemd",name:"Systemd Units",import:()=>import("./chunk-rt7af3wp.js")},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:()=>import("./chunk-pj843s6s.js")},{id:"tasl",name:"Tasl",import:()=>import("./chunk-dnpybaez.js")},{id:"tcl",name:"Tcl",import:()=>import("./chunk-zqxrtejz.js")},{id:"templ",name:"Templ",import:()=>import("./chunk-250846sw.js")},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:()=>import("./chunk-whdmep96.js")},{id:"tex",name:"TeX",import:()=>import("./chunk-7n5b43s8.js")},{id:"toml",name:"TOML",import:()=>import("./chunk-59vj8mx3.js")},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:()=>import("./chunk-asdze5kz.js")},{id:"tsv",name:"TSV",import:()=>import("./chunk-qzy0w65x.js")},{id:"tsx",name:"TSX",import:()=>import("./chunk-cv5akzkw.js")},{id:"turtle",name:"Turtle",import:()=>import("./chunk-kr6cv1mp.js")},{id:"twig",name:"Twig",import:()=>import("./chunk-mft6e1b3.js")},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:()=>import("./chunk-7yf45m28.js")},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:()=>import("./chunk-fm3k6prw.js")},{id:"typst",name:"Typst",aliases:["typ"],import:()=>import("./chunk-r9dm0gyn.js")},{id:"v",name:"V",import:()=>import("./chunk-dp2418kp.js")},{id:"vala",name:"Vala",import:()=>import("./chunk-fdhzjb42.js")},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:()=>import("./chunk-wdm62dbr.js")},{id:"verilog",name:"Verilog",import:()=>import("./chunk-7wa89vcy.js")},{id:"vhdl",name:"VHDL",import:()=>import("./chunk-54kyvbh7.js")},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:()=>import("./chunk-gkhxerej.js")},{id:"vue",name:"Vue",import:()=>import("./chunk-3emyjvqg.js")},{id:"vue-html",name:"Vue HTML",import:()=>import("./chunk-q6m1k4fq.js")},{id:"vue-vine",name:"Vue Vine",import:()=>import("./chunk-z0wdan61.js")},{id:"vyper",name:"Vyper",aliases:["vy"],import:()=>import("./chunk-0k9tc7ys.js")},{id:"wasm",name:"WebAssembly",import:()=>import("./chunk-748hk53z.js")},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:()=>import("./chunk-xjwkmvfz.js")},{id:"wgsl",name:"WGSL",import:()=>import("./chunk-0cknr23d.js")},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:()=>import("./chunk-kc6rwv2m.js")},{id:"wit",name:"WebAssembly Interface Types",import:()=>import("./chunk-w5qvj179.js")},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:()=>import("./chunk-4asb3qnd.js")},{id:"xml",name:"XML",import:()=>import("./chunk-8arg48f8.js")},{id:"xsl",name:"XSL",import:()=>import("./chunk-ffzytaw1.js")},{id:"yaml",name:"YAML",aliases:["yml"],import:()=>import("./chunk-hmtm22t7.js")},{id:"zenscript",name:"ZenScript",import:()=>import("./chunk-ycthcn27.js")},{id:"zig",name:"Zig",import:()=>import("./chunk-8gm5e25z.js")}],e9=Object.fromEntries(WJ.map((Z)=>[Z.id,Z.import])),ZW=Object.fromEntries(WJ.flatMap((Z)=>Z.aliases?.map((Y)=>[Y,Z.import])||[])),UJ={...e9,...ZW};var YW=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:()=>import("./chunk-h0b5na4r.js")},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:()=>import("./chunk-53agfxhn.js")},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:()=>import("./chunk-8qh81vdm.js")},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:()=>import("./chunk-6bhkrdb2.js")},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:()=>import("./chunk-4vhwsrc0.js")},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:()=>import("./chunk-6rhb6xym.js")},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:()=>import("./chunk-8jhmnz2v.js")},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:()=>import("./chunk-ja5m6q40.js")},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:()=>import("./chunk-wqvqvv9e.js")},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:()=>import("./chunk-7khjf5c1.js")},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:()=>import("./chunk-jsqwhbbt.js")},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:()=>import("./chunk-ewxacd5v.js")},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:()=>import("./chunk-4yddzp8e.js")},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:()=>import("./chunk-n8f65qbg.js")},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:()=>import("./chunk-63ncy5kr.js")},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:()=>import("./chunk-sd65hz9x.js")},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:()=>import("./chunk-pz4hhw24.js")},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:()=>import("./chunk-f51sey9j.js")},{id:"github-light",displayName:"GitHub Light",type:"light",import:()=>import("./chunk-q0z3nkep.js")},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:()=>import("./chunk-3009w43m.js")},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:()=>import("./chunk-vg853h8j.js")},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:()=>import("./chunk-6r5npryc.js")},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:()=>import("./chunk-9hznfyjs.js")},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:()=>import("./chunk-774cjjgt.js")},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:()=>import("./chunk-aeajq5ft.js")},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:()=>import("./chunk-pcwsyc9b.js")},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:()=>import("./chunk-hraqhe5e.js")},{id:"horizon",displayName:"Horizon",type:"dark",import:()=>import("./chunk-gvjvbwk6.js")},{id:"houston",displayName:"Houston",type:"dark",import:()=>import("./chunk-b3g51e2m.js")},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:()=>import("./chunk-denz6x2z.js")},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:()=>import("./chunk-s22hm2jp.js")},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:()=>import("./chunk-nrkhbe10.js")},{id:"laserwave",displayName:"LaserWave",type:"dark",import:()=>import("./chunk-5wkah698.js")},{id:"light-plus",displayName:"Light Plus",type:"light",import:()=>import("./chunk-rsb82wcd.js")},{id:"material-theme",displayName:"Material Theme",type:"dark",import:()=>import("./chunk-vcsqkf9c.js")},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:()=>import("./chunk-sv97fsr8.js")},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:()=>import("./chunk-9rmve4r4.js")},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:()=>import("./chunk-6dm27qn5.js")},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:()=>import("./chunk-7z7g35xf.js")},{id:"min-dark",displayName:"Min Dark",type:"dark",import:()=>import("./chunk-bjctrgpr.js")},{id:"min-light",displayName:"Min Light",type:"light",import:()=>import("./chunk-fb70a9sy.js")},{id:"monokai",displayName:"Monokai",type:"dark",import:()=>import("./chunk-tq142qfa.js")},{id:"night-owl",displayName:"Night Owl",type:"dark",import:()=>import("./chunk-hjs9ffqg.js")},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:()=>import("./chunk-bba2g9qj.js")},{id:"nord",displayName:"Nord",type:"dark",import:()=>import("./chunk-r9qyzgns.js")},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:()=>import("./chunk-j9za9ext.js")},{id:"one-light",displayName:"One Light",type:"light",import:()=>import("./chunk-nbkkf36e.js")},{id:"plastic",displayName:"Plastic",type:"dark",import:()=>import("./chunk-6fsb1bxc.js")},{id:"poimandres",displayName:"Poimandres",type:"dark",import:()=>import("./chunk-m9xdbw2j.js")},{id:"red",displayName:"Red",type:"dark",import:()=>import("./chunk-w46ermgd.js")},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:()=>import("./chunk-e8pjcdmj.js")},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:()=>import("./chunk-wm3z6khn.js")},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:()=>import("./chunk-y3c3xgca.js")},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:()=>import("./chunk-6ag9x0z1.js")},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:()=>import("./chunk-7m0c57rj.js")},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:()=>import("./chunk-jdvv96q7.js")},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:()=>import("./chunk-3b8scss4.js")},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:()=>import("./chunk-pvzfgkkq.js")},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:()=>import("./chunk-5m8gh94n.js")},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:()=>import("./chunk-xjgnj3p0.js")},{id:"vesper",displayName:"Vesper",type:"dark",import:()=>import("./chunk-mjfe9s8t.js")},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:()=>import("./chunk-wgamcpyt.js")},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:()=>import("./chunk-kqemj8nq.js")},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:()=>import("./chunk-72cdrnwv.js")}],zJ=Object.fromEntries(YW.map((Z)=>[Z.id,Z.import]));class bY extends Error{constructor(Z){super(Z);this.name="ShikiError"}}function XW(){return 2147483648}function JW(){return typeof performance<"u"?performance.now():Date.now()}var QW=(Z,Y)=>Z+(Y-Z%Y)%Y;async function $W(Z){let Y,X,J={};function Q(M){X=M,J.HEAPU8=new Uint8Array(M),J.HEAPU32=new Uint32Array(M)}function $(M,N,w){J.HEAPU8.copyWithin(M,N,N+w)}function K(M){try{return Y.grow(M-X.byteLength+65535>>>16),Q(Y.buffer),1}catch{}}function U(M){let N=J.HEAPU8.length;M=M>>>0;let w=XW();if(M>w)return!1;for(let L=1;L<=4;L*=2){let B=N*(1+0.2/L);B=Math.min(B,M+100663296);let C=Math.min(w,QW(Math.max(M,B),65536));if(K(C))return!0}return!1}let W=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function z(M,N,w=1024){let L=N+w,B=N;while(M[B]&&!(B>=L))++B;if(B-N>16&&M.buffer&&W)return W.decode(M.subarray(N,B));let C="";while(N<B){let R=M[N++];if(!(R&128)){C+=String.fromCharCode(R);continue}let D=M[N++]&63;if((R&224)===192){C+=String.fromCharCode((R&31)<<6|D);continue}let f=M[N++]&63;if((R&240)===224)R=(R&15)<<12|D<<6|f;else R=(R&7)<<18|D<<12|f<<6|M[N++]&63;if(R<65536)C+=String.fromCharCode(R);else{let V=R-65536;C+=String.fromCharCode(55296|V>>10,56320|V&1023)}}return C}function H(M,N){return M?z(J.HEAPU8,M,N):""}let G={emscripten_get_now:JW,emscripten_memcpy_big:$,emscripten_resize_heap:U,fd_write:()=>0};async function F(){let N=await Z({env:G,wasi_snapshot_preview1:G});Y=N.memory,Q(Y.buffer),Object.assign(J,N),J.UTF8ToString=H}return await F(),J}var KW=Object.defineProperty,WW=(Z,Y,X)=>(Y in Z)?KW(Z,Y,{enumerable:!0,configurable:!0,writable:!0,value:X}):Z[Y]=X,OZ=(Z,Y,X)=>WW(Z,typeof Y!=="symbol"?Y+"":Y,X),NZ=null;function UW(Z){throw new bY(Z.UTF8ToString(Z.getLastOnigError()))}class TY{constructor(Z){OZ(this,"utf16Length"),OZ(this,"utf8Length"),OZ(this,"utf16Value"),OZ(this,"utf8Value"),OZ(this,"utf16OffsetToUtf8"),OZ(this,"utf8OffsetToUtf16");let Y=Z.length,X=TY._utf8ByteLength(Z),J=X!==Y,Q=J?new Uint32Array(Y+1):null;if(J)Q[Y]=X;let $=J?new Uint32Array(X+1):null;if(J)$[X]=Y;let K=new Uint8Array(X),U=0;for(let W=0;W<Y;W++){let z=Z.charCodeAt(W),H=z,G=!1;if(z>=55296&&z<=56319){if(W+1<Y){let F=Z.charCodeAt(W+1);if(F>=56320&&F<=57343)H=(z-55296<<10)+65536|F-56320,G=!0}}if(J){if(Q[W]=U,G)Q[W+1]=U;if(H<=127)$[U+0]=W;else if(H<=2047)$[U+0]=W,$[U+1]=W;else if(H<=65535)$[U+0]=W,$[U+1]=W,$[U+2]=W;else $[U+0]=W,$[U+1]=W,$[U+2]=W,$[U+3]=W}if(H<=127)K[U++]=H;else if(H<=2047)K[U++]=192|(H&1984)>>>6,K[U++]=128|(H&63)>>>0;else if(H<=65535)K[U++]=224|(H&61440)>>>12,K[U++]=128|(H&4032)>>>6,K[U++]=128|(H&63)>>>0;else K[U++]=240|(H&1835008)>>>18,K[U++]=128|(H&258048)>>>12,K[U++]=128|(H&4032)>>>6,K[U++]=128|(H&63)>>>0;if(G)W++}this.utf16Length=Y,this.utf8Length=X,this.utf16Value=Z,this.utf8Value=K,this.utf16OffsetToUtf8=Q,this.utf8OffsetToUtf16=$}static _utf8ByteLength(Z){let Y=0;for(let X=0,J=Z.length;X<J;X++){let Q=Z.charCodeAt(X),$=Q,K=!1;if(Q>=55296&&Q<=56319){if(X+1<J){let U=Z.charCodeAt(X+1);if(U>=56320&&U<=57343)$=(Q-55296<<10)+65536|U-56320,K=!0}}if($<=127)Y+=1;else if($<=2047)Y+=2;else if($<=65535)Y+=3;else Y+=4;if(K)X++}return Y}createString(Z){let Y=Z.omalloc(this.utf8Length);return Z.HEAPU8.set(this.utf8Value,Y),Y}}var fY=class Z{constructor(Y){if(OZ(this,"id",++Z.LAST_ID),OZ(this,"_onigBinding"),OZ(this,"content"),OZ(this,"utf16Length"),OZ(this,"utf8Length"),OZ(this,"utf16OffsetToUtf8"),OZ(this,"utf8OffsetToUtf16"),OZ(this,"ptr"),!NZ)throw new bY("Must invoke loadWasm first.");this._onigBinding=NZ,this.content=Y;let X=new TY(Y);if(this.utf16Length=X.utf16Length,this.utf8Length=X.utf8Length,this.utf16OffsetToUtf8=X.utf16OffsetToUtf8,this.utf8OffsetToUtf16=X.utf8OffsetToUtf16,this.utf8Length<1e4&&!Z._sharedPtrInUse){if(!Z._sharedPtr)Z._sharedPtr=NZ.omalloc(1e4);Z._sharedPtrInUse=!0,NZ.HEAPU8.set(X.utf8Value,Z._sharedPtr),this.ptr=Z._sharedPtr}else this.ptr=X.createString(NZ)}convertUtf8OffsetToUtf16(Y){if(this.utf8OffsetToUtf16){if(Y<0)return 0;if(Y>this.utf8Length)return this.utf16Length;return this.utf8OffsetToUtf16[Y]}return Y}convertUtf16OffsetToUtf8(Y){if(this.utf16OffsetToUtf8){if(Y<0)return 0;if(Y>this.utf16Length)return this.utf8Length;return this.utf16OffsetToUtf8[Y]}return Y}dispose(){if(this.ptr===Z._sharedPtr)Z._sharedPtrInUse=!1;else this._onigBinding.ofree(this.ptr)}};OZ(fY,"LAST_ID",0);OZ(fY,"_sharedPtr",0);OZ(fY,"_sharedPtrInUse",!1);var HJ=fY;class GJ{constructor(Z){if(OZ(this,"_onigBinding"),OZ(this,"_ptr"),!NZ)throw new bY("Must invoke loadWasm first.");let Y=[],X=[];for(let K=0,U=Z.length;K<U;K++){let W=new TY(Z[K]);Y[K]=W.createString(NZ),X[K]=W.utf8Length}let J=NZ.omalloc(4*Z.length);NZ.HEAPU32.set(Y,J/4);let Q=NZ.omalloc(4*Z.length);NZ.HEAPU32.set(X,Q/4);let $=NZ.createOnigScanner(J,Q,Z.length);for(let K=0,U=Z.length;K<U;K++)NZ.ofree(Y[K]);if(NZ.ofree(Q),NZ.ofree(J),$===0)UW(NZ);this._onigBinding=NZ,this._ptr=$}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(Z,Y,X){let J=0;if(typeof X==="number")J=X;if(typeof Z==="string"){Z=new HJ(Z);let Q=this._findNextMatchSync(Z,Y,!1,J);return Z.dispose(),Q}return this._findNextMatchSync(Z,Y,!1,J)}_findNextMatchSync(Z,Y,X,J){let Q=this._onigBinding,$=Q.findNextOnigScannerMatch(this._ptr,Z.id,Z.ptr,Z.utf8Length,Z.convertUtf16OffsetToUtf8(Y),J);if($===0)return null;let K=Q.HEAPU32,U=$/4,W=K[U++],z=K[U++],H=[];for(let G=0;G<z;G++){let F=Z.convertUtf8OffsetToUtf16(K[U++]),M=Z.convertUtf8OffsetToUtf16(K[U++]);H[G]={start:F,end:M,length:M-F}}return{index:W,captureIndices:H}}}function zW(Z){return typeof Z.instantiator==="function"}function HW(Z){return typeof Z.default==="function"}function GW(Z){return typeof Z.data<"u"}function OW(Z){return typeof Response<"u"&&Z instanceof Response}function qW(Z){return typeof ArrayBuffer<"u"&&(Z instanceof ArrayBuffer||ArrayBuffer.isView(Z))||typeof Buffer<"u"&&Buffer.isBuffer?.(Z)||typeof SharedArrayBuffer<"u"&&Z instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&Z instanceof Uint32Array}var EY;function FW(Z){if(EY)return EY;async function Y(){NZ=await $W(async(X)=>{let J=Z;if(J=await J,typeof J==="function")J=await J(X);if(typeof J==="function")J=await J(X);if(zW(J))J=await J.instantiator(X);else if(HW(J))J=await J.default(X);else{if(GW(J))J=J.data;if(OW(J))if(typeof WebAssembly.instantiateStreaming==="function")J=await MW(J)(X);else J=await NW(J)(X);else if(qW(J))J=await rX(J)(X);else if(J instanceof WebAssembly.Module)J=await rX(J)(X);else if("default"in J&&J.default instanceof WebAssembly.Module)J=await rX(J.default)(X)}if("instance"in J)J=J.instance;if("exports"in J)J=J.exports;return J})}return EY=Y(),EY}function rX(Z){return(Y)=>WebAssembly.instantiate(Z,Y)}function MW(Z){return(Y)=>WebAssembly.instantiateStreaming(Z,Y)}function NW(Z){return async(Y)=>{let X=await Z.arrayBuffer();return WebAssembly.instantiate(X,Y)}}async function OJ(Z){if(Z)await FW(Z);return{createScanner(Y){return new GJ(Y.map((X)=>typeof X==="string"?X:X.source))},createString(Y){return new HJ(Y)}}}var qJ=$J({langs:UJ,themes:zJ,engine:()=>OJ(import("./chunk-v3t7hcht.js"))}),{codeToHtml:_W,codeToHast:AW,codeToTokens:oX,codeToTokensBase:wW,codeToTokensWithThemes:BW,getSingletonHighlighter:LW,getLastGrammarState:PW}=KJ(qJ,{guessEmbeddedLanguages:a6});var CZ={h1:{bold:!0,marginBottom:1,color:"#f74cc7ff"},h2:{bold:!0,marginBottom:1,color:"#326cfcff"},h3:{bold:!0,color:"#24ffedff"},h4:{bold:!0,color:"#e29418ff"},h5:{bold:!0,color:"#9fc214ff"},h6:{bold:!0,dimColor:!0,color:"#88eb2bff"},paragraph:{},blockquote:{paddingLeft:1,dimColor:!0,borderTop:!1,borderBottom:!1,borderRight:!1,borderStyle:"single",borderDimColor:!0},code:{marginTop:1},codespan:{dimColor:!0},list:{},listItem:{bullet:"●",paddingLeft:2},hr:{char:"─",width:40,dimColor:!0},link:{color:"#343afcff",underline:!0},strong:{bold:!0},em:{italic:!0},del:{strikethrough:!0,dimColor:!0},image:{color:"blue"},table:{},tableCell:{paddingRight:2}},CW=["color","backgroundColor","dimColor","bold","italic","underline","strikethrough","inverse","wrap"],IW=["paddingLeft","paddingRight","paddingTop","paddingBottom","padding","paddingX","paddingY","marginLeft","marginRight","marginTop","marginBottom","margin","marginX","marginY","borderStyle","borderColor","borderTop","borderBottom","borderLeft","borderRight","borderDimColor","borderTopColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopDimColor","borderBottomDimColor","borderLeftDimColor","borderRightDimColor"];async function vW(Z,Y,X="github-dark"){try{let J=await oX(Z,{lang:Y||"text",theme:X}),Q=[],$=0;for(let K=0;K<J.tokens.length;K++){let U=J.tokens[K];if(U){for(let W of U){let z=W.color||void 0;Q.push(E.jsx(O,{color:z,children:W.content},`token-${$}`)),$++}if(K<J.tokens.length-1)Q.push(E.jsx(O,{children:`
143
- `},`nl-${K}`))}}return Q}catch{return null}}function LZ(Z){if(!Z)return{};let Y={};for(let X of CW)if(X in Z)Y[X]=Z[X];return Y}function tZ(Z){if(!Z)return{};let Y={};for(let X of IW)if(X in Z)Y[X]=Z[X];return Y}function IZ(Z,Y){if(!Z&&!Y)return{};if(!Z)return Y;if(!Y)return Z;return{...Z,...Y}}function DW({code:Z,language:Y,style:X,theme:J}){let[Q,$]=pZ.useState(null),[K,U]=pZ.useState(!0);if(pZ.useEffect(()=>{let W=!1;async function z(){try{let H=await vW(Z,Y,J);if(!W)$(H),U(!1)}catch{if(!W)$(null),U(!1)}}return z(),()=>{W=!0}},[Z,Y,J]),K||!Q)return E.jsx(_,{...tZ(X),children:E.jsx(O,{...LZ(X),children:Z})});return E.jsx(_,{paddingX:2,paddingY:1,...tZ(X),children:E.jsx(O,{...LZ(X),children:Q})})}function jZ(Z,Y,X){if(!Z||Z.length===0)return null;return Z.map((J,Q)=>{let $=`inline-${Q}`;switch(J.type){case"text":case"escape":{let K=J;if("tokens"in K&&K.tokens)return E.jsx(O,{children:jZ(K.tokens,Y,X)},$);return E.jsx(O,{children:K.text},$)}case"strong":{let K=J,U=IZ(CZ.strong,Y.strong);if(X.strong)return E.jsx(O,{children:X.strong(jZ(K.tokens,Y,X),K)},$);return E.jsx(O,{...LZ(U),children:jZ(K.tokens,Y,X)},$)}case"em":{let K=J,U=IZ(CZ.em,Y.em);if(X.em)return E.jsx(O,{children:X.em(jZ(K.tokens,Y,X),K)},$);return E.jsx(O,{...LZ(U),children:jZ(K.tokens,Y,X)},$)}case"del":{let K=J,U=IZ(CZ.del,Y.del);if(X.del)return E.jsx(O,{children:X.del(jZ(K.tokens,Y,X),K)},$);return E.jsx(O,{...LZ(U),children:jZ(K.tokens,Y,X)},$)}case"codespan":{let K=J,U=IZ(CZ.codespan,Y.codespan);if(X.codespan)return E.jsx(O,{children:X.codespan(K.text,K)},$);return E.jsx(O,{...LZ(U),children:K.text},$)}case"link":{let K=J,U=IZ(CZ.link,Y.link);if(X.link)return E.jsx(O,{children:X.link(K.text,K.href,K.title,K)},$);return E.jsxs(O,{...LZ(U),children:[K.text,K.href&&` (${K.href})`]},$)}case"image":{let K=J,U=IZ(CZ.image,Y.image);if(X.image)return E.jsx(O,{children:X.image(K.text,K.href,K.title,K)},$);return E.jsxs(O,{...LZ(U),children:["[Image: ",K.text||K.href,"]"]},$)}case"br":return E.jsx(O,{children:`
144
- `},$);default:if("text"in J)return E.jsx(O,{children:J.text},$);return null}})}function nX(Z,Y,X,J,Q,$="github-dark"){switch(Z.type){case"heading":{let K=Z,U=`h${K.depth}`,W=`h${K.depth}`,z=X[U];if(z)return z(K.text,K);let H=IZ(CZ[W],Y[W]),G=typeof H.showSharp=="boolean"?H.showSharp:Boolean(J);return E.jsx(_,{...tZ(H),children:E.jsxs(O,{...LZ(H),children:[G&&`${"#".repeat(K.depth)} `,jZ(K.tokens,Y,X)]})})}case"paragraph":{let K=Z,U=IZ(CZ.paragraph,Y.paragraph),W=jZ(K.tokens,Y,X);if(X.paragraph)return X.paragraph(W,K);return E.jsx(_,{...tZ(U),children:E.jsx(O,{...LZ(U),children:W})})}case"code":{let K=Z,U=IZ(CZ.code,Y.code);if(X.code)return X.code(K.text,K.lang,K);if(Q)return E.jsx(DW,{code:K.text,language:K.lang,style:U,theme:$});return E.jsx(_,{...tZ(U),children:E.jsx(O,{...LZ(U),children:K.text})})}case"blockquote":{let K=Z,U=IZ(CZ.blockquote,Y.blockquote),W=K.tokens.map((z,H)=>E.jsx(_,{children:nX(z,Y,X,J,Q,$)},`bq-${H}`));if(X.blockquote)return X.blockquote(W,K);return E.jsx(_,{...tZ(U),children:E.jsx(_,{flexDirection:"column",children:K.tokens.map((z,H)=>{if(nX(z,Y,X,J,Q,$))return E.jsx(O,{...LZ(U),children:z.type==="paragraph"?jZ(z.tokens,Y,X):z.text||""},`bq-text-${H}`);return null})})})}case"list":{let K=Z,U=IZ(CZ.list,Y.list),W=IZ(CZ.listItem,Y.listItem),z=W.bullet||"●",H=K.items.map((G,F)=>{let M=typeof K.start=="number"?K.start:1,N=K.ordered?`${M+F}. `:`${z} `,w=jZ(G.tokens,Y,X);if(X.listItem)return E.jsx(_,{...tZ(W),children:X.listItem(w,G)},`li-${F}`);return E.jsx(_,{...tZ(W),children:E.jsxs(O,{...LZ(W),children:[N,w]})},`li-${F}`)});if(X.list)return X.list(H,K.ordered,K);return E.jsx(_,{flexDirection:"column",...tZ(U),children:H})}case"hr":{let K=Z,U=IZ(CZ.hr,Y.hr),W=U.char||"─",z=U.width||40;if(X.hr)return X.hr(K);return E.jsx(_,{...tZ(U),children:E.jsx(O,{...LZ(U),children:W.repeat(z)})})}case"table":{let K=Z,U=IZ(CZ.table,Y.table),W=IZ(CZ.tableCell,Y.tableCell),z=(B)=>B.map((C)=>{if("text"in C)return C.text;return""}).join(""),H=K.header.map((B,C)=>{let R=z(B.tokens).length,D=Math.max(...K.rows.map((f)=>{let V=f[C]?.tokens;return V?z(V).length:0}),0);return Math.max(R,D,3)}),G=E.jsxs(O,{dimColor:!0,children:["┌─",H.map((B)=>"─".repeat(B)).join("─┬─"),"─┐"]}),F=E.jsxs(O,{children:[E.jsx(O,{dimColor:!0,children:"│ "}),K.header.map((B,C)=>{let R=jZ(B.tokens,Y,X),D=z(B.tokens);return E.jsxs(O,{children:[E.jsxs(O,{bold:!0,...LZ(W),children:[R," ".repeat(Math.max(0,(H[C]||3)-D.length))]}),E.jsxs(O,{dimColor:!0,children:[" │",C<K.header.length-1?" ":""]})]},`th-${C}`)})]}),M=E.jsxs(O,{dimColor:!0,children:["├─",H.map((B)=>"─".repeat(B)).join("─┼─"),"─┤"]}),N=K.rows.map((B,C)=>E.jsxs(O,{children:[E.jsx(O,{dimColor:!0,children:"│ "}),B.map((R,D)=>{let f=jZ(R.tokens,Y,X),V=z(R.tokens),d=H[D]||3;return E.jsxs(O,{children:[E.jsxs(O,{...LZ(W),children:[f," ".repeat(Math.max(0,d-V.length))]}),E.jsxs(O,{dimColor:!0,children:[" │",D<B.length-1?" ":""]})]},`td-${C}-${D}`)})]},`tr-${C}`)),w=E.jsxs(O,{dimColor:!0,children:["└─",H.map((B)=>"─".repeat(B)).join("─┴─"),"─┘"]}),L=E.jsxs(E.Fragment,{children:[G,F,M,N,w]});if(X.table)return X.table(F,N,K);return E.jsx(_,{flexDirection:"column",...tZ(U),children:L})}case"space":return E.jsx(O,{children:`
145
- `});case"html":return E.jsx(O,{dimColor:!0,children:Z.text});default:if("text"in Z)return E.jsx(O,{children:Z.text});return null}}var FJ=pZ.memo(function({token:Z,styles:Y,renderers:X,showSharp:J,highlight:Q,theme:$}){return E.jsx(E.Fragment,{children:nX(Z,Y,X,J,Q,$)})},(Z,Y)=>Z.token===Y.token);FJ.displayName="MemoizedBlock";function VW({children:Z,id:Y,styles:X={},renderers:J={},showSharp:Q=!1,highlight:$=!0,theme:K="github-dark"}){let U=pZ.useId(),W=Y||U,z=pZ.useMemo(()=>c.lexer(Z,{silent:!0,gfm:!0}),[Z]);return E.jsx(_,{flexDirection:"column",children:z.map((H,G)=>E.jsx(FJ,{token:H,styles:X,renderers:J,showSharp:Q,highlight:$,theme:K},`${W}-block-${G}`))})}var MJ=pZ.memo(VW);MJ.displayName="Markdown";var EW=MJ,NJ=EW;var _J=P(g(),1);var h0=P(I(),1),AJ=({children:Z,color:Y,dim:X,bold:J,italic:Q})=>{let $=_J.useMemo(()=>{return Z.split(`
146
- `).map((K)=>K===""?`
147
- `:K)},[Z]);return h0.jsxDEV(h0.Fragment,{children:$.map((K,U)=>h0.jsxDEV(O,{color:Y,dimColor:X,bold:J,italic:Q,children:K},U,!1,void 0,this))},void 0,!1,void 0,this)};var jY=P(g(),1),aX=P(I(),1),bW=(Z,Y,X=5)=>{if(!Y||!Z||Z.trim()==="")return Z;let J=Z.split(`
148
- `);if(J.length<=X)return Z;let Q=J.length-X,$=J.slice(-X);return`\x1B[33m${Q} rows hidden...\x1B[0m
149
- ${$.join(`
150
- `)}`},TW=({children:Z,simple:Y,loading:X,maxRows:J=5})=>{let Q=jY.useMemo(()=>{return bW(Z,X,J)},[Z,X,J]);if(Y)return aX.jsxDEV(AJ,{children:Q},void 0,!1,void 0,this);return aX.jsxDEV(NJ,{children:Q},void 0,!1,void 0,this)},wJ=jY.memo(TW);var SZ=P(I(),1),fW=({message:Z,messageNumber:Y,loading:X})=>{let Q=h8(Z),$=J0(Z);if(!$)return SZ.jsxDEV(SZ.Fragment,{},void 0,!1,void 0,this);return SZ.jsxDEV(_,{flexDirection:"column",children:[SZ.jsxDEV(_,{paddingBottom:0,marginBottom:1,children:SZ.jsxDEV(O,{color:c4("teal"),children:[Y," ","Zen Code"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Q&&SZ.jsxDEV(jW,{thinking:Q,visible:$.trim().length===0},void 0,!1,void 0,this),SZ.jsxDEV(wJ,{simple:!1,loading:X,children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},jW=({thinking:Z,visible:Y})=>{let X=Z.split(`
151
- `);return SZ.jsxDEV(_,{flexDirection:"column",marginBottom:1,children:[SZ.jsxDEV(_,{paddingBottom:0,children:SZ.jsxDEV(O,{color:"gray",bold:!0,children:["Think ",X.length," rows"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Y&&SZ.jsxDEV(BJ,{content:Z,maxLines:3},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},SY=fW;var j=P(I(),1),LJ=["yellow","magenta","blue"],SW=(Z)=>{let Y=0;for(let J=0;J<Z.length;J++)Y=Z.charCodeAt(J)+((Y<<5)-Y);let X=Math.abs(Y%LJ.length);return LJ[X]},yW=(Z)=>{return{success:"✓",completed:"✓",ok:"✓",error:"✗",failed:"✗",pending:"⏳",in_progress:"⏳",running:"⏳",cancelled:"⏹"}[Z]||"⏳"},kW=(Z,Y=4,X=100)=>{let J=Z.split(`
152
- `),Q=(U)=>{if(U.length<=X)return U;return U.substring(0,X)+`... (${U.length-X} more chars)`};if(J.length<=Y)return J.map(Q).join(`
153
- `);let $=J.slice(0,2).map(Q),K=J.slice(J.length-3).map(Q);return[...$,`... and more ${J.length-5} lines`,...K].join(`
154
- `)},hW=({content:Z})=>{let Y=(X,J=0,Q=0)=>{let K=" ".repeat(J);if(Q>=3)return j.jsxDEV(O,{dimColor:!0,children:"{...} (truncated)"},void 0,!1,void 0,this);if(X===null)return j.jsxDEV(O,{color:"gray",children:"null"},void 0,!1,void 0,this);if(typeof X!=="object"){let z=JSON.stringify(X);if(typeof X==="string"&&z.length>102){let H=z.substring(1,101);return j.jsxDEV(O,{children:[j.jsxDEV(O,{color:"cyan",children:['"',H,'..."']},void 0,!0,void 0,this)," ",j.jsxDEV(O,{dimColor:!0,children:["(truncated, ",z.length-2," chars)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}if(typeof X==="string")return j.jsxDEV(O,{color:"cyan",children:z},void 0,!1,void 0,this);else if(typeof X==="number")return j.jsxDEV(O,{color:"yellow",children:X},void 0,!1,void 0,this);else if(typeof X==="boolean")return j.jsxDEV(O,{color:"magenta",children:X.toString()},void 0,!1,void 0,this);else return j.jsxDEV(O,{children:z},void 0,!1,void 0,this)}if(Array.isArray(X)){if(X.length===0)return j.jsxDEV(O,{color:"gray",children:"[]"},void 0,!1,void 0,this);let z=5;return j.jsxDEV(j.Fragment,{children:[`
155
- `,X.slice(0,z).map((H,G)=>j.jsxDEV(O,{children:[j.jsxDEV(O,{children:K},void 0,!1,void 0,this),j.jsxDEV(O,{color:"green",children:"- "},void 0,!1,void 0,this)," ",Y(H,J+1,Q+1),G<Math.min(X.length,z)-1?`
156
- `:""]},void 0,!0,void 0,this)),X.length>z&&j.jsxDEV(O,{children:[`
157
- `,j.jsxDEV(O,{children:K},void 0,!1,void 0,this),j.jsxDEV(O,{dimColor:!0,children:["... (",X.length-z," more)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}let U=Object.keys(X);if(U.length===0)return j.jsxDEV(O,{color:"gray"},void 0,!1,void 0,this);let W=5;return j.jsxDEV(j.Fragment,{children:[U.slice(0,W).map((z,H)=>j.jsxDEV(O,{children:[j.jsxDEV(O,{children:K},void 0,!1,void 0,this),j.jsxDEV(O,{color:"blue",children:z},void 0,!1,void 0,this)," ",j.jsxDEV(O,{color:"gray",children:": "},void 0,!1,void 0,this)," ",Y(X[z],J+1,Q+1),H<Math.min(U.length,W)-1?`
158
- `:""]},void 0,!0,void 0,this)),U.length>W&&j.jsxDEV(O,{children:[`
159
- `,j.jsxDEV(O,{children:K},void 0,!1,void 0,this),j.jsxDEV(O,{dimColor:!0,children:["... (",U.length-W," more)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};return j.jsxDEV(O,{children:Y(Z)},void 0,!1,void 0,this)},xW=({message:Z,messageNumber:Y})=>{let{getToolUIRender:X,client:J}=WZ(),Q=new eY(Z,J),$=Q.getInputRepaired(),K=$?.title?`: ${$.title}`:$?.description?`: ${$.description}`:"",U=Z.name?X(Z.name):null,W=SW(Z.name||"");return W=Z.status==="error"?"red":"yellow",j.jsxDEV(r,{children:j.jsxDEV(_,{flexDirection:"column",children:[j.jsxDEV(_,{children:[j.jsxDEV(O,{color:W,children:[Y," ",Z.name,j.jsxDEV(O,{color:"gray",children:K},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j.jsxDEV(O,{children:[" ",yW(Z?.status)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),U?j.jsxDEV(_,{children:[j.jsxDEV(O,{color:"gray",children:"└─ "},void 0,!1,void 0,this),j.jsxDEV(_,{flexDirection:"column",children:U(Z)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):j.jsxDEV(_,{flexDirection:"column",paddingTop:0,children:[j.jsxDEV(_,{children:[j.jsxDEV(O,{color:"gray",children:"└─ "},void 0,!1,void 0,this),j.jsxDEV(hW,{content:Q.getInputRepaired()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j.jsxDEV(_,{paddingTop:0,paddingBottom:0,children:[j.jsxDEV(O,{color:"gray",children:"└─ "},void 0,!1,void 0,this),j.jsxDEV(O,{dimColor:!0,italic:!0,children:kW(PJ(Z.content))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z.sub_messages?.length?j.jsxDEV(_,{children:[j.jsxDEV(O,{color:"gray",children:"└─ "},void 0,!1,void 0,this),j.jsxDEV(O,{color:W,dimColor:!0,children:["(hidden ",Z.sub_messages.length," subagent messages)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},RJ=xW;var f4=P(I(),1),CJ=kY.memo(function({renderMessages:Y,startIndex:X,staticKey:J,loading:Q}){let[$,K]=kY.useState(!1);TZ(()=>K(!0),$?null:0);let U=(G,F,M,N)=>f4.jsxDEV(_,{flexDirection:"column",paddingLeft:1,paddingBottom:1,children:G.type==="human"?f4.jsxDEV(e0,{content:G.content,messageNumber:F+1+X},void 0,!1,void 0,this):G.type==="tool"?f4.jsxDEV(RJ,{message:G,messageNumber:F+1+X},void 0,!1,void 0,this):f4.jsxDEV(SY,{message:G,messageNumber:F+1+X,loading:Q},void 0,!1,void 0,this)},G.id?`${N}-${G.id}`:`${N}-msg-${F}`,!1,void 0,this),W=Y.findIndex((G)=>{if(G.type==="tool"&&!G.done&&!["success","error"].includes(G.status))return!0;return!1});if(W===-1)W=Y.length-1;let z=Y.slice(0,W),H=Y.slice(W);if(!$)return f4.jsxDEV(_,{flexDirection:"column",children:Y.map((G,F)=>U(G,F,F===W,"init"))},void 0,!1,void 0,this);return f4.jsxDEV(_,{flexDirection:"column",children:[f4.jsxDEV(yY,{items:z,children:(G,F)=>U(G,F,!1,"hist")},J,!1,void 0,this),H.map((G,F)=>U(G,z.length+F,!0,"curr"))]},void 0,!0,void 0,this)});var j4=P(g(),1);var q0=P(g(),1);var hY=P(I(),1),gW=({staticKey:Z,children:Y,delay:X=1})=>{let[J,Q]=q0.useState(!0),$=q0.useRef(!0);return q0.useEffect(()=>{Q(!1),$.current=!0},[Z]),TZ(()=>{if($.current)console.clear(),Q(!0),$.current=!1},J?null:X),hY.jsxDEV(hY.Fragment,{children:J?Y():null},void 0,!1,void 0,this)},IJ=gW;var JZ=P(I(),1),uW=j4.memo(function({toolGroup:Y,groupId:X,getToolUIRender:J,depth:Q=0,loading:$}){if(Q>1)return null;return JZ.jsxDEV(_,{flexDirection:"column",children:Y.map((K,U)=>{let W=K.name?J(K.name):null;if(!W)return null;let z=K.sub_messages?.length||0,H=K.sub_messages?.slice(-4)||[],G=z-H.length;return JZ.jsxDEV(j4.Fragment,{children:[JZ.jsxDEV(()=>{return JZ.jsxDEV(r,{fallback:K.name+" is error",children:W(K)},void 0,!1,void 0,this)},{},void 0,!1,void 0,this),H.length?JZ.jsxDEV(JZ.Fragment,{children:[G>0&&JZ.jsxDEV(_,{paddingLeft:2,children:JZ.jsxDEV(O,{dimColor:!0,children:["... ",G," more submessage",G>1?"s":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),JZ.jsxDEV(sX,{renderMessages:H,startIndex:1,depth:Q+1,staticKey:`sub-d${Q}-i${U}`,getToolUIRender:J,loading:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},`${X}-${U}-${K.status}`,!0,void 0,this)})},void 0,!1,void 0,this)}),vJ=j4.memo(function({message:Y,displayIndex:X,isCurrent:J,startIndex:Q=0,getToolUIRender:$,depth:K=0,loading:U}){return JZ.jsxDEV(_,{flexDirection:"column",paddingBottom:1,children:[Y.type==="human"?JZ.jsxDEV(e0,{content:Y.content,messageNumber:X+1+Q},void 0,!1,void 0,this):null,Y.type==="ai"?JZ.jsxDEV(SY,{message:Y,messageNumber:X+1+Q,loading:U},void 0,!1,void 0,this):null,Y.type==="group"&&JZ.jsxDEV(JZ.Fragment,{children:JZ.jsxDEV(uW,{toolGroup:Y.toolGroup,groupId:Y.id,getToolUIRender:$,depth:K,loading:U},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}),DJ=(Z)=>{if(Z.type!=="ai")return!0;try{let Y=J0(Z);return!!(Y&&Y.trim().length>0)}catch{return!1}},sX=j4.memo(function({renderMessages:Y,startIndex:X,staticKey:J,depth:Q=0,getToolUIRender:$,loading:K}){let U=j4.useMemo(()=>{let G=0;return Y.filter((F)=>{if(F.type==="ai")return DJ(F);return!0}).reduce((F,M)=>{if(M.type==="tool"){let N=F[F.length-1];if(N&&N.type==="group"&&N.toolGroup.length<5)N.toolGroup.push(M);else F.push({id:`tool-group-${G++}`,type:"group",toolGroup:[M]})}else F.push(M);return F},[])},[Y,DJ]),W=U.length-1;if(W===-1)W=U.length-1;if(!K)W=U.length;let z=U.slice(0,W),H=U.slice(W);return JZ.jsxDEV(_,{flexDirection:"column",children:[JZ.jsxDEV(IJ,{staticKey:`${J} ${z.length}`,children:()=>JZ.jsxDEV(yY,{items:z,children:(G,F)=>JZ.jsxDEV(vJ,{message:G,displayIndex:F,isCurrent:!1,startIndex:X,getToolUIRender:$,depth:Q,loading:K},G.id?`hist-${G.id}`:`hist-msg-${Q}-${F}`,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),H.map((G,F)=>JZ.jsxDEV(vJ,{message:G,displayIndex:z.length+F,isCurrent:!0,startIndex:X,getToolUIRender:$,depth:Q,loading:K},G.id?`curr-${G.id}`:`curr-msg-${Q}-${z.length}-${F}`,!1,void 0,this))]},void 0,!0,void 0,this)});var T=P(I(),1),mW=()=>{let Z=t0(),Y=new Date().toLocaleDateString(),{extraParams:X,AVAILABLE_MODELS:J,config:Q}=UZ(),$=X.mcp_config||{},K=Object.keys($).length,U=VJ(),W=process.platform,z=W==="darwin"?"macOS":W==="win32"?"Windows":"Linux",H=process.cwd(),G=Q?.provider_id||process.env.MODEL_PROVIDER||"openai",M=!!Q?.providers?.find((L)=>L.id===G)?.apiKey,N=J.length>0,w=M&&N;return T.jsxDEV(_,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,marginBottom:1,children:[T.jsxDEV(_,{flexDirection:"row",justifyContent:"space-between",borderBottom:!1,children:[T.jsxDEV(O,{color:"cyan",bold:!0,children:"ZEN CODE"},void 0,!1,void 0,this),T.jsxDEV(O,{color:"gray",children:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T.jsxDEV(_,{flexDirection:"row",marginTop:1,gap:2,children:[T.jsxDEV(_,{flexDirection:"column",children:T.jsxDEV(O,{color:"cyan",children:`███████╗███████╗███╗ ██╗
126
+ `}tablerow({text:$}){return`<tr>
127
+ ${$}</tr>
128
+ `}tablecell($){let Z=this.parser.parseInline($.tokens),Y=$.header?"th":"td";return($.align?`<${Y} align="${$.align}">`:`<${Y}>`)+Z+`</${Y}>
129
+ `}strong({tokens:$}){return`<strong>${this.parser.parseInline($)}</strong>`}em({tokens:$}){return`<em>${this.parser.parseInline($)}</em>`}codespan({text:$}){return`<code>${e1($,!0)}</code>`}br($){return"<br>"}del({tokens:$}){return`<del>${this.parser.parseInline($)}</del>`}link({href:$,title:Z,tokens:Y}){let J=this.parser.parseInline(Y),X=n4($);if(X===null)return J;$=X;let K='<a href="'+$+'"';return Z&&(K+=' title="'+e1(Z)+'"'),K+=">"+J+"</a>",K}image({href:$,title:Z,text:Y,tokens:J}){J&&(Y=this.parser.parseInline(J,this.parser.textRenderer));let X=n4($);if(X===null)return e1(Y);$=X;let K=`<img src="${$}" alt="${Y}"`;return Z&&(K+=` title="${e1(Z)}"`),K+=">",K}text($){return"tokens"in $&&$.tokens?this.parser.parseInline($.tokens):("escaped"in $)&&$.escaped?$.text:e1($.text)}},H6=class{strong({text:$}){return $}em({text:$}){return $}codespan({text:$}){return $}del({text:$}){return $}html({text:$}){return $}text({text:$}){return $}link({text:$}){return""+$}image({text:$}){return""+$}br(){return""}},c1=class ${options;renderer;textRenderer;constructor(Z){this.options=Z||T0,this.options.renderer=this.options.renderer||new B$,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new H6}static parse(Z,Y){return new $(Y).parse(Z)}static parseInline(Z,Y){return new $(Y).parseInline(Z)}parse(Z,Y=!0){let J="";for(let X=0;X<Z.length;X++){let K=Z[X];if(this.options.extensions?.renderers?.[K.type]){let W=K,_=this.options.extensions.renderers[W.type].call({parser:this},W);if(_!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(W.type)){J+=_||"";continue}}let Q=K;switch(Q.type){case"space":{J+=this.renderer.space(Q);continue}case"hr":{J+=this.renderer.hr(Q);continue}case"heading":{J+=this.renderer.heading(Q);continue}case"code":{J+=this.renderer.code(Q);continue}case"table":{J+=this.renderer.table(Q);continue}case"blockquote":{J+=this.renderer.blockquote(Q);continue}case"list":{J+=this.renderer.list(Q);continue}case"html":{J+=this.renderer.html(Q);continue}case"def":{J+=this.renderer.def(Q);continue}case"paragraph":{J+=this.renderer.paragraph(Q);continue}case"text":{let W=Q,_=this.renderer.text(W);for(;X+1<Z.length&&Z[X+1].type==="text";)W=Z[++X],_+=`
130
+ `+this.renderer.text(W);Y?J+=this.renderer.paragraph({type:"paragraph",raw:_,text:_,tokens:[{type:"text",raw:_,text:_,escaped:!0}]}):J+=_;continue}default:{let W='Token with "'+Q.type+'" type was not found.';if(this.options.silent)return console.error(W),"";throw Error(W)}}}return J}parseInline(Z,Y=this.renderer){let J="";for(let X=0;X<Z.length;X++){let K=Z[X];if(this.options.extensions?.renderers?.[K.type]){let W=this.options.extensions.renderers[K.type].call({parser:this},K);if(W!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(K.type)){J+=W||"";continue}}let Q=K;switch(Q.type){case"escape":{J+=Y.text(Q);break}case"html":{J+=Y.html(Q);break}case"link":{J+=Y.link(Q);break}case"image":{J+=Y.image(Q);break}case"strong":{J+=Y.strong(Q);break}case"em":{J+=Y.em(Q);break}case"codespan":{J+=Y.codespan(Q);break}case"br":{J+=Y.br(Q);break}case"del":{J+=Y.del(Q);break}case"text":{J+=Y.text(Q);break}default:{let W='Token with "'+Q.type+'" type was not found.';if(this.options.silent)return console.error(W),"";throw Error(W)}}}return J}},Y$=class{options;block;constructor($){this.options=$||T0}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess($){return $}postprocess($){return $}processAllTokens($){return $}emStrongMask($){return $}provideLexer(){return this.block?m1.lex:m1.lexInline}provideParser(){return this.block?c1.parse:c1.parseInline}},uY=class{defaults=Q6();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=c1;Renderer=B$;TextRenderer=H6;Lexer=m1;Tokenizer=b$;Hooks=Y$;constructor(...$){this.use(...$)}walkTokens($,Z){let Y=[];for(let J of $)switch(Y=Y.concat(Z.call(this,J)),J.type){case"table":{let X=J;for(let K of X.header)Y=Y.concat(this.walkTokens(K.tokens,Z));for(let K of X.rows)for(let Q of K)Y=Y.concat(this.walkTokens(Q.tokens,Z));break}case"list":{let X=J;Y=Y.concat(this.walkTokens(X.items,Z));break}default:{let X=J;this.defaults.extensions?.childTokens?.[X.type]?this.defaults.extensions.childTokens[X.type].forEach((K)=>{let Q=X[K].flat(1/0);Y=Y.concat(this.walkTokens(Q,Z))}):X.tokens&&(Y=Y.concat(this.walkTokens(X.tokens,Z)))}}return Y}use(...$){let Z=this.defaults.extensions||{renderers:{},childTokens:{}};return $.forEach((Y)=>{let J={...Y};if(J.async=this.defaults.async||J.async||!1,Y.extensions&&(Y.extensions.forEach((X)=>{if(!X.name)throw Error("extension name required");if("renderer"in X){let K=Z.renderers[X.name];K?Z.renderers[X.name]=function(...Q){let W=X.renderer.apply(this,Q);return W===!1&&(W=K.apply(this,Q)),W}:Z.renderers[X.name]=X.renderer}if("tokenizer"in X){if(!X.level||X.level!=="block"&&X.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let K=Z[X.level];K?K.unshift(X.tokenizer):Z[X.level]=[X.tokenizer],X.start&&(X.level==="block"?Z.startBlock?Z.startBlock.push(X.start):Z.startBlock=[X.start]:X.level==="inline"&&(Z.startInline?Z.startInline.push(X.start):Z.startInline=[X.start]))}"childTokens"in X&&X.childTokens&&(Z.childTokens[X.name]=X.childTokens)}),J.extensions=Z),Y.renderer){let X=this.defaults.renderer||new B$(this.defaults);for(let K in Y.renderer){if(!(K in X))throw Error(`renderer '${K}' does not exist`);if(["options","parser"].includes(K))continue;let Q=K,W=Y.renderer[Q],_=X[Q];X[Q]=(...O)=>{let N=W.apply(X,O);return N===!1&&(N=_.apply(X,O)),N||""}}J.renderer=X}if(Y.tokenizer){let X=this.defaults.tokenizer||new b$(this.defaults);for(let K in Y.tokenizer){if(!(K in X))throw Error(`tokenizer '${K}' does not exist`);if(["options","rules","lexer"].includes(K))continue;let Q=K,W=Y.tokenizer[Q],_=X[Q];X[Q]=(...O)=>{let N=W.apply(X,O);return N===!1&&(N=_.apply(X,O)),N}}J.tokenizer=X}if(Y.hooks){let X=this.defaults.hooks||new Y$;for(let K in Y.hooks){if(!(K in X))throw Error(`hook '${K}' does not exist`);if(["options","block"].includes(K))continue;let Q=K,W=Y.hooks[Q],_=X[Q];Y$.passThroughHooks.has(K)?X[Q]=(O)=>{if(this.defaults.async&&Y$.passThroughHooksRespectAsync.has(K))return(async()=>{let U=await W.call(X,O);return _.call(X,U)})();let N=W.call(X,O);return _.call(X,N)}:X[Q]=(...O)=>{if(this.defaults.async)return(async()=>{let U=await W.apply(X,O);return U===!1&&(U=await _.apply(X,O)),U})();let N=W.apply(X,O);return N===!1&&(N=_.apply(X,O)),N}}J.hooks=X}if(Y.walkTokens){let X=this.defaults.walkTokens,K=Y.walkTokens;J.walkTokens=function(Q){let W=[];return W.push(K.call(this,Q)),X&&(W=W.concat(X.call(this,Q))),W}}this.defaults={...this.defaults,...J}}),this}setOptions($){return this.defaults={...this.defaults,...$},this}lexer($,Z){return m1.lex($,Z??this.defaults)}parser($,Z){return c1.parse($,Z??this.defaults)}parseMarkdown($){return(Z,Y)=>{let J={...Y},X={...this.defaults,...J},K=this.onError(!!X.silent,!!X.async);if(this.defaults.async===!0&&J.async===!1)return K(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof Z>"u"||Z===null)return K(Error("marked(): input parameter is undefined or null"));if(typeof Z!="string")return K(Error("marked(): input parameter is of type "+Object.prototype.toString.call(Z)+", string expected"));if(X.hooks&&(X.hooks.options=X,X.hooks.block=$),X.async)return(async()=>{let Q=X.hooks?await X.hooks.preprocess(Z):Z,W=await(X.hooks?await X.hooks.provideLexer():$?m1.lex:m1.lexInline)(Q,X),_=X.hooks?await X.hooks.processAllTokens(W):W;X.walkTokens&&await Promise.all(this.walkTokens(_,X.walkTokens));let O=await(X.hooks?await X.hooks.provideParser():$?c1.parse:c1.parseInline)(_,X);return X.hooks?await X.hooks.postprocess(O):O})().catch(K);try{X.hooks&&(Z=X.hooks.preprocess(Z));let Q=(X.hooks?X.hooks.provideLexer():$?m1.lex:m1.lexInline)(Z,X);X.hooks&&(Q=X.hooks.processAllTokens(Q)),X.walkTokens&&this.walkTokens(Q,X.walkTokens);let W=(X.hooks?X.hooks.provideParser():$?c1.parse:c1.parseInline)(Q,X);return X.hooks&&(W=X.hooks.postprocess(W)),W}catch(Q){return K(Q)}}}onError($,Z){return(Y)=>{if(Y.message+=`
131
+ Please report this to https://github.com/markedjs/marked.`,$){let J="<p>An error occurred:</p><pre>"+e1(Y.message+"",!0)+"</pre>";return Z?Promise.resolve(J):J}if(Z)return Promise.reject(Y);throw Y}}},y0=new uY;function p($,Z){return y0.parse($,Z)}p.options=p.setOptions=function($){return y0.setOptions($),p.defaults=y0.defaults,t4(p.defaults),p};p.getDefaults=Q6;p.defaults=T0;p.use=function(...$){return y0.use(...$),p.defaults=y0.defaults,t4(p.defaults),p};p.walkTokens=function($,Z){return y0.walkTokens($,Z)};p.parseInline=y0.parseInline;p.Parser=c1;p.parser=c1.parse;p.Renderer=B$;p.TextRenderer=H6;p.Lexer=m1;p.lexer=m1.lex;p.Tokenizer=b$;p.Hooks=Y$;p.parse=p;var{options:fQ,setOptions:CQ,use:vQ,walkTokens:SQ,parseInline:IQ}=p;var kQ=c1.parse,yQ=m1.lex;var D0=A(D(),1),H1={h1:{bold:!0,marginBottom:1,color:"#f74cc7ff"},h2:{bold:!0,marginBottom:1,color:"#326cfcff"},h3:{bold:!0,color:"#24ffedff"},h4:{bold:!0,color:"#e29418ff"},h5:{bold:!0,color:"#9fc214ff"},h6:{bold:!0,dimColor:!0,color:"#88eb2bff"},paragraph:{},blockquote:{paddingLeft:1,dimColor:!0,borderTop:!1,borderBottom:!1,borderRight:!1,borderStyle:"single",borderDimColor:!0},code:{marginTop:1,paddingX:2},codespan:{dimColor:!0},list:{},listItem:{bullet:"●",paddingLeft:2},hr:{char:"─",width:40,dimColor:!0},link:{color:"#343afcff",underline:!0},strong:{bold:!0},em:{italic:!0},del:{strikethrough:!0,dimColor:!0},image:{color:"blue"},table:{},tableCell:{paddingRight:2}},dY=["color","backgroundColor","dimColor","bold","italic","underline","strikethrough","inverse","wrap"],lY=["paddingLeft","paddingRight","paddingTop","paddingBottom","padding","paddingX","paddingY","marginLeft","marginRight","marginTop","marginBottom","margin","marginX","marginY","borderStyle","borderColor","borderTop","borderBottom","borderLeft","borderRight","borderDimColor","borderTopColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopDimColor","borderBottomDimColor","borderLeftDimColor","borderRightDimColor"];function R1($){if(!$)return{};let Z={};for(let Y of dY)if(Y in $)Z[Y]=$[Y];return Z}function _0($){if(!$)return{};let Z={};for(let Y of lY)if(Y in $)Z[Y]=$[Y];return Z}function F1($,Z){if(!$&&!Z)return{};if(!$)return Z;if(!Z)return $;return{...$,...Z}}function f1($,Z,Y){if(!$||$.length===0)return null;return $.map((J,X)=>{let K=`inline-${X}`;switch(J.type){case"text":case"escape":{let Q=J;if("tokens"in Q&&Q.tokens)return B.jsx(G,{children:f1(Q.tokens,Z,Y)},K);return B.jsx(G,{children:Q.text},K)}case"strong":{let Q=J,W=F1(H1.strong,Z.strong);if(Y.strong)return B.jsx(G,{children:Y.strong(f1(Q.tokens,Z,Y),Q)},K);return B.jsx(G,{...R1(W),children:f1(Q.tokens,Z,Y)},K)}case"em":{let Q=J,W=F1(H1.em,Z.em);if(Y.em)return B.jsx(G,{children:Y.em(f1(Q.tokens,Z,Y),Q)},K);return B.jsx(G,{...R1(W),children:f1(Q.tokens,Z,Y)},K)}case"del":{let Q=J,W=F1(H1.del,Z.del);if(Y.del)return B.jsx(G,{children:Y.del(f1(Q.tokens,Z,Y),Q)},K);return B.jsx(G,{...R1(W),children:f1(Q.tokens,Z,Y)},K)}case"codespan":{let Q=J,W=F1(H1.codespan,Z.codespan);if(Y.codespan)return B.jsx(G,{children:Y.codespan(Q.text,Q)},K);return B.jsx(G,{...R1(W),children:Q.text},K)}case"link":{let Q=J,W=F1(H1.link,Z.link);if(Y.link)return B.jsx(G,{children:Y.link(Q.text,Q.href,Q.title,Q)},K);return B.jsxs(G,{...R1(W),children:[Q.text,Q.href&&` (${Q.href})`]},K)}case"image":{let Q=J,W=F1(H1.image,Z.image);if(Y.image)return B.jsx(G,{children:Y.image(Q.text,Q.href,Q.title,Q)},K);return B.jsxs(G,{...R1(W),children:["[Image: ",Q.text||Q.href,"]"]},K)}case"br":return B.jsx(G,{children:`
132
+ `},K);default:if("text"in J)return B.jsx(G,{children:J.text},K);return null}})}function G3($,Z,Y,J){switch($.type){case"heading":{let X=$,K=`h${X.depth}`,Q=`h${X.depth}`,W=Y[K];if(W)return W(X.text,X);let _=F1(H1[Q],Z[Q]),O=typeof _.showSharp=="boolean"?_.showSharp:Boolean(J);return B.jsx(z,{..._0(_),children:B.jsxs(G,{...R1(_),children:[O&&`${"#".repeat(X.depth)} `,f1(X.tokens,Z,Y)]})})}case"paragraph":{let X=$,K=F1(H1.paragraph,Z.paragraph),Q=f1(X.tokens,Z,Y);if(Y.paragraph)return Y.paragraph(Q,X);return B.jsx(z,{..._0(K),children:B.jsx(G,{...R1(K),children:Q})})}case"code":{let X=$,K=F1(H1.code,Z.code);if(Y.code)return Y.code(X.text,X.lang,X);return B.jsx(z,{..._0(K),children:B.jsx(G,{...R1(K),children:X.text})})}case"blockquote":{let X=$,K=F1(H1.blockquote,Z.blockquote);if(Y.blockquote){let Q=X.tokens.map((W,_)=>B.jsx(z,{children:G3(W,Z,Y,J)},`bq-${_}`));return Y.blockquote(Q,X)}return B.jsx(z,{..._0(K),children:B.jsx(z,{flexDirection:"column",children:X.tokens.map((Q,W)=>B.jsx(G,{...R1(K),children:Q.type==="paragraph"?f1(Q.tokens,Z,Y):Q.text||""},`bq-text-${W}`))})})}case"list":{let X=$,K=F1(H1.list,Z.list),Q=F1(H1.listItem,Z.listItem),W=Q.bullet||"●",_=X.items.map((O,N)=>{let U=typeof X.start=="number"?X.start:1,F=X.ordered?`${U+N}. `:`${W} `,L=f1(O.tokens,Z,Y);if(Y.listItem)return B.jsx(z,{..._0(Q),children:Y.listItem(L,O)},`li-${N}`);return B.jsx(z,{..._0(Q),children:B.jsxs(G,{...R1(Q),children:[F,L]})},`li-${N}`)});if(Y.list)return Y.list(_,X.ordered,X);return B.jsx(z,{flexDirection:"column",..._0(K),children:_})}case"hr":{let X=$,K=F1(H1.hr,Z.hr),Q=K.char||"─",W=K.width||40;if(Y.hr)return Y.hr(X);return B.jsx(z,{..._0(K),children:B.jsx(G,{...R1(K),children:Q.repeat(W)})})}case"table":{let X=$,K=F1(H1.table,Z.table),Q=F1(H1.tableCell,Z.tableCell),W=(w)=>w.map((R)=>{if("text"in R)return R.text;return""}).join(""),_=X.header.map((w,R)=>{let P=W(w.tokens).length,S=Math.max(...X.rows.map((u)=>{let m=u[R]?.tokens;return m?W(m).length:0}),0);return Math.max(P,S,3)}),O=B.jsxs(G,{dimColor:!0,children:["┌─",_.map((w)=>"─".repeat(w)).join("─┬─"),"─┐"]}),N=B.jsxs(G,{children:[B.jsx(G,{dimColor:!0,children:"│ "}),X.header.map((w,R)=>{let P=f1(w.tokens,Z,Y),S=W(w.tokens);return B.jsxs(G,{children:[B.jsxs(G,{bold:!0,...R1(Q),children:[P," ".repeat(Math.max(0,(_[R]||3)-S.length))]}),B.jsxs(G,{dimColor:!0,children:[" ","│",R<X.header.length-1?" ":""]})]},`th-${R}`)})]}),U=B.jsxs(G,{dimColor:!0,children:["├─",_.map((w)=>"─".repeat(w)).join("─┼─"),"─┤"]}),F=X.rows.map((w,R)=>B.jsxs(G,{children:[B.jsx(G,{dimColor:!0,children:"│ "}),w.map((P,S)=>{let u=f1(P.tokens,Z,Y),m=W(P.tokens),e=_[S]||3;return B.jsxs(G,{children:[B.jsxs(G,{...R1(Q),children:[u," ".repeat(Math.max(0,e-m.length))]}),B.jsxs(G,{dimColor:!0,children:[" │",S<w.length-1?" ":""]})]},`td-${R}-${S}`)})]},`tr-${R}`)),L=B.jsxs(G,{dimColor:!0,children:["└─",_.map((w)=>"─".repeat(w)).join("─┴─"),"─┘"]}),q=B.jsxs(B.Fragment,{children:[O,N,U,F,L]});if(Y.table)return Y.table(N,F,X);return B.jsx(z,{flexDirection:"column",..._0(K),children:q})}case"space":return B.jsx(G,{children:`
133
+ `});case"html":return B.jsx(G,{dimColor:!0,children:$.text});default:if("text"in $)return B.jsx(G,{children:$.text});return null}}var O3=D0.memo(function({token:$,styles:Z,renderers:Y,showSharp:J}){return B.jsx(B.Fragment,{children:G3($,Z,Y,J)})},($,Z)=>$.token===Z.token);O3.displayName="MemoizedBlock";function iY({children:$,id:Z,styles:Y={},renderers:J={},showSharp:X=!1}){let K=D0.useId(),Q=Z||K,W=D0.useMemo(()=>p.lexer($,{silent:!0,gfm:!0}),[$]);return B.jsx(z,{flexDirection:"column",children:W.map((_,O)=>B.jsx(O3,{token:_,styles:Y,renderers:J,showSharp:X},`${Q}-block-${O}`))})}var U3=D0.memo(iY);U3.displayName="Markdown";var oY=U3,N3=oY;var z3=A(D(),1);var K$=A(M(),1),H3=({children:$,color:Z,dim:Y,bold:J,italic:X})=>{let K=z3.useMemo(()=>{return $.split(`
134
+ `).map((Q)=>Q===""?`
135
+ `:Q)},[$]);return K$.jsxDEV(K$.Fragment,{children:K.map((Q,W)=>K$.jsxDEV(G,{color:Z,dimColor:Y,bold:J,italic:X,children:Q},W,!1,void 0,this))},void 0,!1,void 0,this)};var C$=A(D(),1),F6=A(M(),1),rY=($,Z,Y=5)=>{if(!Z||!$||$.trim()==="")return $;let J=$.split(`
136
+ `);if(J.length<=Y)return $;let X=J.length-Y,K=J.slice(-Y);return`\x1B[33m${X} rows hidden...\x1B[0m
137
+ ${K.join(`
138
+ `)}`},nY=({children:$,simple:Z,loading:Y,maxRows:J=5})=>{let X=C$.useMemo(()=>{return rY($,Y,J)},[$,Y,J]);if(Z)return F6.jsxDEV(H3,{children:X},void 0,!1,void 0,this);return F6.jsxDEV(N3,{children:X},void 0,!1,void 0,this)},F3=C$.memo(nY);var C1=A(M(),1),aY=({message:$,messageNumber:Z,loading:Y})=>{let X=_4($),K=g0($);if(!K)return C1.jsxDEV(C1.Fragment,{},void 0,!1,void 0,this);return C1.jsxDEV(z,{flexDirection:"column",children:[C1.jsxDEV(z,{paddingBottom:0,marginBottom:1,children:C1.jsxDEV(G,{color:S0("teal"),children:[Z," ","Zen Code"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),X&&C1.jsxDEV(sY,{thinking:X,visible:K.trim().length===0},void 0,!1,void 0,this),C1.jsxDEV(F3,{simple:!1,loading:Y,children:K},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},sY=({thinking:$,visible:Z})=>{let Y=$.split(`
139
+ `);return C1.jsxDEV(z,{flexDirection:"column",marginBottom:1,children:[C1.jsxDEV(z,{paddingBottom:0,children:C1.jsxDEV(G,{color:"gray",bold:!0,children:["Think ",Y.length," rows"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Z&&C1.jsxDEV(L3,{content:$,maxLines:3},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},v$=aY;var q3=A(D(),1);var C=A(M(),1),A3=["yellow","magenta","blue"],tY=($)=>{let Z=0;for(let J=0;J<$.length;J++)Z=$.charCodeAt(J)+((Z<<5)-Z);let Y=Math.abs(Z%A3.length);return A3[Y]},eY=($)=>{return{success:"✓",completed:"✓",ok:"✓",error:"✗",failed:"✗",pending:"⏳",in_progress:"⏳",running:"⏳",cancelled:"⏹"}[$]||"⏳"},$5=($,Z=4,Y=100)=>{let J=$.split(`
140
+ `),X=(W)=>{if(W.length<=Y)return W;return W.substring(0,Y)+`... (${W.length-Y} more chars)`};if(J.length<=Z)return J.map(X).join(`
141
+ `);let K=J.slice(0,2).map(X),Q=J.slice(J.length-3).map(X);return[...K,`... and more ${J.length-5} lines`,...Q].join(`
142
+ `)},Z5=({content:$})=>{let Z=(Y,J=0,X=0)=>{let Q=" ".repeat(J);if(X>=3)return C.jsxDEV(G,{dimColor:!0,children:"{...} (truncated)"},void 0,!1,void 0,this);if(Y===null)return C.jsxDEV(G,{color:"gray",children:"null"},void 0,!1,void 0,this);if(typeof Y!=="object"){let O=JSON.stringify(Y);if(typeof Y==="string"&&O.length>102){let N=O.substring(1,101);return C.jsxDEV(G,{children:[C.jsxDEV(G,{color:"cyan",children:['"',N,'..."']},void 0,!0,void 0,this)," ",C.jsxDEV(G,{dimColor:!0,children:["(truncated, ",O.length-2," chars)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}if(typeof Y==="string")return C.jsxDEV(G,{color:"cyan",children:O},void 0,!1,void 0,this);else if(typeof Y==="number")return C.jsxDEV(G,{color:"yellow",children:Y},void 0,!1,void 0,this);else if(typeof Y==="boolean")return C.jsxDEV(G,{color:"magenta",children:Y.toString()},void 0,!1,void 0,this);else return C.jsxDEV(G,{children:O},void 0,!1,void 0,this)}if(Array.isArray(Y)){if(Y.length===0)return C.jsxDEV(G,{color:"gray",children:"[]"},void 0,!1,void 0,this);let O=5;return C.jsxDEV(C.Fragment,{children:[`
143
+ `,Y.slice(0,O).map((N,U)=>C.jsxDEV(G,{children:[C.jsxDEV(G,{children:Q},void 0,!1,void 0,this),C.jsxDEV(G,{color:"green",children:"- "},void 0,!1,void 0,this)," ",Z(N,J+1,X+1),U<Math.min(Y.length,O)-1?`
144
+ `:""]},void 0,!0,void 0,this)),Y.length>O&&C.jsxDEV(G,{children:[`
145
+ `,C.jsxDEV(G,{children:Q},void 0,!1,void 0,this),C.jsxDEV(G,{dimColor:!0,children:["... (",Y.length-O," more)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}let W=Object.keys(Y);if(W.length===0)return C.jsxDEV(G,{color:"gray"},void 0,!1,void 0,this);let _=5;return C.jsxDEV(C.Fragment,{children:[W.slice(0,_).map((O,N)=>C.jsxDEV(G,{children:[C.jsxDEV(G,{children:Q},void 0,!1,void 0,this),C.jsxDEV(G,{color:"blue",children:O},void 0,!1,void 0,this)," ",C.jsxDEV(G,{color:"gray",children:": "},void 0,!1,void 0,this)," ",Z(Y[O],J+1,X+1),N<Math.min(W.length,_)-1?`
146
+ `:""]},void 0,!0,void 0,this)),W.length>_&&C.jsxDEV(G,{children:[`
147
+ `,C.jsxDEV(G,{children:Q},void 0,!1,void 0,this),C.jsxDEV(G,{dimColor:!0,children:["... (",W.length-_," more)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};return C.jsxDEV(G,{children:Z($)},void 0,!1,void 0,this)},Y5=({message:$,messageNumber:Z})=>{let{getToolUIRender:Y,client:J}=Z1(),X=new a$($,J),K=X.getInputRepaired(),Q=K?.title?`: ${K.title}`:K?.description?`: ${K.description}`:"",W=$.name?Y($.name):null,_=tY($.name||"");return _=$.status==="error"?"red":"yellow",q3.default.useEffect(()=>{if($.status==="error"&&$.name)import("./chunk-ns6tjjkq.js").then(({logToolError:O,logTerminalError:N,logAgentError:U})=>{let F=L6($.content),L=typeof F==="string"?F:JSON.stringify(F);if($.name==="terminal"){let q=K?.command||"unknown";N(q,L)}else if($.name.startsWith("Agent:"))U($.name,L);else O($.name,L)}).catch((O)=>{console.warn("Failed to log error:",O)})},[$.status,$.name,$.content,K?.command]),C.jsxDEV(g,{children:C.jsxDEV(z,{flexDirection:"column",children:[C.jsxDEV(z,{children:[C.jsxDEV(G,{color:_,children:[Z," ",$.name,C.jsxDEV(G,{color:"gray",children:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C.jsxDEV(G,{children:[" ",eY($?.status)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W?C.jsxDEV(z,{children:[C.jsxDEV(G,{color:"gray",children:"└─ "},void 0,!1,void 0,this),C.jsxDEV(z,{flexDirection:"column",children:W($)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):C.jsxDEV(z,{flexDirection:"column",paddingTop:0,children:[C.jsxDEV(z,{children:[C.jsxDEV(G,{color:"gray",children:"└─ "},void 0,!1,void 0,this),C.jsxDEV(Z5,{content:X.getInputRepaired()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C.jsxDEV(z,{paddingTop:0,paddingBottom:0,children:[C.jsxDEV(G,{color:"gray",children:"└─ "},void 0,!1,void 0,this),C.jsxDEV(G,{dimColor:!0,italic:!0,children:$5(L6($.content))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),$.sub_messages?.length?C.jsxDEV(z,{children:[C.jsxDEV(G,{color:"gray",children:"└─ "},void 0,!1,void 0,this),C.jsxDEV(G,{color:_,dimColor:!0,children:["(hidden ",$.sub_messages.length," subagent messages)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},w3=Y5;var w0=A(M(),1),M3=I$.memo(function({renderMessages:Z,startIndex:Y,staticKey:J,loading:X}){let[K,Q]=I$.useState(!1);B1(()=>Q(!0),K?null:0);let W=(U,F,L,q)=>w0.jsxDEV(z,{flexDirection:"column",paddingLeft:1,paddingBottom:1,children:U.type==="human"?w0.jsxDEV(w$,{content:U.content,messageNumber:F+1+Y},void 0,!1,void 0,this):U.type==="tool"?w0.jsxDEV(w3,{message:U,messageNumber:F+1+Y},void 0,!1,void 0,this):w0.jsxDEV(v$,{message:U,messageNumber:F+1+Y,loading:X},void 0,!1,void 0,this)},U.id?`${q}-${U.id}`:`${q}-msg-${F}`,!1,void 0,this),_=Z.findIndex((U)=>{if(U.type==="tool"&&!U.done&&!["success","error"].includes(U.status))return!0;return!1});if(_===-1)_=Z.length-1;let O=Z.slice(0,_),N=Z.slice(_);if(!K)return w0.jsxDEV(z,{flexDirection:"column",children:Z.map((U,F)=>W(U,F,F===_,"init"))},void 0,!1,void 0,this);return w0.jsxDEV(z,{flexDirection:"column",children:[w0.jsxDEV(S$,{items:O,children:(U,F)=>W(U,F,!1,"hist")},J,!1,void 0,this),N.map((U,F)=>W(U,O.length+F,!0,"curr"))]},void 0,!0,void 0,this)});var M0=A(D(),1);var i0=A(D(),1);var k$=A(M(),1),X5=({staticKey:$,children:Z,delay:Y=1})=>{let[J,X]=i0.useState(!0),K=i0.useRef(!0);return i0.useEffect(()=>{X(!1),K.current=!0},[$]),B1(()=>{if(K.current)X(!0),K.current=!1},J?null:Y),k$.jsxDEV(k$.Fragment,{children:J?Z():null},void 0,!1,void 0,this)},R3=X5;var a=A(M(),1),J5=M0.memo(function({toolGroup:Z,groupId:Y,getToolUIRender:J,depth:X=0,loading:K}){if(X>1)return null;return a.jsxDEV(z,{flexDirection:"column",children:Z.map((Q,W)=>{let _=Q.name?J(Q.name):null;if(!_)return null;let O=Q.sub_messages?.length||0,N=Q.sub_messages?.slice(-4)||[],U=O-N.length;return a.jsxDEV(M0.Fragment,{children:[a.jsxDEV(()=>{return a.jsxDEV(g,{fallback:Q.name+" is error",children:_(Q)},void 0,!1,void 0,this)},{},void 0,!1,void 0,this),N.length?a.jsxDEV(a.Fragment,{children:[U>0&&a.jsxDEV(z,{paddingLeft:2,children:a.jsxDEV(G,{dimColor:!0,children:["... ",U," more submessage",U>1?"s":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),a.jsxDEV(A6,{renderMessages:N,startIndex:1,depth:X+1,staticKey:`sub-d${X}-i${W}`,getToolUIRender:J,loading:K},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},`${Y}-${W}-${Q.status}`,!0,void 0,this)})},void 0,!1,void 0,this)}),b3=M0.memo(function({message:Z,displayIndex:Y,isCurrent:J,startIndex:X=0,getToolUIRender:K,depth:Q=0,loading:W}){return a.jsxDEV(z,{flexDirection:"column",paddingBottom:1,children:[Z.type==="human"?a.jsxDEV(w$,{content:Z.content,messageNumber:Y+1+X},void 0,!1,void 0,this):null,Z.type==="ai"?a.jsxDEV(v$,{message:Z,messageNumber:Y+1+X,loading:W},void 0,!1,void 0,this):null,Z.type==="group"&&a.jsxDEV(a.Fragment,{children:a.jsxDEV(J5,{toolGroup:Z.toolGroup,groupId:Z.id,getToolUIRender:K,depth:Q,loading:W},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}),B3=($)=>{if($.type!=="ai")return!0;try{let Z=g0($);return!!(Z&&Z.trim().length>0)}catch{return!1}},A6=M0.memo(function({renderMessages:Z,startIndex:Y,staticKey:J,depth:X=0,getToolUIRender:K,loading:Q}){let W=M0.useMemo(()=>{let U=0;return Z.filter((F)=>{if(F.type==="ai")return B3(F);return!0}).reduce((F,L)=>{if(L.type==="tool"){let q=F[F.length-1];if(q&&q.type==="group"&&q.toolGroup.length<5)q.toolGroup.push(L);else F.push({id:`tool-group-${U++}`,type:"group",toolGroup:[L]})}else F.push(L);return F},[])},[Z,B3]),_=W.length-1;if(_===-1)_=W.length-1;if(!Q)_=W.length;let O=W.slice(0,_),N=W.slice(_);return a.jsxDEV(z,{flexDirection:"column",children:[a.jsxDEV(R3,{staticKey:`${J} ${O.length}`,children:()=>a.jsxDEV(S$,{items:O,children:(U,F)=>a.jsxDEV(b3,{message:U,displayIndex:F,isCurrent:!1,startIndex:Y,getToolUIRender:K,depth:X,loading:Q},U.id?`hist-${U.id}`:`hist-msg-${X}-${F}`,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),N.map((U,F)=>a.jsxDEV(b3,{message:U,displayIndex:O.length+F,isCurrent:!0,startIndex:Y,getToolUIRender:K,depth:X,loading:Q},U.id?`curr-${U.id}`:`curr-msg-${X}-${O.length}-${F}`,!1,void 0,this))]},void 0,!0,void 0,this)});var f=A(M(),1),K5=()=>{let $=q$(),Z=new Date().toLocaleDateString(),{extraParams:Y,AVAILABLE_MODELS:J,config:X}=t(),K=Y.mcp_config||{},Q=Object.keys(K).length,W=P3(),_=process.platform,O=_==="darwin"?"macOS":_==="win32"?"Windows":"Linux",N=process.cwd(),U=X?.provider_id||process.env.MODEL_PROVIDER||"openai",L=!!X?.providers?.find((R)=>R.id===U)?.apiKey,q=J.length>0,w=L&&q;return f.jsxDEV(z,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,marginBottom:1,children:[f.jsxDEV(z,{flexDirection:"row",justifyContent:"space-between",borderBottom:!1,children:[f.jsxDEV(G,{color:"cyan",bold:!0,children:"ZEN CODE"},void 0,!1,void 0,this),f.jsxDEV(G,{color:"gray",children:Z},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f.jsxDEV(z,{flexDirection:"row",marginTop:1,gap:2,children:[f.jsxDEV(z,{flexDirection:"column",children:f.jsxDEV(G,{color:"cyan",children:`███████╗███████╗███╗ ██╗
160
148
  ╚══███╔╝██╔════╝████╗ ██║
161
149
  ███╔╝ █████╗ ██╔██╗ ██║
162
150
  ███╔╝ ██╔══╝ ██║╚██╗██║
163
151
  ███████╗███████╗██║ ╚████║
164
- ╚══════╝╚══════╝╚═╝ ╚═══╝`},void 0,!1,void 0,this)},void 0,!1,void 0,this),T.jsxDEV(_,{flexDirection:"column",justifyContent:"center",flexGrow:1,children:[T.jsxDEV(_,{marginBottom:1,children:w?T.jsxDEV(O,{color:"green",bold:!0,children:[" ","[ SYSTEM ONLINE ]"]},void 0,!0,void 0,this):T.jsxDEV(O,{color:"red",bold:!0,children:[" ","[ CONFIG REQUIRED ]"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),T.jsxDEV(_,{flexDirection:"column",gap:0,children:[T.jsxDEV(_,{children:[T.jsxDEV(O,{color:"blue",children:"USER::"},void 0,!1,void 0,this),T.jsxDEV(O,{color:"white",children:Z},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T.jsxDEV(_,{children:[T.jsxDEV(O,{color:"blue",children:"ARCH::"},void 0,!1,void 0,this),T.jsxDEV(O,{color:"white",children:process.arch},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T.jsxDEV(_,{children:[T.jsxDEV(O,{color:"blue",children:"PLATFORM::"},void 0,!1,void 0,this),T.jsxDEV(O,{color:"white",children:z},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T.jsxDEV(_,{children:[T.jsxDEV(O,{color:"blue",children:"NODE::"},void 0,!1,void 0,this),T.jsxDEV(O,{color:"white",children:process.version},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T.jsxDEV(_,{children:[T.jsxDEV(O,{color:"blue",children:"TERM::"},void 0,!1,void 0,this),T.jsxDEV(O,{color:"white",children:U},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T.jsxDEV(_,{children:[T.jsxDEV(O,{color:"blue",children:[G?.toUpperCase(),"::"]},void 0,!0,void 0,this),T.jsxDEV(O,{color:N?"white":"red",children:N?X.model_id:"无可用模型"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),T.jsxDEV(_,{marginTop:1,paddingX:1,flexDirection:"column",gap:0,children:[T.jsxDEV(_,{children:T.jsxDEV(O,{color:"blue",children:"WORKING_DIR ::"},void 0,!1,void 0,this)},void 0,!1,void 0,this),T.jsxDEV(_,{children:T.jsxDEV(O,{color:"gray",children:H},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!w&&T.jsxDEV(_,{marginTop:1,paddingX:1,flexDirection:"column",gap:0,children:[T.jsxDEV(O,{color:"red",bold:!0,children:["⚠️ 需要配置 ",G==="anthropic"?"Anthropic":"OpenAI"," API:"]},void 0,!0,void 0,this),!M&&T.jsxDEV(O,{color:"yellow",children:" • 请使用 /m 进入模型配置面板"},void 0,!1,void 0,this),!N&&T.jsxDEV(O,{color:"yellow",children:" • 请确保网络连接正常以获取模型列表"},void 0,!1,void 0,this),T.jsxDEV(O,{color:"gray",children:" • 配置后使用 /m 查看可用模型"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T.jsxDEV(_,{marginTop:1,paddingTop:1,borderTop:!1,flexDirection:"row",justifyContent:"space-between",children:[T.jsxDEV(_,{gap:3,children:[T.jsxDEV(_,{children:[T.jsxDEV(O,{color:"green",children:"●"},void 0,!1,void 0,this),T.jsxDEV(O,{color:"white",dimColor:!0,children:[" ","AGENTS"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),T.jsxDEV(_,{children:[T.jsxDEV(O,{color:K>0?"green":"gray",children:"●"},void 0,!1,void 0,this),T.jsxDEV(O,{color:"white",dimColor:!0,children:[" ","MCP (",K,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),T.jsxDEV(_,{children:[w?T.jsxDEV(O,{color:"yellow",bold:!0,children:">>> WAITING_FOR_INPUT"},void 0,!1,void 0,this):T.jsxDEV(O,{color:"red",bold:!0,children:">>> CONFIGURATION_NEEDED"},void 0,!1,void 0,this),T.jsxDEV(O,{color:"yellow",dimColor:!0,children:[" ","▌"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},EJ=mW;var mY=P(g(),1);var g0=P(g(),1);class bJ{commands=new Map;aliases=new Map;register(Z){if(this.commands.set(Z.name,Z),Z.aliases)Z.aliases.forEach((Y)=>{this.aliases.set(Y,Z.name)})}getCommand(Z){let Y=this.aliases.get(Z)||Z;return this.commands.get(Y)}getAllCommands(){return Array.from(this.commands.values())}isCommand(Z){return Z.trim().startsWith("/")}parseCommand(Z){if(!this.isCommand(Z))return null;let X=Z.trim().slice(1).split(/\s+/),J=X[0],Q=X.slice(1);return{command:J,args:Q}}async executeCommand(Z,Y){let X=this.parseCommand(Z);if(!X)return{success:!1,message:"无效的命令格式"};let{command:J,args:Q}=X,$=this.getCommand(J);if(!$)return{success:!1,message:`未知命令: /${J}`};if($.requiresArgs&&Q.length===0)return{success:!1,message:`命令 /${J} 需要参数。用法: ${$.usage||`/${J} <args>`}`};if($.validateArgs&&!$.validateArgs(Q))return{success:!1,message:`命令 /${J} 参数无效。用法: ${$.usage||`/${J} <args>`}`};try{return await $.execute(Q,Y)}catch(K){return{success:!1,message:`命令执行失败: ${K instanceof Error?K.message:String(K)}`}}}getSuggestions(Z){if(!Z.startsWith("/"))return[];let Y=Z.slice(1).toLowerCase(),X=[];if(Y===""){let U=["new","history","task","agent","model","settings","mcp","knowledge","summarize","template","plan","interview","help"];for(let W of U){let z=this.commands.get(W);if(z)X.push({command:W,displayText:`/${W}`,description:z.description})}return X.slice(0,10)}let J=new Set(["history","knowledge","help","init","model","config"]),Q=[],$=[];for(let[U,W]of this.commands){let z=U.toLowerCase();if(z.startsWith(Y))Q.push({command:U,displayText:`/${U}`,description:W.description});else if(z.includes(Y))$.push({command:U,displayText:`/${U}`,description:W.description});if(W.aliases)for(let H of W.aliases){let G=H.toLowerCase();if(G.startsWith(Y))Q.push({command:U,displayText:`/${H}`,description:`${W.description} (别名)`});else if(G.includes(Y))$.push({command:U,displayText:`/${H}`,description:`${W.description} (别名)`})}}let K=(U,W)=>{let z=J.has(U.command)?1:0,H=J.has(W.command)?1:0;if(z!==H)return H-z;return U.displayText.length-W.displayText.length};return Q.sort(K),$.sort(K),X.push(...Q,...$),X.slice(0,10)}getHelp(Z){if(Z){let X=this.getCommand(Z);if(!X)return`未找到命令: /${Z}`;let J=`命令: /${X.name}
165
- `;if(J+=`描述: ${X.description}
166
- `,X.usage)J+=`用法: ${X.usage}
167
- `;if(X.aliases&&X.aliases.length>0)J+=`别名: ${X.aliases.map((Q)=>`/${Q}`).join(", ")}
168
- `;return J}let Y=`可用命令:
169
- `;for(let X of this.getAllCommands())Y+=` /${X.name} - ${X.description}
170
- `;return Y+=`
171
- 使用 /help <命令名> 获取具体命令的帮助信息`,Y}}var L4=new bJ;var TJ={name:"settings",description:"打开 Settings 面板(Model 和 Provider 配置)",aliases:["s","model","settings","m"],usage:"/settings",execute:async(Z,Y)=>{return Y.switchToSettings?.(),{success:!0,message:"打开 Settings 面板",shouldClearInput:!0}}};var pW={name:"new",description:"初始化新的对话会话",aliases:["new","n"],usage:"/new [主题]",execute:async(Z,Y)=>{let X=Z.join(" ");if(await Y.createNewChat(),X){let J=`我想开始一个关于 "${X}" 的新对话。`;return Y.sendMessage([{type:"human",content:J}]),{success:!0,message:`已创建新对话,主题: ${X}`,shouldClearInput:!0}}return{success:!0,message:"已创建新对话",shouldClearInput:!0}}},dW={name:"help",description:"显示命令帮助信息",aliases:["h","?"],usage:"/help [命令名]",execute:async(Z,Y)=>{let X=Z[0];return{success:!0,message:L4.getHelp(X),shouldClearInput:!0}}},cW={name:"task",description:"打开任务看板面板",aliases:["tasks","kanban"],usage:"/task",execute:async(Z,Y)=>{return Y.switchToTask?.(),{success:!0,message:"打开任务看板",shouldClearInput:!0}}},lW={name:"process",description:"打开进程管理器面板",aliases:["ps","proc"],usage:"/process",execute:async(Z,Y)=>{return Y.switchToProcess?.(),{success:!0,message:"打开进程管理器",shouldClearInput:!0}}},fJ=[pW,dW,cW,TJ,lW];import{readFileSync as iW,readdirSync as rW}from"fs";import{join as jJ}from"path";var x0=null;function oW(Z){let Y=Z.split(`
172
- `);if(Y[0]!=="---")return{metadata:{},content:Z};let X=Y.indexOf("---",1);if(X===-1)return{metadata:{},content:Z};let J=Y.slice(1,X),Q={};for(let K of J){let U=K.match(/^(\w+):\s*(.+)$/);if(U){let[,W,z]=U;if(W==="name")Q.name=z.trim();if(W==="description")Q.description=z.trim()}}let $=Y.slice(X+1).join(`
173
- `).trim();return{metadata:Q,content:$}}function SJ(Z,Y){let X=new Map;try{let J=rW(Z,{withFileTypes:!0});for(let Q of J){let $=jJ(Z,Q.name);if(Q.isDirectory())SJ($,Y).forEach((U)=>X.set(U.name,U));else if(Q.name.endsWith(".md"))try{let K=iW($,"utf-8"),{metadata:U,content:W}=oW(K),z=U.name||Q.name.replace(/\.md$/,"");if(!U.name)console.warn(`Template missing "name" in frontmatter: ${$}`);X.set(z,{name:z,description:U.description||"No description",content:W,path:$})}catch(K){console.warn(`Failed to read template file: ${$}`,K)}}}catch(J){if(J.code!=="ENOENT")console.warn(`Error scanning templates directory: ${Z}`,J)}return X}function yJ(){x0=null}function kJ(Z="./.claude/templates"){if(x0)return Array.from(x0.values());let Y=Z.startsWith("/")?Z:jJ(process.cwd(),Z);return x0=SJ(Y,Y),Array.from(x0.values())}var nW={name:"status",description:"显示当前聊天状态信息",aliases:["stat","info"],execute:async(Z,Y)=>{return{success:!0,message:[`当前代理: ${Y.client?.availableAssistants.find((Q)=>Q.graph_id===Y.currentAgent)?.name||"未选择"} (${Y.currentAgent||"N/A"})`,`聊天ID: ${Y.client?.currentChatId?.slice(-8)||"N/A"}`,`可用代理数: ${Y.client?.availableAssistants?.length||0}`,`模型: ${Y.extraParams?.model_id||"N/A"}`].join(`
174
- `),shouldClearInput:!0}}},aW={name:"template",description:"插入预定义的消息模板",aliases:["tpl","t"],usage:"/template <模板名>",execute:async(Z,Y)=>{let X=Z[0];if(Z.includes("--refresh"))return yJ(),{success:!0,message:"模板缓存已清除",shouldClearInput:!0};let J=kJ();if(!X){if(J.length===0)return{success:!0,message:"当前没有可用的模板。可以在 ./.claude/templates/ 目录下创建 .md 模板文件。",shouldClearInput:!0};return{success:!0,message:`可用模板:
175
- ${J.map((K)=>` - ${K.name}: ${K.description}`).join(`
152
+ ╚══════╝╚══════╝╚═╝ ╚═══╝`},void 0,!1,void 0,this)},void 0,!1,void 0,this),f.jsxDEV(z,{flexDirection:"column",justifyContent:"center",flexGrow:1,children:[f.jsxDEV(z,{marginBottom:1,children:w?f.jsxDEV(G,{color:"green",bold:!0,children:[" ","[ SYSTEM ONLINE ]"]},void 0,!0,void 0,this):f.jsxDEV(G,{color:"red",bold:!0,children:[" ","[ CONFIG REQUIRED ]"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),f.jsxDEV(z,{flexDirection:"column",gap:0,children:[f.jsxDEV(z,{children:[f.jsxDEV(G,{color:"blue",children:"USER::"},void 0,!1,void 0,this),f.jsxDEV(G,{color:"white",children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f.jsxDEV(z,{children:[f.jsxDEV(G,{color:"blue",children:"ARCH::"},void 0,!1,void 0,this),f.jsxDEV(G,{color:"white",children:process.arch},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f.jsxDEV(z,{children:[f.jsxDEV(G,{color:"blue",children:"PLATFORM::"},void 0,!1,void 0,this),f.jsxDEV(G,{color:"white",children:O},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f.jsxDEV(z,{children:[f.jsxDEV(G,{color:"blue",children:"NODE::"},void 0,!1,void 0,this),f.jsxDEV(G,{color:"white",children:process.version},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f.jsxDEV(z,{children:[f.jsxDEV(G,{color:"blue",children:"TERM::"},void 0,!1,void 0,this),f.jsxDEV(G,{color:"white",children:W},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f.jsxDEV(z,{children:[f.jsxDEV(G,{color:"blue",children:[U?.toUpperCase(),"::"]},void 0,!0,void 0,this),f.jsxDEV(G,{color:q?"white":"red",children:q?Y.model_id:"无可用模型"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),f.jsxDEV(z,{marginTop:1,paddingX:1,flexDirection:"column",gap:0,children:[f.jsxDEV(z,{children:f.jsxDEV(G,{color:"blue",children:"WORKING_DIR ::"},void 0,!1,void 0,this)},void 0,!1,void 0,this),f.jsxDEV(z,{children:f.jsxDEV(G,{color:"gray",children:N},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!w&&f.jsxDEV(z,{marginTop:1,paddingX:1,flexDirection:"column",gap:0,children:[f.jsxDEV(G,{color:"red",bold:!0,children:["⚠️ 需要配置 ",U==="anthropic"?"Anthropic":"OpenAI"," API:"]},void 0,!0,void 0,this),!L&&f.jsxDEV(G,{color:"yellow",children:" • 请使用 /m 进入模型配置面板"},void 0,!1,void 0,this),!q&&f.jsxDEV(G,{color:"yellow",children:" • 请确保网络连接正常以获取模型列表"},void 0,!1,void 0,this),f.jsxDEV(G,{color:"gray",children:" • 配置后使用 /m 查看可用模型"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f.jsxDEV(z,{marginTop:1,paddingTop:1,borderTop:!1,flexDirection:"row",justifyContent:"space-between",children:[f.jsxDEV(z,{gap:3,children:[f.jsxDEV(z,{children:[f.jsxDEV(G,{color:"green",children:"●"},void 0,!1,void 0,this),f.jsxDEV(G,{color:"white",dimColor:!0,children:[" ","AGENTS"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),f.jsxDEV(z,{children:[f.jsxDEV(G,{color:Q>0?"green":"gray",children:"●"},void 0,!1,void 0,this),f.jsxDEV(G,{color:"white",dimColor:!0,children:[" ","MCP (",Q,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),f.jsxDEV(z,{children:[w?f.jsxDEV(G,{color:"yellow",bold:!0,children:">>> WAITING_FOR_INPUT"},void 0,!1,void 0,this):f.jsxDEV(G,{color:"red",bold:!0,children:">>> CONFIGURATION_NEEDED"},void 0,!1,void 0,this),f.jsxDEV(G,{color:"yellow",dimColor:!0,children:[" ","▌"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},f3=K5;var E$=A(D(),1);var W$=A(D(),1);class C3{commands=new Map;aliases=new Map;register($){if(this.commands.set($.name,$),$.aliases)$.aliases.forEach((Z)=>{this.aliases.set(Z,$.name)})}getCommand($){let Z=this.aliases.get($)||$;return this.commands.get(Z)}getAllCommands(){return Array.from(this.commands.values())}isCommand($){return $.trim().startsWith("/")}parseCommand($){if(!this.isCommand($))return null;let Y=$.trim().slice(1).split(/\s+/),J=Y[0],X=Y.slice(1);return{command:J,args:X}}async executeCommand($,Z){let Y=this.parseCommand($);if(!Y)return{success:!1,message:"无效的命令格式"};let{command:J,args:X}=Y,K=this.getCommand(J);if(!K)return{success:!1,message:`未知命令: /${J}`};if(K.requiresArgs&&X.length===0)return{success:!1,message:`命令 /${J} 需要参数。用法: ${K.usage||`/${J} <args>`}`};if(K.validateArgs&&!K.validateArgs(X))return{success:!1,message:`命令 /${J} 参数无效。用法: ${K.usage||`/${J} <args>`}`};try{return await K.execute(X,Z)}catch(Q){return{success:!1,message:`命令执行失败: ${Q instanceof Error?Q.message:String(Q)}`}}}getSuggestions($){if(!$.startsWith("/"))return[];let Z=$.slice(1).toLowerCase(),Y=[];if(Z===""){let W=["new","history","task","agent","model","settings","mcp","knowledge","summarize","template","plan","interview","help"];for(let _ of W){let O=this.commands.get(_);if(O)Y.push({command:_,displayText:`/${_}`,description:O.description})}return Y.slice(0,10)}let J=new Set(["history","knowledge","help","init","model","config"]),X=[],K=[];for(let[W,_]of this.commands){let O=W.toLowerCase();if(O.startsWith(Z))X.push({command:W,displayText:`/${W}`,description:_.description});else if(O.includes(Z))K.push({command:W,displayText:`/${W}`,description:_.description});if(_.aliases)for(let N of _.aliases){let U=N.toLowerCase();if(U.startsWith(Z))X.push({command:W,displayText:`/${N}`,description:`${_.description} (别名)`});else if(U.includes(Z))K.push({command:W,displayText:`/${N}`,description:`${_.description} (别名)`})}}let Q=(W,_)=>{let O=J.has(W.command)?1:0,N=J.has(_.command)?1:0;if(O!==N)return N-O;return W.displayText.length-_.displayText.length};return X.sort(Q),K.sort(Q),Y.push(...X,...K),Y.slice(0,10)}getHelp($){if($){let Y=this.getCommand($);if(!Y)return`未找到命令: /${$}`;let J=`命令: /${Y.name}
153
+ `;if(J+=`描述: ${Y.description}
154
+ `,Y.usage)J+=`用法: ${Y.usage}
155
+ `;if(Y.aliases&&Y.aliases.length>0)J+=`别名: ${Y.aliases.map((X)=>`/${X}`).join(", ")}
156
+ `;return J}let Z=`可用命令:
157
+ `;for(let Y of this.getAllCommands())Z+=` /${Y.name} - ${Y.description}
158
+ `;return Z+=`
159
+ 使用 /help <命令名> 获取具体命令的帮助信息`,Z}}var G0=new C3;var v3={name:"settings",description:"打开 Settings 面板(Model 和 Provider 配置)",aliases:["s","model","settings","m"],usage:"/settings",execute:async($,Z)=>{return Z.switchToSettings?.(),{success:!0,message:"打开 Settings 面板",shouldClearInput:!0}}};var Q5={name:"new",description:"初始化新的对话会话",aliases:["new","n"],usage:"/new [主题]",execute:async($,Z)=>{let Y=$.join(" ");if(await Z.createNewChat(),Y){let J=`我想开始一个关于 "${Y}" 的新对话。`;return Z.sendMessage([{type:"human",content:J}]),{success:!0,message:`已创建新对话,主题: ${Y}`,shouldClearInput:!0}}return{success:!0,message:"已创建新对话",shouldClearInput:!0}}},W5={name:"help",description:"显示命令帮助信息",aliases:["h","?"],usage:"/help [命令名]",execute:async($,Z)=>{let Y=$[0];return{success:!0,message:G0.getHelp(Y),shouldClearInput:!0}}},_5={name:"task",description:"打开任务看板面板",aliases:["tasks","kanban"],usage:"/task",execute:async($,Z)=>{return Z.switchToTask?.(),{success:!0,message:"打开任务看板",shouldClearInput:!0}}},G5={name:"process",description:"打开进程管理器面板",aliases:["ps","proc"],usage:"/process",execute:async($,Z)=>{return Z.switchToProcess?.(),{success:!0,message:"打开进程管理器",shouldClearInput:!0}}},S3=[Q5,W5,_5,v3,G5];import{readFileSync as O5,readdirSync as U5}from"fs";import{join as I3}from"path";var Q$=null;function N5($){let Z=$.split(`
160
+ `);if(Z[0]!=="---")return{metadata:{},content:$};let Y=Z.indexOf("---",1);if(Y===-1)return{metadata:{},content:$};let J=Z.slice(1,Y),X={};for(let Q of J){let W=Q.match(/^(\w+):\s*(.+)$/);if(W){let[,_,O]=W;if(_==="name")X.name=O.trim();if(_==="description")X.description=O.trim()}}let K=Z.slice(Y+1).join(`
161
+ `).trim();return{metadata:X,content:K}}function k3($,Z){let Y=new Map;try{let J=U5($,{withFileTypes:!0});for(let X of J){let K=I3($,X.name);if(X.isDirectory())k3(K,Z).forEach((W)=>Y.set(W.name,W));else if(X.name.endsWith(".md"))try{let Q=O5(K,"utf-8"),{metadata:W,content:_}=N5(Q),O=W.name||X.name.replace(/\.md$/,"");if(!W.name)console.warn(`Template missing "name" in frontmatter: ${K}`);Y.set(O,{name:O,description:W.description||"No description",content:_,path:K})}catch(Q){console.warn(`Failed to read template file: ${K}`,Q)}}}catch(J){if(J.code!=="ENOENT")console.warn(`Error scanning templates directory: ${$}`,J)}return Y}function y3(){Q$=null}function T3($="./.claude/templates"){if(Q$)return Array.from(Q$.values());let Z=$.startsWith("/")?$:I3(process.cwd(),$);return Q$=k3(Z,Z),Array.from(Q$.values())}var z5={name:"status",description:"显示当前聊天状态信息",aliases:["stat","info"],execute:async($,Z)=>{return{success:!0,message:[`当前代理: ${Z.client?.availableAssistants.find((X)=>X.graph_id===Z.currentAgent)?.name||"未选择"} (${Z.currentAgent||"N/A"})`,`聊天ID: ${Z.client?.currentChatId?.slice(-8)||"N/A"}`,`可用代理数: ${Z.client?.availableAssistants?.length||0}`,`模型: ${Z.extraParams?.model_id||"N/A"}`].join(`
162
+ `),shouldClearInput:!0}}},H5={name:"template",description:"插入预定义的消息模板",aliases:["tpl","t"],usage:"/template <模板名>",execute:async($,Z)=>{let Y=$[0];if($.includes("--refresh"))return y3(),{success:!0,message:"模板缓存已清除",shouldClearInput:!0};let J=T3();if(!Y){if(J.length===0)return{success:!0,message:"当前没有可用的模板。可以在 ./.claude/templates/ 目录下创建 .md 模板文件。",shouldClearInput:!0};return{success:!0,message:`可用模板:
163
+ ${J.map((Q)=>` - ${Q.name}: ${Q.description}`).join(`
176
164
  `)}
177
165
 
178
- 使用 /template <name> 插入模板`,shouldClearInput:!0}}let Q=J.find(($)=>$.name===X);if(!Q){let $=J.map((K)=>K.name).join(", ");return{success:!1,message:`未找到模板 "${X}"。可用模板: ${$||"(无)"}`}}return Y.setUserInput(Q.content),{success:!0,message:`已插入模板: ${Q.name}
179
- ${Q.description}`,shouldClearInput:!1}}},sW={name:"config",description:"查看或设置配置项",aliases:["cfg"],usage:"/config [key] [value]",execute:async(Z,Y)=>{if(Z.length===0)return{success:!0,message:["当前配置:",` model_id: ${Y.extraParams?.model_id||"N/A"}`,` provider_id: ${Y.extraParams?.provider_id||"N/A"}`,` enable_thinking: ${Y.extraParams?.enable_thinking??!0}`,` compact_mode: ${Y.compactMode??!1}`,` stream_refresh_interval: ${Y.extraParams?.stream_refresh_interval}`,"","使用方法:"," /config <key> <value> - 设置配置项"," /config <key> - 查看配置项","","可用配置项:"," model_id - 当前使用的模型 ID"," provider_id - 当前使用的 Provider ID"," enable_thinking - 启用思考模式 (true, false)"," compact_mode - 紧凑模式 (true, false)"," stream_refresh_interval - 流刷新间隔"].join(`
180
- `),shouldClearInput:!0};let X=Z[0],J=["enable_thinking","stream_refresh_interval","provider_id","model_id","compact_mode"];if(!J.includes(X))return{success:!1,message:`无效的配置项: ${X}
181
- 可用配置项: ${J.join(", ")}`,shouldClearInput:!0};if(Z.length===1){let $;switch(X){case"model_id":$=Y.extraParams?.model_id;break;case"provider_id":$=Y.extraParams?.provider_id;break;case"enable_thinking":$=Y.extraParams?.enable_thinking??!0;break;case"compact_mode":$=Y.compactMode??!1;break;case"stream_refresh_interval":$=Y.extraParams?.stream_refresh_interval;break}return{success:!0,message:`${X}: ${$??"未设置"}`,shouldClearInput:!0}}let Q=Z.slice(1).join(" ");if(X==="enable_thinking"||X==="compact_mode"){if(Q==="true"||Q==="1"||Q==="yes")Q=!0;else if(Q==="false"||Q==="0"||Q==="no")Q=!1}if(X==="stream_refresh_interval"){let $=parseInt(Q,10);if(!isNaN($))Q=$}try{if(!Y.updateConfig)return{success:!1,message:"无法访问配置更新功能",shouldClearInput:!0};await Y.updateConfig({[X]:Q});let $=`配置已更新: ${X} = ${Q} 重启程序生效`;if(X==="model_id"||X==="provider_id")$+=`
182
-
183
- 提示: 更换模型或提供商后,请重启程序以确保完整生效`;return{success:!0,message:$,shouldClearInput:!0}}catch($){return{success:!1,message:`配置更新失败: ${$ instanceof Error?$.message:String($)}`,shouldClearInput:!0}}}},tW={name:"mcp",description:"管理 MCP 服务器配置",aliases:[],usage:"/mcp [list|add|remove|get] [args]",execute:async(Z,Y)=>{if(Z.length===0)return{success:!0,message:["MCP 配置管理命令:","","用法:"," /mcp list - 列出所有 MCP 服务器"," /mcp add <name> <json_string> - 添加 MCP 服务器 (传统格式)"," /mcp remove <name> - 移除 MCP 服务器"," /mcp get <name> - 查看 MCP 服务器详情","","示例 (JSON 格式):",' /mcp add context7 {"name":"context7","url":"https://mcp.context7.com/mcp"}',""].join(`
184
- `),shouldClearInput:!0};let X=Z[0];try{let Q=(Y.extraParams||{}).mcp_config||{};switch(X){case"list":{let $=Object.keys(Q);if($.length===0)return{success:!0,message:"当前未配置任何 MCP 服务器",shouldClearInput:!0};return{success:!0,message:`已配置的 MCP 服务器:
185
- ${$.map((U)=>{return` - ${U}`}).join(`
186
- `)}`,shouldClearInput:!0}}case"add":{if(Z.length<2)return{success:!1,message:"用法: /mcp add <name> <json_string>",shouldClearInput:!0};let[$,K,...U]=Z,W=U.join(""),z={...Q,[K]:JSON.parse(W)};if(!Y.updateConfig)return{success:!1,message:"无法访问配置更新功能",shouldClearInput:!0};return await Y.updateConfig({mcp_config:z}),{success:!0,message:`MCP 服务器 "${K}" 已添加`,shouldClearInput:!0}}case"remove":{if(Z.length<2)return{success:!1,message:"用法: /mcp remove <name>",shouldClearInput:!0};let $=Z[1];if(!Q[$])return{success:!1,message:`MCP 服务器 "${$}" 不存在`,shouldClearInput:!0};let K={...Q};if(delete K[$],!Y.updateConfig)return{success:!1,message:"无法访问配置更新功能",shouldClearInput:!0};return await Y.updateConfig({mcp_config:K}),{success:!0,message:`MCP 服务器 "${$}" 已移除
187
- 重启程序生效`,shouldClearInput:!0}}case"get":{if(Z.length<2)return{success:!1,message:"用法: /mcp get <name>",shouldClearInput:!0};let $=Z[1],K=Q[$];if(!K)return{success:!1,message:`MCP 服务器 "${$}" 不存在`,shouldClearInput:!0};return{success:!0,message:[`MCP 服务器: ${$}`,` URL: ${K.url}`,` Headers: ${JSON.stringify(K.headers||{},null,2)}`].join(`
188
- `),shouldClearInput:!0}}default:return{success:!1,message:`未知操作: ${X}
189
- 可用操作: list, add, remove, get`,shouldClearInput:!0}}}catch(J){return{success:!1,message:`MCP 操作失败: ${J instanceof Error?J.message:String(J)}`,shouldClearInput:!0}}}},eW={name:"summarize",description:"智能总结对话并提取有价值信息保存为记忆",aliases:["sum","summary","compact"],usage:"/sum",execute:async(Z,Y)=>{if(!Y.renderMessages||Y.renderMessages.length===0)return{success:!1,message:"当前会话没有消息可以总结",shouldClearInput:!0};let X=Y.renderMessages.length;try{let J={...Y.extraParams,switch_command:"smart_memory"};return await Y.sendMessage([],{extraParams:J}),{success:!0,message:`正在智能分析 ${X} 条消息并提取记忆...`,shouldClearInput:!0}}catch(J){return{success:!1,message:`总结失败: ${J instanceof Error?J.message:String(J)}`,shouldClearInput:!0}}}},Z2={name:"history",description:"打开历史面板",aliases:["h"],execute:async(Z,Y)=>{if(Y.switchToHistory)return Y.switchToHistory(),{success:!0,message:"已打开历史面板",shouldClearInput:!0};return{success:!1,message:"面板切换功能不可用",shouldClearInput:!0}}},Y2={name:"knowledge",description:"打开知识库面板",aliases:["k"],execute:async(Z,Y)=>{if(Y.switchToKnowledge)return Y.switchToKnowledge(),{success:!0,message:"已打开知识库面板",shouldClearInput:!0};return{success:!1,message:"面板切换功能不可用",shouldClearInput:!0}}},X2={name:"close",description:"关闭当前面板返回聊天",aliases:["c","q"],execute:async(Z,Y)=>{if(Y.closePanel)return Y.closePanel(),{success:!0,message:"已关闭面板",shouldClearInput:!0};return{success:!1,message:"面板关闭功能不可用",shouldClearInput:!0}}},J2={name:"model",description:"打开模型/Provider配置面板",aliases:["mp","m"],execute:async(Z,Y)=>{if(Y.switchToModelProvider)return Y.switchToModelProvider(),{success:!0,message:"已打开模型/Provider配置面板",shouldClearInput:!0};return{success:!1,message:"模型面板切换功能不可用",shouldClearInput:!0}}},Q2={name:"ralph",description:"进入循环模式,持续发送响应直到返回 <COMPLETE></COMPLETE>",aliases:[],usage:"/ralph <text>",requiresArgs:!0,execute:async(Z,Y)=>{let X=Z.join(" ");if(!X.trim())return{success:!1,message:"请提供要循环的文本内容",shouldClearInput:!0};if(Y.startRalphLoop)return Y.startRalphLoop(X),{success:!0,message:`进入 Ralph 循环模式: "${X}"`,shouldClearInput:!0};return{success:!1,message:"Ralph 循环功能不可用",shouldClearInput:!0}}},hJ=[nW,aW,sW,tW,eW,Z2,Y2,X2,J2,Q2];var $2={name:"agent",description:"打开 Agent 选择面板",aliases:["a"],usage:"/agent",execute:async(Z,Y)=>{if(Y.switchToAgent)Y.switchToAgent();return{success:!0,message:"打开 Agent 面板",shouldClearInput:!0}}},xJ=[$2];var K2=`
166
+ 使用 /template <name> 插入模板`,shouldClearInput:!0}}let X=J.find((K)=>K.name===Y);if(!X){let K=J.map((Q)=>Q.name).join(", ");return{success:!1,message:`未找到模板 "${Y}"。可用模板: ${K||"(无)"}`}}return Z.setUserInput(X.content),{success:!0,message:`已插入模板: ${X.name}
167
+ ${X.description}`,shouldClearInput:!1}}},F5={name:"config",description:"查看或设置配置项",aliases:["cfg"],usage:"/config [key] [value]",execute:async($,Z)=>{if($.length===0)return{success:!0,message:["当前配置:",` model_id: ${Z.extraParams?.model_id||"N/A"}`,` provider_id: ${Z.extraParams?.provider_id||"N/A"}`,` enable_thinking: ${Z.extraParams?.enable_thinking??!0}`,` compact_mode: ${Z.compactMode??!1}`,` stream_refresh_interval: ${Z.extraParams?.stream_refresh_interval}`,"","使用方法:"," /config <key> <value> - 设置配置项"," /config <key> - 查看配置项","","可用配置项:"," model_id - 当前使用的模型 ID"," provider_id - 当前使用的 Provider ID"," enable_thinking - 启用思考模式 (true, false)"," compact_mode - 紧凑模式 (true, false)"," stream_refresh_interval - 流刷新间隔"].join(`
168
+ `),shouldClearInput:!0};let Y=$[0],J=["enable_thinking","stream_refresh_interval","provider_id","model_id","compact_mode"];if(!J.includes(Y))return{success:!1,message:`无效的配置项: ${Y}
169
+ 可用配置项: ${J.join(", ")}`,shouldClearInput:!0};if($.length===1){let K;switch(Y){case"model_id":K=Z.extraParams?.model_id;break;case"provider_id":K=Z.extraParams?.provider_id;break;case"enable_thinking":K=Z.extraParams?.enable_thinking??!0;break;case"compact_mode":K=Z.compactMode??!1;break;case"stream_refresh_interval":K=Z.extraParams?.stream_refresh_interval;break}return{success:!0,message:`${Y}: ${K??"未设置"}`,shouldClearInput:!0}}let X=$.slice(1).join(" ");if(Y==="enable_thinking"||Y==="compact_mode"){if(X==="true"||X==="1"||X==="yes")X=!0;else if(X==="false"||X==="0"||X==="no")X=!1}if(Y==="stream_refresh_interval"){let K=parseInt(X,10);if(!isNaN(K))X=K}try{if(!Z.updateConfig)return{success:!1,message:"无法访问配置更新功能",shouldClearInput:!0};await Z.updateConfig({[Y]:X});let K=`配置已更新: ${Y} = ${X} 重启程序生效`;if(Y==="model_id"||Y==="provider_id")K+=`
170
+
171
+ 提示: 更换模型或提供商后,请重启程序以确保完整生效`;return{success:!0,message:K,shouldClearInput:!0}}catch(K){return{success:!1,message:`配置更新失败: ${K instanceof Error?K.message:String(K)}`,shouldClearInput:!0}}}},L5={name:"mcp",description:"管理 MCP 服务器配置",aliases:[],usage:"/mcp [list|add|remove|get] [args]",execute:async($,Z)=>{if($.length===0)return{success:!0,message:["MCP 配置管理命令:","","用法:"," /mcp list - 列出所有 MCP 服务器"," /mcp add <name> <json_string> - 添加 MCP 服务器 (传统格式)"," /mcp remove <name> - 移除 MCP 服务器"," /mcp get <name> - 查看 MCP 服务器详情","","示例 (JSON 格式):",' /mcp add context7 {"name":"context7","url":"https://mcp.context7.com/mcp"}',""].join(`
172
+ `),shouldClearInput:!0};let Y=$[0];try{let X=(Z.extraParams||{}).mcp_config||{};switch(Y){case"list":{let K=Object.keys(X);if(K.length===0)return{success:!0,message:"当前未配置任何 MCP 服务器",shouldClearInput:!0};return{success:!0,message:`已配置的 MCP 服务器:
173
+ ${K.map((W)=>{return` - ${W}`}).join(`
174
+ `)}`,shouldClearInput:!0}}case"add":{if($.length<2)return{success:!1,message:"用法: /mcp add <name> <json_string>",shouldClearInput:!0};let[K,Q,...W]=$,_=W.join(""),O={...X,[Q]:JSON.parse(_)};if(!Z.updateConfig)return{success:!1,message:"无法访问配置更新功能",shouldClearInput:!0};return await Z.updateConfig({mcp_config:O}),{success:!0,message:`MCP 服务器 "${Q}" 已添加`,shouldClearInput:!0}}case"remove":{if($.length<2)return{success:!1,message:"用法: /mcp remove <name>",shouldClearInput:!0};let K=$[1];if(!X[K])return{success:!1,message:`MCP 服务器 "${K}" 不存在`,shouldClearInput:!0};let Q={...X};if(delete Q[K],!Z.updateConfig)return{success:!1,message:"无法访问配置更新功能",shouldClearInput:!0};return await Z.updateConfig({mcp_config:Q}),{success:!0,message:`MCP 服务器 "${K}" 已移除
175
+ 重启程序生效`,shouldClearInput:!0}}case"get":{if($.length<2)return{success:!1,message:"用法: /mcp get <name>",shouldClearInput:!0};let K=$[1],Q=X[K];if(!Q)return{success:!1,message:`MCP 服务器 "${K}" 不存在`,shouldClearInput:!0};return{success:!0,message:[`MCP 服务器: ${K}`,` URL: ${Q.url}`,` Headers: ${JSON.stringify(Q.headers||{},null,2)}`].join(`
176
+ `),shouldClearInput:!0}}default:return{success:!1,message:`未知操作: ${Y}
177
+ 可用操作: list, add, remove, get`,shouldClearInput:!0}}}catch(J){return{success:!1,message:`MCP 操作失败: ${J instanceof Error?J.message:String(J)}`,shouldClearInput:!0}}}},A5={name:"summarize",description:"智能总结对话并提取有价值信息保存为记忆",aliases:["sum","summary","compact"],usage:"/sum",execute:async($,Z)=>{if(!Z.renderMessages||Z.renderMessages.length===0)return{success:!1,message:"当前会话没有消息可以总结",shouldClearInput:!0};let Y=Z.renderMessages.length;try{let J={...Z.extraParams,switch_command:"smart_memory"};return await Z.sendMessage([],{extraParams:J}),{success:!0,message:`正在智能分析 ${Y} 条消息并提取记忆...`,shouldClearInput:!0}}catch(J){return{success:!1,message:`总结失败: ${J instanceof Error?J.message:String(J)}`,shouldClearInput:!0}}}},q5={name:"history",description:"打开历史面板",aliases:["h"],execute:async($,Z)=>{if(Z.switchToHistory)return Z.switchToHistory(),{success:!0,message:"已打开历史面板",shouldClearInput:!0};return{success:!1,message:"面板切换功能不可用",shouldClearInput:!0}}},w5={name:"knowledge",description:"打开知识库面板",aliases:["k"],execute:async($,Z)=>{if(Z.switchToKnowledge)return Z.switchToKnowledge(),{success:!0,message:"已打开知识库面板",shouldClearInput:!0};return{success:!1,message:"面板切换功能不可用",shouldClearInput:!0}}},M5={name:"close",description:"关闭当前面板返回聊天",aliases:["c","q"],execute:async($,Z)=>{if(Z.closePanel)return Z.closePanel(),{success:!0,message:"已关闭面板",shouldClearInput:!0};return{success:!1,message:"面板关闭功能不可用",shouldClearInput:!0}}},R5={name:"model",description:"打开模型/Provider配置面板",aliases:["mp","m"],execute:async($,Z)=>{if(Z.switchToModelProvider)return Z.switchToModelProvider(),{success:!0,message:"已打开模型/Provider配置面板",shouldClearInput:!0};return{success:!1,message:"模型面板切换功能不可用",shouldClearInput:!0}}},b5={name:"ralph",description:"进入循环模式,持续发送响应直到返回 <COMPLETE></COMPLETE>",aliases:[],usage:"/ralph <text>",requiresArgs:!0,execute:async($,Z)=>{let Y=$.join(" ");if(!Y.trim())return{success:!1,message:"请提供要循环的文本内容",shouldClearInput:!0};if(Z.startRalphLoop)return Z.startRalphLoop(Y),{success:!0,message:`进入 Ralph 循环模式: "${Y}"`,shouldClearInput:!0};return{success:!1,message:"Ralph 循环功能不可用",shouldClearInput:!0}}},D3=[z5,H5,F5,L5,A5,q5,w5,M5,R5,b5];var B5={name:"agent",description:"打开 Agent 选择面板",aliases:["a"],usage:"/agent",execute:async($,Z)=>{if(Z.switchToAgent)Z.switchToAgent();return{success:!0,message:"打开 Agent 面板",shouldClearInput:!0}}},V3=[B5];var P5=`
190
178
  [Interview Mode Activated]
191
179
 
192
180
  I want to clarify requirements through guided questions.
@@ -205,8 +193,8 @@ After getting answers:
205
193
  ---
206
194
 
207
195
  User's original message:
208
- `,W2={name:"interview",description:"Start Interview mode to clarify requirements through questions",aliases:["i"],usage:"/interview [your request]",requiresArgs:!0,execute:async(Z,Y)=>{let X=Z.join(" ").trim();if(!X)return{success:!1,message:`❌ Interview 模式需要提供任务描述
209
- 用法: /interview [your request]`};let J=K2+X;return Y.sendMessage([{type:"human",content:J}],{extraParams:Y.extraParams}),{success:!0,message:"\uD83D\uDCCB Interview mode activated",shouldClearInput:!0}}},gJ=[W2];var U2=`
196
+ `,f5={name:"interview",description:"Start Interview mode to clarify requirements through questions",aliases:["i"],usage:"/interview [your request]",requiresArgs:!0,execute:async($,Z)=>{let Y=$.join(" ").trim();if(!Y)return{success:!1,message:`❌ Interview 模式需要提供任务描述
197
+ 用法: /interview [your request]`};let J=P5+Y;return Z.sendMessage([{type:"human",content:J}],{extraParams:Z.extraParams}),{success:!0,message:"\uD83D\uDCCB Interview mode activated",shouldClearInput:!0}}},j3=[f5];var C5=`
210
198
  [Plan Mode Activated]
211
199
 
212
200
  I want to create a comprehensive implementation plan for this task.
@@ -229,8 +217,8 @@ After the plan is created, ask if I want to execute it immediately or save for l
229
217
  ---
230
218
 
231
219
  User's original request:
232
- `,z2={name:"plan",description:"Enter Plan mode to create detailed implementation plans",aliases:["p"],usage:"/plan [your task description]",requiresArgs:!0,execute:async(Z,Y)=>{let X=Z.join(" ").trim();if(!X)return{success:!1,message:`❌ Plan 模式需要提供任务描述
233
- 用法: /plan [your task description]`};let J=U2+X;return Y.sendMessage([{type:"human",content:J}],{extraParams:Y.extraParams}),{success:!0,message:"\uD83D\uDCCB Plan mode activated",shouldClearInput:!0}}},uJ=[z2];var mJ=`
220
+ `,v5={name:"plan",description:"Enter Plan mode to create detailed implementation plans",aliases:["p"],usage:"/plan [your task description]",requiresArgs:!0,execute:async($,Z)=>{let Y=$.join(" ").trim();if(!Y)return{success:!1,message:`❌ Plan 模式需要提供任务描述
221
+ 用法: /plan [your task description]`};let J=C5+Y;return Z.sendMessage([{type:"human",content:J}],{extraParams:Z.extraParams}),{success:!0,message:"\uD83D\uDCCB Plan mode activated",shouldClearInput:!0}}},h3=[v5];var E3=`
234
222
  [Create AGENTS.md Mode Activated]
235
223
 
236
224
  I want to create or update the AGENTS.md file for this project.
@@ -262,7 +250,7 @@ After the AGENTS.md is created or updated, provide a summary of the changes made
262
250
  ---
263
251
 
264
252
  User's request:
265
- `,H2={name:"create-agent-md",description:"Create or update AGENTS.md file with project guidelines",aliases:["agentmd","am"],usage:"/create-agent-md [description or goal for AGENTS.md]",requiresArgs:!0,execute:async(Z,Y)=>{let X=Z.join(" ").trim();if(!X)return{success:!1,message:"❌ 需要提供描述或目标。例如: /create-agent-md 初始化项目指南文档",shouldClearInput:!1};let J=mJ+X;return Y.sendMessage([{type:"human",content:J}],{extraParams:Y.extraParams}),{success:!0,message:"\uD83D\uDCDD AGENTS.md creation mode activated",shouldClearInput:!0}}},G2={name:"init-agents-md",description:"快速初始化 AGENTS.md 项目指南文档",aliases:["iam","init-agents"],usage:"/init-agents-md",requiresArgs:!1,execute:async(Z,Y)=>{let J=mJ+"初始化项目 AGENTS.md 指南文档";return Y.sendMessage([{type:"human",content:J}],{extraParams:Y.extraParams}),{success:!0,message:"\uD83D\uDCDD 开始初始化 AGENTS.md...",shouldClearInput:!0}}},pJ=[H2,G2];var dJ={name:"compact-message",description:"切换紧凑消息显示模式 (紧凑模式显示简化的消息预览)",aliases:["cm"],usage:"/compact-message",requiresArgs:!1,execute:async(Z,Y)=>{try{let{updateConfig:X,compactMode:J}=Y;if(!X)return{success:!1,message:"配置更新功能不可用"};let Q=J??!1;return await X({compact_mode:!Q}),{success:!0,message:!Q?"紧凑模式已启用":"紧凑模式已关闭",shouldClearInput:!0}}catch(X){return{success:!1,message:`切换紧凑模式失败: ${X instanceof Error?X.message:String(X)}`}}}};var cJ={name:"mcp",description:"打开 MCP 服务器配置面板",aliases:[],usage:"/mcp",execute:async(Z,Y)=>{return Y.switchToMcp?.(),{success:!0,message:"打开 MCP 配置面板",shouldClearInput:!0}}};var lJ={name:"settings",description:"打开通用设置面板",aliases:["set"],usage:"/settings",execute:async(Z,Y)=>{if(Y.switchToSettings)return Y.switchToSettings(),{success:!0,message:"打开通用设置面板",shouldClearInput:!0};return{success:!1,message:"Settings 面板不可用",shouldClearInput:!0}}};var O2=`
253
+ `,S5={name:"create-agent-md",description:"Create or update AGENTS.md file with project guidelines",aliases:["agentmd","am"],usage:"/create-agent-md [description or goal for AGENTS.md]",requiresArgs:!0,execute:async($,Z)=>{let Y=$.join(" ").trim();if(!Y)return{success:!1,message:"❌ 需要提供描述或目标。例如: /create-agent-md 初始化项目指南文档",shouldClearInput:!1};let J=E3+Y;return Z.sendMessage([{type:"human",content:J}],{extraParams:Z.extraParams}),{success:!0,message:"\uD83D\uDCDD AGENTS.md creation mode activated",shouldClearInput:!0}}},I5={name:"init-agents-md",description:"快速初始化 AGENTS.md 项目指南文档",aliases:["iam","init-agents"],usage:"/init-agents-md",requiresArgs:!1,execute:async($,Z)=>{let J=E3+"初始化项目 AGENTS.md 指南文档";return Z.sendMessage([{type:"human",content:J}],{extraParams:Z.extraParams}),{success:!0,message:"\uD83D\uDCDD 开始初始化 AGENTS.md...",shouldClearInput:!0}}},g3=[S5,I5];var p3={name:"compact-message",description:"切换紧凑消息显示模式 (紧凑模式显示简化的消息预览)",aliases:["cm"],usage:"/compact-message",requiresArgs:!1,execute:async($,Z)=>{try{let{updateConfig:Y,compactMode:J}=Z;if(!Y)return{success:!1,message:"配置更新功能不可用"};let X=J??!1;return await Y({compact_mode:!X}),{success:!0,message:!X?"紧凑模式已启用":"紧凑模式已关闭",shouldClearInput:!0}}catch(Y){return{success:!1,message:`切换紧凑模式失败: ${Y instanceof Error?Y.message:String(Y)}`}}}};var m3={name:"mcp",description:"打开 MCP 服务器配置面板",aliases:[],usage:"/mcp",execute:async($,Z)=>{return Z.switchToMcp?.(),{success:!0,message:"打开 MCP 配置面板",shouldClearInput:!0}}};var c3={name:"settings",description:"打开通用设置面板",aliases:["set"],usage:"/settings",execute:async($,Z)=>{if(Z.switchToSettings)return Z.switchToSettings(),{success:!0,message:"打开通用设置面板",shouldClearInput:!0};return{success:!1,message:"Settings 面板不可用",shouldClearInput:!0}}};var k5=`
266
254
  [Memory Organization Mode Activated]
267
255
 
268
256
  I want to organize and manage the .claude/memories folder.
@@ -316,26 +304,31 @@ Provide a detailed report of:
316
304
 
317
305
  ---
318
306
 
319
- `,q2={name:"memory-clear",description:"整理 .claude/memories 文件夹,清理、合并和优化项目记忆",aliases:["mem-clean","clean-memory"],usage:"/memory-clear",execute:async(Z,Y)=>{let X=Z.join(" ").trim(),J=O2+(X?`Additional context: ${X}
307
+ `,y5={name:"memory-clear",description:"整理 .claude/memories 文件夹,清理、合并和优化项目记忆",aliases:["mem-clean","clean-memory"],usage:"/memory-clear",execute:async($,Z)=>{let Y=$.join(" ").trim(),J=k5+(Y?`Additional context: ${Y}
320
308
 
321
- ---`:"开始整理记忆文件夹。");return Y.sendMessage([{type:"human",content:J}],{extraParams:Y.extraParams}),{success:!0,message:"\uD83E\uDDE0 记忆整理模式已激活 - 正在分析 .claude/memories 文件夹...",shouldClearInput:!0}}},iJ=[q2];function eZ(Z){if(Z===0)return"0 B";let Y=1024,X=["B","KB","MB","GB"],J=Math.floor(Math.log(Z)/Math.log(Y));return parseFloat((Z/Math.pow(Y,J)).toFixed(2))+" "+X[J]}function tX(){let Z=process.memoryUsage();return{heapTotal:Z.heapTotal,heapUsed:Z.heapUsed,external:Z.external,rss:Z.rss,heapUsedMB:(Z.heapUsed/1024/1024).toFixed(2),heapTotalMB:(Z.heapTotal/1024/1024).toFixed(2)}}function rJ(){return typeof Bun<"u"}function F2(){let Z=tX();if(rJ()&&typeof Bun.gc==="function"){Bun.gc(!0);let Y=tX(),X=Z.heapUsed-Y.heapUsed;return{success:!0,before:Z,after:Y,freed:X,message:`GC 执行成功,释放了 ${eZ(Math.max(0,X))} 内存`}}if(globalThis.global&&typeof globalThis.global.gc==="function"){globalThis.global.gc();let Y=tX(),X=Z.heapUsed-Y.heapUsed;return{success:!0,before:Z,after:Y,freed:X,message:`GC 执行成功,释放了 ${eZ(Math.max(0,X))} 内存`}}return{success:!1,before:Z,message:`/gc 命令仅在 Bun 或者 node --expose-gc 可用
322
- `+"当前内存使用: "+eZ(Z.heapUsed)+" / "+eZ(Z.heapTotal)}}function M2(){let Z=[];if(!rJ())Z.push("/gc 命令仅支持 Bun 运行时,请使用 bun 启动应用");else Z.push("当前运行在 Bun 环境,/gc 命令已就绪");return Z.join(`
323
- `)}var oJ={name:"gc",description:"手动触发垃圾回收,减少内存占用",aliases:["garbage-collect","mem-opt","memory"],usage:"/gc",execute:async(Z,Y)=>{let X=Z.includes("-v")||Z.includes("--verbose"),J=F2(),Q=`\uD83D\uDDD1️ ${J.message}
324
- `;if(J.before&&J.after){if(Q+=`
309
+ ---`:"开始整理记忆文件夹。");return Z.sendMessage([{type:"human",content:J}],{extraParams:Z.extraParams}),{success:!0,message:"\uD83E\uDDE0 记忆整理模式已激活 - 正在分析 .claude/memories 文件夹...",shouldClearInput:!0}}},u3=[y5];function u1($){if($===0)return"0 B";let Z=1024,Y=["B","KB","MB","GB"],J=Math.floor(Math.log($)/Math.log(Z));return parseFloat(($/Math.pow(Z,J)).toFixed(2))+" "+Y[J]}function q6(){let $=process.memoryUsage();return{heapTotal:$.heapTotal,heapUsed:$.heapUsed,external:$.external,rss:$.rss,heapUsedMB:($.heapUsed/1024/1024).toFixed(2),heapTotalMB:($.heapTotal/1024/1024).toFixed(2)}}function x3(){return typeof Bun<"u"}function T5(){let $=q6();if(x3()&&typeof Bun.gc==="function"){Bun.gc(!0);let Z=q6(),Y=$.heapUsed-Z.heapUsed;return{success:!0,before:$,after:Z,freed:Y,message:`GC 执行成功,释放了 ${u1(Math.max(0,Y))} 内存`}}if(globalThis.global&&typeof globalThis.global.gc==="function"){globalThis.global.gc();let Z=q6(),Y=$.heapUsed-Z.heapUsed;return{success:!0,before:$,after:Z,freed:Y,message:`GC 执行成功,释放了 ${u1(Math.max(0,Y))} 内存`}}return{success:!1,before:$,message:`/gc 命令仅在 Bun 或者 node --expose-gc 可用
310
+ `+"当前内存使用: "+u1($.heapUsed)+" / "+u1($.heapTotal)}}function D5(){let $=[];if(!x3())$.push("/gc 命令仅支持 Bun 运行时,请使用 bun 启动应用");else $.push("当前运行在 Bun 环境,/gc 命令已就绪");return $.join(`
311
+ `)}var d3={name:"gc",description:"手动触发垃圾回收,减少内存占用",aliases:["garbage-collect","mem-opt","memory"],usage:"/gc",execute:async($,Z)=>{let Y=$.includes("-v")||$.includes("--verbose"),J=T5(),X=`\uD83D\uDDD1️ ${J.message}
312
+ `;if(J.before&&J.after){if(X+=`
325
313
  \uD83D\uDCCA 内存统计:
326
- `,Q+=` Before: ${eZ(J.before.heapUsed)} / ${eZ(J.before.heapTotal)}
327
- `,Q+=` After: ${eZ(J.after.heapUsed)} / ${eZ(J.after.heapTotal)}
328
- `,J.freed!==void 0&&J.freed>0)Q+=` Freed: ${eZ(J.freed)}
329
- `}else if(J.before)Q+=`
330
- \uD83D\uDCCA 当前内存使用: ${eZ(J.before.heapUsed)} / ${eZ(J.before.heapTotal)}
331
- `;if(!J.success||X)Q+=`
314
+ `,X+=` Before: ${u1(J.before.heapUsed)} / ${u1(J.before.heapTotal)}
315
+ `,X+=` After: ${u1(J.after.heapUsed)} / ${u1(J.after.heapTotal)}
316
+ `,J.freed!==void 0&&J.freed>0)X+=` Freed: ${u1(J.freed)}
317
+ `}else if(J.before)X+=`
318
+ \uD83D\uDCCA 当前内存使用: ${u1(J.before.heapUsed)} / ${u1(J.before.heapTotal)}
319
+ `;if(!J.success||Y)X+=`
332
320
  \uD83D\uDCA1 提示:
333
- `,Q+=` ${M2().replace(/\n/g,`
321
+ `,X+=` ${D5().replace(/\n/g,`
334
322
  `)}
335
- `;return{success:J.success,message:Q,shouldClearInput:!0}}};[...fJ,...hJ,...xJ,...gJ,...uJ,...pJ,...iJ,dJ,cJ,lJ,oJ].forEach((Z)=>{L4.register(Z)});var P4=P(I(),1),nJ=(Z)=>{let{onCommandExecuted:Y,switchToHistory:X,switchToKnowledge:J,switchToSettings:Q,switchToAgent:$,closePanel:K,switchToTask:U,switchToModelProvider:W,switchToMcp:z,switchToProcess:H}=Z,{userInput:G,setUserInput:F,sendMessage:M,currentAgent:N,client:w,createNewChat:L,renderMessages:B}=WZ(),{extraParams:C,updateConfig:R,AVAILABLE_MODELS:D,compactMode:f}=UZ(),[V,d]=g0.useState(null),[l,u]=g0.useState(null);TZ(()=>{d(null)},V?3000:null),TZ(()=>{u(null)},l?5000:null);let n=G.startsWith("/"),i=n?L4.getSuggestions(G):[],Q4=n,$4=g0.useCallback(async(p0)=>{let F0=p0||G;if(!L4.isCommand(F0))return!1;try{let M0={userInput:F0,setUserInput:F,sendMessage(dY,W8={}){return M(dY,{extraParams:{...C,...W8.extraParams},...W8,metadata:U4})},currentAgent:N,client:w,extraParams:C,createNewChat(){return L(U4)},updateConfig:R,AVAILABLE_MODELS:D,renderMessages:B,compactMode:f,switchToHistory:X,switchToKnowledge:J,switchToSettings:Q,switchToModelProvider:W,switchToAgent:$,switchToTask:U,switchToMcp:z,switchToProcess:H,closePanel:K,startRalphLoop:Z.startRalphLoop},v4=await L4.executeCommand(F0,M0);if(!v4.success)d(v4.message||"命令执行失败");else if(v4.message)u(v4.message);if(v4.shouldClearInput)F("");if(v4.shouldSendMessage&&v4.messageContent){let dY=[{type:"human",content:v4.messageContent}];M(dY,{extraParams:C})}return Y?.(),!0}catch(M0){return d(`命令执行错误: ${M0 instanceof Error?M0.message:String(M0)}`),!0}},[G,F,M,N,w,C,L,Y,D,f,X,J,Q,W,$,U,z,H,K,Z.startRalphLoop]);return{isCommandInput:n,commandSuggestions:i,showCommandHint:Q4,commandError:V,executeCommand:$4,CommandHintUI:()=>{if(!Q4||i.length===0)return null;return P4.jsxDEV(_,{marginBottom:1,flexDirection:"column",children:[P4.jsxDEV(O,{color:"yellow",bold:!0,children:"命令建议:"},void 0,!1,void 0,this),i.slice(0,5).map((p0,F0)=>P4.jsxDEV(O,{color:"cyan",children:[p0.displayText," - ",p0.description]},F0,!0,void 0,this)),i.length>5&&P4.jsxDEV(O,{color:"gray",children:["...还有 ",i.length-5," 个命令"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},CommandErrorUI:()=>{if(!V)return null;return P4.jsxDEV(_,{marginBottom:1,children:P4.jsxDEV(O,{color:"red",children:["❌ ",V]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},CommandSuccessUI:()=>{if(!l)return null;return P4.jsxDEV(_,{marginBottom:1,children:P4.jsxDEV(O,{color:"green",children:["✅ ",l]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}}};function aJ({manager:Z,enabled:Y=!0}){return xY({queryKey:gY.skills.list(),queryFn:async()=>{if(!Z)throw Error("ConfigManager not initialized");return await Z.listSkills()},enabled:Y&&!!Z,staleTime:120000})}var N2=[{id:"agents/default",name:"Jarvis",description:"代码实现助手"},{id:"agents/manager",name:"Manager",description:"任务管理员"}];function sJ({enabled:Z=!0}={}){return xY({queryKey:gY.agents.list(),queryFn:async()=>{return N2},enabled:Z,staleTime:300000})}var Z4=P(g(),1);function tJ({loading:Z,renderMessages:Y,sendMessage:X,setUserInput:J,extraParams:Q}){let[$,K]=Z4.useState(null),[U,W]=Z4.useState(!1),z=Z4.useRef(!1),H=Z4.useRef(0),G=Z4.useCallback(async(M)=>{if(!M)return;let N=z.current?`
336
-
337
- [System Context: You are currently in Ralph loop mode. Continue executing the task based on previous context. Respond with <COMPLETE></COMPLETE> tag when the task is complete.]`:"",w=[{type:"human",content:M+N}];await X(w,{extraParams:Q,metadata:U4})},[X,Q]);TZ(()=>{if($)G($);W(!1)},U?100:null);let F=Z4.useCallback((M)=>{K(M),z.current=!0,H.current=0,W(!0)},[]);return Z4.useEffect(()=>{if(z.current&&$&&!Z){let M=Y.length;if(M>H.current){H.current=M;let N=Y[M-1],w=J0(N);if(typeof w==="string"&&w.includes("<COMPLETE></COMPLETE>"))z.current=!1,K(null),N4("Ralph 循环完成");else G($)}}},[Z,Y,$,G]),{ralphLoopText:$,startRalphLoop:F,sendTextMessage:G}}var wZ=P(g(),1);var e4=P(g(),1);import eX from"fuzzysort";function _2(Z,Y){if(Y===0)return!0;let X=Z[Y-1];return X===" "||X===`
338
- `||X==="\t"}function A2(Z,Y){let X=Y+1;while(X<Z.length&&!/[\s\n\t]/.test(Z[X]))X++;return Z.slice(Y+1,X)}function w2(Z,Y,X){if(!Y)return Z.slice(0,X).map((K)=>({skill:K,result:null}));let J=Z.map((K)=>({skill:K,name:eX.prepare(K.name.toLowerCase()),description:eX.prepare((K.description||"").toLowerCase())}));return eX.go(Y.toLowerCase(),J,{key:"name",limit:X,threshold:-1e4}).map((K)=>({skill:K.obj.skill,result:K}))}function eJ({skills:Z,maxSuggestions:Y=5}){let[X,J]=e4.useState({visible:!1,query:"",filteredSkills:[],triggerPosition:-1}),Q=e4.useCallback((z,H)=>{let G=z.lastIndexOf("#");if(G===-1){J((N)=>({...N,visible:!1,query:"",filteredSkills:[],triggerPosition:-1}));return}if(!_2(z,G)){J((N)=>({...N,visible:!1,query:"",filteredSkills:[],triggerPosition:-1}));return}let F=A2(z,G),M=w2(Z,F,Y);if(M.length===1&&M[0].skill.name.toLowerCase()===F.toLowerCase()){J((N)=>({...N,visible:!1,query:"",filteredSkills:[],triggerPosition:-1}));return}J((N)=>({...N,visible:!0,query:F,filteredSkills:M,triggerPosition:G}))},[Z.length,Y]),$=e4.useCallback(()=>{if(!X.visible||X.filteredSkills.length===0)return null;return X.filteredSkills[0]?.skill??null},[X.visible,X.filteredSkills]),K=e4.useCallback((z)=>{let H=$();if(!H)return z;let G=z.slice(0,X.triggerPosition),F=z.slice(X.triggerPosition+1+X.query.length);return`${G}#${H.name} ${F}`},[$,X.triggerPosition,X.query]),U=e4.useCallback(()=>{J((z)=>({...z,visible:!1,query:"",filteredSkills:[],triggerPosition:-1}))},[]),W=X.visible&&X.filteredSkills.length>0;return{state:X,checkTrigger:Q,getFirstSkill:$,complete:K,hide:U,isActive:W}}var Z0=P(g(),1);function B2(Z,Y){if(Y===0)return!0;let X=Z[Y-1];return X===" "||X===`
339
- `||X==="\t"}function L2(Z,Y){let X=Y+1;while(X<Z.length&&!/[\s\n\t]/.test(Z[X]))X++;return Z.slice(Y+1,X)}function P2(Z,Y,X){let J=Y.toLowerCase(),Q=Z.filter(($)=>{let K=$.name.toLowerCase(),U=$.id.toLowerCase();return K.startsWith(J)||U.includes(J)});return Q.sort(($,K)=>$.name.localeCompare(K.name)),Q.slice(0,X)}function Z1({agents:Z,maxSuggestions:Y=5}){let[X,J]=Z0.useState({visible:!1,query:"",filteredAgents:[],triggerPosition:-1}),Q=Z0.useCallback((z,H)=>{let G=z.lastIndexOf("@");if(G===-1){J((N)=>({...N,visible:!1,query:"",filteredAgents:[],triggerPosition:-1}));return}if(!B2(z,G)){J((N)=>({...N,visible:!1,query:"",filteredAgents:[],triggerPosition:-1}));return}let F=L2(z,G),M=P2(Z,F,Y);if(M.length===1&&M[0].name.toLowerCase()===F.toLowerCase()){J((N)=>({...N,visible:!1,query:"",filteredAgents:[],triggerPosition:-1}));return}J((N)=>({...N,visible:!0,query:F,filteredAgents:M,triggerPosition:G}))},[Z.length,Y]),$=Z0.useCallback(()=>{if(!X.visible||X.filteredAgents.length===0)return null;return X.filteredAgents[0]??null},[X.visible,X.filteredAgents]),K=Z0.useCallback((z)=>{let H=$();if(!H)return z;let G=z.slice(0,X.triggerPosition),F=z.slice(X.triggerPosition+1+X.query.length);return`${G}@${H.name} ${F}`},[$,X.triggerPosition,X.query]),U=Z0.useCallback(()=>{J((z)=>({...z,visible:!1,query:"",filteredAgents:[],triggerPosition:-1}))},[]),W=X.visible&&X.filteredAgents.length>0;return{state:X,checkTrigger:Q,getFirstAgent:$,complete:K,hide:U,isActive:W}}var Y1=P(g(),1);var yZ=P(I(),1);function R2({name:Z,result:Y}){if(!Y)return yZ.jsxDEV(O,{color:"cyan",children:Z},void 0,!1,void 0,this);let X=Y.highlight((J)=>yZ.jsxDEV(O,{color:"green",bold:!0,children:J},void 0,!1,void 0,this));if(Array.isArray(X))return yZ.jsxDEV(O,{color:"cyan",children:X.map((J,Q)=>{if(typeof J==="string")return yZ.jsxDEV(O,{children:J},`p-${Q}`,!1,void 0,this);return yZ.jsxDEV(Y1.default.Fragment,{children:J},`m-${Q}`,!1,void 0,this)})},void 0,!1,void 0,this);return yZ.jsxDEV(O,{color:"cyan",children:Z},void 0,!1,void 0,this)}var X1=({visible:Z,skills:Y,query:X,maxVisible:J=5})=>{if(!Z||Y.length===0)return null;let Q=Y.slice(0,J);return yZ.jsxDEV(_,{marginBottom:1,flexDirection:"column",children:[yZ.jsxDEV(O,{color:"yellow",bold:!0,children:"技能建议 (按 → 补全):"},void 0,!1,void 0,this),Q.map(({skill:$,result:K})=>yZ.jsxDEV(_,{children:[yZ.jsxDEV(O,{children:" #"},void 0,!1,void 0,this),yZ.jsxDEV(R2,{name:$.name,result:K},void 0,!1,void 0,this)]},$.name,!0,void 0,this)),Y.length>J&&yZ.jsxDEV(O,{color:"gray",children:["...还有 ",Y.length-J," 个技能"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};var vZ=P(I(),1);function C2({name:Z,query:Y}){if(!Y)return vZ.jsxDEV(O,{color:"magenta",children:Z},void 0,!1,void 0,this);let X=Z.toLowerCase(),J=Y.toLowerCase();if(X.startsWith(J))return vZ.jsxDEV(vZ.Fragment,{children:[vZ.jsxDEV(O,{color:"green",bold:!0,children:Z.slice(0,Y.length)},void 0,!1,void 0,this),vZ.jsxDEV(O,{color:"magenta",children:Z.slice(Y.length)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return vZ.jsxDEV(O,{color:"magenta",children:Z},void 0,!1,void 0,this)}var J1=({visible:Z,agents:Y,query:X,maxVisible:J=5})=>{if(!Z||Y.length===0)return null;let Q=Y.slice(0,J);return vZ.jsxDEV(_,{marginBottom:1,flexDirection:"column",children:[vZ.jsxDEV(O,{color:"yellow",bold:!0,children:"Agent 建议 (按 → 补全):"},void 0,!1,void 0,this),Q.map(($)=>vZ.jsxDEV(_,{children:[vZ.jsxDEV(O,{children:" @"},void 0,!1,void 0,this),vZ.jsxDEV(C2,{name:$.name,query:X},void 0,!1,void 0,this),vZ.jsxDEV(O,{dimColor:!0,children:[" - ",$.description]},void 0,!0,void 0,this)]},$.id,!0,void 0,this)),Y.length>J&&vZ.jsxDEV(O,{color:"gray",children:["...还有 ",Y.length-J," 个 Agent"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};var $1=P(g(),1);function K1(){let{extraParams:Z}=UZ(),{sendMessage:Y,loading:X}=WZ(),{bufferedMessage:J,clearBuffer:Q}=uY(),$=Q1();$1.useEffect(()=>{if(!X&&J.trim()){let K=[{type:"human",content:J}];Q(),Y(K,{extraParams:Z}).then(()=>{N4("Zen Code 完成任务")}).catch((U)=>{console.error("Failed to send buffered message:",U)})}},[X,J,Y,Z,Q,$])}var R4=P(I(),1),W1=({value:Z,onChange:Y,onSubmit:X,loading:J,placeholder:Q="输入消息...",commandHandler:$,skills:K=[],agents:U=[]})=>{K1();let{bufferedMessage:W,setBufferedMessage:z,clearBuffer:H}=uY(),[G,F]=wZ.useState(Z),M=wZ.useRef(!1),N=eJ({skills:K,maxSuggestions:5}),w=Z1({agents:U,maxSuggestions:5});wZ.useEffect(()=>{if(Z!==G)M.current=!0,F(Z)},[Z]);let L=wZ.useMemo(()=>G.startsWith("/"),[G]);wZ.useEffect(()=>{if(!L)N.checkTrigger(G),w.checkTrigger(G)},[G,L]);let B=wZ.useCallback((l)=>{if(M.current){M.current=!1;return}F(l),Y(l)},[Y]),C=wZ.useCallback((l)=>{if(!l.trim())return;if(N.hide(),w.hide(),L){X(l),F("");return}if(J)z(l),F("");else X(l),F("")},[L,J,X,z,N,w]),R=wZ.useCallback(()=>{if(w.isActive){w.hide();return}if(N.isActive){N.hide();return}if(W)H();else F("")},[W,H,N.isActive,w.isActive]),D=wZ.useCallback(()=>{if(!L||!$.commandSuggestions||$.commandSuggestions.length===0)return!1;let u=$.commandSuggestions[0],i=(u.displayText||u.command||"")+" ";return B(i),!0},[L,$.commandSuggestions,B]),f=wZ.useCallback(()=>{if(!N.isActive)return!1;let l=N.complete(G);return B(l),N.hide(),!0},[N.isActive,G,B]),V=wZ.useCallback(()=>{if(!w.isActive)return!1;let l=w.complete(G);return B(l),w.hide(),!0},[w.isActive,G,B]),d=wZ.useMemo(()=>{if(J)return W?"按 Esc 清空缓冲区":"AI 响应中,Enter 将消息加入缓冲区";if(L)return"输入命令... (试试 /help,按 → 补全第一个建议)";if(w.isActive)return"按 → 补全 Agent";if(N.isActive)return"按 → 补全技能";return Q},[J,W,L,w.isActive,N.isActive,Q]);return R4.jsxDEV(_,{flexDirection:"column",children:[W&&R4.jsxDEV(_,{padding:1,children:R4.jsxDEV(O,{color:"yellow",children:["\uD83D\uDCDD 缓冲区: ",W.slice(0,50),W.length>50?"...":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),R4.jsxDEV($.CommandHintUI,{},void 0,!1,void 0,this),R4.jsxDEV(J1,{visible:w.state.visible,agents:w.state.filteredAgents,query:w.state.query},void 0,!1,void 0,this),R4.jsxDEV(X1,{visible:N.state.visible,skills:N.state.filteredSkills,query:N.state.query},void 0,!1,void 0,this),R4.jsxDEV(_,{paddingY:1,children:R4.jsxDEV(iZ,{id:"global-input",value:G,onChange:B,onSubmit:C,onHotKey:(l,u)=>{if(u.escape)return R(),!1;if(u.rightArrow){if(w.isActive){if(V())return!1}if(N.isActive){if(f())return!1}if(D())return!1}return!0},placeholder:d},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};var u0=P(I(),1),Z8=mY.memo(()=>{let{userInput:Z,setUserInput:Y,loading:X,renderMessages:J,sendMessage:Q}=WZ(),{extraParams:$,manager:K}=UZ(),{switchToHistory:U,switchToKnowledge:W,switchToSettings:z,switchToModelProvider:H,switchToAgent:G,switchToTask:F,switchToMcp:M,switchToProcess:N,closePanel:w}=X0(),{data:L=[]}=aJ({manager:K}),{data:B=[]}=sJ(),{startRalphLoop:C}=tJ({loading:X,renderMessages:J,sendMessage:Q,setUserInput:Y,extraParams:$}),R=nJ({extraParams:$,switchToHistory:U,switchToKnowledge:W,switchToSettings:z,switchToModelProvider:H,switchToAgent:G,switchToTask:F,switchToMcp:M,switchToProcess:N,closePanel:w,startRalphLoop:C}),D=mY.useCallback(async(f)=>{if(!f)return;if(f.startsWith("/")){if(await R.executeCommand(f)){Y("");return}}await Q([{type:"human",content:f}],{extraParams:$,metadata:U4}),N4("Zen Code 完成任务")},[R,Y]);return u0.jsxDEV(_,{flexDirection:"column",paddingX:0,paddingY:0,borderColor:"grey",borderTop:!0,borderStyle:"single",borderLeft:!1,borderBottom:!1,borderRight:!1,children:[u0.jsxDEV(R.CommandErrorUI,{},void 0,!1,void 0,this),u0.jsxDEV(R.CommandSuccessUI,{},void 0,!1,void 0,this),u0.jsxDEV(W1,{value:Z,onChange:Y,onSubmit:D,loading:X,commandHandler:{isCommandInput:R.isCommandInput,CommandHintUI:R.CommandHintUI,commandSuggestions:R.commandSuggestions},skills:L,agents:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});Z8.displayName="ChatInput";var kZ=P(I(),1),I2=()=>{let{renderMessages:Z,currentChatId:Y,getToolUIRender:X,loading:J}=WZ(),{compactMode:Q}=UZ(),[$]=U1(Z,50),K=H1.useCallback((U)=>X(U),[X]);return kZ.jsxDEV(_,{flexDirection:"column",flexGrow:1,paddingX:0,paddingY:0,children:[$.length===0&&kZ.jsxDEV(EJ,{},void 0,!1,void 0,this),$.length?Q?kZ.jsxDEV(sX,{renderMessages:$,startIndex:0,staticKey:Y,getToolUIRender:K,loading:J},Y,!1,void 0,this):kZ.jsxDEV(CJ,{loading:J,renderMessages:$,startIndex:0,staticKey:Y},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},Y8=()=>{let{hasPendingInteractions:Z}=xZ();return kZ.jsxDEV(_,{flexDirection:"column",flexGrow:1,children:[kZ.jsxDEV(r,{name:"ChatMessages",fallback:null,children:kZ.jsxDEV(I2,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),kZ.jsxDEV(z1,{children:kZ.jsxDEV(r,{name:"InteractionArea",fallback:null,children:Z?kZ.jsxDEV(_,{paddingX:0,paddingY:0,children:kZ.jsxDEV(WX,{},void 0,!1,void 0,this)},void 0,!1,void 0,this):kZ.jsxDEV(Z8,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};Y8.displayName="ChatMain";var Y4=P(g(),1);var C4=P(g(),1),G1=C4.lazy(()=>import("./chunk-a4vdvjsr.js").then((Z)=>({default:Z.default}))),O1=C4.lazy(()=>import("./chunk-tqh0rjpp.js").then((Z)=>({default:Z.default}))),q1=C4.lazy(()=>import("./chunk-wb6xn1kx.js").then((Z)=>({default:Z.default}))),F1=C4.lazy(()=>import("./chunk-n0sxg10w.js").then((Z)=>({default:Z.default}))),M1=C4.lazy(()=>import("./chunk-edkft0pe.js").then((Z)=>({default:Z.default}))),N1=C4.lazy(()=>import("./chunk-7d4h6qkf.js").then((Z)=>({default:Z.default}))),_1=C4.lazy(()=>import("./chunk-eemwtwb1.js").then((Z)=>({default:Z.default}))),A1=C4.lazy(()=>import("./chunk-6mcx89fj.js").then((Z)=>({default:Z.default})));var h=P(I(),1),S4=()=>h.jsxDEV(_,{paddingX:1,paddingY:1,children:h.jsxDEV(O,{color:"grey",children:"Loading..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),y4=(Z)=>h.jsxDEV(_,{paddingX:1,paddingY:1,children:[h.jsxDEV(O,{color:"red",children:["✗ ",Z," panel error"]},void 0,!0,void 0,this),h.jsxDEV(_,{marginTop:1,children:h.jsxDEV(O,{color:"gray",children:"Try reopening or press ESC to return"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X8=Y4.memo(()=>{let{activeView:Z,closePanel:Y,handleExecuteTask:X}=X0();return h.jsxDEV(_,{flexGrow:1,flexDirection:"row",children:[Z==="history"&&h.jsxDEV(Y4.Suspense,{fallback:h.jsxDEV(S4,{},void 0,!1,void 0,this),children:h.jsxDEV(r,{name:"HistoryPanel",fallback:y4("History"),children:h.jsxDEV(G1,{onClose:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z==="knowledge"&&h.jsxDEV(Y4.Suspense,{fallback:h.jsxDEV(S4,{},void 0,!1,void 0,this),children:h.jsxDEV(r,{name:"KnowledgePanel",fallback:y4("Knowledge"),children:h.jsxDEV(O1,{onClose:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z==="settings"&&h.jsxDEV(Y4.Suspense,{fallback:h.jsxDEV(S4,{},void 0,!1,void 0,this),children:h.jsxDEV(r,{name:"SettingsPanel",fallback:y4("Settings"),children:h.jsxDEV(q1,{onClose:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z==="model-provider"&&h.jsxDEV(Y4.Suspense,{fallback:h.jsxDEV(S4,{},void 0,!1,void 0,this),children:h.jsxDEV(r,{name:"ModelProviderPanel",fallback:y4("Model Provider"),children:h.jsxDEV(F1,{onClose:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z==="agent"&&h.jsxDEV(Y4.Suspense,{fallback:h.jsxDEV(S4,{},void 0,!1,void 0,this),children:h.jsxDEV(r,{name:"AgentPanel",fallback:y4("Agent"),children:h.jsxDEV(M1,{onClose:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z==="task"&&h.jsxDEV(Y4.Suspense,{fallback:h.jsxDEV(S4,{},void 0,!1,void 0,this),children:h.jsxDEV(r,{name:"TaskPanel",fallback:y4("Task"),children:h.jsxDEV(N1,{onClose:Y,onExecuteTask:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z==="mcp"&&h.jsxDEV(Y4.Suspense,{fallback:h.jsxDEV(S4,{},void 0,!1,void 0,this),children:h.jsxDEV(r,{name:"McpPanel",fallback:y4("MCP"),children:h.jsxDEV(_1,{onClose:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z==="process"&&h.jsxDEV(Y4.Suspense,{fallback:h.jsxDEV(S4,{},void 0,!1,void 0,this),children:h.jsxDEV(r,{name:"ProcessPanel",fallback:y4("Process"),children:h.jsxDEV(A1,{onClose:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});X8.displayName="LazyChatViewManager";var k4=P(g(),1);var w1=P(g(),1);var pY=P(I(),1),B1=()=>{let{renderMessages:Z}=WZ(),Y=w1.default.useMemo(()=>{if(!Z)return null;for(let X=Z.length-1;X>=0;X--){let J=Z[X];if(J.role==="assistant"&&J.content)try{let $=(Array.isArray(J.content)?J.content:[{type:"text",text:J.content}]).find((K)=>K.type==="text")?.text||"";if($.includes("load_mcp_tools"))try{let K=JSON.parse($);if(K.status&&K.status.toolCount!==void 0)return K.status}catch(K){}}catch(Q){}}return null},[Z]);if(!Y||Y.toolCount===0)return null;return pY.jsxDEV(_,{paddingX:1,children:[pY.jsxDEV(O,{color:"green",bold:!0,children:"MCP"},void 0,!1,void 0,this),pY.jsxDEV(O,{color:"cyan",children:[" ",Y.toolCount]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};var X4=P(g(),1);function Q8(Z){if(Z===0)return"0";if(Z<1024)return`${Z}`;if(Z<1048576)return`${(Z/1024).toFixed(0)}K`;if(Z<1073741824)return`${(Z/1048576).toFixed(0)}M`;return`${(Z/1073741824).toFixed(1)}G`}function L1(Z){let Y=Math.floor(Z/1000),X=Math.floor(Y/3600),J=Math.floor(Y%3600/60),Q=Y%60;if(X>0)return`${X}:${String(J).padStart(2,"0")}:${String(Q).padStart(2,"0")}`;return`${String(J).padStart(2,"0")}:${String(Q).padStart(2,"0")}`}function P1(Z){let[Y,X]=X4.useState(0),J=X4.useRef(null);return X4.useEffect(()=>{if(Z)J.current=Date.now(),X(0);else J.current=null,X(0)},[Z]),J8(()=>{if(J.current)X(Date.now()-J.current)},Z?1000:null),Y}function R1(){let[Z,Y]=X4.useState({cpuPercent:0,memoryRSS:0,memoryHeapUsed:0,memoryHeapTotal:0}),X=X4.useRef(process.cpuUsage()),J=X4.useRef(Date.now()),Q=()=>{let $=Date.now(),K=process.cpuUsage(),U=process.memoryUsage(),W=$-J.current,z=K.user-X.current.user,H=K.system-X.current.system,F=(z+H)/1000/W*100;Y({cpuPercent:Math.min(100,Math.max(0,F)),memoryRSS:U.rss,memoryHeapUsed:U.heapUsed,memoryHeapTotal:U.heapTotal}),X.current=K,J.current=$};return X4.useEffect(()=>{Q()},[]),J8(Q,2000),Z}function C1(Z){if(Z<50)return"green";if(Z<80)return"yellow";return"red"}function I1(Z,Y){if(Y===0)return"gray";let X=Z/Y*100;if(X<50)return"green";if(X<80)return"yellow";return"red"}var I4=P(I(),1),v2=()=>{let Z=R1(),Y=C1(Z.cpuPercent),X=I1(Z.memoryHeapUsed,Z.memoryHeapTotal);return I4.jsxDEV(_,{paddingX:1,width:"100%",children:I4.jsxDEV(_,{gap:2,children:[I4.jsxDEV(_,{children:[I4.jsxDEV(O,{dimColor:!0,children:"CPU:"},void 0,!1,void 0,this),I4.jsxDEV(O,{color:Y,children:[" ",Z.cpuPercent.toFixed(0),"%"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),I4.jsxDEV(_,{children:[I4.jsxDEV(O,{dimColor:!0,children:"MEM:"},void 0,!1,void 0,this),I4.jsxDEV(O,{color:X,children:[Q8(Z.memoryHeapUsed),"/",Q8(Z.memoryRSS)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},v1=v2;var qZ=P(I(),1);import D2 from"path";var V2=()=>{let{extraParams:Z,compactMode:Y,showDetailedInfo:X}=UZ(),{currentChatId:J,renderMessages:Q}=WZ(),{loading:$,stopGeneration:K}=WZ(),U=process.env.YOLO_MODE==="true",[W,z]=k4.useState(0);k4.useEffect(()=>{let w=async()=>{let B=await V1.getProcessList();z(B.length)};w();let L=setInterval(w,2000);return()=>clearInterval(L)},[]);let H=k4.useCallback((w,L)=>{if(L.ctrl&&w==="c")process.exit()},[$,K]);uZ(H);let G=P1($),F=k4.default.useMemo(()=>{return D2.basename(process.cwd())},[]),N=(Q?.length||0)>100;return qZ.jsxDEV(_,{flexDirection:"column",width:"100%",children:[qZ.jsxDEV(_,{paddingX:1,paddingY:0,justifyContent:"space-between",width:"100%",marginBottom:1,children:[qZ.jsxDEV(_,{gap:1,children:[$&&qZ.jsxDEV(O,{color:"yellow",bold:!0,children:qZ.jsxDEV(D1,{text:"LOADING"},void 0,!1,void 0,this)},void 0,!1,void 0,this),!$&&qZ.jsxDEV(O,{color:"magenta",bold:!0,children:"Zen Code"},void 0,!1,void 0,this),qZ.jsxDEV(O,{color:"cyan",bold:!0,children:[" ",Z.model_id]},void 0,!0,void 0,this),qZ.jsxDEV(O,{color:"yellow",bold:!0,children:[" ","@",Z.switch_command||"default"]},void 0,!0,void 0,this),!Y&&qZ.jsxDEV(O,{color:"blue",bold:!0,children:[" ","[FULL]"]},void 0,!0,void 0,this),U&&qZ.jsxDEV(O,{color:"red",bold:!0,children:[" ","YOLO"]},void 0,!0,void 0,this),qZ.jsxDEV(B1,{},void 0,!1,void 0,this),W>0&&qZ.jsxDEV(O,{color:"magenta",bold:!0,children:[" ","● BG (",W,")"]},void 0,!0,void 0,this),N&&qZ.jsxDEV(O,{color:"red",bold:!0,children:[" ","/summary"]},void 0,!0,void 0,this),qZ.jsxDEV(O,{color:"green",bold:!0,children:Q.length},void 0,!1,void 0,this),qZ.jsxDEV(O,{color:"blue",children:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$&&qZ.jsxDEV(_,{children:qZ.jsxDEV(O,{color:"yellow",children:L1(G)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X&&qZ.jsxDEV(v1,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},E1=V2;var a=P(I(),1),E2=()=>{let{activeView:Z}=X0();return a.jsxDEV(_,{flexDirection:"column",width:"100%",children:[a.jsxDEV(_,{flexGrow:1,flexDirection:"row",children:[a.jsxDEV(r,{name:"ChatMain",fallback:a.jsxDEV(O,{color:"yellow",children:"Chat view unavailable"},void 0,!1,void 0,this),children:Z==="chat"?a.jsxDEV(Y8,{},void 0,!1,void 0,this):null},void 0,!1,void 0,this),a.jsxDEV(r,{name:"PanelView",fallback:a.jsxDEV(O,{color:"yellow",children:"Panel unavailable"},void 0,!1,void 0,this),children:Z!=="chat"?a.jsxDEV(X8,{},void 0,!1,void 0,this):null},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a.jsxDEV(r,{name:"StatusBar",fallback:null,children:a.jsxDEV(E1,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},b2=()=>{return a.jsxDEV(r,{name:"Chat",children:a.jsxDEV(B5,{children:a.jsxDEV(E2,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},T2=()=>{return a.jsxDEV(r,{name:"AppRoot",children:a.jsxDEV(b1,{apiUrl:"http://127.0.0.1:8123",defaultAgent:"code",defaultHeaders:{},withCredentials:!1,showHistory:!1,showGraph:!1,onInitError:(Z,Y)=>{console.error(Z,Y)},fetch:C8,autoRestoreLastSession:!0,historyFilter:{metadata:{path:process.cwd()}},children:a.jsxDEV(r,{name:"TanStackQueryProvider",children:a.jsxDEV(H8,{children:a.jsxDEV(r,{name:"SettingsProvider",children:a.jsxDEV(f1,{get_allowed_models:I8,children:a.jsxDEV(r,{name:"ApprovalProvider",children:a.jsxDEV(T1,{children:a.jsxDEV(r,{name:"InteractionProvider",children:a.jsxDEV(l0,{children:a.jsxDEV(b2,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},f2=()=>a.jsxDEV(T2,{},void 0,!1,void 0,this),$8=f2;var J4=P(I(),1),j2=({error:Z})=>J4.jsxDEV(_,{flexDirection:"column",padding:2,borderStyle:"double",borderColor:"red",children:[J4.jsxDEV(O,{color:"red",bold:!0,children:"✗ Application Crashed"},void 0,!1,void 0,this),J4.jsxDEV(_,{marginTop:1,children:J4.jsxDEV(O,{color:"red",children:Z.message},void 0,!1,void 0,this)},void 0,!1,void 0,this),J4.jsxDEV(_,{marginTop:1,children:J4.jsxDEV(O,{color:"gray",children:["Stack: ",Z.stack?.split(`
323
+ `;return{success:J.success,message:X,shouldClearInput:!0}}};var l3={name:"errors",description:"打开错误日志面板",aliases:["error","err"],usage:"/errors",execute:async($,Z)=>{return Z.switchToErrors?.(),{success:!0,message:"打开错误日志面板",shouldClearInput:!0}}};[...S3,...D3,...V3,...j3,...h3,...g3,...u3,p3,m3,c3,d3,l3].forEach(($)=>{G0.register($)});var O0=A(M(),1),i3=($)=>{let{onCommandExecuted:Z,switchToHistory:Y,switchToKnowledge:J,switchToSettings:X,switchToAgent:K,closePanel:Q,switchToTask:W,switchToModelProvider:_,switchToMcp:O,switchToProcess:N,switchToErrors:U}=$,{userInput:F,setUserInput:L,sendMessage:q,currentAgent:w,client:R,createNewChat:P,renderMessages:S}=Z1(),{extraParams:u,updateConfig:m,AVAILABLE_MODELS:e,compactMode:v}=t(),[i,r]=W$.useState(null),[I,j]=W$.useState(null);B1(()=>{r(null)},i?3000:null),B1(()=>{j(null)},I?5000:null);let x=F.startsWith("/"),A1=x?G0.getSuggestions(F):[],F0=x,p$=W$.useCallback(async(_$)=>{let r0=_$||F;if(!G0.isCommand(r0))return!1;try{let n0={userInput:r0,setUserInput:L,sendMessage(m$,y6={}){return q(m$,{extraParams:{...u,...y6.extraParams},...y6,metadata:r1})},currentAgent:w,client:R,extraParams:u,createNewChat(){return P(r1)},updateConfig:m,AVAILABLE_MODELS:e,renderMessages:S,compactMode:v,switchToHistory:Y,switchToKnowledge:J,switchToSettings:X,switchToModelProvider:_,switchToAgent:K,switchToTask:W,switchToMcp:O,switchToProcess:N,switchToErrors:U,closePanel:Q,startRalphLoop:$.startRalphLoop},L0=await G0.executeCommand(r0,n0);if(!L0.success)r(L0.message||"命令执行失败");else if(L0.message)j(L0.message);if(L0.shouldClearInput)L("");if(L0.shouldSendMessage&&L0.messageContent){let m$=[{type:"human",content:L0.messageContent}];q(m$,{extraParams:u})}return Z?.(),!0}catch(n0){return r(`命令执行错误: ${n0 instanceof Error?n0.message:String(n0)}`),!0}},[F,L,q,w,R,u,P,Z,e,v,Y,J,X,_,K,W,O,N,U,Q,$.startRalphLoop]);return{isCommandInput:x,commandSuggestions:A1,showCommandHint:F0,commandError:i,executeCommand:p$,CommandHintUI:()=>{if(!F0||A1.length===0)return null;return O0.jsxDEV(z,{marginBottom:1,flexDirection:"column",children:[O0.jsxDEV(G,{color:"yellow",bold:!0,children:"命令建议:"},void 0,!1,void 0,this),A1.slice(0,5).map((_$,r0)=>O0.jsxDEV(G,{color:"cyan",children:[_$.displayText," - ",_$.description]},r0,!0,void 0,this)),A1.length>5&&O0.jsxDEV(G,{color:"gray",children:["...还有 ",A1.length-5," 个命令"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},CommandErrorUI:()=>{if(!i)return null;return O0.jsxDEV(z,{marginBottom:1,children:O0.jsxDEV(G,{color:"red",children:["❌ ",i]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},CommandSuccessUI:()=>{if(!I)return null;return O0.jsxDEV(z,{marginBottom:1,children:O0.jsxDEV(G,{color:"green",children:["✅ ",I]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}}};function o3({manager:$,enabled:Z=!0}){return y$({queryKey:T$.skills.list(),queryFn:async()=>{if(!$)throw Error("ConfigManager not initialized");return await $.listSkills()},enabled:Z&&!!$,staleTime:120000})}var V5=[{id:"agents/default",name:"Jarvis",description:"代码实现助手"},{id:"agents/manager",name:"Manager",description:"任务管理员"}];function r3({enabled:$=!0}={}){return y$({queryKey:T$.agents.list(),queryFn:async()=>{return V5},enabled:$,staleTime:300000})}var x1=A(D(),1);function n3({loading:$,renderMessages:Z,sendMessage:Y,setUserInput:J,extraParams:X}){let[K,Q]=x1.useState(null),[W,_]=x1.useState(!1),O=x1.useRef(!1),N=x1.useRef(0),U=x1.useCallback(async(L)=>{if(!L)return;let q=O.current?`
324
+
325
+ [System Context: You are currently in Ralph loop mode. Continue executing the task based on previous context. Respond with <COMPLETE></COMPLETE> tag when the task is complete.]`:"",w=[{type:"human",content:L+q}];await Y(w,{extraParams:X,metadata:r1})},[Y,X]);B1(()=>{if(K)U(K);_(!1)},W?100:null);let F=x1.useCallback((L)=>{Q(L),O.current=!0,N.current=0,_(!0)},[]);return x1.useEffect(()=>{if(O.current&&K&&!$){let L=Z.length;if(L>N.current){N.current=L;let q=Z[L-1],w=g0(q);if(typeof w==="string"&&w.includes("<COMPLETE></COMPLETE>"))O.current=!1,Q(null),J0("Ralph 循环完成");else U(K)}}},[$,Z,K,U]),{ralphLoopText:K,startRalphLoop:F,sendTextMessage:U}}var $0=A(D(),1);import{execa as g5}from"execa";var G1=[];for(let $=0;$<256;++$)G1.push(($+256).toString(16).slice(1));function a3($,Z=0){return(G1[$[Z+0]]+G1[$[Z+1]]+G1[$[Z+2]]+G1[$[Z+3]]+"-"+G1[$[Z+4]]+G1[$[Z+5]]+"-"+G1[$[Z+6]]+G1[$[Z+7]]+"-"+G1[$[Z+8]]+G1[$[Z+9]]+"-"+G1[$[Z+10]]+G1[$[Z+11]]+G1[$[Z+12]]+G1[$[Z+13]]+G1[$[Z+14]]+G1[$[Z+15]]).toLowerCase()}import{randomFillSync as j5}from"crypto";var V$=new Uint8Array(256),D$=V$.length;function w6(){if(D$>V$.length-16)j5(V$),D$=0;return V$.slice(D$,D$+=16)}import{randomUUID as h5}from"crypto";var M6={randomUUID:h5};function E5($,Z,Y){if(M6.randomUUID&&!Z&&!$)return M6.randomUUID();$=$||{};let J=$.random??$.rng?.()??w6();if(J.length<16)throw Error("Random bytes length must be >= 16");if(J[6]=J[6]&15|64,J[8]=J[8]&63|128,Z){if(Y=Y||0,Y<0||Y+16>Z.length)throw RangeError(`UUID byte range ${Y}:${Y+15} is out of buffer bounds`);for(let X=0;X<16;++X)Z[Y+X]=J[X];return Z}return a3(J)}var R6=E5;var p5=new Map;async function t3($){let{command:Z,cwd:Y,timeout:J}=$,X=R6();try{let K=process.platform==="win32",_=g5(K?"cmd.exe":"/bin/bash",[...K?["/d","/s","/c"]:["-c"],Z],{cwd:Y,detached:!0,reject:!1,windowsVerbatimArguments:K,timeout:J});if(!_.pid)return{id:X,pid:0,output:"Error: Failed to start command",status:"failed",exitCode:-1};let O={process:_,stdout:[],stderr:[],command:Z,startTime:Date.now()};s3.set(_.pid,O),p5.set(X,_.pid);let N=[];_.stdout?.on("data",(F)=>{let L=F.toString();N.push(L),O.stdout.push(L)}),_.stderr?.on("data",(F)=>{let L=F.toString();N.push(L),O.stderr.push(L)}),_.on("close",(F)=>{O.status=F===0?"completed":"failed",O.exitCode=F}),await new Promise((F)=>setTimeout(F,100));let U=O.status||"running";return{id:X,pid:_.pid,output:N.join(""),status:U,exitCode:O.exitCode}}catch(K){let Q=K instanceof Error?K.message:"Unknown error";return{id:X,pid:0,output:`Error: ${Q}`,status:"failed",exitCode:-1}}}var m5=["vim","nano","less","more","top","htop","git commit","git rebase -i","crontab -e","vi","emacs"],c5=($)=>{let Z=$.toLowerCase().trim(),Y=Z.split(/\s+/);for(let J of m5)if(Z===J||Z.startsWith(J+" "))return`⚠️ 交互式命令不支持,请使用非交互模式:
326
+ `+' 例如: git commit -m "message" 或使用 --no-edit 参数';if(Y[0]==="git"&&Y[1]==="commit"){if(!(Y.includes("-m")||Y.includes("--message")||Y.includes("--amend")||Y.includes("--no-edit")))return`⚠️ 交互式命令不支持,请使用非交互模式:
327
+ `+' 例如: git commit -m "message" 或使用 --no-edit 参数'}return null};var e3=()=>{let[$,Z]=$0.useState(null),[Y,J]=$0.useState(!1),X=$0.useRef(null);$0.useEffect(()=>{return()=>{if(X.current)clearTimeout(X.current)}},[]);let K=$0.useCallback(()=>{if(Z(null),J(!1),X.current)clearTimeout(X.current),X.current=null},[]);return{executeCommand:$0.useCallback(async(W)=>{let _=W.trim();if(!_)return null;let O=c5(_);if(O)return Z({id:"",command:_,output:O,status:"failed"}),J(!1),$;J(!0);try{let N=await t3({command:_,cwd:process.cwd()}),U={id:N.id,command:_,output:N.output||"",status:N.status||"completed",exitCode:N.exitCode,pid:N.pid};if(Z(U),J(!1),U.status==="completed"||U.status==="failed")X.current=setTimeout(()=>{K()},5000);return U}catch(N){let U=N instanceof Error?N.message:"Unknown error",F={id:"",command:_,output:`Error executing command: ${U}`,status:"failed"};return Z(F),J(!1),X.current=setTimeout(()=>{K()},5000),F}},[K,$]),activeCommand:$,clearOutput:K,isExecuting:Y}};var W1=A(D(),1);var V0=A(D(),1);import b6 from"fuzzysort";function u5($,Z){if(Z===0)return!0;let Y=$[Z-1];return Y===" "||Y===`
328
+ `||Y==="\t"}function x5($,Z){let Y=Z+1;while(Y<$.length&&!/[\s\n\t]/.test($[Y]))Y++;return $.slice(Z+1,Y)}function d5($,Z,Y){if(!Z)return $.slice(0,Y).map((Q)=>({skill:Q,result:null}));let J=$.map((Q)=>({skill:Q,name:b6.prepare(Q.name.toLowerCase()),description:b6.prepare((Q.description||"").toLowerCase())}));return b6.go(Z.toLowerCase(),J,{key:"name",limit:Y,threshold:-1e4}).map((Q)=>({skill:Q.obj.skill,result:Q}))}function $Z({skills:$,maxSuggestions:Z=5}){let[Y,J]=V0.useState({visible:!1,query:"",filteredSkills:[],triggerPosition:-1}),X=V0.useCallback((O,N)=>{let U=O.lastIndexOf("#");if(U===-1){J((q)=>({...q,visible:!1,query:"",filteredSkills:[],triggerPosition:-1}));return}if(!u5(O,U)){J((q)=>({...q,visible:!1,query:"",filteredSkills:[],triggerPosition:-1}));return}let F=x5(O,U),L=d5($,F,Z);if(L.length===1&&L[0].skill.name.toLowerCase()===F.toLowerCase()){J((q)=>({...q,visible:!1,query:"",filteredSkills:[],triggerPosition:-1}));return}J((q)=>({...q,visible:!0,query:F,filteredSkills:L,triggerPosition:U}))},[$.length,Z]),K=V0.useCallback(()=>{if(!Y.visible||Y.filteredSkills.length===0)return null;return Y.filteredSkills[0]?.skill??null},[Y.visible,Y.filteredSkills]),Q=V0.useCallback((O)=>{let N=K();if(!N)return O;let U=O.slice(0,Y.triggerPosition),F=O.slice(Y.triggerPosition+1+Y.query.length);return`${U}#${N.name} ${F}`},[K,Y.triggerPosition,Y.query]),W=V0.useCallback(()=>{J((O)=>({...O,visible:!1,query:"",filteredSkills:[],triggerPosition:-1}))},[]),_=Y.visible&&Y.filteredSkills.length>0;return{state:Y,checkTrigger:X,getFirstSkill:K,complete:Q,hide:W,isActive:_}}var j0=A(D(),1);function l5($,Z){if(Z===0)return!0;let Y=$[Z-1];return Y===" "||Y===`
329
+ `||Y==="\t"}function i5($,Z){let Y=Z+1;while(Y<$.length&&!/[\s\n\t]/.test($[Y]))Y++;return $.slice(Z+1,Y)}function o5($,Z,Y){let J=Z.toLowerCase(),X=$.filter((K)=>{let Q=K.name.toLowerCase(),W=K.id.toLowerCase();return Q.startsWith(J)||W.includes(J)});return X.sort((K,Q)=>K.name.localeCompare(Q.name)),X.slice(0,Y)}function ZZ({agents:$,maxSuggestions:Z=5}){let[Y,J]=j0.useState({visible:!1,query:"",filteredAgents:[],triggerPosition:-1}),X=j0.useCallback((O,N)=>{let U=O.lastIndexOf("@");if(U===-1){J((q)=>({...q,visible:!1,query:"",filteredAgents:[],triggerPosition:-1}));return}if(!l5(O,U)){J((q)=>({...q,visible:!1,query:"",filteredAgents:[],triggerPosition:-1}));return}let F=i5(O,U),L=o5($,F,Z);if(L.length===1&&L[0].name.toLowerCase()===F.toLowerCase()){J((q)=>({...q,visible:!1,query:"",filteredAgents:[],triggerPosition:-1}));return}J((q)=>({...q,visible:!0,query:F,filteredAgents:L,triggerPosition:U}))},[$.length,Z]),K=j0.useCallback(()=>{if(!Y.visible||Y.filteredAgents.length===0)return null;return Y.filteredAgents[0]??null},[Y.visible,Y.filteredAgents]),Q=j0.useCallback((O)=>{let N=K();if(!N)return O;let U=O.slice(0,Y.triggerPosition),F=O.slice(Y.triggerPosition+1+Y.query.length);return`${U}@${N.name} ${F}`},[K,Y.triggerPosition,Y.query]),W=j0.useCallback(()=>{J((O)=>({...O,visible:!1,query:"",filteredAgents:[],triggerPosition:-1}))},[]),_=Y.visible&&Y.filteredAgents.length>0;return{state:Y,checkTrigger:X,getFirstAgent:K,complete:Q,hide:W,isActive:_}}var YZ=A(D(),1);var v1=A(M(),1);function r5({name:$,result:Z}){if(!Z)return v1.jsxDEV(G,{color:"cyan",children:$},void 0,!1,void 0,this);let Y=Z.highlight((J)=>v1.jsxDEV(G,{color:"green",bold:!0,children:J},void 0,!1,void 0,this));if(Array.isArray(Y))return v1.jsxDEV(G,{color:"cyan",children:Y.map((J,X)=>{if(typeof J==="string")return v1.jsxDEV(G,{children:J},`p-${X}`,!1,void 0,this);return v1.jsxDEV(YZ.default.Fragment,{children:J},`m-${X}`,!1,void 0,this)})},void 0,!1,void 0,this);return v1.jsxDEV(G,{color:"cyan",children:$},void 0,!1,void 0,this)}var XZ=({visible:$,skills:Z,query:Y,maxVisible:J=5})=>{if(!$||Z.length===0)return null;let X=Z.slice(0,J);return v1.jsxDEV(z,{marginBottom:1,flexDirection:"column",children:[v1.jsxDEV(G,{color:"yellow",bold:!0,children:"技能建议 (按 → 补全):"},void 0,!1,void 0,this),X.map(({skill:K,result:Q})=>v1.jsxDEV(z,{children:[v1.jsxDEV(G,{children:" #"},void 0,!1,void 0,this),v1.jsxDEV(r5,{name:K.name,result:Q},void 0,!1,void 0,this)]},K.name,!0,void 0,this)),Z.length>J&&v1.jsxDEV(G,{color:"gray",children:["...还有 ",Z.length-J," 个技能"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};var L1=A(M(),1);function n5({name:$,query:Z}){if(!Z)return L1.jsxDEV(G,{color:"magenta",children:$},void 0,!1,void 0,this);let Y=$.toLowerCase(),J=Z.toLowerCase();if(Y.startsWith(J))return L1.jsxDEV(L1.Fragment,{children:[L1.jsxDEV(G,{color:"green",bold:!0,children:$.slice(0,Z.length)},void 0,!1,void 0,this),L1.jsxDEV(G,{color:"magenta",children:$.slice(Z.length)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return L1.jsxDEV(G,{color:"magenta",children:$},void 0,!1,void 0,this)}var JZ=({visible:$,agents:Z,query:Y,maxVisible:J=5})=>{if(!$||Z.length===0)return null;let X=Z.slice(0,J);return L1.jsxDEV(z,{marginBottom:1,flexDirection:"column",children:[L1.jsxDEV(G,{color:"yellow",bold:!0,children:"Agent 建议 (按 → 补全):"},void 0,!1,void 0,this),X.map((K)=>L1.jsxDEV(z,{children:[L1.jsxDEV(G,{children:" @"},void 0,!1,void 0,this),L1.jsxDEV(n5,{name:K.name,query:Y},void 0,!1,void 0,this),L1.jsxDEV(G,{dimColor:!0,children:[" - ",K.description]},void 0,!0,void 0,this)]},K.id,!0,void 0,this)),Z.length>J&&L1.jsxDEV(G,{color:"gray",children:["...还有 ",Z.length-J," 个 Agent"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};import KZ from"chalk";function a5($){if($.length===0)return[];let Z=[];if($.startsWith("/")){let Y=$.indexOf(" ");if(Y===-1)return Z.push({type:"command",value:$}),Z;let J=$.slice(0,Y),X=$.slice(Y);return Z.push({type:"command",value:J}),Z.push(...QZ(X,"args")),Z}return Z.push(...QZ($,"text")),Z}function QZ($,Z){let Y=[],J=/(^|(?<=\s))(#[\w-]+)/g,X=0,K;while((K=J.exec($))!==null){let Q=K[2],W=K.index+K[1].length;if(W>X)Y.push({type:Z,value:$.slice(X,W)});Y.push({type:"skill",value:Q}),X=W+Q.length}if(X<$.length)Y.push({type:Z,value:$.slice(X)});return Y}function s5($){return $.map(({type:Z,value:Y})=>{switch(Z){case"command":return KZ.cyan.bold(Y);case"args":return Y;case"skill":return KZ.green.bold(Y);case"text":return Y}}).join("")}function WZ($){if($.length===0)return $;let Z=a5($);return s5(Z)}var GZ=A(D(),1);function OZ(){let{extraParams:$}=t(),{sendMessage:Z,loading:Y}=Z1(),{bufferedMessage:J,clearBuffer:X}=j$(),K=_Z();GZ.useEffect(()=>{if(!Y&&J.trim()){let Q=[{type:"human",content:J}];X(),Z(Q,{extraParams:$}).then(()=>{J0("Zen Code 完成任务")}).catch((W)=>{console.error("Failed to send buffered message:",W)})}},[Y,J,Z,$,X,K])}var U0=A(M(),1),UZ=({value:$,onChange:Z,onSubmit:Y,loading:J,placeholder:X="输入消息...",commandHandler:K,skills:Q=[],agents:W=[]})=>{OZ();let{bufferedMessage:_,setBufferedMessage:O,clearBuffer:N}=j$(),[U,F]=W1.useState($),L=W1.useRef(!1),q=$Z({skills:Q,maxSuggestions:5}),w=ZZ({agents:W,maxSuggestions:5});W1.useEffect(()=>{if($!==U)L.current=!0,F($)},[$]);let R=W1.useMemo(()=>U.startsWith("/"),[U]),P=W1.useMemo(()=>U.startsWith("/")&&!U.includes(" "),[U]);W1.useEffect(()=>{if(!P)q.checkTrigger(U),w.checkTrigger(U)},[U,P]);let S=W1.useCallback((I)=>{if(L.current){L.current=!1;return}F(I),Z(I)},[Z]),u=W1.useCallback((I)=>{if(!I.trim())return;if(q.hide(),w.hide(),R){Y(I),F("");return}if(J)O(I),F("");else Y(I),F("")},[R,J,Y,O,q,w]),m=W1.useCallback(()=>{if(w.isActive){w.hide();return}if(q.isActive){q.hide();return}if(_)N();else F("")},[_,N,q.isActive,w.isActive]),e=W1.useCallback(()=>{if(!R||!K.commandSuggestions||K.commandSuggestions.length===0)return!1;let j=K.commandSuggestions[0],A1=(j.displayText||j.command||"")+" ";return S(A1),!0},[R,K.commandSuggestions,S]),v=W1.useCallback(()=>{if(!q.isActive)return!1;let I=q.complete(U);return S(I),q.hide(),!0},[q.isActive,U,S]),i=W1.useCallback(()=>{if(!w.isActive)return!1;let I=w.complete(U);return S(I),w.hide(),!0},[w.isActive,U,S]),r=W1.useMemo(()=>{if(J)return _?"按 Esc 清空缓冲区":"AI 响应中,Enter 将消息加入缓冲区";if(R)return"输入命令... (试试 /help,按 → 补全第一个建议)";if(w.isActive)return"按 → 补全 Agent";if(q.isActive)return"按 → 补全技能";return X},[J,_,R,w.isActive,q.isActive,X]);return U0.jsxDEV(z,{flexDirection:"column",children:[_&&U0.jsxDEV(z,{padding:1,children:U0.jsxDEV(G,{color:"yellow",children:["\uD83D\uDCDD 缓冲区: ",_.slice(0,50),_.length>50?"...":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),U0.jsxDEV(K.CommandHintUI,{},void 0,!1,void 0,this),U0.jsxDEV(JZ,{visible:w.state.visible,agents:w.state.filteredAgents,query:w.state.query},void 0,!1,void 0,this),U0.jsxDEV(XZ,{visible:q.state.visible,skills:q.state.filteredSkills,query:q.state.query},void 0,!1,void 0,this),U0.jsxDEV(z,{paddingY:1,children:U0.jsxDEV(h1,{id:"global-input",value:U,onChange:S,onSubmit:u,colorizeContent:WZ,onHotKey:(I,j)=>{if(j.escape)return m(),!1;if(j.rightArrow){if(w.isActive){if(i())return!1}if(q.isActive){if(v())return!1}if(e())return!1}return!0},placeholder:r},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};var h$=A(D(),1);var U1=A(M(),1);var t5=($)=>{switch($){case"running":return{icon:"⏳",color:"yellow"};case"completed":return{icon:"✓",color:"green"};case"failed":return{icon:"✗",color:"red"}}},e5=($,Z=10)=>{if(!$)return"";let Y=$.split(`
330
+ `);if(Y.length<=Z)return $;return[...Y.slice(0,Z),"... (more)"].join(`
331
+ `)},B6=h$.memo(({commandResult:$,onClose:Z,onStop:Y})=>{let{exit:J}=NZ();if(h$.useEffect(()=>{let w=(R)=>{if(R.key==="escape")Z()};return process.stdin.on("keypress",w),()=>{process.stdin.off("keypress",w)}},[Z]),!$)return null;let{command:X,output:K,status:Q,pid:W}=$,{icon:_,color:O}=t5(Q),N=e5(K,10),U=U1.jsxDEV(z,{justifyContent:"space-between",children:[U1.jsxDEV(z,{children:U1.jsxDEV(G,{bold:!0,color:"cyan",children:["\uD83D\uDCDF $ ",X]},void 0,!0,void 0,this)},void 0,!1,void 0,this),U1.jsxDEV(z,{children:[Q==="running"&&Y&&U1.jsxDEV(G,{bold:!0,color:"red",children:[" ","[⏹ 停止]"]},void 0,!0,void 0,this),U1.jsxDEV(G,{bold:!0,color:"gray",children:[" ","[×]"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),F=U1.jsxDEV(z,{flexDirection:"column",marginTop:0,children:N.split(`
332
+ `).map((w,R)=>U1.jsxDEV(z,{children:U1.jsxDEV(G,{color:"gray",children:w},void 0,!1,void 0,this)},R,!1,void 0,this))},void 0,!1,void 0,this),L=U1.jsxDEV(z,{justifyContent:"space-between",marginTop:0,children:[U1.jsxDEV(G,{color:O,children:[_," ",Q==="running"?"Running...":Q.charAt(0).toUpperCase()+Q.slice(1)]},void 0,!0,void 0,this),W&&U1.jsxDEV(G,{color:"gray",children:["PID: ",W]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return U1.jsxDEV(z,{flexDirection:"column",paddingX:1,paddingY:0,borderStyle:"single",borderColor:"gray",width:"100%",children:[U,U1.jsxDEV(z,{children:U1.jsxDEV(G,{color:"gray",children:"────────────────────────────────────────────────────────"},void 0,!1,void 0,this)},void 0,!1,void 0,this),N&&F,L]},void 0,!0,void 0,this)});B6.displayName="ShellOutputPreview";var o0=A(M(),1),P6=E$.memo(()=>{let{userInput:$,setUserInput:Z,loading:Y,renderMessages:J,sendMessage:X}=Z1(),{extraParams:K,manager:Q}=t(),{executeCommand:W,activeCommand:_,clearOutput:O,isExecuting:N}=e3(),{switchToHistory:U,switchToKnowledge:F,switchToSettings:L,switchToModelProvider:q,switchToAgent:w,switchToTask:R,switchToMcp:P,switchToProcess:S,switchToErrors:u,closePanel:m}=E0(),{data:e=[]}=o3({manager:Q}),{data:v=[]}=r3(),{startRalphLoop:i}=n3({loading:Y,renderMessages:J,sendMessage:X,setUserInput:Z,extraParams:K}),r=i3({extraParams:K,switchToHistory:U,switchToKnowledge:F,switchToSettings:L,switchToModelProvider:q,switchToAgent:w,switchToTask:R,switchToMcp:P,switchToProcess:S,switchToErrors:u,closePanel:m,startRalphLoop:i}),I=E$.useCallback(async(j)=>{if(!j)return;if(j.startsWith("!")){let x=j.slice(1).trim();if(x)await W(x),Z("");return}if(j.startsWith("/")){if(await r.executeCommand(j)){Z("");return}}await X([{type:"human",content:j}],{extraParams:K,metadata:r1}),J0("Zen Code 完成任务")},[r,Z,W,K,X]);return o0.jsxDEV(z,{flexDirection:"column",paddingX:0,paddingY:0,borderColor:"grey",borderTop:!0,borderStyle:"single",borderLeft:!1,borderBottom:!1,borderRight:!1,children:[_&&o0.jsxDEV(B6,{commandResult:_,onClose:O},void 0,!1,void 0,this),o0.jsxDEV(r.CommandErrorUI,{},void 0,!1,void 0,this),o0.jsxDEV(r.CommandSuccessUI,{},void 0,!1,void 0,this),o0.jsxDEV(UZ,{value:$,onChange:Z,onSubmit:I,loading:Y,commandHandler:{isCommandInput:r.isCommandInput,CommandHintUI:r.CommandHintUI,commandSuggestions:r.commandSuggestions},skills:e,agents:v},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});P6.displayName="ChatInput";var S1=A(M(),1),$X=()=>{let{renderMessages:$,currentChatId:Z,getToolUIRender:Y,loading:J}=Z1(),{compactMode:X}=t(),[K]=zZ($,50),Q=FZ.useCallback((W)=>Y(W),[Y]);return S1.jsxDEV(z,{flexDirection:"column",flexGrow:1,paddingX:0,paddingY:0,children:[K.length===0&&S1.jsxDEV(f3,{},void 0,!1,void 0,this),K.length?X?S1.jsxDEV(A6,{renderMessages:K,startIndex:0,staticKey:Z,getToolUIRender:Q,loading:J},Z,!1,void 0,this):S1.jsxDEV(M3,{loading:J,renderMessages:K,startIndex:0,staticKey:Z},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},f6=()=>{let{hasPendingInteractions:$}=k1();return S1.jsxDEV(z,{flexDirection:"column",flexGrow:1,children:[S1.jsxDEV(g,{name:"ChatMessages",fallback:null,children:S1.jsxDEV($X,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),S1.jsxDEV(HZ,{children:S1.jsxDEV(g,{name:"InteractionArea",fallback:null,children:$?S1.jsxDEV(z,{paddingX:0,paddingY:0,children:S1.jsxDEV(J6,{},void 0,!1,void 0,this)},void 0,!1,void 0,this):S1.jsxDEV(P6,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};f6.displayName="ChatMain";var D1=A(D(),1);var Z0=A(D(),1),LZ=Z0.lazy(()=>import("./chunk-b8dxq9rq.js").then(($)=>({default:$.default}))),AZ=Z0.lazy(()=>import("./chunk-cjqarwdn.js").then(($)=>({default:$.default}))),qZ=Z0.lazy(()=>import("./chunk-xkz5z0zn.js").then(($)=>({default:$.default}))),wZ=Z0.lazy(()=>import("./chunk-6rfc36jg.js").then(($)=>({default:$.default}))),MZ=Z0.lazy(()=>import("./chunk-zz32kgt2.js").then(($)=>({default:$.default}))),RZ=Z0.lazy(()=>import("./chunk-f8ewggk1.js").then(($)=>({default:$.default}))),bZ=Z0.lazy(()=>import("./chunk-wn43r152.js").then(($)=>({default:$.default}))),BZ=Z0.lazy(()=>import("./chunk-jbf8ve63.js").then(($)=>({default:$.default}))),PZ=Z0.lazy(()=>import("./chunk-j9aysaeb.js").then(($)=>({default:$.default})));var k=A(M(),1),N0=()=>k.jsxDEV(z,{paddingX:1,paddingY:1,children:k.jsxDEV(G,{color:"grey",children:"Loading..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),z0=($)=>k.jsxDEV(z,{paddingX:1,paddingY:1,children:[k.jsxDEV(G,{color:"red",children:["✗ ",$," panel error"]},void 0,!0,void 0,this),k.jsxDEV(z,{marginTop:1,children:k.jsxDEV(G,{color:"gray",children:"Try reopening or press ESC to return"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C6=D1.memo(()=>{let{activeView:$,closePanel:Z,handleExecuteTask:Y}=E0();return k.jsxDEV(z,{flexGrow:1,flexDirection:"row",children:[$==="history"&&k.jsxDEV(D1.Suspense,{fallback:k.jsxDEV(N0,{},void 0,!1,void 0,this),children:k.jsxDEV(g,{name:"HistoryPanel",fallback:z0("History"),children:k.jsxDEV(LZ,{onClose:Z},void 0,!1,void 0,this)},"history-panel",!1,void 0,this)},"history-suspense",!1,void 0,this),$==="knowledge"&&k.jsxDEV(D1.Suspense,{fallback:k.jsxDEV(N0,{},void 0,!1,void 0,this),children:k.jsxDEV(g,{name:"KnowledgePanel",fallback:z0("Knowledge"),children:k.jsxDEV(AZ,{onClose:Z},void 0,!1,void 0,this)},"knowledge-panel",!1,void 0,this)},"knowledge-suspense",!1,void 0,this),$==="settings"&&k.jsxDEV(D1.Suspense,{fallback:k.jsxDEV(N0,{},void 0,!1,void 0,this),children:k.jsxDEV(g,{name:"SettingsPanel",fallback:z0("Settings"),children:k.jsxDEV(qZ,{onClose:Z},void 0,!1,void 0,this)},"settings-panel",!1,void 0,this)},"settings-suspense",!1,void 0,this),$==="model-provider"&&k.jsxDEV(D1.Suspense,{fallback:k.jsxDEV(N0,{},void 0,!1,void 0,this),children:k.jsxDEV(g,{name:"ModelProviderPanel",fallback:z0("Model Provider"),children:k.jsxDEV(wZ,{onClose:Z},void 0,!1,void 0,this)},"model-provider-panel",!1,void 0,this)},"model-provider-suspense",!1,void 0,this),$==="agent"&&k.jsxDEV(D1.Suspense,{fallback:k.jsxDEV(N0,{},void 0,!1,void 0,this),children:k.jsxDEV(g,{name:"AgentPanel",fallback:z0("Agent"),children:k.jsxDEV(MZ,{onClose:Z},void 0,!1,void 0,this)},"agent-panel",!1,void 0,this)},"agent-suspense",!1,void 0,this),$==="task"&&k.jsxDEV(D1.Suspense,{fallback:k.jsxDEV(N0,{},void 0,!1,void 0,this),children:k.jsxDEV(g,{name:"TaskPanel",fallback:z0("Task"),children:k.jsxDEV(RZ,{onClose:Z,onExecuteTask:Y},void 0,!1,void 0,this)},"task-panel",!1,void 0,this)},"task-suspense",!1,void 0,this),$==="mcp"&&k.jsxDEV(D1.Suspense,{fallback:k.jsxDEV(N0,{},void 0,!1,void 0,this),children:k.jsxDEV(g,{name:"McpPanel",fallback:z0("MCP"),children:k.jsxDEV(bZ,{onClose:Z},void 0,!1,void 0,this)},"mcp-panel",!1,void 0,this)},"mcp-suspense",!1,void 0,this),$==="process"&&k.jsxDEV(D1.Suspense,{fallback:k.jsxDEV(N0,{},void 0,!1,void 0,this),children:k.jsxDEV(g,{name:"ProcessPanel",fallback:z0("Process"),children:k.jsxDEV(BZ,{onClose:Z},void 0,!1,void 0,this)},"process-panel",!1,void 0,this)},"process-suspense",!1,void 0,this),$==="errors"&&k.jsxDEV(D1.Suspense,{fallback:k.jsxDEV(N0,{},void 0,!1,void 0,this),children:k.jsxDEV(g,{name:"ErrorPanel",fallback:z0("Errors"),children:k.jsxDEV(PZ,{onClose:Z},void 0,!1,void 0,this)},"errors-panel",!1,void 0,this)},"errors-suspense",!1,void 0,this)]},void 0,!0,void 0,this)});C6.displayName="LazyChatViewManager";var R0=A(D(),1);var fZ=A(D(),1);var g$=A(M(),1),CZ=()=>{let{renderMessages:$}=Z1(),Z=fZ.default.useMemo(()=>{if(!$)return null;for(let Y=$.length-1;Y>=0;Y--){let J=$[Y];if(J.role==="assistant"&&J.content)try{let K=(Array.isArray(J.content)?J.content:[{type:"text",text:J.content}]).find((Q)=>Q.type==="text")?.text||"";if(K.includes("load_mcp_tools"))try{let Q=JSON.parse(K);if(Q.status&&Q.status.toolCount!==void 0)return Q.status}catch(Q){}}catch(X){}}return null},[$]);if(!Z||Z.toolCount===0)return null;return g$.jsxDEV(z,{paddingX:1,children:[g$.jsxDEV(G,{color:"green",bold:!0,children:"MCP"},void 0,!1,void 0,this),g$.jsxDEV(G,{color:"cyan",children:[" ",Z.toolCount]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};var d1=A(D(),1);function S6($){if($===0)return"0";if($<1024)return`${$}`;if($<1048576)return`${($/1024).toFixed(0)}K`;if($<1073741824)return`${($/1048576).toFixed(0)}M`;return`${($/1073741824).toFixed(1)}G`}function vZ($){let Z=Math.floor($/1000),Y=Math.floor(Z/3600),J=Math.floor(Z%3600/60),X=Z%60;if(Y>0)return`${Y}:${String(J).padStart(2,"0")}:${String(X).padStart(2,"0")}`;return`${String(J).padStart(2,"0")}:${String(X).padStart(2,"0")}`}function SZ($){let[Z,Y]=d1.useState(0),J=d1.useRef(null);return d1.useEffect(()=>{if($)J.current=Date.now(),Y(0);else J.current=null,Y(0)},[$]),v6(()=>{if(J.current)Y(Date.now()-J.current)},$?1000:null),Z}function IZ(){let[$,Z]=d1.useState({cpuPercent:0,memoryRSS:0,memoryHeapUsed:0,memoryHeapTotal:0}),Y=d1.useRef(process.cpuUsage()),J=d1.useRef(Date.now()),X=()=>{let K=Date.now(),Q=process.cpuUsage(),W=process.memoryUsage(),_=K-J.current,O=Q.user-Y.current.user,N=Q.system-Y.current.system,F=(O+N)/1000/_*100;Z({cpuPercent:Math.min(100,Math.max(0,F)),memoryRSS:W.rss,memoryHeapUsed:W.heapUsed,memoryHeapTotal:W.heapTotal}),Y.current=Q,J.current=K};return d1.useEffect(()=>{X()},[]),v6(X,2000),$}function kZ($){if($<50)return"green";if($<80)return"yellow";return"red"}function yZ($,Z){if(Z===0)return"gray";let Y=$/Z*100;if(Y<50)return"green";if(Y<80)return"yellow";return"red"}var H0=A(M(),1),ZX=()=>{let $=IZ(),Z=kZ($.cpuPercent),Y=yZ($.memoryHeapUsed,$.memoryHeapTotal);return H0.jsxDEV(z,{paddingX:1,width:"100%",children:H0.jsxDEV(z,{gap:2,children:[H0.jsxDEV(z,{children:[H0.jsxDEV(G,{dimColor:!0,children:"CPU:"},void 0,!1,void 0,this),H0.jsxDEV(G,{color:Z,children:[" ",$.cpuPercent.toFixed(0),"%"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H0.jsxDEV(z,{children:[H0.jsxDEV(G,{dimColor:!0,children:"MEM:"},void 0,!1,void 0,this),H0.jsxDEV(G,{color:Y,children:[S6($.memoryHeapUsed),"/",S6($.memoryRSS)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},TZ=ZX;var J1=A(M(),1);import YX from"path";var XX=()=>{let{extraParams:$,compactMode:Z,showDetailedInfo:Y}=t(),{currentChatId:J,renderMessages:X}=Z1(),{loading:K,stopGeneration:Q}=Z1(),W=process.env.YOLO_MODE==="true",[_,O]=R0.useState(0);R0.useEffect(()=>{let w=async()=>{let P=await VZ.getProcessList();O(P.length)};w();let R=setInterval(w,2000);return()=>clearInterval(R)},[]);let N=R0.useCallback((w,R)=>{if(R.ctrl&&w==="c")process.exit()},[K,Q]);y1(N);let U=SZ(K),F=R0.default.useMemo(()=>{return YX.basename(process.cwd())},[]),q=(X?.length||0)>100;return J1.jsxDEV(z,{flexDirection:"column",width:"100%",children:[J1.jsxDEV(z,{paddingX:1,paddingY:0,justifyContent:"space-between",width:"100%",marginBottom:1,children:[J1.jsxDEV(z,{gap:1,children:[K&&J1.jsxDEV(G,{color:"yellow",bold:!0,children:J1.jsxDEV(DZ,{text:"LOADING"},void 0,!1,void 0,this)},void 0,!1,void 0,this),!K&&J1.jsxDEV(G,{color:"magenta",bold:!0,children:"Zen Code"},void 0,!1,void 0,this),J1.jsxDEV(G,{color:"cyan",bold:!0,children:[" ",$.model_id]},void 0,!0,void 0,this),J1.jsxDEV(G,{color:"yellow",bold:!0,children:[" ","@",$.switch_command||"default"]},void 0,!0,void 0,this),!Z&&J1.jsxDEV(G,{color:"blue",bold:!0,children:[" ","[FULL]"]},void 0,!0,void 0,this),W&&J1.jsxDEV(G,{color:"red",bold:!0,children:[" ","YOLO"]},void 0,!0,void 0,this),J1.jsxDEV(CZ,{},void 0,!1,void 0,this),_>0&&J1.jsxDEV(G,{color:"magenta",bold:!0,children:[" ","● BG (",_,")"]},void 0,!0,void 0,this),q&&J1.jsxDEV(G,{color:"red",bold:!0,children:[" ","/summary"]},void 0,!0,void 0,this),J1.jsxDEV(G,{color:"green",bold:!0,children:X.length},void 0,!1,void 0,this),J1.jsxDEV(G,{color:"blue",children:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this),K&&J1.jsxDEV(z,{children:J1.jsxDEV(G,{color:"yellow",children:vZ(U)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y&&J1.jsxDEV(TZ,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},jZ=XX;var c=A(M(),1),JX=()=>{let{activeView:$}=E0();return c.jsxDEV(z,{flexDirection:"column",width:"100%",children:[c.jsxDEV(z,{flexGrow:1,flexDirection:"row",children:[c.jsxDEV(g,{name:"ChatMain",fallback:c.jsxDEV(G,{color:"yellow",children:"Chat view unavailable"},void 0,!1,void 0,this),children:$==="chat"?c.jsxDEV(f6,{},void 0,!1,void 0,this):null},"chat-main-view",!1,void 0,this),c.jsxDEV(g,{name:"PanelView",fallback:c.jsxDEV(G,{color:"yellow",children:"Panel unavailable"},void 0,!1,void 0,this),children:$!=="chat"?c.jsxDEV(C6,{},void 0,!1,void 0,this):null},"panel-view",!1,void 0,this)]},void 0,!0,void 0,this),c.jsxDEV(g,{name:"StatusBar",fallback:null,children:c.jsxDEV(jZ,{},void 0,!1,void 0,this)},"status-bar",!1,void 0,this)]},void 0,!0,void 0,this)},KX=()=>{return c.jsxDEV(g,{name:"Chat",children:c.jsxDEV(l4,{children:c.jsxDEV(JX,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},QX=({children:$})=>{let{config:Z}=t(),Y=pZ.useMemo(()=>{let J={};if(Z){let X=Z.providers?.find((K)=>K.id===Z.provider_id);if(X){if(X.apiKey)J["x-api-key"]=X.apiKey;if(X.baseUrl)J["x-base-url"]=X.baseUrl}}return J},[Z]);return c.jsxDEV(hZ,{apiUrl:"http://127.0.0.1:8123",defaultAgent:"code",defaultHeaders:Y,withCredentials:!1,showHistory:!1,showGraph:!1,onInitError:(J,X)=>{console.error(J,X),import("./chunk-ns6tjjkq.js").then(({logAgentError:K})=>{K("ChatProvider",J)}).catch(()=>{})},fetch:n6,autoRestoreLastSession:!0,historyFilter:{metadata:{path:process.cwd()}},children:$},void 0,!1,void 0,this)},WX=()=>{return c.jsxDEV(g,{name:"AppRoot",children:c.jsxDEV(g,{name:"TanStackQueryProvider",children:c.jsxDEV(V6,{children:c.jsxDEV(g,{name:"SettingsProvider",children:c.jsxDEV(gZ,{get_allowed_models:a6,children:c.jsxDEV(QX,{children:c.jsxDEV(g,{name:"ApprovalProvider",children:c.jsxDEV(EZ,{children:c.jsxDEV(g,{name:"InteractionProvider",children:c.jsxDEV(U$,{children:c.jsxDEV(KX,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},"interaction-provider",!1,void 0,this)},void 0,!1,void 0,this)},"approval-provider",!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},"settings-provider",!1,void 0,this)},void 0,!1,void 0,this)},"tanstack-query-provider",!1,void 0,this)},"app-root",!1,void 0,this)},_X=()=>c.jsxDEV(WX,{},void 0,!1,void 0,this),I6=_X;var l1=A(M(),1),GX=({error:$})=>l1.jsxDEV(z,{flexDirection:"column",padding:2,borderStyle:"double",borderColor:"red",children:[l1.jsxDEV(G,{color:"red",bold:!0,children:"✗ Application Crashed"},void 0,!1,void 0,this),l1.jsxDEV(z,{marginTop:1,children:l1.jsxDEV(G,{color:"red",children:$.message},void 0,!1,void 0,this)},void 0,!1,void 0,this),l1.jsxDEV(z,{marginTop:1,children:l1.jsxDEV(G,{color:"gray",children:["Stack: ",$.stack?.split(`
340
333
  `).slice(0,3).join(`
341
- `)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),J4.jsxDEV(_,{marginTop:1,children:J4.jsxDEV(O,{color:"blue",children:"Press Ctrl+C to exit"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);try{K8(J4.jsxDEV($8,{},void 0,!1,void 0,this),{exitOnCtrlC:!1})}catch(Z){console.error("Critical rendering error:",Z),K8(J4.jsxDEV(j2,{error:Z},void 0,!1,void 0,this))}process.on("unhandledRejection",(Z,Y)=>{console.error("Unhandled Rejection at:",Y,"reason:",Z)});process.on("uncaughtException",(Z)=>{console.error("Uncaught Exception:",Z)});
334
+ `)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),l1.jsxDEV(z,{marginTop:1,children:l1.jsxDEV(G,{color:"blue",children:"Press Ctrl+C to exit"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);try{k6(l1.jsxDEV(I6,{},void 0,!1,void 0,this),{exitOnCtrlC:!1})}catch($){console.error("Critical rendering error:",$),k6(l1.jsxDEV(GX,{error:$},void 0,!1,void 0,this))}process.on("unhandledRejection",($,Z)=>{console.error("Unhandled Rejection at:",Z,"reason:",$)});process.on("uncaughtException",($)=>{console.error("Uncaught Exception:",$)});