@vibedeckx/linux-x64 0.1.10

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 (579) hide show
  1. package/dist/agent-provider.d.ts +92 -0
  2. package/dist/agent-provider.js +8 -0
  3. package/dist/agent-session-manager.d.ts +165 -0
  4. package/dist/agent-session-manager.js +985 -0
  5. package/dist/agent-types.d.ts +148 -0
  6. package/dist/agent-types.js +4 -0
  7. package/dist/bin.d.ts +2 -0
  8. package/dist/bin.js +4 -0
  9. package/dist/browser-manager.d.ts +46 -0
  10. package/dist/browser-manager.js +182 -0
  11. package/dist/chat-session-manager.d.ts +101 -0
  12. package/dist/chat-session-manager.js +1425 -0
  13. package/dist/command.d.ts +1 -0
  14. package/dist/command.js +163 -0
  15. package/dist/constants.d.ts +3 -0
  16. package/dist/constants.js +5 -0
  17. package/dist/conversation-patch.d.ts +103 -0
  18. package/dist/conversation-patch.js +69 -0
  19. package/dist/dialog.d.ts +1 -0
  20. package/dist/dialog.js +41 -0
  21. package/dist/entry-index-provider.d.ts +74 -0
  22. package/dist/entry-index-provider.js +105 -0
  23. package/dist/event-bus.d.ts +47 -0
  24. package/dist/event-bus.js +16 -0
  25. package/dist/index.d.ts +3 -0
  26. package/dist/index.js +2 -0
  27. package/dist/plugins/shared-services.d.ts +8 -0
  28. package/dist/plugins/shared-services.js +65 -0
  29. package/dist/process-manager.d.ts +146 -0
  30. package/dist/process-manager.js +779 -0
  31. package/dist/providers/claude-code-provider.d.ts +13 -0
  32. package/dist/providers/claude-code-provider.js +127 -0
  33. package/dist/providers/codex-provider.d.ts +41 -0
  34. package/dist/providers/codex-provider.js +354 -0
  35. package/dist/providers/index.d.ts +5 -0
  36. package/dist/providers/index.js +19 -0
  37. package/dist/remote-patch-cache.d.ts +67 -0
  38. package/dist/remote-patch-cache.js +190 -0
  39. package/dist/reverse-connect-client.d.ts +27 -0
  40. package/dist/reverse-connect-client.js +255 -0
  41. package/dist/reverse-connect-manager.d.ts +31 -0
  42. package/dist/reverse-connect-manager.js +287 -0
  43. package/dist/reverse-connect-types.d.ts +55 -0
  44. package/dist/reverse-connect-types.js +7 -0
  45. package/dist/routes/agent-session-routes.d.ts +4 -0
  46. package/dist/routes/agent-session-routes.js +442 -0
  47. package/dist/routes/browser-proxy-routes.d.ts +25 -0
  48. package/dist/routes/browser-proxy-routes.js +421 -0
  49. package/dist/routes/browser-routes.d.ts +4 -0
  50. package/dist/routes/browser-routes.js +73 -0
  51. package/dist/routes/chat-session-routes.d.ts +7 -0
  52. package/dist/routes/chat-session-routes.js +69 -0
  53. package/dist/routes/diff-routes.d.ts +4 -0
  54. package/dist/routes/diff-routes.js +208 -0
  55. package/dist/routes/event-routes.d.ts +4 -0
  56. package/dist/routes/event-routes.js +52 -0
  57. package/dist/routes/executor-group-routes.d.ts +4 -0
  58. package/dist/routes/executor-group-routes.js +76 -0
  59. package/dist/routes/executor-routes.d.ts +4 -0
  60. package/dist/routes/executor-routes.js +106 -0
  61. package/dist/routes/file-routes.d.ts +4 -0
  62. package/dist/routes/file-routes.js +331 -0
  63. package/dist/routes/process-routes.d.ts +4 -0
  64. package/dist/routes/process-routes.js +183 -0
  65. package/dist/routes/project-remote-routes.d.ts +4 -0
  66. package/dist/routes/project-remote-routes.js +82 -0
  67. package/dist/routes/project-routes.d.ts +4 -0
  68. package/dist/routes/project-routes.js +286 -0
  69. package/dist/routes/remote-routes.d.ts +4 -0
  70. package/dist/routes/remote-routes.js +59 -0
  71. package/dist/routes/remote-server-routes.d.ts +4 -0
  72. package/dist/routes/remote-server-routes.js +157 -0
  73. package/dist/routes/reverse-connect-routes.d.ts +4 -0
  74. package/dist/routes/reverse-connect-routes.js +33 -0
  75. package/dist/routes/settings-routes.d.ts +4 -0
  76. package/dist/routes/settings-routes.js +129 -0
  77. package/dist/routes/task-routes.d.ts +4 -0
  78. package/dist/routes/task-routes.js +107 -0
  79. package/dist/routes/terminal-routes.d.ts +4 -0
  80. package/dist/routes/terminal-routes.js +187 -0
  81. package/dist/routes/translate-routes.d.ts +4 -0
  82. package/dist/routes/translate-routes.js +38 -0
  83. package/dist/routes/websocket-routes.d.ts +4 -0
  84. package/dist/routes/websocket-routes.js +604 -0
  85. package/dist/routes/worktree-routes.d.ts +4 -0
  86. package/dist/routes/worktree-routes.js +511 -0
  87. package/dist/server-types.d.ts +41 -0
  88. package/dist/server-types.js +1 -0
  89. package/dist/server.d.ts +23 -0
  90. package/dist/server.js +238 -0
  91. package/dist/storage/sqlite.d.ts +2 -0
  92. package/dist/storage/sqlite.js +1073 -0
  93. package/dist/storage/types.d.ts +281 -0
  94. package/dist/storage/types.js +1 -0
  95. package/dist/ui/404/index.html +1 -0
  96. package/dist/ui/404.html +1 -0
  97. package/dist/ui/__next.__PAGE__.txt +10 -0
  98. package/dist/ui/__next._full.txt +25 -0
  99. package/dist/ui/__next._head.txt +6 -0
  100. package/dist/ui/__next._index.txt +9 -0
  101. package/dist/ui/__next._tree.txt +6 -0
  102. package/dist/ui/_next/static/7vIIuOQPJu8rdb6uAhwtg/_buildManifest.js +11 -0
  103. package/dist/ui/_next/static/7vIIuOQPJu8rdb6uAhwtg/_clientMiddlewareManifest.json +1 -0
  104. package/dist/ui/_next/static/7vIIuOQPJu8rdb6uAhwtg/_ssgManifest.js +1 -0
  105. package/dist/ui/_next/static/chunks/002f5a047b8d07d4.js +1 -0
  106. package/dist/ui/_next/static/chunks/01178e167ba3e5b4.js +1 -0
  107. package/dist/ui/_next/static/chunks/020d675d21be28d4.js +1 -0
  108. package/dist/ui/_next/static/chunks/024926197424b4a5.js +1 -0
  109. package/dist/ui/_next/static/chunks/02c93f6ca211a65d.js +1 -0
  110. package/dist/ui/_next/static/chunks/0364437dee56dc96.js +1 -0
  111. package/dist/ui/_next/static/chunks/03fc6b527b16efdc.js +1 -0
  112. package/dist/ui/_next/static/chunks/04f9a7932751cf2d.js +1 -0
  113. package/dist/ui/_next/static/chunks/0624b8204e5ae457.js +136 -0
  114. package/dist/ui/_next/static/chunks/067d8978cf41b901.js +1 -0
  115. package/dist/ui/_next/static/chunks/06d96238e85cdbb3.js +1 -0
  116. package/dist/ui/_next/static/chunks/071b9575dbdf1dcb.js +1 -0
  117. package/dist/ui/_next/static/chunks/073d5b9dc87ceab0.js +1 -0
  118. package/dist/ui/_next/static/chunks/0876a7111934d6f7.js +1 -0
  119. package/dist/ui/_next/static/chunks/08ffc3bf406c665d.js +1 -0
  120. package/dist/ui/_next/static/chunks/0969e8274c92c2d8.js +1 -0
  121. package/dist/ui/_next/static/chunks/0a3f62f00d7bec78.js +1 -0
  122. package/dist/ui/_next/static/chunks/0b80166023d89049.js +5 -0
  123. package/dist/ui/_next/static/chunks/0c2a941e61c395b6.js +1 -0
  124. package/dist/ui/_next/static/chunks/0c5eac8493334420.js +1 -0
  125. package/dist/ui/_next/static/chunks/0cc61d37b2333469.js +1 -0
  126. package/dist/ui/_next/static/chunks/0d440843348b2871.js +1 -0
  127. package/dist/ui/_next/static/chunks/0da3d15845f17208.js +1 -0
  128. package/dist/ui/_next/static/chunks/0e1982b1a6cbd127.js +53 -0
  129. package/dist/ui/_next/static/chunks/0e81d5bc1c725b75.js +1 -0
  130. package/dist/ui/_next/static/chunks/0e862e51b01e904b.js +63 -0
  131. package/dist/ui/_next/static/chunks/0ed7b6d86744b723.js +1 -0
  132. package/dist/ui/_next/static/chunks/0f0b3025f4e268b1.js +1 -0
  133. package/dist/ui/_next/static/chunks/10a30eb52825da36.js +1 -0
  134. package/dist/ui/_next/static/chunks/10c48da576fd8eef.js +1 -0
  135. package/dist/ui/_next/static/chunks/133e9f1435ca5f45.js +29 -0
  136. package/dist/ui/_next/static/chunks/16f4db3a54f167fd.js +1 -0
  137. package/dist/ui/_next/static/chunks/1988e3ecf5ad06d3.js +1 -0
  138. package/dist/ui/_next/static/chunks/1acfae010fd77014.js +152 -0
  139. package/dist/ui/_next/static/chunks/1ae53c2f1fff8cc2.js +1 -0
  140. package/dist/ui/_next/static/chunks/1af4fbc6c1256fae.js +1 -0
  141. package/dist/ui/_next/static/chunks/1b758c732032b236.js +1 -0
  142. package/dist/ui/_next/static/chunks/1ba26455a9f70c08.js +1 -0
  143. package/dist/ui/_next/static/chunks/1d22644cb4049d6b.css +1 -0
  144. package/dist/ui/_next/static/chunks/1d241f3b57c14cf7.js +1 -0
  145. package/dist/ui/_next/static/chunks/1d640bbe1c2c7869.js +1 -0
  146. package/dist/ui/_next/static/chunks/1da6354c9cb6f0de.js +1 -0
  147. package/dist/ui/_next/static/chunks/1dcd49914412f67b.js +1 -0
  148. package/dist/ui/_next/static/chunks/1e3b3771294825a4.js +1 -0
  149. package/dist/ui/_next/static/chunks/1eaa8ad7eca7f957.js +1 -0
  150. package/dist/ui/_next/static/chunks/1ebc88f60cadb128.js +1 -0
  151. package/dist/ui/_next/static/chunks/1ecb57b258088259.js +1 -0
  152. package/dist/ui/_next/static/chunks/1f5ba6b80fe19200.js +1 -0
  153. package/dist/ui/_next/static/chunks/20a5531534828366.js +1 -0
  154. package/dist/ui/_next/static/chunks/20b511fc299dfe9a.js +1 -0
  155. package/dist/ui/_next/static/chunks/20bff4eb9a0a6872.css +1 -0
  156. package/dist/ui/_next/static/chunks/219b7d9e437c6bd8.js +15 -0
  157. package/dist/ui/_next/static/chunks/21b32f530e0df2c5.js +1 -0
  158. package/dist/ui/_next/static/chunks/21fc6dc60e7647b1.js +1 -0
  159. package/dist/ui/_next/static/chunks/221a27e65aa5fbfd.js +1 -0
  160. package/dist/ui/_next/static/chunks/23a1e247c32bcc61.js +93 -0
  161. package/dist/ui/_next/static/chunks/2473c16c0c2f6b5f.css +2 -0
  162. package/dist/ui/_next/static/chunks/2615c71c0f8fe9bd.js +1 -0
  163. package/dist/ui/_next/static/chunks/263327288d5e2703.js +1 -0
  164. package/dist/ui/_next/static/chunks/2663fbaf43239e38.js +1 -0
  165. package/dist/ui/_next/static/chunks/27332c590d59f4e5.js +1 -0
  166. package/dist/ui/_next/static/chunks/27ca4a4e8191093f.js +1 -0
  167. package/dist/ui/_next/static/chunks/29b7618dcaa8edba.js +1 -0
  168. package/dist/ui/_next/static/chunks/2ba1d2b55b82f4da.js +21 -0
  169. package/dist/ui/_next/static/chunks/2cb23686e72468c8.js +1 -0
  170. package/dist/ui/_next/static/chunks/2d46f05dcbf1cbc2.js +1 -0
  171. package/dist/ui/_next/static/chunks/2d4c0fd06ca34510.js +2 -0
  172. package/dist/ui/_next/static/chunks/2f3d1d07474b8f79.js +1 -0
  173. package/dist/ui/_next/static/chunks/2f85c2849249a0dd.js +1 -0
  174. package/dist/ui/_next/static/chunks/3001d378f166eec9.js +1 -0
  175. package/dist/ui/_next/static/chunks/3018714f3827e360.js +1 -0
  176. package/dist/ui/_next/static/chunks/301cc25e0d489351.js +1 -0
  177. package/dist/ui/_next/static/chunks/305242b22ba8b49b.js +1 -0
  178. package/dist/ui/_next/static/chunks/3067c6e369066bd6.js +1 -0
  179. package/dist/ui/_next/static/chunks/311a77c9d5cb9de9.js +1 -0
  180. package/dist/ui/_next/static/chunks/320c001380e81470.js +1 -0
  181. package/dist/ui/_next/static/chunks/329db6c551df0faf.js +1 -0
  182. package/dist/ui/_next/static/chunks/33da178724072b3d.js +1 -0
  183. package/dist/ui/_next/static/chunks/33e8248c9296537a.js +1 -0
  184. package/dist/ui/_next/static/chunks/35a9992a8958f93b.js +1 -0
  185. package/dist/ui/_next/static/chunks/35bb90cf09892b72.js +1 -0
  186. package/dist/ui/_next/static/chunks/379f91b92366dc15.js +1 -0
  187. package/dist/ui/_next/static/chunks/391f22359769763f.js +1 -0
  188. package/dist/ui/_next/static/chunks/39231cb1044f7823.js +1 -0
  189. package/dist/ui/_next/static/chunks/394e8b7a1c2c58c6.js +1 -0
  190. package/dist/ui/_next/static/chunks/3a2cfdeb5f76ebd2.js +1 -0
  191. package/dist/ui/_next/static/chunks/3a3bd015fd042386.js +1 -0
  192. package/dist/ui/_next/static/chunks/3ad1bee238af9b5a.js +1 -0
  193. package/dist/ui/_next/static/chunks/3b2b2f7a9b7b130d.js +1 -0
  194. package/dist/ui/_next/static/chunks/3b586f80547e3a22.js +1 -0
  195. package/dist/ui/_next/static/chunks/3ca412e72bd3707a.js +1 -0
  196. package/dist/ui/_next/static/chunks/3cbb3bdceb4230af.js +1 -0
  197. package/dist/ui/_next/static/chunks/3ed1465109fecc2d.js +1 -0
  198. package/dist/ui/_next/static/chunks/3fd0801238b3b099.js +1 -0
  199. package/dist/ui/_next/static/chunks/401df66bd5da2115.js +15 -0
  200. package/dist/ui/_next/static/chunks/4211f4efe510f7ac.js +1 -0
  201. package/dist/ui/_next/static/chunks/43085364d0a41d1d.js +1 -0
  202. package/dist/ui/_next/static/chunks/4310c821dbee7a16.js +1 -0
  203. package/dist/ui/_next/static/chunks/46382f31f63e59cf.js +1 -0
  204. package/dist/ui/_next/static/chunks/468836b90ddf24d6.js +1 -0
  205. package/dist/ui/_next/static/chunks/470d091143104517.js +1 -0
  206. package/dist/ui/_next/static/chunks/4712e4f7e6b6ddc1.js +1 -0
  207. package/dist/ui/_next/static/chunks/4899f1e3f21c077e.js +1 -0
  208. package/dist/ui/_next/static/chunks/492ce6930bf61811.js +1 -0
  209. package/dist/ui/_next/static/chunks/494485a20952ffa3.js +1 -0
  210. package/dist/ui/_next/static/chunks/49535db309898f43.js +1 -0
  211. package/dist/ui/_next/static/chunks/4b8d2612d69e2013.js +1 -0
  212. package/dist/ui/_next/static/chunks/4c4a0f67891826a3.js +1 -0
  213. package/dist/ui/_next/static/chunks/4cc11ce32f4453b0.js +1 -0
  214. package/dist/ui/_next/static/chunks/4d03a0bc963fc3d4.js +1 -0
  215. package/dist/ui/_next/static/chunks/4d603a66c067134e.js +1 -0
  216. package/dist/ui/_next/static/chunks/4d8d7e62c2743f71.js +15 -0
  217. package/dist/ui/_next/static/chunks/4da42f10a5460b36.js +1 -0
  218. package/dist/ui/_next/static/chunks/4e832ffb65e75807.js +1 -0
  219. package/dist/ui/_next/static/chunks/4e954e1cec89a9ea.js +1 -0
  220. package/dist/ui/_next/static/chunks/4f2bc7a7a6b05a8b.js +55 -0
  221. package/dist/ui/_next/static/chunks/4f9c934abf34ceb9.js +1 -0
  222. package/dist/ui/_next/static/chunks/4fa248b0d2586928.js +1 -0
  223. package/dist/ui/_next/static/chunks/4fafbac2156844ca.js +1 -0
  224. package/dist/ui/_next/static/chunks/502039e483cc5e48.js +1 -0
  225. package/dist/ui/_next/static/chunks/509c91c38224448a.js +1 -0
  226. package/dist/ui/_next/static/chunks/5159d6f8d4307f36.js +1 -0
  227. package/dist/ui/_next/static/chunks/5179ab56aaaed42d.js +1 -0
  228. package/dist/ui/_next/static/chunks/5269ea07faff562d.js +1 -0
  229. package/dist/ui/_next/static/chunks/529f3f0f7d42444a.js +1 -0
  230. package/dist/ui/_next/static/chunks/5317db6783ee8dc9.js +1 -0
  231. package/dist/ui/_next/static/chunks/53a7b7c0ab020902.js +1 -0
  232. package/dist/ui/_next/static/chunks/544869c670c1dd8e.js +1 -0
  233. package/dist/ui/_next/static/chunks/547c0db6a433370e.js +1 -0
  234. package/dist/ui/_next/static/chunks/54d5670f5fa2abbe.css +1 -0
  235. package/dist/ui/_next/static/chunks/55761e35a8946a1d.js +15 -0
  236. package/dist/ui/_next/static/chunks/558f73c16b7ff14f.js +1 -0
  237. package/dist/ui/_next/static/chunks/55c76f605958d671.js +1 -0
  238. package/dist/ui/_next/static/chunks/55dc6750fb117bf9.js +1 -0
  239. package/dist/ui/_next/static/chunks/584bad9cf2498405.js +1 -0
  240. package/dist/ui/_next/static/chunks/593b85b9abea3ea6.js +1 -0
  241. package/dist/ui/_next/static/chunks/5a79af73c96155d4.js +1 -0
  242. package/dist/ui/_next/static/chunks/5ee54b9b6b400134.js +1 -0
  243. package/dist/ui/_next/static/chunks/5f27ee48dc820109.js +1 -0
  244. package/dist/ui/_next/static/chunks/5ffd50a08d82e2f3.js +1 -0
  245. package/dist/ui/_next/static/chunks/61d65fe807f69413.js +62 -0
  246. package/dist/ui/_next/static/chunks/626a650bcaaecdb8.js +1 -0
  247. package/dist/ui/_next/static/chunks/62baecafed4dbced.js +1 -0
  248. package/dist/ui/_next/static/chunks/634a4b5b6a38ccab.js +1 -0
  249. package/dist/ui/_next/static/chunks/643c359cf3f7364e.js +1 -0
  250. package/dist/ui/_next/static/chunks/649e65f4820a772b.js +1 -0
  251. package/dist/ui/_next/static/chunks/65028938188a230c.js +1 -0
  252. package/dist/ui/_next/static/chunks/65b3658348e8d4fd.js +1 -0
  253. package/dist/ui/_next/static/chunks/65eed220466cbdbc.js +1 -0
  254. package/dist/ui/_next/static/chunks/66714687cfd91953.js +1 -0
  255. package/dist/ui/_next/static/chunks/66ccaa3e69ed7a69.js +1 -0
  256. package/dist/ui/_next/static/chunks/6754600af0c6b3a8.js +1 -0
  257. package/dist/ui/_next/static/chunks/67a1d37727697340.js +1 -0
  258. package/dist/ui/_next/static/chunks/67e965a7f9531cee.js +1 -0
  259. package/dist/ui/_next/static/chunks/6816bf02e4c22a55.js +1 -0
  260. package/dist/ui/_next/static/chunks/68621b90909ec4e6.js +1 -0
  261. package/dist/ui/_next/static/chunks/6929ceb718c6e4c6.js +1 -0
  262. package/dist/ui/_next/static/chunks/69362fff2240a17b.js +1 -0
  263. package/dist/ui/_next/static/chunks/69dab47a307b1a37.js +1 -0
  264. package/dist/ui/_next/static/chunks/6afa71c8b3358dd5.js +1 -0
  265. package/dist/ui/_next/static/chunks/6bf54dc328e667f7.js +1 -0
  266. package/dist/ui/_next/static/chunks/6c44508faf13f6f0.js +1 -0
  267. package/dist/ui/_next/static/chunks/6c9c2b61c905a2de.js +1 -0
  268. package/dist/ui/_next/static/chunks/6cc2e3d7873522b9.js +1 -0
  269. package/dist/ui/_next/static/chunks/6d01e8902e85bfe0.js +1 -0
  270. package/dist/ui/_next/static/chunks/6dc69e4a91f7a353.js +1 -0
  271. package/dist/ui/_next/static/chunks/6e832e016b60ae19.js +1 -0
  272. package/dist/ui/_next/static/chunks/6eab0d8815c18a6d.js +1 -0
  273. package/dist/ui/_next/static/chunks/6f862eb588fa3b7e.js +1 -0
  274. package/dist/ui/_next/static/chunks/6ff7b0a8653036b2.js +1 -0
  275. package/dist/ui/_next/static/chunks/710ce144a9645f3c.js +1 -0
  276. package/dist/ui/_next/static/chunks/71293e300c639b6b.js +1 -0
  277. package/dist/ui/_next/static/chunks/7186d7cce354a012.js +1 -0
  278. package/dist/ui/_next/static/chunks/7215d586009e8158.js +1 -0
  279. package/dist/ui/_next/static/chunks/726fdeaff53a89ac.js +1 -0
  280. package/dist/ui/_next/static/chunks/7322a00d61e7ffad.js +1 -0
  281. package/dist/ui/_next/static/chunks/73c60ee9f233051d.js +1 -0
  282. package/dist/ui/_next/static/chunks/740f5627b5c57baa.js +1 -0
  283. package/dist/ui/_next/static/chunks/74438794a8e9ba80.js +1 -0
  284. package/dist/ui/_next/static/chunks/74ffcd7d13b3fea0.js +1 -0
  285. package/dist/ui/_next/static/chunks/7510496048ab1ad4.js +1 -0
  286. package/dist/ui/_next/static/chunks/7636f89f38cbc3e3.js +1 -0
  287. package/dist/ui/_next/static/chunks/782a93ec4348b666.js +1 -0
  288. package/dist/ui/_next/static/chunks/7850bbac1925646c.js +1 -0
  289. package/dist/ui/_next/static/chunks/790dcc1e825d2504.js +1 -0
  290. package/dist/ui/_next/static/chunks/798597a1c1248d29.js +1 -0
  291. package/dist/ui/_next/static/chunks/7a70641f70a5c72d.js +60 -0
  292. package/dist/ui/_next/static/chunks/7c62789391c35dce.js +1 -0
  293. package/dist/ui/_next/static/chunks/7d533d3f2ab624f2.js +1 -0
  294. package/dist/ui/_next/static/chunks/7d6087c3fabf9ded.js +1 -0
  295. package/dist/ui/_next/static/chunks/7d84c9cb810e6902.js +1 -0
  296. package/dist/ui/_next/static/chunks/7dc4f5ba8c25c409.js +1 -0
  297. package/dist/ui/_next/static/chunks/7e10c0644fbb99d1.js +1 -0
  298. package/dist/ui/_next/static/chunks/7e7aaacf104c17f4.js +1 -0
  299. package/dist/ui/_next/static/chunks/7e92979509de57ed.js +1 -0
  300. package/dist/ui/_next/static/chunks/7f9a52e36f9f001e.js +1 -0
  301. package/dist/ui/_next/static/chunks/7fc4ae2e7cf2e37e.js +1 -0
  302. package/dist/ui/_next/static/chunks/801232fdde8ce252.js +1 -0
  303. package/dist/ui/_next/static/chunks/808ed0f189237446.js +1 -0
  304. package/dist/ui/_next/static/chunks/8199e6b3fa54b2ff.js +1 -0
  305. package/dist/ui/_next/static/chunks/81fa0fa05a94eb02.js +1 -0
  306. package/dist/ui/_next/static/chunks/821b5389566b82d2.js +1 -0
  307. package/dist/ui/_next/static/chunks/82b9e04f88e657df.js +1 -0
  308. package/dist/ui/_next/static/chunks/830c79cc12f2c5a4.js +1 -0
  309. package/dist/ui/_next/static/chunks/8388ae863590404b.js +4 -0
  310. package/dist/ui/_next/static/chunks/83ab70f11a82a8c6.js +1 -0
  311. package/dist/ui/_next/static/chunks/83faf7904ac18d7f.js +1 -0
  312. package/dist/ui/_next/static/chunks/850d850bd879606f.js +1 -0
  313. package/dist/ui/_next/static/chunks/864d4b5cf4ae2226.js +1 -0
  314. package/dist/ui/_next/static/chunks/86d8962196053f53.js +139 -0
  315. package/dist/ui/_next/static/chunks/8723d7000b263475.js +1 -0
  316. package/dist/ui/_next/static/chunks/87e5597a4336e2c1.js +1 -0
  317. package/dist/ui/_next/static/chunks/899fe56c4c707c65.js +1 -0
  318. package/dist/ui/_next/static/chunks/8bda52f55493ae9b.js +1 -0
  319. package/dist/ui/_next/static/chunks/8ce5668c3da0679a.js +1 -0
  320. package/dist/ui/_next/static/chunks/8d1c22aafb4783c5.js +1 -0
  321. package/dist/ui/_next/static/chunks/8deda0adfe811d18.js +1 -0
  322. package/dist/ui/_next/static/chunks/8eed597098a27801.js +1 -0
  323. package/dist/ui/_next/static/chunks/8ff7a1947b8d114b.js +1 -0
  324. package/dist/ui/_next/static/chunks/90367a2ee1e720b2.js +1 -0
  325. package/dist/ui/_next/static/chunks/9097640e1931c0de.js +1 -0
  326. package/dist/ui/_next/static/chunks/912457473a4c91c3.js +1 -0
  327. package/dist/ui/_next/static/chunks/91f7dd388c6b88c6.js +1 -0
  328. package/dist/ui/_next/static/chunks/932d4334e5f98b7c.js +1 -0
  329. package/dist/ui/_next/static/chunks/94b1efc14d44707b.js +1 -0
  330. package/dist/ui/_next/static/chunks/956107bc3ba52911.js +1 -0
  331. package/dist/ui/_next/static/chunks/962e5cad8ea716fc.js +36 -0
  332. package/dist/ui/_next/static/chunks/96acf903dff8ecf7.js +1 -0
  333. package/dist/ui/_next/static/chunks/96b274c82c194b4f.js +1 -0
  334. package/dist/ui/_next/static/chunks/96b3c1b1afe3201d.js +1 -0
  335. package/dist/ui/_next/static/chunks/9880c26551206d33.js +1 -0
  336. package/dist/ui/_next/static/chunks/98ea228d01556617.js +1 -0
  337. package/dist/ui/_next/static/chunks/9951c25a8b05148f.js +1 -0
  338. package/dist/ui/_next/static/chunks/9b10895d33be5f6e.js +1 -0
  339. package/dist/ui/_next/static/chunks/9b50a76ddbe4934d.js +1 -0
  340. package/dist/ui/_next/static/chunks/9bbb1c0146042008.js +1 -0
  341. package/dist/ui/_next/static/chunks/9ccab70823e99451.js +1 -0
  342. package/dist/ui/_next/static/chunks/9cd7bcb29e0b3418.js +24 -0
  343. package/dist/ui/_next/static/chunks/9d06bd5d701ace73.js +1 -0
  344. package/dist/ui/_next/static/chunks/9e5d9fc30c12fbdd.js +1 -0
  345. package/dist/ui/_next/static/chunks/9ec3bc5544bcc15a.js +1 -0
  346. package/dist/ui/_next/static/chunks/9f47133184a7455a.js +1 -0
  347. package/dist/ui/_next/static/chunks/a002d3850b7c7c59.js +1 -0
  348. package/dist/ui/_next/static/chunks/a0bc5573cadd1377.js +1 -0
  349. package/dist/ui/_next/static/chunks/a1d3de9e7615662e.js +160 -0
  350. package/dist/ui/_next/static/chunks/a2ce60768a8373e7.js +1 -0
  351. package/dist/ui/_next/static/chunks/a305087b1a55b367.js +1 -0
  352. package/dist/ui/_next/static/chunks/a41df0d443f66c68.js +1 -0
  353. package/dist/ui/_next/static/chunks/a49d2e9f31886b5e.js +1 -0
  354. package/dist/ui/_next/static/chunks/a50922e0883f65cd.js +1 -0
  355. package/dist/ui/_next/static/chunks/a60e84ee8b6c5ffc.js +43 -0
  356. package/dist/ui/_next/static/chunks/a6dad97d9634a72d.js +1 -0
  357. package/dist/ui/_next/static/chunks/a6dad97d9634a72d.js.map +1 -0
  358. package/dist/ui/_next/static/chunks/a7c40c289b5e2384.js +1 -0
  359. package/dist/ui/_next/static/chunks/a7fdfeea5fd894c1.js +59 -0
  360. package/dist/ui/_next/static/chunks/a81381241f4f484c.js +1 -0
  361. package/dist/ui/_next/static/chunks/a8a3989305bcc136.js +215 -0
  362. package/dist/ui/_next/static/chunks/a8cf26088e63128c.js +1 -0
  363. package/dist/ui/_next/static/chunks/aac4ca816d9ccdb6.js +1 -0
  364. package/dist/ui/_next/static/chunks/ab432bc28a971c8f.js +1 -0
  365. package/dist/ui/_next/static/chunks/abccff1b09b6effa.js +1 -0
  366. package/dist/ui/_next/static/chunks/ac8a8986f09ec520.js +1 -0
  367. package/dist/ui/_next/static/chunks/accbf306b5ddb732.js +1 -0
  368. package/dist/ui/_next/static/chunks/af7b09aba1d477ff.js +1 -0
  369. package/dist/ui/_next/static/chunks/af8114430894d79e.js +1 -0
  370. package/dist/ui/_next/static/chunks/afe2ff5d0727a240.js +1 -0
  371. package/dist/ui/_next/static/chunks/b096fa008120f0ae.js +1 -0
  372. package/dist/ui/_next/static/chunks/b0bc568eaff56dad.js +1 -0
  373. package/dist/ui/_next/static/chunks/b225dddc0852f85c.js +215 -0
  374. package/dist/ui/_next/static/chunks/b2342c5099957971.js +1 -0
  375. package/dist/ui/_next/static/chunks/b2d8c64d7d6a06b7.js +1 -0
  376. package/dist/ui/_next/static/chunks/b331c855cfc8fd57.js +1 -0
  377. package/dist/ui/_next/static/chunks/b356ee8615740392.js +1 -0
  378. package/dist/ui/_next/static/chunks/b3beaac9b7957d3f.js +1 -0
  379. package/dist/ui/_next/static/chunks/b4e7d4a109c4c080.js +1 -0
  380. package/dist/ui/_next/static/chunks/b5010f2ea9df9d00.js +77 -0
  381. package/dist/ui/_next/static/chunks/b5f9d21bd1b51a48.js +1 -0
  382. package/dist/ui/_next/static/chunks/b6a16eb77c5c9831.js +1 -0
  383. package/dist/ui/_next/static/chunks/b6a8e7c2216683ca.js +262 -0
  384. package/dist/ui/_next/static/chunks/b873c4d327a450e0.js +1 -0
  385. package/dist/ui/_next/static/chunks/b8aec8caed569fd2.js +24 -0
  386. package/dist/ui/_next/static/chunks/b8e7601e2379fd74.js +1 -0
  387. package/dist/ui/_next/static/chunks/ba3d03bf2f33f2a3.js +1 -0
  388. package/dist/ui/_next/static/chunks/ba698805336b2cb2.js +1 -0
  389. package/dist/ui/_next/static/chunks/bc48735eee7d1345.js +1 -0
  390. package/dist/ui/_next/static/chunks/bcb48aab1bdae96a.js +1 -0
  391. package/dist/ui/_next/static/chunks/bde2ca9d150d96ff.js +1 -0
  392. package/dist/ui/_next/static/chunks/be4af851547fc916.js +1 -0
  393. package/dist/ui/_next/static/chunks/be70ba8c4ba5cdb6.js +1 -0
  394. package/dist/ui/_next/static/chunks/be87578ee895734b.js +1 -0
  395. package/dist/ui/_next/static/chunks/c0aeb40fcca7d006.js +1 -0
  396. package/dist/ui/_next/static/chunks/c32156843c32ebca.js +1 -0
  397. package/dist/ui/_next/static/chunks/c57a3e045f3722c1.js +1 -0
  398. package/dist/ui/_next/static/chunks/c5add23cde4a234a.js +1 -0
  399. package/dist/ui/_next/static/chunks/c60897f3554a9388.js +1 -0
  400. package/dist/ui/_next/static/chunks/c648a36722afd12a.js +1 -0
  401. package/dist/ui/_next/static/chunks/c652f05e0a0d7b81.js +1 -0
  402. package/dist/ui/_next/static/chunks/c678d9303ed453b4.js +1 -0
  403. package/dist/ui/_next/static/chunks/c681430c24597d06.js +1 -0
  404. package/dist/ui/_next/static/chunks/c890870fb65940bc.js +1 -0
  405. package/dist/ui/_next/static/chunks/c94c394aeec71e21.js +1 -0
  406. package/dist/ui/_next/static/chunks/ca1eb1e2978389e4.js +1 -0
  407. package/dist/ui/_next/static/chunks/ca3512025a981c82.js +1 -0
  408. package/dist/ui/_next/static/chunks/ca6db0d999bad46b.js +1 -0
  409. package/dist/ui/_next/static/chunks/ca926babdf75597c.js +1 -0
  410. package/dist/ui/_next/static/chunks/cb0877764d4a31f2.js +1 -0
  411. package/dist/ui/_next/static/chunks/cb15e0c2ff49cf52.js +1 -0
  412. package/dist/ui/_next/static/chunks/cb1ae84204260ecd.js +1 -0
  413. package/dist/ui/_next/static/chunks/cb2ef733c53d80f7.js +1 -0
  414. package/dist/ui/_next/static/chunks/cbaa87ba8930fb75.js +1 -0
  415. package/dist/ui/_next/static/chunks/cbd29ba61906e19f.js +1 -0
  416. package/dist/ui/_next/static/chunks/ccf1e618faea3d02.js +148 -0
  417. package/dist/ui/_next/static/chunks/cd91712ea04f43ba.js +13 -0
  418. package/dist/ui/_next/static/chunks/cdd85dc039d450f3.js +1 -0
  419. package/dist/ui/_next/static/chunks/ce663833f73b1ec5.js +1 -0
  420. package/dist/ui/_next/static/chunks/ceda8fcac21d8e70.js +1 -0
  421. package/dist/ui/_next/static/chunks/cf565875b66f8cad.js +1 -0
  422. package/dist/ui/_next/static/chunks/d127ded39a594c84.js +1 -0
  423. package/dist/ui/_next/static/chunks/d34124988f5b8f6d.js +1 -0
  424. package/dist/ui/_next/static/chunks/d36807add3e11d59.js +60 -0
  425. package/dist/ui/_next/static/chunks/d3f2e4603faebed8.js +1 -0
  426. package/dist/ui/_next/static/chunks/d414302c23047b9b.js +1 -0
  427. package/dist/ui/_next/static/chunks/d42adc0237103e65.js +1 -0
  428. package/dist/ui/_next/static/chunks/d4a06b205f0a641b.js +1 -0
  429. package/dist/ui/_next/static/chunks/d4e5289ace3acef0.js +1 -0
  430. package/dist/ui/_next/static/chunks/d53b4725d3328076.js +1 -0
  431. package/dist/ui/_next/static/chunks/d5bd04634f922925.js +1 -0
  432. package/dist/ui/_next/static/chunks/d642c9229900dc48.js +1 -0
  433. package/dist/ui/_next/static/chunks/d6651bb78c09d144.js +5 -0
  434. package/dist/ui/_next/static/chunks/d7276c56aa62ceed.js +1 -0
  435. package/dist/ui/_next/static/chunks/d85cd9cda46f2d1b.js +1 -0
  436. package/dist/ui/_next/static/chunks/d8978f4b468bbad4.js +1 -0
  437. package/dist/ui/_next/static/chunks/d8fb9668a83c0603.js +1 -0
  438. package/dist/ui/_next/static/chunks/d95c62472fc41baf.js +1 -0
  439. package/dist/ui/_next/static/chunks/da13170b983f7ebf.js +1 -0
  440. package/dist/ui/_next/static/chunks/dae86e12c7741e6c.js +19 -0
  441. package/dist/ui/_next/static/chunks/db44023a744297d1.js +1 -0
  442. package/dist/ui/_next/static/chunks/dbe7840308be36b8.js +1 -0
  443. package/dist/ui/_next/static/chunks/dc0a4df8f7080b29.js +1 -0
  444. package/dist/ui/_next/static/chunks/dc4a6f59be156511.js +1 -0
  445. package/dist/ui/_next/static/chunks/dcda5e7b57ed88e0.js +1 -0
  446. package/dist/ui/_next/static/chunks/de9ff8c97f75b947.js +1 -0
  447. package/dist/ui/_next/static/chunks/df6abcdb3eb0b236.js +1 -0
  448. package/dist/ui/_next/static/chunks/df8a0933ca385a63.js +1 -0
  449. package/dist/ui/_next/static/chunks/dff6434c44c2dfaa.js +1 -0
  450. package/dist/ui/_next/static/chunks/e037ec5e62b2bdc3.js +1 -0
  451. package/dist/ui/_next/static/chunks/e212cf1f5a503899.js +1 -0
  452. package/dist/ui/_next/static/chunks/e2bfdac0a2305cc1.js +1 -0
  453. package/dist/ui/_next/static/chunks/e2dce648399ad4d4.js +1 -0
  454. package/dist/ui/_next/static/chunks/e318291bb8d74aee.js +1 -0
  455. package/dist/ui/_next/static/chunks/e33e40c2e7ab7629.js +1 -0
  456. package/dist/ui/_next/static/chunks/e410dfbcccddc478.js +1 -0
  457. package/dist/ui/_next/static/chunks/e411d58b52ab342b.js +1 -0
  458. package/dist/ui/_next/static/chunks/e57f7ffd0803a922.js +117 -0
  459. package/dist/ui/_next/static/chunks/e6b56ceb762e84c4.js +1 -0
  460. package/dist/ui/_next/static/chunks/e6d9a6ca68017eef.js +1 -0
  461. package/dist/ui/_next/static/chunks/e6ec2663605cf5a7.js +29 -0
  462. package/dist/ui/_next/static/chunks/e834330589be0639.js +1 -0
  463. package/dist/ui/_next/static/chunks/e8f662ba8bc76802.js +1 -0
  464. package/dist/ui/_next/static/chunks/e9e8e72d7ff45812.js +1 -0
  465. package/dist/ui/_next/static/chunks/eadd25eb66104a63.js +1 -0
  466. package/dist/ui/_next/static/chunks/ec3a7a7f48a8aca9.js +1 -0
  467. package/dist/ui/_next/static/chunks/ed62e349fb1ce14c.js +1 -0
  468. package/dist/ui/_next/static/chunks/ed6caa113f5769a5.js +1 -0
  469. package/dist/ui/_next/static/chunks/f02ac565bb5bc450.js +1 -0
  470. package/dist/ui/_next/static/chunks/f1a7a173e3da4ff4.js +1 -0
  471. package/dist/ui/_next/static/chunks/f268093817d3b260.js +1 -0
  472. package/dist/ui/_next/static/chunks/f6f811ccfe79e963.js +1 -0
  473. package/dist/ui/_next/static/chunks/f8955634331fd956.js +1 -0
  474. package/dist/ui/_next/static/chunks/f8c965a996875e30.js +56 -0
  475. package/dist/ui/_next/static/chunks/f9bb8411d37b06d7.js +1 -0
  476. package/dist/ui/_next/static/chunks/f9d4f77d8c130497.js +1 -0
  477. package/dist/ui/_next/static/chunks/fba113a516eb485f.js +1 -0
  478. package/dist/ui/_next/static/chunks/fc069e49a569d83c.js +1 -0
  479. package/dist/ui/_next/static/chunks/fc245016ffebdde3.js +1 -0
  480. package/dist/ui/_next/static/chunks/fc2d01d74dcf3921.js +1 -0
  481. package/dist/ui/_next/static/chunks/fe2ad0e00041a87d.js +1 -0
  482. package/dist/ui/_next/static/chunks/fe571740188dea3a.js +1 -0
  483. package/dist/ui/_next/static/chunks/turbopack-a5ce95b200d58f7a.js +4 -0
  484. package/dist/ui/_next/static/media/4fa387ec64143e14-s.c1fdd6c2.woff2 +0 -0
  485. package/dist/ui/_next/static/media/7178b3e590c64307-s.b97b3418.woff2 +0 -0
  486. package/dist/ui/_next/static/media/797e433ab948586e-s.p.dbea232f.woff2 +0 -0
  487. package/dist/ui/_next/static/media/8a480f0b521d4e75-s.8e0177b5.woff2 +0 -0
  488. package/dist/ui/_next/static/media/KaTeX_AMS-Regular.892f691b.ttf +0 -0
  489. package/dist/ui/_next/static/media/KaTeX_AMS-Regular.c30af439.woff2 +0 -0
  490. package/dist/ui/_next/static/media/KaTeX_AMS-Regular.e6a3cada.woff +0 -0
  491. package/dist/ui/_next/static/media/KaTeX_Caligraphic-Bold.2f97783e.woff +0 -0
  492. package/dist/ui/_next/static/media/KaTeX_Caligraphic-Bold.a36b8125.ttf +0 -0
  493. package/dist/ui/_next/static/media/KaTeX_Caligraphic-Bold.db991531.woff2 +0 -0
  494. package/dist/ui/_next/static/media/KaTeX_Caligraphic-Regular.2b13f013.woff +0 -0
  495. package/dist/ui/_next/static/media/KaTeX_Caligraphic-Regular.7c50032c.ttf +0 -0
  496. package/dist/ui/_next/static/media/KaTeX_Caligraphic-Regular.c20eee08.woff2 +0 -0
  497. package/dist/ui/_next/static/media/KaTeX_Fraktur-Bold.5fa2f5e4.woff +0 -0
  498. package/dist/ui/_next/static/media/KaTeX_Fraktur-Bold.d514bd28.woff2 +0 -0
  499. package/dist/ui/_next/static/media/KaTeX_Fraktur-Bold.e311399d.ttf +0 -0
  500. package/dist/ui/_next/static/media/KaTeX_Fraktur-Regular.18139813.woff +0 -0
  501. package/dist/ui/_next/static/media/KaTeX_Fraktur-Regular.2a73476d.ttf +0 -0
  502. package/dist/ui/_next/static/media/KaTeX_Fraktur-Regular.5d62e468.woff2 +0 -0
  503. package/dist/ui/_next/static/media/KaTeX_Main-Bold.6d137c77.ttf +0 -0
  504. package/dist/ui/_next/static/media/KaTeX_Main-Bold.c24b5ba7.woff +0 -0
  505. package/dist/ui/_next/static/media/KaTeX_Main-Bold.f4e2828d.woff2 +0 -0
  506. package/dist/ui/_next/static/media/KaTeX_Main-BoldItalic.079b33ae.woff +0 -0
  507. package/dist/ui/_next/static/media/KaTeX_Main-BoldItalic.c003d3ec.ttf +0 -0
  508. package/dist/ui/_next/static/media/KaTeX_Main-BoldItalic.f1884480.woff2 +0 -0
  509. package/dist/ui/_next/static/media/KaTeX_Main-Italic.26a3619b.woff +0 -0
  510. package/dist/ui/_next/static/media/KaTeX_Main-Italic.61da3e93.ttf +0 -0
  511. package/dist/ui/_next/static/media/KaTeX_Main-Italic.a3746929.woff2 +0 -0
  512. package/dist/ui/_next/static/media/KaTeX_Main-Regular.12644167.woff2 +0 -0
  513. package/dist/ui/_next/static/media/KaTeX_Main-Regular.876b86ad.ttf +0 -0
  514. package/dist/ui/_next/static/media/KaTeX_Main-Regular.d511f158.woff +0 -0
  515. package/dist/ui/_next/static/media/KaTeX_Math-BoldItalic.5c6a6a93.woff2 +0 -0
  516. package/dist/ui/_next/static/media/KaTeX_Math-BoldItalic.ad4dffd5.woff +0 -0
  517. package/dist/ui/_next/static/media/KaTeX_Math-BoldItalic.e73b3bf0.ttf +0 -0
  518. package/dist/ui/_next/static/media/KaTeX_Math-Italic.03974bc4.ttf +0 -0
  519. package/dist/ui/_next/static/media/KaTeX_Math-Italic.1cd2c488.woff +0 -0
  520. package/dist/ui/_next/static/media/KaTeX_Math-Italic.d8564edb.woff2 +0 -0
  521. package/dist/ui/_next/static/media/KaTeX_SansSerif-Bold.a03f9428.woff2 +0 -0
  522. package/dist/ui/_next/static/media/KaTeX_SansSerif-Bold.d4608ed5.ttf +0 -0
  523. package/dist/ui/_next/static/media/KaTeX_SansSerif-Bold.ff51ef5c.woff +0 -0
  524. package/dist/ui/_next/static/media/KaTeX_SansSerif-Italic.8ed740d6.woff +0 -0
  525. package/dist/ui/_next/static/media/KaTeX_SansSerif-Italic.9245afda.woff2 +0 -0
  526. package/dist/ui/_next/static/media/KaTeX_SansSerif-Italic.c0b22b1e.ttf +0 -0
  527. package/dist/ui/_next/static/media/KaTeX_SansSerif-Regular.128c9bc2.woff2 +0 -0
  528. package/dist/ui/_next/static/media/KaTeX_SansSerif-Regular.156dbd4e.ttf +0 -0
  529. package/dist/ui/_next/static/media/KaTeX_SansSerif-Regular.ee7b0a16.woff +0 -0
  530. package/dist/ui/_next/static/media/KaTeX_Script-Regular.00d9a561.ttf +0 -0
  531. package/dist/ui/_next/static/media/KaTeX_Script-Regular.186c7155.woff2 +0 -0
  532. package/dist/ui/_next/static/media/KaTeX_Script-Regular.afc2fd5a.woff +0 -0
  533. package/dist/ui/_next/static/media/KaTeX_Size1-Regular.4450ef36.woff2 +0 -0
  534. package/dist/ui/_next/static/media/KaTeX_Size1-Regular.9aaff96b.ttf +0 -0
  535. package/dist/ui/_next/static/media/KaTeX_Size1-Regular.e5bf4c74.woff +0 -0
  536. package/dist/ui/_next/static/media/KaTeX_Size2-Regular.6a97527b.woff2 +0 -0
  537. package/dist/ui/_next/static/media/KaTeX_Size2-Regular.8fbd32af.woff +0 -0
  538. package/dist/ui/_next/static/media/KaTeX_Size2-Regular.f11810ed.ttf +0 -0
  539. package/dist/ui/_next/static/media/KaTeX_Size3-Regular.45ae8eba.woff +0 -0
  540. package/dist/ui/_next/static/media/KaTeX_Size3-Regular.54b7ce9d.woff2 +0 -0
  541. package/dist/ui/_next/static/media/KaTeX_Size3-Regular.9812ade2.ttf +0 -0
  542. package/dist/ui/_next/static/media/KaTeX_Size4-Regular.44a4d487.ttf +0 -0
  543. package/dist/ui/_next/static/media/KaTeX_Size4-Regular.927fc5b9.woff2 +0 -0
  544. package/dist/ui/_next/static/media/KaTeX_Size4-Regular.b211e3d3.woff +0 -0
  545. package/dist/ui/_next/static/media/KaTeX_Typewriter-Regular.68b6c3a9.woff +0 -0
  546. package/dist/ui/_next/static/media/KaTeX_Typewriter-Regular.a1a7ff52.ttf +0 -0
  547. package/dist/ui/_next/static/media/KaTeX_Typewriter-Regular.ff99d643.woff2 +0 -0
  548. package/dist/ui/_next/static/media/bbc41e54d2fcbd21-s.799d8ef8.woff2 +0 -0
  549. package/dist/ui/_next/static/media/caa3a2e1cccd8315-s.p.853070df.woff2 +0 -0
  550. package/dist/ui/_next/static/media/favicon.0b3bf435.ico +0 -0
  551. package/dist/ui/_not-found/__next._full.txt +18 -0
  552. package/dist/ui/_not-found/__next._head.txt +6 -0
  553. package/dist/ui/_not-found/__next._index.txt +9 -0
  554. package/dist/ui/_not-found/__next._not-found.__PAGE__.txt +5 -0
  555. package/dist/ui/_not-found/__next._not-found.txt +4 -0
  556. package/dist/ui/_not-found/__next._tree.txt +3 -0
  557. package/dist/ui/_not-found/index.html +1 -0
  558. package/dist/ui/_not-found/index.txt +18 -0
  559. package/dist/ui/favicon.ico +0 -0
  560. package/dist/ui/file.svg +1 -0
  561. package/dist/ui/globe.svg +1 -0
  562. package/dist/ui/index.html +1 -0
  563. package/dist/ui/index.txt +25 -0
  564. package/dist/ui/next.svg +1 -0
  565. package/dist/ui/vercel.svg +1 -0
  566. package/dist/ui/window.svg +1 -0
  567. package/dist/utils/chat-model.d.ts +11 -0
  568. package/dist/utils/chat-model.js +37 -0
  569. package/dist/utils/diff-parser.d.ts +20 -0
  570. package/dist/utils/diff-parser.js +100 -0
  571. package/dist/utils/proxy-manager.d.ts +18 -0
  572. package/dist/utils/proxy-manager.js +42 -0
  573. package/dist/utils/remote-proxy.d.ts +40 -0
  574. package/dist/utils/remote-proxy.js +145 -0
  575. package/dist/utils/worktree-paths.d.ts +13 -0
  576. package/dist/utils/worktree-paths.js +64 -0
  577. package/dist/virtual-ws-adapter.d.ts +26 -0
  578. package/dist/virtual-ws-adapter.js +54 -0
  579. package/package.json +19 -0
@@ -0,0 +1,29 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,837031,e=>{"use strict";let r,s,i,n,o,a,l,c,d,h,u,f,p,m,g,v,x;var _,y,b,w,S,C,k,j,N,E,R,M,D,T,P,L,B,A,O,I,z,F=e.i(813443),W=e.i(629109),H=e.i(156999),$=e.i(331053);function K(e,r,{checkForDefaultPrevented:s=!0}={}){return function(i){if(e?.(i),!1===s||!i.defaultPrevented)return r?.(i)}}"undefined"!=typeof window&&window.document&&window.document.createElement;var U=e.i(538422);function q(e,r=[]){let s=[],i=()=>{let r=s.map(e=>W.createContext(e));return function(s){let i=s?.[e]||r;return W.useMemo(()=>({[`__scope${e}`]:{...s,[e]:i}}),[s,i])}};return i.scopeName=e,[function(r,i){let n=W.createContext(i),o=s.length;s=[...s,i];let a=r=>{let{scope:s,children:i,...a}=r,l=s?.[e]?.[o]||n,c=W.useMemo(()=>a,Object.values(a));return(0,F.jsx)(l.Provider,{value:c,children:i})};return a.displayName=r+"Provider",[a,function(s,a){let l=a?.[e]?.[o]||n,c=W.useContext(l);if(c)return c;if(void 0!==i)return i;throw Error(`\`${s}\` must be used within \`${r}\``)}]},function(...e){let r=e[0];if(1===e.length)return r;let s=()=>{let s=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let i=s.reduce((r,{useScope:s,scopeName:i})=>{let n=s(e)[`__scope${i}`];return{...r,...n}},{});return W.useMemo(()=>({[`__scope${r.scopeName}`]:i}),[i])}};return s.scopeName=r.scopeName,s}(i,...r)]}var V=globalThis?.document?W.useLayoutEffect:()=>{};W[" useEffectEvent ".trim().toString()],W[" useInsertionEffect ".trim().toString()];var Y=W[" useInsertionEffect ".trim().toString()]||V;function X({prop:e,defaultProp:r,onChange:s=()=>{},caller:i}){let[n,o,a]=function({defaultProp:e,onChange:r}){let[s,i]=W.useState(e),n=W.useRef(s),o=W.useRef(r);return Y(()=>{o.current=r},[r]),W.useEffect(()=>{n.current!==s&&(o.current?.(s),n.current=s)},[s,n]),[s,i,o]}({defaultProp:r,onChange:s}),l=void 0!==e,c=l?e:n;{let r=W.useRef(void 0!==e);W.useEffect(()=>{let e=r.current;if(e!==l){let r=l?"controlled":"uncontrolled";console.warn(`${i} is changing from ${e?"controlled":"uncontrolled"} to ${r}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}r.current=l},[l,i])}return[c,W.useCallback(r=>{if(l){let s="function"==typeof r?r(e):r;s!==e&&a.current?.(s)}else o(r)},[l,e,o,a])]}Symbol("RADIX:SYNC_STATE");var G=e.i(492521),J=e.i(475299),Z=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,r)=>{let s=(0,J.createSlot)(`Primitive.${r}`),i=W.forwardRef((e,i)=>{let{asChild:n,...o}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,F.jsx)(n?s:r,{...o,ref:i})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{});function Q(e,r){e&&G.flushSync(()=>e.dispatchEvent(r))}function ee(e){let r=e+"CollectionProvider",[s,i]=q(r),[n,o]=s(r,{collectionRef:{current:null},itemMap:new Map}),a=e=>{let{scope:r,children:s}=e,i=W.default.useRef(null),o=W.default.useRef(new Map).current;return(0,F.jsx)(n,{scope:r,itemMap:o,collectionRef:i,children:s})};a.displayName=r;let l=e+"CollectionSlot",c=(0,J.createSlot)(l),d=W.default.forwardRef((e,r)=>{let{scope:s,children:i}=e,n=o(l,s),a=(0,U.useComposedRefs)(r,n.collectionRef);return(0,F.jsx)(c,{ref:a,children:i})});d.displayName=l;let h=e+"CollectionItemSlot",u="data-radix-collection-item",f=(0,J.createSlot)(h),p=W.default.forwardRef((e,r)=>{let{scope:s,children:i,...n}=e,a=W.default.useRef(null),l=(0,U.useComposedRefs)(r,a),c=o(h,s);return W.default.useEffect(()=>(c.itemMap.set(a,{ref:a,...n}),()=>void c.itemMap.delete(a))),(0,F.jsx)(f,{...{[u]:""},ref:l,children:i})});return p.displayName=h,[{Provider:a,Slot:d,ItemSlot:p},function(r){let s=o(e+"CollectionConsumer",r);return W.default.useCallback(()=>{let e=s.collectionRef.current;if(!e)return[];let r=Array.from(e.querySelectorAll(`[${u}]`));return Array.from(s.itemMap.values()).sort((e,s)=>r.indexOf(e.ref.current)-r.indexOf(s.ref.current))},[s.collectionRef,s.itemMap])},i]}var et=new WeakMap;function er(e,r){var s,i;let n,o,a;if("at"in Array.prototype)return Array.prototype.at.call(e,r);let l=(s=e,i=r,n=s.length,(a=(o=es(i))>=0?o:n+o)<0||a>=n?-1:a);return -1===l?void 0:e[l]}function es(e){return e!=e||0===e?0:Math.trunc(e)}(class e extends Map{#e;constructor(e){super(e),this.#e=[...super.keys()],et.set(this,!0)}set(e,r){return et.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,r),this}insert(e,r,s){let i,n=this.has(r),o=this.#e.length,a=es(e),l=a>=0?a:o+a,c=l<0||l>=o?-1:l;if(c===this.size||n&&c===this.size-1||-1===c)return this.set(r,s),this;let d=this.size+ +!n;a<0&&l++;let h=[...this.#e],u=!1;for(let e=l;e<d;e++)if(l===e){let o=h[e];h[e]===r&&(o=h[e+1]),n&&this.delete(r),i=this.get(o),this.set(r,s)}else{u||h[e-1]!==r||(u=!0);let s=h[u?e:e-1],n=i;i=this.get(s),this.delete(s),this.set(s,n)}return this}with(r,s,i){let n=new e(this);return n.insert(r,s,i),n}before(e){let r=this.#e.indexOf(e)-1;if(!(r<0))return this.entryAt(r)}setBefore(e,r,s){let i=this.#e.indexOf(e);return -1===i?this:this.insert(i,r,s)}after(e){let r=this.#e.indexOf(e);if(-1!==(r=-1===r||r===this.size-1?-1:r+1))return this.entryAt(r)}setAfter(e,r,s){let i=this.#e.indexOf(e);return -1===i?this:this.insert(i+1,r,s)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let r=super.delete(e);return r&&this.#e.splice(this.#e.indexOf(e),1),r}deleteAt(e){let r=this.keyAt(e);return void 0!==r&&this.delete(r)}at(e){let r=er(this.#e,e);if(void 0!==r)return this.get(r)}entryAt(e){let r=er(this.#e,e);if(void 0!==r)return[r,this.get(r)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return er(this.#e,e)}from(e,r){let s=this.indexOf(e);if(-1===s)return;let i=s+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.at(i)}keyFrom(e,r){let s=this.indexOf(e);if(-1===s)return;let i=s+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.keyAt(i)}find(e,r){let s=0;for(let i of this){if(Reflect.apply(e,r,[i,s,this]))return i;s++}}findIndex(e,r){let s=0;for(let i of this){if(Reflect.apply(e,r,[i,s,this]))return s;s++}return -1}filter(r,s){let i=[],n=0;for(let e of this)Reflect.apply(r,s,[e,n,this])&&i.push(e),n++;return new e(i)}map(r,s){let i=[],n=0;for(let e of this)i.push([e[0],Reflect.apply(r,s,[e,n,this])]),n++;return new e(i)}reduce(...e){let[r,s]=e,i=0,n=s??this.at(0);for(let s of this)n=0===i&&1===e.length?s:Reflect.apply(r,this,[n,s,i,this]),i++;return n}reduceRight(...e){let[r,s]=e,i=s??this.at(-1);for(let s=this.size-1;s>=0;s--){let n=this.at(s);i=s===this.size-1&&1===e.length?n:Reflect.apply(r,this,[i,n,s,this])}return i}toSorted(r){return new e([...this.entries()].sort(r))}toReversed(){let r=new e;for(let e=this.size-1;e>=0;e--){let s=this.keyAt(e),i=this.get(s);r.set(s,i)}return r}toSpliced(...r){let s=[...this.entries()];return s.splice(...r),new e(s)}slice(r,s){let i=new e,n=this.size-1;if(void 0===r)return i;r<0&&(r+=this.size),void 0!==s&&s>0&&(n=s-1);for(let e=r;e<=n;e++){let r=this.keyAt(e),s=this.get(r);i.set(r,s)}return i}every(e,r){let s=0;for(let i of this){if(!Reflect.apply(e,r,[i,s,this]))return!1;s++}return!0}some(e,r){let s=0;for(let i of this){if(Reflect.apply(e,r,[i,s,this]))return!0;s++}return!1}});var ei=W.createContext(void 0);function en(e){let r=W.useContext(ei);return e||r||"ltr"}function eo(e){let r=W.useRef(e);return W.useEffect(()=>{r.current=e}),W.useMemo(()=>(...e)=>r.current?.(...e),[])}var ea="dismissableLayer.update",el=W.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ec=W.forwardRef((e,r)=>{let{disableOutsidePointerEvents:s=!1,onEscapeKeyDown:i,onPointerDownOutside:n,onFocusOutside:o,onInteractOutside:a,onDismiss:l,...c}=e,d=W.useContext(el),[h,u]=W.useState(null),f=h?.ownerDocument??globalThis?.document,[,p]=W.useState({}),m=(0,U.useComposedRefs)(r,e=>u(e)),g=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),x=g.indexOf(v),_=h?g.indexOf(h):-1,y=d.layersWithOutsidePointerEventsDisabled.size>0,b=_>=x,w=function(e,r=globalThis?.document){let s=eo(e),i=W.useRef(!1),n=W.useRef(()=>{});return W.useEffect(()=>{let e=e=>{if(e.target&&!i.current){let i=function(){eh("dismissableLayer.pointerDownOutside",s,o,{discrete:!0})},o={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",n.current),n.current=i,r.addEventListener("click",n.current,{once:!0})):i()}else r.removeEventListener("click",n.current);i.current=!1},o=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),r.removeEventListener("pointerdown",e),r.removeEventListener("click",n.current)}},[r,s]),{onPointerDownCapture:()=>i.current=!0}}(e=>{let r=e.target,s=[...d.branches].some(e=>e.contains(r));b&&!s&&(n?.(e),a?.(e),e.defaultPrevented||l?.())},f),S=function(e,r=globalThis?.document){let s=eo(e),i=W.useRef(!1);return W.useEffect(()=>{let e=e=>{e.target&&!i.current&&eh("dismissableLayer.focusOutside",s,{originalEvent:e},{discrete:!1})};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,s]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{let r=e.target;![...d.branches].some(e=>e.contains(r))&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},f);return!function(e,r=globalThis?.document){let s=eo(e);W.useEffect(()=>{let e=e=>{"Escape"===e.key&&s(e)};return r.addEventListener("keydown",e,{capture:!0}),()=>r.removeEventListener("keydown",e,{capture:!0})},[s,r])}(e=>{_===d.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),W.useEffect(()=>{if(h)return s&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(cy=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),ed(),()=>{s&&1===d.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=cy)}},[h,f,s,d]),W.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),ed())},[h,d]),W.useEffect(()=>{let e=()=>p({});return document.addEventListener(ea,e),()=>document.removeEventListener(ea,e)},[]),(0,F.jsx)(Z.div,{...c,ref:m,style:{pointerEvents:y?b?"auto":"none":void 0,...e.style},onFocusCapture:K(e.onFocusCapture,S.onFocusCapture),onBlurCapture:K(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:K(e.onPointerDownCapture,w.onPointerDownCapture)})});function ed(){let e=new CustomEvent(ea);document.dispatchEvent(e)}function eh(e,r,s,{discrete:i}){let n=s.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});r&&n.addEventListener(e,r,{once:!0}),i?Q(n,o):n.dispatchEvent(o)}ec.displayName="DismissableLayer",W.forwardRef((e,r)=>{let s=W.useContext(el),i=W.useRef(null),n=(0,U.useComposedRefs)(r,i);return W.useEffect(()=>{let e=i.current;if(e)return s.branches.add(e),()=>{s.branches.delete(e)}},[s.branches]),(0,F.jsx)(Z.div,{...e,ref:n})}).displayName="DismissableLayerBranch";var eu=0;function ef(){W.useEffect(()=>{let e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ep()),document.body.insertAdjacentElement("beforeend",e[1]??ep()),eu++,()=>{1===eu&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),eu--}},[])}function ep(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var em="focusScope.autoFocusOnMount",eg="focusScope.autoFocusOnUnmount",ev={bubbles:!1,cancelable:!0},ex=W.forwardRef((e,r)=>{let{loop:s=!1,trapped:i=!1,onMountAutoFocus:n,onUnmountAutoFocus:o,...a}=e,[l,c]=W.useState(null),d=eo(n),h=eo(o),u=W.useRef(null),f=(0,U.useComposedRefs)(r,e=>c(e)),p=W.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;W.useEffect(()=>{if(i){let e=function(e){if(p.paused||!l)return;let r=e.target;l.contains(r)?u.current=r:eb(u.current,{select:!0})},r=function(e){if(p.paused||!l)return;let r=e.relatedTarget;null!==r&&(l.contains(r)||eb(u.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",r);let s=new MutationObserver(function(e){if(document.activeElement===document.body)for(let r of e)r.removedNodes.length>0&&eb(l)});return l&&s.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",r),s.disconnect()}}},[i,l,p.paused]),W.useEffect(()=>{if(l){ew.add(p);let e=document.activeElement;if(!l.contains(e)){let r=new CustomEvent(em,ev);l.addEventListener(em,d),l.dispatchEvent(r),r.defaultPrevented||(function(e,{select:r=!1}={}){let s=document.activeElement;for(let i of e)if(eb(i,{select:r}),document.activeElement!==s)return}(e_(l).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&eb(l))}return()=>{l.removeEventListener(em,d),setTimeout(()=>{let r=new CustomEvent(eg,ev);l.addEventListener(eg,h),l.dispatchEvent(r),r.defaultPrevented||eb(e??document.body,{select:!0}),l.removeEventListener(eg,h),ew.remove(p)},0)}}},[l,d,h,p]);let m=W.useCallback(e=>{if(!s&&!i||p.paused)return;let r="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(r&&n){var o;let r,i=e.currentTarget,[a,l]=[ey(r=e_(o=i),o),ey(r.reverse(),o)];a&&l?e.shiftKey||n!==l?e.shiftKey&&n===a&&(e.preventDefault(),s&&eb(l,{select:!0})):(e.preventDefault(),s&&eb(a,{select:!0})):n===i&&e.preventDefault()}},[s,i,p.paused]);return(0,F.jsx)(Z.div,{tabIndex:-1,...a,ref:f,onKeyDown:m})});function e_(e){let r=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let r="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||r?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)r.push(s.currentNode);return r}function ey(e,r){for(let s of e)if(!function(e,{upTo:r}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===r||e!==r);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(s,{upTo:r}))return s}function eb(e,{select:r=!1}={}){if(e&&e.focus){var s;let i=document.activeElement;e.focus({preventScroll:!0}),e!==i&&(s=e)instanceof HTMLInputElement&&"select"in s&&r&&e.select()}}ex.displayName="FocusScope";var ew=(x=[],{add(e){let r=x[0];e!==r&&r?.pause(),(x=eS(x,e)).unshift(e)},remove(e){x=eS(x,e),x[0]?.resume()}});function eS(e,r){let s=[...e],i=s.indexOf(r);return -1!==i&&s.splice(i,1),s}var eC=W[" useId ".trim().toString()]||(()=>void 0),ek=0;function ej(e){let[r,s]=W.useState(eC());return V(()=>{e||s(e=>e??String(ek++))},[e]),e||(r?`radix-${r}`:"")}let eN=["top","right","bottom","left"],eE=Math.min,eR=Math.max,eM=Math.round,eD=Math.floor,eT=e=>({x:e,y:e}),eP={left:"right",right:"left",bottom:"top",top:"bottom"},eL={start:"end",end:"start"};function eB(e,r){return"function"==typeof e?e(r):e}function eA(e){return e.split("-")[0]}function eO(e){return e.split("-")[1]}function eI(e){return"x"===e?"y":"x"}function ez(e){return"y"===e?"height":"width"}let eF=new Set(["top","bottom"]);function eW(e){return eF.has(eA(e))?"y":"x"}function eH(e){return e.replace(/start|end/g,e=>eL[e])}let e$=["left","right"],eK=["right","left"],eU=["top","bottom"],eq=["bottom","top"];function eV(e){return e.replace(/left|right|bottom|top/g,e=>eP[e])}function eY(e){return"number"!=typeof e?{top:0,right:0,bottom:0,left:0,...e}:{top:e,right:e,bottom:e,left:e}}function eX(e){let{x:r,y:s,width:i,height:n}=e;return{width:i,height:n,top:s,left:r,right:r+i,bottom:s+n,x:r,y:s}}function eG(e,r,s){let i,{reference:n,floating:o}=e,a=eW(r),l=eI(eW(r)),c=ez(l),d=eA(r),h="y"===a,u=n.x+n.width/2-o.width/2,f=n.y+n.height/2-o.height/2,p=n[c]/2-o[c]/2;switch(d){case"top":i={x:u,y:n.y-o.height};break;case"bottom":i={x:u,y:n.y+n.height};break;case"right":i={x:n.x+n.width,y:f};break;case"left":i={x:n.x-o.width,y:f};break;default:i={x:n.x,y:n.y}}switch(eO(r)){case"start":i[l]-=p*(s&&h?-1:1);break;case"end":i[l]+=p*(s&&h?-1:1)}return i}async function eJ(e,r){var s;void 0===r&&(r={});let{x:i,y:n,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:f=!1,padding:p=0}=eB(r,e),m=eY(p),g=l[f?"floating"===u?"reference":"floating":u],v=eX(await o.getClippingRect({element:null==(s=await (null==o.isElement?void 0:o.isElement(g)))||s?g:g.contextElement||await (null==o.getDocumentElement?void 0:o.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:c})),x="floating"===u?{x:i,y:n,width:a.floating.width,height:a.floating.height}:a.reference,_=await (null==o.getOffsetParent?void 0:o.getOffsetParent(l.floating)),y=await (null==o.isElement?void 0:o.isElement(_))&&await (null==o.getScale?void 0:o.getScale(_))||{x:1,y:1},b=eX(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:_,strategy:c}):x);return{top:(v.top-b.top+m.top)/y.y,bottom:(b.bottom-v.bottom+m.bottom)/y.y,left:(v.left-b.left+m.left)/y.x,right:(b.right-v.right+m.right)/y.x}}let eZ=async(e,r,s)=>{let{placement:i="bottom",strategy:n="absolute",middleware:o=[],platform:a}=s,l=o.filter(Boolean),c=await (null==a.isRTL?void 0:a.isRTL(r)),d=await a.getElementRects({reference:e,floating:r,strategy:n}),{x:h,y:u}=eG(d,i,c),f=i,p={},m=0;for(let s=0;s<l.length;s++){var g;let{name:o,fn:v}=l[s],{x:x,y:_,data:y,reset:b}=await v({x:h,y:u,initialPlacement:i,placement:f,strategy:n,middlewareData:p,rects:d,platform:{...a,detectOverflow:null!=(g=a.detectOverflow)?g:eJ},elements:{reference:e,floating:r}});h=null!=x?x:h,u=null!=_?_:u,p={...p,[o]:{...p[o],...y}},b&&m<=50&&(m++,"object"==typeof b&&(b.placement&&(f=b.placement),b.rects&&(d=!0===b.rects?await a.getElementRects({reference:e,floating:r,strategy:n}):b.rects),{x:h,y:u}=eG(d,f,c)),s=-1)}return{x:h,y:u,placement:f,strategy:n,middlewareData:p}};function eQ(e,r){return{top:e.top-r.height,right:e.right-r.width,bottom:e.bottom-r.height,left:e.left-r.width}}function e0(e){return eN.some(r=>e[r]>=0)}let e1=new Set(["left","top"]);async function e2(e,r){let{placement:s,platform:i,elements:n}=e,o=await (null==i.isRTL?void 0:i.isRTL(n.floating)),a=eA(s),l=eO(s),c="y"===eW(s),d=e1.has(a)?-1:1,h=o&&c?-1:1,u=eB(r,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&"number"==typeof m&&(p="end"===l?-1*m:m),c?{x:p*h,y:f*d}:{x:f*d,y:p*h}}function e5(){return"undefined"!=typeof window}function e3(e){return e8(e)?(e.nodeName||"").toLowerCase():"#document"}function e4(e){var r;return(null==e||null==(r=e.ownerDocument)?void 0:r.defaultView)||window}function e6(e){var r;return null==(r=(e8(e)?e.ownerDocument:e.document)||window.document)?void 0:r.documentElement}function e8(e){return!!e5()&&(e instanceof Node||e instanceof e4(e).Node)}function e7(e){return!!e5()&&(e instanceof Element||e instanceof e4(e).Element)}function e9(e){return!!e5()&&(e instanceof HTMLElement||e instanceof e4(e).HTMLElement)}function te(e){return!!e5()&&"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof e4(e).ShadowRoot)}let tt=new Set(["inline","contents"]);function tr(e){let{overflow:r,overflowX:s,overflowY:i,display:n}=tf(e);return/auto|scroll|overlay|hidden|clip/.test(r+i+s)&&!tt.has(n)}let ts=new Set(["table","td","th"]),ti=[":popover-open",":modal"];function tn(e){return ti.some(r=>{try{return e.matches(r)}catch(e){return!1}})}let to=["transform","translate","scale","rotate","perspective"],ta=["transform","translate","scale","rotate","perspective","filter"],tl=["paint","layout","strict","content"];function tc(e){let r=td(),s=e7(e)?tf(e):e;return to.some(e=>!!s[e]&&"none"!==s[e])||!!s.containerType&&"normal"!==s.containerType||!r&&!!s.backdropFilter&&"none"!==s.backdropFilter||!r&&!!s.filter&&"none"!==s.filter||ta.some(e=>(s.willChange||"").includes(e))||tl.some(e=>(s.contain||"").includes(e))}function td(){return"undefined"!=typeof CSS&&!!CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")}let th=new Set(["html","body","#document"]);function tu(e){return th.has(e3(e))}function tf(e){return e4(e).getComputedStyle(e)}function tp(e){return e7(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function tm(e){if("html"===e3(e))return e;let r=e.assignedSlot||e.parentNode||te(e)&&e.host||e6(e);return te(r)?r.host:r}function tg(e,r,s){var i;void 0===r&&(r=[]),void 0===s&&(s=!0);let n=function e(r){let s=tm(r);return tu(s)?r.ownerDocument?r.ownerDocument.body:r.body:e9(s)&&tr(s)?s:e(s)}(e),o=n===(null==(i=e.ownerDocument)?void 0:i.body),a=e4(n);if(o){let e=tv(a);return r.concat(a,a.visualViewport||[],tr(n)?n:[],e&&s?tg(e):[])}return r.concat(n,tg(n,[],s))}function tv(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function tx(e){let r=tf(e),s=parseFloat(r.width)||0,i=parseFloat(r.height)||0,n=e9(e),o=n?e.offsetWidth:s,a=n?e.offsetHeight:i,l=eM(s)!==o||eM(i)!==a;return l&&(s=o,i=a),{width:s,height:i,$:l}}function t_(e){return e7(e)?e:e.contextElement}function ty(e){let r=t_(e);if(!e9(r))return eT(1);let s=r.getBoundingClientRect(),{width:i,height:n,$:o}=tx(r),a=(o?eM(s.width):s.width)/i,l=(o?eM(s.height):s.height)/n;return a&&Number.isFinite(a)||(a=1),l&&Number.isFinite(l)||(l=1),{x:a,y:l}}let tb=eT(0);function tw(e){let r=e4(e);return td()&&r.visualViewport?{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}:tb}function tS(e,r,s,i){var n;void 0===r&&(r=!1),void 0===s&&(s=!1);let o=e.getBoundingClientRect(),a=t_(e),l=eT(1);r&&(i?e7(i)&&(l=ty(i)):l=ty(e));let c=(void 0===(n=s)&&(n=!1),i&&(!n||i===e4(a))&&n)?tw(a):eT(0),d=(o.left+c.x)/l.x,h=(o.top+c.y)/l.y,u=o.width/l.x,f=o.height/l.y;if(a){let e=e4(a),r=i&&e7(i)?e4(i):i,s=e,n=tv(s);for(;n&&i&&r!==s;){let e=ty(n),r=n.getBoundingClientRect(),i=tf(n),o=r.left+(n.clientLeft+parseFloat(i.paddingLeft))*e.x,a=r.top+(n.clientTop+parseFloat(i.paddingTop))*e.y;d*=e.x,h*=e.y,u*=e.x,f*=e.y,d+=o,h+=a,n=tv(s=e4(n))}}return eX({width:u,height:f,x:d,y:h})}function tC(e,r){let s=tp(e).scrollLeft;return r?r.left+s:tS(e6(e)).left+s}function tk(e,r){let s=e.getBoundingClientRect();return{x:s.left+r.scrollLeft-tC(e,s),y:s.top+r.scrollTop}}let tj=new Set(["absolute","fixed"]);function tN(e,r,s){var i;let n;if("viewport"===r)n=function(e,r){let s=e4(e),i=e6(e),n=s.visualViewport,o=i.clientWidth,a=i.clientHeight,l=0,c=0;if(n){o=n.width,a=n.height;let e=td();(!e||e&&"fixed"===r)&&(l=n.offsetLeft,c=n.offsetTop)}let d=tC(i);if(d<=0){let e=i.ownerDocument,r=e.body,s=getComputedStyle(r),n="CSS1Compat"===e.compatMode&&parseFloat(s.marginLeft)+parseFloat(s.marginRight)||0,a=Math.abs(i.clientWidth-r.clientWidth-n);a<=25&&(o-=a)}else d<=25&&(o+=d);return{width:o,height:a,x:l,y:c}}(e,s);else if("document"===r){let r,s,o,a,l,c,d;i=e6(e),r=e6(i),s=tp(i),o=i.ownerDocument.body,a=eR(r.scrollWidth,r.clientWidth,o.scrollWidth,o.clientWidth),l=eR(r.scrollHeight,r.clientHeight,o.scrollHeight,o.clientHeight),c=-s.scrollLeft+tC(i),d=-s.scrollTop,"rtl"===tf(o).direction&&(c+=eR(r.clientWidth,o.clientWidth)-a),n={width:a,height:l,x:c,y:d}}else if(e7(r)){let e,i,o,a,l,c;i=(e=tS(r,!0,"fixed"===s)).top+r.clientTop,o=e.left+r.clientLeft,a=e9(r)?ty(r):eT(1),l=r.clientWidth*a.x,c=r.clientHeight*a.y,n={width:l,height:c,x:o*a.x,y:i*a.y}}else{let s=tw(e);n={x:r.x-s.x,y:r.y-s.y,width:r.width,height:r.height}}return eX(n)}function tE(e){return"static"===tf(e).position}function tR(e,r){if(!e9(e)||"fixed"===tf(e).position)return null;if(r)return r(e);let s=e.offsetParent;return e6(e)===s&&(s=s.ownerDocument.body),s}function tM(e,r){var s;let i=e4(e);if(tn(e))return i;if(!e9(e)){let r=tm(e);for(;r&&!tu(r);){if(e7(r)&&!tE(r))return r;r=tm(r)}return i}let n=tR(e,r);for(;n&&(s=n,ts.has(e3(s)))&&tE(n);)n=tR(n,r);return n&&tu(n)&&tE(n)&&!tc(n)?i:n||function(e){let r=tm(e);for(;e9(r)&&!tu(r);){if(tc(r))return r;if(tn(r))break;r=tm(r)}return null}(e)||i}let tD=async function(e){let r=this.getOffsetParent||tM,s=this.getDimensions,i=await s(e.floating);return{reference:function(e,r,s){let i=e9(r),n=e6(r),o="fixed"===s,a=tS(e,!0,o,r),l={scrollLeft:0,scrollTop:0},c=eT(0);if(i||!i&&!o)if(("body"!==e3(r)||tr(n))&&(l=tp(r)),i){let e=tS(r,!0,o,r);c.x=e.x+r.clientLeft,c.y=e.y+r.clientTop}else n&&(c.x=tC(n));o&&!i&&n&&(c.x=tC(n));let d=!n||i||o?eT(0):tk(n,l);return{x:a.left+l.scrollLeft-c.x-d.x,y:a.top+l.scrollTop-c.y-d.y,width:a.width,height:a.height}}(e.reference,await r(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},tT={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:r,rect:s,offsetParent:i,strategy:n}=e,o="fixed"===n,a=e6(i),l=!!r&&tn(r.floating);if(i===a||l&&o)return s;let c={scrollLeft:0,scrollTop:0},d=eT(1),h=eT(0),u=e9(i);if((u||!u&&!o)&&(("body"!==e3(i)||tr(a))&&(c=tp(i)),e9(i))){let e=tS(i);d=ty(i),h.x=e.x+i.clientLeft,h.y=e.y+i.clientTop}let f=!a||u||o?eT(0):tk(a,c);return{width:s.width*d.x,height:s.height*d.y,x:s.x*d.x-c.scrollLeft*d.x+h.x+f.x,y:s.y*d.y-c.scrollTop*d.y+h.y+f.y}},getDocumentElement:e6,getClippingRect:function(e){let{element:r,boundary:s,rootBoundary:i,strategy:n}=e,o=[..."clippingAncestors"===s?tn(r)?[]:function(e,r){let s=r.get(e);if(s)return s;let i=tg(e,[],!1).filter(e=>e7(e)&&"body"!==e3(e)),n=null,o="fixed"===tf(e).position,a=o?tm(e):e;for(;e7(a)&&!tu(a);){let r=tf(a),s=tc(a);s||"fixed"!==r.position||(n=null),(o?!s&&!n:!s&&"static"===r.position&&!!n&&tj.has(n.position)||tr(a)&&!s&&function e(r,s){let i=tm(r);return!(i===s||!e7(i)||tu(i))&&("fixed"===tf(i).position||e(i,s))}(e,a))?i=i.filter(e=>e!==a):n=r,a=tm(a)}return r.set(e,i),i}(r,this._c):[].concat(s),i],a=o[0],l=o.reduce((e,s)=>{let i=tN(r,s,n);return e.top=eR(i.top,e.top),e.right=eE(i.right,e.right),e.bottom=eE(i.bottom,e.bottom),e.left=eR(i.left,e.left),e},tN(r,a,n));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:tM,getElementRects:tD,getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:r,height:s}=tx(e);return{width:r,height:s}},getScale:ty,isElement:e7,isRTL:function(e){return"rtl"===tf(e).direction}};function tP(e,r){return e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height}let tL=e=>({name:"arrow",options:e,async fn(r){let{x:s,y:i,placement:n,rects:o,platform:a,elements:l,middlewareData:c}=r,{element:d,padding:h=0}=eB(e,r)||{};if(null==d)return{};let u=eY(h),f={x:s,y:i},p=eI(eW(n)),m=ez(p),g=await a.getDimensions(d),v="y"===p,x=v?"clientHeight":"clientWidth",_=o.reference[m]+o.reference[p]-f[p]-o.floating[m],y=f[p]-o.reference[p],b=await (null==a.getOffsetParent?void 0:a.getOffsetParent(d)),w=b?b[x]:0;w&&await (null==a.isElement?void 0:a.isElement(b))||(w=l.floating[x]||o.floating[m]);let S=w/2-g[m]/2-1,C=eE(u[v?"top":"left"],S),k=eE(u[v?"bottom":"right"],S),j=w-g[m]-k,N=w/2-g[m]/2+(_/2-y/2),E=eR(C,eE(N,j)),R=!c.arrow&&null!=eO(n)&&N!==E&&o.reference[m]/2-(N<C?C:k)-g[m]/2<0,M=R?N<C?N-C:N-j:0;return{[p]:f[p]+M,data:{[p]:E,centerOffset:N-E-M,...R&&{alignmentOffset:M}},reset:R}}});var tB="undefined"!=typeof document?W.useLayoutEffect:function(){};function tA(e,r){let s,i,n;if(e===r)return!0;if(typeof e!=typeof r)return!1;if("function"==typeof e&&e.toString()===r.toString())return!0;if(e&&r&&"object"==typeof e){if(Array.isArray(e)){if((s=e.length)!==r.length)return!1;for(i=s;0!=i--;)if(!tA(e[i],r[i]))return!1;return!0}if((s=(n=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(i=s;0!=i--;)if(!({}).hasOwnProperty.call(r,n[i]))return!1;for(i=s;0!=i--;){let s=n[i];if(("_owner"!==s||!e.$$typeof)&&!tA(e[s],r[s]))return!1}return!0}return e!=e&&r!=r}function tO(e){return"undefined"==typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function tI(e,r){let s=tO(e);return Math.round(r*s)/s}function tz(e){let r=W.useRef(e);return tB(()=>{r.current=e}),r}var tF=W.forwardRef((e,r)=>{let{children:s,width:i=10,height:n=5,...o}=e;return(0,F.jsx)(Z.svg,{...o,ref:r,width:i,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:(0,F.jsx)("polygon",{points:"0,0 30,0 15,10"})})});function tW(e){let[r,s]=W.useState(void 0);return V(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});let r=new ResizeObserver(r=>{let i,n;if(!Array.isArray(r)||!r.length)return;let o=r[0];if("borderBoxSize"in o){let e=o.borderBoxSize,r=Array.isArray(e)?e[0]:e;i=r.inlineSize,n=r.blockSize}else i=e.offsetWidth,n=e.offsetHeight;s({width:i,height:n})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}s(void 0)},[e]),r}tF.displayName="Arrow";var tH="Popper",[t$,tK]=q(tH),[tU,tq]=t$(tH),tV=e=>{let{__scopePopper:r,children:s}=e,[i,n]=W.useState(null);return(0,F.jsx)(tU,{scope:r,anchor:i,onAnchorChange:n,children:s})};tV.displayName=tH;var tY="PopperAnchor",tX=W.forwardRef((e,r)=>{let{__scopePopper:s,virtualRef:i,...n}=e,o=tq(tY,s),a=W.useRef(null),l=(0,U.useComposedRefs)(r,a),c=W.useRef(null);return W.useEffect(()=>{let e=c.current;c.current=i?.current||a.current,e!==c.current&&o.onAnchorChange(c.current)}),i?null:(0,F.jsx)(Z.div,{...n,ref:l})});tX.displayName=tY;var tG="PopperContent",[tJ,tZ]=t$(tG),tQ=W.forwardRef((e,r)=>{var s,i,n,o,a,l,c,d,h,u,f,p,m,g,v,x,_,y,b,w,S;let{__scopePopper:C,side:k="bottom",sideOffset:j=0,align:N="center",alignOffset:E=0,arrowPadding:R=0,avoidCollisions:M=!0,collisionBoundary:D=[],collisionPadding:T=0,sticky:P="partial",hideWhenDetached:L=!1,updatePositionStrategy:B="optimized",onPlaced:A,...O}=e,I=tq(tG,C),[z,H]=W.useState(null),$=(0,U.useComposedRefs)(r,e=>H(e)),[K,q]=W.useState(null),Y=tW(K),X=Y?.width??0,J=Y?.height??0,Q="number"==typeof T?T:{top:0,right:0,bottom:0,left:0,...T},ee=Array.isArray(D)?D:[D],et=ee.length>0,er={padding:Q,boundary:ee.filter(t5),altBoundary:et},{refs:es,floatingStyles:ei,placement:en,isPositioned:ea,middlewareData:el}=function(e){void 0===e&&(e={});let{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:n,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[h,u]=W.useState({x:0,y:0,strategy:s,placement:r,middlewareData:{},isPositioned:!1}),[f,p]=W.useState(i);tA(f,i)||p(i);let[m,g]=W.useState(null),[v,x]=W.useState(null),_=W.useCallback(e=>{e!==S.current&&(S.current=e,g(e))},[]),y=W.useCallback(e=>{e!==C.current&&(C.current=e,x(e))},[]),b=o||m,w=a||v,S=W.useRef(null),C=W.useRef(null),k=W.useRef(h),j=null!=c,N=tz(c),E=tz(n),R=tz(d),M=W.useCallback(()=>{var e,i;let n,o,a;if(!S.current||!C.current)return;let l={placement:r,strategy:s,middleware:f};E.current&&(l.platform=E.current),(e=S.current,i=C.current,n=new Map,a={...(o={platform:tT,...l}).platform,_c:n},eZ(e,i,{...o,platform:a})).then(e=>{let r={...e,isPositioned:!1!==R.current};D.current&&!tA(k.current,r)&&(k.current=r,G.flushSync(()=>{u(r)}))})},[f,r,s,E,R]);tB(()=>{!1===d&&k.current.isPositioned&&(k.current.isPositioned=!1,u(e=>({...e,isPositioned:!1})))},[d]);let D=W.useRef(!1);tB(()=>(D.current=!0,()=>{D.current=!1}),[]),tB(()=>{if(b&&(S.current=b),w&&(C.current=w),b&&w){if(N.current)return N.current(b,w,M);M()}},[b,w,M,N,j]);let T=W.useMemo(()=>({reference:S,floating:C,setReference:_,setFloating:y}),[_,y]),P=W.useMemo(()=>({reference:b,floating:w}),[b,w]),L=W.useMemo(()=>{let e={position:s,left:0,top:0};if(!P.floating)return e;let r=tI(P.floating,h.x),i=tI(P.floating,h.y);return l?{...e,transform:"translate("+r+"px, "+i+"px)",...tO(P.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:r,top:i}},[s,l,P.floating,h.x,h.y]);return W.useMemo(()=>({...h,update:M,refs:T,elements:P,floatingStyles:L}),[h,M,T,P,L])}({strategy:"fixed",placement:k+("center"!==N?"-"+N:""),whileElementsMounted:(...e)=>(function(e,r,s,i){let n;void 0===i&&(i={});let{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:c="function"==typeof IntersectionObserver,animationFrame:d=!1}=i,h=t_(e),u=o||a?[...h?tg(h):[],...tg(r)]:[];u.forEach(e=>{o&&e.addEventListener("scroll",s,{passive:!0}),a&&e.addEventListener("resize",s)});let f=h&&c?function(e,r){let s,i=null,n=e6(e);function o(){var e;clearTimeout(s),null==(e=i)||e.disconnect(),i=null}return!function a(l,c){void 0===l&&(l=!1),void 0===c&&(c=1),o();let d=e.getBoundingClientRect(),{left:h,top:u,width:f,height:p}=d;if(l||r(),!f||!p)return;let m={rootMargin:-eD(u)+"px "+-eD(n.clientWidth-(h+f))+"px "+-eD(n.clientHeight-(u+p))+"px "+-eD(h)+"px",threshold:eR(0,eE(1,c))||1},g=!0;function v(r){let i=r[0].intersectionRatio;if(i!==c){if(!g)return a();i?a(!1,i):s=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==i||tP(d,e.getBoundingClientRect())||a(),g=!1}try{i=new IntersectionObserver(v,{...m,root:n.ownerDocument})}catch(e){i=new IntersectionObserver(v,m)}i.observe(e)}(!0),o}(h,s):null,p=-1,m=null;l&&(m=new ResizeObserver(e=>{let[i]=e;i&&i.target===h&&m&&(m.unobserve(r),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=m)||e.observe(r)})),s()}),h&&!d&&m.observe(h),m.observe(r));let g=d?tS(e):null;return d&&function r(){let i=tS(e);g&&!tP(g,i)&&s(),g=i,n=requestAnimationFrame(r)}(),s(),()=>{var e;u.forEach(e=>{o&&e.removeEventListener("scroll",s),a&&e.removeEventListener("resize",s)}),null==f||f(),null==(e=m)||e.disconnect(),m=null,d&&cancelAnimationFrame(n)}})(...e,{animationFrame:"always"===B}),elements:{reference:I.anchor},middleware:[{...{name:"offset",options:n=s={mainAxis:j+J,alignmentAxis:E},async fn(e){var r,s;let{x:i,y:o,placement:a,middlewareData:l}=e,c=await e2(e,n);return a===(null==(r=l.offset)?void 0:r.placement)&&null!=(s=l.arrow)&&s.alignmentOffset?{}:{x:i+c.x,y:o+c.y,data:{...c,placement:a}}}},options:[s,i]},M&&{...{name:"shift",options:h=c={mainAxis:!0,crossAxis:!1,limiter:"partial"===P?{...(void 0===(l=o)&&(l={}),{options:l,fn(e){let{x:r,y:s,placement:i,rects:n,middlewareData:o}=e,{offset:a=0,mainAxis:c=!0,crossAxis:d=!0}=eB(l,e),h={x:r,y:s},u=eW(i),f=eI(u),p=h[f],m=h[u],g=eB(a,e),v="number"==typeof g?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){let e="y"===f?"height":"width",r=n.reference[f]-n.floating[e]+v.mainAxis,s=n.reference[f]+n.reference[e]-v.mainAxis;p<r?p=r:p>s&&(p=s)}if(d){var x,_;let e="y"===f?"width":"height",r=e1.has(eA(i)),s=n.reference[u]-n.floating[e]+(r&&(null==(x=o.offset)?void 0:x[u])||0)+(r?0:v.crossAxis),a=n.reference[u]+n.reference[e]+(r?0:(null==(_=o.offset)?void 0:_[u])||0)-(r?v.crossAxis:0);m<s?m=s:m>a&&(m=a)}return{[f]:p,[u]:m}}}),options:[o,a]}:void 0,...er},async fn(e){let{x:r,y:s,placement:i,platform:n}=e,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:e=>{let{x:r,y:s}=e;return{x:r,y:s}}},...c}=eB(h,e),d={x:r,y:s},u=await n.detectOverflow(e,c),f=eW(eA(i)),p=eI(f),m=d[p],g=d[f];if(o){let e="y"===p?"top":"left",r="y"===p?"bottom":"right",s=m+u[e],i=m-u[r];m=eR(s,eE(m,i))}if(a){let e="y"===f?"top":"left",r="y"===f?"bottom":"right",s=g+u[e],i=g-u[r];g=eR(s,eE(g,i))}let v=l.fn({...e,[p]:m,[f]:g});return{...v,data:{x:v.x-r,y:v.y-s,enabled:{[p]:o,[f]:a}}}}},options:[c,d]},M&&{...{name:"flip",options:p=u={...er},async fn(e){var r,s,i,n,o,a,l,c;let d,h,u,{placement:f,middlewareData:m,rects:g,initialPlacement:v,platform:x,elements:_}=e,{mainAxis:y=!0,crossAxis:b=!0,fallbackPlacements:w,fallbackStrategy:S="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:k=!0,...j}=eB(p,e);if(null!=(r=m.arrow)&&r.alignmentOffset)return{};let N=eA(f),E=eW(v),R=eA(v)===v,M=await (null==x.isRTL?void 0:x.isRTL(_.floating)),D=w||(R||!k?[eV(v)]:(d=eV(v),[eH(v),d,eH(d)])),T="none"!==C;!w&&T&&D.push(...(h=eO(v),u=function(e,r,s){switch(e){case"top":case"bottom":if(s)return r?eK:e$;return r?e$:eK;case"left":case"right":return r?eU:eq;default:return[]}}(eA(v),"start"===C,M),h&&(u=u.map(e=>e+"-"+h),k&&(u=u.concat(u.map(eH)))),u));let P=[v,...D],L=await x.detectOverflow(e,j),B=[],A=(null==(s=m.flip)?void 0:s.overflows)||[];if(y&&B.push(L[N]),b){let e,r,s,i,n=(a=f,l=g,void 0===(c=M)&&(c=!1),e=eO(a),s=ez(r=eI(eW(a))),i="x"===r?e===(c?"end":"start")?"right":"left":"start"===e?"bottom":"top",l.reference[s]>l.floating[s]&&(i=eV(i)),[i,eV(i)]);B.push(L[n[0]],L[n[1]])}if(A=[...A,{placement:f,overflows:B}],!B.every(e=>e<=0)){let e=((null==(i=m.flip)?void 0:i.index)||0)+1,r=P[e];if(r&&("alignment"!==b||E===eW(r)||A.every(e=>eW(e.placement)!==E||e.overflows[0]>0)))return{data:{index:e,overflows:A},reset:{placement:r}};let s=null==(n=A.filter(e=>e.overflows[0]<=0).sort((e,r)=>e.overflows[1]-r.overflows[1])[0])?void 0:n.placement;if(!s)switch(S){case"bestFit":{let e=null==(o=A.filter(e=>{if(T){let r=eW(e.placement);return r===E||"y"===r}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,r)=>e+r,0)]).sort((e,r)=>e[1]-r[1])[0])?void 0:o[0];e&&(s=e);break}case"initialPlacement":s=v}if(f!==s)return{reset:{placement:s}}}return{}}},options:[u,f]},{...{name:"size",options:v=m={...er,apply:({elements:e,rects:r,availableWidth:s,availableHeight:i})=>{let{width:n,height:o}=r.reference,a=e.floating.style;a.setProperty("--radix-popper-available-width",`${s}px`),a.setProperty("--radix-popper-available-height",`${i}px`),a.setProperty("--radix-popper-anchor-width",`${n}px`),a.setProperty("--radix-popper-anchor-height",`${o}px`)}},async fn(e){var r,s;let i,n,{placement:o,rects:a,platform:l,elements:c}=e,{apply:d=()=>{},...h}=eB(v,e),u=await l.detectOverflow(e,h),f=eA(o),p=eO(o),m="y"===eW(o),{width:g,height:x}=a.floating;"top"===f||"bottom"===f?(i=f,n=p===(await (null==l.isRTL?void 0:l.isRTL(c.floating))?"start":"end")?"left":"right"):(n=f,i="end"===p?"top":"bottom");let _=x-u.top-u.bottom,y=g-u.left-u.right,b=eE(x-u[i],_),w=eE(g-u[n],y),S=!e.middlewareData.shift,C=b,k=w;if(null!=(r=e.middlewareData.shift)&&r.enabled.x&&(k=y),null!=(s=e.middlewareData.shift)&&s.enabled.y&&(C=_),S&&!p){let e=eR(u.left,0),r=eR(u.right,0),s=eR(u.top,0),i=eR(u.bottom,0);m?k=g-2*(0!==e||0!==r?e+r:eR(u.left,u.right)):C=x-2*(0!==s||0!==i?s+i:eR(u.top,u.bottom))}await d({...e,availableWidth:k,availableHeight:C});let j=await l.getDimensions(c.floating);return g!==j.width||x!==j.height?{reset:{rects:!0}}:{}}},options:[m,g]},K&&{...{name:"arrow",options:y=x={element:K,padding:R},fn(e){let{element:r,padding:s}="function"==typeof y?y(e):y;return r&&({}).hasOwnProperty.call(r,"current")?null!=r.current?tL({element:r.current,padding:s}).fn(e):{}:r?tL({element:r,padding:s}).fn(e):{}}},options:[x,_]},t3({arrowWidth:X,arrowHeight:J}),L&&{...{name:"hide",options:S=b={strategy:"referenceHidden",...er},async fn(e){let{rects:r,platform:s}=e,{strategy:i="referenceHidden",...n}=eB(S,e);switch(i){case"referenceHidden":{let i=eQ(await s.detectOverflow(e,{...n,elementContext:"reference"}),r.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:e0(i)}}}case"escaped":{let i=eQ(await s.detectOverflow(e,{...n,altBoundary:!0}),r.floating);return{data:{escapedOffsets:i,escaped:e0(i)}}}default:return{}}}},options:[b,w]}]}),[ec,ed]=t4(en),eh=eo(A);V(()=>{ea&&eh?.()},[ea,eh]);let eu=el.arrow?.x,ef=el.arrow?.y,ep=el.arrow?.centerOffset!==0,[em,eg]=W.useState();return V(()=>{z&&eg(window.getComputedStyle(z).zIndex)},[z]),(0,F.jsx)("div",{ref:es.setFloating,"data-radix-popper-content-wrapper":"",style:{...ei,transform:ea?ei.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:em,"--radix-popper-transform-origin":[el.transformOrigin?.x,el.transformOrigin?.y].join(" "),...el.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,F.jsx)(tJ,{scope:C,placedSide:ec,onArrowChange:q,arrowX:eu,arrowY:ef,shouldHideArrow:ep,children:(0,F.jsx)(Z.div,{"data-side":ec,"data-align":ed,...O,ref:$,style:{...O.style,animation:ea?void 0:"none"}})})})});tQ.displayName=tG;var t0="PopperArrow",t1={top:"bottom",right:"left",bottom:"top",left:"right"},t2=W.forwardRef(function(e,r){let{__scopePopper:s,...i}=e,n=tZ(t0,s),o=t1[n.placedSide];return(0,F.jsx)("span",{ref:n.onArrowChange,style:{position:"absolute",left:n.arrowX,top:n.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n.placedSide],visibility:n.shouldHideArrow?"hidden":void 0},children:(0,F.jsx)(tF,{...i,ref:r,style:{...i.style,display:"block"}})})});function t5(e){return null!==e}t2.displayName=t0;var t3=e=>({name:"transformOrigin",options:e,fn(r){let{placement:s,rects:i,middlewareData:n}=r,o=n.arrow?.centerOffset!==0,a=o?0:e.arrowWidth,l=o?0:e.arrowHeight,[c,d]=t4(s),h={start:"0%",center:"50%",end:"100%"}[d],u=(n.arrow?.x??0)+a/2,f=(n.arrow?.y??0)+l/2,p="",m="";return"bottom"===c?(p=o?h:`${u}px`,m=`${-l}px`):"top"===c?(p=o?h:`${u}px`,m=`${i.floating.height+l}px`):"right"===c?(p=`${-l}px`,m=o?h:`${f}px`):"left"===c&&(p=`${i.floating.width+l}px`,m=o?h:`${f}px`),{data:{x:p,y:m}}}});function t4(e){let[r,s="center"]=e.split("-");return[r,s]}var t6=W.forwardRef((e,r)=>{let{container:s,...i}=e,[n,o]=W.useState(!1);V(()=>o(!0),[]);let a=s||n&&globalThis?.document?.body;return a?G.default.createPortal((0,F.jsx)(Z.div,{...i,ref:r}),a):null});t6.displayName="Portal";var t8=e=>{var r;let s,i,{present:n,children:o}=e,a=function(e){var r,s;let[i,n]=W.useState(),o=W.useRef(null),a=W.useRef(e),l=W.useRef("none"),[c,d]=(r=e?"mounted":"unmounted",s={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},W.useReducer((e,r)=>s[e][r]??e,r));return W.useEffect(()=>{let e=t7(o.current);l.current="mounted"===c?e:"none"},[c]),V(()=>{let r=o.current,s=a.current;if(s!==e){let i=l.current,n=t7(r);e?d("MOUNT"):"none"===n||r?.display==="none"?d("UNMOUNT"):s&&i!==n?d("ANIMATION_OUT"):d("UNMOUNT"),a.current=e}},[e,d]),V(()=>{if(i){let e,r=i.ownerDocument.defaultView??window,s=s=>{let n=t7(o.current).includes(CSS.escape(s.animationName));if(s.target===i&&n&&(d("ANIMATION_END"),!a.current)){let s=i.style.animationFillMode;i.style.animationFillMode="forwards",e=r.setTimeout(()=>{"forwards"===i.style.animationFillMode&&(i.style.animationFillMode=s)})}},n=e=>{e.target===i&&(l.current=t7(o.current))};return i.addEventListener("animationstart",n),i.addEventListener("animationcancel",s),i.addEventListener("animationend",s),()=>{r.clearTimeout(e),i.removeEventListener("animationstart",n),i.removeEventListener("animationcancel",s),i.removeEventListener("animationend",s)}}d("ANIMATION_END")},[i,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:W.useCallback(e=>{o.current=e?getComputedStyle(e):null,n(e)},[])}}(n),l="function"==typeof o?o({present:a.isPresent}):W.Children.only(o),c=(0,U.useComposedRefs)(a.ref,(r=l,(i=(s=Object.getOwnPropertyDescriptor(r.props,"ref")?.get)&&"isReactWarning"in s&&s.isReactWarning)?r.ref:(i=(s=Object.getOwnPropertyDescriptor(r,"ref")?.get)&&"isReactWarning"in s&&s.isReactWarning)?r.props.ref:r.props.ref||r.ref));return"function"==typeof o||a.isPresent?W.cloneElement(l,{ref:c}):null};function t7(e){return e?.animationName||"none"}t8.displayName="Presence";var t9="rovingFocusGroup.onEntryFocus",re={bubbles:!1,cancelable:!0},rt="RovingFocusGroup",[rr,rs,ri]=ee(rt),[rn,ro]=q(rt,[ri]),[ra,rl]=rn(rt),rc=W.forwardRef((e,r)=>(0,F.jsx)(rr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(rr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(rd,{...e,ref:r})})}));rc.displayName=rt;var rd=W.forwardRef((e,r)=>{let{__scopeRovingFocusGroup:s,orientation:i,loop:n=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:h=!1,...u}=e,f=W.useRef(null),p=(0,U.useComposedRefs)(r,f),m=en(o),[g,v]=X({prop:a,defaultProp:l??null,onChange:c,caller:rt}),[x,_]=W.useState(!1),y=eo(d),b=rs(s),w=W.useRef(!1),[S,C]=W.useState(0);return W.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(t9,y),()=>e.removeEventListener(t9,y)},[y]),(0,F.jsx)(ra,{scope:s,orientation:i,dir:m,loop:n,currentTabStopId:g,onItemFocus:W.useCallback(e=>v(e),[v]),onItemShiftTab:W.useCallback(()=>_(!0),[]),onFocusableItemAdd:W.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:W.useCallback(()=>C(e=>e-1),[]),children:(0,F.jsx)(Z.div,{tabIndex:x||0===S?-1:0,"data-orientation":i,...u,ref:p,style:{outline:"none",...e.style},onMouseDown:K(e.onMouseDown,()=>{w.current=!0}),onFocus:K(e.onFocus,e=>{let r=!w.current;if(e.target===e.currentTarget&&r&&!x){let r=new CustomEvent(t9,re);if(e.currentTarget.dispatchEvent(r),!r.defaultPrevented){let e=b().filter(e=>e.focusable);rp([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),h)}}w.current=!1}),onBlur:K(e.onBlur,()=>_(!1))})})}),rh="RovingFocusGroupItem",ru=W.forwardRef((e,r)=>{let{__scopeRovingFocusGroup:s,focusable:i=!0,active:n=!1,tabStopId:o,children:a,...l}=e,c=ej(),d=o||c,h=rl(rh,s),u=h.currentTabStopId===d,f=rs(s),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:g}=h;return W.useEffect(()=>{if(i)return p(),()=>m()},[i,p,m]),(0,F.jsx)(rr.ItemSlot,{scope:s,id:d,focusable:i,active:n,children:(0,F.jsx)(Z.span,{tabIndex:u?0:-1,"data-orientation":h.orientation,...l,ref:r,onMouseDown:K(e.onMouseDown,e=>{i?h.onItemFocus(d):e.preventDefault()}),onFocus:K(e.onFocus,()=>h.onItemFocus(d)),onKeyDown:K(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void h.onItemShiftTab();if(e.target!==e.currentTarget)return;let r=function(e,r,s){var i;let n=(i=e.key,"rtl"!==s?i:"ArrowLeft"===i?"ArrowRight":"ArrowRight"===i?"ArrowLeft":i);if(!("vertical"===r&&["ArrowLeft","ArrowRight"].includes(n))&&!("horizontal"===r&&["ArrowUp","ArrowDown"].includes(n)))return rf[n]}(e,h.orientation,h.dir);if(void 0!==r){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===r)n.reverse();else if("prev"===r||"next"===r){var s,i;"prev"===r&&n.reverse();let o=n.indexOf(e.currentTarget);n=h.loop?(s=n,i=o+1,s.map((e,r)=>s[(i+r)%s.length])):n.slice(o+1)}setTimeout(()=>rp(n))}}),children:"function"==typeof a?a({isCurrentTabStop:u,hasTabStop:null!=g}):a})})});ru.displayName=rh;var rf={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function rp(e,r=!1){let s=document.activeElement;for(let i of e)if(i===s||(i.focus({preventScroll:r}),document.activeElement!==s))return}var rm=new WeakMap,rg=new WeakMap,rv={},rx=0,r_=function(e){return e&&(e.host||r_(e.parentNode))},ry=function(e,r,s,i){var n=(Array.isArray(e)?e:[e]).map(function(e){if(r.contains(e))return e;var s=r_(e);return s&&r.contains(s)?s:(console.error("aria-hidden",e,"in not contained inside",r,". Doing nothing"),null)}).filter(function(e){return!!e});rv[s]||(rv[s]=new WeakMap);var o=rv[s],a=[],l=new Set,c=new Set(n),d=function(e){!e||l.has(e)||(l.add(e),d(e.parentNode))};n.forEach(d);var h=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(l.has(e))h(e);else try{var r=e.getAttribute(i),n=null!==r&&"false"!==r,c=(rm.get(e)||0)+1,d=(o.get(e)||0)+1;rm.set(e,c),o.set(e,d),a.push(e),1===c&&n&&rg.set(e,!0),1===d&&e.setAttribute(s,"true"),n||e.setAttribute(i,"true")}catch(r){console.error("aria-hidden: cannot operate on ",e,r)}})};return h(r),l.clear(),rx++,function(){a.forEach(function(e){var r=rm.get(e)-1,n=o.get(e)-1;rm.set(e,r),o.set(e,n),r||(rg.has(e)||e.removeAttribute(i),rg.delete(e)),n||e.removeAttribute(s)}),--rx||(rm=new WeakMap,rm=new WeakMap,rg=new WeakMap,rv={})}},rb=function(e,r,s){void 0===s&&(s="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),n=r||("undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body);return n?(i.push.apply(i,Array.from(n.querySelectorAll("[aria-live], script"))),ry(i,n,s,"aria-hidden")):function(){return null}},rw=function(){return(rw=Object.assign||function(e){for(var r,s=1,i=arguments.length;s<i;s++)for(var n in r=arguments[s])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e}).apply(this,arguments)};function rS(e,r){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>r.indexOf(i)&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)0>r.indexOf(i[n])&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]]);return s}var rC=("function"==typeof SuppressedError&&SuppressedError,"right-scroll-bar-position"),rk="width-before-scroll-bar";function rj(e,r){return"function"==typeof e?e(r):e&&(e.current=r),e}var rN="undefined"!=typeof window?W.useLayoutEffect:W.useEffect,rE=new WeakMap,rR=(void 0===cu&&(cu={}),(void 0===cf&&(cf=function(e){return e}),cp=[],cm=!1,cg={read:function(){if(cm)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return cp.length?cp[cp.length-1]:null},useMedium:function(e){var r=cf(e,cm);return cp.push(r),function(){cp=cp.filter(function(e){return e!==r})}},assignSyncMedium:function(e){for(cm=!0;cp.length;){var r=cp;cp=[],r.forEach(e)}cp={push:function(r){return e(r)},filter:function(){return cp}}},assignMedium:function(e){cm=!0;var r=[];if(cp.length){var s=cp;cp=[],s.forEach(e),r=cp}var i=function(){var s=r;r=[],s.forEach(e)},n=function(){return Promise.resolve().then(i)};n(),cp={push:function(e){r.push(e),n()},filter:function(e){return r=r.filter(e),cp}}}}).options=rw({async:!0,ssr:!1},cu),cg),rM=function(){},rD=W.forwardRef(function(e,r){var s,i,n,o,a=W.useRef(null),l=W.useState({onScrollCapture:rM,onWheelCapture:rM,onTouchMoveCapture:rM}),c=l[0],d=l[1],h=e.forwardProps,u=e.children,f=e.className,p=e.removeScrollBar,m=e.enabled,g=e.shards,v=e.sideCar,x=e.noRelative,_=e.noIsolation,y=e.inert,b=e.allowPinchZoom,w=e.as,S=e.gapMode,C=rS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=(s=[a,r],i=function(e){return s.forEach(function(r){return rj(r,e)})},(n=(0,W.useState)(function(){return{value:null,callback:i,facade:{get current(){return n.value},set current(value){var e=n.value;e!==value&&(n.value=value,n.callback(value,e))}}}})[0]).callback=i,o=n.facade,rN(function(){var e=rE.get(o);if(e){var r=new Set(e),i=new Set(s),n=o.current;r.forEach(function(e){i.has(e)||rj(e,null)}),i.forEach(function(e){r.has(e)||rj(e,n)})}rE.set(o,s)},[s]),o),j=rw(rw({},C),c);return W.createElement(W.Fragment,null,m&&W.createElement(v,{sideCar:rR,removeScrollBar:p,shards:g,noRelative:x,noIsolation:_,inert:y,setCallbacks:d,allowPinchZoom:!!b,lockRef:a,gapMode:S}),h?W.cloneElement(W.Children.only(u),rw(rw({},j),{ref:k})):W.createElement(void 0===w?"div":w,rw({},j,{className:f,ref:k}),u))});rD.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},rD.classNames={fullWidth:rk,zeroRight:rC};var rT=function(e){var r=e.sideCar,s=rS(e,["sideCar"]);if(!r)throw Error("Sidecar: please provide `sideCar` property to import the right car");var i=r.read();if(!i)throw Error("Sidecar medium not found");return W.createElement(i,rw({},s))};rT.isSideCarExport=!0;var rP=function(){var e=0,r=null;return{add:function(s){if(0==e&&(r=function(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var r=cb||("undefined"!=typeof __webpack_nonce__?__webpack_nonce__:void 0);return r&&e.setAttribute("nonce",r),e}())){var i,n;(i=r).styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s)),n=r,(document.head||document.getElementsByTagName("head")[0]).appendChild(n)}e++},remove:function(){--e||!r||(r.parentNode&&r.parentNode.removeChild(r),r=null)}}},rL=function(){var e=rP();return function(r,s){W.useEffect(function(){return e.add(r),function(){e.remove()}},[r&&s])}},rB=function(){var e=rL();return function(r){return e(r.styles,r.dynamic),null}},rA={left:0,top:0,right:0,gap:0},rO=function(e){return parseInt(e||"",10)||0},rI=function(e){var r=window.getComputedStyle(document.body),s=r["padding"===e?"paddingLeft":"marginLeft"],i=r["padding"===e?"paddingTop":"marginTop"],n=r["padding"===e?"paddingRight":"marginRight"];return[rO(s),rO(i),rO(n)]},rz=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return rA;var r=rI(e),s=document.documentElement.clientWidth,i=window.innerWidth;return{left:r[0],top:r[1],right:r[2],gap:Math.max(0,i-s+r[2]-r[0])}},rF=rB(),rW="data-scroll-locked",rH=function(e,r,s,i){var n=e.left,o=e.top,a=e.right,l=e.gap;return void 0===s&&(s="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(i,";\n padding-right: ").concat(l,"px ").concat(i,";\n }\n body[").concat(rW,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([r&&"position: relative ".concat(i,";"),"margin"===s&&"\n padding-left: ".concat(n,"px;\n padding-top: ").concat(o,"px;\n padding-right: ").concat(a,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(l,"px ").concat(i,";\n "),"padding"===s&&"padding-right: ".concat(l,"px ").concat(i,";")].filter(Boolean).join(""),"\n }\n \n .").concat(rC," {\n right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(rk," {\n margin-right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(rC," .").concat(rC," {\n right: 0 ").concat(i,";\n }\n \n .").concat(rk," .").concat(rk," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(rW,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(l,"px;\n }\n")},r$=function(){var e=parseInt(document.body.getAttribute(rW)||"0",10);return isFinite(e)?e:0},rK=function(){W.useEffect(function(){return document.body.setAttribute(rW,(r$()+1).toString()),function(){var e=r$()-1;e<=0?document.body.removeAttribute(rW):document.body.setAttribute(rW,e.toString())}},[])},rU=function(e){var r=e.noRelative,s=e.noImportant,i=e.gapMode,n=void 0===i?"margin":i;rK();var o=W.useMemo(function(){return rz(n)},[n]);return W.createElement(rF,{styles:rH(o,!r,n,s?"":"!important")})},rq=!1;if("undefined"!=typeof window)try{var rV=Object.defineProperty({},"passive",{get:function(){return rq=!0,!0}});window.addEventListener("test",rV,rV),window.removeEventListener("test",rV,rV)}catch(e){rq=!1}var rY=!!rq&&{passive:!1},rX=function(e,r){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return"hidden"!==s[r]&&(s.overflowY!==s.overflowX||"TEXTAREA"===e.tagName||"visible"!==s[r])},rG=function(e,r){var s=r.ownerDocument,i=r;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),rJ(e,i)){var n=rZ(e,i);if(n[1]>n[2])return!0}i=i.parentNode}while(i&&i!==s.body)return!1},rJ=function(e,r){return"v"===e?rX(r,"overflowY"):rX(r,"overflowX")},rZ=function(e,r){return"v"===e?[r.scrollTop,r.scrollHeight,r.clientHeight]:[r.scrollLeft,r.scrollWidth,r.clientWidth]},rQ=function(e,r,s,i,n){var o,a=(o=window.getComputedStyle(r).direction,"h"===e&&"rtl"===o?-1:1),l=a*i,c=s.target,d=r.contains(c),h=!1,u=l>0,f=0,p=0;do{if(!c)break;var m=rZ(e,c),g=m[0],v=m[1]-m[2]-a*g;(g||v)&&rJ(e,c)&&(f+=v,p+=g);var x=c.parentNode;c=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!d&&c!==document.body||d&&(r.contains(c)||r===c))return u&&(n&&1>Math.abs(f)||!n&&l>f)?h=!0:!u&&(n&&1>Math.abs(p)||!n&&-l>p)&&(h=!0),h},r0=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},r1=function(e){return[e.deltaX,e.deltaY]},r2=function(e){return e&&"current"in e?e.current:e},r5=0,r3=[];let r4=(cv=function(e){var r=W.useRef([]),s=W.useRef([0,0]),i=W.useRef(),n=W.useState(r5++)[0],o=W.useState(rB)[0],a=W.useRef(e);W.useEffect(function(){a.current=e},[e]),W.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(n));var r=(function(e,r,s){if(s||2==arguments.length)for(var i,n=0,o=r.length;n<o;n++)!i&&n in r||(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return e.concat(i||Array.prototype.slice.call(r))})([e.lockRef.current],(e.shards||[]).map(r2),!0).filter(Boolean);return r.forEach(function(e){return e.classList.add("allow-interactivity-".concat(n))}),function(){document.body.classList.remove("block-interactivity-".concat(n)),r.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(n))})}}},[e.inert,e.lockRef.current,e.shards]);var l=W.useCallback(function(e,r){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!a.current.allowPinchZoom;var n,o=r0(e),l=s.current,c="deltaX"in e?e.deltaX:l[0]-o[0],d="deltaY"in e?e.deltaY:l[1]-o[1],h=e.target,u=Math.abs(c)>Math.abs(d)?"h":"v";if("touches"in e&&"h"===u&&"range"===h.type)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===h||p.contains(h)))return!1;var m=rG(u,h);if(!m)return!0;if(m?n=u:(n="v"===u?"h":"v",m=rG(u,h)),!m)return!1;if(!i.current&&"changedTouches"in e&&(c||d)&&(i.current=n),!n)return!0;var g=i.current||n;return rQ(g,r,e,"h"===g?c:d,!0)},[]),c=W.useCallback(function(e){if(r3.length&&r3[r3.length-1]===o){var s="deltaY"in e?r1(e):r0(e),i=r.current.filter(function(r){var i;return r.name===e.type&&(r.target===e.target||e.target===r.shadowParent)&&(i=r.delta,i[0]===s[0]&&i[1]===s[1])})[0];if(i&&i.should){e.cancelable&&e.preventDefault();return}if(!i){var n=(a.current.shards||[]).map(r2).filter(Boolean).filter(function(r){return r.contains(e.target)});(n.length>0?l(e,n[0]):!a.current.noIsolation)&&e.cancelable&&e.preventDefault()}}},[]),d=W.useCallback(function(e,s,i,n){var o={name:e,delta:s,target:i,should:n,shadowParent:function(e){for(var r=null;null!==e;)e instanceof ShadowRoot&&(r=e.host,e=e.host),e=e.parentNode;return r}(i)};r.current.push(o),setTimeout(function(){r.current=r.current.filter(function(e){return e!==o})},1)},[]),h=W.useCallback(function(e){s.current=r0(e),i.current=void 0},[]),u=W.useCallback(function(r){d(r.type,r1(r),r.target,l(r,e.lockRef.current))},[]),f=W.useCallback(function(r){d(r.type,r0(r),r.target,l(r,e.lockRef.current))},[]);W.useEffect(function(){return r3.push(o),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:f}),document.addEventListener("wheel",c,rY),document.addEventListener("touchmove",c,rY),document.addEventListener("touchstart",h,rY),function(){r3=r3.filter(function(e){return e!==o}),document.removeEventListener("wheel",c,rY),document.removeEventListener("touchmove",c,rY),document.removeEventListener("touchstart",h,rY)}},[]);var p=e.removeScrollBar,m=e.inert;return W.createElement(W.Fragment,null,m?W.createElement(o,{styles:"\n .block-interactivity-".concat(n," {pointer-events: none;}\n .allow-interactivity-").concat(n," {pointer-events: all;}\n")}):null,p?W.createElement(rU,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},rR.useMedium(cv),rT);var r6=W.forwardRef(function(e,r){return W.createElement(rD,rw({},e,{ref:r,sideCar:r4}))});r6.classNames=rD.classNames;var r8=["Enter"," "],r7=["ArrowUp","PageDown","End"],r9=["ArrowDown","PageUp","Home",...r7],se={ltr:[...r8,"ArrowRight"],rtl:[...r8,"ArrowLeft"]},st={ltr:["ArrowLeft"],rtl:["ArrowRight"]},sr="Menu",[ss,si,sn]=ee(sr),[so,sa]=q(sr,[sn,tK,ro]),sl=tK(),sc=ro(),[sd,sh]=so(sr),[su,sf]=so(sr),sp=e=>{let{__scopeMenu:r,open:s=!1,children:i,dir:n,onOpenChange:o,modal:a=!0}=e,l=sl(r),[c,d]=W.useState(null),h=W.useRef(!1),u=eo(o),f=en(n);return W.useEffect(()=>{let e=()=>{h.current=!0,document.addEventListener("pointerdown",r,{capture:!0,once:!0}),document.addEventListener("pointermove",r,{capture:!0,once:!0})},r=()=>h.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",r,{capture:!0}),document.removeEventListener("pointermove",r,{capture:!0})}},[]),(0,F.jsx)(tV,{...l,children:(0,F.jsx)(sd,{scope:r,open:s,onOpenChange:u,content:c,onContentChange:d,children:(0,F.jsx)(su,{scope:r,onClose:W.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:h,dir:f,modal:a,children:i})})})};sp.displayName=sr;var sm=W.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e,n=sl(s);return(0,F.jsx)(tX,{...n,...i,ref:r})});sm.displayName="MenuAnchor";var sg="MenuPortal",[sv,sx]=so(sg,{forceMount:void 0}),s_=e=>{let{__scopeMenu:r,forceMount:s,children:i,container:n}=e,o=sh(sg,r);return(0,F.jsx)(sv,{scope:r,forceMount:s,children:(0,F.jsx)(t8,{present:s||o.open,children:(0,F.jsx)(t6,{asChild:!0,container:n,children:i})})})};s_.displayName=sg;var sy="MenuContent",[sb,sw]=so(sy),sS=W.forwardRef((e,r)=>{let s=sx(sy,e.__scopeMenu),{forceMount:i=s.forceMount,...n}=e,o=sh(sy,e.__scopeMenu),a=sf(sy,e.__scopeMenu);return(0,F.jsx)(ss.Provider,{scope:e.__scopeMenu,children:(0,F.jsx)(t8,{present:i||o.open,children:(0,F.jsx)(ss.Slot,{scope:e.__scopeMenu,children:a.modal?(0,F.jsx)(sC,{...n,ref:r}):(0,F.jsx)(sk,{...n,ref:r})})})})}),sC=W.forwardRef((e,r)=>{let s=sh(sy,e.__scopeMenu),i=W.useRef(null),n=(0,U.useComposedRefs)(r,i);return W.useEffect(()=>{let e=i.current;if(e)return rb(e)},[]),(0,F.jsx)(sN,{...e,ref:n,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:K(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})}),sk=W.forwardRef((e,r)=>{let s=sh(sy,e.__scopeMenu);return(0,F.jsx)(sN,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})}),sj=(0,J.createSlot)("MenuContent.ScrollLock"),sN=W.forwardRef((e,r)=>{let{__scopeMenu:s,loop:i=!1,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:u,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...g}=e,v=sh(sy,s),x=sf(sy,s),_=sl(s),y=sc(s),b=si(s),[w,S]=W.useState(null),C=W.useRef(null),k=(0,U.useComposedRefs)(r,C,v.onContentChange),j=W.useRef(0),N=W.useRef(""),E=W.useRef(0),R=W.useRef(null),M=W.useRef("right"),D=W.useRef(0),T=m?r6:W.Fragment;W.useEffect(()=>()=>window.clearTimeout(j.current),[]),ef();let P=W.useCallback(e=>{var r,s;return M.current===R.current?.side&&(r=e,!!(s=R.current?.area)&&function(e,r){let{x:s,y:i}=e,n=!1;for(let e=0,o=r.length-1;e<r.length;o=e++){let a=r[e],l=r[o],c=a.x,d=a.y,h=l.x,u=l.y;d>i!=u>i&&s<(h-c)*(i-d)/(u-d)+c&&(n=!n)}return n}({x:r.clientX,y:r.clientY},s))},[]);return(0,F.jsx)(sb,{scope:s,searchRef:N,onItemEnter:W.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:W.useCallback(e=>{P(e)||(C.current?.focus(),S(null))},[P]),onTriggerLeave:W.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:E,onPointerGraceIntentChange:W.useCallback(e=>{R.current=e},[]),children:(0,F.jsx)(T,{...m?{as:sj,allowPinchZoom:!0}:void 0,children:(0,F.jsx)(ex,{asChild:!0,trapped:n,onMountAutoFocus:K(o,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:(0,F.jsx)(ec,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:u,onInteractOutside:f,onDismiss:p,children:(0,F.jsx)(rc,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:i,currentTabStopId:w,onCurrentTabStopIdChange:S,onEntryFocus:K(c,e=>{x.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,F.jsx)(tQ,{role:"menu","aria-orientation":"vertical","data-state":sQ(v.open),"data-radix-menu-content":"",dir:x.dir,..._,...g,ref:k,style:{outline:"none",...g.style},onKeyDown:K(g.onKeyDown,e=>{let r=e.target.closest("[data-radix-menu-content]")===e.currentTarget,s=e.ctrlKey||e.altKey||e.metaKey,i=1===e.key.length;if(r){var n;let r,o,a,l,c,d;"Tab"===e.key&&e.preventDefault(),!s&&i&&(n=e.key,r=N.current+n,o=b().filter(e=>!e.disabled),a=document.activeElement,l=o.find(e=>e.ref.current===a)?.textValue,c=function(e,r,s){var i;let n=r.length>1&&Array.from(r).every(e=>e===r[0])?r[0]:r,o=s?e.indexOf(s):-1,a=(i=Math.max(o,0),e.map((r,s)=>e[(i+s)%e.length]));1===n.length&&(a=a.filter(e=>e!==s));let l=a.find(e=>e.toLowerCase().startsWith(n.toLowerCase()));return l!==s?l:void 0}(o.map(e=>e.textValue),r,l),d=o.find(e=>e.textValue===c)?.ref.current,function e(r){N.current=r,window.clearTimeout(j.current),""!==r&&(j.current=window.setTimeout(()=>e(""),1e3))}(r),d&&setTimeout(()=>d.focus()))}let o=C.current;if(e.target!==o||!r9.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);r7.includes(e.key)&&a.reverse(),function(e){let r=document.activeElement;for(let s of e)if(s===r||(s.focus(),document.activeElement!==r))return}(a)}),onBlur:K(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(j.current),N.current="")}),onPointerMove:K(e.onPointerMove,s2(e=>{let r=e.target,s=D.current!==e.clientX;e.currentTarget.contains(r)&&s&&(M.current=e.clientX>D.current?"right":"left",D.current=e.clientX)}))})})})})})})});sS.displayName=sy;var sE=W.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e;return(0,F.jsx)(Z.div,{role:"group",...i,ref:r})});sE.displayName="MenuGroup";var sR=W.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e;return(0,F.jsx)(Z.div,{...i,ref:r})});sR.displayName="MenuLabel";var sM="MenuItem",sD="menu.itemSelect",sT=W.forwardRef((e,r)=>{let{disabled:s=!1,onSelect:i,...n}=e,o=W.useRef(null),a=sf(sM,e.__scopeMenu),l=sw(sM,e.__scopeMenu),c=(0,U.useComposedRefs)(r,o),d=W.useRef(!1);return(0,F.jsx)(sP,{...n,ref:c,disabled:s,onClick:K(e.onClick,()=>{let e=o.current;if(!s&&e){let r=new CustomEvent(sD,{bubbles:!0,cancelable:!0});e.addEventListener(sD,e=>i?.(e),{once:!0}),Q(e,r),r.defaultPrevented?d.current=!1:a.onClose()}}),onPointerDown:r=>{e.onPointerDown?.(r),d.current=!0},onPointerUp:K(e.onPointerUp,e=>{d.current||e.currentTarget?.click()}),onKeyDown:K(e.onKeyDown,e=>{let r=""!==l.searchRef.current;s||r&&" "===e.key||r8.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});sT.displayName=sM;var sP=W.forwardRef((e,r)=>{let{__scopeMenu:s,disabled:i=!1,textValue:n,...o}=e,a=sw(sM,s),l=sc(s),c=W.useRef(null),d=(0,U.useComposedRefs)(r,c),[h,u]=W.useState(!1),[f,p]=W.useState("");return W.useEffect(()=>{let e=c.current;e&&p((e.textContent??"").trim())},[o.children]),(0,F.jsx)(ss.ItemSlot,{scope:s,disabled:i,textValue:n??f,children:(0,F.jsx)(ru,{asChild:!0,...l,focusable:!i,children:(0,F.jsx)(Z.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...o,ref:d,onPointerMove:K(e.onPointerMove,s2(e=>{i?a.onItemLeave(e):(a.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:K(e.onPointerLeave,s2(e=>a.onItemLeave(e))),onFocus:K(e.onFocus,()=>u(!0)),onBlur:K(e.onBlur,()=>u(!1))})})})}),sL=W.forwardRef((e,r)=>{let{checked:s=!1,onCheckedChange:i,...n}=e;return(0,F.jsx)(sH,{scope:e.__scopeMenu,checked:s,children:(0,F.jsx)(sT,{role:"menuitemcheckbox","aria-checked":s0(s)?"mixed":s,...n,ref:r,"data-state":s1(s),onSelect:K(n.onSelect,()=>i?.(!!s0(s)||!s),{checkForDefaultPrevented:!1})})})});sL.displayName="MenuCheckboxItem";var sB="MenuRadioGroup",[sA,sO]=so(sB,{value:void 0,onValueChange:()=>{}}),sI=W.forwardRef((e,r)=>{let{value:s,onValueChange:i,...n}=e,o=eo(i);return(0,F.jsx)(sA,{scope:e.__scopeMenu,value:s,onValueChange:o,children:(0,F.jsx)(sE,{...n,ref:r})})});sI.displayName=sB;var sz="MenuRadioItem",sF=W.forwardRef((e,r)=>{let{value:s,...i}=e,n=sO(sz,e.__scopeMenu),o=s===n.value;return(0,F.jsx)(sH,{scope:e.__scopeMenu,checked:o,children:(0,F.jsx)(sT,{role:"menuitemradio","aria-checked":o,...i,ref:r,"data-state":s1(o),onSelect:K(i.onSelect,()=>n.onValueChange?.(s),{checkForDefaultPrevented:!1})})})});sF.displayName=sz;var sW="MenuItemIndicator",[sH,s$]=so(sW,{checked:!1}),sK=W.forwardRef((e,r)=>{let{__scopeMenu:s,forceMount:i,...n}=e,o=s$(sW,s);return(0,F.jsx)(t8,{present:i||s0(o.checked)||!0===o.checked,children:(0,F.jsx)(Z.span,{...n,ref:r,"data-state":s1(o.checked)})})});sK.displayName=sW;var sU=W.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e;return(0,F.jsx)(Z.div,{role:"separator","aria-orientation":"horizontal",...i,ref:r})});sU.displayName="MenuSeparator";var sq=W.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e,n=sl(s);return(0,F.jsx)(t2,{...n,...i,ref:r})});sq.displayName="MenuArrow";var[sV,sY]=so("MenuSub"),sX="MenuSubTrigger",sG=W.forwardRef((e,r)=>{let s=sh(sX,e.__scopeMenu),i=sf(sX,e.__scopeMenu),n=sY(sX,e.__scopeMenu),o=sw(sX,e.__scopeMenu),a=W.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=o,d={__scopeMenu:e.__scopeMenu},h=W.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return W.useEffect(()=>h,[h]),W.useEffect(()=>{let e=l.current;return()=>{window.clearTimeout(e),c(null)}},[l,c]),(0,F.jsx)(sm,{asChild:!0,...d,children:(0,F.jsx)(sP,{id:n.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":n.contentId,"data-state":sQ(s.open),...e,ref:(0,U.composeRefs)(r,n.onTriggerChange),onClick:r=>{e.onClick?.(r),e.disabled||r.defaultPrevented||(r.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:K(e.onPointerMove,s2(r=>{o.onItemEnter(r),!r.defaultPrevented&&(e.disabled||s.open||a.current||(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{s.onOpenChange(!0),h()},100)))})),onPointerLeave:K(e.onPointerLeave,s2(e=>{h();let r=s.content?.getBoundingClientRect();if(r){let i=s.content?.dataset.side,n="right"===i,a=r[n?"left":"right"],c=r[n?"right":"left"];o.onPointerGraceIntentChange({area:[{x:e.clientX+(n?-5:5),y:e.clientY},{x:a,y:r.top},{x:c,y:r.top},{x:c,y:r.bottom},{x:a,y:r.bottom}],side:i}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(e),e.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:K(e.onKeyDown,r=>{let n=""!==o.searchRef.current;e.disabled||n&&" "===r.key||se[i.dir].includes(r.key)&&(s.onOpenChange(!0),s.content?.focus(),r.preventDefault())})})})});sG.displayName=sX;var sJ="MenuSubContent",sZ=W.forwardRef((e,r)=>{let s=sx(sy,e.__scopeMenu),{forceMount:i=s.forceMount,...n}=e,o=sh(sy,e.__scopeMenu),a=sf(sy,e.__scopeMenu),l=sY(sJ,e.__scopeMenu),c=W.useRef(null),d=(0,U.useComposedRefs)(r,c);return(0,F.jsx)(ss.Provider,{scope:e.__scopeMenu,children:(0,F.jsx)(t8,{present:i||o.open,children:(0,F.jsx)(ss.Slot,{scope:e.__scopeMenu,children:(0,F.jsx)(sN,{id:l.contentId,"aria-labelledby":l.triggerId,...n,ref:d,align:"start",side:"rtl"===a.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{a.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:K(e.onFocusOutside,e=>{e.target!==l.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:K(e.onEscapeKeyDown,e=>{a.onClose(),e.preventDefault()}),onKeyDown:K(e.onKeyDown,e=>{let r=e.currentTarget.contains(e.target),s=st[a.dir].includes(e.key);r&&s&&(o.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})});function sQ(e){return e?"open":"closed"}function s0(e){return"indeterminate"===e}function s1(e){return s0(e)?"indeterminate":e?"checked":"unchecked"}function s2(e){return r=>"mouse"===r.pointerType?e(r):void 0}sZ.displayName=sJ;var s5="DropdownMenu",[s3,s4]=q(s5,[sa]),s6=sa(),[s8,s7]=s3(s5),s9=e=>{let{__scopeDropdownMenu:r,children:s,dir:i,open:n,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,c=s6(r),d=W.useRef(null),[h,u]=X({prop:n,defaultProp:o??!1,onChange:a,caller:s5});return(0,F.jsx)(s8,{scope:r,triggerId:ej(),triggerRef:d,contentId:ej(),open:h,onOpenChange:u,onOpenToggle:W.useCallback(()=>u(e=>!e),[u]),modal:l,children:(0,F.jsx)(sp,{...c,open:h,onOpenChange:u,dir:i,modal:l,children:s})})};s9.displayName=s5;var ie="DropdownMenuTrigger",it=W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,disabled:i=!1,...n}=e,o=s7(ie,s),a=s6(s);return(0,F.jsx)(sm,{asChild:!0,...a,children:(0,F.jsx)(Z.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...n,ref:(0,U.composeRefs)(r,o.triggerRef),onPointerDown:K(e.onPointerDown,e=>{!i&&0===e.button&&!1===e.ctrlKey&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:K(e.onKeyDown,e=>{!i&&(["Enter"," "].includes(e.key)&&o.onOpenToggle(),"ArrowDown"===e.key&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});it.displayName=ie;var ir=e=>{let{__scopeDropdownMenu:r,...s}=e,i=s6(r);return(0,F.jsx)(s_,{...i,...s})};ir.displayName="DropdownMenuPortal";var is="DropdownMenuContent",ii=W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s7(is,s),o=s6(s),a=W.useRef(!1);return(0,F.jsx)(sS,{id:n.contentId,"aria-labelledby":n.triggerId,...o,...i,ref:r,onCloseAutoFocus:K(e.onCloseAutoFocus,e=>{a.current||n.triggerRef.current?.focus(),a.current=!1,e.preventDefault()}),onInteractOutside:K(e.onInteractOutside,e=>{let r=e.detail.originalEvent,s=0===r.button&&!0===r.ctrlKey,i=2===r.button||s;(!n.modal||i)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ii.displayName=is,W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s6(s);return(0,F.jsx)(sE,{...n,...i,ref:r})}).displayName="DropdownMenuGroup",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s6(s);return(0,F.jsx)(sR,{...n,...i,ref:r})}).displayName="DropdownMenuLabel";var io=W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s6(s);return(0,F.jsx)(sT,{...n,...i,ref:r})});io.displayName="DropdownMenuItem",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s6(s);return(0,F.jsx)(sL,{...n,...i,ref:r})}).displayName="DropdownMenuCheckboxItem",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s6(s);return(0,F.jsx)(sI,{...n,...i,ref:r})}).displayName="DropdownMenuRadioGroup",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s6(s);return(0,F.jsx)(sF,{...n,...i,ref:r})}).displayName="DropdownMenuRadioItem",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s6(s);return(0,F.jsx)(sK,{...n,...i,ref:r})}).displayName="DropdownMenuItemIndicator";var ia=W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s6(s);return(0,F.jsx)(sU,{...n,...i,ref:r})});ia.displayName="DropdownMenuSeparator",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s6(s);return(0,F.jsx)(sq,{...n,...i,ref:r})}).displayName="DropdownMenuArrow",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s6(s);return(0,F.jsx)(sG,{...n,...i,ref:r})}).displayName="DropdownMenuSubTrigger",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=s6(s);return(0,F.jsx)(sZ,{...n,...i,ref:r,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}).displayName="DropdownMenuSubContent";var il=e.i(322387),il=il,ic=e.i(198631);let id=(0,ic.default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),ih=(0,ic.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var iu=e.i(803545);function ip({...e}){return(0,F.jsx)(s9,{"data-slot":"dropdown-menu",...e})}function im({...e}){return(0,F.jsx)(it,{"data-slot":"dropdown-menu-trigger",...e})}function ig({className:e,sideOffset:r=4,...s}){return(0,F.jsx)(ir,{children:(0,F.jsx)(ii,{"data-slot":"dropdown-menu-content",sideOffset:r,className:(0,iu.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...s})})}function iv({className:e,inset:r,variant:s="default",...i}){return(0,F.jsx)(io,{"data-slot":"dropdown-menu-item","data-inset":r,"data-variant":s,className:(0,iu.cn)("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...i})}function ix({className:e,...r}){return(0,F.jsx)(ia,{"data-slot":"dropdown-menu-separator",className:(0,iu.cn)("bg-border -mx-1 my-1 h-px",e),...r})}let i_=(0,ic.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),iy=(0,ic.default)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]),ib=(0,ic.default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),iw=(0,ic.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),iS=(0,ic.default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),iC=(0,ic.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),ik=(0,ic.default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),ij=(0,ic.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),iN=(0,ic.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),iE=(0,ic.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);var iR=e.i(710307),iM=e.i(454267);let iD=(0,ic.default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);var iT=e.i(165512);function iP(e){let[r,s]=(0,W.useState)([]),[i,n]=(0,W.useState)(!1),o=(0,W.useCallback)(async()=>{if(!e)return void s([]);n(!0);try{let r=await iT.api.getProjectRemotes(e);s(r)}catch(e){console.error("Failed to fetch project remotes:",e)}finally{n(!1)}},[e]);return(0,W.useEffect)(()=>{o()},[o]),{remotes:r,loading:i,refresh:o}}var iL="Dialog",[iB,iA]=q(iL),[iO,iI]=iB(iL),iz=e=>{let{__scopeDialog:r,children:s,open:i,defaultOpen:n,onOpenChange:o,modal:a=!0}=e,l=W.useRef(null),c=W.useRef(null),[d,h]=X({prop:i,defaultProp:n??!1,onChange:o,caller:iL});return(0,F.jsx)(iO,{scope:r,triggerRef:l,contentRef:c,contentId:ej(),titleId:ej(),descriptionId:ej(),open:d,onOpenChange:h,onOpenToggle:W.useCallback(()=>h(e=>!e),[h]),modal:a,children:s})};iz.displayName=iL;var iF="DialogTrigger";W.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=iI(iF,s),o=(0,U.useComposedRefs)(r,n.triggerRef);return(0,F.jsx)(Z.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":i6(n.open),...i,ref:o,onClick:K(e.onClick,n.onOpenToggle)})}).displayName=iF;var iW="DialogPortal",[iH,i$]=iB(iW,{forceMount:void 0}),iK=e=>{let{__scopeDialog:r,forceMount:s,children:i,container:n}=e,o=iI(iW,r);return(0,F.jsx)(iH,{scope:r,forceMount:s,children:W.Children.map(i,e=>(0,F.jsx)(t8,{present:s||o.open,children:(0,F.jsx)(t6,{asChild:!0,container:n,children:e})}))})};iK.displayName=iW;var iU="DialogOverlay",iq=W.forwardRef((e,r)=>{let s=i$(iU,e.__scopeDialog),{forceMount:i=s.forceMount,...n}=e,o=iI(iU,e.__scopeDialog);return o.modal?(0,F.jsx)(t8,{present:i||o.open,children:(0,F.jsx)(iY,{...n,ref:r})}):null});iq.displayName=iU;var iV=(0,J.createSlot)("DialogOverlay.RemoveScroll"),iY=W.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=iI(iU,s);return(0,F.jsx)(r6,{as:iV,allowPinchZoom:!0,shards:[n.contentRef],children:(0,F.jsx)(Z.div,{"data-state":i6(n.open),...i,ref:r,style:{pointerEvents:"auto",...i.style}})})}),iX="DialogContent",iG=W.forwardRef((e,r)=>{let s=i$(iX,e.__scopeDialog),{forceMount:i=s.forceMount,...n}=e,o=iI(iX,e.__scopeDialog);return(0,F.jsx)(t8,{present:i||o.open,children:o.modal?(0,F.jsx)(iJ,{...n,ref:r}):(0,F.jsx)(iZ,{...n,ref:r})})});iG.displayName=iX;var iJ=W.forwardRef((e,r)=>{let s=iI(iX,e.__scopeDialog),i=W.useRef(null),n=(0,U.useComposedRefs)(r,s.contentRef,i);return W.useEffect(()=>{let e=i.current;if(e)return rb(e)},[]),(0,F.jsx)(iQ,{...e,ref:n,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:K(e.onCloseAutoFocus,e=>{e.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:K(e.onPointerDownOutside,e=>{let r=e.detail.originalEvent,s=0===r.button&&!0===r.ctrlKey;(2===r.button||s)&&e.preventDefault()}),onFocusOutside:K(e.onFocusOutside,e=>e.preventDefault())})}),iZ=W.forwardRef((e,r)=>{let s=iI(iX,e.__scopeDialog),i=W.useRef(!1),n=W.useRef(!1);return(0,F.jsx)(iQ,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{e.onCloseAutoFocus?.(r),r.defaultPrevented||(i.current||s.triggerRef.current?.focus(),r.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:r=>{e.onInteractOutside?.(r),r.defaultPrevented||(i.current=!0,"pointerdown"===r.detail.originalEvent.type&&(n.current=!0));let o=r.target;s.triggerRef.current?.contains(o)&&r.preventDefault(),"focusin"===r.detail.originalEvent.type&&n.current&&r.preventDefault()}})}),iQ=W.forwardRef((e,r)=>{let{__scopeDialog:s,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...a}=e,l=iI(iX,s),c=W.useRef(null),d=(0,U.useComposedRefs)(r,c);return ef(),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(ex,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:(0,F.jsx)(ec,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":i6(l.open),...a,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(ne,{titleId:l.titleId}),(0,F.jsx)(nt,{contentRef:c,descriptionId:l.descriptionId})]})]})}),i0="DialogTitle",i1=W.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=iI(i0,s);return(0,F.jsx)(Z.h2,{id:n.titleId,...i,ref:r})});i1.displayName=i0;var i2="DialogDescription",i5=W.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=iI(i2,s);return(0,F.jsx)(Z.p,{id:n.descriptionId,...i,ref:r})});i5.displayName=i2;var i3="DialogClose",i4=W.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=iI(i3,s);return(0,F.jsx)(Z.button,{type:"button",...i,ref:r,onClick:K(e.onClick,()=>n.onOpenChange(!1))})});function i6(e){return e?"open":"closed"}i4.displayName=i3;var i8="DialogTitleWarning",[i7,i9]=(cx={contentName:iX,titleName:i0,docsSlug:"dialog"},s=W.createContext(cx),(i=e=>{let{children:r,...i}=e,n=W.useMemo(()=>i,Object.values(i));return(0,F.jsx)(s.Provider,{value:n,children:r})}).displayName=i8+"Provider",[i,function(e){let r=W.useContext(s);if(r)return r;if(void 0!==cx)return cx;throw Error(`\`${e}\` must be used within \`${i8}\``)}]),ne=({titleId:e})=>{let r=i9(i8),s=`\`${r.contentName}\` requires a \`${r.titleName}\` for the component to be accessible for screen reader users.
2
+
3
+ If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.
4
+
5
+ For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return W.useEffect(()=>{e&&(document.getElementById(e)||console.error(s))},[s,e]),null},nt=({contentRef:e,descriptionId:r})=>{let s=i9("DialogDescriptionWarning"),i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${s.contentName}}.`;return W.useEffect(()=>{let s=e.current?.getAttribute("aria-describedby");r&&s&&(document.getElementById(r)||console.warn(i))},[i,e,r]),null};let nr=(0,ic.default)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function ns({...e}){return(0,F.jsx)(iz,{"data-slot":"dialog",...e})}function ni({...e}){return(0,F.jsx)(iK,{"data-slot":"dialog-portal",...e})}function nn({className:e,...r}){return(0,F.jsx)(iq,{"data-slot":"dialog-overlay",className:(0,iu.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function no({className:e,children:r,showCloseButton:s=!0,...i}){return(0,F.jsxs)(ni,{"data-slot":"dialog-portal",children:[(0,F.jsx)(nn,{}),(0,F.jsxs)(iG,{"data-slot":"dialog-content",className:(0,iu.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",e),...i,children:[r,s&&(0,F.jsxs)(i4,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,F.jsx)(nr,{}),(0,F.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function na({className:e,...r}){return(0,F.jsx)("div",{"data-slot":"dialog-header",className:(0,iu.cn)("flex flex-col gap-2 text-center sm:text-left",e),...r})}function nl({className:e,...r}){return(0,F.jsx)("div",{"data-slot":"dialog-footer",className:(0,iu.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function nc({className:e,...r}){return(0,F.jsx)(i1,{"data-slot":"dialog-title",className:(0,iu.cn)("text-lg leading-none font-semibold",e),...r})}function nd({className:e,...r}){return(0,F.jsx)(i5,{"data-slot":"dialog-description",className:(0,iu.cn)("text-muted-foreground text-sm",e),...r})}function nh({className:e,type:r,...s}){return(0,F.jsx)("input",{type:r,"data-slot":"input",className:(0,iu.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...s})}function nu({className:e,...r}){return(0,F.jsx)("textarea",{"data-slot":"textarea",className:(0,iu.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...r})}var nf="Tabs",[np,nm]=q(nf,[ro]),ng=ro(),[nv,nx]=np(nf),n_=W.forwardRef((e,r)=>{let{__scopeTabs:s,value:i,onValueChange:n,defaultValue:o,orientation:a="horizontal",dir:l,activationMode:c="automatic",...d}=e,h=en(l),[u,f]=X({prop:i,onChange:n,defaultProp:o??"",caller:nf});return(0,F.jsx)(nv,{scope:s,baseId:ej(),value:u,onValueChange:f,orientation:a,dir:h,activationMode:c,children:(0,F.jsx)(Z.div,{dir:h,"data-orientation":a,...d,ref:r})})});n_.displayName=nf;var ny="TabsList",nb=W.forwardRef((e,r)=>{let{__scopeTabs:s,loop:i=!0,...n}=e,o=nx(ny,s),a=ng(s);return(0,F.jsx)(rc,{asChild:!0,...a,orientation:o.orientation,dir:o.dir,loop:i,children:(0,F.jsx)(Z.div,{role:"tablist","aria-orientation":o.orientation,...n,ref:r})})});nb.displayName=ny;var nw="TabsTrigger",nS=W.forwardRef((e,r)=>{let{__scopeTabs:s,value:i,disabled:n=!1,...o}=e,a=nx(nw,s),l=ng(s),c=nj(a.baseId,i),d=nN(a.baseId,i),h=i===a.value;return(0,F.jsx)(ru,{asChild:!0,...l,focusable:!n,active:h,children:(0,F.jsx)(Z.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":d,"data-state":h?"active":"inactive","data-disabled":n?"":void 0,disabled:n,id:c,...o,ref:r,onMouseDown:K(e.onMouseDown,e=>{n||0!==e.button||!1!==e.ctrlKey?e.preventDefault():a.onValueChange(i)}),onKeyDown:K(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&a.onValueChange(i)}),onFocus:K(e.onFocus,()=>{let e="manual"!==a.activationMode;h||n||!e||a.onValueChange(i)})})})});nS.displayName=nw;var nC="TabsContent",nk=W.forwardRef((e,r)=>{let{__scopeTabs:s,value:i,forceMount:n,children:o,...a}=e,l=nx(nC,s),c=nj(l.baseId,i),d=nN(l.baseId,i),h=i===l.value,u=W.useRef(h);return W.useEffect(()=>{let e=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,F.jsx)(t8,{present:n||h,children:({present:s})=>(0,F.jsx)(Z.div,{"data-state":h?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!s,id:d,tabIndex:0,...a,ref:r,style:{...e.style,animationDuration:u.current?"0s":void 0},children:s&&o})})});function nj(e,r){return`${e}-trigger-${r}`}function nN(e,r){return`${e}-content-${r}`}nk.displayName=nC;let nE=W.forwardRef(({className:e,...r},s)=>(0,F.jsx)(nb,{ref:s,className:(0,iu.cn)("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...r}));nE.displayName=nb.displayName;let nR=W.forwardRef(({className:e,...r},s)=>(0,F.jsx)(nS,{ref:s,className:(0,iu.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...r}));nR.displayName=nS.displayName;let nM=W.forwardRef(({className:e,...r},s)=>(0,F.jsx)(nk,{ref:s,className:(0,iu.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...r}));nM.displayName=nk.displayName;let nD=(0,ic.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),nT=(0,ic.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);function nP({targets:e,activeTarget:r,onTargetChange:s,onAddRemote:i,disabled:n}){let o=e.length>4,a=o?e.slice(0,3):e,l=o?e.slice(3):[],c=l.some(e=>e.id===r);return(0,F.jsxs)("div",{className:"inline-flex items-center rounded-md border bg-muted/50 p-0.5 text-xs",children:[a.map(e=>{let i=e.icon;return(0,F.jsxs)("button",{onClick:()=>s(e.id),disabled:n,className:(0,iu.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors",r===e.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground",n&&"opacity-50 cursor-not-allowed"),children:[i&&(0,F.jsx)(i,{className:"h-3 w-3"}),e.label]},e.id)}),o&&(0,F.jsxs)(ip,{children:[(0,F.jsx)(im,{asChild:!0,children:(0,F.jsx)("button",{disabled:n,className:(0,iu.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors",c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground",n&&"opacity-50 cursor-not-allowed"),children:(0,F.jsx)(nT,{className:"h-3 w-3"})})}),(0,F.jsx)(ig,{align:"end",children:l.map(e=>{let i=e.icon;return(0,F.jsxs)(iv,{onClick:()=>s(e.id),className:(0,iu.cn)("text-xs",r===e.id&&"font-medium"),children:[i&&(0,F.jsx)(i,{className:"h-3 w-3"}),e.label]},e.id)})})]}),i&&(0,F.jsx)("button",{onClick:i,disabled:n,className:(0,iu.cn)("inline-flex items-center gap-1 rounded-sm px-1.5 py-0.5 transition-colors text-muted-foreground hover:text-foreground",n&&"opacity-50 cursor-not-allowed"),children:(0,F.jsx)(nD,{className:"h-3 w-3"})})]})}var nL=e.i(671798);let nB=(0,ic.default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);var nA=e.i(801836);let nO=(0,ic.default)("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]),nI=(0,ic.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function nz(e,[r,s]){return Math.min(s,Math.max(r,e))}var nF="ScrollArea",[nW,nH]=q(nF),[n$,nK]=nW(nF),nU=W.forwardRef((e,r)=>{let{__scopeScrollArea:s,type:i="hover",dir:n,scrollHideDelay:o=600,...a}=e,[l,c]=W.useState(null),[d,h]=W.useState(null),[u,f]=W.useState(null),[p,m]=W.useState(null),[g,v]=W.useState(null),[x,_]=W.useState(0),[y,b]=W.useState(0),[w,S]=W.useState(!1),[C,k]=W.useState(!1),j=(0,U.useComposedRefs)(r,e=>c(e)),N=en(n);return(0,F.jsx)(n$,{scope:s,type:i,dir:N,scrollHideDelay:o,scrollArea:l,viewport:d,onViewportChange:h,content:u,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:w,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:v,scrollbarYEnabled:C,onScrollbarYEnabledChange:k,onCornerWidthChange:_,onCornerHeightChange:b,children:(0,F.jsx)(Z.div,{dir:N,...a,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});nU.displayName=nF;var nq="ScrollAreaViewport",nV=W.forwardRef((e,r)=>{let{__scopeScrollArea:s,children:i,nonce:n,...o}=e,a=nK(nq,s),l=W.useRef(null),c=(0,U.useComposedRefs)(r,l,a.onViewportChange);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),(0,F.jsx)(Z.div,{"data-radix-scroll-area-viewport":"",...o,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,F.jsx)("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})});nV.displayName=nq;var nY="ScrollAreaScrollbar",nX=W.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=nK(nY,e.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:a}=n,l="horizontal"===e.orientation;return W.useEffect(()=>(l?o(!0):a(!0),()=>{l?o(!1):a(!1)}),[l,o,a]),"hover"===n.type?(0,F.jsx)(nG,{...i,ref:r,forceMount:s}):"scroll"===n.type?(0,F.jsx)(nJ,{...i,ref:r,forceMount:s}):"auto"===n.type?(0,F.jsx)(nZ,{...i,ref:r,forceMount:s}):"always"===n.type?(0,F.jsx)(nQ,{...i,ref:r}):null});nX.displayName=nY;var nG=W.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=nK(nY,e.__scopeScrollArea),[o,a]=W.useState(!1);return W.useEffect(()=>{let e=n.scrollArea,r=0;if(e){let s=()=>{window.clearTimeout(r),a(!0)},i=()=>{r=window.setTimeout(()=>a(!1),n.scrollHideDelay)};return e.addEventListener("pointerenter",s),e.addEventListener("pointerleave",i),()=>{window.clearTimeout(r),e.removeEventListener("pointerenter",s),e.removeEventListener("pointerleave",i)}}},[n.scrollArea,n.scrollHideDelay]),(0,F.jsx)(t8,{present:s||o,children:(0,F.jsx)(nZ,{"data-state":o?"visible":"hidden",...i,ref:r})})}),nJ=W.forwardRef((e,r)=>{var s;let{forceMount:i,...n}=e,o=nK(nY,e.__scopeScrollArea),a="horizontal"===e.orientation,l=oa(()=>d("SCROLL_END"),100),[c,d]=(s={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},W.useReducer((e,r)=>s[e][r]??e,"hidden"));return W.useEffect(()=>{if("idle"===c){let e=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(e)}},[c,o.scrollHideDelay,d]),W.useEffect(()=>{let e=o.viewport,r=a?"scrollLeft":"scrollTop";if(e){let s=e[r],i=()=>{let i=e[r];s!==i&&(d("SCROLL"),l()),s=i};return e.addEventListener("scroll",i),()=>e.removeEventListener("scroll",i)}},[o.viewport,a,d,l]),(0,F.jsx)(t8,{present:i||"hidden"!==c,children:(0,F.jsx)(nQ,{"data-state":"hidden"===c?"hidden":"visible",...n,ref:r,onPointerEnter:K(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:K(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),nZ=W.forwardRef((e,r)=>{let s=nK(nY,e.__scopeScrollArea),{forceMount:i,...n}=e,[o,a]=W.useState(!1),l="horizontal"===e.orientation,c=oa(()=>{if(s.viewport){let e=s.viewport.offsetWidth<s.viewport.scrollWidth,r=s.viewport.offsetHeight<s.viewport.scrollHeight;a(l?e:r)}},10);return ol(s.viewport,c),ol(s.content,c),(0,F.jsx)(t8,{present:i||o,children:(0,F.jsx)(nQ,{"data-state":o?"visible":"hidden",...n,ref:r})})}),nQ=W.forwardRef((e,r)=>{let{orientation:s="vertical",...i}=e,n=nK(nY,e.__scopeScrollArea),o=W.useRef(null),a=W.useRef(0),[l,c]=W.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=or(l.viewport,l.content),h={...i,sizes:l,onSizesChange:c,hasThumb:!!(d>0&&d<1),onThumbChange:e=>o.current=e,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:e=>a.current=e};function u(e,r){return function(e,r,s,i="ltr"){let n=os(s),o=r||n/2,a=s.scrollbar.paddingStart+o,l=s.scrollbar.size-s.scrollbar.paddingEnd-(n-o),c=s.content-s.viewport;return on([a,l],"ltr"===i?[0,c]:[-1*c,0])(e)}(e,a.current,l,r)}return"horizontal"===s?(0,F.jsx)(n0,{...h,ref:r,onThumbPositionChange:()=>{if(n.viewport&&o.current){let e=oi(n.viewport.scrollLeft,l,n.dir);o.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{n.viewport&&(n.viewport.scrollLeft=e)},onDragScroll:e=>{n.viewport&&(n.viewport.scrollLeft=u(e,n.dir))}}):"vertical"===s?(0,F.jsx)(n1,{...h,ref:r,onThumbPositionChange:()=>{if(n.viewport&&o.current){let e=oi(n.viewport.scrollTop,l);o.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{n.viewport&&(n.viewport.scrollTop=e)},onDragScroll:e=>{n.viewport&&(n.viewport.scrollTop=u(e))}}):null}),n0=W.forwardRef((e,r)=>{let{sizes:s,onSizesChange:i,...n}=e,o=nK(nY,e.__scopeScrollArea),[a,l]=W.useState(),c=W.useRef(null),d=(0,U.useComposedRefs)(r,c,o.onScrollbarXChange);return W.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,F.jsx)(n3,{"data-orientation":"horizontal",...n,ref:d,sizes:s,style:{bottom:0,left:"rtl"===o.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===o.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":os(s)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.x),onDragScroll:r=>e.onDragScroll(r.x),onWheelScroll:(r,s)=>{if(o.viewport){var i,n;let a=o.viewport.scrollLeft+r.deltaX;e.onWheelScroll(a),i=a,n=s,i>0&&i<n&&r.preventDefault()}},onResize:()=>{c.current&&o.viewport&&a&&i({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ot(a.paddingLeft),paddingEnd:ot(a.paddingRight)}})}})}),n1=W.forwardRef((e,r)=>{let{sizes:s,onSizesChange:i,...n}=e,o=nK(nY,e.__scopeScrollArea),[a,l]=W.useState(),c=W.useRef(null),d=(0,U.useComposedRefs)(r,c,o.onScrollbarYChange);return W.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,F.jsx)(n3,{"data-orientation":"vertical",...n,ref:d,sizes:s,style:{top:0,right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":os(s)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.y),onDragScroll:r=>e.onDragScroll(r.y),onWheelScroll:(r,s)=>{if(o.viewport){var i,n;let a=o.viewport.scrollTop+r.deltaY;e.onWheelScroll(a),i=a,n=s,i>0&&i<n&&r.preventDefault()}},onResize:()=>{c.current&&o.viewport&&a&&i({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ot(a.paddingTop),paddingEnd:ot(a.paddingBottom)}})}})}),[n2,n5]=nW(nY),n3=W.forwardRef((e,r)=>{let{__scopeScrollArea:s,sizes:i,hasThumb:n,onThumbChange:o,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:h,onResize:u,...f}=e,p=nK(nY,s),[m,g]=W.useState(null),v=(0,U.useComposedRefs)(r,e=>g(e)),x=W.useRef(null),_=W.useRef(""),y=p.viewport,b=i.content-i.viewport,w=eo(h),S=eo(c),C=oa(u,10);function k(e){x.current&&d({x:e.clientX-x.current.left,y:e.clientY-x.current.top})}return W.useEffect(()=>{let e=e=>{let r=e.target;m?.contains(r)&&w(e,b)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[y,m,b,w]),W.useEffect(S,[i,S]),ol(m,C),ol(p.content,C),(0,F.jsx)(n2,{scope:s,scrollbar:m,hasThumb:n,onThumbChange:eo(o),onThumbPointerUp:eo(a),onThumbPositionChange:S,onThumbPointerDown:eo(l),children:(0,F.jsx)(Z.div,{...f,ref:v,style:{position:"absolute",...f.style},onPointerDown:K(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),x.current=m.getBoundingClientRect(),_.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),k(e))}),onPointerMove:K(e.onPointerMove,k),onPointerUp:K(e.onPointerUp,e=>{let r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=_.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),n4="ScrollAreaThumb",n6=W.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=n5(n4,e.__scopeScrollArea);return(0,F.jsx)(t8,{present:s||n.hasThumb,children:(0,F.jsx)(n8,{ref:r,...i})})}),n8=W.forwardRef((e,r)=>{let{__scopeScrollArea:s,style:i,...n}=e,o=nK(n4,s),a=n5(n4,s),{onThumbPositionChange:l}=a,c=(0,U.useComposedRefs)(r,e=>a.onThumbChange(e)),d=W.useRef(void 0),h=oa(()=>{d.current&&(d.current(),d.current=void 0)},100);return W.useEffect(()=>{let e=o.viewport;if(e){let r=()=>{h(),d.current||(d.current=oo(e,l),l())};return l(),e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}},[o.viewport,h,l]),(0,F.jsx)(Z.div,{"data-state":a.hasThumb?"visible":"hidden",...n,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:K(e.onPointerDownCapture,e=>{let r=e.target.getBoundingClientRect(),s=e.clientX-r.left,i=e.clientY-r.top;a.onThumbPointerDown({x:s,y:i})}),onPointerUp:K(e.onPointerUp,a.onThumbPointerUp)})});n6.displayName=n4;var n7="ScrollAreaCorner",n9=W.forwardRef((e,r)=>{let s=nK(n7,e.__scopeScrollArea),i=!!(s.scrollbarX&&s.scrollbarY);return"scroll"!==s.type&&i?(0,F.jsx)(oe,{...e,ref:r}):null});n9.displayName=n7;var oe=W.forwardRef((e,r)=>{let{__scopeScrollArea:s,...i}=e,n=nK(n7,s),[o,a]=W.useState(0),[l,c]=W.useState(0),d=!!(o&&l);return ol(n.scrollbarX,()=>{let e=n.scrollbarX?.offsetHeight||0;n.onCornerHeightChange(e),c(e)}),ol(n.scrollbarY,()=>{let e=n.scrollbarY?.offsetWidth||0;n.onCornerWidthChange(e),a(e)}),d?(0,F.jsx)(Z.div,{...i,ref:r,style:{width:o,height:l,position:"absolute",right:"ltr"===n.dir?0:void 0,left:"rtl"===n.dir?0:void 0,bottom:0,...e.style}}):null});function ot(e){return e?parseInt(e,10):0}function or(e,r){let s=e/r;return isNaN(s)?0:s}function os(e){let r=or(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd;return Math.max((e.scrollbar.size-s)*r,18)}function oi(e,r,s="ltr"){let i=os(r),n=r.scrollbar.paddingStart+r.scrollbar.paddingEnd,o=r.scrollbar.size-n,a=r.content-r.viewport,l=nz(e,"ltr"===s?[0,a]:[-1*a,0]);return on([0,a],[0,o-i])(l)}function on(e,r){return s=>{if(e[0]===e[1]||r[0]===r[1])return r[0];let i=(r[1]-r[0])/(e[1]-e[0]);return r[0]+i*(s-e[0])}}var oo=(e,r=()=>{})=>{let s={left:e.scrollLeft,top:e.scrollTop},i=0;return!function n(){let o={left:e.scrollLeft,top:e.scrollTop},a=s.left!==o.left,l=s.top!==o.top;(a||l)&&r(),s=o,i=window.requestAnimationFrame(n)}(),()=>window.cancelAnimationFrame(i)};function oa(e,r){let s=eo(e),i=W.useRef(0);return W.useEffect(()=>()=>window.clearTimeout(i.current),[]),W.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(s,r)},[s,r])}function ol(e,r){let s=eo(r);V(()=>{let r=0;if(e){let i=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(s)});return i.observe(e),()=>{window.cancelAnimationFrame(r),i.unobserve(e)}}},[e,s])}function oc({className:e,children:r,...s}){return(0,F.jsxs)(nU,{"data-slot":"scroll-area",className:(0,iu.cn)("relative",e),...s,children:[(0,F.jsx)(nV,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:r}),(0,F.jsx)(od,{}),(0,F.jsx)(n9,{})]})}function od({className:e,orientation:r="vertical",...s}){return(0,F.jsx)(nX,{"data-slot":"scroll-area-scrollbar",orientation:r,className:(0,iu.cn)("flex touch-none p-px transition-colors select-none","vertical"===r&&"h-full w-2.5 border-l border-l-transparent","horizontal"===r&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:(0,F.jsx)(n6,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}let oh=(0,ic.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),ou=(0,ic.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);function of({serverId:e,onSelect:r,selectedPath:s}){let[i,n]=(0,W.useState)("/"),[o,a]=(0,W.useState)([]),[l,c]=(0,W.useState)(!1),[d,h]=(0,W.useState)("");return((0,W.useEffect)(()=>{e?(async()=>{c(!0),h("");try{let r=await iT.api.browseRemoteServerDirectory(e,i);a(r.items??[])}catch(e){h(e instanceof Error?e.message:"Failed to load directory"),a([])}finally{c(!1)}})():a([])},[e,i]),e)?(0,F.jsxs)("div",{className:"border rounded-md",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/50",children:[(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:()=>{n(i.split("/").slice(0,-1).join("/")||"/")},disabled:"/"===i||l,children:(0,F.jsx)(ou,{className:"h-4 w-4"})}),(0,F.jsx)("span",{className:"text-sm font-mono truncate flex-1",children:i})]}),l?(0,F.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,F.jsx)(iD,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):d?(0,F.jsx)("div",{className:"p-4 text-sm text-red-500",children:d}):0===o.length?(0,F.jsx)("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No directories found"}):(0,F.jsx)(oc,{className:"h-[200px]",children:(0,F.jsx)("div",{className:"p-1",children:o.map(e=>(0,F.jsxs)("div",{className:`flex items-center gap-2 p-2 rounded-md cursor-pointer hover:bg-muted ${s===e.path?"bg-muted":""}`,children:[(0,F.jsxs)("button",{className:"flex items-center gap-2 flex-1 text-left",onClick:()=>{r(e.path)},children:[(0,F.jsx)(oh,{className:"h-4 w-4 text-muted-foreground"}),(0,F.jsx)("span",{className:"text-sm truncate",children:e.name})]}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:()=>{n(e.path)},title:"Open folder",children:(0,F.jsx)(id,{className:"h-4 w-4"})})]},e.path))})})]}):(0,F.jsx)("div",{className:"text-sm text-muted-foreground p-4 text-center border rounded-md",children:"Select a remote server to browse directories"})}let op={actionType:"command",executionMode:"local",content:""};function om(e){return e?{actionType:e.actionType,executionMode:e.executionMode,content:e.content}:{...op}}function og(e){return{actionType:e.actionType,executionMode:e.executionMode,content:e.content}}function ov({actionType:e,onActionTypeChange:r}){return(0,F.jsxs)("div",{className:"inline-flex items-center rounded-md border bg-muted/50 p-0.5 text-xs",children:[(0,F.jsxs)("button",{onClick:()=>r("command"),className:(0,iu.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","command"===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[(0,F.jsx)(nL.Terminal,{className:"h-3 w-3"}),"Command"]}),(0,F.jsxs)("button",{onClick:()=>r("prompt"),className:(0,iu.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","prompt"===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[(0,F.jsx)(nB,{className:"h-3 w-3"}),"Prompt"]})]})}function ox({config:e,onChange:r,label:s,targets:i}){return(0,F.jsxs)("div",{className:"space-y-4 py-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:s}),i.length>0&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Execution Environment"}),(0,F.jsx)("div",{children:(0,F.jsx)(nP,{targets:i,activeTarget:e.executionMode,onTargetChange:s=>r({...e,executionMode:s})})})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Action Type"}),(0,F.jsx)("div",{children:(0,F.jsx)(ov,{actionType:e.actionType,onActionTypeChange:s=>r({...e,actionType:s})})})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"command"===e.actionType?"Shell Command":"Agent Prompt"}),(0,F.jsx)(nu,{value:e.content,onChange:s=>r({...e,content:s.target.value}),placeholder:"command"===e.actionType?"git push origin HEAD":"Please pull the latest changes and rebase...",rows:3})]})]})}function o_({project:e,onSave:r,onCancel:s}){let{remotes:i,refresh:n}=iP(e.id),o=[];for(let r of(e.path&&o.push({id:"local",label:"Local",icon:nA.Monitor}),i))o.push({id:r.remote_server_id,label:r.server_name,icon:nO});let[a,l]=(0,W.useState)(e.name),[c,d]=(0,W.useState)(e.path??""),[h,u]=(0,W.useState)(!1),[f,p]=(0,W.useState)(""),[m,g]=(0,W.useState)(om(e.sync_up_config)),[v,x]=(0,W.useState)(om(e.sync_down_config)),[_,y]=(0,W.useState)("closed"),[b,w]=(0,W.useState)([]),[S,C]=(0,W.useState)(null),[k,j]=(0,W.useState)(""),[N,E]=(0,W.useState)(""),[R,M]=(0,W.useState)(""),[D,T]=(0,W.useState)(""),[P,L]=(0,W.useState)("idle"),[B,A]=(0,W.useState)(""),O=()=>{y("closed"),C(null),j(""),E(""),M(""),T(""),L("idle"),A("")};(0,W.useEffect)(()=>{l(e.name),d(e.path??""),p(""),g(om(e.sync_up_config)),x(om(e.sync_down_config)),O()},[e.id]);let I=async()=>{let e=await iT.api.selectFolder();e.path&&d(e.path)},z=async()=>{y("pick-server");try{let e=await iT.api.getRemoteServers();w(e)}catch{w([])}},H=async()=>{if(!R||!D)return void A("URL and API key are required");L("testing"),A("");try{await iT.api.testRemoteConnection(R,D),L("success")}catch(e){L("error"),A(e instanceof Error?e.message:"Connection failed")}},K=async()=>{if(N.trim()&&R.trim())try{let e=await iT.api.createRemoteServer({name:N.trim(),url:R.trim(),apiKey:D.trim()||void 0});C(e),j(""),y("pick-path")}catch(e){A(e instanceof Error?e.message:"Failed to create server")}},U=async()=>{if(S&&k)try{await iT.api.addProjectRemote(e.id,{remoteServerId:S.id,remotePath:k}),await n(),O()}catch(e){p(e instanceof Error?e.message:"Failed to add remote")}},q=async r=>{try{await iT.api.removeProjectRemote(e.id,r),await n()}catch(e){p(e instanceof Error?e.message:"Failed to remove remote")}},V=c.trim().length>0,Y=async()=>{if(!a.trim())return void p("Project name is required");if(!V&&0===i.length)return void p("Project must have at least a local folder or remote server");u(!0),p("");try{let s={};a.trim()!==e.name&&(s.name=a.trim());let i=V?c.trim():null;i!==(e.path??null)&&(s.path=i);let n=og(m),o=e.sync_up_config;JSON.stringify(n)!==JSON.stringify(o)&&(s.syncUpConfig=n);let l=og(v),d=e.sync_down_config;JSON.stringify(l)!==JSON.stringify(d)&&(s.syncDownConfig=l),await r(e.id,s)}catch(e){p(e instanceof Error?e.message:"Failed to update project")}finally{u(!1)}};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(n_,{defaultValue:"settings",children:[(0,F.jsxs)(nE,{className:"w-full",children:[(0,F.jsx)(nR,{value:"settings",className:"flex-1",children:"Project Settings"}),(0,F.jsx)(nR,{value:"sync-up",className:"flex-1",children:"Sync Up"}),(0,F.jsx)(nR,{value:"sync-down",className:"flex-1",children:"Sync Down"})]}),(0,F.jsx)(nM,{value:"settings",children:(0,F.jsxs)("div",{className:"space-y-5 py-2",children:[(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Project Name"}),(0,F.jsx)(nh,{value:a,onChange:e=>l(e.target.value),placeholder:"My Project"})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Local Folder"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)(nh,{value:c,onChange:e=>d(e.target.value),placeholder:"/path/to/project (optional)",className:"flex-1"}),(0,F.jsx)($.Button,{variant:"outline",onClick:I,children:(0,F.jsx)(i_,{className:"h-4 w-4"})})]})]}),(0,F.jsxs)("div",{className:"space-y-3",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Remote Servers"}),i.length>0&&(0,F.jsx)("div",{className:"space-y-2",children:i.map(e=>(0,F.jsxs)("div",{className:"flex items-center gap-2 rounded-md border p-2 text-sm",children:[(0,F.jsx)(iw,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,F.jsx)("p",{className:"font-medium truncate",children:e.server_name}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:e.remote_path})]}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 shrink-0",onClick:()=>q(e.id),children:(0,F.jsx)(ib,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},e.id))}),"closed"===_&&(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:z,className:"w-full",children:[(0,F.jsx)(nD,{className:"h-4 w-4 mr-1"}),"Add Remote"]}),"pick-server"===_&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)("label",{className:"text-xs font-medium",children:"Select a Remote Server"}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:O,children:(0,F.jsx)(nr,{className:"h-3.5 w-3.5"})})]}),b.length>0&&(0,F.jsx)("div",{className:"space-y-1",children:b.map(e=>(0,F.jsxs)("button",{className:"flex items-center gap-2 w-full rounded-md p-2 text-sm text-left hover:bg-muted",onClick:()=>{C(e),j(""),y("pick-path")},children:[(0,F.jsx)(nI,{className:"h-4 w-4 text-muted-foreground"}),(0,F.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,F.jsx)("p",{className:"truncate",children:e.name}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.url})]})]},e.id))}),(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:()=>{y("new-server"),E(""),M(""),T(""),L("idle"),A("")},className:"w-full",children:[(0,F.jsx)(nD,{className:"h-4 w-4 mr-1"}),"New Server"]})]}),"new-server"===_&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)("label",{className:"text-xs font-medium",children:"Create New Server"}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:O,children:(0,F.jsx)(nr,{className:"h-3.5 w-3.5"})})]}),(0,F.jsx)(nh,{value:N,onChange:e=>E(e.target.value),placeholder:"Server name"}),(0,F.jsx)(nh,{value:R,onChange:e=>{M(e.target.value),L("idle")},placeholder:"http://remote-server:5173"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)(nh,{type:"password",value:D,onChange:e=>{T(e.target.value),L("idle")},placeholder:"API key",className:"flex-1"}),(0,F.jsx)($.Button,{variant:"outline",size:"sm",onClick:H,disabled:"testing"===P||!R||!D,children:"testing"===P?(0,F.jsx)(iD,{className:"h-4 w-4 animate-spin"}):"success"===P?(0,F.jsx)(iM.Check,{className:"h-4 w-4 text-green-500"}):"error"===P?(0,F.jsx)(nr,{className:"h-4 w-4 text-red-500"}):"Test"})]}),B&&(0,F.jsx)("p",{className:"text-xs text-red-500",children:B}),"success"===P&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("p",{className:"text-xs text-green-500",children:"Connection successful"}),(0,F.jsx)($.Button,{size:"sm",onClick:K,disabled:!N.trim(),children:"Create & Continue"})]})]}),"pick-path"===_&&S&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("label",{className:"text-xs font-medium",children:["Select Directory on ",S.name]}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:O,children:(0,F.jsx)(nr,{className:"h-3.5 w-3.5"})})]}),(0,F.jsx)(of,{serverId:S.id,onSelect:e=>{j(e)},selectedPath:k}),k&&(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Selected:"," ",(0,F.jsx)("span",{className:"font-mono",children:k})]}),(0,F.jsx)($.Button,{size:"sm",onClick:U,children:"Add"})]})]})]})]})}),(0,F.jsx)(nM,{value:"sync-up",children:(0,F.jsx)(ox,{config:m,onChange:g,label:"Sync Up Button",targets:o})}),(0,F.jsx)(nM,{value:"sync-down",children:(0,F.jsx)(ox,{config:v,onChange:x,label:"Sync Down Button",targets:o})})]}),f&&(0,F.jsx)("p",{className:"text-sm text-red-500",children:f}),(0,F.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[s&&(0,F.jsx)($.Button,{variant:"outline",onClick:s,children:"Cancel"}),(0,F.jsx)($.Button,{onClick:Y,disabled:h,children:h?"Saving...":"Save Changes"})]})]})}function oy({project:e,open:r,onOpenChange:s,onProjectUpdated:i}){return(0,F.jsx)(ns,{open:r,onOpenChange:s,children:(0,F.jsxs)(no,{className:"max-w-2xl",children:[(0,F.jsx)(na,{children:(0,F.jsx)(nc,{children:"Edit Project"})}),r&&(0,F.jsx)(o_,{project:e,onSave:async(e,r)=>{await i(e,r),s(!1)},onCancel:()=>s(!1)})]})})}let ob=(0,ic.default)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),ow=(0,ic.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);function oS({open:e,onOpenChange:r,syncType:s,result:i,loading:n}){return(0,F.jsx)(ns,{open:e,onOpenChange:r,children:(0,F.jsxs)(no,{className:"max-w-lg",children:[(0,F.jsx)(na,{children:(0,F.jsxs)(nc,{children:["Sync ","up"===s?"Up":"Down"," Output"]})}),(0,F.jsxs)("div",{className:"space-y-3 py-2",children:[n&&(0,F.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,F.jsx)(iD,{className:"h-4 w-4 animate-spin"}),(0,F.jsx)("span",{children:"Running command..."})]}),i&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[i.success?(0,F.jsx)(ob,{className:"h-4 w-4 text-green-500"}):(0,F.jsx)(ow,{className:"h-4 w-4 text-red-500"}),(0,F.jsxs)("span",{className:"text-sm",children:["Exit code: ",i.exitCode]})]}),i.stdout&&(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"stdout"}),(0,F.jsx)("pre",{className:"text-xs bg-muted rounded-md p-3 overflow-auto max-h-48 whitespace-pre-wrap break-all",children:i.stdout})]}),i.stderr&&(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"stderr"}),(0,F.jsx)("pre",{className:"text-xs bg-muted rounded-md p-3 overflow-auto max-h-48 whitespace-pre-wrap break-all text-red-400",children:i.stderr})]}),!i.stdout&&!i.stderr&&(0,F.jsx)("p",{className:"text-sm text-muted-foreground",children:"No output"})]})]}),(0,F.jsx)("div",{className:"flex justify-end",children:(0,F.jsx)($.Button,{variant:"outline",onClick:()=>r(!1),children:"Close"})})]})})}function oC({project:e,selectedBranch:r,onUpdateProject:s,onDeleteProject:i,onSyncPrompt:n,assignedTask:o,onStartTask:a,onResetTask:l,startingTask:c}){let{remotes:d}=iP(e.id),[h,u]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1),[m,g]=(0,W.useState)({type:"up",result:null,loading:!1}),[v,x]=(0,W.useState)(null),_=new Date(e.created_at).toLocaleDateString(),y=e=>{navigator.clipboard.writeText(e),x(e),setTimeout(()=>x(null),2e3)},b=[],w=[];for(let r of(e.sync_up_config&&b.push({label:"Project",config:e.sync_up_config}),e.sync_down_config&&w.push({label:"Project",config:e.sync_down_config}),d))r.sync_up_config&&b.push({label:r.server_name,config:r.sync_up_config,remoteServerId:r.remote_server_id}),r.sync_down_config&&w.push({label:r.server_name,config:r.sync_down_config,remoteServerId:r.remote_server_id});let S=async(s,i,o)=>{if("prompt"===i.actionType)return void n?.(i.content,i.executionMode);g({type:s,result:null,loading:!0}),p(!0);try{let i=await iT.api.executeSyncCommand(e.id,s,r,o);g({type:s,result:i,loading:!1})}catch(e){g({type:s,result:{success:!1,stdout:"",stderr:e instanceof Error?e.message:"Command execution failed",exitCode:1},loading:!1})}},C=b.length>0,k=w.length>0,j=!!e.path,N=d.length,E=(e,r)=>{let s="up"===e?ik:ij,i="up"===e?"Sync Up":"Sync Down";if(0===r.length)return null;if(1===r.length){let n=r[0];return(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7",onClick:()=>S(e,n.config,n.remoteServerId),title:`${i}: ${n.config.content.slice(0,50)}${n.config.content.length>50?"...":""}`,children:(0,F.jsx)(s,{className:"h-4 w-4"})})}return(0,F.jsxs)(ip,{children:[(0,F.jsx)(im,{asChild:!0,children:(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7",title:i,children:(0,F.jsx)(s,{className:"h-4 w-4"})})}),(0,F.jsx)(ig,{align:"end",children:r.map((r,s)=>(0,F.jsxs)(iv,{onSelect:()=>S(e,r.config,r.remoteServerId),children:[r.label,": ",r.config.content.slice(0,40),r.config.content.length>40?"...":""]},`${r.remoteServerId??"project"}-${s}`))})]})};return(0,F.jsxs)(H.Card,{className:"border-border/60 shadow-sm",children:[(0,F.jsx)(H.CardHeader,{className:"pb-2",children:(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(H.CardTitle,{className:"text-sm font-semibold flex-1",children:e.name}),j&&N>1?(0,F.jsxs)("span",{className:"flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-purple-500/10 text-purple-500",title:`Local + ${N} remotes`,children:[(0,F.jsx)(iw,{className:"h-3 w-3"}),"Local + ",N," Remotes"]}):j&&1===N?(0,F.jsxs)("span",{className:"flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-purple-500/10 text-purple-500",title:`Local + Remote: ${d[0].server_name}`,children:[(0,F.jsx)(iw,{className:"h-3 w-3"}),"Local + Remote"]}):!j&&N>1?(0,F.jsxs)("span",{className:"flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-blue-500/10 text-blue-500",title:`${N} remotes`,children:[(0,F.jsx)(iw,{className:"h-3 w-3"}),N," Remotes"]}):j||1!==N?j&&e.remote_path?(0,F.jsxs)("span",{className:"flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-purple-500/10 text-purple-500",title:`Local + Remote: ${e.remote_url}`,children:[(0,F.jsx)(iw,{className:"h-3 w-3"}),"Local + Remote"]}):!j&&e.remote_path?(0,F.jsxs)("span",{className:"flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-blue-500/10 text-blue-500",title:`Remote: ${e.remote_url}`,children:[(0,F.jsx)(iw,{className:"h-3 w-3"}),"Remote"]}):null:(0,F.jsxs)("span",{className:"flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-blue-500/10 text-blue-500",title:`Remote: ${d[0].server_name}`,children:[(0,F.jsx)(iw,{className:"h-3 w-3"}),"Remote"]}),C&&E("up",b),k&&E("down",w),(0,F.jsxs)(ip,{children:[(0,F.jsx)(im,{asChild:!0,children:(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7",children:(0,F.jsx)(iS,{className:"h-4 w-4"})})}),(0,F.jsxs)(ig,{align:"end",children:[(0,F.jsxs)(iv,{onSelect:()=>u(!0),children:[(0,F.jsx)(iC,{className:"h-4 w-4 mr-2"}),"Edit"]}),(0,F.jsxs)(iv,{className:"text-destructive focus:text-destructive",onSelect:()=>i(e.id),children:[(0,F.jsx)(ib,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})}),(0,F.jsxs)(H.CardContent,{className:"space-y-3",children:[e.path&&(0,F.jsxs)("div",{className:"group/path flex items-center gap-2 text-sm text-muted-foreground",children:[(0,F.jsx)(i_,{className:"h-4 w-4 shrink-0"}),(0,F.jsx)("span",{className:"truncate flex-1",title:e.path,children:e.path}),(0,F.jsx)("button",{onClick:()=>y(e.path),className:"shrink-0 p-0.5 rounded hover:bg-muted opacity-0 group-hover/path:opacity-100 transition-opacity",title:"Copy local path",children:v===e.path?(0,F.jsx)(iM.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,F.jsx)(iR.Copy,{className:"h-3.5 w-3.5"})})]}),d.map(e=>(0,F.jsxs)("div",{className:"group/remote flex items-center gap-2 text-sm text-muted-foreground",children:[(0,F.jsx)(iw,{className:"h-4 w-4 shrink-0"}),(0,F.jsxs)("span",{className:"truncate flex-1",title:`${e.server_name}: ${e.remote_path}`,children:[e.server_name,": ",e.remote_path]}),(0,F.jsx)("button",{onClick:()=>y(e.remote_path),className:"shrink-0 p-0.5 rounded hover:bg-muted opacity-0 group-hover/remote:opacity-100 transition-opacity",title:"Copy remote path",children:v===e.remote_path?(0,F.jsx)(iM.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,F.jsx)(iR.Copy,{className:"h-3.5 w-3.5"})})]},e.id)),0===d.length&&e.remote_path&&e.remote_url&&(0,F.jsxs)("div",{className:"group/remote flex items-center gap-2 text-sm text-muted-foreground",children:[(0,F.jsx)(iw,{className:"h-4 w-4 shrink-0"}),(0,F.jsxs)("span",{className:"truncate flex-1",title:`${e.remote_url}:${e.remote_path}`,children:[e.remote_url,":",e.remote_path]}),(0,F.jsx)("button",{onClick:()=>y(e.remote_path),className:"shrink-0 p-0.5 rounded hover:bg-muted opacity-0 group-hover/remote:opacity-100 transition-opacity",title:"Copy remote path",children:v===e.remote_path?(0,F.jsx)(iM.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,F.jsx)(iR.Copy,{className:"h-3.5 w-3.5"})})]}),(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,F.jsx)(iy,{className:"h-4 w-4"}),(0,F.jsx)("span",{children:_})]}),o&&(0,F.jsxs)("div",{className:"border-t border-border/40 pt-3 space-y-2",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,F.jsx)("span",{className:"text-muted-foreground text-xs font-medium",children:"Assigned Task:"}),(0,F.jsx)("span",{className:"text-sm truncate flex-1",children:o.title})]}),(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsxs)($.Button,{size:"sm",className:"flex-1 active:scale-95 transition-transform",onClick:()=>a?.(o),disabled:c,children:[c?(0,F.jsx)(iD,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,F.jsx)(iN,{className:"h-3.5 w-3.5 mr-1"}),c?"Starting...":"Start"]}),(0,F.jsxs)($.Button,{size:"sm",variant:"outline",onClick:()=>l?.(o.id),children:[(0,F.jsx)(iE,{className:"h-3.5 w-3.5 mr-1"}),"Reset"]})]})]})]}),(0,F.jsx)(oy,{project:e,open:h,onOpenChange:u,onProjectUpdated:s}),(0,F.jsx)(oS,{open:f,onOpenChange:p,syncType:m.type,result:m.result,loading:m.loading})]})}function ok({project:e}){let r=!!e.path,s=e.is_remote||!!e.remote_path;return r&&s?(0,F.jsx)("span",{className:"inline-flex items-center rounded-full bg-purple-500/10 px-2.5 py-0.5 text-xs font-medium text-purple-600",children:"Local + Remote"}):s?(0,F.jsx)("span",{className:"inline-flex items-center rounded-full bg-blue-500/10 px-2.5 py-0.5 text-xs font-medium text-blue-600",children:"Remote"}):(0,F.jsx)("span",{className:"inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 text-xs font-medium text-muted-foreground",children:"Local"})}function oj({project:e,onProjectUpdated:r}){let{remotes:s}=iP(e.id);return(0,F.jsx)("div",{className:"h-full flex flex-col p-6 overflow-hidden",children:(0,F.jsxs)(n_,{defaultValue:"home",className:"w-full max-w-2xl mx-auto flex flex-col flex-1 min-h-0",children:[(0,F.jsxs)(nE,{children:[(0,F.jsx)(nR,{value:"home",children:"Home"}),(0,F.jsx)(nR,{value:"settings",children:"Settings"})]}),(0,F.jsx)(nM,{value:"home",className:"flex-1 flex items-center justify-center",children:(0,F.jsxs)(H.Card,{className:"w-full max-w-md",children:[(0,F.jsx)(H.CardHeader,{children:(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)(H.CardTitle,{className:"text-lg",children:e.name}),(0,F.jsx)(ok,{project:e})]})}),(0,F.jsxs)(H.CardContent,{className:"space-y-4",children:[e.path&&(0,F.jsxs)("div",{className:"flex items-start gap-3 text-sm",children:[(0,F.jsx)(i_,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,F.jsx)("span",{className:"text-muted-foreground break-all",children:e.path})]}),s.map(e=>(0,F.jsxs)("div",{className:"flex items-start gap-3 text-sm",children:[(0,F.jsx)(iw,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:"text-muted-foreground break-all",children:e.server_name}),e.server_url&&(0,F.jsx)("span",{className:"block text-xs text-muted-foreground/70 break-all",children:e.server_url})]})]},e.id)),(0,F.jsxs)("div",{className:"flex items-center gap-3 text-sm",children:[(0,F.jsx)(iy,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsxs)("span",{className:"text-muted-foreground",children:["Created ",new Date(e.created_at).toLocaleDateString()]})]})]})]})}),(0,F.jsx)(nM,{value:"settings",className:"flex-1 overflow-auto",children:(0,F.jsx)(o_,{project:e,onSave:r})})]})})}function oN({open:e,onOpenChange:r,onProjectCreated:s}){let[i,n]=(0,W.useState)(""),[o,a]=(0,W.useState)(""),[l,c]=(0,W.useState)([]),[d,h]=(0,W.useState)("closed"),[u,f]=(0,W.useState)([]),[p,m]=(0,W.useState)(null),[g,v]=(0,W.useState)(""),[x,_]=(0,W.useState)(""),[y,b]=(0,W.useState)(""),[w,S]=(0,W.useState)(""),[C,k]=(0,W.useState)("idle"),[j,N]=(0,W.useState)(""),[E,R]=(0,W.useState)(!1),[M,D]=(0,W.useState)(""),T=()=>{n(""),a(""),c([]),P(),D("")},P=()=>{h("closed"),m(null),v(""),_(""),b(""),S(""),k("idle"),N("")},L=e=>{e||T(),r(e)},B=async()=>{let e=await iT.api.selectFolder();e.path&&(a(e.path),i||n(e.path.split("/").pop()||""))},A=async()=>{h("pick-server");try{let e=await iT.api.getRemoteServers();f(e)}catch{f([])}},O=async()=>{if(!y||!w)return void N("URL and API key are required");k("testing"),N("");try{await iT.api.testRemoteConnection(y,w),k("success")}catch(e){k("error"),N(e instanceof Error?e.message:"Connection failed")}},I=async()=>{if(x.trim()&&y.trim())try{let e=await iT.api.createRemoteServer({name:x.trim(),url:y.trim(),apiKey:w.trim()||void 0});m(e),v(""),h("pick-path")}catch(e){N(e instanceof Error?e.message:"Failed to create server")}},z=o.trim().length>0,H=l.length>0,K=async()=>{if(!i.trim())return void D("Project name is required");if(!z&&!H)return void D("Please provide a local folder, remote server, or both");R(!0),D("");try{let e=await iT.api.createProject({name:i.trim(),...z?{path:o.trim()}:{},...H&&!z?{agentMode:l[0].serverId}:{}});for(let r of l)await iT.api.addProjectRemote(e.id,{remoteServerId:r.serverId,remotePath:r.remotePath});s(e),T(),r(!1)}catch(e){D(e instanceof Error?e.message:"Failed to create project")}finally{R(!1)}};return(0,F.jsx)(ns,{open:e,onOpenChange:L,children:(0,F.jsxs)(no,{className:"max-w-lg",children:[(0,F.jsx)(na,{children:(0,F.jsx)(nc,{children:"Create New Project"})}),(0,F.jsxs)("div",{className:"space-y-5 py-2",children:[(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Project Name"}),(0,F.jsx)(nh,{value:i,onChange:e=>n(e.target.value),placeholder:"My Project"})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Local Folder"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)(nh,{value:o,onChange:e=>a(e.target.value),placeholder:"/path/to/project (optional)",className:"flex-1"}),(0,F.jsx)($.Button,{variant:"outline",onClick:B,children:(0,F.jsx)(i_,{className:"h-4 w-4"})})]})]}),(0,F.jsxs)("div",{className:"space-y-3",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Remote Servers"}),l.length>0&&(0,F.jsx)("div",{className:"space-y-2",children:l.map((e,r)=>(0,F.jsxs)("div",{className:"flex items-center gap-2 rounded-md border p-2 text-sm",children:[(0,F.jsx)(iw,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,F.jsx)("p",{className:"font-medium truncate",children:e.serverName}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:e.remotePath})]}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 shrink-0",onClick:()=>{c(e=>e.filter((e,s)=>s!==r))},children:(0,F.jsx)(ib,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},`${e.serverId}-${e.remotePath}`))}),"closed"===d&&(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:A,className:"w-full",children:[(0,F.jsx)(nD,{className:"h-4 w-4 mr-1"}),"Add Remote"]}),"pick-server"===d&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)("label",{className:"text-xs font-medium",children:"Select a Remote Server"}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:P,children:(0,F.jsx)(nr,{className:"h-3.5 w-3.5"})})]}),u.length>0&&(0,F.jsx)("div",{className:"space-y-1",children:u.map(e=>(0,F.jsxs)("button",{className:"flex items-center gap-2 w-full rounded-md p-2 text-sm text-left hover:bg-muted",onClick:()=>{m(e),v(""),h("pick-path")},children:[(0,F.jsx)(nI,{className:"h-4 w-4 text-muted-foreground"}),(0,F.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,F.jsx)("p",{className:"truncate",children:e.name}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.url})]})]},e.id))}),(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:()=>{h("new-server"),_(""),b(""),S(""),k("idle"),N("")},className:"w-full",children:[(0,F.jsx)(nD,{className:"h-4 w-4 mr-1"}),"New Server"]})]}),"new-server"===d&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)("label",{className:"text-xs font-medium",children:"Create New Server"}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:P,children:(0,F.jsx)(nr,{className:"h-3.5 w-3.5"})})]}),(0,F.jsx)(nh,{value:x,onChange:e=>_(e.target.value),placeholder:"Server name"}),(0,F.jsx)(nh,{value:y,onChange:e=>{b(e.target.value),k("idle")},placeholder:"http://remote-server:5173"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)(nh,{type:"password",value:w,onChange:e=>{S(e.target.value),k("idle")},placeholder:"API key",className:"flex-1"}),(0,F.jsx)($.Button,{variant:"outline",size:"sm",onClick:O,disabled:"testing"===C||!y||!w,children:"testing"===C?(0,F.jsx)(iD,{className:"h-4 w-4 animate-spin"}):"success"===C?(0,F.jsx)(iM.Check,{className:"h-4 w-4 text-green-500"}):"error"===C?(0,F.jsx)(nr,{className:"h-4 w-4 text-red-500"}):"Test"})]}),j&&(0,F.jsx)("p",{className:"text-xs text-red-500",children:j}),"success"===C&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("p",{className:"text-xs text-green-500",children:"Connection successful"}),(0,F.jsx)($.Button,{size:"sm",onClick:I,disabled:!x.trim(),children:"Create & Continue"})]})]}),"pick-path"===d&&p&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("label",{className:"text-xs font-medium",children:["Select Directory on ",p.name]}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:P,children:(0,F.jsx)(nr,{className:"h-3.5 w-3.5"})})]}),(0,F.jsx)(of,{serverId:p.id,onSelect:e=>{v(e)},selectedPath:g}),g&&(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Selected: ",(0,F.jsx)("span",{className:"font-mono",children:g})]}),(0,F.jsx)($.Button,{size:"sm",onClick:()=>{p&&g&&(l.some(e=>e.serverId===p.id&&e.remotePath===g)||(c(e=>[...e,{serverId:p.id,serverName:p.name,serverUrl:p.url,remotePath:g}]),i||n(g.split("/").pop()||"")),P())},children:"Add"})]})]})]})]}),M&&(0,F.jsx)("p",{className:"text-sm text-red-500",children:M}),(0,F.jsxs)(nl,{children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),(0,F.jsx)($.Button,{onClick:K,disabled:E,children:E?"Creating...":"Create Project"})]})]})})}let oE=(0,ic.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);function oR(){let[e,r]=(0,W.useState)("deepseek"),[s,i]=(0,W.useState)(""),[n,o]=(0,W.useState)(""),[a,l]=(0,W.useState)(""),[c,d]=(0,W.useState)(!0),[h,u]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),[m,g]=(0,W.useState)(!1),[v,x]=(0,W.useState)(!1);(0,W.useEffect)(()=>{d(!0),iT.api.getChatProviderSettings().then(e=>{r(e.provider),i(e.deepseekApiKey),o(e.openrouterApiKey),l(e.openrouterModel),g(!1),x(!1),d(!1)}).catch(()=>{d(!1)})},[]);let _=async()=>{u(!0),p(null);try{let r={provider:e,openrouterModel:a};m&&(r.deepseekApiKey=s),v&&(r.openrouterApiKey=n);let l=await iT.api.updateChatProviderSettings(r);i(l.deepseekApiKey),o(l.openrouterApiKey),g(!1),x(!1),p("Settings saved"),setTimeout(()=>p(null),2e3)}catch(e){p(e instanceof Error?e.message:"Failed to save")}finally{u(!1)}};return c?(0,F.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,F.jsx)(iD,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-2 block",children:"Provider"}),(0,F.jsx)("div",{className:"space-y-2",children:[["deepseek","DeepSeek","Use DeepSeek API directly"],["openrouter","OpenRouter","Route through OpenRouter (supports many models)"]].map(([s,i,n])=>(0,F.jsxs)("label",{className:`flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-all duration-150 ${e===s?"border-primary/40 bg-primary/5 shadow-sm":"border-border/60 hover:border-border hover:bg-accent/30"}`,children:[(0,F.jsx)("input",{type:"radio",name:"chatProvider",value:s,checked:e===s,onChange:()=>{r(s),p(null)},className:"mt-0.5"}),(0,F.jsxs)("div",{children:[(0,F.jsx)("div",{className:"text-sm font-medium",children:i}),(0,F.jsx)("div",{className:"text-xs text-muted-foreground",children:n})]})]},s))})]}),"deepseek"===e&&(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"DeepSeek API Key"}),(0,F.jsx)(nh,{type:"password",placeholder:s&&!m?s:"sk-...",value:m?s:"",onChange:e=>{i(e.target.value),g(!0),p(null)}}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Leave empty to use DEEPSEEK_API_KEY environment variable"})]}),"openrouter"===e&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"OpenRouter API Key"}),(0,F.jsx)(nh,{type:"password",placeholder:n&&!v?n:"sk-or-...",value:v?n:"",onChange:e=>{o(e.target.value),x(!0),p(null)}}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Leave empty to use OPENROUTER_API_KEY environment variable"})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Model"}),(0,F.jsx)(nh,{placeholder:"deepseek/deepseek-chat-v3-0324",value:a,onChange:e=>{l(e.target.value),p(null)}}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"OpenRouter model identifier. Leave empty for default."})]})]}),f&&(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:["Settings saved"===f&&(0,F.jsx)(oE,{className:"h-4 w-4 text-green-500"}),f]}),(0,F.jsx)("div",{className:"flex justify-end pt-2",children:(0,F.jsxs)($.Button,{onClick:_,disabled:h,children:[h&&(0,F.jsx)(iD,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Save"]})})]})}function oM(){let[e,r]=(0,W.useState)("none"),[s,i]=(0,W.useState)(""),[n,o]=(0,W.useState)(""),[a,l]=(0,W.useState)(!0),[c,d]=(0,W.useState)(!1),[h,u]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),[m,g]=(0,W.useState)(null);(0,W.useEffect)(()=>{l(!0),p(null),g(null),iT.api.getProxySettings().then(e=>{r(e.type),i(e.host),o(e.port?String(e.port):""),l(!1)}).catch(()=>{l(!1)})},[]);let v=()=>({type:e,host:"none"===e?"":s.trim(),port:"none"===e?0:parseInt(n,10)||0}),x=async()=>{u(!0),p(null);try{let e=await iT.api.testProxyConnection(v());p(e)}catch(e){p({success:!1,message:e instanceof Error?e.message:"Test failed"})}finally{u(!1)}},_=async()=>{d(!0),g(null);try{await iT.api.updateProxySettings(v()),g("Settings saved")}catch(e){g(e instanceof Error?e.message:"Failed to save")}finally{d(!1)}},y="none"!==e;return(0,F.jsxs)("div",{className:"h-full flex flex-col overflow-auto",children:[(0,F.jsxs)("div",{className:"border-b border-border/60 px-6 py-4 flex-shrink-0",children:[(0,F.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Settings"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Configure proxy and network settings"})]}),(0,F.jsx)("div",{className:"flex-1 px-6 py-5 flex justify-center",children:(0,F.jsx)("div",{className:"w-full max-w-2xl",children:a?(0,F.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,F.jsx)(iD,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,F.jsxs)("div",{className:"space-y-8",children:[(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsx)("h3",{className:"text-sm font-semibold",children:"AI Chat"}),(0,F.jsx)(oR,{})]}),(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsx)("h3",{className:"text-sm font-semibold",children:"Proxy"}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-2 block",children:"Proxy Type"}),(0,F.jsx)("div",{className:"space-y-2",children:[["none","No Proxy","Direct connection"],["http","HTTP Proxy","Route through HTTP/HTTPS proxy"],["socks5","SOCKS5 Proxy","Route through SOCKS5 proxy"]].map(([s,i,n])=>(0,F.jsxs)("label",{className:`flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-all duration-150 ${e===s?"border-primary/40 bg-primary/5 shadow-sm":"border-border/60 hover:border-border hover:bg-accent/30"}`,children:[(0,F.jsx)("input",{type:"radio",name:"proxyType",value:s,checked:e===s,onChange:()=>{r(s),p(null),g(null)},className:"mt-0.5"}),(0,F.jsxs)("div",{children:[(0,F.jsx)("div",{className:"text-sm font-medium",children:i}),(0,F.jsx)("div",{className:"text-xs text-muted-foreground",children:n})]})]},s))})]}),y&&(0,F.jsxs)("div",{className:"flex gap-3",children:[(0,F.jsxs)("div",{className:"flex-1",children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Host"}),(0,F.jsx)(nh,{placeholder:"127.0.0.1",value:s,onChange:e=>{i(e.target.value),p(null),g(null)}})]}),(0,F.jsxs)("div",{className:"w-24",children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Port"}),(0,F.jsx)(nh,{type:"number",placeholder:"1080",value:n,onChange:e=>{o(e.target.value),p(null),g(null)},min:1,max:65535})]})]}),f&&(0,F.jsxs)("div",{className:`flex items-center gap-2 text-sm p-2 rounded-md ${f.success?"text-green-600 bg-green-50 dark:text-green-400 dark:bg-green-950/30":"text-red-600 bg-red-50 dark:text-red-400 dark:bg-red-950/30"}`,children:[f.success?(0,F.jsx)(oE,{className:"h-4 w-4 shrink-0"}):(0,F.jsx)(ow,{className:"h-4 w-4 shrink-0"}),(0,F.jsx)("span",{className:"truncate",children:f.message})]}),m&&!f&&(0,F.jsx)("div",{className:"text-sm text-muted-foreground text-center",children:m}),(0,F.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[y&&(0,F.jsxs)($.Button,{variant:"outline",onClick:x,disabled:h||!s.trim()||!n,children:[h&&(0,F.jsx)(iD,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Test Connection"]}),(0,F.jsxs)($.Button,{onClick:_,disabled:c,children:[c&&(0,F.jsx)(iD,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Save"]})]})]})]})})})]})}function oD({className:e,...r}){return(0,F.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,F.jsx)("table",{"data-slot":"table",className:(0,iu.cn)("w-full caption-bottom text-sm",e),...r})})}function oT({className:e,...r}){return(0,F.jsx)("thead",{"data-slot":"table-header",className:(0,iu.cn)("[&_tr]:border-b",e),...r})}function oP({className:e,...r}){return(0,F.jsx)("tbody",{"data-slot":"table-body",className:(0,iu.cn)("[&_tr:last-child]:border-0",e),...r})}function oL({className:e,...r}){return(0,F.jsx)("tr",{"data-slot":"table-row",className:(0,iu.cn)("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...r})}function oB({className:e,...r}){return(0,F.jsx)("th",{"data-slot":"table-head",className:(0,iu.cn)("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}function oA({className:e,...r}){return(0,F.jsx)("td",{"data-slot":"table-cell",className:(0,iu.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}let oO=(0,ic.default)("plug-zap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]),oI=(0,ic.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),oz={name:"",url:"",apiKey:"",connectionMode:"outbound"};function oF(){let[e,r]=(0,W.useState)([]),[s,i]=(0,W.useState)(!0),[n,o]=(0,W.useState)(""),[a,l]=(0,W.useState)(!1),[c,d]=(0,W.useState)(null),[h,u]=(0,W.useState)(oz),[f,p]=(0,W.useState)(""),[m,g]=(0,W.useState)(!1),[v,x]=(0,W.useState)(null),[_,y]=(0,W.useState)(!1),[b,w]=(0,W.useState)({}),[S,C]=(0,W.useState)({}),[k,j]=(0,W.useState)(null),[N,E]=(0,W.useState)(null),[R,M]=(0,W.useState)(null),[D,T]=(0,W.useState)(!1),[P,L]=(0,W.useState)(!1),B=(0,W.useCallback)(async()=>{try{let e=await iT.api.getRemoteServers();r(e),o("")}catch(e){o(e instanceof Error?e.message:"Failed to load servers")}finally{i(!1)}},[]);(0,W.useEffect)(()=>{B()},[B]),(0,W.useEffect)(()=>{let e=setInterval(B,15e3),r=()=>B();return window.addEventListener("focus",r),()=>{clearInterval(e),window.removeEventListener("focus",r)}},[B]);let A=async()=>{if(!h.name.trim())return void p("Name is required");if("outbound"===h.connectionMode&&!h.url.trim())return void p("URL is required for outbound servers");g(!0),p("");try{if(c){let e={};h.name.trim()!==c.name&&(e.name=h.name.trim()),h.url.trim()!==(c.url||"")&&(e.url=h.url.trim()),h.apiKey.trim()&&(e.apiKey=h.apiKey.trim()),await iT.api.updateRemoteServer(c.id,e)}else await iT.api.createRemoteServer({name:h.name.trim(),url:h.url.trim(),...h.apiKey.trim()?{apiKey:h.apiKey.trim()}:{},connectionMode:h.connectionMode});l(!1),await B()}catch(e){p(e instanceof Error?e.message:"Failed to save server")}finally{g(!1)}},O=async()=>{if(v){y(!0);try{await iT.api.deleteRemoteServer(v.id),x(null),await B()}catch(e){p(e instanceof Error?e.message:"Failed to delete server")}finally{y(!1)}}},I=async e=>{w(r=>({...r,[e.id]:"testing"})),C(r=>{let s={...r};return delete s[e.id],s});try{let r=await iT.api.testRemoteServer(e.id);w(s=>({...s,[e.id]:r.success?"success":"error"})),r.success||C(r=>({...r,[e.id]:"Connection failed"}))}catch(r){w(r=>({...r,[e.id]:"error"})),C(s=>({...s,[e.id]:r instanceof Error?r.message:"Test failed"}))}},z=async e=>{j(e),E(null),M(null),L(!1),T(!0);try{let r=await iT.api.generateRemoteServerToken(e.id);E(r.token),M(r.connectCommand)}catch(e){p(e instanceof Error?e.message:"Failed to generate token"),j(null)}finally{T(!1)}},H=async e=>{try{await iT.api.revokeRemoteServerToken(e.id),await B()}catch(e){o(e instanceof Error?e.message:"Failed to revoke token")}};return s?(0,F.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,F.jsx)(iD,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("h3",{className:"text-sm font-medium",children:"Remote Servers"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"Manage globally available remote servers"})]}),(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:()=>{d(null),u(oz),p(""),l(!0)},children:[(0,F.jsx)(nD,{className:"h-4 w-4 mr-1.5"}),"Add Server"]})]}),n&&(0,F.jsx)("p",{className:"text-sm text-red-500",children:n}),0===e.length?(0,F.jsxs)("div",{className:"text-center py-8 text-sm text-muted-foreground border rounded-md",children:[(0,F.jsx)(iw,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),"No remote servers configured"]}):(0,F.jsxs)(oD,{children:[(0,F.jsx)(oT,{children:(0,F.jsxs)(oL,{children:[(0,F.jsx)(oB,{children:"Name"}),(0,F.jsx)(oB,{children:"Mode"}),(0,F.jsx)(oB,{children:"URL / Status"}),(0,F.jsx)(oB,{className:"w-[180px] text-right",children:"Actions"})]})}),(0,F.jsx)(oP,{children:e.map(e=>{let r;return(0,F.jsxs)(oL,{children:[(0,F.jsx)(oA,{className:"font-medium",children:(0,F.jsxs)("div",{className:"flex items-center",children:[(e=>{if("inbound"!==e.connection_mode)return null;let r="online"===e.status;return(0,F.jsx)("span",{className:`inline-block h-2.5 w-2.5 rounded-full mr-2 ${r?"bg-green-500":"bg-gray-400"}`,title:r?"Online":"Offline"})})(e),e.name]})}),(0,F.jsx)(oA,{children:(0,F.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${"inbound"===e.connection_mode?"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400":"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-400"}`,children:"inbound"===e.connection_mode?"Inbound":"Outbound"})}),(0,F.jsx)(oA,{className:"font-mono text-xs text-muted-foreground",children:"inbound"===e.connection_mode?"online"===e.status?"Connected":"Waiting for connection...":e.url}),(0,F.jsxs)(oA,{className:"text-right",children:[(0,F.jsxs)("div",{className:"flex items-center justify-end gap-1",children:["inbound"===e.connection_mode&&(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>z(e),title:"Generate connect token",className:"h-8 w-8",children:(0,F.jsx)(oI,{className:"h-4 w-4"})}),(r=b[e.id]||"idle",(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>I(e),disabled:"testing"===r,title:"Test connection",className:"h-8 w-8",children:"testing"===r?(0,F.jsx)(iD,{className:"h-4 w-4 animate-spin"}):"success"===r?(0,F.jsx)(iM.Check,{className:"h-4 w-4 text-green-500"}):"error"===r?(0,F.jsx)(nr,{className:"h-4 w-4 text-red-500"}):(0,F.jsx)(oO,{className:"h-4 w-4"})})),(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>{d(e),u({name:e.name,url:e.url||"",apiKey:"",connectionMode:e.connection_mode}),p(""),l(!0)},title:"Edit server",className:"h-8 w-8",children:(0,F.jsx)(iC,{className:"h-4 w-4"})}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>x(e),title:"Delete server",className:"h-8 w-8 text-destructive hover:text-destructive",children:(0,F.jsx)(ib,{className:"h-4 w-4"})})]}),S[e.id]&&(0,F.jsx)("p",{className:"text-xs text-red-500 mt-1 text-right",children:S[e.id]})]})]},e.id)})})]}),(0,F.jsx)(ns,{open:a,onOpenChange:l,children:(0,F.jsxs)(no,{className:"sm:max-w-md",children:[(0,F.jsxs)(na,{children:[(0,F.jsx)(nc,{children:c?"Edit Server":"Add Remote Server"}),(0,F.jsx)(nd,{children:c?"Update the server connection details.":"Add a new remote server to the global registry."})]}),(0,F.jsxs)("div",{className:"space-y-4",children:[!c&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Connection Mode"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)($.Button,{type:"button",variant:"outbound"===h.connectionMode?"default":"outline",size:"sm",onClick:()=>u(e=>({...e,connectionMode:"outbound"})),children:"Outbound"}),(0,F.jsx)($.Button,{type:"button",variant:"inbound"===h.connectionMode?"default":"outline",size:"sm",onClick:()=>u(e=>({...e,connectionMode:"inbound"})),children:"Inbound"})]}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"outbound"===h.connectionMode?"Server connects outbound to the remote node (remote must have a public URL).":"Remote node connects inbound to this server (no public URL needed on remote)."})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,F.jsx)(nh,{value:h.name,onChange:e=>{u(r=>({...r,name:e.target.value})),p("")},placeholder:"My Remote Server"})]}),("outbound"===h.connectionMode||c)&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsxs)("label",{className:"text-sm font-medium",children:["URL","inbound"!==h.connectionMode||c?"":" (optional)"]}),(0,F.jsx)(nh,{value:h.url,onChange:e=>{u(r=>({...r,url:e.target.value})),p("")},placeholder:"http://remote-server:5173"})]}),"outbound"===h.connectionMode&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"API Key"}),(0,F.jsx)(nh,{type:"password",value:h.apiKey,onChange:e=>{u(r=>({...r,apiKey:e.target.value})),p("")},placeholder:c?"(unchanged)":"Optional"})]}),f&&(0,F.jsx)("p",{className:"text-sm text-red-500",children:f})]}),(0,F.jsxs)(nl,{children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),(0,F.jsxs)($.Button,{onClick:A,disabled:m,children:[m&&(0,F.jsx)(iD,{className:"h-4 w-4 mr-1.5 animate-spin"}),c?"Save Changes":"Add Server"]})]})]})}),(0,F.jsx)(ns,{open:null!==k,onOpenChange:e=>{e||(j(null),E(null),M(null))},children:(0,F.jsxs)(no,{className:"sm:max-w-lg",children:[(0,F.jsxs)(na,{children:[(0,F.jsx)(nc,{children:"Connect Token"}),(0,F.jsxs)(nd,{children:["Use this token to connect a remote node to"," ",(0,F.jsx)("span",{className:"font-semibold",children:k?.name}),". The token is shown only once."]})]}),D?(0,F.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,F.jsx)(iD,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):N?(0,F.jsx)("div",{className:"space-y-4",children:(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Connect Command"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)(nh,{readOnly:!0,value:R||"",className:"font-mono text-xs"}),(0,F.jsx)($.Button,{variant:"outline",size:"icon",className:"shrink-0",onClick:()=>{var e;return e=R||"",void(navigator.clipboard.writeText(e),L(!0),setTimeout(()=>L(!1),2e3))},title:"Copy command",children:P?(0,F.jsx)(iM.Check,{className:"h-4 w-4 text-green-500"}):(0,F.jsx)(iR.Copy,{className:"h-4 w-4"})})]}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"Run this command on the remote machine to establish the reverse connection."})]})}):null,(0,F.jsxs)(nl,{children:[N&&k&&(0,F.jsx)($.Button,{variant:"outline",className:"mr-auto text-destructive hover:text-destructive",onClick:()=>{H(k),j(null),E(null)},children:"Revoke Token"}),(0,F.jsx)($.Button,{variant:"outline",onClick:()=>{j(null),E(null),M(null)},children:"Close"})]})]})}),(0,F.jsx)(ns,{open:null!==v,onOpenChange:e=>{e||x(null)},children:(0,F.jsxs)(no,{className:"sm:max-w-sm",children:[(0,F.jsxs)(na,{children:[(0,F.jsx)(nc,{children:"Delete Server"}),(0,F.jsxs)(nd,{children:["Are you sure you want to delete"," ",(0,F.jsx)("span",{className:"font-semibold",children:v?.name}),"? This will also remove it from any projects that reference it."]})]}),(0,F.jsxs)(nl,{children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>x(null),children:"Cancel"}),(0,F.jsxs)($.Button,{variant:"destructive",onClick:O,disabled:_,children:[_&&(0,F.jsx)(iD,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Delete"]})]})]})})]})}function oW(e){let r=W.useRef({value:e,previous:e});return W.useMemo(()=>(r.current.value!==e&&(r.current.previous=r.current.value,r.current.value=e),r.current.previous),[e])}var oH=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),o$=W.forwardRef((e,r)=>(0,F.jsx)(Z.span,{...e,ref:r,style:{...oH,...e.style}}));o$.displayName="VisuallyHidden";var oK=[" ","Enter","ArrowUp","ArrowDown"],oU=[" ","Enter"],oq="Select",[oV,oY,oX]=ee(oq),[oG,oJ]=q(oq,[oX,tK]),oZ=tK(),[oQ,o0]=oG(oq),[o1,o2]=oG(oq),o5=e=>{let{__scopeSelect:r,children:s,open:i,defaultOpen:n,onOpenChange:o,value:a,defaultValue:l,onValueChange:c,dir:d,name:h,autoComplete:u,disabled:f,required:p,form:m}=e,g=oZ(r),[v,x]=W.useState(null),[_,y]=W.useState(null),[b,w]=W.useState(!1),S=en(d),[C,k]=X({prop:i,defaultProp:n??!1,onChange:o,caller:oq}),[j,N]=X({prop:a,defaultProp:l,onChange:c,caller:oq}),E=W.useRef(null),R=!v||m||!!v.closest("form"),[M,D]=W.useState(new Set),T=Array.from(M).map(e=>e.props.value).join(";");return(0,F.jsx)(tV,{...g,children:(0,F.jsxs)(oQ,{required:p,scope:r,trigger:v,onTriggerChange:x,valueNode:_,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:w,contentId:ej(),value:j,onValueChange:N,open:C,onOpenChange:k,dir:S,triggerPointerDownPosRef:E,disabled:f,children:[(0,F.jsx)(oV.Provider,{scope:r,children:(0,F.jsx)(o1,{scope:e.__scopeSelect,onNativeOptionAdd:W.useCallback(e=>{D(r=>new Set(r).add(e))},[]),onNativeOptionRemove:W.useCallback(e=>{D(r=>{let s=new Set(r);return s.delete(e),s})},[]),children:s})}),R?(0,F.jsxs)(aM,{"aria-hidden":!0,required:p,tabIndex:-1,name:h,autoComplete:u,value:j,onChange:e=>N(e.target.value),disabled:f,form:m,children:[void 0===j?(0,F.jsx)("option",{value:""}):null,Array.from(M)]},T):null]})})};o5.displayName=oq;var o3="SelectTrigger",o4=W.forwardRef((e,r)=>{let{__scopeSelect:s,disabled:i=!1,...n}=e,o=oZ(s),a=o0(o3,s),l=a.disabled||i,c=(0,U.useComposedRefs)(r,a.onTriggerChange),d=oY(s),h=W.useRef("touch"),[u,f,p]=aT(e=>{let r=d().filter(e=>!e.disabled),s=r.find(e=>e.value===a.value),i=aP(r,e,s);void 0!==i&&a.onValueChange(i.value)}),m=e=>{l||(a.onOpenChange(!0),p()),e&&(a.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,F.jsx)(tX,{asChild:!0,...o,children:(0,F.jsx)(Z.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":aD(a.value)?"":void 0,...n,ref:c,onClick:K(n.onClick,e=>{e.currentTarget.focus(),"mouse"!==h.current&&m(e)}),onPointerDown:K(n.onPointerDown,e=>{h.current=e.pointerType;let r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(m(e),e.preventDefault())}),onKeyDown:K(n.onKeyDown,e=>{let r=""!==u.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||f(e.key),(!r||" "!==e.key)&&oK.includes(e.key)&&(m(),e.preventDefault())})})})});o4.displayName=o3;var o6="SelectValue",o8=W.forwardRef((e,r)=>{let{__scopeSelect:s,className:i,style:n,children:o,placeholder:a="",...l}=e,c=o0(o6,s),{onValueNodeHasChildrenChange:d}=c,h=void 0!==o,u=(0,U.useComposedRefs)(r,c.onValueNodeChange);return V(()=>{d(h)},[d,h]),(0,F.jsx)(Z.span,{...l,ref:u,style:{pointerEvents:"none"},children:aD(c.value)?(0,F.jsx)(F.Fragment,{children:a}):o})});o8.displayName=o6;var o7=W.forwardRef((e,r)=>{let{__scopeSelect:s,children:i,...n}=e;return(0,F.jsx)(Z.span,{"aria-hidden":!0,...n,ref:r,children:i||"▼"})});o7.displayName="SelectIcon";var o9=e=>(0,F.jsx)(t6,{asChild:!0,...e});o9.displayName="SelectPortal";var ae="SelectContent",at=W.forwardRef((e,r)=>{let s=o0(ae,e.__scopeSelect),[i,n]=W.useState();return(V(()=>{n(new DocumentFragment)},[]),s.open)?(0,F.jsx)(an,{...e,ref:r}):i?G.createPortal((0,F.jsx)(ar,{scope:e.__scopeSelect,children:(0,F.jsx)(oV.Slot,{scope:e.__scopeSelect,children:(0,F.jsx)("div",{children:e.children})})}),i):null});at.displayName=ae;var[ar,as]=oG(ae),ai=(0,J.createSlot)("SelectContent.RemoveScroll"),an=W.forwardRef((e,r)=>{let{__scopeSelect:s,position:i="item-aligned",onCloseAutoFocus:n,onEscapeKeyDown:o,onPointerDownOutside:a,side:l,sideOffset:c,align:d,alignOffset:h,arrowPadding:u,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:v,...x}=e,_=o0(ae,s),[y,b]=W.useState(null),[w,S]=W.useState(null),C=(0,U.useComposedRefs)(r,e=>b(e)),[k,j]=W.useState(null),[N,E]=W.useState(null),R=oY(s),[M,D]=W.useState(!1),T=W.useRef(!1);W.useEffect(()=>{if(y)return rb(y)},[y]),ef();let P=W.useCallback(e=>{let[r,...s]=R().map(e=>e.ref.current),[i]=s.slice(-1),n=document.activeElement;for(let s of e)if(s===n||(s?.scrollIntoView({block:"nearest"}),s===r&&w&&(w.scrollTop=0),s===i&&w&&(w.scrollTop=w.scrollHeight),s?.focus(),document.activeElement!==n))return},[R,w]),L=W.useCallback(()=>P([k,y]),[P,k,y]);W.useEffect(()=>{M&&L()},[M,L]);let{onOpenChange:B,triggerPointerDownPosRef:A}=_;W.useEffect(()=>{if(y){let e={x:0,y:0},r=r=>{e={x:Math.abs(Math.round(r.pageX)-(A.current?.x??0)),y:Math.abs(Math.round(r.pageY)-(A.current?.y??0))}},s=s=>{e.x<=10&&e.y<=10?s.preventDefault():y.contains(s.target)||B(!1),document.removeEventListener("pointermove",r),A.current=null};return null!==A.current&&(document.addEventListener("pointermove",r),document.addEventListener("pointerup",s,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",s,{capture:!0})}}},[y,B,A]),W.useEffect(()=>{let e=()=>B(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[B]);let[O,I]=aT(e=>{let r=R().filter(e=>!e.disabled),s=r.find(e=>e.ref.current===document.activeElement),i=aP(r,e,s);i&&setTimeout(()=>i.ref.current.focus())}),z=W.useCallback((e,r,s)=>{let i=!T.current&&!s;(void 0!==_.value&&_.value===r||i)&&(j(e),i&&(T.current=!0))},[_.value]),H=W.useCallback(()=>y?.focus(),[y]),$=W.useCallback((e,r,s)=>{let i=!T.current&&!s;(void 0!==_.value&&_.value===r||i)&&E(e)},[_.value]),q="popper"===i?aa:ao,V=q===aa?{side:l,sideOffset:c,align:d,alignOffset:h,arrowPadding:u,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:v}:{};return(0,F.jsx)(ar,{scope:s,content:y,viewport:w,onViewportChange:S,itemRefCallback:z,selectedItem:k,onItemLeave:H,itemTextRefCallback:$,focusSelectedItem:L,selectedItemText:N,position:i,isPositioned:M,searchRef:O,children:(0,F.jsx)(r6,{as:ai,allowPinchZoom:!0,children:(0,F.jsx)(ex,{asChild:!0,trapped:_.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:K(n,e=>{_.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,F.jsx)(ec,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:(0,F.jsx)(q,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:e=>e.preventDefault(),...x,...V,onPlaced:()=>D(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:K(x.onKeyDown,e=>{let r=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),r||1!==e.key.length||I(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let r=R().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(r=r.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){let s=e.target,i=r.indexOf(s);r=r.slice(i+1)}setTimeout(()=>P(r)),e.preventDefault()}})})})})})})});an.displayName="SelectContentImpl";var ao=W.forwardRef((e,r)=>{let{__scopeSelect:s,onPlaced:i,...n}=e,o=o0(ae,s),a=as(ae,s),[l,c]=W.useState(null),[d,h]=W.useState(null),u=(0,U.useComposedRefs)(r,e=>h(e)),f=oY(s),p=W.useRef(!1),m=W.useRef(!0),{viewport:g,selectedItem:v,selectedItemText:x,focusSelectedItem:_}=a,y=W.useCallback(()=>{if(o.trigger&&o.valueNode&&l&&d&&g&&v&&x){let e=o.trigger.getBoundingClientRect(),r=d.getBoundingClientRect(),s=o.valueNode.getBoundingClientRect(),n=x.getBoundingClientRect();if("rtl"!==o.dir){let i=n.left-r.left,o=s.left-i,a=e.left-o,c=e.width+a,d=Math.max(c,r.width),h=nz(o,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.left=h+"px"}else{let i=r.right-n.right,o=window.innerWidth-s.right-i,a=window.innerWidth-e.right-o,c=e.width+a,d=Math.max(c,r.width),h=nz(o,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.right=h+"px"}let a=f(),c=window.innerHeight-20,h=g.scrollHeight,u=window.getComputedStyle(d),m=parseInt(u.borderTopWidth,10),_=parseInt(u.paddingTop,10),y=parseInt(u.borderBottomWidth,10),b=m+_+h+parseInt(u.paddingBottom,10)+y,w=Math.min(5*v.offsetHeight,b),S=window.getComputedStyle(g),C=parseInt(S.paddingTop,10),k=parseInt(S.paddingBottom,10),j=e.top+e.height/2-10,N=v.offsetHeight/2,E=m+_+(v.offsetTop+N);if(E<=j){let e=a.length>0&&v===a[a.length-1].ref.current;l.style.bottom="0px";let r=Math.max(c-j,N+(e?k:0)+(d.clientHeight-g.offsetTop-g.offsetHeight)+y);l.style.height=E+r+"px"}else{let e=a.length>0&&v===a[0].ref.current;l.style.top="0px";let r=Math.max(j,m+g.offsetTop+(e?C:0)+N);l.style.height=r+(b-E)+"px",g.scrollTop=E-j+g.offsetTop}l.style.margin="10px 0",l.style.minHeight=w+"px",l.style.maxHeight=c+"px",i?.(),requestAnimationFrame(()=>p.current=!0)}},[f,o.trigger,o.valueNode,l,d,g,v,x,o.dir,i]);V(()=>y(),[y]);let[b,w]=W.useState();V(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let S=W.useCallback(e=>{e&&!0===m.current&&(y(),_?.(),m.current=!1)},[y,_]);return(0,F.jsx)(al,{scope:s,contentWrapper:l,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:(0,F.jsx)("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:b},children:(0,F.jsx)(Z.div,{...n,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...n.style}})})})});ao.displayName="SelectItemAlignedPosition";var aa=W.forwardRef((e,r)=>{let{__scopeSelect:s,align:i="start",collisionPadding:n=10,...o}=e,a=oZ(s);return(0,F.jsx)(tQ,{...a,...o,ref:r,align:i,collisionPadding:n,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});aa.displayName="SelectPopperPosition";var[al,ac]=oG(ae,{}),ad="SelectViewport",ah=W.forwardRef((e,r)=>{let{__scopeSelect:s,nonce:i,...n}=e,o=as(ad,s),a=ac(ad,s),l=(0,U.useComposedRefs)(r,o.onViewportChange),c=W.useRef(0);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),(0,F.jsx)(oV.Slot,{scope:s,children:(0,F.jsx)(Z.div,{"data-radix-select-viewport":"",role:"presentation",...n,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...n.style},onScroll:K(n.onScroll,e=>{let r=e.currentTarget,{contentWrapper:s,shouldExpandOnScrollRef:i}=a;if(i?.current&&s){let e=Math.abs(c.current-r.scrollTop);if(e>0){let i=window.innerHeight-20,n=Math.max(parseFloat(s.style.minHeight),parseFloat(s.style.height));if(n<i){let o=n+e,a=Math.min(i,o),l=o-a;s.style.height=a+"px","0px"===s.style.bottom&&(r.scrollTop=l>0?l:0,s.style.justifyContent="flex-end")}}}c.current=r.scrollTop})})})]})});ah.displayName=ad;var au="SelectGroup",[af,ap]=oG(au);W.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e,n=ej();return(0,F.jsx)(af,{scope:s,id:n,children:(0,F.jsx)(Z.div,{role:"group","aria-labelledby":n,...i,ref:r})})}).displayName=au;var am="SelectLabel";W.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e,n=ap(am,s);return(0,F.jsx)(Z.div,{id:n.id,...i,ref:r})}).displayName=am;var ag="SelectItem",[av,ax]=oG(ag),a_=W.forwardRef((e,r)=>{let{__scopeSelect:s,value:i,disabled:n=!1,textValue:o,...a}=e,l=o0(ag,s),c=as(ag,s),d=l.value===i,[h,u]=W.useState(o??""),[f,p]=W.useState(!1),m=(0,U.useComposedRefs)(r,e=>c.itemRefCallback?.(e,i,n)),g=ej(),v=W.useRef("touch"),x=()=>{n||(l.onValueChange(i),l.onOpenChange(!1))};if(""===i)throw Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return(0,F.jsx)(av,{scope:s,value:i,disabled:n,textId:g,isSelected:d,onItemTextChange:W.useCallback(e=>{u(r=>r||(e?.textContent??"").trim())},[]),children:(0,F.jsx)(oV.ItemSlot,{scope:s,value:i,disabled:n,textValue:h,children:(0,F.jsx)(Z.div,{role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":d&&f,"data-state":d?"checked":"unchecked","aria-disabled":n||void 0,"data-disabled":n?"":void 0,tabIndex:n?void 0:-1,...a,ref:m,onFocus:K(a.onFocus,()=>p(!0)),onBlur:K(a.onBlur,()=>p(!1)),onClick:K(a.onClick,()=>{"mouse"!==v.current&&x()}),onPointerUp:K(a.onPointerUp,()=>{"mouse"===v.current&&x()}),onPointerDown:K(a.onPointerDown,e=>{v.current=e.pointerType}),onPointerMove:K(a.onPointerMove,e=>{v.current=e.pointerType,n?c.onItemLeave?.():"mouse"===v.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:K(a.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:K(a.onKeyDown,e=>{(c.searchRef?.current===""||" "!==e.key)&&(oU.includes(e.key)&&x()," "===e.key&&e.preventDefault())})})})})});a_.displayName=ag;var ay="SelectItemText",ab=W.forwardRef((e,r)=>{let{__scopeSelect:s,className:i,style:n,...o}=e,a=o0(ay,s),l=as(ay,s),c=ax(ay,s),d=o2(ay,s),[h,u]=W.useState(null),f=(0,U.useComposedRefs)(r,e=>u(e),c.onItemTextChange,e=>l.itemTextRefCallback?.(e,c.value,c.disabled)),p=h?.textContent,m=W.useMemo(()=>(0,F.jsx)("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:v}=d;return V(()=>(g(m),()=>v(m)),[g,v,m]),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Z.span,{id:c.textId,...o,ref:f}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?G.createPortal(o.children,a.valueNode):null]})});ab.displayName=ay;var aw="SelectItemIndicator",aS=W.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e;return ax(aw,s).isSelected?(0,F.jsx)(Z.span,{"aria-hidden":!0,...i,ref:r}):null});aS.displayName=aw;var aC="SelectScrollUpButton",ak=W.forwardRef((e,r)=>{let s=as(aC,e.__scopeSelect),i=ac(aC,e.__scopeSelect),[n,o]=W.useState(!1),a=(0,U.useComposedRefs)(r,i.onScrollButtonChange);return V(()=>{if(s.viewport&&s.isPositioned){let e=function(){o(r.scrollTop>0)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),n?(0,F.jsx)(aE,{...e,ref:a,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop-r.offsetHeight)}}):null});ak.displayName=aC;var aj="SelectScrollDownButton",aN=W.forwardRef((e,r)=>{let s=as(aj,e.__scopeSelect),i=ac(aj,e.__scopeSelect),[n,o]=W.useState(!1),a=(0,U.useComposedRefs)(r,i.onScrollButtonChange);return V(()=>{if(s.viewport&&s.isPositioned){let e=function(){let e=r.scrollHeight-r.clientHeight;o(Math.ceil(r.scrollTop)<e)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),n?(0,F.jsx)(aE,{...e,ref:a,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop+r.offsetHeight)}}):null});aN.displayName=aj;var aE=W.forwardRef((e,r)=>{let{__scopeSelect:s,onAutoScroll:i,...n}=e,o=as("SelectScrollButton",s),a=W.useRef(null),l=oY(s),c=W.useCallback(()=>{null!==a.current&&(window.clearInterval(a.current),a.current=null)},[]);return W.useEffect(()=>()=>c(),[c]),V(()=>{let e=l().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[l]),(0,F.jsx)(Z.div,{"aria-hidden":!0,...n,ref:r,style:{flexShrink:0,...n.style},onPointerDown:K(n.onPointerDown,()=>{null===a.current&&(a.current=window.setInterval(i,50))}),onPointerMove:K(n.onPointerMove,()=>{o.onItemLeave?.(),null===a.current&&(a.current=window.setInterval(i,50))}),onPointerLeave:K(n.onPointerLeave,()=>{c()})})});W.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e;return(0,F.jsx)(Z.div,{"aria-hidden":!0,...i,ref:r})}).displayName="SelectSeparator";var aR="SelectArrow";W.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e,n=oZ(s),o=o0(aR,s),a=as(aR,s);return o.open&&"popper"===a.position?(0,F.jsx)(t2,{...n,...i,ref:r}):null}).displayName=aR;var aM=W.forwardRef(({__scopeSelect:e,value:r,...s},i)=>{let n=W.useRef(null),o=(0,U.useComposedRefs)(i,n),a=oW(r);return W.useEffect(()=>{let e=n.current;if(!e)return;let s=Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype,"value").set;if(a!==r&&s){let i=new Event("change",{bubbles:!0});s.call(e,r),e.dispatchEvent(i)}},[a,r]),(0,F.jsx)(Z.select,{...s,style:{...oH,...s.style},ref:o,defaultValue:r})});function aD(e){return""===e||void 0===e}function aT(e){let r=eo(e),s=W.useRef(""),i=W.useRef(0),n=W.useCallback(e=>{let n=s.current+e;r(n),function e(r){s.current=r,window.clearTimeout(i.current),""!==r&&(i.current=window.setTimeout(()=>e(""),1e3))}(n)},[r]),o=W.useCallback(()=>{s.current="",window.clearTimeout(i.current)},[]);return W.useEffect(()=>()=>window.clearTimeout(i.current),[]),[s,n,o]}function aP(e,r,s){var i,n;let o=r.length>1&&Array.from(r).every(e=>e===r[0])?r[0]:r,a=s?e.indexOf(s):-1,l=(i=e,n=Math.max(a,0),i.map((e,r)=>i[(n+r)%i.length]));1===o.length&&(l=l.filter(e=>e!==s));let c=l.find(e=>e.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==s?c:void 0}aM.displayName="SelectBubbleInput";var il=il;let aL=(0,ic.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);function aB({...e}){return(0,F.jsx)(o5,{"data-slot":"select",...e})}function aA({...e}){return(0,F.jsx)(o8,{"data-slot":"select-value",...e})}function aO({className:e,size:r="default",children:s,...i}){return(0,F.jsxs)(o4,{"data-slot":"select-trigger","data-size":r,className:(0,iu.cn)("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...i,children:[s,(0,F.jsx)(o7,{asChild:!0,children:(0,F.jsx)(aL,{className:"size-4 opacity-50"})})]})}function aI({className:e,children:r,position:s="item-aligned",align:i="center",...n}){return(0,F.jsx)(o9,{children:(0,F.jsxs)(at,{"data-slot":"select-content",className:(0,iu.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,align:i,...n,children:[(0,F.jsx)(aF,{}),(0,F.jsx)(ah,{className:(0,iu.cn)("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),(0,F.jsx)(aW,{})]})})}function az({className:e,children:r,...s}){return(0,F.jsxs)(a_,{"data-slot":"select-item",className:(0,iu.cn)("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...s,children:[(0,F.jsx)("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,F.jsx)(aS,{children:(0,F.jsx)(il.default,{className:"size-4"})})}),(0,F.jsx)(ab,{children:r})]})}function aF({className:e,...r}){return(0,F.jsx)(ak,{"data-slot":"select-scroll-up-button",className:(0,iu.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,F.jsx)(ou,{className:"size-4"})})}function aW({className:e,...r}){return(0,F.jsx)(aN,{"data-slot":"select-scroll-down-button",className:(0,iu.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,F.jsx)(aL,{className:"size-4"})})}function aH({projectId:e,project:r,open:s,onOpenChange:i,onWorktreeCreated:n}){let[o,a]=(0,W.useState)(""),[l,c]=(0,W.useState)(!1),[d,h]=(0,W.useState)(null),[u,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(!0),[g,v]=(0,W.useState)(!0),[x,_]=(0,W.useState)([]),[y,b]=(0,W.useState)([]),[w,S]=(0,W.useState)("main"),[C,k]=(0,W.useState)("main"),[j,N]=(0,W.useState)(!1),E=!!(r.path&&r.remote_path);(0,W.useEffect)(()=>{s&&(N(!0),E?Promise.all([iT.api.getProjectBranches(e,"local"),iT.api.getProjectBranches(e,"remote")]).then(([e,r])=>{_(e),b(r),S(e.includes("main")?"main":e[0]||"main"),k(r.includes("main")?"main":r[0]||"main"),N(!1)}):iT.api.getProjectBranches(e).then(e=>{_(e),S(e.includes("main")?"main":e[0]||"main"),N(!1)}))},[s,e,E]);let R=async()=>{if(o.trim()){c(!0),h(null),f(null);try{let r;E&&(r=[],p&&r.push("local"),g&&r.push("remote"));let s=await iT.api.createWorktree(e,o.trim(),r,w,E?C:void 0);if(s.partialSuccess){let e,r=s.results?.remote?.success===!1?"remote":"local",i=s.results?.[r],n=i?.error||"Unknown error",o=i?.errorCode,a=i?.requestId;switch(o){case"timeout":e="Connection to remote server timed out. The remote server may be slow or unreachable.";break;case"network_error":e="Cannot connect to remote server. Check that the server is running and the URL is correct.";break;case"auth_error":e="Authentication failed with remote server. Check the API key in project settings.";break;case"server_error":e=`Remote server returned an error: ${n}`;break;default:e=`Worktree created locally, but ${r} creation failed: ${n}`}a&&(e+=` (Request ID: ${a})`),f(e)}n(s.worktree.branch),s.partialSuccess||(i(!1),a(""))}catch(e){h(e instanceof Error?e.message:"Failed to create worktree")}finally{c(!1)}}},M=e=>{e||(a(""),h(null),f(null),m(!0),v(!0),_([]),b([]),S("main"),k("main")),i(e)},D=(e,r,s,i)=>(0,F.jsxs)(aB,{value:r,onValueChange:s,disabled:i||j,children:[(0,F.jsx)(aO,{size:"sm",children:(0,F.jsx)(aA,{placeholder:j?"Loading...":"Select branch"})}),(0,F.jsx)(aI,{children:e.map(e=>(0,F.jsx)(az,{value:e,children:e},e))})]});return(0,F.jsx)(ns,{open:s,onOpenChange:M,children:(0,F.jsxs)(no,{children:[(0,F.jsxs)(na,{children:[(0,F.jsx)(nc,{children:"Create New Worktree"}),(0,F.jsx)(nd,{children:"Create a new branch based on an existing branch"})]}),(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{htmlFor:"branch-name",className:"text-sm font-medium",children:"Branch Name"}),(0,F.jsx)(nh,{id:"branch-name",placeholder:"feature/my-feature",value:o,onChange:e=>a(e.target.value),disabled:l,onKeyDown:e=>{"Enter"===e.key&&o.trim()&&(!E||p||g)&&R()}})]}),E?(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Create On"}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,F.jsx)("input",{type:"checkbox",checked:p,onChange:e=>{(e.target.checked||g)&&m(e.target.checked)},disabled:l,className:"h-4 w-4 rounded border-input accent-primary"}),(0,F.jsx)("span",{children:"Local"}),(0,F.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:r.path})]}),p&&x.length>0&&(0,F.jsxs)("div",{className:"ml-6",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Base Branch"}),D(x,w,S,l)]}),(0,F.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,F.jsx)("input",{type:"checkbox",checked:g,onChange:e=>{(e.target.checked||p)&&v(e.target.checked)},disabled:l,className:"h-4 w-4 rounded border-input accent-primary"}),(0,F.jsx)("span",{children:"Remote"}),(0,F.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:r.remote_path})]}),g&&y.length>0&&(0,F.jsxs)("div",{className:"ml-6",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Base Branch"}),D(y,C,k,l)]})]})]}):x.length>0&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Base Branch"}),D(x,w,S,l)]}),u&&(0,F.jsx)("div",{className:"text-sm text-yellow-600 dark:text-yellow-500 bg-yellow-500/10 px-3 py-2 rounded-md",children:u}),d&&(0,F.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:d})]}),(0,F.jsxs)(nl,{children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>M(!1),disabled:l,children:"Cancel"}),(0,F.jsx)($.Button,{onClick:R,disabled:!o.trim()||l||E&&!p&&!g,children:l?"Creating...":"Create"})]})]})})}function a$({projectId:e,worktree:r,open:s,onOpenChange:i,onWorktreeDeleted:n}){let[o,a]=(0,W.useState)(!1),[l,c]=(0,W.useState)(null),[d,h]=(0,W.useState)(null),u=async()=>{if(r){a(!0),c(null),h(null);try{let s=await iT.api.deleteWorktree(e,r.branch);if(s.partialSuccess){let e=s.results?.remote?.error||"Unknown error";h(`Local worktree deleted, but remote deletion failed: ${e}`)}n(),s.partialSuccess||i(!1)}catch(e){c(e instanceof Error?e.message:"Failed to delete worktree")}finally{a(!1)}}},f=e=>{e||(c(null),h(null)),i(e)};return(0,F.jsx)(ns,{open:s,onOpenChange:f,children:(0,F.jsxs)(no,{children:[(0,F.jsxs)(na,{children:[(0,F.jsx)(nc,{children:"Delete Worktree"}),(0,F.jsx)(nd,{children:"Are you sure you want to delete this worktree?"})]}),r&&(0,F.jsx)("div",{className:"space-y-2",children:(0,F.jsxs)("div",{className:"text-sm",children:[(0,F.jsx)("span",{className:"font-medium",children:"Branch:"})," ",(0,F.jsx)("span",{className:"text-muted-foreground",children:r.branch})]})}),d&&(0,F.jsx)("div",{className:"text-sm text-yellow-600 dark:text-yellow-500 bg-yellow-500/10 px-3 py-2 rounded-md",children:d}),l&&(0,F.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:l}),(0,F.jsxs)(nl,{children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>f(!1),disabled:o,children:"Cancel"}),(0,F.jsx)($.Button,{variant:"destructive",onClick:u,disabled:o,children:o?"Deleting...":"Delete"})]})]})})}e.i(247755);var aK=e.i(642098),aU=e.i(423917);function aq(){let{config:e}=(0,aU.useAppConfig)();return e?.authEnabled?(0,F.jsx)("div",{className:"flex items-center",children:(0,F.jsx)(aK.UserButton,{appearance:{elements:{avatarBox:"h-7 w-7 ring-1 ring-border/60"}}})}):null}let aV=(0,ic.default)("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),aY=(0,ic.default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),aX=(0,ic.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);var aG="Collapsible",[aJ,aZ]=q(aG),[aQ,a0]=aJ(aG),a1=W.forwardRef((e,r)=>{let{__scopeCollapsible:s,open:i,defaultOpen:n,disabled:o,onOpenChange:a,...l}=e,[c,d]=X({prop:i,defaultProp:n??!1,onChange:a,caller:aG});return(0,F.jsx)(aQ,{scope:s,disabled:o,contentId:ej(),open:c,onOpenToggle:W.useCallback(()=>d(e=>!e),[d]),children:(0,F.jsx)(Z.div,{"data-state":a8(c),"data-disabled":o?"":void 0,...l,ref:r})})});a1.displayName=aG;var a2="CollapsibleTrigger",a5=W.forwardRef((e,r)=>{let{__scopeCollapsible:s,...i}=e,n=a0(a2,s);return(0,F.jsx)(Z.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":a8(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...i,ref:r,onClick:K(e.onClick,n.onOpenToggle)})});a5.displayName=a2;var a3="CollapsibleContent",a4=W.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=a0(a3,e.__scopeCollapsible);return(0,F.jsx)(t8,{present:s||n.open,children:({present:e})=>(0,F.jsx)(a6,{...i,ref:r,present:e})})});a4.displayName=a3;var a6=W.forwardRef((e,r)=>{let{__scopeCollapsible:s,present:i,children:n,...o}=e,a=a0(a3,s),[l,c]=W.useState(i),d=W.useRef(null),h=(0,U.useComposedRefs)(r,d),u=W.useRef(0),f=u.current,p=W.useRef(0),m=p.current,g=a.open||l,v=W.useRef(g),x=W.useRef(void 0);return W.useEffect(()=>{let e=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(e)},[]),V(()=>{let e=d.current;if(e){x.current=x.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let r=e.getBoundingClientRect();u.current=r.height,p.current=r.width,v.current||(e.style.transitionDuration=x.current.transitionDuration,e.style.animationName=x.current.animationName),c(i)}},[a.open,i]),(0,F.jsx)(Z.div,{"data-state":a8(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!g,...o,ref:h,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&n})});function a8(e){return e?"open":"closed"}function a7({...e}){return(0,F.jsx)(a1,{"data-slot":"collapsible",...e})}function a9({...e}){return(0,F.jsx)(a5,{"data-slot":"collapsible-trigger",...e})}function le({...e}){return(0,F.jsx)(a4,{"data-slot":"collapsible-content",...e})}var lt=Symbol.for("react.lazy"),lr=W[" use ".trim().toString()];function ls(e){var r;return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===lt&&"_payload"in e&&"object"==typeof(r=e._payload)&&null!==r&&"then"in r}function li(e){var r;let s,i=(r=e,(s=W.forwardRef((e,r)=>{let{children:s,...i}=e;if(ls(s)&&"function"==typeof lr&&(s=lr(s._payload)),W.isValidElement(s)){var n;let e,o,a=(n=s,(o=(e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?n.ref:(o=(e=Object.getOwnPropertyDescriptor(n,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?n.props.ref:n.props.ref||n.ref),l=function(e,r){let s={...r};for(let i in r){let n=e[i],o=r[i];/^on[A-Z]/.test(i)?n&&o?s[i]=(...e)=>{let r=o(...e);return n(...e),r}:n&&(s[i]=n):"style"===i?s[i]={...n,...o}:"className"===i&&(s[i]=[n,o].filter(Boolean).join(" "))}return{...e,...s}}(i,s.props);return s.type!==W.Fragment&&(l.ref=r?(0,U.composeRefs)(r,a):a),W.cloneElement(s,l)}return W.Children.count(s)>1?W.Children.only(null):null})).displayName=`${r}.SlotClone`,s),n=W.forwardRef((e,r)=>{let{children:s,...n}=e;ls(s)&&"function"==typeof lr&&(s=lr(s._payload));let o=W.Children.toArray(s),a=o.find(la);if(a){let e=a.props.children,s=o.map(r=>r!==a?r:W.Children.count(e)>1?W.Children.only(null):W.isValidElement(e)?e.props.children:null);return(0,F.jsx)(i,{...n,ref:r,children:W.isValidElement(e)?W.cloneElement(e,void 0,s):null})}return(0,F.jsx)(i,{...n,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var ln=li("Slot"),lo=Symbol("radix.slottable");function la(e){return W.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===lo}var ll=e.i(294237);let lc=(0,ll.cva)("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function ld({className:e,variant:r,asChild:s=!1,...i}){return(0,F.jsx)(s?ln:"span",{"data-slot":"badge",className:(0,iu.cn)(lc({variant:r}),e),...i})}let lh=(0,ic.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),lu=(0,ic.default)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);var lf=e.i(885101),lp=Object.defineProperty,lm=Object.getOwnPropertyDescriptor,lg=(e,r,s,i)=>{for(var n,o=i>1?void 0:i?lm(r,s):r,a=e.length-1;a>=0;a--)(n=e[a])&&(o=(i?n(r,s,o):n(o))||o);return i&&o&&lp(r,s,o),o},lv=(e,r)=>(s,i)=>r(s,i,e),lx="Terminal input",l_="Too much output to announce, navigate to rows manually to read";function ly(e,r,s,i){var n;n=e=e.replace(/\r?\n/g,"\r"),e=s.decPrivateModes.bracketedPasteMode&&!0!==i.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+n+"\x1b[201~":n,s.triggerDataEvent(e,!0),r.value=""}function lb(e,r,s){let i=s.getBoundingClientRect(),n=e.clientX-i.left-10,o=e.clientY-i.top-10;r.style.width="20px",r.style.height="20px",r.style.left=`${n}px`,r.style.top=`${o}px`,r.style.zIndex="1000",r.focus()}function lw(e,r,s,i,n){lb(e,r,s),n&&i.rightClickSelect(e),r.value=i.selectionText,r.select()}function lS(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function lC(e,r=0,s=e.length){let i="";for(let n=r;n<s;++n){let r=e[n];r>65535?(r-=65536,i+=String.fromCharCode((r>>10)+55296)+String.fromCharCode(r%1024+56320)):i+=String.fromCharCode(r)}return i}var lk=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,r){let s=e.length;if(!s)return 0;let i=0,n=0;if(this._interim){let s=e.charCodeAt(n++);56320<=s&&s<=57343?r[i++]=(this._interim-55296)*1024+s-56320+65536:(r[i++]=this._interim,r[i++]=s),this._interim=0}for(let o=n;o<s;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=s)return this._interim=n,i;let a=e.charCodeAt(o);56320<=a&&a<=57343?r[i++]=(n-55296)*1024+a-56320+65536:(r[i++]=n,r[i++]=a);continue}65279!==n&&(r[i++]=n)}return i}},lj=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,r){let s=e.length;if(!s)return 0;let i=0,n,o,a,l,c=0,d=0;if(this.interim[0]){let n=!1,o=this.interim[0];o&=(224&o)==192?31:(240&o)==224?15:7;let a=0,l;for(;(l=63&this.interim[++a])&&a<4;)o<<=6,o|=l;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,h=c-a;for(;d<h;){if(d>=s)return 0;if((192&(l=e[d++]))!=128){d--,n=!0;break}this.interim[a++]=l,o<<=6,o|=63&l}n||(2===c?o<128?d--:r[i++]=o:3===c?o<2048||o>=55296&&o<=57343||65279===o||(r[i++]=o):o<65536||o>1114111||(r[i++]=o)),this.interim.fill(0)}let h=s-4,u=d;for(;u<s;){for(;u<h&&!(128&(n=e[u]))&&!(128&(o=e[u+1]))&&!(128&(a=e[u+2]))&&!(128&(l=e[u+3]));)r[i++]=n,r[i++]=o,r[i++]=a,r[i++]=l,u+=4;if((n=e[u++])<128)r[i++]=n;else if((224&n)==192){if(u>=s)return this.interim[0]=n,i;if((192&(o=e[u++]))!=128||(c=(31&n)<<6|63&o)<128){u--;continue}r[i++]=c}else if((240&n)==224){if(u>=s)return this.interim[0]=n,i;if((192&(o=e[u++]))!=128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,i;if((192&(a=e[u++]))!=128){u--;continue}if((c=(15&n)<<12|(63&o)<<6|63&a)<2048||c>=55296&&c<=57343||65279===c)continue;r[i++]=c}else if((248&n)==240){if(u>=s)return this.interim[0]=n,i;if((192&(o=e[u++]))!=128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,i;if((192&(a=e[u++]))!=128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,i;if((192&(l=e[u++]))!=128){u--;continue}if((c=(7&n)<<18|(63&o)<<12|(63&a)<<6|63&l)<65536||c>1114111)continue;r[i++]=c}}return i}},lN=class e{constructor(){this.fg=0,this.bg=0,this.extended=new lE}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let r=new e;return r.fg=this.fg,r.bg=this.bg,r.extended=this.extended.clone(),r}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},lE=class e{constructor(e=0,r=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=r}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},lR=class e extends lN{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new lE,this.combinedData=""}static fromCharData(r){let s=new e;return s.setFromCharData(r),s}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?lS(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let r=!1;if(e[1].length>2)r=!0;else if(2===e[1].length){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let i=e[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(s-55296)*1024+i-56320+65536|e[2]<<22:r=!0}else r=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;r&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},lM="di$target",lD="di$dependencies",lT=new Map;function lP(e){if(lT.has(e))return lT.get(e);let r=function(e,s,i){var n,o,a;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");n=r,o=e,a=i,o[lM]===o?o[lD].push({id:n,index:a}):(o[lD]=[{id:n,index:a}],o[lM]=o)};return r._id=e,lT.set(e,r),r}var lL=lP("BufferService"),lB=lP("CoreMouseService"),lA=lP("CoreService"),lO=lP("CharsetService"),lI=lP("InstantiationService"),lz=lP("LogService"),lF=lP("OptionsService"),lW=lP("OscLinkService"),lH=lP("UnicodeService"),l$=lP("DecorationService"),lK=class{constructor(e,r,s){this._bufferService=e,this._optionsService=r,this._oscLinkService=s}provideLinks(e,r){let s=this._bufferService.buffer.lines.get(e-1);if(!s)return void r(void 0);let i=[],n=this._optionsService.rawOptions.linkHandler,o=new lR,a=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let r=0;r<a;r++)if(!(-1===c&&!s.hasContent(r))){if(s.loadCell(r,o),o.hasExtendedAttrs()&&o.extended.urlId)if(-1===c){c=r,l=o.extended.urlId;continue}else d=o.extended.urlId!==l;else -1!==c&&(d=!0);if(d||-1!==c&&r===a-1){let s=this._oscLinkService.getLinkData(l)?.uri;if(s){let o={start:{x:c+1,y:e},end:{x:r+ +(!d&&r===a-1),y:e}},l=!1;if(!n?.allowNonHttpProtocols)try{let e=new URL(s);["http:","https:"].includes(e.protocol)||(l=!0)}catch{l=!0}l||i.push({text:s,range:o,activate:(e,r)=>n?n.activate(e,r,o):function(e,r){if(confirm(`Do you want to navigate to ${r}?
6
+
7
+ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}}(0,r),hover:(e,r)=>n?.hover?.(e,r,o),leave:(e,r)=>n?.leave?.(e,r,o)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=r,l=o.extended.urlId):(c=-1,l=-1)}}r(i)}};lK=lg([lv(0,lL),lv(1,lF),lv(2,lW)],lK);var lU=lP("CharSizeService"),lq=lP("CoreBrowserService"),lV=lP("MouseService"),lY=lP("RenderService"),lX=lP("SelectionService"),lG=lP("CharacterJoinerService"),lJ=lP("ThemeService"),lZ=lP("LinkProviderService"),lQ=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?l5.isErrorNoTelemetry(e)?new l5(e.message+`
8
+
9
+ `+e.stack):Error(e.message+`
10
+
11
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(r=>{r(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function l0(e){var r;(r=e)instanceof l2||r instanceof Error&&r.name===l1&&r.message===l1||lQ.onUnexpectedError(e)}var l1="Canceled",l2=class extends Error{constructor(){super(l1),this.name=this.message}},l5=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(r){if(r instanceof e)return r;let s=new e;return s.message=r.message,s.stack=r.stack,s}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}},l3=class e extends Error{constructor(r){super(r||"An unexpected bug occurred."),Object.setPrototypeOf(this,e.prototype)}};function l4(e,r=0){return e[e.length-(1+r)]}(c_=cw||={}).isLessThan=function(e){return e<0},c_.isLessThanOrEqual=function(e){return e<=0},c_.isGreaterThan=function(e){return e>0},c_.isNeitherLessOrGreaterThan=function(e){return 0===e},c_.greaterThan=1,c_.lessThan=-1,c_.neitherLessOrGreaterThan=0;var l6=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(r=>(e(r),!0))}toArray(){let e=[];return this.iterate(r=>(e.push(r),!0)),e}filter(r){return new e(e=>this.iterate(s=>!r(s)||e(s)))}map(r){return new e(e=>this.iterate(s=>e(r(s))))}some(e){let r=!1;return this.iterate(s=>!(r=e(s))),r}findFirst(e){let r;return this.iterate(s=>!e(s)||(r=s,!1)),r}findLast(e){let r;return this.iterate(s=>(e(s)&&(r=s),!0)),r}findLastMaxBy(e){let r,s=!0;return this.iterate(i=>((s||cw.isGreaterThan(e(i,r)))&&(s=!1,r=i),!0)),r}};l6.empty=new l6(e=>{});function l8(e){}function l7(e,r){}function l9(e){if(cS.is(e)){let r=[];for(let s of e)if(s)try{s.dispose()}catch(e){r.push(e)}if(1===r.length)throw r[0];if(r.length>1)throw AggregateError(r,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function ce(e){let r={dispose:function(e,r){let s=this,i=!1,n;return function(){if(i)return n;if(i=!0,r)try{n=e.apply(s,arguments)}finally{r()}else n=e.apply(s,arguments);return n}}(()=>{l8(r),e()})};return r}(e=>{function r(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=r;let s=Object.freeze([]);function*i(e){yield e}e.empty=function(){return s},e.single=i,e.wrap=function(e){return r(e)?e:i(e)},e.from=function(e){return e||s},e.reverse=function*(e){for(let r=e.length-1;r>=0;r--)yield e[r]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,r){let s=0;for(let i of e)if(r(i,s++))return!0;return!1},e.find=function(e,r){for(let s of e)if(r(s))return s},e.filter=function*(e,r){for(let s of e)r(s)&&(yield s)},e.map=function*(e,r){let s=0;for(let i of e)yield r(i,s++)},e.flatMap=function*(e,r){let s=0;for(let i of e)yield*r(i,s++)},e.concat=function*(...e){for(let r of e)yield*r},e.reduce=function(e,r,s){let i=s;for(let s of e)i=r(i,s);return i},e.slice=function*(e,r,s=e.length){for(r<0&&(r+=e.length),s<0?s+=e.length:s>e.length&&(s=e.length);r<s;r++)yield e[r]},e.consume=function(r,s=1/0){let i=[];if(0===s)return[i,r];let n=r[Symbol.iterator]();for(let r=0;r<s;r++){let r=n.next();if(r.done)return[i,e.empty()];i.push(r.value)}return[i,{[Symbol.iterator]:()=>n}]},e.asyncToArray=async function(e){let r=[];for await(let s of e)r.push(s);return Promise.resolve(r)}})(cS||={});var ct=class e{constructor(){var e;this._toDispose=new Set,this._isDisposed=!1,e=this}dispose(){this._isDisposed||(l8(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{l9(this._toDispose)}finally{this._toDispose.clear()}}add(r){if(!r)return r;if(r===this)throw Error("Cannot register a disposable on itself!");return l7(r,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(r),r}delete(e){if(e){if(e===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),l7(e,null))}};ct.DISABLE_DISPOSED_WARNING=!1;var cr=ct,cs=class{constructor(){var e;this._store=new cr,e=this,l7(this._store,this)}dispose(){l8(this),this._store.dispose()}_register(e){if(e===this)throw Error("Cannot register a disposable on itself!");return this._store.add(e)}};cs.None=Object.freeze({dispose(){}});var ci=class{constructor(){var e;this._isDisposed=!1,e=this}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&l7(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,l8(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&l7(e,null),e}},cn="object"==typeof window?window:globalThis,co=class e{constructor(r){this.element=r,this.next=e.Undefined,this.prev=e.Undefined}};co.Undefined=new co(void 0);var ca=class{constructor(){this._first=co.Undefined,this._last=co.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===co.Undefined}clear(){let e=this._first;for(;e!==co.Undefined;){let r=e.next;e.prev=co.Undefined,e.next=co.Undefined,e=r}this._first=co.Undefined,this._last=co.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,r){let s=new co(e);if(this._first===co.Undefined)this._first=s,this._last=s;else if(r){let e=this._last;this._last=s,s.prev=e,e.next=s}else{let e=this._first;this._first=s,s.next=e,e.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==co.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==co.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==co.Undefined&&e.next!==co.Undefined){let r=e.prev;r.next=e.next,e.next.prev=r}else e.prev===co.Undefined&&e.next===co.Undefined?(this._first=co.Undefined,this._last=co.Undefined):e.next===co.Undefined?(this._last=this._last.prev,this._last.next=co.Undefined):e.prev===co.Undefined&&(this._first=this._first.next,this._first.prev=co.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==co.Undefined;)yield e.element,e=e.next}},cl=globalThis.performance&&"function"==typeof globalThis.performance.now,cc=class e{static create(r){return new e(r)}constructor(e){this._now=cl&&!1===e?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return -1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function r(e){}function s(e){return(r,s=null,i)=>{let n=!1,o;return o=e(e=>{if(!n)return o?o.dispose():n=!0,r.call(s,e)},null,i),n&&o.dispose(),o}}function i(e,r,s){return o((s,i=null,n)=>e(e=>s.call(i,r(e)),null,n),s)}function n(e,r,s){return o((s,i=null,n)=>e(e=>r(e)&&s.call(i,e),null,n),s)}function o(e,s){let i,n={onWillAddFirstListener(){i=e(o.fire,o)},onDidRemoveLastListener(){i?.dispose()}};s||r(n);let o=new cD(n);return s?.add(o),o.event}function a(e,s,i=100,n=!1,o=!1,l,c){let d,h,u,f=0,p,m={leakWarningThreshold:l,onWillAddFirstListener(){d=e(e=>{f++,h=s(h,e),n&&!u&&(g.fire(h),h=void 0),p=()=>{let e=h;h=void 0,u=void 0,(!n||f>1)&&g.fire(e),f=0},"number"==typeof i?(clearTimeout(u),u=setTimeout(p,i)):void 0===u&&(u=0,queueMicrotask(p))})},onWillRemoveListener(){o&&f>0&&p?.()},onDidRemoveLastListener(){p=void 0,d.dispose()}};c||r(m);let g=new cD(m);return c?.add(g),g.event}e.None=()=>cs.None,e.defer=function(e,r){return a(e,()=>{},0,void 0,!0,void 0,r)},e.once=s,e.map=i,e.forEach=function(e,r,s){return o((s,i=null,n)=>e(e=>{r(e),s.call(i,e)},null,n),s)},e.filter=n,e.signal=function(e){return e},e.any=function(...e){return(r,s=null,i)=>{var n,o;return n=function(...e){var r,s;let i=ce(()=>l9(e));return r=0,s=0,i}(...e.map(e=>e(e=>r.call(s,e)))),(o=i)instanceof Array?o.push(n):o&&o.add(n),n}},e.reduce=function(e,r,s,n){let o=s;return i(e,e=>o=r(o,e),n)},e.debounce=a,e.accumulate=function(r,s=0,i){return e.debounce(r,(e,r)=>e?(e.push(r),e):[r],s,void 0,!0,void 0,i)},e.latch=function(e,r=(e,r)=>e===r,s){let i=!0,o;return n(e,e=>{let s=i||!r(e,o);return i=!1,o=e,s},s)},e.split=function(r,s,i){return[e.filter(r,s,i),e.filter(r,e=>!s(e),i)]},e.buffer=function(e,r=!1,s=[],i){let n=s.slice(),o=e(e=>{n?n.push(e):l.fire(e)});i&&i.add(o);let a=()=>{n?.forEach(e=>l.fire(e)),n=null},l=new cD({onWillAddFirstListener(){o||(o=e(e=>l.fire(e)),i&&i.add(o))},onDidAddFirstListener(){n&&(r?setTimeout(a):a())},onDidRemoveLastListener(){o&&o.dispose(),o=null}});return i&&i.add(l),l.event},e.chain=function(e,r){return(s,i,n)=>{let o=r(new c);return e(function(e){let r=o.evaluate(e);r!==l&&s.call(i,r)},void 0,n)}};let l=Symbol("HaltChainable");class c{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(r=>(e(r),r)),this}filter(e){return this.steps.push(r=>e(r)?r:l),this}reduce(e,r){let s=r;return this.steps.push(r=>s=e(s,r)),this}latch(e=(e,r)=>e===r){let r=!0,s;return this.steps.push(i=>{let n=r||!e(i,s);return r=!1,s=i,n?i:l}),this}evaluate(e){for(let r of this.steps)if((e=r(e))===l)break;return e}}e.fromNodeEventEmitter=function(e,r,s=e=>e){let i=(...e)=>n.fire(s(...e)),n=new cD({onWillAddFirstListener:()=>e.on(r,i),onDidRemoveLastListener:()=>e.removeListener(r,i)});return n.event},e.fromDOMEventEmitter=function(e,r,s=e=>e){let i=(...e)=>n.fire(s(...e)),n=new cD({onWillAddFirstListener:()=>e.addEventListener(r,i),onDidRemoveLastListener:()=>e.removeEventListener(r,i)});return n.event},e.toPromise=function(e){return new Promise(r=>s(e)(r))},e.fromPromise=function(e){let r=new cD;return e.then(e=>{r.fire(e)},()=>{r.fire(void 0)}).finally(()=>{r.dispose()}),r.event},e.forward=function(e,r){return e(e=>r.fire(e))},e.runAndSubscribe=function(e,r,s){return r(s),e(e=>r(e))};class d{constructor(e,s){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};s||r(i),this.emitter=new cD(i),s&&s.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,r){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,r){return new d(e,r).emitter.event},e.fromObservableLight=function(e){return(r,s,i)=>{let n=0,o=!1,a={beginUpdate(){n++},endUpdate(){0==--n&&(e.reportChanges(),o&&(o=!1,r.call(s)))},handlePossibleChange(){},handleChange(){o=!0}};e.addObserver(a),e.reportChanges();let l={dispose(){e.removeObserver(a)}};return i instanceof cr?i.add(l):Array.isArray(i)&&i.push(l),l}}})(cC||={});var cd=class e{constructor(r){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${r}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new cc,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};cd.all=new Set,cd._idPool=0;var ch=class e{constructor(r,s,i=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=r,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,r){let s=this.threshold;if(s<=0||r<s)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;let[e,i]=this.getMostFrequentStack(),n=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${i}):`;console.warn(n),console.warn(e);let o=new cN(n,e);this._errorHandler(o)}return()=>{let r=this._stacks.get(e.value)||0;this._stacks.set(e.value,r-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,r=0;for(let[s,i]of this._stacks)(!e||r<i)&&(e=[s,i],r=i);return e}};ch._idPool=1;var cu,cf,cp,cm,cg,cv,cx,c_,cy,cb,cw,cS,cC,ck,cj=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??"")}print(){console.warn(this.value.split(`
12
+ `).slice(2).join(`
13
+ `))}},cN=class extends Error{constructor(e,r){super(e),this.name="ListenerLeakError",this.stack=r}},cE=class extends Error{constructor(e,r){super(e),this.name="ListenerRefusalError",this.stack=r}},cR=0,cM=class{constructor(e){this.value=e,this.id=cR++}},cD=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new ch(e?.onListenerError??l0,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new cd(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,r,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let r=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new cE(`${e}. HINT: Stack shows most frequent listener (${r[1]}-times)`,r[0]);return(this._options?.onListenerError||l0)(s),cs.None}if(this._disposed)return cs.None;r&&(e=e.bind(r));let i=new cM(e),n;this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(i.stack=cj.create(),n=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof cM?(this._deliveryQueue??=new cT,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=ce(()=>{ck?.unregister(o),n?.(),this._removeListener(i)});if(s instanceof cr?s.add(o):Array.isArray(s)&&s.push(o),ck){let e=Error().stack.split(`
14
+ `).slice(2,3).join(`
15
+ `).trim(),r=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);ck.register(o,r?.[2]??e,o)}return o},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let r=this._listeners,s=r.indexOf(e);if(-1===s)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,r[s]=void 0;let i=this._deliveryQueue.current===this;if(2*this._size<=r.length){let e=0;for(let s=0;s<r.length;s++)r[s]?r[e++]=r[s]:i&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);r.length=e}}_deliver(e,r){if(!e)return;let s=this._options?.onListenerError||l0;try{e.value(r)}catch(e){s(e)}}_deliverQueue(e){let r=e.current._listeners;for(;e.i<e.end;)this._deliver(r[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof cM)this._deliver(this._listeners,e);else{let r=this._deliveryQueue;r.enqueue(this,e,this._listeners.length),this._deliverQueue(r)}this._perfMon?.stop()}hasListeners(){return this._size>0}},cT=class{constructor(){this.i=-1,this.end=0}enqueue(e,r,s){this.i=0,this.end=s,this.current=e,this.value=r}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},cP=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new cD,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new cD,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,r){if(this.getZoomLevel(r)===e)return;let s=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),e)}setFullscreen(e,r){if(this.isFullscreen(r)===e)return;let s=this.getWindowId(r);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};cP.INSTANCE=new cP,cP.INSTANCE.onDidChangeZoomLevel,cP.INSTANCE.onDidChangeFullscreen;var cL="object"==typeof navigator?navigator.userAgent:"",cB=cL.indexOf("Firefox")>=0,cA=cL.indexOf("AppleWebKit")>=0,cO=cL.indexOf("Chrome")>=0,cI=!cO&&cL.indexOf("Safari")>=0;cL.indexOf("Electron/"),cL.indexOf("Android");var cz=!1;if("function"==typeof cn.matchMedia){let e=cn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),r=cn.matchMedia("(display-mode: fullscreen)");cz=e.matches,cF=e,"string"==typeof cF&&(cF=cn.matchMedia(cF)),cF.addEventListener("change",({matches:e})=>{cz&&r.matches||(cz=e)})}var cF,cW,cH,c$=!1,cK=!1,cU=!1,cq=!1,cV=!1,cY="en",cX=globalThis;"u">typeof cX.vscode&&"u">typeof cX.vscode.process?cH=cX.vscode.process:"u">typeof lf.default&&"string"==typeof lf.default?.versions?.node&&(cH=lf.default);var cG="string"==typeof cH?.versions?.electron&&cH?.type==="renderer";if("object"==typeof cH){c$="win32"===cH.platform,cK="darwin"===cH.platform,(cU="linux"===cH.platform)&&cH.env.SNAP&&cH.env.SNAP_REVISION,cH.env.CI||cH.env.BUILD_ARTIFACTSTAGINGDIRECTORY,cY="en";let e=cH.env.VSCODE_NLS_CONFIG;if(e)try{let r=JSON.parse(e);r.userLocale,r.osLocale,cY=r.resolvedLanguage||"en",r.languagePack?.translationsConfigFile}catch{}cq=!0}else"object"!=typeof navigator||cG?console.error("Unable to resolve platform."):(c$=(cW=navigator.userAgent).indexOf("Windows")>=0,cK=cW.indexOf("Macintosh")>=0,(cW.indexOf("Macintosh")>=0||cW.indexOf("iPad")>=0||cW.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,cU=cW.indexOf("Linux")>=0,cW?.indexOf("Mobi"),cV=!0,cY=globalThis._VSCODE_NLS_LANGUAGE||"en",navigator.language.toLowerCase());var cJ=c$,cZ=cK,cQ=cU,c0=cq;cV&&"function"==typeof cX.importScripts&&cX.origin;var c1,c2=cW,c5=cY;(ds=c1||={}).value=function(){return c5},ds.isDefaultVariant=function(){return 2===c5.length?"en"===c5:c5.length>=3&&"e"===c5[0]&&"n"===c5[1]&&"-"===c5[2]},ds.isDefault=function(){return"en"===c5};var c3="function"==typeof cX.postMessage&&!cX.importScripts,c4=(()=>{if(c3){let e=[];cX.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.id===r.data.vscodeScheduleAsyncWork){e.splice(s,1),i.callback();return}}});let r=0;return s=>{let i=++r;e.push({id:i,callback:s}),cX.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})(),c6=!!(c2&&c2.indexOf("Chrome")>=0);c2&&c2.indexOf("Firefox"),!c6&&c2&&c2.indexOf("Safari"),c2&&c2.indexOf("Edg/"),c2&&c2.indexOf("Android");var c8="object"==typeof navigator?navigator:{};c0||document.queryCommandSupported&&document.queryCommandSupported("copy")||c8&&c8.clipboard&&c8.clipboard.writeText,c0||c8&&c8.clipboard&&c8.clipboard.readText,c0||cz||c8.keyboard,"ontouchstart"in cn||c8.maxTouchPoints,cn.PointerEvent&&("ontouchstart"in cn||navigator.maxTouchPoints);var c7=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,r){this._keyCodeToStr[e]=r,this._strToKeyCode[r.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},c9=new c7,de=new c7,dt=new c7,dr=Array(230);(di=dn||={}).toString=function(e){return c9.keyCodeToStr(e)},di.fromString=function(e){return c9.strToKeyCode(e)},di.toUserSettingsUS=function(e){return de.keyCodeToStr(e)},di.toUserSettingsGeneral=function(e){return dt.keyCodeToStr(e)},di.fromUserSettings=function(e){return de.strToKeyCode(e)||dt.strToKeyCode(e)},di.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return c9.keyCodeToStr(e)};var ds,di,dn,da,dl=class e{constructor(e,r,s,i,n){this.ctrlKey=e,this.shiftKey=r,this.altKey=s,this.metaKey=i,this.keyCode=n}equals(r){return r instanceof e&&this.ctrlKey===r.ctrlKey&&this.shiftKey===r.shiftKey&&this.altKey===r.altKey&&this.metaKey===r.metaKey&&this.keyCode===r.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",r=this.shiftKey?"1":"0",s=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${e}${r}${s}${i}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new dc([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},dc=class{constructor(e){if(0===e.length)throw function(e){return e?Error(`Illegal argument: ${e}`):Error("Illegal argument")}("chords");this.chords=e}getHashCode(){let e="";for(let r=0,s=this.chords.length;r<s;r++)0!==r&&(e+=";"),e+=this.chords[r].getHashCode();return e}equals(e){if(null===e||this.chords.length!==e.chords.length)return!1;for(let r=0;r<this.chords.length;r++)if(!this.chords[r].equals(e.chords[r]))return!1;return!0}},dd=cZ?256:2048,dh=cZ?2048:256,du=class{constructor(e){this._standardKeyboardEventBrand=!0,this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=function(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return dn.fromString(r)}let r=e.keyCode;if(3===r)return 7;if(cB)switch(r){case 59:return 85;case 60:if(cQ)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(cZ)return 57}else if(cA&&(cZ&&93===r||!cZ&&92===r))return 57;return dr[r]||0}(e),this.code=e.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode);let r=0;return this.ctrlKey&&(r|=dd),this.altKey&&(r|=512),this.shiftKey&&(r|=1024),this.metaKey&&(r|=dh),r|=e}_computeKeyCodeChord(){let e=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode),new dl(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},df=new WeakMap,dp=class{static getSameOriginWindowChain(e){let r=df.get(e);if(!r){r=[],df.set(e,r);let s=e,i;do(i=function(e){if(!e.parent||e.parent===e)return null;try{let r=e.location,s=e.parent.location;if("null"!==r.origin&&"null"!==s.origin&&r.origin!==s.origin)return null}catch{return null}return e.parent}(s))?r.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):r.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return r.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,r){if(!r||e===r)return{top:0,left:0};let s=0,i=0;for(let n of this.getSameOriginWindowChain(e)){let e=n.window.deref();if(s+=e?.scrollY??0,i+=e?.scrollX??0,e===r||!n.iframeElement)break;let o=n.iframeElement.getBoundingClientRect();s+=o.top,i+=o.left}return{top:s,left:i}}},dm=class{constructor(e,r){this.timestamp=Date.now(),this.browserEvent=r,this.leftButton=0===r.button,this.middleButton=1===r.button,this.rightButton=2===r.button,this.buttons=r.buttons,this.target=r.target,this.detail=r.detail||1,"dblclick"===r.type&&(this.detail=2),this.ctrlKey=r.ctrlKey,this.shiftKey=r.shiftKey,this.altKey=r.altKey,this.metaKey=r.metaKey,"number"==typeof r.pageX?(this.posx=r.pageX,this.posy=r.pageY):(this.posx=r.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=r.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=dp.getPositionOfChildWindowRelativeToAncestorWindow(e,r.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},dg=class{constructor(e,r=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=r;let i=!1;if(cO){let e=navigator.userAgent.match(/Chrome\/(\d+)/);i=(e?parseInt(e[1]):123)<=122}if(e){let r=e.view?.devicePixelRatio||1;"u">typeof e.wheelDeltaY?i?this.deltaY=e.wheelDeltaY/(120*r):this.deltaY=e.wheelDeltaY/120:"u">typeof e.VERTICAL_AXIS&&e.axis===e.VERTICAL_AXIS?this.deltaY=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?cB&&!cZ?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40),"u">typeof e.wheelDeltaX?cI&&cJ?this.deltaX=-(e.wheelDeltaX/120):i?this.deltaX=e.wheelDeltaX/(120*r):this.deltaX=e.wheelDeltaX/120:"u">typeof e.HORIZONTAL_AXIS&&e.axis===e.HORIZONTAL_AXIS?this.deltaX=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?cB&&!cZ?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40),0===this.deltaY&&0===this.deltaX&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*r):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},dv=Object.freeze(function(e,r){let s=setTimeout(e.bind(r),0);return{dispose(){clearTimeout(s)}}});(ha=da||={}).isCancellationToken=function(e){return e===ha.None||e===ha.Cancelled||e instanceof dx||!!e&&"object"==typeof e&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},ha.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:cC.None}),ha.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:dv});var dx=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?dv:(this._emitter||(this._emitter=new cD),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};Symbol("MicrotaskDelay");var d_=class{constructor(e,r){this._isDisposed=!1,this._token=-1,"function"==typeof e&&"number"==typeof r&&this.setIfNotSet(e,r)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,r){if(this._isDisposed)throw new l3("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},r)}setIfNotSet(e,r){if(this._isDisposed)throw new l3("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,e()},r))}},dy=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,r,s=globalThis){if(this.isDisposed)throw new l3("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},r);this.disposable=ce(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(hl=hc||={}).settled=async function(e){let r,s=await Promise.all(e.map(e=>e.then(e=>e,e=>{r||(r=e)})));if("u">typeof r)throw r;return s},hl.withAsyncBody=function(e){return new Promise(async(r,s)=>{try{await e(r,s)}catch(e){s(e)}})};var db=class e{static fromArray(r){return new e(e=>{e.emitMany(r)})}static fromPromise(r){return new e(async e=>{e.emitMany(await r)})}static fromPromises(r){return new e(async e=>{await Promise.all(r.map(async r=>e.emitOne(await r)))})}static merge(r){return new e(async e=>{await Promise.all(r.map(async r=>{for await(let s of r)e.emitOne(s)}))})}constructor(e,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new cD,queueMicrotask(async()=>{let r={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(r)),this.resolve()}catch(e){this.reject(e)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await cC.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(r,s){return new e(async e=>{for await(let i of r)e.emitOne(s(i))})}map(r){return e.map(this,r)}static filter(r,s){return new e(async e=>{for await(let i of r)s(i)&&e.emitOne(i)})}filter(r){return e.filter(this,r)}static coalesce(r){return e.filter(r,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let r=[];for await(let s of e)r.push(s);return r}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};db.EMPTY=db.fromArray([]);function dw(e,r){return(r<<5)-r+e|0}function dS(e,r){r=dw(149417,r);for(let s=0,i=e.length;s<i;s++)r=dw(e.charCodeAt(s),r);return r}new DataView(new ArrayBuffer(320));var{registerWindow:dC,getWindow:dk,getDocument:dj,getWindows:dN,getWindowsCount:dE,getWindowId:dR,getWindowById:dM,hasWindow:dD,onDidRegisterWindow:dT,onWillUnregisterWindow:dP,onDidUnregisterWindow:dL}=(n=new Map,o={window:cn,disposables:new cr},n.set(cn.vscodeWindowId,o),a=new cD,l=new cD,c=new cD,{onDidRegisterWindow:a.event,onWillUnregisterWindow:c.event,onDidUnregisterWindow:l.event,registerWindow(e){if(n.has(e.vscodeWindowId))return cs.None;let r=new cr,s={window:e,disposables:r.add(new cr)};return n.set(e.vscodeWindowId,s),r.add(ce(()=>{n.delete(e.vscodeWindowId),l.fire(e)})),r.add(dA(e,dW.BEFORE_UNLOAD,()=>{c.fire(e)})),a.fire(s),r},getWindows:()=>n.values(),getWindowsCount:()=>n.size,getWindowId:e=>e.vscodeWindowId,hasWindow:e=>n.has(e),getWindowById:function(e,r){return("number"==typeof e?n.get(e):void 0)??(r?o:void 0)},getWindow:e=>e?.ownerDocument?.defaultView?e.ownerDocument.defaultView.window:e?.view?e.view.window:cn,getDocument:e=>dk(e).document}),dB=class{constructor(e,r,s,i){this._node=e,this._type=r,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function dA(e,r,s,i){return new dB(e,r,s,i)}var dO=function(e,r,s,i){var n;let o=s;return"click"===r||"mousedown"===r||"contextmenu"===r?(n=dk(e),o=function(e){return s(new dm(n,e))}):("keydown"===r||"keypress"===r||"keyup"===r)&&(o=function(e){return s(new du(e))}),dA(e,r,o,i)},dI=class extends dy{constructor(e){super(),this.defaultTarget=e&&dk(e)}cancelAndSet(e,r,s){return super.cancelAndSet(e,r,s??this.defaultTarget)}},dz=class{constructor(e,r=0){this._runner=e,this.priority=r,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){l0(e)}}static sort(e,r){return r.priority-e.priority}};d=new Map,h=new Map,u=new Map,f=new Map,hd=(e,r,s=0)=>{let i=dR(e),n=new dz(r,s),o=d.get(i);return o||(o=[],d.set(i,o)),o.push(n),u.get(i)||(u.set(i,!0),e.requestAnimationFrame(()=>(e=>{u.set(e,!1);let r=d.get(e)??[];for(h.set(e,r),d.set(e,[]),f.set(e,!0);r.length>0;)r.sort(dz.sort),r.shift().execute();f.set(e,!1)})(i))),n};var dF=class e{constructor(e,r){this.width=e,this.height=r}with(r=this.width,s=this.height){return r!==this.width||s!==this.height?new e(r,s):this}static is(e){return"object"==typeof e&&"number"==typeof e.height&&"number"==typeof e.width}static lift(r){return r instanceof e?r:new e(r.width,r.height)}static equals(e,r){return e===r||!!e&&!!r&&e.width===r.width&&e.height===r.height}};dF.None=new dF(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,r,s){let i=this.mutationObservers.get(e);i||(i=new Map,this.mutationObservers.set(e,i));let n=function e(r,s){switch(typeof r){case"object":var i,n,o,a;return null===r?dw(349,s):Array.isArray(r)?(i=r,n=dw(104579,n=s),i.reduce((r,s)=>e(s,r),n)):(o=r,a=dw(181387,a=s),Object.keys(o).sort().reduce((r,s)=>(r=dS(s,r),e(o[s],r)),a));case"string":return dS(r,s);case"boolean":return dw(r?433:863,s);case"number":return dw(r,s);case"undefined":return dw(937,s);default:return dw(617,s)}}(s,0),o=i.get(n);if(o)o.users+=1;else{let a=new cD,l=new MutationObserver(e=>a.fire(e));l.observe(e,s);let c=o={users:1,observer:l,onDidMutate:a.event};r.add(ce(()=>{c.users-=1,0===c.users&&(a.dispose(),l.disconnect(),i?.delete(n),i?.size===0&&this.mutationObservers.delete(e))})),i.set(n,o)}return o.onDidMutate}};var dW={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},dH=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let r=d$(e);this._maxWidth!==r&&(this._maxWidth=r,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let r=d$(e);this._width!==r&&(this._width=r,this.domNode.style.width=this._width)}setHeight(e){let r=d$(e);this._height!==r&&(this._height=r,this.domNode.style.height=this._height)}setTop(e){let r=d$(e);this._top!==r&&(this._top=r,this.domNode.style.top=this._top)}setLeft(e){let r=d$(e);this._left!==r&&(this._left=r,this.domNode.style.left=this._left)}setBottom(e){let r=d$(e);this._bottom!==r&&(this._bottom=r,this.domNode.style.bottom=this._bottom)}setRight(e){let r=d$(e);this._right!==r&&(this._right=r,this.domNode.style.right=this._right)}setPaddingTop(e){let r=d$(e);this._paddingTop!==r&&(this._paddingTop=r,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let r=d$(e);this._paddingLeft!==r&&(this._paddingLeft=r,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let r=d$(e);this._paddingBottom!==r&&(this._paddingBottom=r,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let r=d$(e);this._paddingRight!==r&&(this._paddingRight=r,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let r=d$(e);this._fontSize!==r&&(this._fontSize=r,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let r=d$(e);this._lineHeight!==r&&(this._lineHeight=r,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let r=d$(e);this._letterSpacing!==r&&(this._letterSpacing=r,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,r){this.domNode.classList.toggle(e,r),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,r){this.domNode.setAttribute(e,r)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function d$(e){return"number"==typeof e?`${e}px`:e}function dK(e){return new dH(e)}var dU=class{constructor(){this._hooks=new cr,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,r){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(r)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,r,s,i,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=n;let o=e;try{e.setPointerCapture(r),this._hooks.add(ce(()=>{try{e.releasePointerCapture(r)}catch{}}))}catch{o=dk(e)}this._hooks.add(dA(o,dW.POINTER_MOVE,e=>{e.buttons!==s?this.stopMonitoring(!0):(e.preventDefault(),this._pointerMoveCallback(e))})),this._hooks.add(dA(o,dW.POINTER_UP,e=>this.stopMonitoring(!0)))}};(p=hh||={}).Tap="-xterm-gesturetap",p.Change="-xterm-gesturechange",p.Start="-xterm-gesturestart",p.End="-xterm-gesturesend",p.Contextmenu="-xterm-gesturecontextmenu";var dq=class e extends cs{constructor(){super(),this.dispatched=!1,this.targets=new ca,this.ignoreTargets=new ca,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(cC.runAndSubscribe(dT,({window:e,disposables:r})=>{r.add(dA(e.document,"touchstart",e=>this.onTouchStart(e),{passive:!1})),r.add(dA(e.document,"touchend",r=>this.onTouchEnd(e,r))),r.add(dA(e.document,"touchmove",e=>this.onTouchMove(e),{passive:!1}))},{window:cn,disposables:this._store}))}static addTarget(r){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),ce(e.INSTANCE.targets.push(r))):cs.None}static ignoreTarget(r){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),ce(e.INSTANCE.ignoreTargets.push(r))):cs.None}static isTouchDevice(){return"ontouchstart"in cn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,i=e.targetTouches.length;s<i;s++){let i=e.targetTouches.item(s);this.activeTouches[i.identifier]={id:i.identifier,initialTarget:i.target,initialTimeStamp:r,initialPageX:i.pageX,initialPageY:i.pageY,rollingTimestamps:[r],rollingPageX:[i.pageX],rollingPageY:[i.pageY]};let n=this.newGestureEvent(hh.Start,i.target);n.pageX=i.pageX,n.pageY=i.pageY,this.dispatchEvent(n)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(r,s){let i=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let a=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],c=Date.now()-l.initialTimeStamp;if(c<e.HOLD_DELAY&&30>Math.abs(l.initialPageX-l4(l.rollingPageX))&&30>Math.abs(l.initialPageY-l4(l.rollingPageY))){let e=this.newGestureEvent(hh.Tap,l.initialTarget);e.pageX=l4(l.rollingPageX),e.pageY=l4(l.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&30>Math.abs(l.initialPageX-l4(l.rollingPageX))&&30>Math.abs(l.initialPageY-l4(l.rollingPageY))){let e=this.newGestureEvent(hh.Contextmenu,l.initialTarget);e.pageX=l4(l.rollingPageX),e.pageY=l4(l.rollingPageY),this.dispatchEvent(e)}else if(1===n){let e=l4(l.rollingPageX),s=l4(l.rollingPageY),n=l4(l.rollingTimestamps)-l.rollingTimestamps[0],o=e-l.rollingPageX[0],a=s-l.rollingPageY[0],c=[...this.targets].filter(e=>l.initialTarget instanceof Node&&e.contains(l.initialTarget));this.inertia(r,c,i,Math.abs(o)/n,o>0?1:-1,e,Math.abs(a)/n,a>0?1:-1,s)}this.dispatchEvent(this.newGestureEvent(hh.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,r){let s=document.createEvent("CustomEvent");return s.initEvent(e,!1,!0),s.initialTarget=r,s.tapCount=0,s}dispatchEvent(r){if(r.type===hh.Tap){let s=new Date().getTime(),i=0;i=s-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=s,r.tapCount=i}else(r.type===hh.Change||r.type===hh.Contextmenu)&&(this._lastSetTapCountTime=0);if(r.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(r.initialTarget))return;let e=[];for(let s of this.targets)if(s.contains(r.initialTarget)){let i=0,n=r.initialTarget;for(;n&&n!==s;)i++,n=n.parentElement;e.push([i,s])}for(let[s,i]of(e.sort((e,r)=>e[0]-r[0]),e))i.dispatchEvent(r),this.dispatched=!0}}inertia(r,s,i,n,o,a,l,c,d){this.handle=hd(r,()=>{let h=Date.now(),u=h-i,f=0,p=0,m=!0;n+=e.SCROLL_FRICTION*u,l+=e.SCROLL_FRICTION*u,n>0&&(m=!1,f=o*n*u),l>0&&(m=!1,p=c*l*u);let g=this.newGestureEvent(hh.Change);g.translationX=f,g.translationY=p,s.forEach(e=>e.dispatchEvent(g)),m||this.inertia(r,s,h,n,o,a+f,l,c,d+p)})}onTouchMove(e){let r=Date.now();for(let s=0,i=e.changedTouches.length;s<i;s++){let i=e.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(i.identifier))){console.warn("end of an UNKNOWN touch",i);continue}let n=this.activeTouches[i.identifier],o=this.newGestureEvent(hh.Change,n.initialTarget);o.translationX=i.pageX-l4(n.rollingPageX),o.translationY=i.pageY-l4(n.rollingPageY),o.pageX=i.pageX,o.pageY=i.pageY,this.dispatchEvent(o),n.rollingPageX.length>3&&(n.rollingPageX.shift(),n.rollingPageY.shift(),n.rollingTimestamps.shift()),n.rollingPageX.push(i.pageX),n.rollingPageY.push(i.pageY),n.rollingTimestamps.push(r)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};dq.SCROLL_FRICTION=-.005,dq.HOLD_DELAY=700,dq.CLEAR_TAP_COUNT_TIME=400,lg([function(e,r,s){let i=null,n=null;if("function"==typeof s.value?(i="value",0!==(n=s.value).length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof s.get&&(i="get",n=s.get),!n)throw Error("not supported");let o=`$memoize$${r}`;s[i]=function(...e){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,e)}),this[o]}}],dq,"isTouchDevice",1);var dV=class extends cs{onclick(e,r){this._register(dA(e,dW.CLICK,s=>r(new dm(dk(e),s))))}onmousedown(e,r){this._register(dA(e,dW.MOUSE_DOWN,s=>r(new dm(dk(e),s))))}onmouseover(e,r){this._register(dA(e,dW.MOUSE_OVER,s=>r(new dm(dk(e),s))))}onmouseleave(e,r){this._register(dA(e,dW.MOUSE_LEAVE,s=>r(new dm(dk(e),s))))}onkeydown(e,r){this._register(dA(e,dW.KEY_DOWN,e=>r(new du(e))))}onkeyup(e,r){this._register(dA(e,dW.KEY_UP,e=>r(new du(e))))}oninput(e,r){this._register(dA(e,dW.INPUT,r))}onblur(e,r){this._register(dA(e,dW.BLUR,r))}onfocus(e,r){this._register(dA(e,dW.FOCUS,r))}onchange(e,r){this._register(dA(e,dW.CHANGE,r))}ignoreGesture(e){return dq.ignoreTarget(e)}},dY=class extends dV{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px","u">typeof e.top&&(this.bgDomNode.style.top="0px"),"u">typeof e.left&&(this.bgDomNode.style.left="0px"),"u">typeof e.bottom&&(this.bgDomNode.style.bottom="0px"),"u">typeof e.right&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width="11px",this.domNode.style.height="11px","u">typeof e.top&&(this.domNode.style.top=e.top+"px"),"u">typeof e.left&&(this.domNode.style.left=e.left+"px"),"u">typeof e.bottom&&(this.domNode.style.bottom=e.bottom+"px"),"u">typeof e.right&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new dU),this._register(dO(this.bgDomNode,dW.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(dO(this.domNode,dW.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new dI),this._pointerdownScheduleRepeatTimer=this._register(new d_)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let r=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,dk(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(r,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},dX=class e{constructor(e,r,s,i,n,o,a){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r|=0,s|=0,i|=0,n|=0,o|=0,a|=0),this.rawScrollLeft=i,this.rawScrollTop=a,r<0&&(r=0),i+r>s&&(i=s-r),i<0&&(i=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=r,this.scrollWidth=s,this.scrollLeft=i,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(r,s){return new e(this._forceIntegerValues,"u">typeof r.width?r.width:this.width,"u">typeof r.scrollWidth?r.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,"u">typeof r.height?r.height:this.height,"u">typeof r.scrollHeight?r.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(r){return new e(this._forceIntegerValues,this.width,this.scrollWidth,"u">typeof r.scrollLeft?r.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,"u">typeof r.scrollTop?r.scrollTop:this.rawScrollTop)}createScrollEvent(e,r){let s=this.width!==e.width,i=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,a=this.scrollHeight!==e.scrollHeight,l=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:r,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:i,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},dG=class extends cs{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new cD),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new dX(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,r){let s=this._state.withScrollDimensions(e,r);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let r=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(r,!1)}setScrollPositionSmooth(e,r){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(e);if(this._smoothScrolling){let s;e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;s=r?new dQ(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=dQ.start(this._state,r,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),r=this._state.withScrollPosition(e);if(this._setState(r,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,r){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,r)))}},dJ=class{constructor(e,r,s){this.scrollLeft=e,this.scrollTop=r,this.isDone=s}};function dZ(e,r){let s=r-e;return function(r){return e+s*(1-Math.pow(1-r,3))}}var dQ=class e{constructor(e,r,s,i){this.from=e,this.to=r,this.duration=i,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,r,s){if(Math.abs(e-r)>2.5*s){var i,n;let o,a;return e<r?(o=e+.75*s,a=r-.75*s):(o=e-.75*s,a=r+.75*s),i=dZ(e,o),n=dZ(a,r),function(e){return e<.33?i(e/.33):n((e-.33)/(1-.33))}}return dZ(e,r)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let r=(e-this.startTime)/this.duration;return r<1?new dJ(this.scrollLeft(r),this.scrollTop(r),!1):new dJ(this.to.scrollLeft,this.to.scrollTop,!0)}combine(r,s,i){return e.start(r,s,i)}static start(r,s,i){return i+=10,new e(r,s,Date.now()-10,i)}},d0=class extends cs{constructor(e,r,s){super(),this._visibility=e,this._visibleClassName=r,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new d_)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||this._rawShouldBeVisible)}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},d1=class extends dV{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new d0(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new dU),this._shouldRender=!0,this.domNode=dK(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(dA(this.domNode.domNode,dW.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let r=this._register(new dY(e));this.domNode.domNode.appendChild(r.bgDomNode),this.domNode.domNode.appendChild(r.domNode)}_createSlider(e,r,s,i){this.slider=dK(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(r),"number"==typeof s&&this.slider.setWidth(s),"number"==typeof i&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(dA(this.slider.domNode,dW.POINTER_DOWN,e=>{0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let r=this.domNode.domNode.getClientRects()[0].top,s=r+this._scrollbarState.getSliderPosition(),i=r+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=i?0===e.button&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let r,s;if(e.target===this.domNode.domNode&&"number"==typeof e.offsetX&&"number"==typeof e.offsetY)r=e.offsetX,s=e.offsetY;else{var i;let n,o,a=(n=(i=this.domNode.domNode).getBoundingClientRect(),o=dk(i),{left:n.left+o.scrollX,top:n.top+o.scrollY,width:n.width,height:n.height});r=e.pageX-a.left,s=e.pageY-a.top}let n=this._pointerDownRelativePosition(r,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let r=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let n=Math.abs(this._sliderOrthogonalPointerPosition(e)-s);if(cJ&&n>140)return void this._setDesiredScrollPositionNow(i.getScrollPosition());let o=this._sliderPointerPosition(e)-r;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let r={};this.writeScrollPosition(r,e),this._scrollable.setScrollPositionNow(r)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},d2=class e{constructor(e,r,s,i,n,o){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(e),this._visibleSize=i,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let r=Math.round(e);return this._visibleSize!==r&&(this._visibleSize=r,this._refreshComputedValues(),!0)}setScrollSize(e){let r=Math.round(e);return this._scrollSize!==r&&(this._scrollSize=r,this._refreshComputedValues(),!0)}setScrollPosition(e){let r=Math.round(e);return this._scrollPosition!==r&&(this._scrollPosition=r,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,r,s,i,n){let o=Math.max(0,s-e),a=Math.max(0,o-2*r),l=i>0&&i>s;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(s*a/i))),d=(a-c)/(i-s);return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(c),computedSliderRatio:d,computedSliderPosition:Math.round(n*d)}}_refreshComputedValues(){let r=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=r.computedAvailableSize,this._computedIsNeeded=r.computedIsNeeded,this._computedSliderSize=r.computedSliderSize,this._computedSliderRatio=r.computedSliderRatio,this._computedSliderPosition=r.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){return this._computedIsNeeded?Math.round((e-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let r=e-this._arrowSize,s=this._scrollPosition;return r<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(e){return this._computedIsNeeded?Math.round((this._computedSliderPosition+e)/this._computedSliderRatio):0}},d5=class extends d1{constructor(e,r,s){let i=e.getScrollDimensions();if(super({lazyRender:r.lazyRender,host:s,scrollbarState:new d2(r.horizontalHasArrows?r.arrowSize:0,2===r.horizontal?0:r.horizontalScrollbarSize,2===r.vertical?0:r.verticalScrollbarSize,i.width,i.scrollWidth,e.getCurrentScrollPosition().scrollLeft),visibility:r.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:r.scrollByPage}),r.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((r.horizontalScrollbarSize-r.horizontalSliderSize)/2),0,void 0,r.horizontalSliderSize)}_updateSlider(e,r){this.slider.setWidth(e),this.slider.setLeft(r)}_renderDomNode(e,r){this.domNode.setWidth(e),this.domNode.setHeight(r),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,r){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,r){e.scrollLeft=r}updateOptions(e){this.updateScrollbarSize(2===e.horizontal?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},d3=class extends d1{constructor(e,r,s){let i=e.getScrollDimensions();if(super({lazyRender:r.lazyRender,host:s,scrollbarState:new d2(r.verticalHasArrows?r.arrowSize:0,2===r.vertical?0:r.verticalScrollbarSize,0,i.height,i.scrollHeight,e.getCurrentScrollPosition().scrollTop),visibility:r.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:r.scrollByPage}),r.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((r.verticalScrollbarSize-r.verticalSliderSize)/2),r.verticalSliderSize,void 0)}_updateSlider(e,r){this.slider.setHeight(e),this.slider.setTop(r)}_renderDomNode(e,r){this.domNode.setWidth(r),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,r){return r}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,r){e.scrollTop=r}updateOptions(e){this.updateScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},d4=class{constructor(e,r,s){this.timestamp=e,this.deltaX=r,this.deltaY=s,this.score=0}},d6=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let e=1,r=0,s=1,i=this._rear;for(;;){let n=i===this._front?e:Math.pow(2,-s);if(e-=n,r+=this._memory[i].score*n,i===this._front)break;i=(this._capacity+i-1)%this._capacity,s++}return r<=.5}acceptStandardWheelEvent(e){if(cO){var r;let s=(r=dk(e.browserEvent),cP.INSTANCE.getZoomFactor(r));this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,r,s){let i=null,n=new d4(e,r,s);-1===this._front&&-1===this._rear?(this._memory[0]=n,this._front=0,this._rear=0):(i=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,i)}_computeScore(e,r){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let s=.5;if(this._isAlmostInt(e.deltaX)&&this._isAlmostInt(e.deltaY)||(s+=.25),r){let i=Math.abs(e.deltaX),n=Math.abs(e.deltaY),o=Math.abs(r.deltaX),a=Math.abs(r.deltaY),l=Math.max(Math.min(i,o),1),c=Math.max(Math.min(n,a),1),d=Math.max(n,a);Math.max(i,o)%l==0&&d%c==0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(e){return .01>Math.abs(Math.round(e)-e)}};d6.INSTANCE=new d6;var d8=class extends dV{constructor(e,r,s){super(),this._onScroll=this._register(new cD),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new cD),this.onWillScroll=this._onWillScroll.event,this._options=function(e){let r={lazyRender:"u">typeof e.lazyRender&&e.lazyRender,className:"u">typeof e.className?e.className:"",useShadows:!("u">typeof e.useShadows)||e.useShadows,handleMouseWheel:!("u">typeof e.handleMouseWheel)||e.handleMouseWheel,flipAxes:"u">typeof e.flipAxes&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:"u">typeof e.consumeMouseWheelIfScrollbarIsNeeded&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:"u">typeof e.alwaysConsumeMouseWheel&&e.alwaysConsumeMouseWheel,scrollYToX:"u">typeof e.scrollYToX&&e.scrollYToX,mouseWheelScrollSensitivity:"u">typeof e.mouseWheelScrollSensitivity?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:"u">typeof e.fastScrollSensitivity?e.fastScrollSensitivity:5,scrollPredominantAxis:!("u">typeof e.scrollPredominantAxis)||e.scrollPredominantAxis,mouseWheelSmoothScroll:!("u">typeof e.mouseWheelSmoothScroll)||e.mouseWheelSmoothScroll,arrowSize:"u">typeof e.arrowSize?e.arrowSize:11,listenOnDomNode:"u">typeof e.listenOnDomNode?e.listenOnDomNode:null,horizontal:"u">typeof e.horizontal?e.horizontal:1,horizontalScrollbarSize:"u">typeof e.horizontalScrollbarSize?e.horizontalScrollbarSize:10,horizontalSliderSize:"u">typeof e.horizontalSliderSize?e.horizontalSliderSize:0,horizontalHasArrows:"u">typeof e.horizontalHasArrows&&e.horizontalHasArrows,vertical:"u">typeof e.vertical?e.vertical:1,verticalScrollbarSize:"u">typeof e.verticalScrollbarSize?e.verticalScrollbarSize:10,verticalHasArrows:"u">typeof e.verticalHasArrows&&e.verticalHasArrows,verticalSliderSize:"u">typeof e.verticalSliderSize?e.verticalSliderSize:0,scrollByPage:"u">typeof e.scrollByPage&&e.scrollByPage};return r.horizontalSliderSize="u">typeof e.horizontalSliderSize?e.horizontalSliderSize:r.horizontalScrollbarSize,r.verticalSliderSize="u">typeof e.verticalSliderSize?e.verticalSliderSize:r.verticalScrollbarSize,cZ&&(r.className+=" mac"),r}(r),this._scrollable=s,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let i={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new d3(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new d5(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=dK(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=dK(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=dK(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new d_),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=l9(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,cZ&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){"u">typeof e.handleMouseWheel&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),"u">typeof e.mouseWheelScrollSensitivity&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),"u">typeof e.fastScrollSensitivity&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),"u">typeof e.scrollPredominantAxis&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),"u">typeof e.horizontal&&(this._options.horizontal=e.horizontal),"u">typeof e.vertical&&(this._options.vertical=e.vertical),"u">typeof e.horizontalScrollbarSize&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),"u">typeof e.verticalScrollbarSize&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),"u">typeof e.scrollByPage&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new dg(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=l9(this._mouseWheelToDispose),e)){let e=e=>{this._onMouseWheel(new dg(e))};this._mouseWheelToDispose.push(dA(this._listenOnDomNode,dW.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let r=d6.INSTANCE;r.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let i=e.deltaY*this._options.mouseWheelScrollSensitivity,n=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&n+i===0?n=i=0:Math.abs(i)>=Math.abs(n)?n=0:i=0),this._options.flipAxes&&([i,n]=[n,i]);let o=!cZ&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||o)&&!n&&(n=i,i=0),e.browserEvent&&e.browserEvent.altKey&&(n*=this._options.fastScrollSensitivity,i*=this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),l={};if(i){let e=50*i,r=a.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(l,r)}if(n){let e=50*n,r=a.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(l,r)}l=this._scrollable.validateScrollPosition(l),(a.scrollLeft!==l.scrollLeft||a.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&r.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),r=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",n=r?" top":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${s||r?" top-left-corner":""}${n}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){this._mouseIsOver||this._isDragging||(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){this._mouseIsOver||this._isDragging||this._hideTimeout.cancelAndSet(()=>this._hide(),500)}},d7=class extends d8{constructor(e,r,s){super(e,r,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},d9=class extends cs{constructor(e,r,s,i,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new cD),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new dG({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>hd(i.window,e)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new d7(r,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&e)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(cC.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ce(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),r.appendChild(this._styleElement),this._register(ce(()=>this._styleElement.remove())),this._register(cC.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
16
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let r=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:r.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,r){r&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!r,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){void 0!==e&&(this._latestYDisp=e),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let r=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=r-this._bufferService.buffer.ydisp;0!==s&&(this._latestYDisp=r,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};d9=lg([lv(2,lL),lv(3,lq),lv(4,lB),lv(5,lJ),lv(6,lF),lv(7,lY)],d9);var he=class extends cs{constructor(e,r,s,i,n){super(),this._screenElement=e,this._bufferService=r,this._coreBrowserService=s,this._decorationService=i,this._renderService=n,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(ce(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){void 0===this._animationFrame&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let r=this._coreBrowserService.mainDocument.createElement("div");r.classList.add("xterm-decoration"),r.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(r.style.display="none"),this._refreshXPosition(e,r),r}_refreshStyle(e){let r=e.marker.line-this._bufferService.buffers.active.ydisp;if(r<0||r>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${r*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,r=e.element){if(!r)return;let s=e.options.x??0;"right"===(e.options.anchor||"left")?r.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":r.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};he=lg([lv(1,lL),lv(2,lq),lv(3,l$),lv(4,lY)],he);var ht=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let r of this._zones)if(r.color===e.options.overviewRulerOptions.color&&r.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(r,e.marker.line))return;if(this._lineAdjacentToZone(r,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(r,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,r){return r>=e.startBufferLine&&r<=e.endBufferLine}_lineAdjacentToZone(e,r,s){return r>=e.startBufferLine-this._linePadding[s||"full"]&&r<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,r){e.startBufferLine=Math.min(e.startBufferLine,r),e.endBufferLine=Math.max(e.endBufferLine,r)}},hr={full:0,left:0,center:0,right:0},hs={full:0,left:0,center:0,right:0},hi={full:0,left:0,center:0,right:0},hn=class extends cs{constructor(e,r,s,i,n,o,a,l){super(),this._viewportElement=e,this._screenElement=r,this._bufferService=s,this._decorationService=i,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new ht,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(ce(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),r=Math.ceil((this._canvas.width-1)/3);hs.full=this._canvas.width,hs.left=e,hs.center=r,hs.right=e,this._refreshDrawHeightConstants(),hi.full=1,hi.left=1,hi.center=1+hs.left,hi.right=1+hs.left+hs.center}_refreshDrawHeightConstants(){hr.full=Math.round(2*this._coreBrowserService.dpr);let e=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);hr.left=e,hr.center=e,hr.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hr.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){for(let e of(this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear(),this._decorationService.decorations))this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let r of e)"full"!==r.position&&this._renderColorZone(r);for(let r of e)"full"===r.position&&this._renderColorZone(r);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(hi[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-hr[e.position||"full"]/2),hs[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+hr[e.position||"full"]))}_queueRefresh(e,r){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=r||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};hn=lg([lv(2,lL),lv(3,l$),lv(4,lY),lv(5,lF),lv(6,lJ),lv(7,lq)],hn),(m=hu||={}).NUL="\0",m.SOH="\x01",m.STX="\x02",m.ETX="\x03",m.EOT="\x04",m.ENQ="\x05",m.ACK="\x06",m.BEL="\x07",m.BS="\b",m.HT=" ",m.LF=`
17
+ `,m.VT="\v",m.FF="\f",m.CR="\r",m.SO="\x0e",m.SI="\x0f",m.DLE="\x10",m.DC1="\x11",m.DC2="\x12",m.DC3="\x13",m.DC4="\x14",m.NAK="\x15",m.SYN="\x16",m.ETB="\x17",m.CAN="\x18",m.EM="\x19",m.SUB="\x1a",m.ESC="\x1b",m.FS="\x1c",m.GS="\x1d",m.RS="\x1e",m.US="\x1f",m.SP=" ",m.DEL="",(g=hf||={}).PAD="€",g.HOP="",g.BPH="‚",g.NBH="ƒ",g.IND="„",g.NEL="…",g.SSA="†",g.ESA="‡",g.HTS="ˆ",g.HTJ="‰",g.VTS="Š",g.PLD="‹",g.PLU="Œ",g.RI="",g.SS2="Ž",g.SS3="",g.DCS="",g.PU1="‘",g.PU2="’",g.STS="“",g.CCH="”",g.MW="•",g.SPA="–",g.EPA="—",g.SOS="˜",g.SGCI="™",g.SCI="š",g.CSI="›",g.ST="œ",g.OSC="",g.PM="ž",g.APC="Ÿ",(hp||={}).ST=`${hu.ESC}\\`;var ho=class{constructor(e,r,s,i,n,o){this._textarea=e,this._compositionView=r,this._bufferService=s,this._optionsService=i,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(20===e.keyCode||229===e.keyCode||16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let r;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,(r=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start)).length>0&&this._coreService.triggerDataEvent(r,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let r=this._textarea.value,s=r.replace(e,"");this._dataAlreadySent=s,r.length>e.length?this._coreService.triggerDataEvent(s,!0):r.length<e.length?this._coreService.triggerDataEvent(`${hu.DEL}`,!0):r.length===e.length&&r!==e&&this._coreService.triggerDataEvent(r,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),r=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};ho=lg([lv(2,lL),lv(3,lF),lv(4,lA),lv(5,lY)],ho);var ha,hl,hc,hd,hh,hu,hf,hp,hm,hg=0,hv=0,hx=0,h_=0,hy={css:"#00000000",rgba:0};(u4=hm||={}).toCss=function(e,r,s,i){return void 0!==i?`#${hE(e)}${hE(r)}${hE(s)}${hE(i)}`:`#${hE(e)}${hE(r)}${hE(s)}`},u4.toRgba=function(e,r,s,i=255){return(e<<24|r<<16|s<<8|i)>>>0},u4.toColor=function(e,r,s,i){return{css:u4.toCss(e,r,s,i),rgba:u4.toRgba(e,r,s,i)}};var hb=u6||={};function hw(e,r){return h_=Math.round(255*r),[hg,hv,hx]=u9.toChannels(e.rgba),{css:hm.toCss(hg,hv,hx,h_),rgba:hm.toRgba(hg,hv,hx,h_)}}hb.blend=function(e,r){if(1==(h_=(255&r.rgba)/255))return{css:r.css,rgba:r.rgba};let s=r.rgba>>24&255,i=r.rgba>>16&255,n=r.rgba>>8&255,o=e.rgba>>24&255,a=e.rgba>>16&255,l=e.rgba>>8&255;return hg=o+Math.round((s-o)*h_),hv=a+Math.round((i-a)*h_),hx=l+Math.round((n-l)*h_),{css:hm.toCss(hg,hv,hx),rgba:hm.toRgba(hg,hv,hx)}},hb.isOpaque=function(e){return(255&e.rgba)==255},hb.ensureContrastRatio=function(e,r,s){let i=u9.ensureContrastRatio(e.rgba,r.rgba,s);if(i)return hm.toColor(i>>24&255,i>>16&255,i>>8&255)},hb.opaque=function(e){let r=(255|e.rgba)>>>0;return[hg,hv,hx]=u9.toChannels(r),{css:hm.toCss(hg,hv,hx),rgba:r}},hb.opacity=hw,hb.multiplyOpacity=function(e,r){return h_=255&e.rgba,hw(e,h_*r/255)},hb.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]},(e=>{let r,s;try{let e=document.createElement("canvas");e.width=1,e.height=1;let i=e.getContext("2d",{willReadFrequently:!0});i&&((r=i).globalCompositeOperation="copy",s=r.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return hg=parseInt(e.slice(1,2).repeat(2),16),hv=parseInt(e.slice(2,3).repeat(2),16),hx=parseInt(e.slice(3,4).repeat(2),16),hm.toColor(hg,hv,hx);case 5:return hg=parseInt(e.slice(1,2).repeat(2),16),hv=parseInt(e.slice(2,3).repeat(2),16),hx=parseInt(e.slice(3,4).repeat(2),16),h_=parseInt(e.slice(4,5).repeat(2),16),hm.toColor(hg,hv,hx,h_);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let i=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(i)return hg=parseInt(i[1]),hv=parseInt(i[2]),hx=parseInt(i[3]),h_=Math.round((void 0===i[5]?1:parseFloat(i[5]))*255),hm.toColor(hg,hv,hx,h_);if(!r||!s||(r.fillStyle=s,r.fillStyle=e,"string"!=typeof r.fillStyle)||(r.fillRect(0,0,1,1),[hg,hv,hx,h_]=r.getImageData(0,0,1,1).data,255!==h_))throw Error("css.toColor: Unsupported css format");return{rgba:hm.toRgba(hg,hv,hx,h_),css:e}}})(u8||={});var hS=u7||={};function hC(e,r,s){let i=e/255,n=r/255,o=s/255;return .2126*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}hS.relativeLuminance=function(e){return hC(e>>16&255,e>>8&255,255&e)},hS.relativeLuminance2=hC;var hk=u9||={};function hj(e,r,s){let i=e>>24&255,n=e>>16&255,o=e>>8&255,a=r>>24&255,l=r>>16&255,c=r>>8&255,d=hR(u7.relativeLuminance2(a,l,c),u7.relativeLuminance2(i,n,o));for(;d<s&&(a>0||l>0||c>0);)a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),c-=Math.max(0,Math.ceil(.1*c)),d=hR(u7.relativeLuminance2(a,l,c),u7.relativeLuminance2(i,n,o));return(a<<24|l<<16|c<<8|255)>>>0}function hN(e,r,s){let i=e>>24&255,n=e>>16&255,o=e>>8&255,a=r>>24&255,l=r>>16&255,c=r>>8&255,d=hR(u7.relativeLuminance2(a,l,c),u7.relativeLuminance2(i,n,o));for(;d<s&&(a<255||l<255||c<255);)a=Math.min(255,a+Math.ceil((255-a)*.1)),l=Math.min(255,l+Math.ceil((255-l)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),d=hR(u7.relativeLuminance2(a,l,c),u7.relativeLuminance2(i,n,o));return(a<<24|l<<16|c<<8|255)>>>0}function hE(e){let r=e.toString(16);return r.length<2?"0"+r:r}function hR(e,r){return e<r?(r+.05)/(e+.05):(e+.05)/(r+.05)}hk.blend=function(e,r){if(1==(h_=(255&r)/255))return r;let s=e>>24&255,i=e>>16&255,n=e>>8&255;return hg=s+Math.round(((r>>24&255)-s)*h_),hv=i+Math.round(((r>>16&255)-i)*h_),hx=n+Math.round(((r>>8&255)-n)*h_),hm.toRgba(hg,hv,hx)},hk.ensureContrastRatio=function(e,r,s){let i=u7.relativeLuminance(e>>8),n=u7.relativeLuminance(r>>8);if(hR(i,n)<s){if(n<i){let n=hj(e,r,s),o=hR(i,u7.relativeLuminance(n>>8));if(o<s){let a=hN(e,r,s);return o>hR(i,u7.relativeLuminance(a>>8))?n:a}return n}let o=hN(e,r,s),a=hR(i,u7.relativeLuminance(o>>8));if(a<s){let n=hj(e,r,s);return a>hR(i,u7.relativeLuminance(n>>8))?o:n}return o}},hk.reduceLuminance=hj,hk.increaseLuminance=hN,hk.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]};var hM=class extends lN{constructor(e,r,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=r,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},hD=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new lR}register(e){let r={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(r),r.id}deregister(e){for(let r=0;r<this._characterJoiners.length;r++)if(this._characterJoiners[r].id===e)return this._characterJoiners.splice(r,1),!0;return!1}getJoinedCharacters(e){if(0===this._characterJoiners.length)return[];let r=this._bufferService.buffer.lines.get(e);if(!r||0===r.length)return[];let s=[],i=r.translateToString(!0),n=0,o=0,a=0,l=r.getFg(0),c=r.getBg(0);for(let e=0;e<r.getTrimmedLength();e++)if(r.loadCell(e,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==l||this._workCell.bg!==c){if(e-n>1){let e=this._getJoinedRanges(i,a,o,r,n);for(let r=0;r<e.length;r++)s.push(e[r])}n=e,a=o,l=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||1}if(this._bufferService.cols-n>1){let e=this._getJoinedRanges(i,a,o,r,n);for(let r=0;r<e.length;r++)s.push(e[r])}return s}_getJoinedRanges(e,r,s,i,n){let o=e.substring(r,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let r=this._characterJoiners[e].handler(o);for(let e=0;e<r.length;e++)hD._mergeRanges(a,r[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(a,i,n),a}_stringRangesToCellRanges(e,r,s){let i=0,n=!1,o=0,a=e[0];if(a){for(let l=s;l<this._bufferService.cols;l++){let s=r.getWidth(l),c=r.getString(l).length||1;if(0!==s){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,!(a=e[++i]))break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,r){let s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(s){if(r[1]<=n[0])return e[i-1][1]=r[1],e;if(r[1]<=n[1])return e[i-1][1]=Math.max(r[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(r[1]<=n[0])return e.splice(i,0,r),e;if(r[1]<=n[1])return n[0]=Math.min(r[0],n[0]),e;r[0]<n[1]&&(n[0]=Math.min(r[0],n[0]),s=!0);continue}}return s?e[e.length-1][1]=r[1]:e.push(r),e}};function hT(){return{width:0,height:0}}hD=lg([lv(0,lL)],hD);var hP=class{constructor(e,r,s,i,n,o,a){this._document=e,this._characterJoinerService=r,this._optionsService=s,this._coreBrowserService=i,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new lR,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,r,s){this._selectionStart=e,this._selectionEnd=r,this._columnSelectMode=s}createRow(e,r,s,i,n,o,a,l,c,d,h){let u=[],f=this._characterJoinerService.getJoinedCharacters(r),p=this._themeService.colors,m=e.getNoBgTrimmedLength();s&&m<o+1&&(m=o+1);let g,v=0,x="",_=0,y=0,b=0,w=0,S=!1,C=0,k=!1,j=0,N=0,E=[],R=-1!==d&&-1!==h;for(let M=0;M<m;M++){let m;e.loadCell(M,this._workCell);let D=this._workCell.getWidth();if(0===D)continue;let T=!1,P=M>=N,L=M,B=this._workCell;if(f.length>0&&M===f[0][0]&&P){let i=f.shift(),n=this._isCellInSelection(i[0],r);for(_=i[0]+1;_<i[1];_++)P&&=n===this._isCellInSelection(_,r);(P&&=!s||o<i[0]||o>=i[1])?(T=!0,B=new hM(this._workCell,e.translateToString(!0,i[0],i[1]),i[1]-i[0]),L=i[1]-1,D=B.getWidth()):N=i[1]}let A=this._isCellInSelection(M,r),O=s&&M===o,I=R&&M>=d&&M<=h,z=!1;this._decorationService.forEachDecorationAtCell(M,r,void 0,e=>{z=!0});let F=B.getChars()||" ";if(" "===F&&(B.isUnderline()||B.isOverline())&&(F=" "),j=D*l-c.get(F,B.isBold(),B.isItalic()),g)if(v&&(A&&k||!A&&!k&&B.bg===y)&&(A&&k&&p.selectionForeground||B.fg===b)&&B.extended.ext===w&&I===S&&j===C&&!O&&!T&&!z&&P){B.isInvisible()?x+=" ":x+=F,v++;continue}else v&&(g.textContent=x),g=this._document.createElement("span"),v=0,x="";else g=this._document.createElement("span");if(y=B.bg,b=B.fg,w=B.extended.ext,S=I,C=j,k=A,T&&o>=M&&o<=L&&(o=M),!this._coreService.isCursorHidden&&O&&this._coreService.isCursorInitialized){if(E.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&E.push("xterm-cursor-blink"),E.push("bar"===i?"xterm-cursor-bar":"underline"===i?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":E.push("xterm-cursor-outline");break;case"block":E.push("xterm-cursor-block");break;case"bar":E.push("xterm-cursor-bar");break;case"underline":E.push("xterm-cursor-underline")}}if(B.isBold()&&E.push("xterm-bold"),B.isItalic()&&E.push("xterm-italic"),B.isDim()&&E.push("xterm-dim"),x=B.isInvisible()?" ":B.getChars()||" ",B.isUnderline()&&(E.push(`xterm-underline-${B.extended.underlineStyle}`)," "===x&&(x=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${lN.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let e=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&e<8&&(e+=8),g.style.textDecorationColor=p.ansi[e].css}B.isOverline()&&(E.push("xterm-overline")," "===x&&(x=" ")),B.isStrikethrough()&&E.push("xterm-strikethrough"),I&&(g.style.textDecoration="underline");let W=B.getFgColor(),H=B.getFgColorMode(),$=B.getBgColor(),K=B.getBgColorMode(),U=!!B.isInverse();if(U){let e=W;W=$,$=e;let r=H;H=K,K=r}let q,V,Y=!1;switch(this._decorationService.forEachDecorationAtCell(M,r,void 0,e=>{"top"!==e.options.layer&&Y||(e.backgroundColorRGB&&(K=0x3000000,$=e.backgroundColorRGB.rgba>>8&0xffffff,q=e.backgroundColorRGB),e.foregroundColorRGB&&(H=0x3000000,W=e.foregroundColorRGB.rgba>>8&0xffffff,V=e.foregroundColorRGB),Y="top"===e.options.layer)}),!Y&&A&&($=(q=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba>>8&0xffffff,K=0x3000000,Y=!0,p.selectionForeground&&(H=0x3000000,W=p.selectionForeground.rgba>>8&0xffffff,V=p.selectionForeground)),Y&&E.push("xterm-decoration-top"),K){case 0x1000000:case 0x2000000:m=p.ansi[$],E.push(`xterm-bg-${$}`);break;case 0x3000000:m=hm.toColor($>>16,$>>8&255,255&$),this._addStyle(g,`background-color:#${hL(($>>>0).toString(16),"0",6)}`);break;default:U?(m=p.foreground,E.push("xterm-bg-257")):m=p.background}switch(q||B.isDim()&&(q=u6.multiplyOpacity(m,.5)),H){case 0x1000000:case 0x2000000:B.isBold()&&W<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(W+=8),this._applyMinimumContrast(g,m,p.ansi[W],B,q,void 0)||E.push(`xterm-fg-${W}`);break;case 0x3000000:let X=hm.toColor(W>>16&255,W>>8&255,255&W);this._applyMinimumContrast(g,m,X,B,q,V)||this._addStyle(g,`color:#${hL(W.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,m,p.foreground,B,q,V)||U&&E.push("xterm-fg-257")}E.length&&(g.className=E.join(" "),E.length=0),O||T||z||!P?g.textContent=x:v++,j!==this.defaultSpacing&&(g.style.letterSpacing=`${j}px`),u.push(g),M=L}return g&&v&&(g.textContent=x),u}_applyMinimumContrast(e,r,s,i,n,o){var a,l,c;if(1===this._optionsService.rawOptions.minimumContrastRatio||57508<=(l=a=i.getCode())&&l<=57558||9472<=(c=a)&&c<=9631)return!1;let d=this._getContrastCache(i),h;if(n||o||(h=d.getColor(r.rgba,s.rgba)),void 0===h){let e=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);h=u6.ensureContrastRatio(n||r,o||s,e),d.setColor((n||r).rgba,(o||s).rgba,h??null)}return!!h&&(this._addStyle(e,`color:${h.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,r){e.setAttribute("style",`${e.getAttribute("style")||""}${r};`)}_isCellInSelection(e,r){let s=this._selectionStart,i=this._selectionEnd;return!!s&&!!i&&(this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&r>=s[1]&&e<i[0]&&r<=i[1]:e<s[0]&&r>=s[1]&&e>=i[0]&&r<=i[1]:r>s[1]&&r<i[1]||s[1]===i[1]&&r===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&r===i[1]&&e<i[0]||s[1]<i[1]&&r===s[1]&&e>=s[0])}};function hL(e,r,s){for(;e.length<s;)e=r+e;return e}hP=lg([lv(1,lG),lv(2,lF),lv(3,lq),lv(4,lA),lv(5,l$),lv(6,lJ)],hP);var hB=class{constructor(e,r){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,n,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(n),this._container.appendChild(o),r.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,r,s,i){e===this._font&&r===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=r,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,r,s){let i=0;if(!r&&!s&&1===e.length&&(i=e.charCodeAt(0))<256){if(-9999!==this._flat[i])return this._flat[i];let r=this._measure(e,0);return r>0&&(this._flat[i]=r),r}let n=e;r&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(void 0===o){let i=0;r&&(i|=1),s&&(i|=2),(o=this._measure(e,i))>0&&this._holey.set(n,o)}return o}_measure(e,r){let s=this._measureElements[r];return s.textContent=e.repeat(32),s.offsetWidth/32}},hA=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,r,s,i=!1){if(this.selectionStart=r,this.selectionEnd=s,!r||!s||r[0]===s[0]&&r[1]===s[1])return void this.clear();let n=e.buffers.active.ydisp,o=r[1]-n,a=s[1]-n,l=Math.max(o,0),c=Math.min(a,e.rows-1);l>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=r[0],this.endCol=s[0])}isCellSelected(e,r,s){return!!this.hasSelection&&(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?r>=this.startCol&&s>=this.viewportCappedStartRow&&r<this.endCol&&s<=this.viewportCappedEndRow:r<this.startCol&&s>=this.viewportCappedStartRow&&r>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&r>=this.startCol&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&r>=this.startCol)}},hO="xterm-dom-renderer-owner-",hI="xterm-rows",hz="xterm-fg-",hF="xterm-bg-",hW="xterm-focus",hH="xterm-selection",h$=1,hK=class extends cs{constructor(e,r,s,i,n,o,a,l,c,d,h,u,f,p){super(),this._terminal=e,this._document=r,this._element=s,this._screenElement=i,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=c,this._optionsService=d,this._bufferService=h,this._coreService=u,this._coreBrowserService=f,this._themeService=p,this._terminalClass=h$++,this._rowElements=[],this._selectionRenderModel=new hA,this.onRequestRedraw=this._register(new cD).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(hI),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(hH),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:hT(),cell:hT()},device:{canvas:hT(),cell:hT(),char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(hP,document),this._element.classList.add(hO+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(ce(()=>{this._element.classList.remove(hO+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new hB(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;for(let r of(this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows,this._rowElements))r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let r=`${this._terminalSelector} .${hI} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=r,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let r=`${this._terminalSelector} .${hI} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;r+=`${this._terminalSelector} .${hI} .xterm-dim { color: ${u6.multiplyOpacity(e.foreground,.5).css};}${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;for(let[o,a]of(r+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}@keyframes ${i} { 50% { box-shadow: none; }}@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}${this._terminalSelector} .${hI}.${hW} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${hI}.${hW} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${hI}.${hW} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${hI} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${hI} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${hI} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${hI} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${hI} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}${this._terminalSelector} .${hH} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${hH} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${hH} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`,e.ansi.entries()))r+=`${this._terminalSelector} .${hz}${o} { color: ${a.css}; }${this._terminalSelector} .${hz}${o}.xterm-dim { color: ${u6.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${hF}${o} { background-color: ${a.css}; }`;r+=`${this._terminalSelector} .${hz}257 { color: ${u6.opaque(e.background).css}; }${this._terminalSelector} .${hz}257.xterm-dim { color: ${u6.multiplyOpacity(u6.opaque(e.background),.5).css}; }${this._terminalSelector} .${hF}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=r}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,r){for(let e=this._rowElements.length;e<=r;e++){let e=this._document.createElement("div");this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>r;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,r){this._refreshRowElements(e,r),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(hW),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(hW),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,r,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,r,s),this.renderRows(0,this._bufferService.rows-1),!e||!r||(this._selectionRenderModel.update(this._terminal,e,r,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let s=e[0]>r[0];l.appendChild(this._createSelectionElement(o,s?r[0]:e[0],s?e[0]:r[0],a-o+1))}else{let s=i===o?e[0]:0,c=o===n?r[0]:this._bufferService.cols;if(l.appendChild(this._createSelectionElement(o,s,c)),l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,a-o-1)),o!==a){let e=n===a?r[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,e))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,r,s,i=1){let n=this._document.createElement("div"),o=r*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-r);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${i*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,r){let s=this._bufferService.buffer,i=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=r;c++){let e=c+s.ydisp,r=this._rowElements[c],d=s.lines.get(e);if(!r||!d)break;r.replaceChildren(...this._rowFactory.createRow(d,e,e===i,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${hO}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,r,s,i,n,o){s<0&&(e=0),i<0&&(r=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,d=Math.min(l.x,n-1),h=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let a=s;a<=i;++a){let p=a+l.ydisp,m=this._rowElements[a],g=l.lines.get(p);if(!m||!g)break;m.replaceChildren(...this._rowFactory.createRow(g,p,p===c,u,f,d,h,this.dimensions.css.cell.width,this._widthCache,o?a===s?e:0:-1,o?(a===i?r:n)-1:-1))}}};hK=lg([lv(7,lI),lv(8,lU),lv(9,lF),lv(10,lL),lv(11,lA),lv(12,lq),lv(13,lJ)],hK);var hU=class extends cs{constructor(e,r,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new cD),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new hY(this._optionsService))}catch{this._measureStrategy=this._register(new hV(e,r,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};hU=lg([lv(2,lF)],hU);var hq=class extends cs{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,r){void 0!==e&&e>0&&void 0!==r&&r>0&&(this._result.width=e,this._result.height=r)}},hV=class extends hq{constructor(e,r,s){super(),this._document=e,this._parentElement=r,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},hY=class extends hq{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let r=this._ctx.measureText("W");if(!("width"in r&&"fontBoundingBoxAscent"in r&&"fontBoundingBoxDescent"in r))throw Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},hX=class extends cs{constructor(e,r,s){super(),this._textarea=e,this._window=r,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new hG(this._window)),this._onDprChange=this._register(new cD),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new cD),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(cC.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(dA(this._textarea,"focus",()=>this._isFocused=!0)),this._register(dA(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},hG=class extends cs{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ci),this._onDprChange=this._register(new cD),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ce(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=dA(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},hJ=class extends cs{constructor(){super(),this.linkProviders=[],this._register(ce(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let r=this.linkProviders.indexOf(e);-1!==r&&this.linkProviders.splice(r,1)}}}};function hZ(e,r,s){let i=s.getBoundingClientRect(),n=e.getComputedStyle(s),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[r.clientX-i.left-o,r.clientY-i.top-a]}var hQ=class{constructor(e,r){this._renderService=e,this._charSizeService=r}getCoords(e,r,s,i,n){return function(e,r,s,i,n,o,a,l,c){if(!o)return;let d=hZ(e,r,s);return d[0]=Math.ceil((d[0]+(c?a/2:0))/a),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),i+ +!!c),d[1]=Math.min(Math.max(d[1],1),n),d}(window,e,r,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,r){let s=hZ(window,e,r);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};hQ=lg([lv(0,lY),lv(1,lU)],hQ);var h0=class{constructor(e,r){this._renderCallback=e,this._coreBrowserService=r,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,r,s){this._rowCount=s,e=void 0!==e?e:0,r=void 0!==r?r:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,r):r,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();let e=Math.max(this._rowStart,0),r=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,r),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},h1={},h2={getSafariVersion:()=>ue,isChromeOS:()=>uo,isFirefox:()=>h8,isIpad:()=>ur,isIphone:()=>us,isLegacyEdge:()=>h7,isLinux:()=>un,isMac:()=>ut,isNode:()=>h3,isSafari:()=>h9,isWindows:()=>ui};for(var h5 in h2)lp(h1,h5,{get:h2[h5],enumerable:!0});var h3="u">typeof lf.default&&"title"in lf.default,h4=h3?"node":navigator.userAgent,h6=h3?"node":navigator.platform,h8=h4.includes("Firefox"),h7=h4.includes("Edge"),h9=/^((?!chrome|android).)*safari/i.test(h4);function ue(){if(!h9)return 0;let e=h4.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}var ut=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(h6),ur="iPad"===h6,us="iPhone"===h6,ui=["Windows","Win16","Win32","WinCE"].includes(h6),un=h6.indexOf("Linux")>=0,uo=/\bCrOS\b/.test(h4),ua=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let r=0,s=0,i=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(r=performance.now(),this._tasks[this._i]()||this._i++,1.5*(s=Math.max(r=Math.max(1,performance.now()-r),s))>(n=e.timeRemaining())){i-r<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-r))}ms`),this._start();return}i=n}this.clear()}},ul=class extends ua{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let r=performance.now()+e;return{timeRemaining:()=>Math.max(0,r-performance.now())}}},uc=class extends ua{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ud=!h3&&"requestIdleCallback"in window?uc:ul,uh=class{constructor(){this._queue=new ud}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},uu=class extends cs{constructor(e,r,s,i,n,o,a,l,c){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new ci),this._pausedResizeTask=new uh,this._observerDisposable=this._register(new ci),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new cD),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new cD),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new cD),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new cD),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new h0((e,r)=>this._renderRows(e,r),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new uf(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ce(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,r),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,r)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,r){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});s.observe(r),this._observerDisposable.value=ce(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,r,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,r);let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),r=Math.max(r,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,r,this._rowCount)}_renderRows(e,r){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,r);e=Math.min(e,this._rowCount-1),r=Math.min(r,this._rowCount-1),this._renderer.value.renderRows(e,r),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:r}),this._onRender.fire({start:e,end:r}),this._isNextRenderRedrawOnly=!0}}resize(e,r){this._rowCount=r,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,r){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,r)):this._renderer.value.handleResize(e,r),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,r,s){this._selectionState.start=e,this._selectionState.end=r,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,r,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};uu=lg([lv(2,lF),lv(3,lU),lv(4,lA),lv(5,l$),lv(6,lL),lv(7,lq),lv(8,lJ)],uu);var uf=class{constructor(e,r,s){this._coreBrowserService=e,this._coreService=r,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,r){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,r)):(this._start=e,this._end=r,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function up(e,r,s,i){return ux(Math.abs(e-um(e,s)-(r-um(r,s)))-function(e,r,s){let i=0,n=e-um(e,s),o=r-um(r,s);for(let a=0;a<Math.abs(n-o);a++){let o="A"===function(e,r){return e>r?"A":"B"}(e,r)?-1:1;s.buffer.lines.get(n+o*a)?.isWrapped&&i++}return i}(e,r,s),uv(e>r?"A":"B",i))}function um(e,r){let s=0,i=r.buffer.lines.get(e),n=i?.isWrapped;for(;n&&e>=0&&e<r.rows;)s++,i=r.buffer.lines.get(--e),n=i?.isWrapped;return s}function ug(e,r,s,i,n,o){let a=e,l=r,c="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(c+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(c+=o.buffer.translateBufferLineToString(l,!1,0,e+1),e=a=o.cols-1,l--);return c+o.buffer.translateBufferLineToString(l,!1,e,a)}function uv(e,r){return hu.ESC+(r?"O":"[")+e}function ux(e,r){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=r;return s}var u_=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,r=this.selectionEnd;return!!e&&!!r&&(e[1]>r[1]||e[1]===r[1]&&e[0]>r[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function uy(e,r){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return r*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var ub=RegExp(" ","g"),uw=class extends cs{constructor(e,r,s,i,n,o,a,l,c){super(),this._element=e,this._screenElement=r,this._linkifier=s,this._bufferService=i,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new lR,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new cD),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new cD),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new cD),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new cD),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new u_(this._bufferService),this._activeSelectionMode=0,this._register(ce(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!!e&&!!r&&(e[0]!==r[0]||e[1]!==r[1])}get selectionText(){let e=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;if(!e||!r)return"";let s=this._bufferService.buffer,i=[];if(3===this._activeSelectionMode){if(e[0]===r[0])return"";let n=e[0]<r[0]?e[0]:r[0],o=e[0]<r[0]?r[0]:e[0];for(let a=e[1];a<=r[1];a++){let e=s.translateBufferLineToString(a,!0,n,o);i.push(e)}}else{let n=e[1]===r[1]?r[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let n=e[1]+1;n<=r[1]-1;n++){let e=s.lines.get(n),r=s.translateBufferLineToString(n,!0);e?.isWrapped?i[i.length-1]+=r:i.push(r)}if(e[1]!==r[1]){let e=s.lines.get(r[1]),n=s.translateBufferLineToString(r[1],!0,0,r[0]);e&&e.isWrapped?i[i.length-1]+=n:i.push(n)}}return i.map(e=>e.replace(ub," ")).join(ui?`\r
18
+ `:`
19
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),un&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})}_isClickInSelection(e){let r=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!s&&!!i&&!!r&&this._areCoordsInSelection(r,s,i)}isCellInSelection(e,r){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!s&&!!i&&this._areCoordsInSelection([e,r],s,i)}_areCoordsInSelection(e,r,s){return e[1]>r[1]&&e[1]<s[1]||r[1]===s[1]&&e[1]===r[1]&&e[0]>=r[0]&&e[0]<s[0]||r[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||r[1]<s[1]&&e[1]===r[1]&&e[0]>=r[0]}_selectWordAtCursor(e,r){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=uy(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return!!i&&(this._selectWordAt(i,r),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,r){this._model.clearSelection(),e=Math.max(e,0),r=Math.min(r,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,r],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let r=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(r)return r[0]--,r[1]--,r[1]+=this._bufferService.buffer.ydisp,r}_getMouseEventScrollAmount(e){let r=hZ(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return r>=0&&r<=s?0:(r>s&&(r-=s),(r=Math.min(Math.max(r,-50),50)/50)/Math.abs(r)+Math.round(14*r))}shouldForceSelection(e){return ut?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(2===e.button&&this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):1===e.detail?this._handleSingleClick(e):2===e.detail?this._handleDoubleClick(e):3===e.detail&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=3*!!this.shouldColumnSelect(e),this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let r=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);r&&r.length!==this._model.selectionStart[0]&&0===r.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let r=this._getMouseBufferCoords(e);r&&(this._activeSelectionMode=2,this._selectLineAt(r[1]))}shouldColumnSelect(e){return e.altKey&&!(ut&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let r=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let e=s.lines.get(this._model.selectionEnd[1]);e&&0===e.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}r&&r[0]===this._model.selectionEnd[0]&&r[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let r=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&r<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&void 0!==r[0]&&void 0!==r[1]){let e=function(e,r,s,i){var n,o,a,l,c,d,h,u,f,p,m,g,v,x,_,y,b,w;let S,C=s.buffer.x,k=s.buffer.y;if(!s.buffer.hasScrollback){let b,w,S;return n=C,a=0,(0===up(o=k,r,l=s,c=i).length?"":ux(ug(n,o,n,o-um(o,l),!1,l).length,uv("D",c)))+up(k,r,s,i)+(d=C,h=k,u=e,b=up(h,f=r,p=s,m=i).length>0?f-um(f,p):h,S=(g=d,v=h,w=up(x=u,_=f,y=p,m).length>0?_-um(_,y):v,g<x&&w<=_||g>=x&&w<_?"C":"D"),ux(ug(d,b,u,f,"C"===S,p).length,uv(S,m)))}if(k===r)return S=C>e?"D":"C",ux(Math.abs(C-e),uv(S,i));S=k>r?"D":"C";let j=Math.abs(k-r);return ux((b=k>r?e:C,s.cols-b+(j-1)*s.cols+1+(w=0,(k>r?C:e)-1)),uv(S,i))}(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,r=this._model.finalSelectionEnd,s=!!e&&!!r&&(e[0]!==r[0]||e[1]!==r[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,r,s);return}!e||!r||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&r[0]===this._oldSelectionEnd[0]&&r[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,r,s)}_fireOnSelectionChange(e,r,s){this._oldSelectionStart=e,this._oldSelectionEnd=r,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,r){let s=r;for(let i=0;r>=i;i++){let n=e.loadCell(i,this._workCell).getChars().length;0===this._workCell.getWidth()?s--:n>1&&r!==i&&(s+=n-1)}return s}setSelection(e,r,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,r],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,r,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),c=l,d=e[0]-l,h=0,u=0,f=0,p=0;if(" "===a.charAt(l)){for(;l>0&&" "===a.charAt(l-1);)l--;for(;c<a.length&&" "===a.charAt(c+1);)c++}else{let r=e[0],s=e[0];0===o.getWidth(r)&&(h++,r--),2===o.getWidth(s)&&(u++,s++);let i=o.getString(s).length;for(i>1&&(p+=i-1,c+=i-1);r>0&&l>0&&!this._isCharWordSeparator(o.loadCell(r-1,this._workCell));){o.loadCell(r-1,this._workCell);let e=this._workCell.getChars().length;0===this._workCell.getWidth()?(h++,r--):e>1&&(f+=e-1,l-=e-1),l--,r--}for(;s<o.length&&c+1<a.length&&!this._isCharWordSeparator(o.loadCell(s+1,this._workCell));){o.loadCell(s+1,this._workCell);let e=this._workCell.getChars().length;2===this._workCell.getWidth()?(u++,s++):e>1&&(p+=e-1,c+=e-1),c++,s++}}c++;let m=l+d-h+f,g=Math.min(this._bufferService.cols,c-l+h+u-f-p);if(!(!r&&""===a.slice(l,c).trim())){if(s&&0===m&&32!==o.getCodePoint(0)){let r=n.lines.get(e[1]-1);if(r&&o.isWrapped&&32!==r.getCodePoint(this._bufferService.cols-1)){let r=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(r){let e=this._bufferService.cols-r.start;m-=e,g+=e}}}if(i&&m+g===this._bufferService.cols&&32!==o.getCodePoint(this._bufferService.cols-1)){let r=n.lines.get(e[1]+1);if(r?.isWrapped&&32!==r.getCodePoint(0)){let r=this._getWordAt([0,e[1]+1],!1,!1,!0);r&&(g+=r.length)}}return{start:m,length:g}}}_selectWordAt(e,r){let s=this._getWordAt(e,r);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let r=this._getWordAt(e,!0);if(r){let s=e[1];for(;r.start<0;)r.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;r.start+r.length>this._bufferService.cols;)r.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?r.start:r.start+r.length,s]}}_isCharWordSeparator(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let r=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:r.first},end:{x:this._bufferService.cols-1,y:r.last}};this._model.selectionStart=[0,r.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=uy(s,this._bufferService.cols)}};uw=lg([lv(3,lL),lv(4,lA),lv(5,lV),lv(6,lF),lv(7,lY),lv(8,lq)],uw);var uS=class{constructor(){this._data={}}set(e,r,s){this._data[e]||(this._data[e]={}),this._data[e][r]=s}get(e,r){return this._data[e]?this._data[e][r]:void 0}clear(){this._data={}}},uC=class{constructor(){this._color=new uS,this._css=new uS}setCss(e,r,s){this._css.set(e,r,s)}getCss(e,r){return this._css.get(e,r)}setColor(e,r,s){this._color.set(e,r,s)}getColor(e,r){return this._color.get(e,r)}clear(){this._color.clear(),this._css.clear()}},uk=Object.freeze((()=>{let e=[u8.toColor("#2e3436"),u8.toColor("#cc0000"),u8.toColor("#4e9a06"),u8.toColor("#c4a000"),u8.toColor("#3465a4"),u8.toColor("#75507b"),u8.toColor("#06989a"),u8.toColor("#d3d7cf"),u8.toColor("#555753"),u8.toColor("#ef2929"),u8.toColor("#8ae234"),u8.toColor("#fce94f"),u8.toColor("#729fcf"),u8.toColor("#ad7fa8"),u8.toColor("#34e2e2"),u8.toColor("#eeeeec")],r=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=r[s/36%6|0],n=r[s/6%6|0],o=r[s%6];e.push({css:hm.toCss(i,n,o),rgba:hm.toRgba(i,n,o)})}for(let r=0;r<24;r++){let s=8+10*r;e.push({css:hm.toCss(s,s,s),rgba:hm.toRgba(s,s,s)})}return e})()),uj=u8.toColor("#ffffff"),uN=u8.toColor("#000000"),uE=u8.toColor("#ffffff"),uR={css:"rgba(255, 255, 255, 0.3)",rgba:0xffffff4d},uM=class extends cs{constructor(e){super(),this._optionsService=e,this._contrastCache=new uC,this._halfContrastCache=new uC,this._onChangeColors=this._register(new cD),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:uj,background:uN,cursor:uE,cursorAccent:uN,selectionForeground:void 0,selectionBackgroundTransparent:uR,selectionBackgroundOpaque:u6.blend(uN,uR),selectionInactiveBackgroundTransparent:uR,selectionInactiveBackgroundOpaque:u6.blend(uN,uR),scrollbarSliderBackground:u6.opacity(uj,.2),scrollbarSliderHoverBackground:u6.opacity(uj,.4),scrollbarSliderActiveBackground:u6.opacity(uj,.5),overviewRulerBorder:uj,ansi:uk.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let r=this._colors;if(r.foreground=uD(e.foreground,uj),r.background=uD(e.background,uN),r.cursor=u6.blend(r.background,uD(e.cursor,uE)),r.cursorAccent=u6.blend(r.background,uD(e.cursorAccent,uN)),r.selectionBackgroundTransparent=uD(e.selectionBackground,uR),r.selectionBackgroundOpaque=u6.blend(r.background,r.selectionBackgroundTransparent),r.selectionInactiveBackgroundTransparent=uD(e.selectionInactiveBackground,r.selectionBackgroundTransparent),r.selectionInactiveBackgroundOpaque=u6.blend(r.background,r.selectionInactiveBackgroundTransparent),r.selectionForeground=e.selectionForeground?uD(e.selectionForeground,hy):void 0,r.selectionForeground===hy&&(r.selectionForeground=void 0),u6.isOpaque(r.selectionBackgroundTransparent)&&(r.selectionBackgroundTransparent=u6.opacity(r.selectionBackgroundTransparent,.3)),u6.isOpaque(r.selectionInactiveBackgroundTransparent)&&(r.selectionInactiveBackgroundTransparent=u6.opacity(r.selectionInactiveBackgroundTransparent,.3)),r.scrollbarSliderBackground=uD(e.scrollbarSliderBackground,u6.opacity(r.foreground,.2)),r.scrollbarSliderHoverBackground=uD(e.scrollbarSliderHoverBackground,u6.opacity(r.foreground,.4)),r.scrollbarSliderActiveBackground=uD(e.scrollbarSliderActiveBackground,u6.opacity(r.foreground,.5)),r.overviewRulerBorder=uD(e.overviewRulerBorder,uj),r.ansi=uk.slice(),r.ansi[0]=uD(e.black,uk[0]),r.ansi[1]=uD(e.red,uk[1]),r.ansi[2]=uD(e.green,uk[2]),r.ansi[3]=uD(e.yellow,uk[3]),r.ansi[4]=uD(e.blue,uk[4]),r.ansi[5]=uD(e.magenta,uk[5]),r.ansi[6]=uD(e.cyan,uk[6]),r.ansi[7]=uD(e.white,uk[7]),r.ansi[8]=uD(e.brightBlack,uk[8]),r.ansi[9]=uD(e.brightRed,uk[9]),r.ansi[10]=uD(e.brightGreen,uk[10]),r.ansi[11]=uD(e.brightYellow,uk[11]),r.ansi[12]=uD(e.brightBlue,uk[12]),r.ansi[13]=uD(e.brightMagenta,uk[13]),r.ansi[14]=uD(e.brightCyan,uk[14]),r.ansi[15]=uD(e.brightWhite,uk[15]),e.extendedAnsi){let s=Math.min(r.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)r.ansi[i+16]=uD(e.extendedAnsi[i],uk[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(void 0===e){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function uD(e,r){if(void 0!==e)try{return u8.toColor(e)}catch{}return r}uM=lg([lv(0,lF)],uM);var uT=class{constructor(...e){for(let[r,s]of(this._entries=new Map,e))this.set(r,s)}set(e,r){let s=this._entries.get(e);return this._entries.set(e,r),s}forEach(e){for(let[r,s]of this._entries.entries())e(r,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},uP=class{constructor(){this._services=new uT,this._services.set(lI,this)}setService(e,r){this._services.set(e,r)}getService(e){return this._services.get(e)}createInstance(e,...r){let s=(e[lD]||[]).sort((e,r)=>e.index-r.index),i=[];for(let r of s){let s=this._services.get(r.id);if(!s)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${r.id._id}.`);i.push(s)}let n=s.length>0?s[0].index:r.length;if(r.length!==n)throw Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${r.length} static arguments`);return new e(...r,...i)}},uL={trace:0,debug:1,info:2,warn:3,error:4,off:5},uB=class extends cs{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=uL[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let r=0;r<e.length;r++)"function"==typeof e[r]&&(e[r]=e[r]())}_log(e,r,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+r,...s)}trace(e,...r){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,r)}debug(e,...r){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,r)}info(e,...r){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,r)}warn(e,...r){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,r)}error(e,...r){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,r)}};uB=lg([lv(0,lF)],uB);var uA=class extends cs{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new cD),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new cD),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new cD),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let r=Array(e);for(let s=0;s<Math.min(e,this.length);s++)r[s]=this._array[this._getCyclicIndex(s)];this._array=r,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let r=this._length;r<e;r++)this._array[r]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,r){this._array[this._getCyclicIndex(e)]=r}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,r,...s){if(r){for(let s=e;s<this._length-r;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+r)];this._length-=r,this.onDeleteEmitter.fire({index:e,amount:r})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<s.length;r++)this._array[this._getCyclicIndex(e+r)]=s[r];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let e=this._length+s.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,r,s){if(!(r<=0)){if(e<0||e>=this._length)throw Error("start argument out of range");if(e+s<0)throw Error("Cannot shift elements in list beyond index 0");if(s>0){for(let i=r-1;i>=0;i--)this.set(e+i+s,this.get(e+i));let i=e+r+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<r;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},uO=Object.freeze(new lN),uI=0,uz=class e{constructor(e,r,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let i=r||lR.fromCharData([0,"",1,0]);for(let r=0;r<e;++r)this.setCell(r,i);this.length=e}get(e){let r=this._data[3*e+0],s=2097151&r;return[this._data[3*e+1],2097152&r?this._combined[e]:s?lS(s):"",r>>22,2097152&r?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,r){this._data[3*e+1]=r[0],r[1].length>1?(this._combined[e]=r[1],this._data[3*e+0]=2097152|e|r[2]<<22):this._data[3*e+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 0xc00000&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let r=this._data[3*e+0];return 2097152&r?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&r}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let r=this._data[3*e+0];return 2097152&r?this._combined[e]:2097151&r?lS(2097151&r):""}isProtected(e){return 0x20000000&this._data[3*e+2]}loadCell(e,r){return uI=3*e,r.content=this._data[uI+0],r.fg=this._data[uI+1],r.bg=this._data[uI+2],2097152&r.content&&(r.combinedData=this._combined[e]),0x10000000&r.bg&&(r.extended=this._extendedAttrs[e]),r}setCell(e,r){2097152&r.content&&(this._combined[e]=r.combinedData),0x10000000&r.bg&&(this._extendedAttrs[e]=r.extended),this._data[3*e+0]=r.content,this._data[3*e+1]=r.fg,this._data[3*e+2]=r.bg}setCellFromCodepoint(e,r,s,i){0x10000000&i.bg&&(this._extendedAttrs[e]=i.extended),this._data[3*e+0]=r|s<<22,this._data[3*e+1]=i.fg,this._data[3*e+2]=i.bg}addCodepointToCell(e,r,s){let i=this._data[3*e+0];2097152&i?this._combined[e]+=lS(r):2097151&i?(this._combined[e]=lS(2097151&i)+lS(r),i&=-2097152,i|=2097152):i=4194304|r,s&&(i&=-0xc00001,i|=s<<22),this._data[3*e+0]=i}insertCells(e,r,s){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length-e){let i=new lR;for(let s=this.length-e-r-1;s>=0;--s)this.setCell(e+r+s,this.loadCell(e+s,i));for(let i=0;i<r;++i)this.setCell(e+i,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,r,s){if(e%=this.length,r<this.length-e){let i=new lR;for(let s=0;s<this.length-e-r;++s)this.setCell(e+s,this.loadCell(e+r+s,i));for(let e=this.length-r;e<this.length;++e)this.setCell(e,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),0!==this.getWidth(e)||this.hasContent(e)||this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,r,s,i=!1){if(i){for(e&&2===this.getWidth(e-1)&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length&&2===this.getWidth(r-1)&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,s);e<r&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length&&2===this.getWidth(r-1)&&this.setCellFromCodepoint(r,0,1,s);e<r&&e<this.length;)this.setCell(e++,s)}resize(e,r){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let s=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*s)this._data=new Uint32Array(this._data.buffer,0,s);else{let e=new Uint32Array(s);e.set(this._data),this._data=e}for(let s=this.length;s<e;++s)this.setCell(s,r)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let s=0;s<r.length;s++){let i=parseInt(r[s],10);i>=e&&delete this._combined[i]}let i=Object.keys(this._extendedAttrs);for(let r=0;r<i.length;r++){let s=parseInt(i[r],10);s>=e&&delete this._extendedAttrs[s]}}return this.length=e,4*s*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,r=!1){if(r){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,e);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,e)}copyFrom(e){for(let r in this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={},e._combined)this._combined[r]=e._combined[r];for(let r in this._extendedAttrs={},e._extendedAttrs)this._extendedAttrs[r]=e._extendedAttrs[r];this.isWrapped=e.isWrapped}clone(){let r=new e(0);for(let e in r._data=new Uint32Array(this._data),r.length=this.length,this._combined)r._combined[e]=this._combined[e];for(let e in this._extendedAttrs)r._extendedAttrs[e]=this._extendedAttrs[e];return r.isWrapped=this.isWrapped,r}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||0x3000000&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,r,s,i,n){let o=e._data;if(n)for(let n=i-1;n>=0;n--){for(let e=0;e<3;e++)this._data[(s+n)*3+e]=o[(r+n)*3+e];0x10000000&o[(r+n)*3+2]&&(this._extendedAttrs[s+n]=e._extendedAttrs[r+n])}else for(let n=0;n<i;n++){for(let e=0;e<3;e++)this._data[(s+n)*3+e]=o[(r+n)*3+e];0x10000000&o[(r+n)*3+2]&&(this._extendedAttrs[s+n]=e._extendedAttrs[r+n])}let a=Object.keys(e._combined);for(let i=0;i<a.length;i++){let n=parseInt(a[i],10);n>=r&&(this._combined[n-r+s]=e._combined[n])}}translateToString(e,r,s,i){r=r??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),i&&(i.length=0);let n="";for(;r<s;){let e=this._data[3*r+0],s=2097151&e,o=2097152&e?this._combined[r]:s?lS(s):" ";if(n+=o,i)for(let e=0;e<o.length;++e)i.push(r);r+=e>>22||1}return i&&i.push(r),n}};function uF(e,r,s){if(r===e.length-1)return e[r].getTrimmedLength();let i=!e[r].hasContent(s-1)&&1===e[r].getWidth(s-1),n=2===e[r+1].getWidth(0);return i&&n?s-1:s}var uW=class e{constructor(r){this.line=r,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new cD),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),l9(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};uW._nextId=1;var uH={},u$=uH.B;uH[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},uH.A={"#":"£"},uH.B=void 0,uH[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},uH.C=uH[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},uH.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},uH.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},uH.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},uH.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},uH.E=uH[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},uH.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},uH.H=uH[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},uH["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var uK=class{constructor(e,r,s){this._hasScrollback=e,this._optionsService=r,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=uO.clone(),this.savedCharset=u$,this.markers=[],this._nullCell=lR.fromCharData([0,"",1,0]),this._whitespaceCell=lR.fromCharData([0," ",1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ud,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new uA(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new lE),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new lE),this._whitespaceCell}getBlankLine(e,r){return new uz(this._bufferService.cols,this.getNullCell(e),r)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let r=e+this._optionsService.rawOptions.scrollback;return r>0xffffffff?0xffffffff:r}fillViewportRows(e){if(0===this.lines.length){void 0===e&&(e=uO);let r=this._rows;for(;r--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new uA(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,r){let s=this.getNullCell(uO),i=0,n=this._getCorrectBufferLength(r);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let r=0;r<this.lines.length;r++)i+=+this.lines.get(r).resize(e,s);let o=0;if(this._rows<r)for(let i=this._rows;i<r;i++)this.lines.length<r+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new uz(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new uz(e,s)));else for(let e=this._rows;e>r;e--)this.lines.length>r+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let e=this.lines.length-n;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,r-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=r-1,this._isReflowEnabled&&(this._reflow(e,r),this._cols>e))for(let r=0;r<this.lines.length;r++)i+=+this.lines.get(r).resize(e,s);this._cols=e,this._rows=r,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let r=0;for(;this._memoryCleanupPosition<this.lines.length;)if((r+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory())>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&"conpty"===e.backend&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,r){this._cols!==e&&(e>this._cols?this._reflowLarger(e,r):this._reflowSmaller(e,r))}_reflowLarger(e,r){let s=this._optionsService.rawOptions.reflowCursorLine,i=function(e,r,s,i,n,o){let a=[];for(let l=0;l<e.length-1;l++){let c=l,d=e.get(++c);if(!d.isWrapped)continue;let h=[e.get(l)];for(;c<e.length&&d.isWrapped;)h.push(d),d=e.get(++c);if(!o&&i>=l&&i<c){l+=h.length-1;continue}let u=0,f=uF(h,0,r),p=1,m=0;for(;p<h.length;){let e=uF(h,p,r),i=Math.min(e-m,s-f);h[u].copyCellsFrom(h[p],m,f,i,!1),(f+=i)===s&&(u++,f=0),(m+=i)===e&&(p++,m=0),0===f&&0!==u&&2===h[u-1].getWidth(s-1)&&(h[u].copyCellsFrom(h[u-1],s-1,f++,1,!1),h[u-1].setCell(s-1,n))}h[u].replaceCells(f,s,n);let g=0;for(let e=h.length-1;e>0&&(e>u||0===h[e].getTrimmedLength());e--)g++;g>0&&(a.push(l+h.length-g),a.push(g)),l+=h.length-1}return a}(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(uO),s);if(i.length>0){let s=function(e,r){let s=[],i=0,n=r[0],o=0;for(let a=0;a<e.length;a++)if(n===a){let s=r[++i];e.onDeleteEmitter.fire({index:a-o,amount:s}),a+=s-1,o+=s,n=r[++i]}else s.push(a);return{layout:s,countRemoved:o}}(this.lines,i);(function(e,r){let s=[];for(let i=0;i<r.length;i++)s.push(e.get(r[i]));for(let r=0;r<s.length;r++)e.set(r,s[r]);e.length=r.length})(this.lines,s.layout),this._reflowLargerAdjustViewport(e,r,s.countRemoved)}}_reflowLargerAdjustViewport(e,r,s){let i=this.getNullCell(uO),n=s;for(;n-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<r&&this.lines.push(new uz(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,r){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(uO),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let c=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),c.unshift(l);if(!s){let e=this.ybase+this.y;if(e>=a&&e<a+c.length)continue}let d=c[c.length-1].getTrimmedLength(),h=function(e,r,s){let i=[],n=e.map((s,i)=>uF(e,i,r)).reduce((e,r)=>e+r),o=0,a=0,l=0;for(;l<n;){if(n-l<s){i.push(n-l);break}o+=s;let c=uF(e,a,r);o>c&&(o-=c,a++);let d=2===e[a].getWidth(o-1);d&&o--;let h=d?s-1:s;i.push(h),l+=h}return i}(c,this._cols,e),u=h.length-c.length,f;f=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+u):Math.max(0,this.lines.length-this.lines.maxLength+u);let p=[];for(let e=0;e<u;e++){let e=this.getBlankLine(uO,!0);p.push(e)}p.length>0&&(n.push({start:a+c.length+o,newLines:p}),o+=p.length),c.push(...p);let m=h.length-1,g=h[m];0===g&&(g=h[--m]);let v=c.length-u-1,x=d;for(;v>=0;){let e=Math.min(x,g);if(void 0===c[m])break;c[m].copyCellsFrom(c[v],x-e,g-e,e,!0),0==(g-=e)&&(g=h[--m]),0==(x-=e)&&(x=uF(c,Math.max(--v,0),this._cols))}for(let r=0;r<c.length;r++)h[r]<e&&c[r].setCell(h[r],i);let _=u-f;for(;_-- >0;)0===this.ybase?this.y<r-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-r&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+r-1)}if(n.length>0){let e=[],r=[];for(let e=0;e<this.lines.length;e++)r.push(this.lines.get(e));let s=this.lines.length,i=s-1,a=0,l=n[0];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let c=0;for(let d=Math.min(this.lines.maxLength-1,s+o-1);d>=0;d--)if(l&&l.start>i+c){for(let e=l.newLines.length-1;e>=0;e--)this.lines.set(d--,l.newLines[e]);d++,e.push({index:i+1,amount:l.newLines.length}),c+=l.newLines.length,l=n[++a]}else this.lines.set(d,r[i--]);let d=0;for(let r=e.length-1;r>=0;r--)e[r].index+=d,this.lines.onInsertEmitter.fire(e[r]),d+=e[r].amount;let h=Math.max(0,s+o-this.lines.maxLength);h>0&&this.lines.onTrimEmitter.fire(h)}}translateBufferLineToString(e,r,s=0,i){let n=this.lines.get(e);return n?n.translateToString(r,s,i):""}getWrappedRangeForLine(e){let r=e,s=e;for(;r>0&&this.lines.get(r).isWrapped;)r--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:r,last:s}}setupTabStops(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let r=0;r<this.markers.length;r++)this.markers[r].line===e&&(this.markers[r].dispose(),this.markers.splice(r--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let r=new uW(e);return this.markers.push(r),r.register(this.lines.onTrim(e=>{r.line-=e,r.line<0&&r.dispose()})),r.register(this.lines.onInsert(e=>{r.line>=e.index&&(r.line+=e.amount)})),r.register(this.lines.onDelete(e=>{r.line>=e.index&&r.line<e.index+e.amount&&r.dispose(),r.line>e.index&&(r.line-=e.amount)})),r.register(r.onDispose(()=>this._removeMarker(r))),r}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},uU=class extends cs{constructor(e,r){super(),this._optionsService=e,this._bufferService=r,this._onBufferActivate=this._register(new cD),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new uK(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new uK(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,r){this._normal.resize(e,r),this._alt.resize(e,r),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},uq=class extends cs{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new cD),this.onResize=this._onResize.event,this._onScroll=this._register(new cD),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,2),this.rows=Math.max(e.rawOptions.rows||0,1),this.buffers=this._register(new uU(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,r){let s=this.cols!==e,i=this.rows!==r;this.cols=e,this.rows=r,this.buffers.resize(e,r),this._onResize.fire({cols:e,rows:r,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,r=!1){let s=this.buffer,i;(i=this._cachedBlankLine)&&i.length===this.cols&&i.getFg(0)===e.fg&&i.getBg(0)===e.bg||(i=s.getBlankLine(e,r),this._cachedBlankLine=i),i.isWrapped=r;let n=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(0===s.scrollTop){let e=s.lines.isFull;o===s.lines.length-1?e?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),e?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let e=o-n+1;s.lines.shiftElements(n+1,e-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,r){let s=this.buffer;if(e<0){if(0===s.ydisp)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(r||this._onScroll.fire(s.ydisp))}};uq=lg([lv(0,lF)],uq);var uV={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:ut,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},uY=["normal","bold","100","200","300","400","500","600","700","800","900"],uX=class extends cs{constructor(e){super(),this._onOptionChange=this._register(new cD),this.onOptionChange=this._onOptionChange.event;let r={...uV};for(let s in e)if(s in r)try{let i=e[s];r[s]=this._sanitizeAndValidateOption(s,i)}catch(e){console.error(e)}this.rawOptions=r,this.options={...r},this._setupOptions(),this._register(ce(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,r){return this.onOptionChange(s=>{s===e&&r(this.rawOptions[e])})}onMultipleOptionChange(e,r){return this.onOptionChange(s=>{-1!==e.indexOf(s)&&r()})}_setupOptions(){let e=e=>{if(!(e in uV))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},r=(e,r)=>{if(!(e in uV))throw Error(`No option with key "${e}"`);r=this._sanitizeAndValidateOption(e,r),this.rawOptions[e]!==r&&(this.rawOptions[e]=r,this._onOptionChange.fire(e))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:r.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,r){switch(e){case"cursorStyle":var s;if(r||(r=uV[e]),"block"!==(s=r)&&"underline"!==s&&"bar"!==s)throw Error(`"${r}" is not a valid value for ${e}`);break;case"wordSeparator":r||(r=uV[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof r&&1<=r&&r<=1e3)break;r=uY.includes(r)?r:uV[e];break;case"cursorWidth":r=Math.floor(r);case"lineHeight":case"tabStopWidth":if(r<1)throw Error(`${e} cannot be less than 1, value: ${r}`);break;case"minimumContrastRatio":r=Math.max(1,Math.min(21,Math.round(10*r)/10));break;case"scrollback":if((r=Math.min(r,0xffffffff))<0)throw Error(`${e} cannot be less than 0, value: ${r}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(r<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${r}`);break;case"rows":case"cols":if(!r&&0!==r)throw Error(`${e} must be numeric, value: ${r}`);break;case"windowsPty":r=r??{}}return r}};function uG(e,r=5){if("object"!=typeof e)return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=r<=1?e[i]:e[i]&&uG(e[i],r-1);return s}var uJ=Object.freeze({insertMode:!1}),uZ=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),uQ=class extends cs{constructor(e,r,s){super(),this._bufferService=e,this._logService=r,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new cD),this.onData=this._onData.event,this._onUserInput=this._register(new cD),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new cD),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new cD),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=uG(uJ),this.decPrivateModes=uG(uZ)}reset(){this.modes=uG(uJ),this.decPrivateModes=uG(uZ)}triggerDataEvent(e,r=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;r&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),r&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};uQ=lg([lv(0,lL),lv(1,lz),lv(2,lF)],uQ);var u0={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>32!==e.action},DRAG:{events:23,restrict:e=>32!==e.action||3!==e.button},ANY:{events:31,restrict:e=>!0}};function u1(e,r){let s=16*!!e.ctrl|4*!!e.shift|8*!!e.alt;return 4===e.button?(s|=64,s|=e.action):(s|=3&e.button,4&e.button&&(s|=64),8&e.button&&(s|=128),32===e.action?s|=32:0!==e.action||r||(s|=3)),s}var u2=String.fromCharCode,u5={DEFAULT:e=>{let r=[u1(e,!1)+32,e.col+32,e.row+32];return r[0]>255||r[1]>255||r[2]>255?"":`\x1b[M${u2(r[0])}${u2(r[1])}${u2(r[2])}`},SGR:e=>{let r=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${u1(e,!0)};${e.col};${e.row}${r}`},SGR_PIXELS:e=>{let r=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${u1(e,!0)};${e.x};${e.y}${r}`}},u3=class extends cs{constructor(e,r,s){for(let i of(super(),this._bufferService=e,this._coreService=r,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new cD),this.onProtocolChange=this._onProtocolChange.event,Object.keys(u0)))this.addProtocol(i,u0[i]);for(let e of Object.keys(u5))this.addEncoding(e,u5[e]);this.reset()}addProtocol(e,r){this._protocols[e]=r}addEncoding(e,r){this._encodings[e]=r}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,r,s){if(0===e.deltaY||e.shiftKey||void 0===r||void 0===s)return 0;let i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r/s+0,50>Math.abs(e.deltaY)&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,r){return r.altKey||r.ctrlKey||r.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||4===e.button&&32===e.action||3===e.button&&32!==e.action||4!==e.button&&(2===e.action||3===e.action)||(e.col++,e.row++,32===e.action&&this._lastEvent&&this._equalEvents(this._lastEvent,e,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(e))return!1;let r=this._encodings[this._activeEncoding](e);return r&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(r):this._coreService.triggerDataEvent(r,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,r,s){if(s){if(e.x!==r.x||e.y!==r.y)return!1}else if(e.col!==r.col||e.row!==r.row)return!1;return e.button===r.button&&e.action===r.action&&e.ctrl===r.ctrl&&e.alt===r.alt&&e.shift===r.shift}};u3=lg([lv(0,lL),lv(1,lA),lv(2,lF)],u3);var u4,u6,u8,u7,u9,fe,ft=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],fr=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],fs=class{constructor(){if(this.version="6",!fe){(fe=new Uint8Array(65536)).fill(1),fe[0]=0,fe.fill(0,1,32),fe.fill(0,127,160),fe.fill(2,4352,4448),fe[9001]=2,fe[9002]=2,fe.fill(2,11904,42192),fe[12351]=1,fe.fill(2,44032,55204),fe.fill(2,63744,64256),fe.fill(2,65040,65050),fe.fill(2,65072,65136),fe.fill(2,65280,65377),fe.fill(2,65504,65511);for(let e=0;e<ft.length;++e)fe.fill(0,ft[e][0],ft[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?fe[e]:!function(e,r){let s=0,i=r.length-1,n;if(e<r[0][0]||e>r[i][1])return!1;for(;i>=s;)if(e>r[n=s+i>>1][1])s=n+1;else{if(!(e<r[n][0]))return!0;i=n-1}return!1}(e,fr)?e>=131072&&e<=196605||e>=196608&&e<=262141?2:1:0}charProperties(e,r){let s=this.wcwidth(e),i=0===s&&0!==r;if(i){let e=fi.extractWidth(r);0===e?i=!1:e>s&&(s=e)}return fi.createPropertyValue(0,s,i)}},fi=class e{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new cD,this.onChange=this._onChange.event;let e=new fs;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,r,s=!1){return(0xffffff&e)<<3|(3&r)<<1|!!s}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(r){let s=0,i=0,n=r.length;for(let o=0;o<n;++o){let a=r.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return s+this.wcwidth(a);let e=r.charCodeAt(o);56320<=e&&e<=57343?a=(a-55296)*1024+e-56320+65536:s+=this.wcwidth(e)}let l=this.charProperties(a,i),c=e.extractWidth(l);e.extractShouldJoin(l)&&(c-=e.extractWidth(i)),s+=c,i=l}return s}charProperties(e,r){return this._activeProvider.charProperties(e,r)}},fn=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,r){this._charsets[e]=r,this.glevel===e&&(this.charset=r)}};function fo(e){let r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&r&&(s.isWrapped=0!==r[3]&&32!==r[3])}var fa=class e{constructor(e=32,r=32){if(this.maxLength=e,this.maxSubParamsLength=r,r>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(r){let s=new e;if(!r.length)return s;for(let e=+!!Array.isArray(r[0]);e<r.length;++e){let i=r[e];if(Array.isArray(i))for(let e=0;e<i.length;++e)s.addSubParam(i[e]);else s.addParam(i)}return s}clone(){let r=new e(this.maxLength,this.maxSubParamsLength);return r.params.set(this.params),r.length=this.length,r._subParams.set(this._subParams),r._subParamsLength=this._subParamsLength,r._subParamsIdx.set(this._subParamsIdx),r._rejectDigits=this._rejectDigits,r._rejectSubDigits=this._rejectSubDigits,r._digitIsSub=this._digitIsSub,r}toArray(){let e=[];for(let r=0;r<this.length;++r){e.push(this.params[r]);let s=this._subParamsIdx[r]>>8,i=255&this._subParamsIdx[r];i-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,i))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>0x7fffffff?0x7fffffff:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>0x7fffffff?0x7fffffff:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let r=this._subParamsIdx[e]>>8,s=255&this._subParamsIdx[e];return s-r>0?this._subParams.subarray(r,s):null}getSubParamsAll(){let e={};for(let r=0;r<this.length;++r){let s=this._subParamsIdx[r]>>8,i=255&this._subParamsIdx[r];i-s>0&&(e[r]=this._subParams.slice(s,i))}return e}addDigit(e){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,i=s[r-1];s[r-1]=~i?Math.min(10*i+e,0x7fffffff):e}},fl=[],fc=class{constructor(){this._state=0,this._active=fl,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,r){void 0===this._handlers[e]&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(r),{dispose:()=>{let e=s.indexOf(r);-1!==e&&s.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=fl}reset(){if(2===this._state)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=fl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||fl,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")}_put(e,r,s){if(this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,r,s);else this._handlerFb(this._id,"PUT",lC(e,r,s))}start(){this.reset(),this._state=1}put(e,r,s){if(3!==this._state){if(1===this._state)for(;r<s;){let s=e[r++];if(59===s){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}-1===this._id&&(this._id=0),this._id=10*this._id+s-48}2===this._state&&s-r>0&&this._put(e,r,s)}}end(e,r=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=r,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===s){for(;i>=0&&!0!==(s=this._active[i].end(e));i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if((s=this._active[i].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}else this._handlerFb(this._id,"END",e);this._active=fl,this._id=-1,this._state=0}}},fd=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,r,s){this._hitLimit||(this._data+=lC(e,r,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data))instanceof Promise)return r.then(e=>(this._data="",this._hitLimit=!1,e));return this._data="",this._hitLimit=!1,r}},fh=[],fu=class{constructor(){this._handlers=Object.create(null),this._active=fh,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=fh}registerHandler(e,r){void 0===this._handlers[e]&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(r),{dispose:()=>{let e=s.indexOf(r);-1!==e&&s.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=fh,this._ident=0}hook(e,r){if(this.reset(),this._ident=e,this._active=this._handlers[e]||fh,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(r);else this._handlerFb(this._ident,"HOOK",r)}put(e,r,s){if(this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,r,s);else this._handlerFb(this._ident,"PUT",lC(e,r,s))}unhook(e,r=!0){if(this._active.length){let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=r,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===s){for(;i>=0&&!0!==(s=this._active[i].unhook(e));i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if((s=this._active[i].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}else this._handlerFb(this._ident,"UNHOOK",e);this._active=fh,this._ident=0}},ff=new fa;ff.addParam(0);var fp=class{constructor(e){this._handler=e,this._data="",this._params=ff,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ff,this._data="",this._hitLimit=!1}put(e,r,s){this._hitLimit||(this._data+=lC(e,r,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data,this._params))instanceof Promise)return r.then(e=>(this._params=ff,this._data="",this._hitLimit=!1,e));return this._params=ff,this._data="",this._hitLimit=!1,r}},fm=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,r){this.table.fill(e<<4|r)}add(e,r,s,i){this.table[r<<8|e]=s<<4|i}addMany(e,r,s,i){for(let n=0;n<e.length;n++)this.table[r<<8|e[n]]=s<<4|i}},fg=function(){let e=new fm(4095),r=Array.apply(null,Array(256)).map((e,r)=>r),s=(e,s)=>r.slice(e,s),i=s(32,127),n=s(0,24);n.push(25),n.push.apply(n,s(28,32));let o=s(0,14),a;for(a in e.setDefault(1,0),e.addMany(i,0,2,0),o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}(),fv=class extends cs{constructor(e=fg){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new fa,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,r,s)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,r)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ce(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new fc),this._dcsParser=this._register(new fu),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,r=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw Error("only one byte as prefix supported");if((s=e.prefix.charCodeAt(0))&&60>s||s>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let i=e.intermediates.charCodeAt(r);if(32>i||i>47)throw Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=i}}if(1!==e.final.length)throw Error("final must be a single byte");let i=e.final.charCodeAt(0);if(r[0]>i||i>r[1])throw Error(`final must be in range ${r[0]} .. ${r[1]}`);return s<<=8,s|=i}identToString(e){let r=[];for(;e;)r.push(String.fromCharCode(255&e)),e>>=8;return r.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,r){let s=this._identifier(e,[48,126]);void 0===this._escHandlers[s]&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(r),{dispose:()=>{let e=i.indexOf(r);-1!==e&&i.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,r){this._executeHandlers[e.charCodeAt(0)]=r}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,r){let s=this._identifier(e);void 0===this._csiHandlers[s]&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(r),{dispose:()=>{let e=i.indexOf(r);-1!==e&&i.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,r){return this._dcsParser.registerHandler(this._identifier(e),r)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,r){return this._oscParser.registerHandler(e,r)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,r,s,i,n){this._parseStack.state=e,this._parseStack.handlers=r,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=n}parse(e,r,s){let i=0,n=0,o=0,a;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(void 0===s||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let r=this._parseStack.handlers,n=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===s&&n>-1){for(;n>=0&&!0!==(a=r[n](this._params));n--)if(a instanceof Promise)return this._parseStack.handlerPos=n,a}this._parseStack.handlers=[];break;case 4:if(!1===s&&n>-1){for(;n>=0&&!0!==(a=r[n]());n--)if(a instanceof Promise)return this._parseStack.handlerPos=n,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(24!==i&&26!==i,s))return a;27===i&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(24!==i&&26!==i,s))return a;27===i&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let s=o;s<r;++s){switch(i=e[s],(n=this._transitions.table[this.currentState<<8|(i<160?i:160)])>>4){case 2:for(let n=s+1;;++n)if(n>=r||(i=e[n])<32||i>126&&i<160||++n>=r||(i=e[n])<32||i>126&&i<160||++n>=r||(i=e[n])<32||i>126&&i<160||++n>=r||(i=e[n])<32||i>126&&i<160){this._printHandler(e,s,n),s=n-1;break}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:s,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o=this._csiHandlers[this._collect<<8|i],l=o?o.length-1:-1;for(;l>=0&&!0!==(a=o[l](this._params));l--)if(a instanceof Promise)return this._preserveStack(3,o,l,n,s),a;l<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++s<r&&(i=e[s])>47&&i<60)s--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let c=this._escHandlers[this._collect<<8|i],d=c?c.length-1:-1;for(;d>=0&&!0!==(a=c[d]());d--)if(a instanceof Promise)return this._preserveStack(4,c,d,n,s),a;d<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let n=s+1;;++n)if(n>=r||24===(i=e[n])||26===i||27===i||i>127&&i<160){this._dcsParser.put(e,s,n),s=n-1;break}break;case 14:if(a=this._dcsParser.unhook(24!==i&&26!==i))return this._preserveStack(6,[],0,n,s),a;27===i&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let n=s+1;;n++)if(n>=r||(i=e[n])<32||i>127&&i<160){this._oscParser.put(e,s,n),s=n-1;break}break;case 6:if(a=this._oscParser.end(24!==i&&26!==i))return this._preserveStack(5,[],0,n,s),a;27===i&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&n}}},fx=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,f_=/^[\da-f]+$/;function fy(e){if(!e)return;let r=e.toLowerCase();if(0===r.indexOf("rgb:")){r=r.slice(4);let e=fx.exec(r);if(e){let r=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/r*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/r*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/r*255)]}}else if(0===r.indexOf("#")&&(r=r.slice(1),f_.exec(r)&&[3,6,9,12].includes(r.length))){let e=r.length/3,s=[0,0,0];for(let i=0;i<3;++i){let n=parseInt(r.slice(e*i,e*i+e),16);s[i]=1===e?n<<4:2===e?n:3===e?n>>4:n>>8}return s}}function fb(e,r){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(r){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}var fw={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function fS(e,r){if(e>24)return r.setWinLines||!1;switch(e){case 1:return!!r.restoreWin;case 2:return!!r.minimizeWin;case 3:return!!r.setWinPosition;case 4:return!!r.setWinSizePixels;case 5:return!!r.raiseWin;case 6:return!!r.lowerWin;case 7:return!!r.refreshWin;case 8:return!!r.setWinSizeChars;case 9:return!!r.maximizeWin;case 10:return!!r.fullscreenWin;case 11:return!!r.getWinState;case 13:return!!r.getWinPosition;case 14:return!!r.getWinSizePixels;case 15:return!!r.getScreenSizePixels;case 16:return!!r.getCellSizePixels;case 18:return!!r.getWinSizeChars;case 19:return!!r.getScreenSizeChars;case 20:return!!r.getIconTitle;case 21:return!!r.getWinTitle;case 22:return!!r.pushTitle;case 23:return!!r.popTitle;case 24:return!!r.setWinLines}return!1}var fC=0,fk=class extends cs{constructor(e,r,s,i,n,o,a,l,c=new fv){for(let d in super(),this._bufferService=e,this._charsetService=r,this._coreService=s,this._logService=i,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new lk,this._utf8Decoder=new lj,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=uO.clone(),this._eraseAttrDataInternal=uO.clone(),this._onRequestBell=this._register(new cD),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new cD),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new cD),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new cD),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new cD),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new cD),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new cD),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new cD),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new cD),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new cD),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new cD),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new cD),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new cD),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new fj(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,r)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e),params:r.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug("Unknown EXECUTE code: ",{code:e})}),this._parser.setOscHandlerFallback((e,r,s)=>{this._logService.debug("Unknown OSC code: ",{identifier:e,action:r,data:s})}),this._parser.setDcsHandlerFallback((e,r,s)=>{"HOOK"===r&&(s=s.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e),action:r,payload:s})}),this._parser.setPrintHandler((e,r,s)=>this.print(e,r,s)),this._parser.registerCsiHandler({final:"@"},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:"A"},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:"B"},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:"C"},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:"D"},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:"E"},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:"F"},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:"G"},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:"H"},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:"I"},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:"J"},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:"K"},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:"L"},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:"M"},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:"P"},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:"S"},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:"T"},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:"X"},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:"Z"},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:"a"},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:"b"},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:"c"},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:">",final:"c"},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:"d"},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:"e"},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:"f"},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:"g"},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:"h"},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"h"},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:"l"},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"l"},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:"m"},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:"n"},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:"?",final:"n"},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:"r"},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:"s"},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:"t"},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:"u"},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(hu.BEL,()=>this.bell()),this._parser.setExecuteHandler(hu.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(hu.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(hu.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(hu.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(hu.BS,()=>this.backspace()),this._parser.setExecuteHandler(hu.HT,()=>this.tab()),this._parser.setExecuteHandler(hu.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(hu.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(hf.IND,()=>this.index()),this._parser.setExecuteHandler(hf.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(hf.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new fd(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new fd(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new fd(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new fd(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new fd(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new fd(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new fd(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new fd(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new fd(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new fd(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new fd(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new fd(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset()),uH)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error("Parsing error: ",e),e)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new fp((e,r)=>this.requestStatusString(e,r)))}getAttrData(){return this._curAttrData}_preserveStack(e,r,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=r,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),5e3))]).catch(e=>{if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,r){let s,i=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,r))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>131072&&(o=this._parseStack.position+131072)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${"string"==typeof e?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join("")}"`}`),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof e?e.split("").map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(e.length,131072))),a||this._dirtyRowTracker.clearRange(),e.length>131072)for(let r=o;r<e.length;r+=131072){let o=r+131072<e.length?r+131072:e.length,a="string"==typeof e?this._stringDecoder.decode(e.substring(r,o),this._parseBuffer):this._utf8Decoder.decode(e.subarray(r,o),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,a))return this._preserveStack(i,n,a,r),this._logSlowResolvingAsync(s),s}else if(!a){let r="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,r))return this._preserveStack(i,n,r,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,r,s){let i,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,h=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-r>0&&2===u.getWidth(this._activeBuffer.x-1)&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let f=this._parser.precedingJoinState;for(let p=r;p<s;++p){if((i=e[p])<127&&o){let e=o[String.fromCharCode(i)];e&&(i=e.charCodeAt(0))}let r=this._unicodeService.charProperties(i,f);n=fi.extractWidth(r);let s=fi.extractShouldJoin(r),m=s?fi.extractWidth(f):0;if(f=r,a&&this._onA11yChar.fire(lS(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-m>l){if(c){let e=u,r=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&u instanceof uz&&u.copyCellsFrom(e,r,0,m,!1);r<l;)e.setCellFromCodepoint(r++,0,1,h)}else if(this._activeBuffer.x=l-1,2===n)continue}if(s&&this._activeBuffer.x){let e=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-e,i,n);for(let e=n-m;--e>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(d&&(u.insertCells(this._activeBuffer.x,n-m,this._activeBuffer.getNullCell(h)),2===u.getWidth(l-1)&&u.setCellFromCodepoint(l-1,0,1,h)),u.setCellFromCodepoint(this._activeBuffer.x++,i,n,h),n>0)for(;--n;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-r>0&&0===u.getWidth(this._activeBuffer.x)&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,r){return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,r):this._parser.registerCsiHandler(e,e=>!fS(e.params[0],this._optionsService.rawOptions.windowOptions)||r(e))}registerDcsHandler(e,r){return this._parser.registerDcsHandler(e,new fp(r))}registerEscHandler(e,r){return this._parser.registerEscHandler(e,r)}registerOscHandler(e,r){return this._parser.registerOscHandler(e,new fd(r))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(0===this._activeBuffer.x&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,r){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+r):(this._activeBuffer.x=e,this._activeBuffer.y=r),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,r){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+r)}cursorUp(e){let r=this._activeBuffer.y-this._activeBuffer.scrollTop;return r>=0?this._moveCursor(0,-Math.min(r,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let r=this._activeBuffer.scrollBottom-this._activeBuffer.y;return r>=0?this._moveCursor(0,Math.min(r,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let r=e.params[0];return 0===r?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===r&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let r=e.params[0]||1;for(;r--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let r=e.params[0]||1;for(;r--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let r=e.params[0];return 1===r&&(this._curAttrData.bg|=0x20000000),(2===r||0===r)&&(this._curAttrData.bg&=-0x20000001),!0}_eraseInBufferLine(e,r,s,i=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(r,s,this._activeBuffer.getNullCell(this._eraseAttrData()),n),i&&(o.isWrapped=!1)}_resetBufferLine(e,r=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),r),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,r=!1){let s;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,r);s<this._bufferService.rows;s++)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,r),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0))}return!0}eraseInLine(e,r=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,r);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,r);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,r)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let r=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;r--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let r=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;r--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let r=e.params[0]||1;for(;r--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let r=e.params[0]||1;for(;r--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(uO));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.deleteCells(0,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.insertCells(0,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.insertCells(this._activeBuffer.x,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.deleteCells(this._activeBuffer.x,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let r=this._parser.precedingJoinState;if(!r)return!0;let s=e.params[0]||1,i=fi.extractWidth(r),n=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*s),l=0;for(let e=0;e<o.length;){let r=o.codePointAt(e)||0;a[l++]=r,e+=r>65535?2:1}let c=l;for(let e=1;e<s;++e)a.copyWithin(c,0,l),c+=l;return this.print(a,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(hu.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(hu.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(hu.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(hu.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(hu.ESC+"[>83;40003;0c")),!0}_is(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)}setMode(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,u$),this._charsetService.setgCharset(1,u$),this._charsetService.setgCharset(2,u$),this._charsetService.setgCharset(3,u$);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[r]&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,r){let s,i,n,o;(i=s||={})[i.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",i[i.SET=1]="SET",i[i.RESET=2]="RESET",i[i.PERMANENTLY_SET=3]="PERMANENTLY_SET",i[i.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let a=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:c}=this._coreMouseService,d=this._coreService,{buffers:h,cols:u}=this._bufferService,{active:f,alt:p}=h,m=this._optionsService.rawOptions,g=e=>e?1:2,v=e.params[0];return n=v,o=r?2===v?4:4===v?g(d.modes.insertMode):12===v?3:20===v?g(m.convertEol):0:1===v?g(a.applicationCursorKeys):3===v?m.windowOptions.setWinLines?80===u?2:+(132===u):0:6===v?g(a.origin):7===v?g(a.wraparound):8===v?3:9===v?g("X10"===l):12===v?g(m.cursorBlink):25===v?g(!d.isCursorHidden):45===v?g(a.reverseWraparound):66===v?g(a.applicationKeypad):67===v?4:1e3===v?g("VT200"===l):1002===v?g("DRAG"===l):1003===v?g("ANY"===l):1004===v?g(a.sendFocus):1005===v?4:1006===v?g("SGR"===c):1015===v?4:1016===v?g("SGR_PIXELS"===c):1048===v?1:47===v||1047===v||1049===v?g(f===p):2004===v?g(a.bracketedPasteMode):2026===v?g(a.synchronizedOutput):0,d.triggerDataEvent(`${hu.ESC}[${r?"":"?"}${n};${o}$y`),!0}_updateAttrColor(e,r,s,i,n){return 2===r?(e|=0x3000000,e&=-0x1000000,e|=lN.fromColorRGB([s,i,n])):5===r&&(e&=-0x3000100,e|=0x2000000|255&s),e}_extractColor(e,r,s){let i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[r+o],e.hasSubParams(r+o)){let s=e.getSubParams(r+o),a=0;do 5===i[1]&&(n=1),i[o+a+1+n]=s[a];while(++a<s.length&&a+o+1+n<i.length)break}if(5===i[1]&&o+n>=2||2===i[1]&&o+n>=5)break;i[1]&&(n=1)}while(++o+r<e.length&&o+n<i.length)for(let e=2;e<i.length;++e)-1===i[e]&&(i[e]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,r){r.extended=r.extended.clone(),(!~e||e>5)&&(e=1),r.extended.underlineStyle=e,r.fg|=0x10000000,0===e&&(r.fg&=-0x10000001),r.updateExtended()}_processSGR0(e){e.fg=uO.fg,e.bg=uO.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-0x4000000,e.updateExtended()}charAttributes(e){if(1===e.length&&0===e.params[0])return this._processSGR0(this._curAttrData),!0;let r=e.length,s,i=this._curAttrData;for(let n=0;n<r;n++)(s=e.params[n])>=30&&s<=37?(i.fg&=-0x3000100,i.fg|=0x1000000|s-30):s>=40&&s<=47?(i.bg&=-0x3000100,i.bg|=0x1000000|s-40):s>=90&&s<=97?(i.fg&=-0x3000100,i.fg|=0x1000000|s-90|8):s>=100&&s<=107?(i.bg&=-0x3000100,i.bg|=0x1000000|s-100|8):0===s?this._processSGR0(i):1===s?i.fg|=0x8000000:3===s?i.bg|=0x4000000:4===s?(i.fg|=0x10000000,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):5===s?i.fg|=0x20000000:7===s?i.fg|=0x4000000:8===s?i.fg|=0x40000000:9===s?i.fg|=0x80000000:2===s?i.bg|=0x8000000:21===s?this._processUnderline(2,i):22===s?(i.fg&=-0x8000001,i.bg&=-0x8000001):23===s?i.bg&=-0x4000001:24===s?(i.fg&=-0x10000001,this._processUnderline(0,i)):25===s?i.fg&=-0x20000001:27===s?i.fg&=-0x4000001:28===s?i.fg&=-0x40000001:29===s?i.fg&=0x7fffffff:39===s?(i.fg&=-0x4000000,i.fg|=0xffffff&uO.fg):49===s?(i.bg&=-0x4000000,i.bg|=0xffffff&uO.bg):38===s||48===s||58===s?n+=this._extractColor(e,n,i):53===s?i.bg|=0x40000000:55===s?i.bg&=-0x40000001:59===s?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):100===s?(i.fg&=-0x4000000,i.fg|=0xffffff&uO.fg,i.bg&=-0x4000000,i.bg|=0xffffff&uO.bg):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${hu.ESC}[0n`);break;case 6:let r=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${hu.ESC}[${r};${s}R`)}return!0}deviceStatusPrivate(e){if(6===e.params[0]){let e=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${hu.ESC}[?${e};${r}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=uO.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let r=0===e.length?1:e.params[0];if(0===r)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(r){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar"}this._coreService.decPrivateModes.cursorBlink=r%2==1}return!0}setScrollRegion(e){let r=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||0===s)&&(s=this._bufferService.rows),s>r&&(this._activeBuffer.scrollTop=r-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!fS(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let r=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==r&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${hu.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===r||2===r)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===r||1===r)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===r||2===r)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===r||1===r)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let r=[],s=e.split(";");for(;s.length>1;){let e=s.shift(),i=s.shift();if(/^\d+$/.exec(e)){let s=parseInt(e);if(fN(s))if("?"===i)r.push({type:0,index:s});else{let e=fy(i);e&&r.push({type:1,index:s,color:e})}}}return r.length&&this._onColor.fire(r),!0}setHyperlink(e){let r=e.indexOf(";");if(-1===r)return!0;let s=e.slice(0,r).trim(),i=e.slice(r+1);return i?this._createHyperlink(s,i):!s.trim()&&this._finishHyperlink()}_createHyperlink(e,r){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,n=s.findIndex(e=>e.startsWith("id="));return -1!==n&&(i=s[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:r}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,r){let s=e.split(";");for(let e=0;e<s.length&&!(r>=this._specialColors.length);++e,++r)if("?"===s[e])this._onColor.fire([{type:0,index:this._specialColors[r]}]);else{let i=fy(s[e]);i&&this._onColor.fire([{type:1,index:this._specialColors[r],color:i}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let r=[],s=e.split(";");for(let e=0;e<s.length;++e)if(/^\d+$/.exec(s[e])){let i=parseInt(s[e]);fN(i)&&r.push({type:2,index:i})}return r.length&&this._onColor.fire(r),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,u$),!0}selectCharset(e){return 2!==e.length?this.selectDefaultCharset():"/"===e[0]||this._charsetService.setgCharset(fw[e[0]],uH[e[1]]||u$),!0}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=uO.clone(),this._eraseAttrDataInternal=uO.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-0x4000000,this._eraseAttrDataInternal.bg|=0x3ffffff&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new lR;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let r=0;r<this._bufferService.rows;++r){let s=this._activeBuffer.ybase+this._activeBuffer.y+r,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,r){let s=e=>(this._coreService.triggerDataEvent(`${hu.ESC}${e}${hu.ESC}\\`),!0),i=this._bufferService.buffer,n=this._optionsService.rawOptions;return s('"q'===e?`P1$r${+!!this._curAttrData.isProtected()}"q`:'"p'===e?'P1$r61;1"p':"r"===e?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:"m"===e?"P1$r0m":" q"===e?`P1$r${({block:2,underline:4,bar:6})[n.cursorStyle]-!!n.cursorBlink} q`:"P0$r")}markRangeDirty(e,r){this._dirtyRowTracker.markRangeDirty(e,r)}},fj=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,r){e>r&&(fC=e,e=r,r=fC),e<this.start&&(this.start=e),r>this.end&&(this.end=r)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function fN(e){return 0<=e&&e<256}fj=lg([lv(0,lL)],fj);var fE=class extends cs{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new cD),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,r){let s;if(void 0!==r&&this._syncCalls>r){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){for(this._isSyncWriting=!0;s=this._writeBuffer.shift();){this._action(s);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=0x7fffffff,this._isSyncWriting=!1,this._syncCalls=0}}write(e,r){if(this._pendingData>5e7)throw Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(r),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(r)}_innerWrite(e=0,r=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],i=this._action(e,r);if(i){let e=e=>performance.now()-s>=12?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(s,e);i.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-s>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},fR=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let r=this._bufferService.buffer;if(void 0===e.id){let s=r.addMarker(r.ybase+r.y),i={data:e,id:this._nextId++,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(i,s)),this._dataByLinkId.set(i.id,i),i.id}let s=this._getEntryIdKey(e),i=this._entriesWithId.get(s);if(i)return this.addLineToLink(i.id,r.ybase+r.y),i.id;let n=r.addMarker(r.ybase+r.y),o={id:this._nextId++,key:this._getEntryIdKey(e),data:e,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,r){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(e=>e.line!==r)){let e=this._bufferService.buffer.addMarker(r);s.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(s,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,r){let s=e.lines.indexOf(r);-1!==s&&(e.lines.splice(s,1),0===e.lines.length&&(void 0!==e.data.id&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};fR=lg([lv(0,lL)],fR);var fM=!1,fD=class extends cs{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ci),this._onBinary=this._register(new cD),this.onBinary=this._onBinary.event,this._onData=this._register(new cD),this.onData=this._onData.event,this._onLineFeed=this._register(new cD),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new cD),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new cD),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new cD),this._instantiationService=new uP,this.optionsService=this._register(new uX(e)),this._instantiationService.setService(lF,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(uq)),this._instantiationService.setService(lL,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(uB)),this._instantiationService.setService(lz,this._logService),this.coreService=this._register(this._instantiationService.createInstance(uQ)),this._instantiationService.setService(lA,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(u3)),this._instantiationService.setService(lB,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(fi)),this._instantiationService.setService(lH,this.unicodeService),this._charsetService=this._instantiationService.createInstance(fn),this._instantiationService.setService(lO,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(fR),this._instantiationService.setService(lW,this._oscLinkService),this._inputHandler=this._register(new fk(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(cC.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(cC.forward(this._bufferService.onResize,this._onResize)),this._register(cC.forward(this.coreService.onData,this._onData)),this._register(cC.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new fE((e,r)=>this._inputHandler.parse(e,r))),this._register(cC.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new cD),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let r in e)this.optionsService.options[r]=e[r]}write(e,r){this._writeBuffer.write(e,r)}writeSync(e,r){this._logService.logLevel<=3&&!fM&&(this._logService.warn("writeSync is unreliable and will be removed soon."),fM=!0),this._writeBuffer.writeSync(e,r)}input(e,r=!0){this.coreService.triggerDataEvent(e,r)}resize(e,r){isNaN(e)||isNaN(r)||(e=Math.max(e,2),r=Math.max(r,1),this._bufferService.resize(e,r))}scroll(e,r=!1){this._bufferService.scroll(e,r)}scrollLines(e,r){this._bufferService.scrollLines(e,r)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let r=e-this._bufferService.buffer.ydisp;0!==r&&this.scrollLines(r)}registerEscHandler(e,r){return this._inputHandler.registerEscHandler(e,r)}registerDcsHandler(e,r){return this._inputHandler.registerDcsHandler(e,r)}registerCsiHandler(e,r){return this._inputHandler.registerCsiHandler(e,r)}registerOscHandler(e,r){return this._inputHandler.registerOscHandler(e,r)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,r=this.optionsService.rawOptions.windowsPty;r&&void 0!==r.buildNumber&&void 0!==r.buildNumber?e="conpty"===r.backend&&r.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(fo.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(fo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ce(()=>{for(let r of e)r.dispose()})}}},fT={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']},fP=0,fL=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ud,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ud,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,r)=>this._getKey(e)-this._getKey(r)),r=0,s=0,i=Array(this._array.length+this._insertedValues.length);for(let n=0;n<i.length;n++)s>=this._array.length||this._getKey(e[r])<=this._getKey(this._array[s])?(i[n]=e[r],r++):i[n]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),0===this._array.length)return!1;let r=this._getKey(e);if(void 0===r||-1===(fP=this._search(r))||this._getKey(this._array[fP])!==r)return!1;do if(this._array[fP]===e)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(fP),!0;while(++fP<this._array.length&&this._getKey(this._array[fP])===r)return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,r)=>e-r),r=0,s=Array(this._array.length-e.length),i=0;for(let n=0;n<this._array.length;n++)e[r]===n?r++:s[i++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((fP=this._search(e))<0||fP>=this._array.length)&&this._getKey(this._array[fP])===e)do yield this._array[fP];while(++fP<this._array.length&&this._getKey(this._array[fP])===e)}forEachByKey(e,r){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((fP=this._search(e))<0||fP>=this._array.length)&&this._getKey(this._array[fP])===e)do r(this._array[fP]);while(++fP<this._array.length&&this._getKey(this._array[fP])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let r=0,s=this._array.length-1;for(;s>=r;){let i=r+s>>1,n=this._getKey(this._array[i]);if(n>e)s=i-1;else if(n<e)r=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return r}},fB=0,fA=0,fO=class extends cs{constructor(){super(),this._decorations=new fL(e=>e?.marker.line),this._onDecorationRegistered=this._register(new cD),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new cD),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ce(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let r=new fI(e);if(r){let e=r.marker.onDispose(()=>r.dispose()),s=r.onDispose(()=>{s.dispose(),r&&(this._decorations.delete(r)&&this._onDecorationRemoved.fire(r),e.dispose())});this._decorations.insert(r),this._onDecorationRegistered.fire(r)}return r}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,r,s){let i=0,n=0;for(let o of this._decorations.getKeyIterator(r))n=(i=o.options.x??0)+(o.options.width??1),e>=i&&e<n&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,r,s,i){this._decorations.forEachByKey(r,r=>{fA=(fB=r.options.x??0)+(r.options.width??1),e>=fB&&e<fA&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},fI=class extends cr{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new cD),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new cD),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=u8.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=u8.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},fz=class{constructor(e,r=1e3){this._renderCallback=e,this._debounceThresholdMS=r,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,r,s){this._rowCount=s,e=void 0!==e?e:0,r=void 0!==r?r:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,r):r;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=i-this._lastRefreshMs,r=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},r)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let e=Math.max(this._rowStart,0),r=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,r)}},fF=class extends cs{constructor(e,r,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new fz(this._renderRows.bind(this))),!this._terminal.element)throw Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
20
+ `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(dA(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ce(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let r=0;r<e;r++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
21
+ `&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=l_)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,r){this._liveRegionDebouncer.refresh(e,r,this._terminal.rows)}_renderRows(e,r){let s=this._terminal.buffer,i=s.lines.length.toString();for(let n=e;n<=r;n++){let e=s.lines.get(s.ydisp+n),r=[],o=e?.translateToString(!0,void 0,void 0,r)||"",a=(s.ydisp+n+1).toString(),l=this._rowElements[n];l&&(0===o.length?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=o,this._rowColumns.set(l,r)),l.setAttribute("aria-posinset",a),l.setAttribute("aria-setsize",i),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,r){let s,i,n=e.target,o=this._rowElements[0===r?1:this._rowElements.length-2];if(n.getAttribute("aria-posinset")!==(0===r?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===o){if(0===r?(s=n,i=this._rowElements.pop(),this._rowContainer.removeChild(i)):(s=this._rowElements.shift(),i=n,this._rowContainer.removeChild(s)),s.removeEventListener("focus",this._topBoundaryFocusListener),i.removeEventListener("focus",this._bottomBoundaryFocusListener),0===r){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===r?-1:1),this._rowElements[0===r?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode)return void console.error("anchorNode and/or focusNode are null");let r={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((r.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||r.node===s.node&&r.offset>s.offset)&&([r,s]=[s,r]),r.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(r={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(r.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let n=({node:e,offset:r})=>{let s=e instanceof Text?e.parentNode:e,i=parseInt(s?.getAttribute("aria-posinset"),10)-1;if(isNaN(i))return console.warn("row is invalid. Race condition?"),null;let n=this._rowColumns.get(s);if(!n)return console.warn("columns is null. Race condition?"),null;let o=r<n.length?n[r]:n.slice(-1)[0]+1;return o>=this._terminal.cols&&(++i,o=0),{row:i,column:o}},o=n(r),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let r=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/r})`}};fF=lg([lv(1,lI),lv(2,lq),lv(3,lY)],fF);var fW=class extends cs{constructor(e,r,s,i,n){super(),this._element=e,this._mouseService=r,this._renderService=s,this._bufferService=i,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new cD),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new cD),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ce(()=>{l9(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(dA(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(dA(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(dA(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(dA(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let r=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!r)return;this._isMouseOut=!1;let s=e.composedPath();for(let e=0;e<s.length;e++){let r=s[e];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}this._lastBufferCell&&r.x===this._lastBufferCell.x&&r.y===this._lastBufferCell.y||(this._handleHover(r),this._lastBufferCell=r)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,r){this._activeProviderReplies&&r||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[i,n]of this._linkProviderService.linkProviders.entries())r?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,e,s)):n.provideLinks(e.y,r=>{if(this._isMouseOut)return;let n=r?.map(e=>({link:e}));this._activeProviderReplies?.set(i,n),s=this._checkLinkProviderResult(i,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,r){let s=new Set;for(let i=0;i<r.size;i++){let n=r.get(i);if(n)for(let r=0;r<n.length;r++){let i=n[r],o=i.link.range.start.y<e?0:i.link.range.start.x,a=i.link.range.end.y>e?this._bufferService.cols:i.link.range.end.x;for(let e=o;e<=a;e++){if(s.has(e)){n.splice(r--,1);break}s.add(e)}}}}_checkLinkProviderResult(e,r,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),n=!1;for(let r=0;r<e;r++)(!this._activeProviderReplies.has(r)||this._activeProviderReplies.get(r))&&(n=!0);if(!n&&i){let e=i.find(e=>this._linkAtPosition(e.link,r));e&&(s=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let e=0;e<this._activeProviderReplies.size;e++){let i=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,r));if(i){s=!0,this._handleNewLink(i);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){var r,s;if(!this._currentLink)return;let i=this._positionFromMouseEvent(e,this._element,this._mouseService);i&&this._mouseDownLink&&(r=this._mouseDownLink.link,s=this._currentLink.link,r.text===s.text&&r.range.start.x===s.range.start.x&&r.range.start.y===s.range.start.y&&r.range.end.x===s.range.end.x&&r.range.end.y===s.range.end.y)&&this._linkAtPosition(this._currentLink.link,i)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,r){this._currentLink&&this._lastMouseEvent&&(!e||!r||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=r)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,l9(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let r=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);r&&this._linkAtPosition(e.link,r)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let r=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(r,s),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,r,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(r,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),r.hover&&r.hover(s,r.text)}_fireUnderlineEvent(e,r){let s=e.range,i=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(r?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,r,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(r,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),r.leave&&r.leave(s,r.text)}_linkAtPosition(e,r){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,n=r.y*this._bufferService.cols+r.x;return s<=n&&n<=i}_positionFromMouseEvent(e,r,s){let i=s.getCoords(e,r,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,r,s,i,n){return{x1:e,y1:r,x2:s,y2:i,cols:this._bufferService.cols,fg:n}}};fW=lg([lv(1,lV),lv(2,lY),lv(3,lL),lv(4,lZ)],fW);var fH=class extends fD{constructor(e={}){super(e),this._linkifier=this._register(new ci),this.browser=h1,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ci),this._onCursorMove=this._register(new cD),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new cD),this.onKey=this._onKey.event,this._onRender=this._register(new cD),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new cD),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new cD),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new cD),this.onBell=this._onBell.event,this._onFocus=this._register(new cD),this._onBlur=this._register(new cD),this._onA11yCharEmitter=this._register(new cD),this._onA11yTabEmitter=this._register(new cD),this._onWillOpen=this._register(new cD),this._setup(),this._decorationService=this._instantiationService.createInstance(fO),this._instantiationService.setService(l$,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(hJ),this._instantiationService.setService(lZ,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(lK)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(cC.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(cC.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(cC.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(cC.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(ce(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let r of e){let e,s="";switch(r.index){case 256:e="foreground",s="10";break;case 257:e="background",s="11";break;case 258:e="cursor",s="12";break;default:e="ansi",s="4;"+r.index}switch(r.type){case 0:let i=u6.toColorRGB("ansi"===e?this._themeService.colors.ansi[r.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${hu.ESC}]${s};${function(e,r=16){let[s,i,n]=e;return`rgb:${fb(s,r)}/${fb(i,r)}/${fb(n,r)}`}(i)}${hp.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[r.index]=hm.toColor(...r.color));else{let s=e;this._themeService.modifyColors(e=>e[s]=hm.toColor(...r.color))}break;case 2:this._themeService.restoreColor(r.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(fF,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(hu.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(hu.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,r=this.buffer.lines.get(e);if(!r)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,n=r.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(dA(this.element,"copy",e=>{var r;this.hasSelection()&&(r=this._selectionService,e.clipboardData&&e.clipboardData.setData("text/plain",r.selectionText),e.preventDefault())}));let e=e=>{var r,s,i;return r=this.textarea,s=this.coreService,i=this.optionsService,void(e.stopPropagation(),e.clipboardData&&ly(e.clipboardData.getData("text/plain"),r,s,i))};this._register(dA(this.textarea,"paste",e)),this._register(dA(this.element,"paste",e)),h8?this._register(dA(this.element,"mousedown",e=>{2===e.button&&lw(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(dA(this.element,"contextmenu",e=>{lw(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),un&&this._register(dA(this.element,"auxclick",e=>{1===e.button&&lb(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(dA(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(dA(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(dA(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(dA(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(dA(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(dA(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(dA(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let r=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),r.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(dA(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),r.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",lx),uo||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(hX,this.textarea,e.ownerDocument.defaultView??window,this._document??"u">typeof window?window.document:null)),this._instantiationService.setService(lq,this._coreBrowserService),this._register(dA(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(dA(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(hU,this._document,this._helperContainer),this._instantiationService.setService(lU,this._charSizeService),this._themeService=this._instantiationService.createInstance(uM),this._instantiationService.setService(lJ,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(hD),this._instantiationService.setService(lG,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(uu,this.rows,this.screenElement)),this._instantiationService.setService(lY,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(ho,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(hQ),this._instantiationService.setService(lV,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(fW,this.screenElement));this.element.appendChild(r);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(d9,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(uw,this.element,this.screenElement,i)),this._instantiationService.setService(lX,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(cC.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(he,this.screenElement)),this._register(dA(this.element,"mousedown",e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(fF,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(hn,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(hn,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(hK,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,r=this.element;function s(r){let s,i,n=e._mouseService.getMouseReportCoords(r,e.screenElement);if(!n)return!1;switch(r.overrideType||r.type){case"mousemove":i=32,void 0===r.buttons?(s=3,void 0!==r.button&&(s=r.button<3?r.button:3)):s=1&r.buttons?0:4&r.buttons?1:2&r.buttons?2:3;break;case"mouseup":i=0,s=r.button<3?r.button:3;break;case"mousedown":i=1,s=r.button<3?r.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(r))return!1;let o=r.deltaY;if(0===o||0===e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return!1;i=o<0?0:1,s=4;break;default:return!1}return void 0!==i&&void 0!==s&&!(s>4)&&e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:s,action:i,ctrl:r.ctrlKey,alt:r.altKey,shift:r.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n=e=>(s(e),e.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(e)),o=e=>(s(e),this.cancel(e,!0)),a=e=>{e.buttons&&s(e)},l=e=>{e.buttons||s(e)};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&e?i.mousemove||(r.addEventListener("mousemove",l),i.mousemove=l):(r.removeEventListener("mousemove",i.mousemove),i.mousemove=null),16&e?i.wheel||(r.addEventListener("wheel",o,{passive:!1}),i.wheel=o):(r.removeEventListener("wheel",i.wheel),i.wheel=null),2&e?i.mouseup||(i.mouseup=n):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),4&e?i.mousedrag||(i.mousedrag=a):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(dA(r,"mousedown",e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return s(e),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(e)})),this._register(dA(r,"wheel",r=>{if(!i.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(r))return!1;if(!this.buffer.hasScrollback){if(0===r.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return this.cancel(r,!0);let s=hu.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(r.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(s,!0),this.cancel(r,!0)}}},{passive:!1}))}refresh(e,r){this._renderService?.refreshRows(e,r)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,r){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,r),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let r=e-this._bufferService.buffer.ydisp;0!==r&&this.scrollLines(r)}paste(e){ly(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let r=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),r}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,r,s){this._selectionService.setSelection(e,r,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,r){this._selectionService?.selectLines(e,r)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let r=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!r&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;r||"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);let s=function(e,r,s,i){let n={type:0,cancel:!1,key:void 0},o=!!e.shiftKey|2*!!e.altKey|4*!!e.ctrlKey|8*!!e.metaKey;switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?r?n.key=hu.ESC+"OA":n.key=hu.ESC+"[A":"UIKeyInputLeftArrow"===e.key?r?n.key=hu.ESC+"OD":n.key=hu.ESC+"[D":"UIKeyInputRightArrow"===e.key?r?n.key=hu.ESC+"OC":n.key=hu.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(r?n.key=hu.ESC+"OB":n.key=hu.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":hu.DEL,e.altKey&&(n.key=hu.ESC+n.key);break;case 9:if(e.shiftKey){n.key=hu.ESC+"[Z";break}n.key=hu.HT,n.cancel=!0;break;case 13:n.key=e.altKey?hu.ESC+hu.CR:hu.CR,n.cancel=!0;break;case 27:n.key=hu.ESC,e.altKey&&(n.key=hu.ESC+hu.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=hu.ESC+"[1;"+(o+1)+"D":r?n.key=hu.ESC+"OD":n.key=hu.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=hu.ESC+"[1;"+(o+1)+"C":r?n.key=hu.ESC+"OC":n.key=hu.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=hu.ESC+"[1;"+(o+1)+"A":r?n.key=hu.ESC+"OA":n.key=hu.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=hu.ESC+"[1;"+(o+1)+"B":r?n.key=hu.ESC+"OB":n.key=hu.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(n.key=hu.ESC+"[2~");break;case 46:o?n.key=hu.ESC+"[3;"+(o+1)+"~":n.key=hu.ESC+"[3~";break;case 36:o?n.key=hu.ESC+"[1;"+(o+1)+"H":r?n.key=hu.ESC+"OH":n.key=hu.ESC+"[H";break;case 35:o?n.key=hu.ESC+"[1;"+(o+1)+"F":r?n.key=hu.ESC+"OF":n.key=hu.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=hu.ESC+"[5;"+(o+1)+"~":n.key=hu.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=hu.ESC+"[6;"+(o+1)+"~":n.key=hu.ESC+"[6~";break;case 112:o?n.key=hu.ESC+"[1;"+(o+1)+"P":n.key=hu.ESC+"OP";break;case 113:o?n.key=hu.ESC+"[1;"+(o+1)+"Q":n.key=hu.ESC+"OQ";break;case 114:o?n.key=hu.ESC+"[1;"+(o+1)+"R":n.key=hu.ESC+"OR";break;case 115:o?n.key=hu.ESC+"[1;"+(o+1)+"S":n.key=hu.ESC+"OS";break;case 116:o?n.key=hu.ESC+"[15;"+(o+1)+"~":n.key=hu.ESC+"[15~";break;case 117:o?n.key=hu.ESC+"[17;"+(o+1)+"~":n.key=hu.ESC+"[17~";break;case 118:o?n.key=hu.ESC+"[18;"+(o+1)+"~":n.key=hu.ESC+"[18~";break;case 119:o?n.key=hu.ESC+"[19;"+(o+1)+"~":n.key=hu.ESC+"[19~";break;case 120:o?n.key=hu.ESC+"[20;"+(o+1)+"~":n.key=hu.ESC+"[20~";break;case 121:o?n.key=hu.ESC+"[21;"+(o+1)+"~":n.key=hu.ESC+"[21~";break;case 122:o?n.key=hu.ESC+"[23;"+(o+1)+"~":n.key=hu.ESC+"[23~";break;case 123:o?n.key=hu.ESC+"[24;"+(o+1)+"~":n.key=hu.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if((!s||i)&&e.altKey&&!e.metaKey){let r=fT[e.keyCode]?.[+!!e.shiftKey];if(r)n.key=hu.ESC+r;else if(e.keyCode>=65&&e.keyCode<=90){let r=String.fromCharCode(e.ctrlKey?e.keyCode-64:e.keyCode+32);e.shiftKey&&(r=r.toUpperCase()),n.key=hu.ESC+r}else if(32===e.keyCode)n.key=hu.ESC+(e.ctrlKey?hu.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let r=e.code.slice(3,4);e.shiftKey||(r=r.toLowerCase()),n.key=hu.ESC+r,n.cancel=!0}}else!s||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?!e.key||e.ctrlKey||e.altKey||e.metaKey||!(e.keyCode>=48)||1!==e.key.length?e.key&&e.ctrlKey&&("_"===e.key&&(n.key=hu.US),"@"===e.key&&(n.key=hu.NUL)):n.key=e.key:65===e.keyCode&&(n.type=1);else e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?n.key=hu.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?n.key=hu.DEL:219===e.keyCode?n.key=hu.ESC:220===e.keyCode?n.key=hu.FS:221===e.keyCode&&(n.key=hu.GS)}return n}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===s.type||2===s.type){let r=this.rows-1;return this.scrollLines(2===s.type?-r:r),this.cancel(e,!0)}return 1===s.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&90>=e.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((s.key===hu.ETX||s.key===hu.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)?this.cancel(e,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(e,r){let s=e.isMac&&!this.options.macOptionIsMeta&&r.altKey&&!r.ctrlKey&&!r.metaKey||e.isWindows&&r.altKey&&r.ctrlKey&&!r.metaKey||e.isWindows&&r.getModifierState("AltGraph");return"keypress"===r.type?s:s&&(!r.keyCode||r.keyCode>47)}_keyUp(e){var r;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(16===(r=e).keyCode||17===r.keyCode||18===r.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let r;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)r=e.charCode;else if(null===e.which||void 0===e.which)r=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;r=e.which}return!!r&&(!e.altKey&&!e.ctrlKey&&!e.metaKey||!!this._isThirdLevelShift(this.browser,e))&&(r=String.fromCharCode(r),this._onKey.fire({key:r,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&"insertText"===e.inputType&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let r=e.data;return this.coreService.triggerDataEvent(r,!0),this.cancel(e),!0}return!1}resize(e,r){if(e===this.cols&&r===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,r)}_afterResize(e,r){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(uO));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(hu.ESC+"[I"):this.coreService.triggerDataEvent(hu.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let r=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${hu.ESC}[4;${s};${r}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${hu.ESC}[6;${n};${i}t`)}}cancel(e,r){if(!(!this.options.cancelEvents&&!r))return e.preventDefault(),e.stopPropagation(),!1}},f$=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,r){let s={instance:r,dispose:r.dispose,isDisposed:!1};this._addons.push(s),r.dispose=()=>this._wrappedAddonDispose(s),r.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let r=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){r=s;break}if(-1===r)throw Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(r,1)}},fK=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,r){if(!(e<0||e>=this._line.length))return r?(this._line.loadCell(e,r),r):this._line.loadCell(e,new lR)}translateToString(e,r,s){return this._line.translateToString(e,r,s)}},fU=class{constructor(e,r){this._buffer=e,this.type=r}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let r=this._buffer.lines.get(e);if(r)return new fK(r)}getNullCell(){return new lR}},fq=class extends cs{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new cD),this.onBufferChange=this._onBufferChange.event,this._normal=new fU(this._core.buffers.normal,"normal"),this._alternate=new fU(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},fV=class{constructor(e){this._core=e}registerCsiHandler(e,r){return this._core.registerCsiHandler(e,e=>r(e.toArray()))}addCsiHandler(e,r){return this.registerCsiHandler(e,r)}registerDcsHandler(e,r){return this._core.registerDcsHandler(e,(e,s)=>r(e,s.toArray()))}addDcsHandler(e,r){return this.registerDcsHandler(e,r)}registerEscHandler(e,r){return this._core.registerEscHandler(e,r)}addEscHandler(e,r){return this.registerEscHandler(e,r)}registerOscHandler(e,r){return this._core.registerOscHandler(e,r)}addOscHandler(e,r){return this.registerOscHandler(e,r)}},fY=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},fX=["cols","rows"],fG=0,fJ=class extends cs{constructor(e){super(),this._core=this._register(new fH(e)),this._addonManager=this._register(new f$),this._publicOptions={...this._core.options};let r=e=>this._core.options[e],s=(e,r)=>{this._checkReadonlyOptions(e),this._core.options[e]=r};for(let e in this._core.options){let i={get:r.bind(this,e),set:s.bind(this,e)};Object.defineProperty(this._publicOptions,e,i)}}_checkReadonlyOptions(e){if(fX.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new fV(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new fY(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new fq(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,r="none";switch(this._core.coreMouseService.activeProtocol){case"X10":r="x10";break;case"VT200":r="vt200";break;case"DRAG":r="drag";break;case"ANY":r="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:r,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let r in e)this._publicOptions[r]=e[r]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,r=!0){this._core.input(e,r)}resize(e,r){this._verifyIntegers(e,r),this._core.resize(e,r)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,r,s){this._verifyIntegers(e,r,s),this._core.select(e,r,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,r){this._verifyIntegers(e,r),this._core.selectLines(e,r)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,r){this._core.write(e,r)}writeln(e,r){this._core.write(e),this._core.write(`\r
22
+ `,r)}paste(e){this._core.paste(e)}refresh(e,r){this._verifyIntegers(e,r),this._core.refresh(e,r)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return lx},set promptLabel(t){lx=t},get tooMuchOutput(){return l_},set tooMuchOutput(t){l_=t}}}_verifyIntegers(...e){for(fG of e)if(fG===1/0||isNaN(fG)||fG%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(fG of e)if(fG&&(fG===1/0||isNaN(fG)||fG%1!=0||fG<0))throw Error("This API only accepts positive integers")}},fZ=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let r=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(r._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(0===e.css.cell.width||0===e.css.cell.height)return;let r=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom;return{cols:Math.max(2,Math.floor((n-(a.right+a.left)-r)/e.css.cell.width)),rows:Math.max(1,Math.floor((i-l)/e.css.cell.height))}}},fQ=class{constructor(e,r,s,i={}){this._terminal=e,this._regex=r,this._handler=s,this._options=i}provideLinks(e,r){let s=f0.computeLink(e,this._regex,this._terminal,this._handler);r(this._addCallbacks(s))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(r,s)=>{if(this._options.hover){let{range:i}=e;this._options.hover(r,s,i)}},e))}},f0=class e{static computeLink(r,s,i,n){let o=RegExp(s.source,(s.flags||"")+"g"),[a,l]=e._getWindowedLineStrings(r-1,i),c=a.join(""),d,h=[];for(;d=o.exec(c);){let r=d[0];if(!function(e){try{let r=new URL(e),s=r.password&&r.username?`${r.protocol}//${r.username}:${r.password}@${r.host}`:r.username?`${r.protocol}//${r.username}@${r.host}`:`${r.protocol}//${r.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}(r))continue;let[s,o]=e._mapStrIdx(i,l,0,d.index),[a,c]=e._mapStrIdx(i,s,o,r.length);if(-1===s||-1===o||-1===a||-1===c)continue;let u={start:{x:o+1,y:s+1},end:{x:c,y:a+1}};h.push({range:u,text:r,activate:n})}return h}static _getWindowedLineStrings(e,r){let s,i=e,n=e,o=0,a="",l=[];if(s=r.buffer.active.getLine(e)){let e=s.translateToString(!0);if(s.isWrapped&&" "!==e[0]){for(o=0;(s=r.buffer.active.getLine(--i))&&o<2048&&(o+=(a=s.translateToString(!0)).length,l.push(a),!(!s.isWrapped||-1!==a.indexOf(" "))););l.reverse()}for(l.push(e),o=0;(s=r.buffer.active.getLine(++n))&&s.isWrapped&&o<2048&&(o+=(a=s.translateToString(!0)).length,l.push(a),-1===a.indexOf(" ")););}return[l,i]}static _mapStrIdx(e,r,s,i){let n=e.buffer.active,o=n.getNullCell(),a=s;for(;i;){let e=n.getLine(r);if(!e)return[-1,-1];for(let s=a;s<e.length;++s){e.getCell(s,o);let a=o.getChars();if(o.getWidth()&&(i-=a.length||1,s===e.length-1&&""===a)){let e=n.getLine(r+1);e&&e.isWrapped&&(e.getCell(0,o),2===o.getWidth()&&(i+=1))}if(i<0)return[r,s]}r++,a=0}return[r,a]}},f1=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function f2(e,r){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}var f5=class{constructor(e=f2,r={}){this._handler=e,this._options=r}activate(e){this._terminal=e;let r=this._options,s=r.urlRegex||f1;this._linkProvider=this._terminal.registerLinkProvider(new fQ(this._terminal,s,this._handler,r))}dispose(){this._linkProvider?.dispose()}};function f3({logs:e,isPty:r,className:s,onInput:i,onResize:n}){let o=(0,W.useRef)(null),a=(0,W.useRef)(null),l=(0,W.useRef)(null),c=(0,W.useRef)(0);return(0,W.useEffect)(()=>{if(!o.current||a.current)return;let e=new fJ({cursorBlink:r,cursorStyle:r?"block":"underline",disableStdin:!r,convertEol:!0,fontSize:13,fontFamily:'Menlo, Monaco, "Courier New", monospace',theme:{background:"#09090b",foreground:"#fafafa",cursor:r?"#fafafa":"#09090b",cursorAccent:"#09090b",selectionBackground:"#3f3f46",black:"#09090b",red:"#f87171",green:"#4ade80",yellow:"#facc15",blue:"#60a5fa",magenta:"#c084fc",cyan:"#22d3ee",white:"#fafafa",brightBlack:"#71717a",brightRed:"#fca5a5",brightGreen:"#86efac",brightYellow:"#fde047",brightBlue:"#93c5fd",brightMagenta:"#d8b4fe",brightCyan:"#67e8f9",brightWhite:"#ffffff"},allowProposedApi:!0}),s=new fZ,d=new f5;return e.loadAddon(s),e.loadAddon(d),e.open(o.current),setTimeout(()=>{try{s.fit(),r&&n?.(e.cols,e.rows)}catch{}},0),a.current=e,l.current=s,r&&i&&e.onData(e=>{i(e)}),r&&n&&e.onResize(({cols:e,rows:r})=>{n(e,r)}),()=>{e.dispose(),a.current=null,l.current=null,c.current=0}},[r,i,n]),(0,W.useEffect)(()=>{if(a.current){e.length<c.current&&(a.current.reset(),c.current=0);for(let r=c.current;r<e.length;r++){let s=e[r];"pty"===s.type?a.current.write(s.data):("stdout"===s.type||"stderr"===s.type)&&a.current.write(s.data)}c.current=e.length}},[e]),(0,W.useEffect)(()=>{if(!o.current||!l.current)return;let e=new ResizeObserver(()=>{try{l.current?.fit()}catch{}});return e.observe(o.current),()=>{e.disconnect()}},[]),(0,F.jsx)("div",{ref:o,className:(0,iu.cn)("h-[300px] rounded-md border bg-zinc-950 overflow-hidden",s)})}let f4=(0,ic.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]),f6=[{name:"Dev Server",command:"pnpm dev",executor_type:"command",pty:!0,description:"Start the development server with hot reload"},{name:"Build",command:"pnpm build",executor_type:"command",pty:!0,description:"Build the project for production"},{name:"Lint",command:"pnpm lint",executor_type:"command",pty:!0,description:"Run the linter to check code quality"},{name:"Type Check",command:"npx tsc --noEmit",executor_type:"command",pty:!0,description:"Run TypeScript type checking without emitting files"},{name:"Test",command:"pnpm test",executor_type:"command",pty:!0,description:"Run the test suite"},{name:"Rebase on and merge into main",command:"Our goal is to sync the current local branch with the local branch/worktree `main`. The two branches may have diverged.\n\nPlease do the following in order. Only proceed to the next step if the previous step succeeds:\n\n1. Rebase the current local branch onto the local branch `main`, and resolve any conflicts if needed.\n2. If, after the rebase, `main` does not yet contain the current branch's commits, switch to the `main` branch/worktree and merge the current branch into `main` using `git merge`. Do not use `git branch -f`.\n3. If the current branch is already fully contained in `main`, and `main` has newer commits, update the current branch so it includes the latest commits from `main`.\n4. Push both the current local branch and the local branch `main` to the remote.",executor_type:"prompt",pty:!1,description:"Rebase current branch onto main, merge into main, and push both branches"},{name:"Reset to main",command:"git reset --hard main",executor_type:"command",pty:!0,description:"Hard reset the current branch to match main"},{name:"Push to remote",command:"git push --force-with-lease",executor_type:"command",pty:!0,description:"Force push to remote with lease safety check"},{name:"Git commit",command:"Inspect the modified and untracked and deleted files in the current repository, generate an appropriate commit message, and commit all relevant files.\n\nCommit message rules:\n- Use Conventional Commits format (feat:, fix:, chore:, refactor:, docs:, test:, ci:, build:, perf:, style:, etc.)\n- Choose the type that best matches the main purpose of the changes\n- Make the message specific to the actual changes\n- Keep it within 50 characters if possible\n- Use lowercase\n- Do not end with a period\n- Do not wrap the message in quotes, backticks, or markdown\n\nCommit requirements:\n- Include all relevant modified and untracked files\n- Do not include unrelated files\n- If there are no meaningful changes to commit, do not create a commit\n\nWhen finished, output only the final commit message.",executor_type:"prompt",pty:!1,description:"Inspect changes, generate a conventional commit message, and commit"}];function f8({open:e,onOpenChange:r,executor:s,onSubmit:i}){let[n,o]=(0,W.useState)(s?.name??""),[a,l]=(0,W.useState)(s?.executor_type??"command"),[c,d]=(0,W.useState)(s?.prompt_provider??"claude"),[h,u]=(0,W.useState)(s?.command??""),[f,p]=(0,W.useState)(s?.cwd??""),[m,g]=(0,W.useState)(s?.pty??!0),[v,x]=(0,W.useState)(!1),[_,y]=(0,W.useState)(!1),[b,w]=(0,W.useState)(null),[S,C]=(0,W.useState)(null),[k,j]=(0,W.useState)(""),N=!!s;(0,W.useEffect)(()=>{e&&(y(!1),w(null),C(null),j(""),s&&(o(s.name),l(s.executor_type??"command"),d(s.prompt_provider??"claude"),u(s.command),p(s.cwd??""),g(s.pty)))},[e]);let E=async e=>{if(e.preventDefault(),n.trim()&&h.trim()){x(!0);try{await i({name:n.trim(),command:h.trim(),executor_type:a,prompt_provider:"prompt"===a?c:null,cwd:f.trim()||void 0,pty:"prompt"===a||m}),r(!1),N||(o(""),l("command"),d("claude"),u(""),p(""),g(!0))}finally{x(!1)}}};return(0,F.jsx)(ns,{open:e,onOpenChange:r,children:(0,F.jsxs)(no,{children:[(0,F.jsx)(na,{children:(0,F.jsxs)("div",{className:"flex items-center justify-between pr-6",children:[(0,F.jsx)(nc,{children:_?"Select Preset":N?"Edit Executor":"Add Executor"}),!N&&!_&&(0,F.jsx)("button",{type:"button",className:"text-sm text-muted-foreground hover:text-foreground transition-colors",onClick:()=>y(!0),children:"Select from presets"})]})}),(0,F.jsxs)("div",{className:"h-[420px] flex flex-col",children:[!_&&(0,F.jsxs)("form",{onSubmit:E,className:"space-y-4 flex-1 flex flex-col",children:[(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,F.jsx)(nh,{placeholder:"e.g., Dev Server",value:n,onChange:e=>o(e.target.value),required:!0})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Type"}),(0,F.jsxs)("div",{className:"flex rounded-md border border-input overflow-hidden",children:[(0,F.jsx)("button",{type:"button",className:(0,iu.cn)("flex-1 px-3 py-1.5 text-sm font-medium transition-colors","command"===a?"bg-primary text-primary-foreground":"bg-background text-muted-foreground hover:bg-muted"),onClick:()=>l("command"),children:"Command"}),(0,F.jsx)("button",{type:"button",className:(0,iu.cn)("flex-1 px-3 py-1.5 text-sm font-medium transition-colors border-l border-input","prompt"===a?"bg-primary text-primary-foreground":"bg-background text-muted-foreground hover:bg-muted"),onClick:()=>l("prompt"),children:"Prompt"})]})]}),"prompt"===a&&(0,F.jsxs)("div",{className:"flex gap-3",children:[(0,F.jsxs)("div",{className:"w-[140px] shrink-0 space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Provider"}),(0,F.jsxs)(aB,{value:c,onValueChange:e=>d(e),children:[(0,F.jsx)(aO,{className:"w-full",children:(0,F.jsx)(aA,{})}),(0,F.jsxs)(aI,{children:[(0,F.jsx)(az,{value:"claude",children:"Claude"}),(0,F.jsx)(az,{value:"codex",children:"Codex"})]})]})]}),(0,F.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,F.jsxs)("label",{className:"text-sm font-medium",children:["Working Directory"," ",(0,F.jsx)("span",{className:"text-muted-foreground",children:"(optional)"})]}),(0,F.jsx)(nh,{placeholder:"Relative to worktree root",value:f,onChange:e=>p(e.target.value)})]})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"prompt"===a?"Prompt":"Command"}),"prompt"===a?(0,F.jsx)("textarea",{className:"flex min-h-[90px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-y",placeholder:"e.g., Review the code and suggest improvements",value:h,onChange:e=>u(e.target.value),required:!0}):(0,F.jsx)(nh,{placeholder:"e.g., npm run dev",value:h,onChange:e=>u(e.target.value),required:!0})]}),"command"===a&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsxs)("label",{className:"text-sm font-medium",children:["Working Directory"," ",(0,F.jsx)("span",{className:"text-muted-foreground",children:"(optional)"})]}),(0,F.jsx)(nh,{placeholder:"Relative to worktree root (leave empty for root)",value:f,onChange:e=>p(e.target.value)})]}),"command"===a&&(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("div",{className:"space-y-0.5",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Terminal Mode (PTY)"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enable for interactive commands like top, vim, htop"})]}),(0,F.jsx)("button",{type:"button",role:"switch","aria-checked":m,onClick:()=>g(!m),className:(0,iu.cn)("relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",m?"bg-primary":"bg-input"),children:(0,F.jsx)("span",{className:(0,iu.cn)("pointer-events-none inline-block h-5 w-5 transform rounded-full bg-background shadow-lg ring-0 transition-transform",m?"translate-x-5":"translate-x-0")})})]}),(0,F.jsx)("div",{className:"flex-1"}),(0,F.jsxs)(nl,{children:[(0,F.jsx)($.Button,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,F.jsx)($.Button,{type:"submit",disabled:v||!n.trim()||!h.trim(),children:v?"Saving...":N?"Save":"Add"})]})]}),_&&(0,F.jsxs)("div",{className:"space-y-4 flex-1 flex flex-col min-h-0",children:[(0,F.jsx)(nh,{placeholder:"Search presets...",value:k,onChange:e=>j(e.target.value),autoFocus:!0}),(0,F.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 space-y-1",children:f6.filter(e=>{if(!k.trim())return!0;let r=k.toLowerCase();return e.name.toLowerCase().includes(r)||e.command.toLowerCase().includes(r)||(e.description?.toLowerCase().includes(r)??!1)}).map(e=>{let r=b?.command===e.command,s=S===e.command;return(0,F.jsxs)("div",{className:"rounded-md overflow-hidden",children:[(0,F.jsxs)("button",{type:"button",className:(0,iu.cn)("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",r?"bg-primary/10 text-primary":"hover:bg-muted"),onClick:()=>w(e),children:["command"===e.executor_type?(0,F.jsx)(nL.Terminal,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,F.jsx)(f4,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsx)("span",{className:"font-medium flex-1 text-left",children:e.name}),(0,F.jsx)("button",{type:"button",className:"shrink-0 p-0.5 rounded hover:bg-muted-foreground/10 transition-colors",onClick:r=>{r.stopPropagation(),C(s?null:e.command)},children:s?(0,F.jsx)(aL,{className:"h-4 w-4 text-muted-foreground"}):(0,F.jsx)(id,{className:"h-4 w-4 text-muted-foreground"})})]}),s&&(0,F.jsxs)("div",{className:(0,iu.cn)("px-3 pb-2 pt-1 text-xs text-muted-foreground space-y-1 border-t border-border/50",r?"bg-primary/5":"bg-muted/50"),children:[e.description&&(0,F.jsx)("p",{children:e.description}),(0,F.jsx)("pre",{className:"whitespace-pre-wrap break-all bg-muted/50 rounded px-2 py-1 font-mono",children:e.command}),(0,F.jsxs)("div",{className:"flex gap-3",children:[(0,F.jsxs)("span",{children:["Type: ",(0,F.jsx)("span",{className:"font-medium text-foreground/70",children:e.executor_type})]}),(0,F.jsxs)("span",{children:["PTY: ",(0,F.jsx)("span",{className:"font-medium text-foreground/70",children:e.pty?"on":"off"})]})]})]})]},e.command)})}),(0,F.jsxs)(nl,{children:[(0,F.jsx)($.Button,{type:"button",variant:"outline",onClick:()=>{y(!1),w(null),C(null)},children:"Cancel"}),(0,F.jsx)($.Button,{type:"button",disabled:!b,onClick:()=>{b&&(o(b.name),u(b.command),l(b.executor_type),g(b.pty),y(!1),w(null),C(null))},children:"Select"})]})]})]})]})})}function f7(e,r){let[s,i]=(0,W.useState)([]),[n,o]=(0,W.useState)("closed"),[a,l]=(0,W.useState)(null),[c,d]=(0,W.useState)(!1),h=(0,W.useRef)(null),u=(0,W.useRef)(null),f=(0,W.useRef)(0),p=(0,W.useRef)(null),m=(0,W.useRef)(!1),g=(0,W.useCallback)(()=>{i([]),l(null),d(!1)},[]),v=(0,W.useCallback)(e=>{h.current?.readyState===WebSocket.OPEN&&h.current.send(JSON.stringify({type:"input",data:e}))},[]),x=(0,W.useCallback)((e,r)=>{h.current?.readyState===WebSocket.OPEN?h.current.send(JSON.stringify({type:"resize",cols:e,rows:r})):u.current={cols:e,rows:r}},[]);return(0,W.useEffect)(()=>{if(!e)return;i([]),l(null),d(!1),m.current=!1,f.current=0;let r=!1;return!function s(){if(r||m.current)return;o("connecting");let n=(0,iT.getWebSocketUrl)(`/api/executor-processes/${e}/logs`);console.log(`[useExecutorLogs] Connecting to WebSocket: ${n}`);let a=new WebSocket(n);h.current=a,a.onopen=()=>{if(!r&&(console.log("[useExecutorLogs] WebSocket connected"),o("connected"),i([]),f.current=0,u.current)){let{cols:e,rows:r}=u.current;a.send(JSON.stringify({type:"resize",cols:e,rows:r})),u.current=null}},a.onmessage=e=>{if(!r)try{let r=JSON.parse(e.data);"init"===r.type?d(r.isPty):"finished"===r.type?(m.current=!0,l(r.exitCode),o("closed")):"error"===r.type?o("error"):i(e=>[...e,r])}catch(e){console.error("Failed to parse WebSocket message:",e)}},a.onerror=e=>{r||console.error("[useExecutorLogs] WebSocket error:",e)},a.onclose=i=>{if(console.log("[useExecutorLogs] WebSocket closed:",i.code,i.reason),h.current=null,m.current||r||!e?.startsWith("remote-"))return void o("closed");if(f.current<8){let e=f.current,i=Math.min(15e3,1e3*Math.pow(2,e)),n=i*Math.random()*.25,a=i+n;console.log(`[useExecutorLogs] Scheduling reconnect in ${Math.round(a)}ms (attempt ${e+1}/8)`),o("connecting"),f.current=e+1,p.current=setTimeout(()=>{p.current=null,r||s()},a)}else console.log("[useExecutorLogs] Max reconnect attempts reached"),o("error")}}(),()=>{r=!0,p.current&&(clearTimeout(p.current),p.current=null),h.current&&(h.current.close(),h.current=null)}},[e,r]),{logs:s,status:n,exitCode:a,isPty:c,clearLogs:g,sendInput:v,sendResize:x}}let f9="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function pe(e){let r=Object.prototype.toString.call(e);return"[object Window]"===r||"[object global]"===r}function pt(e){return"nodeType"in e}function pr(e){var r,s;return e?pe(e)?e:pt(e)&&null!=(r=null==(s=e.ownerDocument)?void 0:s.defaultView)?r:window:window}function ps(e){let{Document:r}=pr(e);return e instanceof r}function pi(e){return!pe(e)&&e instanceof pr(e).HTMLElement}function pn(e){return e instanceof pr(e).SVGElement}function po(e){return e?pe(e)?e.document:pt(e)?ps(e)?e:pi(e)||pn(e)?e.ownerDocument:document:document:document}let pa=f9?W.useLayoutEffect:W.useEffect;function pl(e){let r=(0,W.useRef)(e);return pa(()=>{r.current=e}),(0,W.useCallback)(function(){for(var e=arguments.length,s=Array(e),i=0;i<e;i++)s[i]=arguments[i];return null==r.current?void 0:r.current(...s)},[])}function pc(e,r){void 0===r&&(r=[e]);let s=(0,W.useRef)(e);return pa(()=>{s.current!==e&&(s.current=e)},r),s}function pd(e,r){let s=(0,W.useRef)();return(0,W.useMemo)(()=>{let r=e(s.current);return s.current=r,r},[...r])}function ph(e){let r=pl(e),s=(0,W.useRef)(null),i=(0,W.useCallback)(e=>{e!==s.current&&(null==r||r(e,s.current)),s.current=e},[]);return[s,i]}function pu(e){let r=(0,W.useRef)();return(0,W.useEffect)(()=>{r.current=e},[e]),r.current}let pf={};function pp(e,r){return(0,W.useMemo)(()=>{if(r)return r;let s=null==pf[e]?0:pf[e]+1;return pf[e]=s,e+"-"+s},[e,r])}function pm(e){return function(r){for(var s=arguments.length,i=Array(s>1?s-1:0),n=1;n<s;n++)i[n-1]=arguments[n];return i.reduce((r,s)=>{for(let[i,n]of Object.entries(s)){let s=r[i];null!=s&&(r[i]=s+e*n)}return r},{...r})}}let pg=pm(1),pv=pm(-1);function px(e){if(!e)return!1;let{KeyboardEvent:r}=pr(e.target);return r&&e instanceof r}function p_(e){if(function(e){if(!e)return!1;let{TouchEvent:r}=pr(e.target);return r&&e instanceof r}(e)){if(e.touches&&e.touches.length){let{clientX:r,clientY:s}=e.touches[0];return{x:r,y:s}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:r,clientY:s}=e.changedTouches[0];return{x:r,y:s}}}return"clientX"in e&&"clientY"in e?{x:e.clientX,y:e.clientY}:null}let py=Object.freeze({Translate:{toString(e){if(!e)return;let{x:r,y:s}=e;return"translate3d("+(r?Math.round(r):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;let{scaleX:r,scaleY:s}=e;return"scaleX("+r+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[py.Translate.toString(e),py.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:r,duration:s,easing:i}=e;return r+" "+s+"ms "+i}}}),pb="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]",pw={display:"none"};function pS(e){let{id:r,value:s}=e;return W.default.createElement("div",{id:r,style:pw},s)}function pC(e){let{id:r,announcement:s,ariaLiveType:i="assertive"}=e;return W.default.createElement("div",{id:r,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":i,"aria-atomic":!0},s)}let pk=(0,W.createContext)(null),pj={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},pN={onDragStart(e){let{active:r}=e;return"Picked up draggable item "+r.id+"."},onDragOver(e){let{active:r,over:s}=e;return s?"Draggable item "+r.id+" was moved over droppable area "+s.id+".":"Draggable item "+r.id+" is no longer over a droppable area."},onDragEnd(e){let{active:r,over:s}=e;return s?"Draggable item "+r.id+" was dropped over droppable area "+s.id:"Draggable item "+r.id+" was dropped."},onDragCancel(e){let{active:r}=e;return"Dragging was cancelled. Draggable item "+r.id+" was dropped."}};function pE(e){var r;let s,{announcements:i=pN,container:n,hiddenTextDescribedById:o,screenReaderInstructions:a=pj}=e,{announce:l,announcement:c}=function(){let[e,r]=(0,W.useState)("");return{announce:(0,W.useCallback)(e=>{null!=e&&r(e)},[]),announcement:e}}(),d=pp("DndLiveRegion"),[h,u]=(0,W.useState)(!1);if((0,W.useEffect)(()=>{u(!0)},[]),r=(0,W.useMemo)(()=>({onDragStart(e){let{active:r}=e;l(i.onDragStart({active:r}))},onDragMove(e){let{active:r,over:s}=e;i.onDragMove&&l(i.onDragMove({active:r,over:s}))},onDragOver(e){let{active:r,over:s}=e;l(i.onDragOver({active:r,over:s}))},onDragEnd(e){let{active:r,over:s}=e;l(i.onDragEnd({active:r,over:s}))},onDragCancel(e){let{active:r,over:s}=e;l(i.onDragCancel({active:r,over:s}))}}),[l,i]),s=(0,W.useContext)(pk),(0,W.useEffect)(()=>{if(!s)throw Error("useDndMonitor must be used within a children of <DndContext>");return s(r)},[r,s]),!h)return null;let f=W.default.createElement(W.default.Fragment,null,W.default.createElement(pS,{id:o,value:a.draggable}),W.default.createElement(pC,{id:d,announcement:c}));return n?(0,G.createPortal)(f,n):f}function pR(){}function pM(e,r){return(0,W.useMemo)(()=>({sensor:e,options:null!=r?r:{}}),[e,r])}(_=E||(E={})).DragStart="dragStart",_.DragMove="dragMove",_.DragEnd="dragEnd",_.DragCancel="dragCancel",_.DragOver="dragOver",_.RegisterDroppable="registerDroppable",_.SetDroppableDisabled="setDroppableDisabled",_.UnregisterDroppable="unregisterDroppable";let pD=Object.freeze({x:0,y:0});function pT(e,r){return Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))}function pP(e,r){let{data:{value:s}}=e,{data:{value:i}}=r;return s-i}function pL(e,r){let{data:{value:s}}=e,{data:{value:i}}=r;return i-s}function pB(e){let{left:r,top:s,height:i,width:n}=e;return[{x:r,y:s},{x:r+n,y:s},{x:r,y:s+i},{x:r+n,y:s+i}]}function pA(e,r){if(!e||0===e.length)return null;let[s]=e;return r?s[r]:s}function pO(e,r,s){return void 0===r&&(r=e.left),void 0===s&&(s=e.top),{x:r+.5*e.width,y:s+.5*e.height}}let pI=e=>{let{collisionRect:r,droppableRects:s,droppableContainers:i}=e,n=[];for(let e of i){let{id:i}=e,o=s.get(i);if(o){let s=function(e,r){let s=Math.max(r.top,e.top),i=Math.max(r.left,e.left),n=Math.min(r.left+r.width,e.left+e.width),o=Math.min(r.top+r.height,e.top+e.height);if(i<n&&s<o){let a=r.width*r.height,l=e.width*e.height,c=(n-i)*(o-s);return Number((c/(a+l-c)).toFixed(4))}return 0}(o,r);s>0&&n.push({id:i,data:{droppableContainer:e,value:s}})}}return n.sort(pL)};function pz(e,r){return e&&r?{x:e.left-r.left,y:e.top-r.top}:pD}let pF=function(e){for(var r=arguments.length,s=Array(r>1?r-1:0),i=1;i<r;i++)s[i-1]=arguments[i];return s.reduce((e,r)=>({...e,top:e.top+ +r.y,bottom:e.bottom+ +r.y,left:e.left+ +r.x,right:e.right+ +r.x}),{...e})},pW={ignoreTransform:!1};function pH(e,r){void 0===r&&(r=pW);let s=e.getBoundingClientRect();if(r.ignoreTransform){let{transform:r,transformOrigin:i}=pr(e).getComputedStyle(e);r&&(s=function(e,r,s){let i=function(e){if(e.startsWith("matrix3d(")){let r=e.slice(9,-1).split(/, /);return{x:+r[12],y:+r[13],scaleX:+r[0],scaleY:+r[5]}}if(e.startsWith("matrix(")){let r=e.slice(7,-1).split(/, /);return{x:+r[4],y:+r[5],scaleX:+r[0],scaleY:+r[3]}}return null}(r);if(!i)return e;let{scaleX:n,scaleY:o,x:a,y:l}=i,c=e.left-a-(1-n)*parseFloat(s),d=e.top-l-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),h=n?e.width/n:e.width,u=o?e.height/o:e.height;return{width:h,height:u,top:d,right:c+h,bottom:d+u,left:c}}(s,r,i))}let{top:i,left:n,width:o,height:a,bottom:l,right:c}=s;return{top:i,left:n,width:o,height:a,bottom:l,right:c}}function p$(e){return pH(e,{ignoreTransform:!0})}function pK(e,r){let s=[];return e?function i(n){var o,a;let l;if(null!=r&&s.length>=r||!n)return s;if(ps(n)&&null!=n.scrollingElement&&!s.includes(n.scrollingElement))return s.push(n.scrollingElement),s;if(!pi(n)||pn(n)||s.includes(n))return s;let c=pr(e).getComputedStyle(n);return(n!==e&&(void 0===(o=c)&&(o=pr(n).getComputedStyle(n)),l=/(auto|scroll|overlay)/,["overflow","overflowX","overflowY"].some(e=>{let r=o[e];return"string"==typeof r&&l.test(r)}))&&s.push(n),void 0===(a=c)&&(a=pr(n).getComputedStyle(n)),"fixed"===a.position)?s:i(n.parentNode)}(e):s}function pU(e){let[r]=pK(e,1);return null!=r?r:null}function pq(e){return f9&&e?pe(e)?e:pt(e)?ps(e)||e===po(e).scrollingElement?window:pi(e)?e:null:null:null}function pV(e){return pe(e)?e.scrollX:e.scrollLeft}function pY(e){return pe(e)?e.scrollY:e.scrollTop}function pX(e){return{x:pV(e),y:pY(e)}}function pG(e){return!!f9&&!!e&&e===document.scrollingElement}function pJ(e){let r={x:0,y:0},s=pG(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},i={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},n=e.scrollTop<=r.y,o=e.scrollLeft<=r.x;return{isTop:n,isLeft:o,isBottom:e.scrollTop>=i.y,isRight:e.scrollLeft>=i.x,maxScroll:i,minScroll:r}}(y=R||(R={}))[y.Forward=1]="Forward",y[y.Backward=-1]="Backward";let pZ={x:.2,y:.2};function pQ(e){return e.reduce((e,r)=>pg(e,pX(r)),pD)}let p0=[["x",["left","right"],function(e){return e.reduce((e,r)=>e+pV(r),0)}],["y",["top","bottom"],function(e){return e.reduce((e,r)=>e+pY(r),0)}]];class p1{constructor(e,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=pK(r),i=pQ(s);for(const[r,n,o]of(this.rect={...e},this.width=e.width,this.height=e.height,p0))for(const e of n)Object.defineProperty(this,e,{get:()=>{let n=o(s),a=i[r]-n;return this.rect[e]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class p2{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>{var r;return null==(r=this.target)?void 0:r.removeEventListener(...e)})},this.target=e}add(e,r,s){var i;null==(i=this.target)||i.addEventListener(e,r,s),this.listeners.push([e,r,s])}}function p5(e,r){let s=Math.abs(e.x),i=Math.abs(e.y);return"number"==typeof r?Math.sqrt(s**2+i**2)>r:"x"in r&&"y"in r?s>r.x&&i>r.y:"x"in r?s>r.x:"y"in r&&i>r.y}function p3(e){e.preventDefault()}function p4(e){e.stopPropagation()}(b=M||(M={})).Click="click",b.DragStart="dragstart",b.Keydown="keydown",b.ContextMenu="contextmenu",b.Resize="resize",b.SelectionChange="selectionchange",b.VisibilityChange="visibilitychange",(w=D||(D={})).Space="Space",w.Down="ArrowDown",w.Right="ArrowRight",w.Left="ArrowLeft",w.Up="ArrowUp",w.Esc="Escape",w.Enter="Enter",w.Tab="Tab";let p6={start:[D.Space,D.Enter],cancel:[D.Esc],end:[D.Space,D.Enter,D.Tab]},p8=(e,r)=>{let{currentCoordinates:s}=r;switch(e.code){case D.Right:return{...s,x:s.x+25};case D.Left:return{...s,x:s.x-25};case D.Down:return{...s,y:s.y+25};case D.Up:return{...s,y:s.y-25}}};class p7{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:r}}=e;this.props=e,this.listeners=new p2(po(r)),this.windowListeners=new p2(pr(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(M.Resize,this.handleCancel),this.windowListeners.add(M.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(M.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:r}=this.props,s=e.node.current;s&&function(e,r){if(void 0===r&&(r=pH),!e)return;let{top:s,left:i,bottom:n,right:o}=r(e);pU(e)&&(n<=0||o<=0||s>=window.innerHeight||i>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(s),r(pD)}handleKeyDown(e){if(px(e)){let{active:r,context:s,options:i}=this.props,{keyboardCodes:n=p6,coordinateGetter:o=p8,scrollBehavior:a="smooth"}=i,{code:l}=e;if(n.end.includes(l))return void this.handleEnd(e);if(n.cancel.includes(l))return void this.handleCancel(e);let{collisionRect:c}=s.current,d=c?{x:c.left,y:c.top}:pD;this.referenceCoordinates||(this.referenceCoordinates=d);let h=o(e,{active:r,context:s.current,currentCoordinates:d});if(h){let r=pv(h,d),i={x:0,y:0},{scrollableAncestors:n}=s.current;for(let s of n){let n=e.code,{isTop:o,isRight:l,isLeft:c,isBottom:d,maxScroll:u,minScroll:f}=pJ(s),p=function(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:r}=window;return{top:0,left:0,right:e,bottom:r,width:e,height:r}}let{top:r,left:s,right:i,bottom:n}=e.getBoundingClientRect();return{top:r,left:s,right:i,bottom:n,width:e.clientWidth,height:e.clientHeight}}(s),m={x:Math.min(n===D.Right?p.right-p.width/2:p.right,Math.max(n===D.Right?p.left:p.left+p.width/2,h.x)),y:Math.min(n===D.Down?p.bottom-p.height/2:p.bottom,Math.max(n===D.Down?p.top:p.top+p.height/2,h.y))},g=n===D.Right&&!l||n===D.Left&&!c,v=n===D.Down&&!d||n===D.Up&&!o;if(g&&m.x!==h.x){let e=s.scrollLeft+r.x,o=n===D.Right&&e<=u.x||n===D.Left&&e>=f.x;if(o&&!r.y)return void s.scrollTo({left:e,behavior:a});o?i.x=s.scrollLeft-e:i.x=n===D.Right?s.scrollLeft-u.x:s.scrollLeft-f.x,i.x&&s.scrollBy({left:-i.x,behavior:a});break}if(v&&m.y!==h.y){let e=s.scrollTop+r.y,o=n===D.Down&&e<=u.y||n===D.Up&&e>=f.y;if(o&&!r.x)return void s.scrollTo({top:e,behavior:a});o?i.y=s.scrollTop-e:i.y=n===D.Down?s.scrollTop-u.y:s.scrollTop-f.y,i.y&&s.scrollBy({top:-i.y,behavior:a});break}}this.handleMove(e,pg(pv(h,this.referenceCoordinates),i))}}}handleMove(e,r){let{onMove:s}=this.props;e.preventDefault(),s(r)}handleEnd(e){let{onEnd:r}=this.props;e.preventDefault(),this.detach(),r()}handleCancel(e){let{onCancel:r}=this.props;e.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function p9(e){return!!(e&&"distance"in e)}function me(e){return!!(e&&"delay"in e)}p7.activators=[{eventName:"onKeyDown",handler:(e,r,s)=>{let{keyboardCodes:i=p6,onActivation:n}=r,{active:o}=s,{code:a}=e.nativeEvent;if(i.start.includes(a)){let r=o.activatorNode.current;return(!r||e.target===r)&&(e.preventDefault(),null==n||n({event:e.nativeEvent}),!0)}return!1}}];class mt{constructor(e,r,s){var i;void 0===s&&(s=function(e){let{EventTarget:r}=pr(e);return e instanceof r?e:po(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=r;const{event:n}=e,{target:o}=n;this.props=e,this.events=r,this.document=po(o),this.documentListeners=new p2(this.document),this.listeners=new p2(s),this.windowListeners=new p2(pr(o)),this.initialCoordinates=null!=(i=p_(n))?i:pD,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:r,bypassActivationConstraint:s}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(M.Resize,this.handleCancel),this.windowListeners.add(M.DragStart,p3),this.windowListeners.add(M.VisibilityChange,this.handleCancel),this.windowListeners.add(M.ContextMenu,p3),this.documentListeners.add(M.Keydown,this.handleKeydown),r){if(null!=s&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(me(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(p9(r))return void this.handlePending(r)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,r){let{active:s,onPending:i}=this.props;i(s,e,this.initialCoordinates,r)}handleStart(){let{initialCoordinates:e}=this,{onStart:r}=this.props;e&&(this.activated=!0,this.documentListeners.add(M.Click,p4,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(M.SelectionChange,this.removeTextSelection),r(e))}handleMove(e){var r;let{activated:s,initialCoordinates:i,props:n}=this,{onMove:o,options:{activationConstraint:a}}=n;if(!i)return;let l=null!=(r=p_(e))?r:pD,c=pv(i,l);if(!s&&a){if(p9(a)){if(null!=a.tolerance&&p5(c,a.tolerance))return this.handleCancel();if(p5(c,a.distance))return this.handleStart()}return me(a)&&p5(c,a.tolerance)?this.handleCancel():void this.handlePending(a,c)}e.cancelable&&e.preventDefault(),o(l)}handleEnd(){let{onAbort:e,onEnd:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleCancel(){let{onAbort:e,onCancel:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleKeydown(e){e.code===D.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}let mr={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class ms extends mt{constructor(e){const{event:r}=e;super(e,mr,po(r.target))}}ms.activators=[{eventName:"onPointerDown",handler:(e,r)=>{let{nativeEvent:s}=e,{onActivation:i}=r;return!!s.isPrimary&&0===s.button&&(null==i||i({event:s}),!0)}}];(S=T||(T={}))[S.RightClick=2]="RightClick";(C=P||(P={}))[C.Pointer=0]="Pointer",C[C.DraggableRect=1]="DraggableRect",(k=L||(L={}))[k.TreeOrder=0]="TreeOrder",k[k.ReversedTreeOrder=1]="ReversedTreeOrder";let mi={x:{[R.Backward]:!1,[R.Forward]:!1},y:{[R.Backward]:!1,[R.Forward]:!1}};(j=B||(B={}))[j.Always=0]="Always",j[j.BeforeDragging=1]="BeforeDragging",j[j.WhileDragging=2]="WhileDragging",(A||(A={})).Optimized="optimized";let mn=new Map;function mo(e,r){return pd(s=>e?s||("function"==typeof r?r(e):e):null,[r,e])}function ma(e){let{callback:r,disabled:s}=e,i=pl(r),n=(0,W.useMemo)(()=>{if(s||"undefined"==typeof window||void 0===window.ResizeObserver)return;let{ResizeObserver:e}=window;return new e(i)},[s]);return(0,W.useEffect)(()=>()=>null==n?void 0:n.disconnect(),[n]),n}function ml(e){return new p1(pH(e),e)}function mc(e,r,s){void 0===r&&(r=ml);let[i,n]=(0,W.useState)(null);function o(){n(i=>{if(!e)return null;if(!1===e.isConnected){var n;return null!=(n=null!=i?i:s)?n:null}let o=r(e);return JSON.stringify(i)===JSON.stringify(o)?i:o})}let a=function(e){let{callback:r,disabled:s}=e,i=pl(r),n=(0,W.useMemo)(()=>{if(s||"undefined"==typeof window||void 0===window.MutationObserver)return;let{MutationObserver:e}=window;return new e(i)},[i,s]);return(0,W.useEffect)(()=>()=>null==n?void 0:n.disconnect(),[n]),n}({callback(r){if(e)for(let s of r){let{type:r,target:i}=s;if("childList"===r&&i instanceof HTMLElement&&i.contains(e)){o();break}}}}),l=ma({callback:o});return pa(()=>{o(),e?(null==l||l.observe(e),null==a||a.observe(document.body,{childList:!0,subtree:!0})):(null==l||l.disconnect(),null==a||a.disconnect())},[e]),i}let md=[];function mh(e,r){void 0===r&&(r=[]);let s=(0,W.useRef)(null);return(0,W.useEffect)(()=>{s.current=null},r),(0,W.useEffect)(()=>{let r=e!==pD;r&&!s.current&&(s.current=e),!r&&s.current&&(s.current=null)},[e]),s.current?pv(e,s.current):pD}function mu(e){return(0,W.useMemo)(()=>{let r,s;return e?(r=e.innerWidth,{top:0,left:0,right:r,bottom:s=e.innerHeight,width:r,height:s}):null},[e])}let mf=[],mp=[{sensor:ms,options:{}},{sensor:p7,options:{}}],mm={current:{}},mg={draggable:{measure:p$},droppable:{measure:p$,strategy:B.WhileDragging,frequency:A.Optimized},dragOverlay:{measure:pH}};class mv extends Map{get(e){var r;return null!=e&&null!=(r=super.get(e))?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:r}=e;return!r})}getNodeFor(e){var r,s;return null!=(r=null==(s=this.get(e))?void 0:s.node.current)?r:void 0}}let mx={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new mv,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:pR},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:mg,measureDroppableContainers:pR,windowRect:null,measuringScheduled:!1},m_={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:pR,draggableNodes:new Map,over:null,measureDroppableContainers:pR},my=(0,W.createContext)(m_),mb=(0,W.createContext)(mx);function mw(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new mv}}}function mS(e,r){switch(r.type){case E.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:r.initialCoordinates,active:r.active}};case E.DragMove:if(null==e.draggable.active)return e;return{...e,draggable:{...e.draggable,translate:{x:r.coordinates.x-e.draggable.initialCoordinates.x,y:r.coordinates.y-e.draggable.initialCoordinates.y}}};case E.DragEnd:case E.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case E.RegisterDroppable:{let{element:s}=r,{id:i}=s,n=new mv(e.droppable.containers);return n.set(i,s),{...e,droppable:{...e.droppable,containers:n}}}case E.SetDroppableDisabled:{let{id:s,key:i,disabled:n}=r,o=e.droppable.containers.get(s);if(!o||i!==o.key)return e;let a=new mv(e.droppable.containers);return a.set(s,{...o,disabled:n}),{...e,droppable:{...e.droppable,containers:a}}}case E.UnregisterDroppable:{let{id:s,key:i}=r,n=e.droppable.containers.get(s);if(!n||i!==n.key)return e;let o=new mv(e.droppable.containers);return o.delete(s),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function mC(e){let{disabled:r}=e,{active:s,activatorEvent:i,draggableNodes:n}=(0,W.useContext)(my),o=pu(i),a=pu(null==s?void 0:s.id);return(0,W.useEffect)(()=>{if(!r&&!i&&o&&null!=a){if(!px(o)||document.activeElement===o.target)return;let e=n.get(a);if(!e)return;let{activatorNode:r,node:s}=e;(r.current||s.current)&&requestAnimationFrame(()=>{for(let e of[r.current,s.current]){if(!e)continue;let r=e.matches(pb)?e:e.querySelector(pb);if(r){r.focus();break}}})}},[i,r,n,a,o]),null}let mk=(0,W.createContext)({...pD,scaleX:1,scaleY:1});(N=O||(O={}))[N.Uninitialized=0]="Uninitialized",N[N.Initializing=1]="Initializing",N[N.Initialized=2]="Initialized";let mj=(0,W.memo)(function(e){var r,s,i,n,o,a,l,c;let d,h,u,f,p,m,g,v,{id:x,accessibility:_,autoScroll:y=!0,children:b,sensors:w=mp,collisionDetection:S=pI,measuring:C,modifiers:k,...j}=e,[N,M]=(0,W.useReducer)(mS,void 0,mw),[D,T]=function(){let[e]=(0,W.useState)(()=>new Set),r=(0,W.useCallback)(r=>(e.add(r),()=>e.delete(r)),[e]);return[(0,W.useCallback)(r=>{let{type:s,event:i}=r;e.forEach(e=>{var r;return null==(r=e[s])?void 0:r.call(e,i)})},[e]),r]}(),[A,I]=(0,W.useState)(O.Uninitialized),z=A===O.Initialized,{draggable:{active:F,nodes:H,translate:$},droppable:{containers:K}}=N,U=null!=F?H.get(F):null,q=(0,W.useRef)({initial:null,translated:null}),V=(0,W.useMemo)(()=>{var e;return null!=F?{id:F,data:null!=(e=null==U?void 0:U.data)?e:mm,rect:q}:null},[F,U]),Y=(0,W.useRef)(null),[X,J]=(0,W.useState)(null),[Z,Q]=(0,W.useState)(null),ee=pc(j,Object.values(j)),et=pp("DndDescribedBy",x),er=(0,W.useMemo)(()=>K.getEnabled(),[K]),es=(0,W.useMemo)(()=>({draggable:{...mg.draggable,...null==C?void 0:C.draggable},droppable:{...mg.droppable,...null==C?void 0:C.droppable},dragOverlay:{...mg.dragOverlay,...null==C?void 0:C.dragOverlay}}),[null==C?void 0:C.draggable,null==C?void 0:C.droppable,null==C?void 0:C.dragOverlay]),{droppableRects:ei,measureDroppableContainers:en,measuringScheduled:eo}=function(e,r){let{dragging:s,dependencies:i,config:n}=r,[o,a]=(0,W.useState)(null),{frequency:l,measure:c,strategy:d}=n,h=(0,W.useRef)(e),u=function(){switch(d){case B.Always:return!1;case B.BeforeDragging:return s;default:return!s}}(),f=pc(u),p=(0,W.useCallback)(function(e){void 0===e&&(e=[]),f.current||a(r=>null===r?e:r.concat(e.filter(e=>!r.includes(e))))},[f]),m=(0,W.useRef)(null),g=pd(r=>{if(u&&!s)return mn;if(!r||r===mn||h.current!==e||null!=o){let r=new Map;for(let s of e){if(!s)continue;if(o&&o.length>0&&!o.includes(s.id)&&s.rect.current){r.set(s.id,s.rect.current);continue}let e=s.node.current,i=e?new p1(c(e),e):null;s.rect.current=i,i&&r.set(s.id,i)}return r}return r},[e,o,s,u,c]);return(0,W.useEffect)(()=>{h.current=e},[e]),(0,W.useEffect)(()=>{u||p()},[s,u]),(0,W.useEffect)(()=>{o&&o.length>0&&a(null)},[JSON.stringify(o)]),(0,W.useEffect)(()=>{u||"number"!=typeof l||null!==m.current||(m.current=setTimeout(()=>{p(),m.current=null},l))},[l,u,p,...i]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:null!=o}}(er,{dragging:z,dependencies:[$.x,$.y],config:es.droppable}),ea=pd(e=>{var r;return null==F?null:null!=(r=null!=p?p:e)?r:null},[p=(f=null!=F?H.get(F):void 0)?f.node.current:null,F]),el=(0,W.useMemo)(()=>Z?p_(Z):null,[Z]),ec=(d=(null==X?void 0:X.autoScrollEnabled)===!1,h="object"==typeof y?!1===y.enabled:!1===y,u=z&&!d&&!h,"object"==typeof y?{...y,enabled:u}:{enabled:u}),ed=mo(ea,es.draggable.measure);!function(e){let{activeNode:r,measure:s,initialRect:i,config:n=!0}=e,o=(0,W.useRef)(!1),{x:a,y:l}="boolean"==typeof n?{x:n,y:n}:n;pa(()=>{if(!a&&!l||!r){o.current=!1;return}if(o.current||!i)return;let e=null==r?void 0:r.node.current;if(!e||!1===e.isConnected)return;let n=pz(s(e),i);if(a||(n.x=0),l||(n.y=0),o.current=!0,Math.abs(n.x)>0||Math.abs(n.y)>0){let r=pU(e);r&&r.scrollBy({top:n.y,left:n.x})}},[r,a,l,i,s])}({activeNode:null!=F?H.get(F):null,config:ec.layoutShiftCompensation,initialRect:ed,measure:es.draggable.measure});let eh=mc(ea,es.draggable.measure,ed),eu=mc(ea?ea.parentElement:null),ef=(0,W.useRef)({activatorEvent:null,active:null,activeNode:ea,collisionRect:null,collisions:null,droppableRects:ei,draggableNodes:H,draggingNode:null,draggingNodeRect:null,droppableContainers:K,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ep=K.getNodeFor(null==(r=ef.current.over)?void 0:r.id),em=function(e){let{measure:r}=e,[s,i]=(0,W.useState)(null),n=ma({callback:(0,W.useCallback)(e=>{for(let{target:s}of e)if(pi(s)){i(e=>{let i=r(s);return e?{...e,width:i.width,height:i.height}:i});break}},[r])}),[o,a]=ph((0,W.useCallback)(e=>{let s=function(e){if(!e)return null;if(e.children.length>1)return e;let r=e.children[0];return pi(r)?r:e}(e);null==n||n.disconnect(),s&&(null==n||n.observe(s)),i(s?r(s):null)},[r,n]));return(0,W.useMemo)(()=>({nodeRef:o,rect:s,setRef:a}),[s,o,a])}({measure:es.dragOverlay.measure}),eg=null!=(s=em.nodeRef.current)?s:ea,ev=z?null!=(i=em.rect)?i:eh:null,ex=!!(em.nodeRef.current&&em.rect),e_=(m=mo(o=ex?null:eh),pz(o,m)),ey=mu(eg?pr(eg):null),eb=(a=z?null!=ep?ep:ea:null,g=(0,W.useRef)(a),v=pd(e=>a?e&&e!==md&&a&&g.current&&a.parentNode===g.current.parentNode?e:pK(a):md,[a]),(0,W.useEffect)(()=>{g.current=a},[a]),v),ew=function(e,r){void 0===r&&(r=pH);let[s]=e,i=mu(s?pr(s):null),[n,o]=(0,W.useState)(mf);function a(){o(()=>e.length?e.map(e=>pG(e)?i:new p1(r(e),e)):mf)}let l=ma({callback:a});return pa(()=>{null==l||l.disconnect(),a(),e.forEach(e=>null==l?void 0:l.observe(e))},[e]),n}(eb),eS=function(e,r){let{transform:s,...i}=r;return null!=e&&e.length?e.reduce((e,r)=>r({transform:e,...i}),s):s}(k,{transform:{x:$.x-e_.x,y:$.y-e_.y,scaleX:1,scaleY:1},activatorEvent:Z,active:V,activeNodeRect:eh,containerNodeRect:eu,draggingNodeRect:ev,over:ef.current.over,overlayNodeRect:em.rect,scrollableAncestors:eb,scrollableAncestorRects:ew,windowRect:ey}),eC=el?pg(el,$):null,ek=function(e){let[r,s]=(0,W.useState)(null),i=(0,W.useRef)(e),n=(0,W.useCallback)(e=>{let r=pq(e.target);r&&s(e=>e?(e.set(r,pX(r)),new Map(e)):null)},[]);return(0,W.useEffect)(()=>{let r=i.current;if(e!==r){o(r);let a=e.map(e=>{let r=pq(e);return r?(r.addEventListener("scroll",n,{passive:!0}),[r,pX(r)]):null}).filter(e=>null!=e);s(a.length?new Map(a):null),i.current=e}return()=>{o(e),o(r)};function o(e){e.forEach(e=>{let r=pq(e);null==r||r.removeEventListener("scroll",n)})}},[n,e]),(0,W.useMemo)(()=>e.length?r?Array.from(r.values()).reduce((e,r)=>pg(e,r),pD):pQ(e):pD,[e,r])}(eb),ej=mh(ek),eN=mh(ek,[eh]),eE=pg(eS,ej),eR=ev?pF(ev,eS):null,eM=V&&eR?S({active:V,collisionRect:eR,droppableRects:ei,droppableContainers:er,pointerCoordinates:eC}):null,eD=pA(eM,"id"),[eT,eP]=(0,W.useState)(null),eL=(l=ex?eS:pg(eS,eN),c=null!=(n=null==eT?void 0:eT.rect)?n:null,{...l,scaleX:c&&eh?c.width/eh.width:1,scaleY:c&&eh?c.height/eh.height:1}),eB=(0,W.useRef)(null),eA=(0,W.useCallback)((e,r)=>{let{sensor:s,options:i}=r;if(null==Y.current)return;let n=H.get(Y.current);if(!n)return;let o=e.nativeEvent,a=new s({active:Y.current,activeNode:n,event:o,options:i,context:ef,onAbort(e){if(!H.get(e))return;let{onDragAbort:r}=ee.current,s={id:e};null==r||r(s),D({type:"onDragAbort",event:s})},onPending(e,r,s,i){if(!H.get(e))return;let{onDragPending:n}=ee.current,o={id:e,constraint:r,initialCoordinates:s,offset:i};null==n||n(o),D({type:"onDragPending",event:o})},onStart(e){let r=Y.current;if(null==r)return;let s=H.get(r);if(!s)return;let{onDragStart:i}=ee.current,n={activatorEvent:o,active:{id:r,data:s.data,rect:q}};(0,G.unstable_batchedUpdates)(()=>{null==i||i(n),I(O.Initializing),M({type:E.DragStart,initialCoordinates:e,active:r}),D({type:"onDragStart",event:n}),J(eB.current),Q(o)})},onMove(e){M({type:E.DragMove,coordinates:e})},onEnd:l(E.DragEnd),onCancel:l(E.DragCancel)});function l(e){return async function(){let{active:r,collisions:s,over:i,scrollAdjustedTranslate:n}=ef.current,a=null;if(r&&n){let{cancelDrop:l}=ee.current;a={activatorEvent:o,active:r,collisions:s,delta:n,over:i},e===E.DragEnd&&"function"==typeof l&&await Promise.resolve(l(a))&&(e=E.DragCancel)}Y.current=null,(0,G.unstable_batchedUpdates)(()=>{M({type:e}),I(O.Uninitialized),eP(null),J(null),Q(null),eB.current=null;let r=e===E.DragEnd?"onDragEnd":"onDragCancel";if(a){let e=ee.current[r];null==e||e(a),D({type:r,event:a})}})}}eB.current=a},[H]),eO=(0,W.useCallback)((e,r)=>(s,i)=>{let n=s.nativeEvent,o=H.get(i);null!==Y.current||!o||n.dndKit||n.defaultPrevented||!0===e(s,r.options,{active:o})&&(n.dndKit={capturedBy:r.sensor},Y.current=i,eA(s,r))},[H,eA]),eI=(0,W.useMemo)(()=>w.reduce((e,r)=>{let{sensor:s}=r;return[...e,...s.activators.map(e=>({eventName:e.eventName,handler:eO(e.handler,r)}))]},[]),[w,eO]);(0,W.useEffect)(()=>{if(!f9)return;let e=w.map(e=>{let{sensor:r}=e;return null==r.setup?void 0:r.setup()});return()=>{for(let r of e)null==r||r()}},w.map(e=>{let{sensor:r}=e;return r})),pa(()=>{eh&&A===O.Initializing&&I(O.Initialized)},[eh,A]),(0,W.useEffect)(()=>{let{onDragMove:e}=ee.current,{active:r,activatorEvent:s,collisions:i,over:n}=ef.current;if(!r||!s)return;let o={active:r,activatorEvent:s,collisions:i,delta:{x:eE.x,y:eE.y},over:n};(0,G.unstable_batchedUpdates)(()=>{null==e||e(o),D({type:"onDragMove",event:o})})},[eE.x,eE.y]),(0,W.useEffect)(()=>{let{active:e,activatorEvent:r,collisions:s,droppableContainers:i,scrollAdjustedTranslate:n}=ef.current;if(!e||null==Y.current||!r||!n)return;let{onDragOver:o}=ee.current,a=i.get(eD),l=a&&a.rect.current?{id:a.id,rect:a.rect.current,data:a.data,disabled:a.disabled}:null,c={active:e,activatorEvent:r,collisions:s,delta:{x:n.x,y:n.y},over:l};(0,G.unstable_batchedUpdates)(()=>{eP(l),null==o||o(c),D({type:"onDragOver",event:c})})},[eD]),pa(()=>{ef.current={activatorEvent:Z,active:V,activeNode:ea,collisionRect:eR,collisions:eM,droppableRects:ei,draggableNodes:H,draggingNode:eg,draggingNodeRect:ev,droppableContainers:K,over:eT,scrollableAncestors:eb,scrollAdjustedTranslate:eE},q.current={initial:ev,translated:eR}},[V,ea,eM,eR,H,eg,ev,ei,K,eT,eb,eE]),function(e){let r,{acceleration:s,activator:i=P.Pointer,canScroll:n,draggingRect:o,enabled:a,interval:l=5,order:c=L.TreeOrder,pointerCoordinates:d,scrollableAncestors:h,scrollableAncestorRects:u,delta:f,threshold:p}=e,m=function(e){let{delta:r,disabled:s}=e,i=pu(r);return pd(e=>{if(s||!i||!e)return mi;let n={x:Math.sign(r.x-i.x),y:Math.sign(r.y-i.y)};return{x:{[R.Backward]:e.x[R.Backward]||-1===n.x,[R.Forward]:e.x[R.Forward]||1===n.x},y:{[R.Backward]:e.y[R.Backward]||-1===n.y,[R.Forward]:e.y[R.Forward]||1===n.y}}},[s,r,i])}({delta:f,disabled:!a}),[g,v]=(r=(0,W.useRef)(null),[(0,W.useCallback)((e,s)=>{r.current=setInterval(e,s)},[]),(0,W.useCallback)(()=>{null!==r.current&&(clearInterval(r.current),r.current=null)},[])]),x=(0,W.useRef)({x:0,y:0}),_=(0,W.useRef)({x:0,y:0}),y=(0,W.useMemo)(()=>{switch(i){case P.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case P.DraggableRect:return o}},[i,o,d]),b=(0,W.useRef)(null),w=(0,W.useCallback)(()=>{let e=b.current;if(!e)return;let r=x.current.x*_.current.x,s=x.current.y*_.current.y;e.scrollBy(r,s)},[]),S=(0,W.useMemo)(()=>c===L.TreeOrder?[...h].reverse():h,[c,h]);(0,W.useEffect)(()=>{if(!a||!h.length||!y)return void v();for(let e of S){if((null==n?void 0:n(e))===!1)continue;let r=u[h.indexOf(e)];if(!r)continue;let{direction:i,speed:o}=function(e,r,s,i,n){let{top:o,left:a,right:l,bottom:c}=s;void 0===i&&(i=10),void 0===n&&(n=pZ);let{isTop:d,isBottom:h,isLeft:u,isRight:f}=pJ(e),p={x:0,y:0},m={x:0,y:0},g={height:r.height*n.y,width:r.width*n.x};return!d&&o<=r.top+g.height?(p.y=R.Backward,m.y=i*Math.abs((r.top+g.height-o)/g.height)):!h&&c>=r.bottom-g.height&&(p.y=R.Forward,m.y=i*Math.abs((r.bottom-g.height-c)/g.height)),!f&&l>=r.right-g.width?(p.x=R.Forward,m.x=i*Math.abs((r.right-g.width-l)/g.width)):!u&&a<=r.left+g.width&&(p.x=R.Backward,m.x=i*Math.abs((r.left+g.width-a)/g.width)),{direction:p,speed:m}}(e,r,y,s,p);for(let e of["x","y"])m[e][i[e]]||(o[e]=0,i[e]=0);if(o.x>0||o.y>0){v(),b.current=e,g(w,l),x.current=o,_.current=i;return}}x.current={x:0,y:0},_.current={x:0,y:0},v()},[s,w,n,v,a,l,JSON.stringify(y),JSON.stringify(m),g,h,S,u,JSON.stringify(p)])}({...ec,delta:$,draggingRect:eR,pointerCoordinates:eC,scrollableAncestors:eb,scrollableAncestorRects:ew});let ez=(0,W.useMemo)(()=>({active:V,activeNode:ea,activeNodeRect:eh,activatorEvent:Z,collisions:eM,containerNodeRect:eu,dragOverlay:em,draggableNodes:H,droppableContainers:K,droppableRects:ei,over:eT,measureDroppableContainers:en,scrollableAncestors:eb,scrollableAncestorRects:ew,measuringConfiguration:es,measuringScheduled:eo,windowRect:ey}),[V,ea,eh,Z,eM,eu,em,H,K,ei,eT,en,eb,ew,es,eo,ey]),eF=(0,W.useMemo)(()=>({activatorEvent:Z,activators:eI,active:V,activeNodeRect:eh,ariaDescribedById:{draggable:et},dispatch:M,draggableNodes:H,over:eT,measureDroppableContainers:en}),[Z,eI,V,eh,M,et,H,eT,en]);return W.default.createElement(pk.Provider,{value:T},W.default.createElement(my.Provider,{value:eF},W.default.createElement(mb.Provider,{value:ez},W.default.createElement(mk.Provider,{value:eL},b)),W.default.createElement(mC,{disabled:(null==_?void 0:_.restoreFocus)===!1})),W.default.createElement(pE,{..._,hiddenTextDescribedById:et}))}),mN=(0,W.createContext)(null),mE="button",mR={timeout:25},mM={position:"fixed",touchAction:"none"},mD=e=>px(e)?"transform 250ms ease":void 0;function mT(e,r,s){let i=e.slice();return i.splice(s<0?i.length+s:s,0,i.splice(r,1)[0]),i}function mP(e){return null!==e&&e>=0}(e,r)=>{let{as:s,activatorEvent:i,adjustScale:n,children:o,className:a,rect:l,style:c,transform:d,transition:h=mD}=e;if(!l)return null;let u=n?d:{...d,scaleX:1,scaleY:1},f={...mM,width:l.width,height:l.height,top:l.top,left:l.left,transform:py.Transform.toString(u),transformOrigin:n&&i?function(e,r){let s=p_(e);if(!s)return"0 0";let i={x:(s.x-r.left)/r.width*100,y:(s.y-r.top)/r.height*100};return i.x+"% "+i.y+"%"}(i,l):void 0,transition:"function"==typeof h?h(i):h,...c};return W.default.createElement(s,{className:a,style:f,ref:r},o)},v={styles:{active:{opacity:"0"}}};let mL=e=>{let{rects:r,activeIndex:s,overIndex:i,index:n}=e,o=mT(r,i,s),a=r[n],l=o[n];return l&&a?{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}:null},mB={scaleX:1,scaleY:1},mA=e=>{var r,s,i,n;let o,a,l,{activeIndex:c,activeNodeRect:d,index:h,rects:u,overIndex:f}=e,p=null!=(r=u[c])?r:d;if(!p)return null;if(h===c){let e=u[f];return e?{x:0,y:c<f?e.top+e.height-(p.top+p.height):e.top-p.top,...mB}:null}let m=(s=u,i=h,n=c,o=s[i],a=s[i-1],l=s[i+1],o?n<i?a?o.top-(a.top+a.height):l?l.top-(o.top+o.height):0:l?l.top-(o.top+o.height):a?o.top-(a.top+a.height):0:0);return h>c&&h<=f?{x:0,y:-p.height-m,...mB}:h<c&&h>=f?{x:0,y:p.height+m,...mB}:{x:0,y:0,...mB}},mO="Sortable",mI=W.default.createContext({activeIndex:-1,containerId:mO,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:mL,disabled:{draggable:!1,droppable:!1}});function mz(e){let{children:r,id:s,items:i,strategy:n=mL,disabled:o=!1}=e,{active:a,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=(0,W.useContext)(mb),u=pp(mO,s),f=null!==l.rect,p=(0,W.useMemo)(()=>i.map(e=>"object"==typeof e&&"id"in e?e.id:e),[i]),m=null!=a,g=a?p.indexOf(a.id):-1,v=d?p.indexOf(d.id):-1,x=(0,W.useRef)(p),_=!function(e,r){if(e===r)return!0;if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==r[s])return!1;return!0}(p,x.current),y=-1!==v&&-1===g||_,b="boolean"==typeof o?{draggable:o,droppable:o}:o;pa(()=>{_&&m&&h(p)},[_,p,m,h]),(0,W.useEffect)(()=>{x.current=p},[p]);let w=(0,W.useMemo)(()=>({activeIndex:g,containerId:u,disabled:b,disableTransforms:y,items:p,overIndex:v,useDragOverlay:f,sortedRects:p.reduce((e,r,s)=>{let i=c.get(r);return i&&(e[s]=i),e},Array(p.length)),strategy:n}),[g,u,b.draggable,b.droppable,y,p,v,c,f,n]);return W.default.createElement(mI.Provider,{value:w},r)}let mF=e=>{let{id:r,items:s,activeIndex:i,overIndex:n}=e;return mT(s,i,n).indexOf(r)},mW=e=>{let{containerId:r,isSorting:s,wasDragging:i,index:n,items:o,newIndex:a,previousItems:l,previousContainerId:c,transition:d}=e;return!!d&&!!i&&(l===o||n!==a)&&(!!s||a!==n&&r===c)},mH={duration:200,easing:"ease"},m$="transform",mK=py.Transition.toString({property:m$,duration:0,easing:"linear"}),mU={roleDescription:"sortable"};function mq(e){if(!e)return!1;let r=e.data.current;return!!r&&"sortable"in r&&"object"==typeof r.sortable&&"containerId"in r.sortable&&"items"in r.sortable&&"index"in r.sortable}let mV=[D.Down,D.Right,D.Up,D.Left],mY=(e,r)=>{let{context:{active:s,collisionRect:i,droppableRects:n,droppableContainers:o,over:a,scrollableAncestors:l}}=r;if(mV.includes(e.code)){if(e.preventDefault(),!s||!i)return;let r=[];o.getEnabled().forEach(s=>{if(!s||null!=s&&s.disabled)return;let o=n.get(s.id);if(o)switch(e.code){case D.Down:i.top<o.top&&r.push(s);break;case D.Up:i.top>o.top&&r.push(s);break;case D.Left:i.left>o.left&&r.push(s);break;case D.Right:i.left<o.left&&r.push(s)}});let h=(e=>{let{collisionRect:r,droppableRects:s,droppableContainers:i}=e,n=pB(r),o=[];for(let e of i){let{id:r}=e,i=s.get(r);if(i){let s=pB(i),a=Number((n.reduce((e,r,i)=>e+pT(s[i],r),0)/4).toFixed(4));o.push({id:r,data:{droppableContainer:e,value:a}})}}return o.sort(pP)})({active:s,collisionRect:i,droppableRects:n,droppableContainers:r,pointerCoordinates:null}),u=pA(h,"id");if(u===(null==a?void 0:a.id)&&h.length>1&&(u=h[1].id),null!=u){let e=o.get(s.id),r=o.get(u),a=r?n.get(r.id):null,h=null==r?void 0:r.node.current;if(h&&a&&e&&r){var c,d;let s=pK(h).some((e,r)=>l[r]!==e),n=mX(e,r),o=(c=e,d=r,!!mq(c)&&!!mq(d)&&!!mX(c,d)&&c.data.current.sortable.index<d.data.current.sortable.index),u=s||!n?{x:0,y:0}:{x:o?i.width-a.width:0,y:o?i.height-a.height:0},f={x:a.left,y:a.top};return u.x&&u.y?f:pv(f,u)}}}};function mX(e,r){return!!mq(e)&&!!mq(r)&&e.data.current.sortable.containerId===r.data.current.sortable.containerId}function mG({executor:e,executorMode:r,isOpen:s,onOpenChange:i,onStart:n,onStop:o,onUpdate:a,onDelete:l,onProcessFinished:c}){let[d,h]=(0,W.useState)(!1),[u,f]=(0,W.useState)(e.currentProcessId),p=(0,W.useRef)(!1),{attributes:m,listeners:g,setNodeRef:v,transform:x,transition:_,isDragging:y}=function(e){var r,s,i,n;let{animateLayoutChanges:o=mW,attributes:a,disabled:l,data:c,getNewIndex:d=mF,id:h,strategy:u,resizeObserverConfig:f,transition:p=mH}=e,{items:m,containerId:g,activeIndex:v,disabled:x,disableTransforms:_,sortedRects:y,overIndex:b,useDragOverlay:w,strategy:S}=(0,W.useContext)(mI),C=(r=l,s=x,"boolean"==typeof r?{draggable:r,droppable:!1}:{draggable:null!=(i=null==r?void 0:r.draggable)?i:s.draggable,droppable:null!=(n=null==r?void 0:r.droppable)?n:s.droppable}),k=m.indexOf(h),j=(0,W.useMemo)(()=>({sortable:{containerId:g,index:k,items:m},...c}),[g,c,k,m]),N=(0,W.useMemo)(()=>m.slice(m.indexOf(h)),[m,h]),{rect:R,node:M,isOver:D,setNodeRef:T}=function(e){let{data:r,disabled:s=!1,id:i,resizeObserverConfig:n}=e,o=pp("Droppable"),{active:a,dispatch:l,over:c,measureDroppableContainers:d}=(0,W.useContext)(my),h=(0,W.useRef)({disabled:s}),u=(0,W.useRef)(!1),f=(0,W.useRef)(null),p=(0,W.useRef)(null),{disabled:m,updateMeasurementsFor:g,timeout:v}={...mR,...n},x=pc(null!=g?g:i),_=ma({callback:(0,W.useCallback)(()=>{if(!u.current){u.current=!0;return}null!=p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d(Array.isArray(x.current)?x.current:[x.current]),p.current=null},v)},[v]),disabled:m||!a}),[y,b]=ph((0,W.useCallback)((e,r)=>{_&&(r&&(_.unobserve(r),u.current=!1),e&&_.observe(e))},[_])),w=pc(r);return(0,W.useEffect)(()=>{_&&y.current&&(_.disconnect(),u.current=!1,_.observe(y.current))},[y,_]),(0,W.useEffect)(()=>(l({type:E.RegisterDroppable,element:{id:i,key:o,disabled:s,node:y,rect:f,data:w}}),()=>l({type:E.UnregisterDroppable,key:o,id:i})),[i]),(0,W.useEffect)(()=>{s!==h.current.disabled&&(l({type:E.SetDroppableDisabled,id:i,key:o,disabled:s}),h.current.disabled=s)},[i,o,s,l]),{active:a,rect:f,isOver:(null==c?void 0:c.id)===i,node:y,over:c,setNodeRef:b}}({id:h,data:j,disabled:C.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...f}}),{active:P,activatorEvent:L,activeNodeRect:B,attributes:A,setNodeRef:O,listeners:I,isDragging:z,over:F,setActivatorNodeRef:H,transform:$}=function(e){let{id:r,data:s,disabled:i=!1,attributes:n}=e,o=pp("Draggable"),{activators:a,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:h,draggableNodes:u,over:f}=(0,W.useContext)(my),{role:p=mE,roleDescription:m="draggable",tabIndex:g=0}=null!=n?n:{},v=(null==c?void 0:c.id)===r,x=(0,W.useContext)(v?mk:mN),[_,y]=ph(),[b,w]=ph(),S=(0,W.useMemo)(()=>a.reduce((e,s)=>{let{eventName:i,handler:n}=s;return e[i]=e=>{n(e,r)},e},{}),[a,r]),C=pc(s);return pa(()=>(u.set(r,{id:r,key:o,node:_,activatorNode:b,data:C}),()=>{let e=u.get(r);e&&e.key===o&&u.delete(r)}),[u,r]),{active:c,activatorEvent:l,activeNodeRect:d,attributes:(0,W.useMemo)(()=>({role:p,tabIndex:g,"aria-disabled":i,"aria-pressed":!!v&&p===mE||void 0,"aria-roledescription":m,"aria-describedby":h.draggable}),[i,p,g,v,m,h.draggable]),isDragging:v,listeners:i?void 0:S,node:_,over:f,setNodeRef:y,setActivatorNodeRef:w,transform:x}}({id:h,data:j,attributes:{...mU,...a},disabled:C.draggable}),K=function(){for(var e=arguments.length,r=Array(e),s=0;s<e;s++)r[s]=arguments[s];return(0,W.useMemo)(()=>e=>{r.forEach(r=>r(e))},r)}(T,O),U=!!P,q=U&&!_&&mP(v)&&mP(b),V=!w&&z,Y=V&&q?$:null,X=q?null!=Y?Y:(null!=u?u:S)({rects:y,activeNodeRect:B,activeIndex:v,overIndex:b,index:k}):null,G=mP(v)&&mP(b)?d({id:h,items:m,activeIndex:v,overIndex:b}):k,J=null==P?void 0:P.id,Z=(0,W.useRef)({activeId:J,items:m,newIndex:G,containerId:g}),Q=m!==Z.current.items,ee=o({active:P,containerId:g,isDragging:z,isSorting:U,id:h,index:k,items:m,newIndex:Z.current.newIndex,previousItems:Z.current.items,previousContainerId:Z.current.containerId,transition:p,wasDragging:null!=Z.current.activeId}),et=function(e){let{disabled:r,index:s,node:i,rect:n}=e,[o,a]=(0,W.useState)(null),l=(0,W.useRef)(s);return pa(()=>{if(!r&&s!==l.current&&i.current){let e=n.current;if(e){let r=pH(i.current,{ignoreTransform:!0}),s={x:e.left-r.left,y:e.top-r.top,scaleX:e.width/r.width,scaleY:e.height/r.height};(s.x||s.y)&&a(s)}}s!==l.current&&(l.current=s)},[r,s,i,n]),(0,W.useEffect)(()=>{o&&a(null)},[o]),o}({disabled:!ee,index:k,node:M,rect:R});return(0,W.useEffect)(()=>{U&&Z.current.newIndex!==G&&(Z.current.newIndex=G),g!==Z.current.containerId&&(Z.current.containerId=g),m!==Z.current.items&&(Z.current.items=m)},[U,G,g,m]),(0,W.useEffect)(()=>{if(J===Z.current.activeId)return;if(null!=J&&null==Z.current.activeId){Z.current.activeId=J;return}let e=setTimeout(()=>{Z.current.activeId=J},50);return()=>clearTimeout(e)},[J]),{active:P,activeIndex:v,attributes:A,data:j,rect:R,index:k,newIndex:G,items:m,isOver:D,isSorting:U,isDragging:z,listeners:I,node:M,overIndex:b,over:F,setNodeRef:K,setActivatorNodeRef:H,setDroppableNodeRef:T,setDraggableNodeRef:O,transform:null!=et?et:X,transition:et||Q&&Z.current.newIndex===k?mK:(!V||px(L))&&p&&(U||ee)?py.Transition.toString({...p,property:m$}):void 0}}({id:e.id}),b={transform:py.Translate.toString(x),transition:_,zIndex:y?50:void 0,position:y?"relative":void 0,opacity:y?1:void 0},{logs:w,status:S,exitCode:C,isPty:k,sendInput:j,sendResize:N}=f7(u,r);(0,W.useEffect)(()=>{f(e.currentProcessId),e.currentProcessId&&(p.current=!1)},[e.currentProcessId]),(0,W.useEffect)(()=>{"closed"!==S||null===C||p.current||(p.current=!0,c(u))},[S,C,u,c]);let R=async()=>{console.log(`[ExecutorItem] Starting executor ${e.id}`),p.current=!1;let r=await n();console.log(`[ExecutorItem] Got processId: ${r}`),r&&(f(r),i(!0))},M=async()=>{await o(u||void 0)},D=e.isRunning;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(a7,{open:s,onOpenChange:i,children:(0,F.jsxs)("div",{ref:v,style:b,className:(0,iu.cn)("border rounded-lg",y&&"shadow-lg bg-background"),children:[(0,F.jsx)(a9,{asChild:!0,children:(0,F.jsxs)("div",{className:"flex items-center justify-between p-3 cursor-pointer hover:bg-muted/50",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...m,...g,onClick:e=>e.stopPropagation(),children:(0,F.jsx)(lu,{className:"h-4 w-4"})}),s?(0,F.jsx)(aL,{className:"h-4 w-4"}):(0,F.jsx)(id,{className:"h-4 w-4"}),(0,F.jsx)("span",{className:"font-medium",children:e.name}),(0,F.jsx)(ld,{variant:D?"default":"secondary",className:(0,iu.cn)(D&&"bg-green-600 hover:bg-green-600"),children:D?"Running":null!==C?0===C?"Completed":"Failed":"Stopped"})]}),(0,F.jsxs)("div",{className:"flex items-center gap-2",onClick:e=>e.stopPropagation(),children:[D?(0,F.jsxs)($.Button,{size:"sm",variant:"destructive",onClick:M,children:[(0,F.jsx)(lh,{className:"h-3 w-3 mr-1"}),"Stop"]}):(0,F.jsxs)($.Button,{size:"sm",onClick:R,children:[(0,F.jsx)(iN,{className:"h-3 w-3 mr-1"}),"Start"]}),(0,F.jsxs)(ip,{children:[(0,F.jsx)(im,{asChild:!0,children:(0,F.jsx)($.Button,{size:"icon",variant:"ghost",className:"h-8 w-8",children:(0,F.jsx)(iS,{className:"h-4 w-4"})})}),(0,F.jsxs)(ig,{align:"end",children:[(0,F.jsxs)(iv,{onClick:()=>h(!0),children:[(0,F.jsx)(iC,{className:"h-4 w-4 mr-2"}),"Edit"]}),(0,F.jsxs)(iv,{onClick:l,className:"text-destructive",children:[(0,F.jsx)(ib,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})]})}),(0,F.jsx)(le,{children:(0,F.jsxs)("div",{className:"px-3 pb-3",children:[(0,F.jsx)("div",{className:"text-xs text-muted-foreground mb-2 font-mono",children:"prompt"===e.executor_type?`${e.prompt_provider??"claude"} → ${e.command}`:`$ ${e.command}`}),(0,F.jsx)(f3,{logs:w,isPty:k,onInput:j,onResize:N})]})})]})}),(0,F.jsx)(f8,{open:d,onOpenChange:h,executor:e,onSubmit:async e=>{await a(e)}})]})}let mJ=e=>{let{droppableContainers:r,pointerCoordinates:s}=e;if(!s)return(e=>{let{collisionRect:r,droppableRects:s,droppableContainers:i}=e,n=pO(r,r.left,r.top),o=[];for(let e of i){let{id:r}=e,i=s.get(r);if(i){let s=pT(pO(i),n);o.push({id:r,data:{droppableContainer:e,value:s}})}}return o.sort(pP)})(e);let i=[];for(let e of r){let r=e.rect.current;if(!r)continue;let n=r.top,o=r.top+52;s.x>=r.left&&s.x<=r.right&&s.y>=n&&s.y<=o&&i.push({id:e.id,data:{droppableContainer:e}})}if(i.length>0)return i;let n=null;for(let e of r){let r=e.rect.current;if(!r)continue;let i=r.top+26,o=r.left+r.width/2,a=Math.sqrt(Math.pow(s.x-o,2)+Math.pow(s.y-i,2));(!n||a<n.distance)&&(n={id:e.id,distance:a,data:{droppableContainer:e}})}return n?[{id:n.id,data:n.data}]:[]};function mZ({projectId:e,selectedBranch:r,project:s,onExecutorModeChange:i}){let[n,o]=(0,W.useState)(!1),[a,l]=(0,W.useState)(new Set),{remotes:c}=iP(s?.id??void 0),d=[];for(let e of(s?.path&&d.push({id:"local",label:"Local",icon:nA.Monitor}),c))d.push({id:e.remote_server_id,label:e.server_name,icon:nO});let{activeGroup:h,loading:u,createGroup:f}=function(e,r){let[s,i]=(0,W.useState)([]),[n,o]=(0,W.useState)(null),[a,l]=(0,W.useState)(!0),c=r??"",d=(0,W.useCallback)(async()=>{if(!e){i([]),o(null),l(!1);return}try{let[r,s]=await Promise.all([iT.api.getExecutorGroups(e),iT.api.getExecutorGroupByBranch(e,c)]);i(r),o(s)}catch(e){console.error("Failed to fetch executor groups:",e)}finally{l(!1)}},[e,c]);(0,W.useEffect)(()=>{l(!0),d()},[d]);let h=(0,W.useCallback)(async r=>{if(!e)return null;try{let s=await iT.api.createExecutorGroup(e,{name:r,branch:c});return i(e=>[...e,s]),o(s),s}catch(e){return console.error("Failed to create executor group:",e),null}},[e,c]);return{groups:s,activeGroup:n,loading:a,createGroup:h,updateGroup:(0,W.useCallback)(async(e,r)=>{try{let s=await iT.api.updateExecutorGroup(e,r);return i(r=>r.map(r=>r.id===e?s:r)),o(r=>r?.id===e?s:r),s}catch(e){return console.error("Failed to update executor group:",e),null}},[]),deleteGroup:(0,W.useCallback)(async e=>{try{await iT.api.deleteExecutorGroup(e),i(r=>r.filter(r=>r.id!==e)),o(r=>r?.id===e?null:r)}catch(e){console.error("Failed to delete executor group:",e)}},[]),refetch:d}}(e,r),{executors:p,loading:m,createExecutor:g,updateExecutor:v,deleteExecutor:x,startExecutor:_,stopExecutor:y,markProcessFinished:b,reorderExecutors:w}=function(e,r,s){let[i,n]=(0,W.useState)([]),[o,a]=(0,W.useState)(new Map),[l,c]=(0,W.useState)(!0),d=(0,W.useCallback)(async()=>{if(!e||!r){n([]),c(!1);return}try{let s=await iT.api.getExecutors(e,r);n(s)}catch(e){console.error("Failed to fetch executors:",e)}finally{c(!1)}},[e,r]),h=(0,W.useCallback)(async()=>{try{let e=await iT.api.getRunningProcesses(),r=new Map;for(let s of e){let e={processId:s.id,target:s.target??"local"},i=r.get(s.executor_id);i?i.push(e):r.set(s.executor_id,[e])}a(r)}catch(e){console.error("Failed to fetch running processes:",e)}},[]);(0,W.useEffect)(()=>{d(),h()},[d,h]),(0,W.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&h()};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[h]);let u=(0,W.useRef)(new Set);(0,W.useEffect)(()=>{u.current=new Set(i.map(e=>e.id))},[i]),(0,W.useEffect)(()=>{if(!e)return;let r=new EventSource(`${"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}/api/events`);return r.onmessage=r=>{try{let s=JSON.parse(r.data);if(s.projectId!==e||!u.current.has(s.executorId))return;"executor:started"===s.type?a(e=>{let r=e.get(s.executorId)??[];if(r.some(e=>e.processId===s.processId))return e;let i=new Map(e);return i.set(s.executorId,[...r,{processId:s.processId,target:s.target??"local"}]),i}):"executor:stopped"===s.type&&a(e=>{let r=e.get(s.executorId);if(!r)return e;let i=r.filter(e=>e.processId!==s.processId),n=new Map(e);return 0===i.length?n.delete(s.executorId):n.set(s.executorId,i),n})}catch{}},()=>{r.close()}},[e]);let f=(0,W.useCallback)(async s=>{if(!e||!r)return null;try{let i=await iT.api.createExecutor(e,{...s,group_id:r});return n(e=>[...e,i]),i}catch(e){return console.error("Failed to create executor:",e),null}},[e,r]),p=(0,W.useCallback)(async(e,r)=>{try{let s=await iT.api.updateExecutor(e,r);return n(r=>r.map(r=>r.id===e?s:r)),s}catch(e){return console.error("Failed to update executor:",e),null}},[]),m=(0,W.useCallback)(async e=>{try{await iT.api.deleteExecutor(e),n(r=>r.filter(r=>r.id!==e))}catch(e){console.error("Failed to delete executor:",e)}},[]),g=(0,W.useCallback)(async(e,r)=>{try{let i=await iT.api.startExecutor(e,r,s);return a(r=>{let n=r.get(e)??[],o=new Map(r);return o.set(e,[...n,{processId:i,target:s??"local"}]),o}),i}catch(e){return console.error("Failed to start executor:",e),null}},[s]),v=(0,W.useCallback)(async(e,r)=>{let i=o.get(e),n=i?.find(e=>e.target===(s??"local")),l=r||n?.processId;if(l){try{await iT.api.stopProcess(l)}catch(e){console.error("Failed to stop executor:",e)}a(r=>{let s=r.get(e);if(!s)return r;let i=s.filter(e=>e.processId!==l),n=new Map(r);return 0===i.length?n.delete(e):n.set(e,i),n})}},[o,s]),x=(0,W.useCallback)((e,r)=>{a(s=>{let i=s.get(e);if(!i)return s;if(r){let n=i.filter(e=>e.processId!==r);if(n.length===i.length)return s;let o=new Map(s);return 0===n.length?o.delete(e):o.set(e,n),o}let n=new Map(s);return n.delete(e),n})},[]),_=(0,W.useCallback)(async s=>{if(e&&r){n(s.map(e=>i.find(r=>r.id===e)).filter(e=>void 0!==e));try{await iT.api.reorderExecutors(e,s,r)}catch(e){console.error("Failed to reorder executors:",e),n(i)}}},[e,r,i]);return{executors:i.map(e=>{let r=o.get(e.id),i=s??"local",n=r?.find(e=>e.target===i);return{...e,currentProcessId:n?.processId??null,isRunning:!!n}}),loading:l,createExecutor:f,updateExecutor:p,deleteExecutor:m,startExecutor:g,stopExecutor:v,markProcessFinished:x,reorderExecutors:_,refetch:d}}(e,h?.id,s?.executor_mode),S=function(){for(var e=arguments.length,r=Array(e),s=0;s<e;s++)r[s]=arguments[s];return(0,W.useMemo)(()=>[...r].filter(e=>null!=e),[...r])}(pM(ms,{activationConstraint:{distance:8}}),pM(p7,{coordinateGetter:mY}));return e?(0,F.jsxs)("div",{className:"h-full flex flex-col",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border/60 h-10",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsxs)("h2",{className:"text-xs font-semibold flex items-center gap-2 text-foreground",children:[(0,F.jsx)(nL.Terminal,{className:"h-3.5 w-3.5"}),h?h.name:"Executors"]}),d.length>1&&i&&(0,F.jsx)(nP,{targets:d,activeTarget:s?.executor_mode??"local",onTargetChange:i})]}),h&&(0,F.jsxs)($.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>o(!0),children:[(0,F.jsx)(nD,{className:"h-3 w-3 mr-1"}),"Add"]})]}),(0,F.jsx)(oc,{className:"flex-1 overflow-hidden",children:(0,F.jsx)("div",{className:"p-4 space-y-3",children:u||m?(0,F.jsx)("div",{className:"text-center text-muted-foreground py-8",children:"Loading executors..."}):h?0===p.length?(0,F.jsxs)("div",{className:"text-center text-muted-foreground py-8",children:[(0,F.jsx)("p",{children:"No executors configured"}),(0,F.jsx)("p",{className:"text-sm mt-1",children:'Add an executor to run commands like "npm run dev"'})]}):(0,F.jsx)(mj,{sensors:S,collisionDetection:mJ,onDragEnd:e=>{let{active:r,over:s}=e;if(s&&r.id!==s.id){let e=p.findIndex(e=>e.id===r.id),i=p.findIndex(e=>e.id===s.id),n=[...p],[o]=n.splice(e,1);n.splice(i,0,o),w(n.map(e=>e.id))}},children:(0,F.jsx)(mz,{items:p.map(e=>e.id),strategy:mA,children:p.map(e=>(0,F.jsx)(mG,{executor:e,executorMode:s?.executor_mode??"local",isOpen:a.has(e.id),onOpenChange:r=>l(s=>{let i=new Set(s);return r?i.add(e.id):i.delete(e.id),i}),onStart:()=>_(e.id,r),onStop:r=>y(e.id,r||e.currentProcessId||void 0),onUpdate:r=>v(e.id,r),onDelete:()=>x(e.id),onProcessFinished:r=>b(e.id,r)},`${e.id}-${s?.executor_mode??"local"}`))})}):(0,F.jsxs)("div",{className:"text-center text-muted-foreground py-8",children:[(0,F.jsx)("p",{children:"No executor group for this branch"}),(0,F.jsx)("p",{className:"text-sm mt-1 mb-4",children:"Create a group to start adding executors"}),(0,F.jsxs)($.Button,{size:"sm",onClick:()=>f(r?`Executors (${r})`:"Default"),children:[(0,F.jsx)(aX,{className:"h-4 w-4 mr-1"}),"Create Group"]})]})})}),(0,F.jsx)(f8,{open:n,onOpenChange:o,onSubmit:async e=>{await g(e)}})]}):(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(nL.Terminal,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to manage executors"})]})})}let mQ=(0,ic.default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),m0=(0,ic.default)("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]),m1=(0,ic.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);function m2({line:e}){let r="add"===e.type?"+":"delete"===e.type?"-":" ";return(0,F.jsxs)("div",{className:(0,iu.cn)("flex font-mono text-sm","add"===e.type&&"bg-green-500/30","delete"===e.type&&"bg-red-500/30"),children:[(0,F.jsx)("span",{className:"w-12 flex-shrink-0 text-right pr-2 text-muted-foreground select-none border-r border-border",children:e.oldLineNo??""}),(0,F.jsx)("span",{className:"w-12 flex-shrink-0 text-right pr-2 text-muted-foreground select-none border-r border-border",children:e.newLineNo??""}),(0,F.jsx)("span",{className:"w-6 flex-shrink-0 text-center select-none",children:r}),(0,F.jsx)("span",{className:"whitespace-pre-wrap break-all pr-4 flex-1 min-w-0",children:e.content})]})}let m5={modified:"bg-yellow-500/20 text-yellow-500",added:"bg-green-500/20 text-green-500",deleted:"bg-red-500/20 text-red-500",renamed:"bg-blue-500/20 text-blue-500"},m3={modified:"Modified",added:"Added",deleted:"Deleted",renamed:"Renamed"};function m4({file:e,defaultOpen:r=!0}){let[s,i]=(0,W.useState)(r);return(0,F.jsxs)(a7,{open:s,onOpenChange:i,className:"border rounded-lg overflow-hidden",children:[(0,F.jsxs)(a9,{className:"flex items-center gap-2 px-4 py-2 bg-muted border-b w-full cursor-pointer hover:bg-muted/80 transition-colors",children:[s?(0,F.jsx)(aL,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,F.jsx)(id,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsx)("span",{className:"font-mono text-sm flex-1 min-w-0 truncate text-left",children:e.oldPath&&"renamed"===e.status?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("span",{className:"text-muted-foreground",children:e.oldPath}),(0,F.jsx)("span",{className:"mx-2",children:"→"}),e.path]}):e.path}),(0,F.jsx)(ld,{variant:"secondary",className:m5[e.status],children:m3[e.status]})]}),(0,F.jsx)(le,{children:(0,F.jsx)("div",{children:e.hunks.map((e,r)=>(0,F.jsxs)("div",{children:[(0,F.jsxs)("div",{className:"px-4 py-1 bg-muted/50 text-muted-foreground text-sm font-mono sticky top-0",children:["@@ -",e.oldStart,",",e.oldLines," +",e.newStart,",",e.newLines," @@"]}),e.lines.map((e,r)=>(0,F.jsx)(m2,{line:e},r))]},r))})})]})}let m6=(0,ic.default)("git-commit-horizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),m8="__head__";function m7({commits:e,selectedCommit:r,onSelectCommit:s,loading:i,disabled:n}){return(0,F.jsxs)(aB,{value:r??m8,onValueChange:e=>{s(e===m8?null:e)},disabled:n||i,children:[(0,F.jsxs)(aO,{size:"sm",className:"w-[200px]",children:[(0,F.jsx)(m6,{className:"h-3.5 w-3.5 shrink-0"}),(0,F.jsx)(aA,{placeholder:"Compare from..."})]}),(0,F.jsxs)(aI,{children:[(0,F.jsx)(az,{value:m8,children:"HEAD (uncommitted)"}),e.map(e=>(0,F.jsxs)(az,{value:e.hash,children:[(0,F.jsx)("span",{className:"font-mono text-xs",children:e.shortHash})," ",(0,F.jsx)("span",{className:"truncate",children:e.message.length>40?e.message.slice(0,40)+"...":e.message})]},e.hash))]})]})}function m9({projectId:e,selectedBranch:r,onMergeRequest:s,project:i}){let[n,o]=(0,W.useState)(null),{remotes:a}=iP(i?.id??void 0),l=[];for(let e of(i?.path&&l.push({id:"local",label:"Local",icon:nA.Monitor}),a))l.push({id:e.remote_server_id,label:e.server_name,icon:nO});let c=i?.path?"local":a.length>0?a[0].remote_server_id:"local",[d,h]=(0,W.useState)(c),[u,f]=(0,W.useState)(!0),[p,m]=(0,W.useState)(0),g="local"===d?i?.path?"local":void 0:"remote",{diff:v,loading:x,error:_,refresh:y}=function(e,r,s,i){let[n,o]=(0,W.useState)(null),[a,l]=(0,W.useState)(!1),[c,d]=(0,W.useState)(null),h=(0,W.useCallback)(async()=>{if(!e)return void o(null);l(!0),d(null);try{let n=await iT.api.getDiff(e,r,s,i);o(n)}catch(e){d(e instanceof Error?e.message:"Failed to load diff"),o(null)}finally{l(!1)}},[e,r,s,i]);return{diff:n,loading:a,error:c,refresh:h}}(e,r,n,g),{commits:b,loading:w,refetch:S}=function(e,r,s,i){let[n,o]=(0,W.useState)([]),[a,l]=(0,W.useState)(!1);return{commits:n,loading:a,refetch:(0,W.useCallback)(async()=>{if(!e)return void o([]);l(!0);try{let n=await iT.api.getCommits(e,r,s,i);o(n)}catch{o([])}finally{l(!1)}},[e,r,s,i])}}(e,r,void 0,g);if((0,W.useEffect)(()=>{y()},[y]),(0,W.useEffect)(()=>{S()},[S]),(0,W.useEffect)(()=>{o(null)},[r]),(0,W.useEffect)(()=>{h(c)},[e,c]),!e)return(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(aV,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to view changes"})]})});let C=v?.files.length??0;return(0,F.jsxs)("div",{className:"h-full flex flex-col",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border/60 h-10",children:[(0,F.jsx)("div",{className:"flex items-center gap-4",children:C>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)("span",{className:"text-xs text-muted-foreground",children:[C," file",1!==C?"s":""," changed"]}),(0,F.jsxs)($.Button,{size:"sm",variant:"ghost",onClick:()=>{f(e=>!e),m(e=>e+1)},title:u?"Collapse all":"Expand all",children:[(0,F.jsx)(m1,{className:"h-4 w-4 mr-1"}),u?"Collapse all":"Expand all"]})]})}),(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[l.length>1&&(0,F.jsx)(nP,{targets:l,activeTarget:d,onTargetChange:h,disabled:x}),(0,F.jsx)("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Changes since:"}),(0,F.jsx)(m7,{commits:b,selectedCommit:n,onSelectCommit:o,loading:w,disabled:x}),(0,F.jsxs)($.Button,{size:"sm",variant:"outline",onClick:s,disabled:x||0===C,children:[(0,F.jsx)(m0,{className:"h-4 w-4 mr-1"}),"Merge"]}),(0,F.jsxs)($.Button,{size:"sm",variant:"outline",onClick:y,disabled:x,children:[(0,F.jsx)(mQ,{className:`h-4 w-4 mr-1 ${x?"animate-spin":""}`}),"Refresh"]})]})]}),(0,F.jsx)(oc,{className:"flex-1 overflow-hidden",children:(0,F.jsx)("div",{className:"p-4 space-y-4",children:x&&!v?(0,F.jsx)("div",{className:"text-center text-muted-foreground py-8",children:"Loading changes..."}):_?(0,F.jsx)("div",{className:"text-center text-red-400 py-8",children:_}):0===C?(0,F.jsxs)("div",{className:"text-center text-muted-foreground py-8",children:[(0,F.jsx)("p",{children:n?"No changes since this commit":"No changes"}),n&&(0,F.jsx)("p",{className:"text-sm mt-1",children:"Try selecting an earlier commit"})]}):v?.files.map((e,r)=>(0,F.jsx)(m4,{file:e,defaultOpen:u},`${r}-${p}`))})})]})}function ge({terminalId:e,onExit:r}){let{logs:s,sendInput:i,sendResize:n,exitCode:o}=f7(e);return(0,W.useEffect)(()=>{null!==o&&r(e)},[o,r,e]),(0,F.jsx)(f3,{logs:s,isPty:!0,className:"h-full rounded-none border-0",onInput:i,onResize:n})}function gt({projectId:e,selectedBranch:r,project:s}){let{terminals:i,activeTerminalId:n,createTerminal:o,closeTerminal:a,setActiveTerminal:l,removeTerminal:c}=function(e,r){let[s,i]=(0,W.useState)([]),[n,o]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(!e){i([]),o(null);return}iT.api.getTerminals(e,r).then(e=>{i(e),o(e.length>0?e[0].id:null)})},[e,r]);let a=(0,W.useCallback)(async(s,n)=>{if(!e)return;let a=await iT.api.createTerminal(e,r,s,n);i(e=>[...e,a]),o(a.id)},[e,r]),l=(0,W.useCallback)(async e=>{await iT.api.closeTerminal(e),i(r=>{let s=r.filter(r=>r.id!==e);return o(r=>r===e?s.length>0?s[s.length-1].id:null:r),s})},[]);return{terminals:s,activeTerminalId:n,createTerminal:a,closeTerminal:l,setActiveTerminal:(0,W.useCallback)(e=>{o(e)},[]),removeTerminal:(0,W.useCallback)(e=>{i(r=>{let s=r.filter(r=>r.id!==e);return o(r=>r===e?s.length>0?s[s.length-1].id:null:r),s})},[])}}(e,r),{remotes:d}=iP(s?.id??void 0),[h,u]=(0,W.useState)(!1),f=(0,W.useRef)(null),p=!!s?.path,m=d.length>0,g=p&&m||d.length>1,v=!p&&m||g&&s?.executor_mode!=="local"?"remote":"local",x=(0,W.useCallback)(()=>{o(v)},[o,v]),_=(0,W.useCallback)((e,r)=>{u(!1),o(e,r)},[o]);(0,W.useEffect)(()=>{if(h)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){f.current&&!f.current.contains(e.target)&&u(!1)}},[h]);let y=(0,W.useCallback)(e=>{c(e)},[c]);return e?(0,F.jsxs)("div",{className:"h-full flex flex-col",children:[(0,F.jsxs)("div",{className:"flex items-center h-10 border-b border-border/60 px-2 gap-1 shrink-0 bg-muted/20",children:[(0,F.jsxs)(oc,{className:"flex-1",children:[(0,F.jsx)("div",{className:"flex items-center gap-1",children:i.map(e=>{let r="remote"===e.location||e.id.startsWith("remote-"),s=g?r?nO:nA.Monitor:nL.Terminal;return(0,F.jsxs)("button",{onClick:()=>l(e.id),className:(0,iu.cn)("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs whitespace-nowrap transition-all duration-150",n===e.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-background/50"),children:[(0,F.jsx)(s,{className:"h-3 w-3"}),e.name,(0,F.jsx)("span",{role:"button",onClick:r=>{r.stopPropagation(),a(e.id)},className:"ml-1 hover:text-destructive",children:(0,F.jsx)(nr,{className:"h-3 w-3"})})]},e.id)})}),(0,F.jsx)(od,{orientation:"horizontal"})]}),(0,F.jsxs)("div",{className:"relative shrink-0",ref:f,children:[(0,F.jsx)($.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:g?()=>u(e=>!e):x,children:(0,F.jsx)(nD,{className:"h-3.5 w-3.5"})}),g&&h&&(0,F.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[160px] rounded-md border bg-popover p-1 shadow-md",children:[p&&(0,F.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>_("local"),children:[(0,F.jsx)(nA.Monitor,{className:"h-3.5 w-3.5"}),"Local Terminal"]}),d.map(e=>(0,F.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>_("remote",e.remote_server_id),children:[(0,F.jsx)(nO,{className:"h-3.5 w-3.5"}),e.server_name," Terminal"]},e.remote_server_id))]})]})]}),(0,F.jsx)("div",{className:"flex-1 overflow-hidden bg-zinc-950",children:n?(0,F.jsx)(ge,{terminalId:n,onExit:y},n):(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsx)(nL.Terminal,{className:"h-10 w-10 text-muted-foreground/70"})})})]}):(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(nL.Terminal,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to use the terminal"})]})})}let gr=(0,ic.default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);var[gs,gi]=q("Tooltip",[tK]),gn=tK(),go="TooltipProvider",ga="tooltip.open",[gl,gc]=gs(go),gd=e=>{let{__scopeTooltip:r,delayDuration:s=700,skipDelayDuration:i=300,disableHoverableContent:n=!1,children:o}=e,a=W.useRef(!0),l=W.useRef(!1),c=W.useRef(0);return W.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,F.jsx)(gl,{scope:r,isOpenDelayedRef:a,delayDuration:s,onOpen:W.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:W.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:W.useCallback(e=>{l.current=e},[]),disableHoverableContent:n,children:o})};gd.displayName=go;var gh="Tooltip",[gu,gf]=gs(gh),gp=e=>{let{__scopeTooltip:r,children:s,open:i,defaultOpen:n,onOpenChange:o,disableHoverableContent:a,delayDuration:l}=e,c=gc(gh,e.__scopeTooltip),d=gn(r),[h,u]=W.useState(null),f=ej(),p=W.useRef(0),m=a??c.disableHoverableContent,g=l??c.delayDuration,v=W.useRef(!1),[x,_]=X({prop:i,defaultProp:n??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(ga))):c.onClose(),o?.(e)},caller:gh}),y=W.useMemo(()=>x?v.current?"delayed-open":"instant-open":"closed",[x]),b=W.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v.current=!1,_(!0)},[_]),w=W.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),S=W.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{v.current=!0,_(!0),p.current=0},g)},[g,_]);return W.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),(0,F.jsx)(tV,{...d,children:(0,F.jsx)(gu,{scope:r,contentId:f,open:x,stateAttribute:y,trigger:h,onTriggerChange:u,onTriggerEnter:W.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:W.useCallback(()=>{m?w():(window.clearTimeout(p.current),p.current=0)},[w,m]),onOpen:b,onClose:w,disableHoverableContent:m,children:s})})};gp.displayName=gh;var gm="TooltipTrigger",gg=W.forwardRef((e,r)=>{let{__scopeTooltip:s,...i}=e,n=gf(gm,s),o=gc(gm,s),a=gn(s),l=W.useRef(null),c=(0,U.useComposedRefs)(r,l,n.onTriggerChange),d=W.useRef(!1),h=W.useRef(!1),u=W.useCallback(()=>d.current=!1,[]);return W.useEffect(()=>()=>document.removeEventListener("pointerup",u),[u]),(0,F.jsx)(tX,{asChild:!0,...a,children:(0,F.jsx)(Z.button,{"aria-describedby":n.open?n.contentId:void 0,"data-state":n.stateAttribute,...i,ref:c,onPointerMove:K(e.onPointerMove,e=>{"touch"!==e.pointerType&&(h.current||o.isPointerInTransitRef.current||(n.onTriggerEnter(),h.current=!0))}),onPointerLeave:K(e.onPointerLeave,()=>{n.onTriggerLeave(),h.current=!1}),onPointerDown:K(e.onPointerDown,()=>{n.open&&n.onClose(),d.current=!0,document.addEventListener("pointerup",u,{once:!0})}),onFocus:K(e.onFocus,()=>{d.current||n.onOpen()}),onBlur:K(e.onBlur,n.onClose),onClick:K(e.onClick,n.onClose)})})});gg.displayName=gm;var gv="TooltipPortal",[gx,g_]=gs(gv,{forceMount:void 0}),gy=e=>{let{__scopeTooltip:r,forceMount:s,children:i,container:n}=e,o=gf(gv,r);return(0,F.jsx)(gx,{scope:r,forceMount:s,children:(0,F.jsx)(t8,{present:s||o.open,children:(0,F.jsx)(t6,{asChild:!0,container:n,children:i})})})};gy.displayName=gv;var gb="TooltipContent",gw=W.forwardRef((e,r)=>{let s=g_(gb,e.__scopeTooltip),{forceMount:i=s.forceMount,side:n="top",...o}=e,a=gf(gb,e.__scopeTooltip);return(0,F.jsx)(t8,{present:i||a.open,children:a.disableHoverableContent?(0,F.jsx)(gN,{side:n,...o,ref:r}):(0,F.jsx)(gS,{side:n,...o,ref:r})})}),gS=W.forwardRef((e,r)=>{let s=gf(gb,e.__scopeTooltip),i=gc(gb,e.__scopeTooltip),n=W.useRef(null),o=(0,U.useComposedRefs)(r,n),[a,l]=W.useState(null),{trigger:c,onClose:d}=s,h=n.current,{onPointerInTransitChange:u}=i,f=W.useCallback(()=>{l(null),u(!1)},[u]),p=W.useCallback((e,r)=>{let s,i=e.currentTarget,n={x:e.clientX,y:e.clientY},o=function(e,r){let s=Math.abs(r.top-e.y),i=Math.abs(r.bottom-e.y),n=Math.abs(r.right-e.x),o=Math.abs(r.left-e.x);switch(Math.min(s,i,n,o)){case o:return"left";case n:return"right";case s:return"top";case i:return"bottom";default:throw Error("unreachable")}}(n,i.getBoundingClientRect());l(((s=[...function(e,r,s=5){let i=[];switch(r){case"top":i.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":i.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":i.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":i.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s})}return i}(n,o),...function(e){let{top:r,right:s,bottom:i,left:n}=e;return[{x:n,y:r},{x:s,y:r},{x:s,y:i},{x:n,y:i}]}(r.getBoundingClientRect())].slice()).sort((e,r)=>e.x<r.x?-1:e.x>r.x?1:e.y<r.y?-1:1*!!(e.y>r.y)),function(e){if(e.length<=1)return e.slice();let r=[];for(let s=0;s<e.length;s++){let i=e[s];for(;r.length>=2;){let e=r[r.length-1],s=r[r.length-2];if((e.x-s.x)*(i.y-s.y)>=(e.y-s.y)*(i.x-s.x))r.pop();else break}r.push(i)}r.pop();let s=[];for(let r=e.length-1;r>=0;r--){let i=e[r];for(;s.length>=2;){let e=s[s.length-1],r=s[s.length-2];if((e.x-r.x)*(i.y-r.y)>=(e.y-r.y)*(i.x-r.x))s.pop();else break}s.push(i)}return(s.pop(),1===r.length&&1===s.length&&r[0].x===s[0].x&&r[0].y===s[0].y)?r:r.concat(s)}(s))),u(!0)},[u]);return W.useEffect(()=>()=>f(),[f]),W.useEffect(()=>{if(c&&h){let e=e=>p(e,h),r=e=>p(e,c);return c.addEventListener("pointerleave",e),h.addEventListener("pointerleave",r),()=>{c.removeEventListener("pointerleave",e),h.removeEventListener("pointerleave",r)}}},[c,h,p,f]),W.useEffect(()=>{if(a){let e=e=>{let r=e.target,s={x:e.clientX,y:e.clientY},i=c?.contains(r)||h?.contains(r),n=!function(e,r){let{x:s,y:i}=e,n=!1;for(let e=0,o=r.length-1;e<r.length;o=e++){let a=r[e],l=r[o],c=a.x,d=a.y,h=l.x,u=l.y;d>i!=u>i&&s<(h-c)*(i-d)/(u-d)+c&&(n=!n)}return n}(s,a);i?f():n&&(f(),d())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,h,a,d,f]),(0,F.jsx)(gN,{...e,ref:o})}),[gC,gk]=gs(gh,{isInside:!1}),gj=(0,J.createSlottable)("TooltipContent"),gN=W.forwardRef((e,r)=>{let{__scopeTooltip:s,children:i,"aria-label":n,onEscapeKeyDown:o,onPointerDownOutside:a,...l}=e,c=gf(gb,s),d=gn(s),{onClose:h}=c;return W.useEffect(()=>(document.addEventListener(ga,h),()=>document.removeEventListener(ga,h)),[h]),W.useEffect(()=>{if(c.trigger){let e=e=>{let r=e.target;r?.contains(c.trigger)&&h()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,h]),(0,F.jsx)(ec,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:h,children:(0,F.jsxs)(tQ,{"data-state":c.stateAttribute,...d,...l,ref:r,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[(0,F.jsx)(gj,{children:i}),(0,F.jsx)(gC,{scope:s,isInside:!0,children:(0,F.jsx)(o$,{id:c.contentId,role:"tooltip",children:n||i})})]})})});gw.displayName=gb;var gE="TooltipArrow",gR=W.forwardRef((e,r)=>{let{__scopeTooltip:s,...i}=e,n=gn(s);return gk(gE,s).isInside?null:(0,F.jsx)(t2,{...n,...i,ref:r})});gR.displayName=gE,e.s(["Arrow",()=>gR,"Content",()=>gw,"Portal",()=>gy,"Provider",()=>gd,"Root",()=>gp,"Tooltip",()=>gp,"TooltipArrow",()=>gR,"TooltipContent",()=>gw,"TooltipPortal",()=>gy,"TooltipProvider",()=>gd,"TooltipTrigger",()=>gg,"Trigger",()=>gg,"createTooltipScope",()=>gi],517964);var gM=e.i(517964),gM=gM;function gD({delayDuration:e=0,...r}){return(0,F.jsx)(gM.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function gT({...e}){return(0,F.jsx)(gM.Root,{"data-slot":"tooltip",...e})}function gP({...e}){return(0,F.jsx)(gM.Trigger,{"data-slot":"tooltip-trigger",...e})}function gL({className:e,sideOffset:r=0,children:s,...i}){return(0,F.jsx)(gM.Portal,{children:(0,F.jsxs)(gM.Content,{"data-slot":"tooltip-content",sideOffset:r,className:(0,iu.cn)("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...i,children:[s,(0,F.jsx)(gM.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}let gB=(0,W.createContext)(null),gA=({className:e,children:r,defaultUrl:s="",onUrlChange:i,...n})=>{let[o,a]=(0,W.useState)(s),[l,c]=(0,W.useState)(!1);return(0,F.jsx)(gB.Provider,{value:{url:o,setUrl:e=>{a(e),i?.(e)},consoleOpen:l,setConsoleOpen:c},children:(0,F.jsx)("div",{className:(0,iu.cn)("flex size-full flex-col bg-card",e),...n,children:r})})},gO=({className:e,children:r,...s})=>(0,F.jsx)("div",{className:(0,iu.cn)("flex items-center gap-1 border-b p-2 h-14",e),...s,children:r}),gI=({onClick:e,disabled:r,tooltip:s,children:i,...n})=>(0,F.jsx)(gD,{children:(0,F.jsxs)(gT,{children:[(0,F.jsx)(gP,{asChild:!0,children:(0,F.jsx)($.Button,{className:"h-8 w-8 p-0 hover:text-foreground",disabled:r,onClick:e,size:"sm",variant:"ghost",...n,children:i})}),(0,F.jsx)(gL,{children:(0,F.jsx)("p",{children:s})})]})}),gz=({value:e,onChange:r,onKeyDown:s,...i})=>{let{url:n,setUrl:o}=(()=>{let e=(0,W.useContext)(gB);if(!e)throw Error("WebPreview components must be used within a WebPreview");return e})(),[a,l]=(0,W.useState)(n);return(0,W.useEffect)(()=>{l(n)},[n]),(0,F.jsx)(nh,{className:"h-8 flex-1 text-sm",onChange:r??(e=>{l(e.target.value),r?.(e)}),onKeyDown:e=>{"Enter"===e.key&&o(e.target.value),s?.(e)},placeholder:"Enter URL...",value:e??a,...i})};var gF=e.i(254824);function gW({projectId:e}){let r=(0,W.useRef)(null),s=(0,W.useRef)(null),{addFrame:i,updateFrameUrl:n,refreshFrame:o,hasFrame:a,claimFrame:l,getFrameUrl:c}=(0,gF.useBrowserFrames)(),d=e?c(e):void 0;(0,W.useEffect)(()=>{if(e&&d&&r.current){let i=setTimeout(()=>{r.current&&(s.current?.(),s.current=l(e,r.current))},50);return()=>{clearTimeout(i),s.current?.(),s.current=null}}return()=>{s.current?.(),s.current=null}},[e,d,l]);let h=(0,W.useCallback)(()=>{e&&o(e)},[e,o]),u=(0,W.useCallback)(()=>{d&&window.open(d,"_blank")},[d]),f=(0,W.useCallback)(r=>{e&&(a(e)?n(e,r):i(e,r))},[e,a,n,i]);return(0,F.jsx)("div",{className:"h-full flex flex-col",children:(0,F.jsxs)(gA,{defaultUrl:d??"",onUrlChange:f,className:"h-full",children:[(0,F.jsxs)(gO,{className:"h-10 p-1.5 gap-0.5",children:[(0,F.jsx)(gI,{tooltip:"Refresh",onClick:h,disabled:!d,children:(0,F.jsx)(mQ,{className:"h-3.5 w-3.5"})}),(0,F.jsx)(gI,{tooltip:"Open in browser",onClick:u,disabled:!d,children:(0,F.jsx)(gr,{className:"h-3.5 w-3.5"})}),(0,F.jsx)(gz,{className:"h-7 text-xs"})]}),d?(0,F.jsx)("div",{ref:r,className:"flex-1 bg-white"}):(0,F.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,F.jsx)(iw,{className:"h-8 w-8 opacity-40"}),(0,F.jsx)("p",{className:"text-sm",children:"Enter a URL above to preview"})]})})]})})}function gH({projectId:e,selectedBranch:r,onMergeRequest:s,project:i,onExecutorModeChange:n,agentSlot:o}){let[a,l]=function(e,r){let s=`vibedeckx:activeTab:${e??"none"}:${r??"main"}`,[i,n]=(0,W.useState)(()=>localStorage.getItem(s)??"agent");return(0,W.useEffect)(()=>{n(localStorage.getItem(s)??"agent")},[s]),[i,(0,W.useCallback)(e=>{n(e),localStorage.setItem(s,e)},[s])]}(e,r);return(0,F.jsxs)("div",{className:"h-full flex flex-col",children:[(0,F.jsxs)("div",{className:"flex items-center border-b border-border/60 h-10 px-2 gap-0.5 bg-muted/30",children:[(0,F.jsxs)("button",{onClick:()=>l("agent"),className:(0,iu.cn)("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all duration-150","agent"===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-background/50"),children:[(0,F.jsx)(nB,{className:"h-3.5 w-3.5"}),"Agent"]}),(0,F.jsxs)("button",{onClick:()=>l("executors"),className:(0,iu.cn)("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all duration-150","executors"===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-background/50"),children:[(0,F.jsx)(nL.Terminal,{className:"h-3.5 w-3.5"}),"Executors"]}),(0,F.jsxs)("button",{onClick:()=>l("diff"),className:(0,iu.cn)("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all duration-150","diff"===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-background/50"),children:[(0,F.jsx)(aV,{className:"h-3.5 w-3.5"}),"Diff"]}),(0,F.jsxs)("button",{onClick:()=>l("terminal"),className:(0,iu.cn)("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all duration-150","terminal"===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-background/50"),children:[(0,F.jsx)(aY,{className:"h-3.5 w-3.5"}),"Terminal"]}),(0,F.jsxs)("button",{onClick:()=>l("preview"),className:(0,iu.cn)("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all duration-150","preview"===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-background/50"),children:[(0,F.jsx)(iw,{className:"h-3.5 w-3.5"}),"Preview"]})]}),(0,F.jsx)("div",{className:(0,iu.cn)("flex-1 overflow-hidden","agent"!==a&&"hidden"),children:o}),(0,F.jsx)("div",{className:(0,iu.cn)("flex-1 overflow-hidden","executors"!==a&&"hidden"),children:(0,F.jsx)(mZ,{projectId:e,selectedBranch:r,project:i,onExecutorModeChange:n})}),(0,F.jsx)("div",{className:(0,iu.cn)("flex-1 overflow-hidden","diff"!==a&&"hidden"),children:(0,F.jsx)(m9,{projectId:e,selectedBranch:r,onMergeRequest:s,project:i})}),(0,F.jsx)("div",{className:(0,iu.cn)("flex-1 overflow-hidden","terminal"!==a&&"hidden"),children:(0,F.jsx)(gt,{projectId:e,selectedBranch:r,project:i})}),(0,F.jsx)("div",{className:(0,iu.cn)("flex-1 overflow-hidden","preview"!==a&&"hidden"),children:(0,F.jsx)(gW,{projectId:e,selectedBranch:r,project:i})})]})}var g$=Symbol.for("immer-nothing"),gK=Symbol.for("immer-draftable"),gU=Symbol.for("immer-state");function gq(e){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var gV=Object.getPrototypeOf;function gY(e){return!!e&&!!e[gU]}function gX(e){return!!e&&(gZ(e)||Array.isArray(e)||!!e[gK]||!!e.constructor?.[gK]||g5(e)||g3(e))}var gG=Object.prototype.constructor.toString(),gJ=new WeakMap;function gZ(e){if(!e||"object"!=typeof e)return!1;let r=Object.getPrototypeOf(e);if(null===r||r===Object.prototype)return!0;let s=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;if(s===Object)return!0;if("function"!=typeof s)return!1;let i=gJ.get(s);return void 0===i&&(i=Function.toString.call(s),gJ.set(s,i)),i===gG}function gQ(e,r,s=!0){0===g0(e)?(s?Reflect.ownKeys(e):Object.keys(e)).forEach(s=>{r(s,e[s],e)}):e.forEach((s,i)=>r(i,s,e))}function g0(e){let r=e[gU];return r?r.type_:Array.isArray(e)?1:g5(e)?2:3*!!g3(e)}function g1(e,r){return 2===g0(e)?e.has(r):Object.prototype.hasOwnProperty.call(e,r)}function g2(e,r,s){let i=g0(e);2===i?e.set(r,s):3===i?e.add(s):e[r]=s}function g5(e){return e instanceof Map}function g3(e){return e instanceof Set}function g4(e){return e.copy_||e.base_}function g6(e,r){if(g5(e))return new Map(e);if(g3(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let s=gZ(e);if(!0!==r&&("class_only"!==r||s)){let r=gV(e);return null!==r&&s?{...e}:Object.assign(Object.create(r),e)}{let r=Object.getOwnPropertyDescriptors(e);delete r[gU];let s=Reflect.ownKeys(r);for(let i=0;i<s.length;i++){let n=s[i],o=r[n];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[n]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[n]})}return Object.create(gV(e),r)}}function g8(e,r=!1){return g9(e)||gY(e)||!gX(e)||(g0(e)>1&&Object.defineProperties(e,{set:g7,add:g7,clear:g7,delete:g7}),Object.freeze(e),r&&Object.values(e).forEach(e=>g8(e,!0))),e}var g7={value:function(){gq(2)}};function g9(e){return null===e||"object"!=typeof e||Object.isFrozen(e)}var ve={};function vt(e){let r=ve[e];return r||gq(0,e),r}function vr(e,r){r&&(vt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function vs(e){vi(e),e.drafts_.forEach(vo),e.drafts_=null}function vi(e){e===I&&(I=e.parent_)}function vn(e){return I={drafts_:[],parent_:I,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function vo(e){let r=e[gU];0===r.type_||1===r.type_?r.revoke_():r.revoked_=!0}function va(e,r){r.unfinalizedDrafts_=r.drafts_.length;let s=r.drafts_[0];return void 0!==e&&e!==s?(s[gU].modified_&&(vs(r),gq(4)),gX(e)&&(e=vl(r,e),r.parent_||vd(r,e)),r.patches_&&vt("Patches").generateReplacementPatches_(s[gU].base_,e,r.patches_,r.inversePatches_)):e=vl(r,s,[]),vs(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==g$?e:void 0}function vl(e,r,s){if(g9(r))return r;let i=e.immer_.shouldUseStrictIteration(),n=r[gU];if(!n)return gQ(r,(i,o)=>vc(e,n,r,i,o,s),i),r;if(n.scope_!==e)return r;if(!n.modified_)return vd(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;let r=n.copy_,o=r,a=!1;3===n.type_&&(o=new Set(r),r.clear(),a=!0),gQ(o,(i,o)=>vc(e,n,r,i,o,s,a),i),vd(e,r,!1),s&&e.patches_&&vt("Patches").generatePatches_(n,s,e.patches_,e.inversePatches_)}return n.copy_}function vc(e,r,s,i,n,o,a){if(null==n||"object"!=typeof n&&!a)return;let l=g9(n);if(!l||a){if(gY(n)){let a=vl(e,n,o&&r&&3!==r.type_&&!g1(r.assigned_,i)?o.concat(i):void 0);if(g2(s,i,a),!gY(a))return;e.canAutoFreeze_=!1}else a&&s.add(n);if(gX(n)&&!l){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||r&&r.base_&&r.base_[i]===n&&l)return;vl(e,n),(!r||!r.scope_.parent_)&&"symbol"!=typeof i&&(g5(s)?s.has(i):Object.prototype.propertyIsEnumerable.call(s,i))&&vd(e,n)}}}function vd(e,r,s=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&g8(r,s)}var vh={get(e,r){if(r===gU)return e;let s=g4(e);if(!g1(s,r)){var i;let n;return i=e,(n=vp(s,r))?"value"in n?n.value:n.get?.call(i.draft_):void 0}let n=s[r];return e.finalized_||!gX(n)?n:n===vf(e.base_,r)?(vg(e),e.copy_[r]=vv(n,e)):n},has:(e,r)=>r in g4(e),ownKeys:e=>Reflect.ownKeys(g4(e)),set(e,r,s){let i=vp(g4(e),r);if(i?.set)return i.set.call(e.draft_,s),!0;if(!e.modified_){let i=vf(g4(e),r),n=i?.[gU];if(n&&n.base_===s)return e.copy_[r]=s,e.assigned_[r]=!1,!0;if((s===i?0!==s||1/s==1/i:s!=s&&i!=i)&&(void 0!==s||g1(e.base_,r)))return!0;vg(e),vm(e)}return!!(e.copy_[r]===s&&(void 0!==s||r in e.copy_)||Number.isNaN(s)&&Number.isNaN(e.copy_[r]))||(e.copy_[r]=s,e.assigned_[r]=!0,!0)},deleteProperty:(e,r)=>(void 0!==vf(e.base_,r)||r in e.base_?(e.assigned_[r]=!1,vg(e),vm(e)):delete e.assigned_[r],e.copy_&&delete e.copy_[r],!0),getOwnPropertyDescriptor(e,r){let s=g4(e),i=Reflect.getOwnPropertyDescriptor(s,r);return i?{writable:!0,configurable:1!==e.type_||"length"!==r,enumerable:i.enumerable,value:s[r]}:i},defineProperty(){gq(11)},getPrototypeOf:e=>gV(e.base_),setPrototypeOf(){gq(12)}},vu={};function vf(e,r){let s=e[gU];return(s?g4(s):e)[r]}function vp(e,r){if(!(r in e))return;let s=gV(e);for(;s;){let e=Object.getOwnPropertyDescriptor(s,r);if(e)return e;s=gV(s)}}function vm(e){!e.modified_&&(e.modified_=!0,e.parent_&&vm(e.parent_))}function vg(e){e.copy_||(e.copy_=g6(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function vv(e,r){let s=g5(e)?vt("MapSet").proxyMap_(e,r):g3(e)?vt("MapSet").proxySet_(e,r):function(e,r){let s=Array.isArray(e),i={type_:+!!s,scope_:r?r.scope_:I,modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=i,o=vh;s&&(n=[i],o=vu);let{revoke:a,proxy:l}=Proxy.revocable(n,o);return i.draft_=l,i.revoke_=a,l}(e,r);return(r?r.scope_:I).drafts_.push(s),s}gQ(vh,(e,r)=>{vu[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),vu.deleteProperty=function(e,r){return vu.set.call(this,e,r,void 0)},vu.set=function(e,r,s){return vh.set.call(this,e[0],r,s,e[0])};var vx=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,r,s)=>{let i;if("function"==typeof e&&"function"!=typeof r){let s=r;r=e;let i=this;return function(e=s,...n){return i.produce(e,e=>r.call(this,e,...n))}}if("function"!=typeof r&&gq(6),void 0!==s&&"function"!=typeof s&&gq(7),gX(e)){let n=vn(this),o=vv(e,void 0),a=!0;try{i=r(o),a=!1}finally{a?vs(n):vi(n)}return vr(n,s),va(i,n)}if(e&&"object"==typeof e)gq(1,e);else{if(void 0===(i=r(e))&&(i=e),i===g$&&(i=void 0),this.autoFreeze_&&g8(i,!0),s){let r=[],n=[];vt("Patches").generateReplacementPatches_(e,i,r,n),s(r,n)}return i}},this.produceWithPatches=(e,r)=>{let s,i;return"function"==typeof e?(r,...s)=>this.produceWithPatches(r,r=>e(r,...s)):[this.produce(e,r,(e,r)=>{s=e,i=r}),s,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),"boolean"==typeof e?.useStrictIteration&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){var r;gX(e)||gq(8),gY(e)&&(gY(r=e)||gq(10,r),e=function e(r){let s;if(!gX(r)||g9(r))return r;let i=r[gU],n=!0;if(i){if(!i.modified_)return i.base_;i.finalized_=!0,s=g6(r,i.scope_.immer_.useStrictShallowCopy_),n=i.scope_.immer_.shouldUseStrictIteration()}else s=g6(r,!0);return gQ(s,(r,i)=>{g2(s,r,e(i))},n),i&&(i.finalized_=!1),s}(r));let s=vn(this),i=vv(e,void 0);return i[gU].isManual_=!0,vi(s),i}finishDraft(e,r){let s=e&&e[gU];s&&s.isManual_||gq(9);let{scope_:i}=s;return vr(i,r),va(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,r){let s;for(s=r.length-1;s>=0;s--){let i=r[s];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}s>-1&&(r=r.slice(s+1));let i=vt("Patches").applyPatches_;return gY(e)?i(e,r):this.produce(e,e=>i(e,r))}}().produce,v_=e.i(754219);function vy(){return"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}function vb(e){let r={};e&&(r["Content-Type"]=e);let s=(0,iT.getAuthToken)();return s&&(r.Authorization=`Bearer ${s}`),r}async function vw(e,r,s,i){let n=await fetch(`${vy()}/api/projects/${e}/agent-sessions`,{method:"POST",headers:vb("application/json"),body:JSON.stringify({branch:r,permissionMode:s,agentType:i})});if(!n.ok)throw Error("Failed to create session");return n.json()}async function vS(e,r){let s=await fetch(`${vy()}/api/agent-sessions/${e}/message`,{method:"POST",headers:vb("application/json"),body:JSON.stringify({content:r})});if(!s.ok){let r="";try{let e=await s.json();if(e.errorCode){let s=[`${e.errorCode}`];e.attempts&&s.push(`${e.attempts} attempts`),e.totalDurationMs&&s.push(`${(e.totalDurationMs/1e3).toFixed(1)}s`),r=` (${s.join(", ")})`}else e.error&&(r=` — ${e.error}`)}catch{}throw console.error(`[AgentSession] /message failed: status=${s.status}, sessionId=${e}, detail=${r}`),Error(`Failed to send message [${s.status}]${r}`)}}async function vC(e,r){if(!(await fetch(`${vy()}/api/agent-sessions/${e}/restart`,{method:"POST",headers:vb("application/json"),body:JSON.stringify({agentType:r})})).ok)throw Error("Failed to restart session")}async function vk(e){if(!(await fetch(`${vy()}/api/agent-sessions/${e}/stop`,{method:"POST",headers:vb()})).ok)throw Error("Failed to stop session")}async function vj(e,r){if(!(await fetch(`${vy()}/api/agent-sessions/${e}/switch-mode`,{method:"POST",headers:vb("application/json"),body:JSON.stringify({mode:r})})).ok)throw Error("Failed to switch mode")}async function vN(e,r){if(!(await fetch(`${vy()}/api/agent-sessions/${e}/accept-plan`,{method:"POST",headers:vb("application/json"),body:JSON.stringify({planContent:r})})).ok)throw Error("Failed to accept plan")}let vE=new Map;function vR(e,r){return`${e}:${r??""}`}let vM=(0,ic.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),vD=(0,ic.default)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),vT=(0,ic.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),vP=(0,ic.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),vL=(0,ic.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),vB=(0,ic.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),vA=(0,ic.default)("file-check",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]),vO=(0,ic.default)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),vI=(0,ic.default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),vz=(0,ic.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),vF=(0,ic.default)("folder-search",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]),vW=(0,ic.default)("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),vH=(0,ic.default)("file-pen-line",[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]),v$=(0,ic.default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]),vK=(0,ic.default)("file-plus-corner",[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]]),vU=(0,ic.default)("earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),vq=(0,ic.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var vV="horizontal",vY=["horizontal","vertical"],vX=W.forwardRef((e,r)=>{var s;let{decorative:i,orientation:n=vV,...o}=e,a=(s=n,vY.includes(s))?n:vV;return(0,F.jsx)(Z.div,{"data-orientation":a,...i?{role:"none"}:{"aria-orientation":"vertical"===a?a:void 0,role:"separator"},...o,ref:r})});vX.displayName="Separator",e.s(["Root",()=>vX,"Separator",()=>vX],691102),e.i(691102),(0,ll.cva)("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}}),(0,ic.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var vG=e.i(94265);let vJ=({className:e,from:r,...s})=>(0,F.jsx)("div",{className:(0,iu.cn)("group flex w-full max-w-[95%] flex-col gap-2","user"===r?"is-user ml-auto justify-end":"is-assistant",e),...s}),vZ=({children:e,className:r,...s})=>(0,F.jsx)("div",{className:(0,iu.cn)("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",r),...s,children:e}),vQ=(0,W.memo)(({className:e,...r})=>(0,F.jsx)(vG.i,{className:(0,iu.cn)("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...r}),(e,r)=>e.children===r.children);function v0({input:e,messageIndex:r}){let{sendMessage:s,messages:i}=y_(),n=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&Array.isArray(r.questions)&&r.questions.length>0&&r.questions.every(e=>"string"==typeof e.question&&"string"==typeof e.header&&Array.isArray(e.options)))return r}catch{}return null}(e),o=i[r+1],a=o?.type==="user",l=a?o.content:"",c="string"==typeof l?l:l.filter(e=>"text"===e.type).map(e=>e.text).join("\n");if(!n){let r="string"==typeof e?e:JSON.stringify(e,null,2);return(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:r.length>500?r.substring(0,500)+"...":r})}return a?(0,F.jsx)(v1,{questions:n.questions,answeredText:c}):(0,F.jsx)(v2,{questions:n.questions,sendMessage:s})}function v1({questions:e,answeredText:r}){return(0,F.jsx)("div",{className:"space-y-3 mt-2",children:e.map((e,s)=>(0,F.jsxs)("div",{className:"rounded-lg border bg-muted/30 p-3",children:[(0,F.jsx)("div",{className:"flex items-center gap-2 mb-1.5",children:(0,F.jsx)(ld,{variant:"secondary",className:"text-[10px]",children:e.header})}),(0,F.jsx)("p",{className:"text-sm text-muted-foreground mb-2",children:e.question}),(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[(0,F.jsx)(oE,{className:"h-4 w-4"}),(0,F.jsx)("span",{className:"font-medium",children:r})]})]},s))})}function v2({questions:e,sendMessage:r}){let[s,i]=(0,W.useState)(new Map),[n,o]=(0,W.useState)(new Map),[a,l]=(0,W.useState)(new Set),[c,d]=(0,W.useState)(!1);async function h(){let i=[];for(let r=0;r<e.length;r++)if(a.has(r)){let e=n.get(r)?.trim();e&&i.push(e)}else{let e=s.get(r);e&&e.size>0&&i.push(Array.from(e).join(", "))}if(i.length>0){d(!0);try{await r(i.join("\n"))}finally{d(!1)}}}let u=e.some((e,r)=>{if(a.has(r))return!!n.get(r)?.trim();let i=s.get(r);return i&&i.size>0});return(0,F.jsxs)("div",{className:"space-y-4 mt-2",children:[e.map((e,r)=>{let c=s.get(r)||new Set,d=n.get(r)||"",h=a.has(r);return(0,F.jsxs)("div",{className:"rounded-lg border bg-card p-3",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,F.jsx)(vB,{className:"h-3.5 w-3.5 text-violet-500"}),(0,F.jsx)(ld,{variant:"secondary",className:"text-[10px]",children:e.header})]}),(0,F.jsx)("p",{className:"text-sm font-medium mb-3",children:e.question}),(0,F.jsxs)("div",{className:"grid gap-2",children:[e.options.map(s=>{let n=c.has(s.label)&&!h;return(0,F.jsx)($.Button,{variant:n?"default":"outline",className:(0,iu.cn)("h-auto py-2 px-3 justify-start text-left whitespace-normal",n&&"ring-2 ring-primary/50"),onClick:()=>{var n,o;return n=s.label,o=e.multiSelect,void(i(e=>{let s=new Map(e),i=new Set(s.get(r)||[]);return o?i.has(n)?i.delete(n):i.add(n):i.has(n)?i.clear():(i.clear(),i.add(n)),s.set(r,i),s}),l(e=>{let s=new Set(e);return s.delete(r),s}))},children:(0,F.jsxs)("div",{children:[(0,F.jsx)("span",{className:"font-medium text-sm",children:s.label}),s.description&&(0,F.jsx)("span",{className:"block text-xs text-muted-foreground mt-0.5",children:s.description})]})},s.label)}),(0,F.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,F.jsx)(nh,{placeholder:"Other...",value:d,onChange:e=>{var s;return s=e.target.value,void(o(e=>new Map(e).set(r,s)),s&&(i(e=>{let s=new Map(e);return s.set(r,new Set),s}),l(e=>new Set(e).add(r))))},className:"text-sm"})})]})]},r)}),(0,F.jsxs)($.Button,{onClick:h,disabled:!u||c,size:"sm",className:"active:scale-95 transition-transform",children:[c&&(0,F.jsx)(iD,{className:"h-3.5 w-3.5 animate-spin"}),c?"Submitting...":"Submit"]})]})}function v5(e){try{return JSON.parse(e)}catch{return null}}function v3({input:e,messageIndex:r}){let{messages:s,acceptPlan:i,permissionMode:n,agentType:o}=y_(),[a,l]=(0,W.useState)(!0),[c,d]=(0,W.useState)(!1),h=function(e,r,s){let i="string"==typeof e?v5(e):e;if(i&&"object"==typeof i&&"plan"in i){let e=i.plan;if(e)return e}if("claude-code"===s)for(let e=r.length-1;e>=0;e--){let s=r[e];if("tool_use"===s.type&&"Write"===s.tool){let e="string"==typeof s.input?v5(s.input):s.input;if(e&&"object"==typeof e&&e.file_path?.includes(".claude/plans/")&&e.content)return e.content}}return"Plan written to file"}(e,s,o),u=(0,W.useCallback)(async()=>{d(!0);try{await i(h)}catch{d(!1)}},[i,h]),f="edit"===n,p=!1,m="";for(let e=r+1;e<s.length;e++){let r=s[e];if(r?.type==="user"){p=!0;let e=r.content??"";m="string"==typeof e?e:e.filter(e=>"text"===e.type).map(e=>e.text).join("\n");break}}return(f&&!p&&(p=!0),f||p)?(0,F.jsxs)("div",{className:"space-y-2 mt-2",children:[f?(0,F.jsxs)(ld,{variant:"default",className:"bg-green-600 hover:bg-green-700 text-white",children:[(0,F.jsx)(oE,{className:"h-3 w-3 mr-1"}),"Plan Accepted"]}):(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,F.jsx)(f4,{className:"h-3.5 w-3.5"}),(0,F.jsxs)("span",{children:["Feedback sent: ",m.length>100?m.substring(0,100)+"...":m]})]}),(0,F.jsxs)("details",{open:!f,children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View Plan"}),(0,F.jsx)("div",{className:"mt-2 rounded-lg border p-3 bg-muted/30",children:(0,F.jsx)("div",{className:"text-sm prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",children:(0,F.jsx)(vQ,{children:h})})})]})]}):(0,F.jsxs)("div",{className:"space-y-3 mt-2",children:[(0,F.jsxs)("div",{className:"rounded-lg border p-3 bg-card",children:[(0,F.jsxs)("button",{onClick:()=>l(!a),className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground mb-2 block",children:[a?"Collapse":"Expand"," Plan"]}),a&&(0,F.jsx)("div",{className:"text-sm prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words max-h-96 overflow-y-auto",children:(0,F.jsx)(vQ,{children:h})})]}),(0,F.jsxs)($.Button,{onClick:u,disabled:c,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[c?(0,F.jsx)(iD,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):(0,F.jsx)(iN,{className:"h-3.5 w-3.5 mr-1.5"}),c?"Accepting Plan...":"Accept Plan & Start Editing"]})]})}function v4({requestId:e,command:r,cwd:s,messageIndex:i}){let{messages:n,sessionId:o}=y_(),[a,l]=(0,W.useState)(!1),[c,d]=(0,W.useState)(null),h=!1;for(let e=i+1;e<n.length;e++)if(n[e]?.type==="user"){h=!0;break}c&&(h=!0);let u=(0,W.useCallback)(async r=>{if(o){l(!0),d(r);try{await (0,iT.sendApprovalResponse)(o,e,r)}catch{d(null),l(!1)}}},[o,e]);return h?(0,F.jsxs)("div",{className:"space-y-2 mt-2",children:[(0,F.jsxs)("div",{className:"rounded-lg border bg-muted/30 p-3",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,F.jsx)(nL.Terminal,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,F.jsx)("span",{className:"text-xs text-muted-foreground",children:"Command"})]}),(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:r||"(empty)"}),s&&(0,F.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:["cwd: ",s]})]}),(0,F.jsxs)(ld,{variant:"default",className:"decline"===c?"bg-red-600 hover:bg-red-700 text-white":"bg-green-600 hover:bg-green-700 text-white",children:[(0,F.jsx)(oE,{className:"h-3 w-3 mr-1"}),"decline"===c?"Denied":"Allowed"]})]}):(0,F.jsxs)("div",{className:"space-y-2 mt-2",children:[(0,F.jsxs)("div",{className:"rounded-lg border bg-card p-3",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,F.jsx)(nL.Terminal,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,F.jsx)("span",{className:"text-xs text-muted-foreground",children:"Command"})]}),(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:r||"(empty)"}),s&&(0,F.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:["cwd: ",s]})]}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsxs)($.Button,{onClick:()=>u("accept"),disabled:a,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[a&&"accept"===c?(0,F.jsx)(iD,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,F.jsx)(oE,{className:"h-3.5 w-3.5 mr-1"}),"Allow"]}),(0,F.jsxs)($.Button,{onClick:()=>u("decline"),disabled:a,variant:"destructive",size:"sm",children:[a&&"decline"===c?(0,F.jsx)(iD,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,F.jsx)(ow,{className:"h-3.5 w-3.5 mr-1"}),"Deny"]})]})]})}function v6({requestId:e,changes:r,messageIndex:s}){let{messages:i,sessionId:n}=y_(),[o,a]=(0,W.useState)(!1),[l,c]=(0,W.useState)(null),d=!1;for(let e=s+1;e<i.length;e++)if(i[e]?.type==="user"){d=!0;break}l&&(d=!0);let h=(0,W.useCallback)(async r=>{if(n){a(!0),c(r);try{await (0,iT.sendApprovalResponse)(n,e,r)}catch{c(null),a(!1)}}},[n,e]),u=r??[],f=()=>(0,F.jsx)("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2",children:0===u.length?(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"No file changes"}):u.map((e,r)=>(0,F.jsxs)("div",{children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(vI,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),(0,F.jsx)("code",{className:"text-xs break-all",children:e.path}),(0,F.jsx)(ld,{variant:"secondary",className:`text-[10px] ${function(e){switch(e){case"added":case"add":return"bg-green-500/10 text-green-600";case"deleted":case"delete":return"bg-red-500/10 text-red-600";default:return"bg-blue-500/10 text-blue-600"}}(e.kind)}`,children:function(e){switch(e){case"added":case"add":return"added";case"deleted":case"delete":return"deleted";default:return"modified"}}(e.kind)})]}),e.diff&&(0,F.jsxs)("details",{className:"mt-1",children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View diff"}),(0,F.jsx)("pre",{className:"mt-1 text-xs p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.diff.split("\n").map((e,r)=>{let s="";return e.startsWith("+")?s="bg-green-500/10 text-green-700 dark:text-green-400":e.startsWith("-")&&(s="bg-red-500/10 text-red-700 dark:text-red-400"),(0,F.jsx)("div",{className:s,children:e},r)})})]})]},r))});return d?(0,F.jsxs)("div",{className:"space-y-2 mt-2",children:[f(),(0,F.jsxs)(ld,{variant:"default",className:"decline"===l?"bg-red-600 hover:bg-red-700 text-white":"bg-green-600 hover:bg-green-700 text-white",children:[(0,F.jsx)(oE,{className:"h-3 w-3 mr-1"}),"decline"===l?"Denied":"Allowed"]})]}):(0,F.jsxs)("div",{className:"space-y-2 mt-2",children:[f(),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsxs)($.Button,{onClick:()=>h("accept"),disabled:o,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[o&&"accept"===l?(0,F.jsx)(iD,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,F.jsx)(oE,{className:"h-3.5 w-3.5 mr-1"}),"Allow"]}),(0,F.jsxs)($.Button,{onClick:()=>h("decline"),disabled:o,variant:"destructive",size:"sm",children:[o&&"decline"===l?(0,F.jsx)(iD,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,F.jsx)(ow,{className:"h-3.5 w-3.5 mr-1"}),"Deny"]})]})]})}vQ.displayName="MessageResponse";let v8=(0,ic.default)("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);var v7=e.i(252512);let v9=(0,ic.default)("badge",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}]]);function xe({status:e,className:r}){switch(e){case"completed":return(0,F.jsx)(oE,{className:(0,iu.cn)("h-4 w-4 text-green-500",r)});case"in_progress":return(0,F.jsx)(iD,{className:(0,iu.cn)("h-4 w-4 text-cyan-500 animate-spin",r)});case"pending":default:return(0,F.jsx)(ih,{className:(0,iu.cn)("h-4 w-4 text-muted-foreground",r)});case"deleted":return(0,F.jsx)(ow,{className:(0,iu.cn)("h-4 w-4 text-red-400",r)})}}function xt(e,r){try{let s="string"==typeof e?JSON.parse(e):e;if(s&&"object"==typeof s&&r(s))return s}catch{}return null}function xr({input:e}){let r="string"==typeof e?e:JSON.stringify(e,null,2);return(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:r.length>500?r.substring(0,500)+"...":r})}function xs({input:e}){let r=xt(e,e=>Array.isArray(e.todos)&&e.todos.length>0);return r?(0,F.jsx)("div",{className:"mt-2 space-y-1",children:r.todos.map((e,r)=>(0,F.jsxs)("div",{className:"flex items-start gap-2 py-0.5",children:[(0,F.jsx)(xe,{status:e.status,className:"mt-0.5 flex-shrink-0"}),(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:(0,iu.cn)("text-sm break-words","completed"===e.status&&"line-through text-muted-foreground"),children:e.subject??e.content??"Untitled task"}),"in_progress"===e.status&&e.activeForm&&(0,F.jsx)("span",{className:"block text-xs italic text-cyan-500",children:e.activeForm})]})]},e.id??r))}):(0,F.jsx)(xr,{input:e})}function xi({input:e}){let r=xt(e,e=>"string"==typeof e.subject);return r?(0,F.jsxs)("div",{className:"mt-2 flex items-start gap-2",children:[(0,F.jsx)(v8,{className:"h-4 w-4 text-cyan-500 mt-0.5 flex-shrink-0"}),(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:"text-sm font-medium break-words",children:r.subject}),r.description&&(0,F.jsx)("span",{className:"block text-xs text-muted-foreground mt-0.5 break-words",children:r.description.length>200?r.description.substring(0,200)+"...":r.description})]})]}):(0,F.jsx)(xr,{input:e})}function xn({input:e}){let r=xt(e,e=>"string"==typeof e.taskId);return r?(0,F.jsxs)("div",{className:"mt-2 flex items-start gap-2 flex-wrap",children:[r.status?(0,F.jsx)(xe,{status:r.status,className:"mt-0.5 flex-shrink-0"}):(0,F.jsx)(v7.ArrowRight,{className:"h-4 w-4 text-cyan-500 mt-0.5 flex-shrink-0"}),(0,F.jsxs)("span",{className:"text-sm break-words",children:["Task #",r.taskId,r.status&&(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsx)(v7.ArrowRight,{className:"inline h-3 w-3 text-muted-foreground mx-0.5"})," ",r.status]}),r.subject&&(0,F.jsxs)("span",{className:"text-muted-foreground",children:[" — ",r.subject]})]}),r.addBlockedBy&&r.addBlockedBy.length>0&&(0,F.jsx)("div",{className:"flex gap-1 mt-1 w-full pl-6",children:r.addBlockedBy.map(e=>(0,F.jsxs)(ld,{variant:"outline",className:"text-[10px]",children:[(0,F.jsx)(v9,{className:"h-2.5 w-2.5 mr-0.5"}),"blocked by #",e]},e))}),r.addBlocks&&r.addBlocks.length>0&&(0,F.jsx)("div",{className:"flex gap-1 mt-1 w-full pl-6",children:r.addBlocks.map(e=>(0,F.jsxs)(ld,{variant:"outline",className:"text-[10px]",children:[(0,F.jsx)(v9,{className:"h-2.5 w-2.5 mr-0.5"}),"blocks #",e]},e))})]}):(0,F.jsx)(xr,{input:e})}function xo(){return(0,F.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,F.jsx)(iD,{className:"h-4 w-4 animate-spin text-cyan-500"}),(0,F.jsx)("span",{children:"Listing tasks..."})]})}function xa({input:e}){let r=xt(e,e=>"string"==typeof e.taskId);return r?(0,F.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,F.jsx)(iD,{className:"h-4 w-4 animate-spin text-cyan-500"}),(0,F.jsxs)("span",{children:["Fetching task #",r.taskId,"..."]})]}):(0,F.jsx)(xr,{input:e})}function xl({output:e}){let r=function(e){try{let r=JSON.parse(e);if(Array.isArray(r))return r.filter(e=>e.id&&e.subject).map(e=>({id:String(e.id),subject:String(e.subject),status:e.status||"pending",owner:e.owner?String(e.owner):void 0,blockedBy:Array.isArray(e.blockedBy)?e.blockedBy.map(String):void 0}));let s=r.tasks??r.items??r.data;if(Array.isArray(s))return s.filter(e=>e.id&&e.subject).map(e=>({id:String(e.id),subject:String(e.subject),status:e.status||"pending",owner:e.owner?String(e.owner):void 0,blockedBy:Array.isArray(e.blockedBy)?e.blockedBy.map(String):void 0}))}catch{let r=e.trim().split("\n").filter(Boolean),s=[];for(let e of r){let r=e.match(/^#?(\d+)[\s.:\-]+\[?(completed|in_progress|pending|deleted)\]?\s+(.+)/i);r&&s.push({id:r[1],status:r[2].toLowerCase(),subject:r[3].trim()})}if(s.length>0)return s}return null}(e);return r?(0,F.jsx)("div",{className:"mt-1 space-y-1",children:r.map(e=>(0,F.jsxs)("div",{className:"flex items-start gap-2 py-0.5",children:[(0,F.jsx)(xe,{status:e.status,className:"mt-0.5 flex-shrink-0"}),(0,F.jsxs)("div",{className:"min-w-0 flex items-center gap-1.5 flex-wrap",children:[(0,F.jsxs)("span",{className:"text-xs text-muted-foreground",children:["#",e.id]}),(0,F.jsx)("span",{className:(0,iu.cn)("text-sm break-words","completed"===e.status&&"line-through text-muted-foreground"),children:e.subject}),e.blockedBy&&e.blockedBy.length>0&&(0,F.jsx)(ld,{variant:"outline",className:"text-[10px]",children:"blocked"})]})]},e.id))}):null}function xc({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,offset:i,limit:n}=r,o=s.split("/"),a=o.pop()||s,l=o.join("/"),c=null!=i||null!=n,d="";if(c){let e=i??1;d=null!=n?`Lines ${e}\u2013${e+n-1}`:`From line ${e}`}return(0,F.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:"text-sm font-medium break-all",children:a}),l&&(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:s,children:l})]}),c&&(0,F.jsx)(ld,{variant:"outline",className:"text-xs shrink-0",children:d})]})}function xd({output:e}){let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["File contents (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xh({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,content:i}=r,n=s.split("/"),o=n.pop()||s,a=n.join("/"),l=i.split("\n").length;return(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:"text-sm font-medium break-all",children:o}),a&&(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:s,children:a})]}),(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Content (",l," ",1===l?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:i.length>1e3?i.substring(0,1e3)+"...":i})]})]})}function xu({output:e}){return e&&""!==e.trim()?(0,F.jsxs)("details",{children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Result"}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]}):(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"File written"})}function xf({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.command)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{command:s,description:i,timeout:n}=r;return(0,F.jsxs)("div",{className:"space-y-1",children:[i&&(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),(0,F.jsxs)("div",{className:"flex items-start gap-2",children:[(0,F.jsxs)("pre",{className:"flex-1 min-w-0 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:[(0,F.jsx)("span",{className:"text-muted-foreground select-none",children:"$ "}),s]}),null!=n&&(0,F.jsx)(ld,{variant:"outline",className:"text-xs shrink-0 mt-1",children:function(e){if(e>=6e4){let r=e/6e4;return`${r%1==0?r:r.toFixed(1)}m`}return`${e/1e3}s`}(n)})]})]})}function xp({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Output (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xm({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.pattern)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let s=[];return r.path&&s.push({label:r.path}),r.glob&&s.push({label:r.glob}),r.type&&s.push({label:`.${r.type}`}),r.output_mode&&"files_with_matches"!==r.output_mode&&s.push({label:r.output_mode}),null!=r.context&&s.push({label:`context: ${r.context}`}),null!=r["-C"]&&s.push({label:`context: ${r["-C"]}`}),null!=r["-B"]&&s.push({label:`before: ${r["-B"]}`}),null!=r["-A"]&&s.push({label:`after: ${r["-A"]}`}),r["-i"]&&s.push({label:"case-insensitive"}),r.multiline&&s.push({label:"multiline"}),null!=r.head_limit&&s.push({label:`limit: ${r.head_limit}`}),null!=r.offset&&s.push({label:`offset: ${r.offset}`}),(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsx)("div",{className:"flex items-start gap-2",children:(0,F.jsxs)("pre",{className:"flex-1 min-w-0 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:[(0,F.jsx)("span",{className:"text-muted-foreground select-none",children:"/ "}),r.pattern]})}),s.length>0&&(0,F.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",children:s.map((e,r)=>(0,F.jsx)(ld,{variant:"outline",className:"text-xs",children:e.label},r))})]})}function xg({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No matches"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Results (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xv({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.pattern)return r;return null}catch{return null}}(e);return r?(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsx)("div",{className:"flex items-start gap-2",children:(0,F.jsx)("pre",{className:"flex-1 min-w-0 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:r.pattern})}),r.path&&(0,F.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",children:(0,F.jsx)(ld,{variant:"outline",className:"text-xs",children:r.path})})]}):(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function xx({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No matches"});let r=e.trim().split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:[r," ",1===r?"file":"files"," found"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}let x_={Explore:"Explore",Bash:"Bash",Plan:"Plan","general-purpose":"General","code-simplifier":"Simplify","superpowers:code-reviewer":"Review","memory-leak-detector":"Memory","directory-structure-validator":"Structure","tech-docs-finder":"Docs","claude-code-guide":"Guide","statusline-setup":"Status"};function xy({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.description&&"string"==typeof r.subagent_type)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{description:s,subagent_type:i,prompt:n,model:o,max_turns:a,resume:l,run_in_background:c}=r,d=[];return d.push({label:x_[i]||i}),o&&d.push({label:o}),null!=a&&d.push({label:`${a} turns`}),c&&d.push({label:"background"}),l&&d.push({label:"resume"}),(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,F.jsx)("span",{className:"text-sm",children:s}),d.map((e,r)=>(0,F.jsx)(ld,{variant:"outline",className:"text-xs shrink-0",children:e.label},r))]}),n&&(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Prompt (",n.length>1e3?`${Math.round(n.length/1e3)}k chars`:`${n.length} chars`,")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:n.length>1e3?n.substring(0,1e3)+"...":n})]})]})}function xb({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Agent result (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xw(e,r){return e.length>r?e.substring(0,r)+"...":e}function xS({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path&&"string"==typeof r.old_string&&"string"==typeof r.new_string)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,old_string:i,new_string:n,replace_all:o}=r,a=s.split("/"),l=a.pop()||s,c=a.join("/"),d=i.split("\n").length,h=n.split("\n").length;return(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:"text-sm font-medium break-all",children:l}),c&&(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:s,children:c})]}),(0,F.jsx)(ld,{variant:"outline",className:"text-xs shrink-0",children:d===h?`${d} ${1===d?"line":"lines"}`:`${d}\u2192${h} lines`}),o&&(0,F.jsx)(ld,{variant:"outline",className:"text-xs shrink-0",children:"replace all"})]}),(0,F.jsxs)("details",{children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Diff"}),(0,F.jsxs)("div",{className:"mt-1 text-xs rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full",children:[(0,F.jsxs)("pre",{className:"bg-red-500/10 p-1.5 rounded-t whitespace-pre-wrap break-all",children:[(0,F.jsx)("span",{className:"text-red-500 select-none",children:"- "}),xw(i,500)]}),(0,F.jsxs)("pre",{className:"bg-green-500/10 p-1.5 rounded-b whitespace-pre-wrap break-all",children:[(0,F.jsx)("span",{className:"text-green-500 select-none",children:"+ "}),xw(n,500)]})]})]})]})}function xC({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});if(e.length<=200)return(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:e});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Result (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xk({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.url&&"string"==typeof r.prompt)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{display:s,href:i}=function(e){try{let r=new URL(e),s="/"===r.pathname?"":r.pathname,i=r.hostname+s;return{display:i.length>80?i.substring(0,77)+"...":i,href:e}}catch{return{display:e.length>80?e.substring(0,77)+"...":e,href:e}}}(r.url),n=r.prompt.length>150?r.prompt.substring(0,147)+"...":r.prompt;return(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsx)("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"block text-xs font-mono text-blue-500 hover:underline truncate",children:s}),(0,F.jsxs)("p",{className:"text-xs text-muted-foreground",children:['"',n,'"']})]})}function xj({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No content fetched"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Response (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xN({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.query)return r;return null}catch{return null}}(e);return r?(0,F.jsxs)("div",{className:"space-y-1.5",children:[(0,F.jsx)("p",{className:"text-xs font-mono bg-muted/50 px-2 py-1 rounded break-words",children:r.query}),r.allowed_domains&&r.allowed_domains.length>0&&(0,F.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,F.jsx)("span",{className:"text-xs text-muted-foreground",children:"only:"}),r.allowed_domains.map(e=>(0,F.jsx)(ld,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:e},e))]}),r.blocked_domains&&r.blocked_domains.length>0&&(0,F.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,F.jsx)("span",{className:"text-xs text-muted-foreground",children:"exclude:"}),r.blocked_domains.map(e=>(0,F.jsx)(ld,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:e},e))]})]}):(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function xE({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No search results"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Results (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xR({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.skill)return r;return null}catch{return null}}(e);return r?(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsx)("p",{className:"text-xs font-mono text-pink-500",children:r.skill}),r.args&&(0,F.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:["args: ",r.args]})]}):(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function xM({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Loaded (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xD({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.task_id)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{task_id:s,block:i,timeout:n}=r,o=[];return o.push({label:!1===i?"non-blocking":"blocking"}),null!=n&&o.push({label:`${Math.round(n/1e3)}s`}),(0,F.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,F.jsx)("code",{className:"text-sm bg-muted/50 px-1.5 py-0.5 rounded",children:s}),o.map((e,r)=>(0,F.jsx)(ld,{variant:"outline",className:"text-xs shrink-0",children:e.label},r))]})}function xT({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Task output (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xP({input:e}){let r="string"==typeof e?function(e){try{return JSON.parse(e)}catch{return null}}(e):e,s=r?.changes??[];return 0===s.length?(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"No file changes"}):(0,F.jsx)("div",{className:"space-y-2 mt-1",children:s.map((e,r)=>(0,F.jsxs)("div",{children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(vI,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),(0,F.jsx)("code",{className:"text-xs break-all",children:e.path}),(0,F.jsx)(ld,{variant:"secondary",className:`text-[10px] ${function(e){switch(e){case"added":case"add":return"bg-green-500/10 text-green-600";case"deleted":case"delete":return"bg-red-500/10 text-red-600";default:return"bg-blue-500/10 text-blue-600"}}(e.kind)}`,children:function(e){switch(e){case"added":case"add":return"added";case"deleted":case"delete":return"deleted";default:return"modified"}}(e.kind)})]}),e.diff&&(0,F.jsxs)("details",{className:"mt-1",children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View diff"}),(0,F.jsx)("pre",{className:"mt-1 text-xs p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.diff.split("\n").map((e,r)=>{let s="";return e.startsWith("+")?s="bg-green-500/10 text-green-700 dark:text-green-400":e.startsWith("-")&&(s="bg-red-500/10 text-red-700 dark:text-red-400"),(0,F.jsx)("div",{className:s,children:e},r)})})]})]},r))})}function xL({output:e}){let r=e.toLowerCase(),s="text-muted-foreground";return r.includes("completed")||r.includes("success")?s="text-green-600 dark:text-green-400":r.includes("failed")||r.includes("error")?s="text-red-600 dark:text-red-400":(r.includes("declined")||r.includes("denied"))&&(s="text-amber-600 dark:text-amber-400"),(0,F.jsx)("p",{className:`text-xs ${s}`,children:e})}function xB({message:e,messageIndex:r}){switch(e.type){case"user":return(0,F.jsx)(xA,{content:e.content});case"assistant":return(0,F.jsx)(xO,{content:e.content});case"tool_use":return(0,F.jsx)(xI,{tool:e.tool,input:e.input,messageIndex:r});case"tool_result":return(0,F.jsx)(xz,{tool:e.tool,output:e.output});case"thinking":return(0,F.jsx)(xF,{content:e.content});case"error":return(0,F.jsx)(xW,{message:e.message});case"system":return(0,F.jsx)(xH,{content:e.content});case"approval_request":return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-amber-500/10 flex items-center justify-center",children:(0,F.jsx)(vq,{className:"w-4 h-4 text-amber-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-amber-500 mb-1",children:"command"===e.requestType?"Command Approval":"File Change Approval"}),"command"===e.requestType?(0,F.jsx)(v4,{requestId:e.requestId,command:e.command,cwd:e.cwd,messageIndex:r}):(0,F.jsx)(v6,{requestId:e.requestId,changes:e.changes,messageIndex:r})]})]});default:return null}}function xA({content:e}){return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-primary/10 flex items-center justify-center",children:(0,F.jsx)(vM,{className:"w-3.5 h-3.5 text-primary"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-foreground mb-1",children:"You"}),(0,F.jsx)("div",{className:"text-sm text-foreground prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",children:"string"==typeof e?(0,F.jsx)(vQ,{children:e??""}):e.map((e,r)=>"text"===e.type?(0,F.jsx)(vQ,{children:e.text},r):(0,F.jsx)("img",{src:`data:${e.mediaType};base64,${e.data}`,alt:"Attached image",className:"max-w-sm rounded-lg mt-2"},r))})]})]})}function xO({content:e}){let r="codex"===function(){try{return y_().agentType}catch{return"claude-code"}}();return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:`flex-shrink-0 w-7 h-7 rounded-lg ${r?"bg-green-500/10":"bg-violet-500/10"} flex items-center justify-center`,children:(0,F.jsx)(nB,{className:`w-3.5 h-3.5 ${r?"text-green-500":"text-violet-500"}`})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:`text-sm font-medium ${r?"text-green-500":"text-violet-500"} mb-1`,children:r?"Codex":"Claude"}),(0,F.jsx)("div",{className:"text-sm text-foreground prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",children:(0,F.jsx)(vQ,{children:e??""})})]})]})}function xI({tool:e,input:r,messageIndex:s}){if("AskUserQuestion"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-violet-500/10 flex items-center justify-center",children:(0,F.jsx)(vB,{className:"w-4 h-4 text-violet-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-violet-500 mb-1",children:"Question"}),(0,F.jsx)(v0,{input:r,messageIndex:s})]})]});if("ExitPlanMode"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-green-500/10 flex items-center justify-center",children:(0,F.jsx)(vA,{className:"w-4 h-4 text-green-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-green-500 mb-1",children:"Plan Ready"}),(0,F.jsx)(v3,{input:r,messageIndex:s})]})]});let i={TodoWrite:{label:"Tasks",ui:(0,F.jsx)(xs,{input:r})},TaskCreate:{label:"Create Task",ui:(0,F.jsx)(xi,{input:r})},TaskUpdate:{label:"Update Task",ui:(0,F.jsx)(xn,{input:r})},TaskList:{label:"Task List",ui:(0,F.jsx)(xo,{})},TaskGet:{label:"Get Task",ui:(0,F.jsx)(xa,{input:r})}}[e];if(i)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-cyan-500/10 flex items-center justify-center",children:(0,F.jsx)(vO,{className:"w-4 h-4 text-cyan-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-cyan-500 mb-1",children:i.label}),i.ui]})]});if("Read"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,F.jsx)(vI,{className:"w-4 h-4 text-sky-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"Read File"}),(0,F.jsx)(xc,{input:r})]})]});if("Edit"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,F.jsx)(vH,{className:"w-4 h-4 text-sky-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"Edit File"}),(0,F.jsx)(xS,{input:r})]})]});if("Write"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,F.jsx)(vK,{className:"w-4 h-4 text-sky-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"Write File"}),(0,F.jsx)(xh,{input:r})]})]});if("Bash"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:(0,F.jsx)(nL.Terminal,{className:"w-4 h-4 text-emerald-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-emerald-500 mb-1",children:"Run Command"}),(0,F.jsx)(xf,{input:r})]})]});if("Grep"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-orange-500/10 flex items-center justify-center",children:(0,F.jsx)(vz,{className:"w-4 h-4 text-orange-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-orange-500 mb-1",children:"Search"}),(0,F.jsx)(xm,{input:r})]})]});if("Glob"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-teal-500/10 flex items-center justify-center",children:(0,F.jsx)(vF,{className:"w-4 h-4 text-teal-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-teal-500 mb-1",children:"Glob"}),(0,F.jsx)(xv,{input:r})]})]});if("Task"===e||"Agent"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-purple-500/10 flex items-center justify-center",children:(0,F.jsx)(vW,{className:"w-4 h-4 text-purple-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-purple-500 mb-1",children:"Agent"}),(0,F.jsx)(xy,{input:r})]})]});if("TaskOutput"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-purple-500/10 flex items-center justify-center",children:(0,F.jsx)(vW,{className:"w-4 h-4 text-purple-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-purple-500 mb-1",children:"Task Output"}),(0,F.jsx)(xD,{input:r})]})]});if("WebFetch"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-blue-500/10 flex items-center justify-center",children:(0,F.jsx)(iw,{className:"w-4 h-4 text-blue-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-blue-500 mb-1",children:"Fetch Web Page"}),(0,F.jsx)(xk,{input:r})]})]});if("WebSearch"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-indigo-500/10 flex items-center justify-center",children:(0,F.jsx)(vU,{className:"w-4 h-4 text-indigo-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-indigo-500 mb-1",children:"Web Search"}),(0,F.jsx)(xN,{input:r})]})]});if("Skill"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-pink-500/10 flex items-center justify-center",children:(0,F.jsx)(v$,{className:"w-4 h-4 text-pink-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-pink-500 mb-1",children:"Skill"}),(0,F.jsx)(xR,{input:r})]})]});if("FileChange"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,F.jsx)(vH,{className:"w-4 h-4 text-sky-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"File Changes"}),(0,F.jsx)(xP,{input:r})]})]});let n="string"==typeof r?r:JSON.stringify(r,null,2);return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-amber-500/10 flex items-center justify-center",children:(0,F.jsx)(vD,{className:"w-4 h-4 text-amber-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsxs)("p",{className:"text-sm font-medium text-amber-500 mb-1 break-words",children:["Tool: ",e]}),(0,F.jsxs)("details",{open:!0,children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Input"}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:n.length>500?n.substring(0,500)+"...":n})]})]})]})}function xz({tool:e,output:r}){if(["TodoWrite","TaskCreate","TaskUpdate","TaskList","TaskGet"].includes(e)){let s="TaskList"===e?(0,F.jsx)(xl,{output:r}):null;return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsxs)("p",{className:"text-xs text-muted-foreground mb-1",children:["Result (",e,")"]}),s||(0,F.jsxs)("details",{children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Output"}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:r.length>1e3?r.substring(0,1e3)+"...":r})]})]})})}if("Read"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xd,{output:r})})});if("Edit"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xC,{output:r})})});if("Write"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xu,{output:r})})});if("Bash"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xp,{output:r})})});if("Grep"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xg,{output:r})})});if("Glob"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xx,{output:r})})});if("Task"===e||"Agent"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xb,{output:r})})});if("TaskOutput"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xT,{output:r})})});if("WebFetch"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xj,{output:r})})});if("WebSearch"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xE,{output:r})})});if("Skill"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xM,{output:r})})});if("FileChange"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xL,{output:r})})});let s=r.length>200;return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsxs)("p",{className:"text-xs text-muted-foreground mb-1",children:["Result",e?` (${e})`:""]}),(0,F.jsxs)("details",{className:(0,iu.cn)(!s&&"open"),children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Output"}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:r.length>1e3?r.substring(0,1e3)+"...":r})]})]})})}function xF({content:e}){return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-blue-500/10 flex items-center justify-center",children:(0,F.jsx)(vT,{className:"w-3.5 h-3.5 text-blue-500"})}),(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsxs)("details",{children:[(0,F.jsx)("summary",{className:"text-xs font-medium text-blue-500 cursor-pointer hover:underline",children:"Thinking..."}),(0,F.jsx)("div",{className:"mt-2 text-xs text-muted-foreground whitespace-pre-wrap break-words bg-blue-500/5 p-2 rounded-md overflow-hidden",children:(e??"").length>500?(e??"").substring(0,500)+"...":e??""})]})})]})}function xW({message:e}){return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-red-500/10 flex items-center justify-center",children:(0,F.jsx)(vP,{className:"w-3.5 h-3.5 text-red-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-red-500 mb-1",children:"Error"}),(0,F.jsx)("p",{className:"text-sm text-red-500/80 break-words",children:e})]})]})}function xH({content:e}){return(0,F.jsxs)("div",{className:"flex gap-3 py-2",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-gray-500/10 flex items-center justify-center",children:(0,F.jsx)(vL,{className:"w-3.5 h-3.5 text-gray-500"})}),(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)("p",{className:"text-xs text-muted-foreground break-words",children:e??""})})]})}let x$={damping:.7,stiffness:.05,mass:1.25},xK=1e3/60,xU=!1;function xq(e,r){let s=(0,W.useCallback)(r=>(s.current=r,e(r)),r);return s}globalThis.document?.addEventListener("mousedown",()=>{xU=!0}),globalThis.document?.addEventListener("mouseup",()=>{xU=!1}),globalThis.document?.addEventListener("click",()=>{xU=!1});let xV=new Map;function xY(...e){let r={...x$},s=!1;for(let i of e){if("instant"===i){s=!0;continue}"object"==typeof i&&(s=!1,r.damping=i.damping??r.damping,r.stiffness=i.stiffness??r.stiffness,r.mass=i.mass??r.mass)}let i=JSON.stringify(r);return xV.has(i)||xV.set(i,Object.freeze(r)),s?"instant":xV.get(i)}let xX=(0,W.createContext)(null),xG="undefined"!=typeof window?W.useLayoutEffect:W.useEffect;function xJ({instance:e,children:r,resize:s,initial:i,mass:n,damping:o,stiffness:a,targetScrollTop:l,contextRef:c,...d}){let h=(0,W.useRef)(null),u=((e={})=>{let[r,s]=(0,W.useState)(!1),[i,n]=(0,W.useState)(!1!==e.initial),[o,a]=(0,W.useState)(!1),l=(0,W.useRef)(null);l.current=e;let c=(0,W.useCallback)(()=>{if(!xU)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let r=e.getRangeAt(0);return r.commonAncestorContainer.contains(v.current)||v.current?.contains(r.commonAncestorContainer)},[]),d=(0,W.useCallback)(e=>{u.isAtBottom=e,n(e)},[]),h=(0,W.useCallback)(e=>{u.escapedFromLock=e,s(e)},[]),u=(0,W.useMemo)(()=>{let s;return{escapedFromLock:r,isAtBottom:i,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return v.current?.scrollTop??0},set scrollTop(scrollTop){v.current&&(v.current.scrollTop=scrollTop,u.ignoreScrollToTop=v.current.scrollTop)},get targetScrollTop(){if(!v.current||!x.current)return 0;return v.current.scrollHeight-1-v.current.clientHeight},get calculatedTargetScrollTop(){if(!v.current||!x.current)return 0;let{targetScrollTop:r}=this;if(!e.targetScrollTop)return r;if(s?.targetScrollTop===r)return s.calculatedScrollTop;let i=Math.max(Math.min(e.targetScrollTop(r,{scrollElement:v.current,contentElement:x.current}),r),0);return s={targetScrollTop:r,calculatedScrollTop:i},requestAnimationFrame(()=>{s=void 0}),i},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=70}}},[]),f=(0,W.useCallback)((e={})=>{let r;"string"==typeof e&&(e={animation:e}),e.preserveScrollPosition||d(!0);let s=Date.now()+(Number(e.wait)||0),i=xY(l.current,e.animation),{ignoreEscapes:n=!1}=e,o=u.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{r=Date.now()}):r=s+(e.duration??0);let a=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!u.isAtBottom)return u.animation=void 0,!1;let{scrollTop:d}=u,h=performance.now(),p=(h-(u.lastTick??h))/xK;if(u.animation||(u.animation={behavior:i,promise:e,ignoreEscapes:n}),u.animation.behavior===i&&(u.lastTick=h),c()||s>Date.now())return a();if(d<Math.min(o,u.calculatedTargetScrollTop)){if(u.animation?.behavior===i){if("instant"===i)return u.scrollTop=u.calculatedTargetScrollTop,a();u.velocity=(i.damping*u.velocity+i.stiffness*u.scrollDifference)/i.mass,u.accumulated+=u.velocity*p,u.scrollTop+=u.accumulated,u.scrollTop!==d&&(u.accumulated=0)}return a()}return r>Date.now()?(o=u.calculatedTargetScrollTop,a()):(u.animation=void 0,u.scrollTop<u.calculatedTargetScrollTop)?f({animation:xY(l.current,l.current.resize),ignoreEscapes:n,duration:Math.max(0,r-Date.now())||void 0}):u.isAtBottom});return e.then(e=>(requestAnimationFrame(()=>{u.animation||(u.lastTick=void 0,u.velocity=0)}),e))};return(!0!==e.wait&&(u.animation=void 0),u.animation?.behavior===i)?u.animation.promise:a()},[d,c,u]),p=(0,W.useCallback)(()=>{h(!0),d(!1)},[h,d]),m=(0,W.useCallback)(({target:e})=>{if(e!==v.current)return;let{scrollTop:r,ignoreScrollToTop:s}=u,{lastScrollTop:i=r}=u;u.lastScrollTop=r,u.ignoreScrollToTop=void 0,s&&s>r&&(i=s),a(u.isNearBottom),setTimeout(()=>{if(u.resizeDifference||r===s)return;if(c()){h(!0),d(!1);return}let e=r>i,n=r<i;if(u.animation?.ignoreEscapes){u.scrollTop=i;return}n&&(h(!0),d(!1)),e&&h(!1),!u.escapedFromLock&&u.isNearBottom&&d(!0)},1)},[h,d,c,u]),g=(0,W.useCallback)(({target:e,deltaY:r})=>{let s=e;for(;!["scroll","auto"].includes(getComputedStyle(s).overflow);){if(!s.parentElement)return;s=s.parentElement}s===v.current&&r<0&&v.current.scrollHeight>v.current.clientHeight&&!u.animation?.ignoreEscapes&&(h(!0),d(!1))},[h,d,u]),v=xq(e=>{v.current?.removeEventListener("scroll",m),v.current?.removeEventListener("wheel",g),e?.addEventListener("scroll",m,{passive:!0}),e?.addEventListener("wheel",g,{passive:!0})},[]),x=xq(e=>{let r;u.resizeObserver?.disconnect(),e&&(u.resizeObserver=new ResizeObserver(([e])=>{let{height:s}=e.contentRect,i=s-(r??s);if(u.resizeDifference=i,u.scrollTop>u.targetScrollTop&&(u.scrollTop=u.targetScrollTop),a(u.isNearBottom),i>=0){let e=xY(l.current,r?l.current.resize:l.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:"instant"===e?void 0:350})}else u.isNearBottom&&(h(!1),d(!0));r=s,requestAnimationFrame(()=>{setTimeout(()=>{u.resizeDifference===i&&(u.resizeDifference=0)},1)})}),u.resizeObserver?.observe(e))},[]);return{contentRef:x,scrollRef:v,scrollToBottom:f,stopScroll:p,isAtBottom:i||o,isNearBottom:o,escapedFromLock:r,state:u}})({mass:n,damping:o,stiffness:a,resize:s,initial:i,targetScrollTop:W.useCallback((e,r)=>{let s=y?.targetScrollTop??l;return s?.(e,r)??e},[l])}),{scrollRef:f,contentRef:p,scrollToBottom:m,stopScroll:g,isAtBottom:v,escapedFromLock:x,state:_}=e??u,y=(0,W.useMemo)(()=>({scrollToBottom:m,stopScroll:g,scrollRef:f,isAtBottom:v,escapedFromLock:x,contentRef:p,state:_,get targetScrollTop(){return h.current},set targetScrollTop(targetScrollTop){h.current=targetScrollTop}}),[m,v,p,f,g,x,_]);return(0,W.useImperativeHandle)(c,()=>y,[y]),xG(()=>{f.current&&"visible"===getComputedStyle(f.current).overflow&&(f.current.style.overflow="auto")},[]),W.createElement(xX.Provider,{value:y},W.createElement("div",{...d},"function"==typeof r?r(y):r))}function xZ(){let e=(0,W.useContext)(xX);if(!e)throw Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}(xJ||(xJ={})).Content=function({children:e,scrollClassName:r,...s}){let i=xZ();return W.createElement("div",{ref:i.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:r},W.createElement("div",{...s,ref:i.contentRef},"function"==typeof e?e(i):e))};let xQ=({className:e,...r})=>(0,F.jsx)(xJ,{className:(0,iu.cn)("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...r}),x0=({className:e,...r})=>(0,F.jsx)(xJ.Content,{className:(0,iu.cn)("flex flex-col gap-8 p-4",e),...r}),x1=({className:e,...r})=>{let{isAtBottom:s,scrollToBottom:i}=xZ(),n=(0,W.useCallback)(()=>{i()},[i]);return!s&&(0,F.jsx)($.Button,{className:(0,iu.cn)("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:n,size:"icon",type:"button",variant:"outline",...r,children:(0,F.jsx)(ij,{className:"size-4"})})};var x2=/[\\\/_+.#"@\[\(\{&]/,x5=/[\\\/_+.#"@\[\(\{&]/g,x3=/[\s-]/,x4=/[\s-]/g;function x6(e){return e.toLowerCase().replace(x4," ")}var x8=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,r)=>{let s=li(`Primitive.${r}`),i=W.forwardRef((e,i)=>{let{asChild:n,...o}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,F.jsx)(n?s:r,{...o,ref:i})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{}),x7='[cmdk-group=""]',x9='[cmdk-group-items=""]',_e='[cmdk-item=""]',_t=`${_e}:not([aria-disabled="true"])`,_r="cmdk-item-select",_s="data-value",_i=(e,r,s)=>{var i;return i=e,function e(r,s,i,n,o,a,l){if(a===s.length)return o===r.length?1:.99;var c=`${o},${a}`;if(void 0!==l[c])return l[c];for(var d,h,u,f,p=n.charAt(a),m=i.indexOf(p,o),g=0;m>=0;)(d=e(r,s,i,n,m+1,a+1,l))>g&&(m===o?d*=1:x2.test(r.charAt(m-1))?(d*=.8,(u=r.slice(o,m-1).match(x5))&&o>0&&(d*=Math.pow(.999,u.length))):x3.test(r.charAt(m-1))?(d*=.9,(f=r.slice(o,m-1).match(x4))&&o>0&&(d*=Math.pow(.999,f.length))):(d*=.17,o>0&&(d*=Math.pow(.999,m-o))),r.charAt(m)!==s.charAt(a)&&(d*=.9999)),(d<.1&&i.charAt(m-1)===n.charAt(a+1)||n.charAt(a+1)===n.charAt(a)&&i.charAt(m-1)!==n.charAt(a))&&.1*(h=e(r,s,i,n,m+1,a+2,l))>d&&(d=.1*h),d>g&&(g=d),m=i.indexOf(p,m+1);return l[c]=g,g}(i=s&&s.length>0?`${i+" "+s.join(" ")}`:i,r,x6(i),x6(r),0,0,{})},_n=W.createContext(void 0),_o=W.createContext(void 0),_a=W.createContext(void 0),_l=W.forwardRef((e,r)=>{let s=_v(()=>{var r,s;return{search:"",value:null!=(s=null!=(r=e.value)?r:e.defaultValue)?s:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=_v(()=>new Set),n=_v(()=>new Map),o=_v(()=>new Map),a=_v(()=>new Set),l=_m(e),{label:c,children:d,value:h,onValueChange:u,filter:f,shouldFilter:p,loop:m,disablePointerSelection:g=!1,vimBindings:v=!0,...x}=e,_=ej(),y=ej(),b=ej(),w=W.useRef(null),S=_y();_g(()=>{if(void 0!==h){let e=h.trim();s.current.value=e,C.emit()}},[h]),_g(()=>{S(6,M)},[]);let C=W.useMemo(()=>({subscribe:e=>(a.current.add(e),()=>a.current.delete(e)),snapshot:()=>s.current,setState:(e,r,i)=>{var n,o,a,c;if(!Object.is(s.current[e],r)){if(s.current[e]=r,"search"===e)R(),N(),S(1,E);else if("value"===e){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let e=document.getElementById(b);e?e.focus():null==(n=document.getElementById(_))||n.focus()}if(S(7,()=>{var e;s.current.selectedItemId=null==(e=D())?void 0:e.id,C.emit()}),i||S(5,M),(null==(o=l.current)?void 0:o.value)!==void 0){null==(c=(a=l.current).onValueChange)||c.call(a,null!=r?r:"");return}}C.emit()}},emit:()=>{a.current.forEach(e=>e())}}),[]),k=W.useMemo(()=>({value:(e,r,i)=>{var n;r!==(null==(n=o.current.get(e))?void 0:n.value)&&(o.current.set(e,{value:r,keywords:i}),s.current.filtered.items.set(e,j(r,i)),S(2,()=>{N(),C.emit()}))},item:(e,r)=>(i.current.add(e),r&&(n.current.has(r)?n.current.get(r).add(e):n.current.set(r,new Set([e]))),S(3,()=>{R(),N(),s.current.value||E(),C.emit()}),()=>{o.current.delete(e),i.current.delete(e),s.current.filtered.items.delete(e);let r=D();S(4,()=>{R(),(null==r?void 0:r.getAttribute("id"))===e&&E(),C.emit()})}),group:e=>(n.current.has(e)||n.current.set(e,new Set),()=>{o.current.delete(e),n.current.delete(e)}),filter:()=>l.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:_,inputId:b,labelId:y,listInnerRef:w}),[]);function j(e,r){var i,n;let o=null!=(n=null==(i=l.current)?void 0:i.filter)?n:_i;return e?o(e,s.current.search,r):0}function N(){if(!s.current.search||!1===l.current.shouldFilter)return;let e=s.current.filtered.items,r=[];s.current.filtered.groups.forEach(s=>{let i=n.current.get(s),o=0;i.forEach(r=>{o=Math.max(e.get(r),o)}),r.push([s,o])});let i=w.current;T().sort((r,s)=>{var i,n;let o=r.getAttribute("id"),a=s.getAttribute("id");return(null!=(i=e.get(a))?i:0)-(null!=(n=e.get(o))?n:0)}).forEach(e=>{let r=e.closest(x9);r?r.appendChild(e.parentElement===r?e:e.closest(`${x9} > *`)):i.appendChild(e.parentElement===i?e:e.closest(`${x9} > *`))}),r.sort((e,r)=>r[1]-e[1]).forEach(e=>{var r;let s=null==(r=w.current)?void 0:r.querySelector(`${x7}[${_s}="${encodeURIComponent(e[0])}"]`);null==s||s.parentElement.appendChild(s)})}function E(){let e=T().find(e=>"true"!==e.getAttribute("aria-disabled")),r=null==e?void 0:e.getAttribute(_s);C.setState("value",r||void 0)}function R(){var e,r,a,c;if(!s.current.search||!1===l.current.shouldFilter){s.current.filtered.count=i.current.size;return}s.current.filtered.groups=new Set;let d=0;for(let n of i.current){let i=j(null!=(r=null==(e=o.current.get(n))?void 0:e.value)?r:"",null!=(c=null==(a=o.current.get(n))?void 0:a.keywords)?c:[]);s.current.filtered.items.set(n,i),i>0&&d++}for(let[e,r]of n.current)for(let i of r)if(s.current.filtered.items.get(i)>0){s.current.filtered.groups.add(e);break}s.current.filtered.count=d}function M(){var e,r,s;let i=D();i&&((null==(e=i.parentElement)?void 0:e.firstChild)===i&&(null==(s=null==(r=i.closest(x7))?void 0:r.querySelector('[cmdk-group-heading=""]'))||s.scrollIntoView({block:"nearest"})),i.scrollIntoView({block:"nearest"}))}function D(){var e;return null==(e=w.current)?void 0:e.querySelector(`${_e}[aria-selected="true"]`)}function T(){var e;return Array.from((null==(e=w.current)?void 0:e.querySelectorAll(_t))||[])}function P(e){let r=T()[e];r&&C.setState("value",r.getAttribute(_s))}function L(e){var r;let s=D(),i=T(),n=i.findIndex(e=>e===s),o=i[n+e];null!=(r=l.current)&&r.loop&&(o=n+e<0?i[i.length-1]:n+e===i.length?i[0]:i[n+e]),o&&C.setState("value",o.getAttribute(_s))}function B(e){let r=D(),s=null==r?void 0:r.closest(x7),i;for(;s&&!i;)i=null==(s=e>0?function(e,r){let s=e.nextElementSibling;for(;s;){if(s.matches(r))return s;s=s.nextElementSibling}}(s,x7):function(e,r){let s=e.previousElementSibling;for(;s;){if(s.matches(r))return s;s=s.previousElementSibling}}(s,x7))?void 0:s.querySelector(_t);i?C.setState("value",i.getAttribute(_s)):L(e)}let A=()=>P(T().length-1),O=e=>{e.preventDefault(),e.metaKey?A():e.altKey?B(1):L(1)},I=e=>{e.preventDefault(),e.metaKey?P(0):e.altKey?B(-1):L(-1)};return W.createElement(x8.div,{ref:r,tabIndex:-1,...x,"cmdk-root":"",onKeyDown:e=>{var r;null==(r=x.onKeyDown)||r.call(x,e);let s=e.nativeEvent.isComposing||229===e.keyCode;if(!(e.defaultPrevented||s))switch(e.key){case"n":case"j":v&&e.ctrlKey&&O(e);break;case"ArrowDown":O(e);break;case"p":case"k":v&&e.ctrlKey&&I(e);break;case"ArrowUp":I(e);break;case"Home":e.preventDefault(),P(0);break;case"End":e.preventDefault(),A();break;case"Enter":{e.preventDefault();let r=D();if(r){let e=new Event(_r);r.dispatchEvent(e)}}}}},W.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:_w},c),_b(e,e=>W.createElement(_o.Provider,{value:C},W.createElement(_n.Provider,{value:k},e))))}),_c=W.forwardRef((e,r)=>{var s,i;let n=ej(),o=W.useRef(null),a=W.useContext(_a),l=W.useContext(_n),c=_m(e),d=null!=(i=null==(s=c.current)?void 0:s.forceMount)?i:null==a?void 0:a.forceMount;_g(()=>{if(!d)return l.item(n,null==a?void 0:a.id)},[d]);let h=__(n,o,[e.value,e.children,o],e.keywords),u=W.useContext(_o),f=_x(e=>e.value&&e.value===h.current),p=_x(e=>!!d||!1===l.filter()||!e.search||e.filtered.items.get(n)>0);function m(){var e,r;g(),null==(r=(e=c.current).onSelect)||r.call(e,h.current)}function g(){u.setState("value",h.current,!0)}if(W.useEffect(()=>{let r=o.current;if(!(!r||e.disabled))return r.addEventListener(_r,m),()=>r.removeEventListener(_r,m)},[p,e.onSelect,e.disabled]),!p)return null;let{disabled:v,value:x,onSelect:_,forceMount:y,keywords:b,...w}=e;return W.createElement(x8.div,{ref:(0,U.composeRefs)(o,r),...w,id:n,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!f,"data-disabled":!!v,"data-selected":!!f,onPointerMove:v||l.getDisablePointerSelection()?void 0:g,onClick:v?void 0:m},e.children)}),_d=W.forwardRef((e,r)=>{let{heading:s,children:i,forceMount:n,...o}=e,a=ej(),l=W.useRef(null),c=W.useRef(null),d=ej(),h=W.useContext(_n),u=_x(e=>!!n||!1===h.filter()||!e.search||e.filtered.groups.has(a));_g(()=>h.group(a),[]),__(a,l,[e.value,e.heading,c]);let f=W.useMemo(()=>({id:a,forceMount:n}),[n]);return W.createElement(x8.div,{ref:(0,U.composeRefs)(l,r),...o,"cmdk-group":"",role:"presentation",hidden:!u||void 0},s&&W.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},s),_b(e,e=>W.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":s?d:void 0},W.createElement(_a.Provider,{value:f},e))))}),_h=W.forwardRef((e,r)=>{let{alwaysRender:s,...i}=e,n=W.useRef(null),o=_x(e=>!e.search);return s||o?W.createElement(x8.div,{ref:(0,U.composeRefs)(n,r),...i,"cmdk-separator":"",role:"separator"}):null}),_u=W.forwardRef((e,r)=>{let{onValueChange:s,...i}=e,n=null!=e.value,o=W.useContext(_o),a=_x(e=>e.search),l=_x(e=>e.selectedItemId),c=W.useContext(_n);return W.useEffect(()=>{null!=e.value&&o.setState("search",e.value)},[e.value]),W.createElement(x8.input,{ref:r,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:n?e.value:a,onChange:e=>{n||o.setState("search",e.target.value),null==s||s(e.target.value)}})}),_f=W.forwardRef((e,r)=>{let{children:s,label:i="Suggestions",...n}=e,o=W.useRef(null),a=W.useRef(null),l=_x(e=>e.selectedItemId),c=W.useContext(_n);return W.useEffect(()=>{if(a.current&&o.current){let e=a.current,r=o.current,s,i=new ResizeObserver(()=>{s=requestAnimationFrame(()=>{let s=e.offsetHeight;r.style.setProperty("--cmdk-list-height",s.toFixed(1)+"px")})});return i.observe(e),()=>{cancelAnimationFrame(s),i.unobserve(e)}}},[]),W.createElement(x8.div,{ref:(0,U.composeRefs)(o,r),...n,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":i,id:c.listId},_b(e,e=>W.createElement("div",{ref:(0,U.composeRefs)(a,c.listInnerRef),"cmdk-list-sizer":""},e)))}),_p=W.forwardRef((e,r)=>{let{open:s,onOpenChange:i,overlayClassName:n,contentClassName:o,container:a,...l}=e;return W.createElement(iz,{open:s,onOpenChange:i},W.createElement(iK,{container:a},W.createElement(iq,{"cmdk-overlay":"",className:n}),W.createElement(iG,{"aria-label":e.label,"cmdk-dialog":"",className:o},W.createElement(_l,{ref:r,...l}))))});function _m(e){let r=W.useRef(e);return _g(()=>{r.current=e}),r}Object.assign(_l,{List:_f,Item:_c,Input:_u,Group:_d,Separator:_h,Dialog:_p,Empty:W.forwardRef((e,r)=>_x(e=>0===e.filtered.count)?W.createElement(x8.div,{ref:r,...e,"cmdk-empty":"",role:"presentation"}):null),Loading:W.forwardRef((e,r)=>{let{progress:s,children:i,label:n="Loading...",...o}=e;return W.createElement(x8.div,{ref:r,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n},_b(e,e=>W.createElement("div",{"aria-hidden":!0},e)))})});var _g="undefined"==typeof window?W.useEffect:W.useLayoutEffect;function _v(e){let r=W.useRef();return void 0===r.current&&(r.current=e()),r}function _x(e){let r=W.useContext(_o),s=()=>e(r.snapshot());return W.useSyncExternalStore(r.subscribe,s,s)}function __(e,r,s,i=[]){let n=W.useRef(),o=W.useContext(_n);return _g(()=>{var a;let l=(()=>{var e;for(let r of s){if("string"==typeof r)return r.trim();if("object"==typeof r&&"current"in r)return r.current?null==(e=r.current.textContent)?void 0:e.trim():n.current}})(),c=i.map(e=>e.trim());o.value(e,l,c),null==(a=r.current)||a.setAttribute(_s,l),n.current=l}),n}var _y=()=>{let[e,r]=W.useState(),s=_v(()=>new Map);return _g(()=>{s.current.forEach(e=>e()),s.current=new Map},[e]),(e,i)=>{s.current.set(e,i),r({})}};function _b({asChild:e,children:r},s){let i;return e&&W.isValidElement(r)?W.cloneElement("function"==typeof(i=r.type)?i(r.props):"render"in i?i.render(r.props):r,{ref:r.ref},s(r.props.children)):s(r)}var _w={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"},_S="HoverCard",[_C,_k]=q(_S,[tK]),_j=tK(),[_N,_E]=_C(_S),_R=e=>{let{__scopeHoverCard:r,children:s,open:i,defaultOpen:n,onOpenChange:o,openDelay:a=700,closeDelay:l=300}=e,c=_j(r),d=W.useRef(0),h=W.useRef(0),u=W.useRef(!1),f=W.useRef(!1),[p,m]=X({prop:i,defaultProp:n??!1,onChange:o,caller:_S}),g=W.useCallback(()=>{clearTimeout(h.current),d.current=window.setTimeout(()=>m(!0),a)},[a,m]),v=W.useCallback(()=>{clearTimeout(d.current),u.current||f.current||(h.current=window.setTimeout(()=>m(!1),l))},[l,m]),x=W.useCallback(()=>m(!1),[m]);return W.useEffect(()=>()=>{clearTimeout(d.current),clearTimeout(h.current)},[]),(0,F.jsx)(_N,{scope:r,open:p,onOpenChange:m,onOpen:g,onClose:v,onDismiss:x,hasSelectionRef:u,isPointerDownOnContentRef:f,children:(0,F.jsx)(tV,{...c,children:s})})};_R.displayName=_S;var _M="HoverCardTrigger",_D=W.forwardRef((e,r)=>{let{__scopeHoverCard:s,...i}=e,n=_E(_M,s),o=_j(s);return(0,F.jsx)(tX,{asChild:!0,...o,children:(0,F.jsx)(Z.a,{"data-state":n.open?"open":"closed",...i,ref:r,onPointerEnter:K(e.onPointerEnter,_z(n.onOpen)),onPointerLeave:K(e.onPointerLeave,_z(n.onClose)),onFocus:K(e.onFocus,n.onOpen),onBlur:K(e.onBlur,n.onClose),onTouchStart:K(e.onTouchStart,e=>e.preventDefault())})})});_D.displayName=_M;var _T="HoverCardPortal",[_P,_L]=_C(_T,{forceMount:void 0}),_B=e=>{let{__scopeHoverCard:r,forceMount:s,children:i,container:n}=e,o=_E(_T,r);return(0,F.jsx)(_P,{scope:r,forceMount:s,children:(0,F.jsx)(t8,{present:s||o.open,children:(0,F.jsx)(t6,{asChild:!0,container:n,children:i})})})};_B.displayName=_T;var _A="HoverCardContent",_O=W.forwardRef((e,r)=>{let s=_L(_A,e.__scopeHoverCard),{forceMount:i=s.forceMount,...n}=e,o=_E(_A,e.__scopeHoverCard);return(0,F.jsx)(t8,{present:i||o.open,children:(0,F.jsx)(_I,{"data-state":o.open?"open":"closed",...n,onPointerEnter:K(e.onPointerEnter,_z(o.onOpen)),onPointerLeave:K(e.onPointerLeave,_z(o.onClose)),ref:r})})});_O.displayName=_A;var _I=W.forwardRef((e,r)=>{let{__scopeHoverCard:s,onEscapeKeyDown:i,onPointerDownOutside:n,onFocusOutside:o,onInteractOutside:a,...l}=e,c=_E(_A,s),d=_j(s),h=W.useRef(null),u=(0,U.useComposedRefs)(r,h),[f,p]=W.useState(!1);return W.useEffect(()=>{if(f){let e=document.body;return z=e.style.userSelect||e.style.webkitUserSelect,e.style.userSelect="none",e.style.webkitUserSelect="none",()=>{e.style.userSelect=z,e.style.webkitUserSelect=z}}},[f]),W.useEffect(()=>{if(h.current){let e=()=>{p(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(c.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",e),()=>{document.removeEventListener("pointerup",e),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),W.useEffect(()=>{h.current&&(function(e){let r=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;s.nextNode();)r.push(s.currentNode);return r})(h.current).forEach(e=>e.setAttribute("tabindex","-1"))}),(0,F.jsx)(ec,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:a,onEscapeKeyDown:i,onPointerDownOutside:n,onFocusOutside:K(o,e=>{e.preventDefault()}),onDismiss:c.onDismiss,children:(0,F.jsx)(tQ,{...d,...l,onPointerDown:K(l.onPointerDown,e=>{e.currentTarget.contains(e.target)&&p(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:u,style:{...l.style,userSelect:f?"text":void 0,WebkitUserSelect:f?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})});function _z(e){return r=>"touch"===r.pointerType?void 0:e()}function _F({...e}){return(0,F.jsx)(_R,{"data-slot":"hover-card",...e})}function _W({...e}){return(0,F.jsx)(_D,{"data-slot":"hover-card-trigger",...e})}function _H({className:e,align:r="center",sideOffset:s=4,...i}){return(0,F.jsx)(_B,{"data-slot":"hover-card-portal",children:(0,F.jsx)(_O,{"data-slot":"hover-card-content",align:r,sideOffset:s,className:(0,iu.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...i})})}function _$({className:e,...r}){return(0,F.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,iu.cn)("group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none","h-9 min-w-0 has-[textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",e),...r})}W.forwardRef((e,r)=>{let{__scopeHoverCard:s,...i}=e,n=_j(s);return(0,F.jsx)(t2,{...n,...i,ref:r})}).displayName="HoverCardArrow";let _K=(0,ll.cva)("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5","block-end":"order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function _U({className:e,align:r="inline-start",...s}){return(0,F.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:(0,iu.cn)(_K({align:r}),e),onClick:e=>{e.target.closest("button")||e.currentTarget.parentElement?.querySelector("input")?.focus()},...s})}let _q=(0,ll.cva)("text-sm shadow-none flex gap-2 items-center",{variants:{size:{xs:"h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",sm:"h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function _V({className:e,type:r="button",variant:s="ghost",size:i="xs",...n}){return(0,F.jsx)($.Button,{type:r,"data-size":i,variant:s,className:(0,iu.cn)(_q({size:i}),e),...n})}function _Y({className:e,...r}){return(0,F.jsx)(nu,{"data-slot":"input-group-control",className:(0,iu.cn)("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",e),...r})}let _X=(0,ic.default)("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]),_G=(0,ic.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);(0,ic.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);let _J=(0,ic.default)("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),_Z=(e=21)=>{let r="",s=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)r+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&s[e]];return r},_Q=(0,W.createContext)(null),_0=(0,W.createContext)(null),_1=()=>(0,W.useContext)(_Q),_2=(0,W.createContext)(null),_5=()=>{let e=(0,W.useContext)(_0),r=(0,W.useContext)(_2),s=e??r;if(!s)throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return s};function _3({data:e,className:r,...s}){let i=_5(),n=e.filename||"",o="image"==(e.mediaType?.startsWith("image/")&&e.url?"image":"file"),a=n||(o?"Image":"Attachment");return(0,F.jsxs)(yo,{children:[(0,F.jsx)(_W,{asChild:!0,children:(0,F.jsxs)("div",{className:(0,iu.cn)("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",r),...s,children:[(0,F.jsxs)("div",{className:"relative size-5 shrink-0",children:[(0,F.jsx)("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:o?(0,F.jsx)("img",{alt:n||"attachment",className:"size-5 object-cover",height:20,src:e.url,width:20}):(0,F.jsx)("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:(0,F.jsx)(_J,{className:"size-3"})})}),(0,F.jsxs)($.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:r=>{r.stopPropagation(),i.remove(e.id)},type:"button",variant:"ghost",children:[(0,F.jsx)(nr,{}),(0,F.jsx)("span",{className:"sr-only",children:"Remove"})]})]}),(0,F.jsx)("span",{className:"flex-1 truncate",children:a})]},e.id)}),(0,F.jsx)(ya,{className:"w-auto p-2",children:(0,F.jsxs)("div",{className:"w-auto space-y-3",children:[o&&(0,F.jsx)("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:(0,F.jsx)("img",{alt:n||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:e.url,width:448})}),(0,F.jsx)("div",{className:"flex items-center gap-2.5",children:(0,F.jsxs)("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[(0,F.jsx)("h4",{className:"truncate font-semibold text-sm leading-none",children:n||(o?"Image":"Attachment")}),e.mediaType&&(0,F.jsx)("p",{className:"truncate font-mono text-muted-foreground text-xs",children:e.mediaType})]})})]})})]})}function _4({children:e,className:r,...s}){let i=_5();return i.files.length?(0,F.jsx)("div",{className:(0,iu.cn)("flex flex-wrap items-center gap-2 p-3 w-full",r),...s,children:i.files.map(r=>(0,F.jsx)(W.Fragment,{children:e(r)},r.id))}):null}let _6=({label:e="Add photos or files",...r})=>{let s=_5();return(0,F.jsxs)(iv,{...r,onSelect:e=>{e.preventDefault(),s.openFileDialog()},children:[(0,F.jsx)(_G,{className:"mr-2 size-4"})," ",e]})},_8=({className:e,accept:r,multiple:s,globalDrop:i,syncHiddenInput:n,maxFiles:o,maxFileSize:a,onError:l,onSubmit:c,children:d,...h})=>{let u=_1(),f=!!u,p=(0,W.useRef)(null),m=(0,W.useRef)(null),[g,v]=(0,W.useState)([]),x=f?u.attachments.files:g,_=(0,W.useRef)(x);_.current=x;let y=(0,W.useCallback)(()=>{p.current?.click()},[]),b=(0,W.useCallback)(e=>!r||""===r.trim()||r.split(",").map(e=>e.trim()).filter(Boolean).some(r=>{if(r.endsWith("/*")){let s=r.slice(0,-1);return e.type.startsWith(s)}return e.type===r}),[r]),w=(0,W.useCallback)(e=>{let r=Array.from(e),s=r.filter(e=>b(e));if(r.length&&0===s.length)return void l?.({code:"accept",message:"No files match the accepted types."});let i=s.filter(e=>!a||e.size<=a);s.length>0&&0===i.length?l?.({code:"max_file_size",message:"All files exceed the maximum size."}):v(e=>{let r="number"==typeof o?Math.max(0,o-e.length):void 0,s="number"==typeof r?i.slice(0,r):i;"number"==typeof r&&i.length>r&&l?.({code:"max_files",message:"Too many files. Some were not added."});let n=[];for(let e of s)n.push({id:_Z(),type:"file",url:URL.createObjectURL(e),mediaType:e.type,filename:e.name});return e.concat(n)})},[b,o,a,l]),S=(0,W.useCallback)(e=>v(r=>{let s=r.find(r=>r.id===e);return s?.url&&URL.revokeObjectURL(s.url),r.filter(r=>r.id!==e)}),[]),C=(0,W.useCallback)(()=>v(e=>{for(let r of e)r.url&&URL.revokeObjectURL(r.url);return[]}),[]),k=f?u.attachments.add:w,j=f?u.attachments.remove:S,N=f?u.attachments.clear:C,E=f?u.attachments.openFileDialog:y;(0,W.useEffect)(()=>{f&&u.__registerFileInput(p,()=>p.current?.click())},[f,u]),(0,W.useEffect)(()=>{n&&p.current&&0===x.length&&(p.current.value="")},[x,n]),(0,W.useEffect)(()=>{let e=m.current;if(!e||i)return;let r=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},s=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&k(e.dataTransfer.files)};return e.addEventListener("dragover",r),e.addEventListener("drop",s),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",s)}},[k,i]),(0,W.useEffect)(()=>{if(!i)return;let e=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},r=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&k(e.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",r),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",r)}},[k,i]),(0,W.useEffect)(()=>()=>{if(!f)for(let e of _.current)e.url&&URL.revokeObjectURL(e.url)},[f]);let R=async e=>{try{let r=await fetch(e),s=await r.blob();return new Promise(e=>{let r=new FileReader;r.onloadend=()=>e(r.result),r.onerror=()=>e(null),r.readAsDataURL(s)})}catch{return null}},M=(0,W.useMemo)(()=>({files:x.map(e=>({...e,id:e.id})),add:k,remove:j,clear:N,openFileDialog:E,fileInputRef:p}),[x,k,j,N,E]),D=(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("input",{accept:r,"aria-label":"Upload files",className:"hidden",multiple:s,onChange:e=>{e.currentTarget.files&&k(e.currentTarget.files),e.currentTarget.value=""},ref:p,title:"Upload files",type:"file"}),(0,F.jsx)("form",{className:(0,iu.cn)("w-full",e),onSubmit:e=>{e.preventDefault();let r=e.currentTarget,s=f?u.textInput.value:new FormData(r).get("message")||"";f||r.reset(),Promise.all(x.map(async({id:e,...r})=>{if(r.url&&r.url.startsWith("blob:")){let e=await R(r.url);return{...r,url:e??r.url}}return r})).then(r=>{try{let i=c({text:s,files:r},e);i instanceof Promise?i.then(()=>{N(),f&&u.textInput.clear()}).catch(()=>{}):(N(),f&&u.textInput.clear())}catch{}}).catch(()=>{})},ref:m,...h,children:(0,F.jsx)(_$,{className:"overflow-hidden",children:d})})]});return f?D:(0,F.jsx)(_2.Provider,{value:M,children:D})},_7=({onChange:e,onKeyDown:r,className:s,placeholder:i="What would you like to know?",...n})=>{let o=_1(),a=_5(),[l,c]=(0,W.useState)(!1),d=o?{value:o.textInput.value,onChange:r=>{o.textInput.setInput(r.currentTarget.value),e?.(r)}}:{onChange:e};return(0,F.jsx)(_Y,{className:(0,iu.cn)("field-sizing-content max-h-48 min-h-9",s),name:"message",onCompositionEnd:()=>c(!1),onCompositionStart:()=>c(!0),onKeyDown:e=>{if(r?.(e),!e.defaultPrevented){if("Enter"===e.key){if(l||e.nativeEvent.isComposing||e.shiftKey)return;e.preventDefault();let r=e.currentTarget.form,s=r?.querySelector('button[type="submit"]');if(s?.disabled)return;r?.requestSubmit()}if("Backspace"===e.key&&""===e.currentTarget.value&&a.files.length>0){e.preventDefault();let r=a.files.at(-1);r&&a.remove(r.id)}}},onPaste:e=>{let r=e.clipboardData?.items;if(!r)return;let s=[];for(let e of r)if("file"===e.kind){let r=e.getAsFile();r&&s.push(r)}s.length>0&&(e.preventDefault(),a.add(s))},placeholder:i,...n,...d})},_9=({className:e,...r})=>(0,F.jsx)(_U,{align:"block-end",className:(0,iu.cn)("order-first flex-wrap gap-1",e),...r}),ye=({variant:e="ghost",className:r,size:s,...i})=>{let n=s??(W.Children.count(i.children)>1?"sm":"icon-sm");return(0,F.jsx)(_V,{className:(0,iu.cn)(r),size:n,type:"button",variant:e,...i})},yt=e=>(0,F.jsx)(ip,{...e}),yr=({className:e,children:r,...s})=>(0,F.jsx)(im,{asChild:!0,children:(0,F.jsx)(ye,{className:e,...s,children:r??(0,F.jsx)(nD,{className:"size-4"})})}),ys=({className:e,...r})=>(0,F.jsx)(ig,{align:"start",className:(0,iu.cn)(e),...r}),yi=({className:e,...r})=>(0,F.jsx)(iv,{className:(0,iu.cn)(e),...r}),yn=({className:e,variant:r="default",size:s="icon-sm",status:i,children:n,...o})=>{let a=(0,F.jsx)(_X,{className:"size-4"});return"submitted"===i?a=(0,F.jsx)(iD,{className:"size-4 animate-spin"}):"streaming"===i?a=(0,F.jsx)(lh,{className:"size-4"}):"error"===i&&(a=(0,F.jsx)(nr,{className:"size-4"})),(0,F.jsx)(_V,{"aria-label":"Submit",className:(0,iu.cn)(e),size:s,type:"submit",variant:r,...o,children:n??a})},yo=({openDelay:e=0,closeDelay:r=0,...s})=>(0,F.jsx)(_F,{closeDelay:r,openDelay:e,...s}),ya=({align:e="start",...r})=>(0,F.jsx)(_H,{align:e,...r}),yl=({size:e=16})=>(0,F.jsxs)("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:[(0,F.jsx)("title",{children:"Loader"}),(0,F.jsxs)("g",{clipPath:"url(#clip0_2393_1490)",children:[(0,F.jsx)("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),(0,F.jsx)("defs",{children:(0,F.jsx)("clipPath",{id:"clip0_2393_1490",children:(0,F.jsx)("rect",{fill:"white",height:"16",width:"16"})})})]}),yc=({className:e,size:r=16,...s})=>(0,F.jsx)("div",{className:(0,iu.cn)("inline-flex animate-spin items-center justify-center",e),...s,children:(0,F.jsx)(yl,{size:r})}),yd=(0,ic.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),yh=(0,ic.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),yu=(0,ic.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),yf=(0,ic.default)("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);function yp({mode:e,onModeChange:r,disabled:s}){return(0,F.jsxs)("div",{className:"inline-flex items-center rounded-md border bg-muted/50 p-0.5 text-xs",children:[(0,F.jsxs)("button",{onClick:()=>r("plan"),disabled:s,className:(0,iu.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","plan"===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground",s&&"opacity-50 cursor-not-allowed"),children:[(0,F.jsx)(yf,{className:"h-3 w-3"}),"Plan"]}),(0,F.jsxs)("button",{onClick:()=>r("edit"),disabled:s,className:(0,iu.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","edit"===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground",s&&"opacity-50 cursor-not-allowed"),children:[(0,F.jsx)(iC,{className:"h-3 w-3"}),"Edit"]})]})}function ym(e){let r=e.parentElement;for(;r;){let{overflowY:e}=getComputedStyle(r);if("auto"===e||"scroll"===e)return r;r=r.parentElement}return null}function yg({messages:e,contentRef:r}){let[s,i]=(0,W.useState)([]),[n,o]=(0,W.useState)(!1),[a,l]=(0,W.useState)(null),c=(0,W.useRef)(null),d=(0,W.useCallback)(()=>{let s=r.current;if(!s)return;c.current||(c.current=ym(s));let n=c.current;if(!n)return;let a=n.scrollHeight>n.clientHeight;if(o(a),!a)return void i([]);let l=s.querySelectorAll("[data-user-msg-idx]"),d=n.getBoundingClientRect(),h=[];l.forEach(r=>{let s=parseInt(r.dataset.userMsgIdx,10),i=(r.getBoundingClientRect().top-d.top+n.scrollTop)/n.scrollHeight;h.push({index:s,position:Math.max(0,Math.min(1,i)),preview:function(e){if("user"!==e.type)return"";let r=e.content,s="string"==typeof r?r:r.filter(e=>"text"===e.type).map(e=>e.text).join(" "),i="string"!=typeof r&&r.some(e=>"image"===e.type),n=s.split("\n")[0]??"";return(n.length>80?n.slice(0,77)+"...":n)||(i?"(Image)":"")}(e[s])})}),i(h)},[e,r]);(0,W.useEffect)(()=>{let e=r.current;if(!e)return;let s=ym(e);if(!s)return;c.current=s,d();let i=new ResizeObserver(d);return i.observe(s),i.observe(e),()=>{i.disconnect()}},[e,d,r]);let h=(0,W.useCallback)(e=>{let s=r.current;if(!s)return;let i=s.querySelector(`[data-user-msg-idx="${e}"]`);i&&i.scrollIntoView({block:"start",behavior:"smooth"})},[r]);return n&&0!==s.length?(0,F.jsx)("div",{className:"absolute right-0 top-0 bottom-0 w-5 z-20 pointer-events-none",children:s.map(e=>(0,F.jsxs)("div",{className:"absolute right-0.5 -translate-y-1/2 pointer-events-auto",style:{top:`${100*e.position}%`},children:[(0,F.jsx)("div",{className:"w-3 h-[3px] rounded-sm bg-primary/50 hover:bg-primary cursor-pointer transition-colors",onClick:()=>h(e.index),onMouseEnter:()=>l(e.index),onMouseLeave:()=>l(null)}),a===e.index&&e.preview&&(0,F.jsxs)("div",{className:"absolute right-full mr-2 top-1/2 -translate-y-1/2 max-w-64 px-2.5 py-1.5 bg-popover border border-border rounded-md shadow-md text-xs text-popover-foreground whitespace-nowrap overflow-hidden text-ellipsis pointer-events-none",children:[e.preview,(0,F.jsx)("div",{className:"absolute top-1/2 -translate-y-1/2 -right-1 w-2 h-2 bg-popover border-r border-t border-border rotate-45"})]})]},e.index))}):null}function yv(){return 0===_5().files.length?null:(0,F.jsx)(_9,{children:(0,F.jsx)(_4,{children:e=>(0,F.jsx)(_3,{data:e})})})}let yx=(0,W.createContext)(null);function y_(){let e=(0,W.useContext)(yx);if(!e)throw Error("useAgentConversation must be used within AgentConversationContext");return e}let yy=(0,W.forwardRef)(function({projectId:e,branch:r,project:s,onAgentModeChange:i,onTaskCompleted:n,onSessionStarted:o,onStatusChange:a},l){let c,d,h,u,f,p,m,[g,v]=(0,W.useState)(""),[x,_]=(0,W.useState)("edit"),[y,b]=(0,W.useState)(!1),[w,S]=(0,W.useState)(!1),[C,k]=(0,W.useState)("claude-code"),[j,N]=(0,W.useState)([]),E=(0,W.useRef)(null),R=(f=(0,W.useRef)([]),p=(0,W.useRef)(-1),m=(0,W.useRef)(""),{push:(0,W.useCallback)(e=>{let r=e.trim();if(!r)return;let s=f.current;if(s.length>0&&s[s.length-1]===r){p.current=-1;return}s.push(r),s.length>50&&s.shift(),p.current=-1},[]),handleKeyDown:(0,W.useCallback)(e=>{let r=e.currentTarget,s=f.current;if(0!==s.length)if("ArrowUp"===e.key){if(0!==r.selectionStart||0!==r.selectionEnd)return;if(e.preventDefault(),-1===p.current)m.current=r.value,p.current=s.length-1;else{if(!(p.current>0))return;p.current--}v(s[p.current])}else if("ArrowDown"===e.key){if(-1===p.current)return;let i=r.value.length;if(r.selectionStart!==i||r.selectionEnd!==i)return;e.preventDefault(),p.current<s.length-1?(p.current++,v(s[p.current])):(p.current=-1,v(m.current))}else -1!==p.current&&(p.current=-1)},[v])}),{remotes:M}=iP(s?.id??void 0),D=[];for(let e of(s?.path&&D.push({id:"local",label:"Local",icon:nA.Monitor}),M))D.push({id:e.remote_server_id,label:e.server_name,icon:nO});let{session:T,messages:P,status:L,isConnected:B,isInitialized:A,isLoading:O,error:I,remoteStatus:z,startSession:H,sendMessage:K,stopSession:U,restartSession:q,switchMode:V,acceptPlan:Y}=function(e,r,s,i,n){let[o,a]=(0,W.useState)(null),[l,c]=(0,W.useState)([]),[d,h]=(0,W.useState)("stopped"),[u,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),[g,v]=(0,W.useState)(!1),[x,_]=(0,W.useState)(null),[y,b]=(0,W.useState)(null),w=(0,W.useRef)(null),S=(0,W.useRef)(null),C=(0,W.useRef)(null),k=(0,W.useRef)(0),j=(0,W.useRef)({entries:[],status:"stopped"}),N=(0,W.useRef)(!1),E=(0,W.useRef)(!0),R=(0,W.useRef)(null),M=(0,W.useRef)(null),D=(0,W.useRef)(0),T=(0,W.useRef)(!1),P=(0,W.useRef)(0),L=(0,W.useRef)(!1),B=(0,W.useRef)(!1),A=(0,W.useRef)(n?.onTaskCompleted),O=(0,W.useRef)(n?.onSessionStarted);(0,W.useEffect)(()=>{A.current=n?.onTaskCompleted,O.current=n?.onSessionStarted});let I=(0,W.useCallback)(s=>{if(w.current&&S.current!==s&&(console.log(`[AgentSession] Closing stale WS for ${S.current}, switching to ${s}`),w.current.close(1e3,"session-switch"),w.current=null,S.current=null),w.current?.readyState===WebSocket.OPEN||w.current?.readyState===WebSocket.CONNECTING)return;0===j.current.entries.filter(Boolean).length&&(j.current={entries:[],status:"running"}),N.current=!1,T.current=!0;let i=(0,iT.getWebSocketUrl)(`/api/agent-sessions/${s}/stream`);console.log("[AgentSession] Connecting to WebSocket:",i);let n=new WebSocket(i);w.current=n,S.current=s,n.onopen=()=>{console.log("[AgentSession] WebSocket connected"),f(!0),_(null),b(null),R.current=Date.now(),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{console.log("[AgentSession] Connection stable, resetting backoff counter"),k.current=0,D.current=0},5e3)},n.onmessage=s=>{try{let o=JSON.parse(s.data);if("JsonPatch"in o){var i;let s=o.JsonPatch;i=j.current,j.current=vx(i,e=>{for(let r of s){let{op:s,path:i,value:n}=r;if("/entries"===i&&"replace"===s&&n?.type==="ENTRY"&&n.content?.type==="system"&&n.content?.content==="__CLEAR_ALL__"){console.log("[JsonPatch] Received clearAll signal - clearing all entries"),e.entries=[];continue}if(i.startsWith("/entries/")){let r=parseInt(i.replace("/entries/",""),10);if(isNaN(r)){console.warn(`[JsonPatch] Invalid index in path: ${i}`);continue}if(n?.type!=="ENTRY"){console.warn("[JsonPatch] Expected ENTRY type for entries path");continue}switch(s){case"add":for(;e.entries.length<=r;)e.entries.push(null);e.entries[r]=n.content;break;case"replace":r<e.entries.length?e.entries[r]=n.content:console.warn(`[JsonPatch] Replace index out of bounds: ${r}`);break;case"remove":r<e.entries.length&&e.entries.splice(r,1)}}else"/status"===i&&n?.type==="STATUS"&&(e.status=n.content)}}),!T.current&&(c([...j.current.entries.filter(Boolean)]),h(j.current.status),("stopped"===j.current.status||"error"===j.current.status)&&e&&vE.delete(vR(e,r)));return}if("Ready"in o){console.log("[AgentSession] Received Ready signal - history complete"),T.current=!1,c([...j.current.entries.filter(Boolean)]),h(j.current.status),m(!0);return}if("finished"in o){console.log("[AgentSession] Received finished signal, invalidating cache"),N.current=!0,e&&vE.delete(vR(e,r)),n.close(1e3,"finished");return}if("taskCompleted"in o){let{duration_ms:e,cost_usd:r,input_tokens:s,output_tokens:i}=o.taskCompleted,n=[];if(null!=e){let r=(e/1e3).toFixed(1);n.push(`${r}s`)}if(null!=r)n.push(`$${r.toFixed(4)}`);else if(null!=s||null!=i){let e=(s??0)+(i??0),r=e>1e3?`${(e/1e3).toFixed(1)}K`:String(e);n.push(`${r} tokens`)}v_.toast.success("Task completed",{description:n.length>0?n.join(" · "):void 0}),A.current?.();return}if("remoteStatus"in o)return void b(o.remoteStatus);if("error"in o){console.error("[AgentSession] Server error:",o.error),_(o.error),"Session not found"===o.error&&(console.log("[AgentSession] Session invalid, invalidating cache, will create new session"),e&&vE.delete(vR(e,r)),N.current=!0,a(null),h("stopped"),m(!1),E.current=!0);return}}catch(e){console.error("[AgentSession] Failed to parse message:",e)}},n.onclose=s=>{let i,n;console.log("[AgentSession] WebSocket disconnected",s.code,s.reason),f(!1),M.current&&(clearTimeout(M.current),M.current=null);let o=R.current?Date.now()-R.current:0;if(R.current=null,o>0&&o<5e3){if(D.current++,console.log(`[AgentSession] Short-lived connection (${o}ms), count: ${D.current}, backoff attempt: ${k.current}`),D.current>=3){if(console.log("[AgentSession] Multiple short-lived connections detected, session likely invalid - will recreate"),L.current){console.log("[AgentSession] Skipping auto-restart: last session creation failed"),_("Unable to connect to remote server. Please check the server configuration.");return}e&&vE.delete(vR(e,r)),a(null),_(null),k.current=0,D.current=0,E.current=!0;return}}else o>=5e3&&(D.current=0);if(N.current||1e3===s.code)return;if(k.current>=10){console.log("[AgentSession] Max reconnect attempts reached"),_("Unable to connect to server. Please check if the backend is running.");return}let l=(n=(i=Math.min(3e4,1e3*Math.pow(2,k.current)))*Math.random()*.25,i+n);console.log(`[AgentSession] Reconnecting in ${Math.round(l)}ms (attempt ${k.current+1})`),k.current++,C.current=setTimeout(()=>{let e=S.current;e&&!N.current&&I(e)},l)},n.onerror=e=>{console.error("[AgentSession] WebSocket error:",e)}},[]),z=(0,W.useCallback)(async s=>{if(!e)return null;if(B.current)return console.log("[AgentSession] startSession already in progress, skipping"),null;B.current=!0;let n=P.current;_(null),b(null),m(!1),L.current=!1;let o=vR(e,r),l=vE.get(o);if(l)return console.log(`[AgentSession] Cache hit for ${o}, reconnecting WebSocket directly`),a(l),h(l.status),I(l.id),O.current?.(),B.current=!1,l;v(!0);try{console.log(`[AgentSession] Starting REST call: projectId=${e}, branch=${r}, agentType=${i}, generation=${n}`);let{session:l,messages:d}=await vw(e,r,s,i);if(console.log(`[AgentSession] REST response: sessionId=${l.id}, msgCount=${d?.length??0}`),P.current!==n)return console.log("[AgentSession] Discarding stale session response (generation mismatch)"),null;return vE.set(o,l),a(l),h(l.status),d&&d.length>0&&(c(d),j.current={entries:[...d],status:l.status}),I(l.id),O.current?.(),l}catch(e){if(console.error("[AgentSession] startSession error:",e),P.current!==n)return console.log("[AgentSession] Discarding error (generation mismatch)"),null;return _(e instanceof Error?e.message:"Failed to start session"),L.current=!0,null}finally{B.current=!1,P.current===n&&v(!1)}},[e,r,i,I]),F=(0,W.useCallback)(async(s,i)=>{let n=i||o?.id;if(!n)return void console.warn("[AgentSession] sendMessage: no session ID available (sessionId param:",i,", session?.id:",o?.id,")");if(("string"!=typeof s||s.trim())&&(!Array.isArray(s)||0!==s.length)){console.log(`[AgentSession] sendMessage: targetSessionId=${n}, source=${i?"explicit":"state"}`);try{let e="string"==typeof s?s.trim():s;await vS(n,e)}catch(i){let s=i instanceof Error?i.message:"Failed to send message";console.error("[AgentSession] Failed to send message:",s),s.includes("[404]")&&(e&&vE.delete(vR(e,r)),a(null),h("stopped"),m(!1),E.current=!0),_(s),v_.toast.error("Failed to send message",{description:s})}}},[o?.id]),H=(0,W.useCallback)(async()=>{if(o?.id)try{await vk(o.id)}catch(e){e instanceof Error&&e.message,console.error("[AgentSession] Failed to stop session:",e),v_.toast.error("Failed to stop session")}},[o?.id]),$=(0,W.useCallback)(async s=>{if(o?.id){e&&vE.delete(vR(e,r)),v(!0),_(null);try{await vC(o.id,s),s&&a(e=>e?{...e,agentType:s}:null)}catch(e){_(e instanceof Error?e.message:"Failed to restart session"),console.error("[AgentSession] Failed to restart session:",e)}finally{v(!1)}}},[o?.id]),K=(0,W.useCallback)(async s=>{if(o?.id){_(null);try{await vj(o.id,s),a(i=>{if(!i)return i;let n={...i,permissionMode:s};return e&&vE.set(vR(e,r),n),n})}catch(e){_(e instanceof Error?e.message:"Failed to switch mode"),console.error("[AgentSession] Failed to switch mode:",e)}}},[o?.id,e,r]),U=(0,W.useCallback)(async s=>{if(o?.id){_(null);try{await vN(o.id,s),a(s=>{if(!s)return s;let i={...s,permissionMode:"edit"};return e&&vE.set(vR(e,r),i),i})}catch(e){_(e instanceof Error?e.message:"Failed to accept plan"),console.error("[AgentSession] Failed to accept plan:",e)}}},[o?.id,e,r]);return(0,W.useEffect)(()=>()=>{w.current&&(N.current=!0,w.current.close(),S.current=null),C.current&&clearTimeout(C.current),M.current&&clearTimeout(M.current)},[]),(0,W.useEffect)(()=>{w.current&&(w.current.close(1e3,"branch-switch"),w.current=null,S.current=null),C.current&&(clearTimeout(C.current),C.current=null),M.current&&(clearTimeout(M.current),M.current=null),P.current+=1,a(null),h("stopped"),f(!1),m(!1),_(null),v(!1),b(null),c([]),j.current={entries:[],status:"stopped"},N.current=!1,k.current=0,R.current=null,D.current=0,L.current=!1,B.current=!1,E.current=!0,e&&vE.delete(vR(e,r))},[e,r,s]),(0,W.useEffect)(()=>{!E.current||!e||o||g||L.current||(E.current=!1,console.log(`[AgentSession] Auto-start: projectId=${e}, branch=${r}, agentMode=${s}`),z())},[e,o,g,z]),(0,W.useEffect)(()=>{let e=()=>{if("visible"===document.visibilityState&&o?.id&&!N.current){let e=w.current;e&&e.readyState!==WebSocket.CLOSED&&e.readyState!==WebSocket.CLOSING||(console.log("[AgentSession] Tab visible, WebSocket disconnected - reconnecting"),k.current=0,D.current=0,C.current&&(clearTimeout(C.current),C.current=null),I(o.id))}};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[o?.id,I]),(0,W.useEffect)(()=>{o?.id&&!N.current&&I(o.id)},[o?.id,I]),{session:o,messages:l,status:d,isConnected:u,isInitialized:p,isLoading:g,error:x,remoteStatus:y,startSession:z,sendMessage:F,stopSession:H,restartSession:$,switchMode:K,acceptPlan:U}}(e,r,s?.agent_mode,C,{onTaskCompleted:n,onSessionStarted:o});(0,W.useEffect)(()=>{(0,iT.getAgentProviders)().then(N).catch(()=>{})},[]),(0,W.useEffect)(()=>{T?.permissionMode&&_(T.permissionMode)},[T?.permissionMode]),(0,W.useEffect)(()=>{T?.agentType&&k(T.agentType)},[T?.agentType]);let X=(0,W.useRef)(!1);(0,W.useEffect)(()=>{let e="running"===L&&P.length>0;e&&!X.current&&a?.(),X.current=e},[L,P.length,a]);let G=async e=>{_(e),T&&await V(e)},J=async e=>{await Y(e),_("edit"),a?.()};(0,W.useImperativeHandle)(l,()=>({submitMessage:async e=>{if(T&&"running"===L)K(e);else{a?.();let r=await H(x);r&&"running"===r.status?K(e,r.id):r&&console.error(`[AgentConversation] Session ${r.id} is ${r.status}, not sending message`)}}}),[T,L,H,K,x]);let Z=async e=>{let r,s=e.text.trim(),i=e.files.length>0;if(s||i){if(v(""),R.push(s),i){let i=[];for(let r of(s&&i.push({type:"text",text:s}),e.files))if(r.mediaType&&r.url){let e=r.url.match(/^data:[^;]+;base64,(.+)$/);e&&i.push({type:"image",mediaType:r.mediaType,data:e[1]})}r=i}else r=s;if(y){let e="string"==typeof r?r:r.filter(e=>"text"===e.type).map(e=>e.text).join("\n");if(e.trim()){S(!0);try{let i=await (0,iT.translateText)(e);if(i.error){v(s),v_.toast.error("Translation failed",{description:"Disable translation to send the original text."});return}r="string"==typeof r?i.translatedText:r.map(e=>"text"===e.type?{...e,text:i.translatedText}:e)}catch{v(s),v_.toast.error("Translation failed",{description:"Disable translation to send the original text."});return}finally{S(!1)}}}if(T&&"running"===L)console.log(`[AgentConversation] handleSubmit: existing session ${T.id}, status=${L}`),K(r);else{console.log(`[AgentConversation] handleSubmit: no session or not running (session=${T?.id}, status=${L}), starting new session...`),a?.();let e=await H(x);console.log("[AgentConversation] handleSubmit: startSession returned",e?.id??"null",e?.status),e&&"running"===e.status?K(r,e.id):e&&console.error(`[AgentConversation] Session ${e.id} is ${e.status}, not sending message`)}}};return e?(0,F.jsxs)("div",{className:"h-full flex flex-col min-h-0",children:[(0,F.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-between px-4 h-10 border-b border-border/60 bg-muted/20",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(nB,{className:`h-4 w-4 ${"codex"===C?"text-green-500":"text-violet-500"}`}),j.length>1?(0,F.jsx)("select",{className:"text-sm font-medium bg-transparent border border-border rounded px-1.5 py-0.5 outline-none",value:C,onChange:e=>{let r=e.target.value;k(r),T&&q(r)},disabled:null!==T&&P.length>0,children:j.map(e=>(0,F.jsx)("option",{value:e.type,disabled:!e.available,children:e.displayName},e.type))}):(0,F.jsx)("span",{className:"text-sm font-medium",children:"codex"===C?"Codex":"Claude Code"}),(0,F.jsx)(yp,{mode:x,onModeChange:G,disabled:O}),D.length>=1&&i&&(0,F.jsx)(nP,{targets:D,activeTarget:s?.agent_mode??"local",onTargetChange:i}),T&&(c=T.id.startsWith("remote-"),d="text-muted-foreground",h=(0,F.jsx)(yh,{className:"h-3 w-3"}),u="Disconnected",B&&(c&&"connected"!==z&&null!==z?"reconnecting"===z?(d="text-amber-500",h=(0,F.jsx)(yd,{className:"h-3 w-3 animate-pulse"}),u="Reconnecting..."):"disconnected"===z&&(d="text-red-500",h=(0,F.jsx)(yh,{className:"h-3 w-3"}),u="Remote disconnected"):(d="text-green-500",h=(0,F.jsx)(yd,{className:"h-3 w-3"}),u="Connected")),(0,F.jsxs)("span",{className:`flex items-center gap-1 text-xs ${d}`,children:[h,u]}))]}),T&&(0,F.jsxs)("div",{className:"flex items-center gap-1",children:[(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>q(),disabled:O,className:"h-7 w-7",title:"New Conversation",children:(0,F.jsx)(iE,{className:"h-3.5 w-3.5"})}),"running"===T.status&&(0,F.jsxs)($.Button,{variant:"ghost",size:"sm",onClick:()=>U(),className:"h-7 text-xs",children:[(0,F.jsx)(lh,{className:"h-3 w-3 mr-1"}),"Stop"]})]})]}),(0,F.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[(0,F.jsxs)(xQ,{className:"h-full",initial:"instant",children:[(0,F.jsxs)(x0,{className:"gap-1 p-4",children:[T||0!==P.length?(0,F.jsx)(yx.Provider,{value:{sendMessage:K,messages:P,acceptPlan:J,permissionMode:T?.permissionMode??x,agentType:T?.agentType??C,sessionId:T?.id??null},children:(0,F.jsxs)("div",{className:"space-y-1",ref:E,children:[P.map((e,r)=>"user"===e.type?(0,F.jsx)("div",{"data-user-msg-idx":r,children:(0,F.jsx)(xB,{message:e,messageIndex:r})},r):(0,F.jsx)(xB,{message:e,messageIndex:r},r)),O&&(0,F.jsxs)("div",{className:"flex items-center gap-2 py-4 text-muted-foreground",children:[(0,F.jsx)(yc,{className:"h-4 w-4"}),(0,F.jsx)("span",{className:"text-sm",children:"Connecting to agent..."})]})]})}):(0,F.jsx)("div",{className:"text-center py-16",children:O||e&&!A?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(yc,{className:"h-6 w-6 mx-auto mb-4"}),(0,F.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Connecting to agent..."}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Setting up the session for this worktree"})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("div",{className:"mx-auto w-12 h-12 rounded-xl bg-primary/10 flex items-center justify-center mb-4",children:(0,F.jsx)(nB,{className:"h-6 w-6 text-primary/60"})}),(0,F.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Start a conversation"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Ask the agent to help you with coding tasks in this worktree"})]})}),I&&(0,F.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-red-500/10 rounded-lg text-red-500 text-sm mt-4",children:[(0,F.jsx)(vP,{className:"h-4 w-4"}),I]})]}),(0,F.jsx)(x1,{})]}),(0,F.jsx)(yg,{messages:P,contentRef:E})]}),(0,F.jsx)("div",{className:"flex-shrink-0 border-t border-border/60 p-3",children:(0,F.jsxs)(_8,{onSubmit:Z,accept:"image/*",className:"w-full",children:[(0,F.jsx)(yv,{}),(0,F.jsxs)("div",{className:"relative flex w-full flex-col",children:[y&&(0,F.jsx)("div",{className:"flex items-center pl-12 pr-2 pt-1.5 pb-0.5",children:(0,F.jsxs)("button",{type:"button",onClick:()=>b(!1),className:"inline-flex shrink-0 items-center gap-1.5 rounded-full bg-blue-500/10 text-blue-600 dark:text-blue-400 px-2.5 py-0.5 text-xs font-medium hover:bg-blue-500/20 transition-colors",children:[w?(0,F.jsx)(iD,{className:"size-3 animate-spin"}):(0,F.jsx)(yu,{className:"size-3"}),"Translate",(0,F.jsx)(nr,{className:"size-3"})]})}),(0,F.jsxs)("div",{className:"flex w-full items-center",children:[(0,F.jsxs)(yt,{children:[(0,F.jsx)(yr,{className:"ml-1"}),(0,F.jsxs)(ys,{children:[(0,F.jsx)(_6,{label:"Add images"}),(0,F.jsxs)(yi,{onSelect:()=>{b(!y)},children:[(0,F.jsx)(yu,{className:"mr-2 size-4"}),y?"Disable translation":"Translate"]})]})]}),(0,F.jsx)(_7,{value:g,onChange:e=>v(e.target.value),onKeyDown:R.handleKeyDown,placeholder:T?"Ask the agent to help with your code...":"Type your first message to start...",className:"pr-12"}),(0,F.jsx)(yn,{className:"absolute bottom-1 right-1",disabled:!g.trim()&&!O||w,status:w?"submitted":O?"streaming":"ready"})]})]})]})})]}):(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(nB,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to start coding"})]})})});function yb(){return"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}function yw(e){let r={};e&&(r["Content-Type"]=e);let s=(0,iT.getAuthToken)();return s&&(r.Authorization=`Bearer ${s}`),r}async function yS(e,r){let s=await fetch(`${yb()}/api/projects/${e}/chat-sessions`,{method:"POST",headers:yw("application/json"),body:JSON.stringify({branch:r})});if(!s.ok)throw Error("Failed to create chat session");return s.json()}async function yC(e,r){if(!(await fetch(`${yb()}/api/chat-sessions/${e}/message`,{method:"POST",headers:yw("application/json"),body:JSON.stringify({content:r})})).ok)throw Error("Failed to send message")}async function yk(e){if(!(await fetch(`${yb()}/api/chat-sessions/${e}/stop`,{method:"POST",headers:yw()})).ok)throw Error("Failed to stop generation")}let yj=new Map;function yN(e,r){return`chat:${e}:${r??""}`}var yE=e.i(286235);function yR({projectId:e,branch:r}){let{session:s,messages:i,status:n,isInitialized:o,isLoading:a,error:l,sendMessage:c,stopGeneration:d}=function(e,r){let[s,i]=(0,W.useState)(null),[n,o]=(0,W.useState)([]),[a,l]=(0,W.useState)("stopped"),[c,d]=(0,W.useState)(!1),[h,u]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1),[m,g]=(0,W.useState)(null),v=(0,W.useRef)(null),x=(0,W.useRef)(null),_=(0,W.useRef)(0),y=(0,W.useRef)({entries:[],status:"stopped"}),b=(0,W.useRef)(!1),w=(0,W.useRef)(!0),S=(0,W.useRef)(!1),C=(0,W.useRef)(0),k=(0,W.useRef)(null),j=(0,W.useRef)(null),N=(0,W.useRef)(0),E=(0,W.useRef)(!1),R=(0,W.useCallback)(n=>{if(v.current?.readyState===WebSocket.OPEN||v.current?.readyState===WebSocket.CONNECTING)return;y.current={entries:[],status:"stopped"},b.current=!1,S.current=!0;let a=new WebSocket((0,iT.getWebSocketUrl)(`/api/chat-sessions/${n}/stream`));v.current=a,a.onopen=()=>{d(!0),g(null),k.current=Date.now(),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{_.current=0,N.current=0},5e3)},a.onmessage=s=>{try{let c=JSON.parse(s.data);if("JsonPatch"in c){var i,n;i=y.current,n=c.JsonPatch,y.current=vx(i,e=>{for(let r of n){let{op:s,path:i,value:n}=r;if("/entries"===i&&"replace"===s&&n?.type==="ENTRY"&&n.content?.type==="system"&&n.content?.content==="__CLEAR_ALL__"){e.entries=[];continue}if(i.startsWith("/entries/")){let r=parseInt(i.replace("/entries/",""),10);if(isNaN(r)||n?.type!=="ENTRY")continue;switch(s){case"add":for(;e.entries.length<=r;)e.entries.push(null);e.entries[r]=n.content;break;case"replace":r<e.entries.length&&(e.entries[r]=n.content);break;case"remove":r<e.entries.length&&e.entries.splice(r,1)}}else"/status"===i&&n?.type==="STATUS"&&(e.status=n.content)}}),S.current||(o([...y.current.entries.filter(Boolean)]),l(y.current.status));return}if("Ready"in c){S.current=!1,o([...y.current.entries.filter(Boolean)]),l(y.current.status),u(!0);return}if("finished"in c){b.current=!0,a.close(1e3,"finished");return}if("openPreviewFrame"in c)return void(0,gF.openPreviewFrame)(c.openPreviewFrame.projectId,c.openPreviewFrame.url);if("browserCommand"in c){let r=c.browserCommand;e&&(0,gF.sendCommandToIframe)(e,{type:"vibedeckx-command",...r}).then(e=>{e&&a.readyState===WebSocket.OPEN&&a.send(JSON.stringify({type:"browser_result",result:{id:r.id,success:e.success??!1,error:e.error,content:e.content,found:e.found,tag:e.tag,text:e.text}}))});return}if("error"in c){g(c.error),"Session not found"===c.error&&(e&&yj.delete(yN(e,r)),b.current=!0);return}}catch(e){console.error("[ChatSession] Failed to parse message:",e)}},a.onclose=n=>{let o,a;d(!1),j.current&&(clearTimeout(j.current),j.current=null);let l=k.current?Date.now()-k.current:0;if(k.current=null,l>0&&l<5e3){if(N.current++,N.current>=3)return E.current?void g("Unable to connect to remote server. Please check the server configuration."):(e&&yj.delete(yN(e,r)),i(null),g(null),_.current=0,N.current=0,void(w.current=!0))}else l>=5e3&&(N.current=0);if(b.current||1e3===n.code)return;if(_.current>=10)return void g("Unable to connect to server.");let c=(a=(o=Math.min(3e4,1e3*Math.pow(2,_.current)))*Math.random()*.25,o+a);_.current++,x.current=setTimeout(()=>{s?.id&&!b.current&&R(s.id)},c)},a.onerror=()=>{}},[s?.id]),M=(0,W.useCallback)(async()=>{if(!e)return null;let s=C.current;g(null),u(!1),E.current=!1;let n=yN(e,r),a=yj.get(n);if(a)return i(a),l(a.status),R(a.id),a;p(!0);try{let{session:a,messages:c}=await yS(e,r);if(C.current!==s)return null;return yj.set(n,a),i(a),l(a.status),c&&c.length>0&&o(c),R(a.id),a}catch(e){if(C.current!==s)return null;return g(e instanceof Error?e.message:"Failed to start session"),E.current=!0,null}finally{C.current===s&&p(!1)}},[e,r,R]),D=(0,W.useCallback)(async e=>{let r=s?.id;if(r&&e.trim())try{await yC(r,e.trim())}catch(r){let e=r instanceof Error?r.message:"Failed to send message";g(e),v_.toast.error("Failed to send message",{description:e})}},[s?.id]),T=(0,W.useCallback)(async()=>{if(s?.id)try{await yk(s.id)}catch(e){console.error("[ChatSession] Failed to stop generation:",e)}},[s?.id]);return(0,W.useEffect)(()=>()=>{v.current&&(b.current=!0,v.current.close()),x.current&&clearTimeout(x.current),j.current&&clearTimeout(j.current)},[]),(0,W.useEffect)(()=>{v.current&&(v.current.close(1e3,"branch-switch"),v.current=null),x.current&&(clearTimeout(x.current),x.current=null),j.current&&(clearTimeout(j.current),j.current=null),C.current+=1,i(null),l("stopped"),d(!1),u(!1),g(null),p(!1),y.current={entries:[],status:"stopped"},b.current=!1,_.current=0,k.current=null,N.current=0,E.current=!1,w.current=!0},[e,r]),(0,W.useEffect)(()=>{!w.current||!e||s||f||E.current||(w.current=!1,M())},[e,s,f,M]),(0,W.useEffect)(()=>{!s?.id||c||b.current||R(s.id)},[s?.id,c,R]),{session:s,messages:n,status:a,isConnected:c,isInitialized:h,isLoading:f,error:m,sendMessage:D,stopGeneration:T}}(e,r),[h,u]=(0,W.useState)(""),[f,p]=(0,W.useState)(!1),m="running"===n,g=(0,W.useCallback)(async e=>{let r=e.text.trim();r&&(u(""),await c(r))},[c]);return e?(0,F.jsxs)("div",{className:"h-full flex flex-col min-h-0",children:[(0,F.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-between px-4 h-10 border-b border-border/60 bg-muted/20",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(f4,{className:"h-3.5 w-3.5 text-primary"}),(0,F.jsx)("span",{className:"text-xs font-medium text-foreground",children:"Main Chat"}),m&&(0,F.jsx)(iD,{className:"h-3 w-3 animate-spin text-primary/60"})]}),s&&(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:async()=>{let e=!f;try{await iT.api.setChatEventListening(s.id,e),p(e)}catch{v_.toast.error("Failed to toggle event listening")}},className:`h-7 w-7 ${f?"text-amber-500":""}`,title:f?"Listening to executor events (click to disable)":"Listen to executor events (click to enable)",children:(0,F.jsx)(yE.Radio,{className:"h-3.5 w-3.5"})})]}),(0,F.jsxs)(xQ,{className:"flex-1 min-h-0",initial:"instant",children:[(0,F.jsxs)(x0,{className:"gap-4 p-4",children:[a&&0===i.length&&(0,F.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,F.jsx)(iD,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),!a&&o&&0===i.length&&(0,F.jsxs)("div",{className:"text-center py-16",children:[(0,F.jsx)("div",{className:"mx-auto w-12 h-12 rounded-xl bg-primary/10 flex items-center justify-center mb-4",children:(0,F.jsx)(f4,{className:"h-6 w-6 text-primary/60"})}),(0,F.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Start a conversation"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Chat with the AI assistant about your project"})]}),i.map((e,r)=>"user"===e.type?(0,F.jsx)(vJ,{from:"user",children:(0,F.jsx)(vZ,{children:e.content})},r):"assistant"===e.type?(0,F.jsx)(vJ,{from:"assistant",children:(0,F.jsx)(vZ,{children:(0,F.jsx)(vQ,{children:e.content})})},r):"tool_use"===e.type?(0,F.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-xs text-muted-foreground",children:[(0,F.jsx)(vz,{className:"w-3.5 h-3.5 animate-pulse"}),(0,F.jsx)("span",{children:function(e){switch(e){case"getExecutorStatus":return"Checking executor status...";case"getAgentConversation":return"Checking agent conversation...";case"listTerminals":return"Listing terminals...";case"runInTerminal":return"Sending command to terminal...";default:return`Running ${e}...`}}(e.tool)})]},r):"tool_result"===e.type?(0,F.jsx)("div",{className:"px-4 py-2",children:(0,F.jsxs)("details",{className:"text-xs text-muted-foreground",children:[(0,F.jsx)("summary",{className:"cursor-pointer hover:text-foreground",children:"Tool result"}),(0,F.jsx)("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto whitespace-pre-wrap",children:e.output})]})},r):"error"===e.type?(0,F.jsx)("div",{className:"mx-auto max-w-[90%] rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:e.message},r):null),l&&(0,F.jsx)("div",{className:"mx-auto max-w-[90%] rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:l})]}),(0,F.jsx)(x1,{})]}),(0,F.jsxs)("div",{className:"flex-shrink-0 border-t border-border/60 p-3",children:[m&&(0,F.jsx)("div",{className:"flex justify-center mb-2",children:(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:d,className:"gap-1.5",children:[(0,F.jsx)(lh,{className:"h-3 w-3"}),"Stop generating"]})}),(0,F.jsxs)(_8,{onSubmit:g,className:"w-full",children:[(0,F.jsx)(_7,{disabled:!o||m,placeholder:o?m?"Waiting for response...":"Type a message...":"Connecting...",className:"pr-12",value:h,onChange:e=>u(e.currentTarget.value)}),(0,F.jsx)(yn,{className:"absolute bottom-1 right-1",disabled:!o||m||!h.trim()})]})]})]}):(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(f4,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to start chatting"})]})})}let yM=(0,W.createContext)(null);yM.displayName="PanelGroupContext";let yD="data-panel-group-direction",yT="data-panel-group-id",yP="data-resize-handle",yL="data-panel-resize-handle-id",yB=W.useLayoutEffect,yA=W["useId".toString()],yO="function"==typeof yA?yA:()=>null,yI=0;function yz(e=null){let r=yO(),s=(0,W.useRef)(e||r||null);return null===s.current&&(s.current=""+yI++),null!=e?e:s.current}function yF({children:e,className:r="",collapsedSize:s,collapsible:i,defaultSize:n,forwardedRef:o,id:a,maxSize:l,minSize:c,onCollapse:d,onExpand:h,onResize:u,order:f,style:p,tagName:m="div",...g}){let v=(0,W.useContext)(yM);if(null===v)throw Error("Panel components must be rendered within a PanelGroup container");let{collapsePanel:x,expandPanel:_,getPanelSize:y,getPanelStyle:b,groupId:w,isPanelCollapsed:S,reevaluatePanelConstraints:C,registerPanel:k,resizePanel:j,unregisterPanel:N}=v,E=yz(a),R=(0,W.useRef)({callbacks:{onCollapse:d,onExpand:h,onResize:u},constraints:{collapsedSize:s,collapsible:i,defaultSize:n,maxSize:l,minSize:c},id:E,idIsFromProps:void 0!==a,order:f});(0,W.useRef)({didLogMissingDefaultSizeWarning:!1}),yB(()=>{let{callbacks:e,constraints:r}=R.current,o={...r};R.current.id=E,R.current.idIsFromProps=void 0!==a,R.current.order=f,e.onCollapse=d,e.onExpand=h,e.onResize=u,r.collapsedSize=s,r.collapsible=i,r.defaultSize=n,r.maxSize=l,r.minSize=c,(o.collapsedSize!==r.collapsedSize||o.collapsible!==r.collapsible||o.maxSize!==r.maxSize||o.minSize!==r.minSize)&&C(R.current,o)}),yB(()=>{let e=R.current;return k(e),()=>{N(e)}},[f,E,k,N]),(0,W.useImperativeHandle)(o,()=>({collapse:()=>{x(R.current)},expand:e=>{_(R.current,e)},getId:()=>E,getSize:()=>y(R.current),isCollapsed:()=>S(R.current),isExpanded:()=>!S(R.current),resize:e=>{j(R.current,e)}}),[x,_,y,S,E,j]);let M=b(R.current,n);return(0,W.createElement)(m,{...g,children:e,className:r,id:E,style:{...M,...p},[yT]:w,"data-panel":"","data-panel-collapsible":i||void 0,"data-panel-id":E,"data-panel-size":parseFloat(""+M.flexGrow).toFixed(1)})}let yW=(0,W.forwardRef)((e,r)=>(0,W.createElement)(yF,{...e,forwardedRef:r}));yF.displayName="Panel",yW.displayName="forwardRef(Panel)";let yH=null,y$=-1,yK=null;function yU(e,s){var i,n,o;let a=function(e,r){if(r){let e=(r&y1)!=0,s=(r&y2)!=0,i=(r&y5)!=0,n=(r&y3)!=0;if(e)if(i)return"se-resize";else if(n)return"ne-resize";else return"e-resize";if(s)if(i)return"sw-resize";else if(n)return"nw-resize";else return"w-resize";if(i)return"s-resize";else if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,s);yH!==a&&(yH=a,null===yK&&(yK=document.createElement("style"),r&&yK.setAttribute("nonce",r),document.head.appendChild(yK)),y$>=0&&(null==(o=yK.sheet)||o.removeRule(y$)),y$=null!=(i=null==(n=yK.sheet)?void 0:n.insertRule(`*{cursor: ${a} !important;}`))?i:-1)}function yq(e){return"keydown"===e.type}function yV(e){return e.type.startsWith("pointer")}function yY(e){return e.type.startsWith("mouse")}function yX(e){if(yV(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(yY(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}let yG=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function yJ(e){let r=e.length;for(;r--;){let s=e[r];if(bd(s,"Missing node"),function(e){var r;let s,i=getComputedStyle(e);return"fixed"===i.position||!!("auto"!==i.zIndex&&("static"!==i.position||"flex"===(s=getComputedStyle(null!=(r=y0(e))?r:e).display)||"inline-flex"===s)||1>+i.opacity||"transform"in i&&"none"!==i.transform||"webkitTransform"in i&&"none"!==i.webkitTransform||"mixBlendMode"in i&&"normal"!==i.mixBlendMode||"filter"in i&&"none"!==i.filter||"webkitFilter"in i&&"none"!==i.webkitFilter||"isolation"in i&&"isolate"===i.isolation||yG.test(i.willChange))||"touch"===i.webkitOverflowScrolling}(s))return s}return null}function yZ(e){return e&&Number(getComputedStyle(e).zIndex)||0}function yQ(e){let r=[];for(;e;)r.push(e),e=y0(e);return r}function y0(e){let{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}let y1=1,y2=2,y5=4,y3=8,y4="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}(),y6=[],y8=!1,y7=new Map,y9=new Map,be=new Set;function bt(e){let{target:r}=e,{x:s,y:i}=yX(e);y8=!0,bn({target:r,x:s,y:i}),bl(),y6.length>0&&(bc("down",e),e.preventDefault(),bi(r)||e.stopImmediatePropagation())}function br(e){let{x:r,y:s}=yX(e);if(y8&&0===e.buttons&&(y8=!1,bc("up",e)),!y8){let{target:i}=e;bn({target:i,x:r,y:s})}bc("move",e),bo(),y6.length>0&&e.preventDefault()}function bs(e){let{target:r}=e,{x:s,y:i}=yX(e);y9.clear(),y8=!1,y6.length>0&&(e.preventDefault(),bi(r)||e.stopImmediatePropagation()),bc("up",e),bn({target:r,x:s,y:i}),bo(),bl()}function bi(e){let r=e;for(;r;){if(r.hasAttribute(yP))return!0;r=r.parentElement}return!1}function bn({target:e,x:r,y:s}){y6.splice(0);let i=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(i=e),be.forEach(e=>{let{element:n,hitAreaMargins:o}=e,a=n.getBoundingClientRect(),{bottom:l,left:c,right:d,top:h}=a,u=y4?o.coarse:o.fine;if(r>=c-u&&r<=d+u&&s>=h-u&&s<=l+u){if(null!==i&&document.contains(i)&&n!==i&&!n.contains(i)&&!i.contains(n)&&function(e,r){let s;if(e===r)throw Error("Cannot compare node with itself");let i={a:yQ(e),b:yQ(r)};for(;i.a.at(-1)===i.b.at(-1);)e=i.a.pop(),r=i.b.pop(),s=e;bd(s,"Stacking order can only be calculated for elements with a common ancestor");let n={a:yZ(yJ(i.a)),b:yZ(yJ(i.b))};if(n.a===n.b){let e=s.childNodes,r={a:i.a.at(-1),b:i.b.at(-1)},n=e.length;for(;n--;){let s=e[n];if(s===r.a)return 1;if(s===r.b)return -1}}return Math.sign(n.a-n.b)}(i,n)>0){let e=i,r=!1;for(;e;){var f;if(e.contains(n))break;if(f=e.getBoundingClientRect(),f.x<a.x+a.width&&f.x+f.width>a.x&&f.y<a.y+a.height&&f.y+f.height>a.y){r=!0;break}e=e.parentElement}if(r)return}y6.push(e)}})}function bo(){let e=!1,r=!1;y6.forEach(s=>{let{direction:i}=s;"horizontal"===i?e=!0:r=!0});let s=0;y9.forEach(e=>{s|=e}),e&&r?yU("intersection",s):e?yU("horizontal",s):r?yU("vertical",s):null!==yK&&(document.head.removeChild(yK),yH=null,yK=null,y$=-1)}let ba=new AbortController;function bl(){ba.abort();let e={capture:!0,signal:(ba=new AbortController).signal};be.size&&(y8?(y6.length>0&&y7.forEach((r,s)=>{let{body:i}=s;r>0&&(i.addEventListener("contextmenu",bs,e),i.addEventListener("pointerleave",br,e),i.addEventListener("pointermove",br,e))}),window.addEventListener("pointerup",bs,e),window.addEventListener("pointercancel",bs,e)):y7.forEach((r,s)=>{let{body:i}=s;r>0&&(i.addEventListener("pointerdown",bt,e),i.addEventListener("pointermove",br,e))}))}function bc(e,r){be.forEach(s=>{let{setResizeHandlerState:i}=s;i(e,y6.includes(s),r)})}function bd(e,r){if(!e)throw console.error(r),Error(r)}function bh(e,r,s=10){return e.toFixed(s)===r.toFixed(s)?0:e>r?1:-1}function bu(e,r,s=10){return 0===bh(e,r,s)}function bf(e,r,s){return 0===bh(e,r,s)}function bp({panelConstraints:e,panelIndex:r,size:s}){let i=e[r];bd(null!=i,`Panel constraints not found for index ${r}`);let{collapsedSize:n=0,collapsible:o,maxSize:a=100,minSize:l=0}=i;return 0>bh(s,l)&&(s=o&&0>bh(s,(n+l)/2)?n:l),s=parseFloat((s=Math.min(a,s)).toFixed(10))}function bm({delta:e,initialLayout:r,panelConstraints:s,pivotIndices:i,prevLayout:n,trigger:o}){if(bf(e,0))return r;let a=[...r],[l,c]=i;bd(null!=l,"Invalid first pivot index"),bd(null!=c,"Invalid second pivot index");let d=0;if("keyboard"===o){{let i=e<0?c:l,n=s[i];bd(n,`Panel constraints not found for index ${i}`);let{collapsedSize:o=0,collapsible:a,minSize:d=0}=n;if(a){let s=r[i];if(bd(null!=s,`Previous layout not found for panel index ${i}`),bf(s,o)){let r=d-s;bh(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}{let i=e<0?l:c,n=s[i];bd(n,`No panel constraints found for index ${i}`);let{collapsedSize:o=0,collapsible:a,minSize:d=0}=n;if(a){let s=r[i];if(bd(null!=s,`Previous layout not found for panel index ${i}`),bf(s,d)){let r=s-o;bh(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}}{let i=e<0?1:-1,n=e<0?c:l,o=0;for(;;){let e=r[n];if(bd(null!=e,`Previous layout not found for panel index ${n}`),o+=bp({panelConstraints:s,panelIndex:n,size:100})-e,(n+=i)<0||n>=s.length)break}let a=Math.min(Math.abs(e),Math.abs(o));e=e<0?0-a:a}{let i=e<0?l:c;for(;i>=0&&i<s.length;){let n=Math.abs(e)-Math.abs(d),o=r[i];bd(null!=o,`Previous layout not found for panel index ${i}`);let l=bp({panelConstraints:s,panelIndex:i,size:o-n});if(!bf(o,l)&&(d+=o-l,a[i]=l,d.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?i--:i++}}if(function(e,r,s){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(!bf(e[s],r[s],void 0))return!1;return!0}(n,a))return n;{let i=e<0?c:l,n=r[i];bd(null!=n,`Previous layout not found for panel index ${i}`);let o=n+d,h=bp({panelConstraints:s,panelIndex:i,size:o});if(a[i]=h,!bf(h,o)){let r=o-h,i=e<0?c:l;for(;i>=0&&i<s.length;){let n=a[i];bd(null!=n,`Previous layout not found for panel index ${i}`);let o=bp({panelConstraints:s,panelIndex:i,size:n+r});if(bf(n,o)||(r-=o-n,a[i]=o),bf(r,0))break;e>0?i--:i++}}}return bf(a.reduce((e,r)=>r+e,0),100)?a:n}function bg(e,r=document){return Array.from(r.querySelectorAll(`[${yL}][data-panel-group-id="${e}"]`))}function bv(e,r,s=document){let i=bg(e,s).findIndex(e=>e.getAttribute(yL)===r);return null!=i?i:null}function bx(e,r,s){let i=bv(e,r,s);return null!=i?[i,i+1]:[-1,-1]}function b_(e,r=document){var s;if(r instanceof HTMLElement&&(null==r||null==(s=r.dataset)?void 0:s.panelGroupId)==e)return r;let i=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return i||null}function by(e,r=document){let s=r.querySelector(`[${yL}="${e}"]`);return s||null}function bb(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==r[s])return!1;return!0}function bw(e,r){let{x:s,y:i}=yX(r);return"horizontal"===e?s:i}function bS(e,r,s){r.forEach((r,i)=>{let n=e[i];bd(n,`Panel data not found for index ${i}`);let{callbacks:o,constraints:a,id:l}=n,{collapsedSize:c=0,collapsible:d}=a,h=s[l];if(null==h||r!==h){s[l]=r;let{onCollapse:e,onExpand:i,onResize:n}=o;n&&n(r,h),d&&(e||i)&&(i&&(null==h||bu(h,c))&&!bu(r,c)&&i(),e&&(null==h||!bu(h,c))&&bu(r,c)&&e())}})}function bC(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=r[s])return!1;return!0}function bk(e){try{if("undefined"!=typeof localStorage)e.getItem=e=>localStorage.getItem(e),e.setItem=(e,r)=>{localStorage.setItem(e,r)};else throw Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function bj(e){return`react-resizable-panels:${e}`}function bN(e){return e.map(e=>{let{constraints:r,id:s,idIsFromProps:i,order:n}=e;return i?s:n?`${n}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((e,r)=>e.localeCompare(r)).join(",")}function bE(e,r){try{let s=bj(e),i=r.getItem(s);if(i){let e=JSON.parse(i);if("object"==typeof e&&null!=e)return e}}catch(e){}return null}function bR(e,r,s,i,n){var o;let a=bj(e),l=bN(r),c=null!=(o=bE(e,n))?o:{};c[l]={expandToSizes:Object.fromEntries(s.entries()),layout:i};try{n.setItem(a,JSON.stringify(c))}catch(e){console.error(e)}}function bM({layout:e,panelConstraints:r}){let s=[...e],i=s.reduce((e,r)=>e+r,0);if(s.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${s.map(e=>`${e}%`).join(", ")}`);if(!bf(i,100)&&s.length>0)for(let e=0;e<r.length;e++){let r=s[e];bd(null!=r,`No layout data found for index ${e}`);let n=100/i*r;s[e]=n}let n=0;for(let e=0;e<r.length;e++){let i=s[e];bd(null!=i,`No layout data found for index ${e}`);let o=bp({panelConstraints:r,panelIndex:e,size:i});i!=o&&(n+=i-o,s[e]=o)}if(!bf(n,0))for(let e=0;e<r.length;e++){let i=s[e];bd(null!=i,`No layout data found for index ${e}`);let o=bp({panelConstraints:r,panelIndex:e,size:i+n});if(i!==o&&(n-=o-i,s[e]=o,bf(n,0)))break}return s}let bD={getItem:e=>(bk(bD),bD.getItem(e)),setItem:(e,r)=>{bk(bD),bD.setItem(e,r)}},bT={};function bP({autoSaveId:e=null,children:r,className:s="",direction:i,forwardedRef:n,id:o=null,onLayout:a=null,keyboardResizeBy:l=null,storage:c=bD,style:d,tagName:h="div",...u}){let f=yz(o),p=(0,W.useRef)(null),[m,g]=(0,W.useState)(null),[v,x]=(0,W.useState)([]),_=function(){let[e,r]=(0,W.useState)(0);return(0,W.useCallback)(()=>r(e=>e+1),[])}(),y=(0,W.useRef)({}),b=(0,W.useRef)(new Map),w=(0,W.useRef)(0),S=(0,W.useRef)({autoSaveId:e,direction:i,dragState:m,id:f,keyboardResizeBy:l,onLayout:a,storage:c}),C=(0,W.useRef)({layout:v,panelDataArray:[],panelDataArrayChanged:!1});(0,W.useRef)({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),(0,W.useImperativeHandle)(n,()=>({getId:()=>S.current.id,getLayout:()=>{let{layout:e}=C.current;return e},setLayout:e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:i}=C.current,n=bM({layout:e,panelConstraints:i.map(e=>e.constraints)});bb(s,n)||(x(n),C.current.layout=n,r&&r(n),bS(i,n,y.current))}}),[]),yB(()=>{S.current.autoSaveId=e,S.current.direction=i,S.current.dragState=m,S.current.id=f,S.current.onLayout=a,S.current.storage=c}),function({committedValuesRef:e,eagerValuesRef:r,groupId:s,layout:i,panelDataArray:n,panelGroupElement:o,setLayout:a}){(0,W.useRef)({didWarnAboutMissingResizeHandle:!1}),yB(()=>{if(!o)return;let e=bg(s,o);for(let r=0;r<n.length-1;r++){let{valueMax:s,valueMin:o,valueNow:a}=function({layout:e,panelsArray:r,pivotIndices:s}){let i=0,n=100,o=0,a=0,l=s[0];return bd(null!=l,"No pivot index found"),r.forEach((e,r)=>{let{constraints:s}=e,{maxSize:c=100,minSize:d=0}=s;r===l?(i=d,n=c):(o+=d,a+=c)}),{valueMax:Math.min(n,100-o),valueMin:Math.max(i,100-a),valueNow:e[l]}}({layout:i,panelsArray:n,pivotIndices:[r,r+1]}),l=e[r];if(null==l);else{let e=n[r];bd(e,`No panel data found for index "${r}"`),l.setAttribute("aria-controls",e.id),l.setAttribute("aria-valuemax",""+Math.round(s)),l.setAttribute("aria-valuemin",""+Math.round(o)),l.setAttribute("aria-valuenow",null!=a?""+Math.round(a):"")}}return()=>{e.forEach((e,r)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")})}},[s,i,n,o]),(0,W.useEffect)(()=>{if(!o)return;let e=r.current;bd(e,"Eager values not found");let{panelDataArray:n}=e;bd(null!=b_(s,o),`No group found for id "${s}"`);let l=bg(s,o);bd(l,`No resize handles found for group id "${s}"`);let c=l.map(e=>{let r=e.getAttribute(yL);bd(r,"Resize handle element has no handle id attribute");let[l,c]=function(e,r,s,i=document){var n,o,a,l;let c=by(r,i),d=bg(e,i),h=c?d.indexOf(c):-1;return[null!=(n=null==(o=s[h])?void 0:o.id)?n:null,null!=(a=null==(l=s[h+1])?void 0:l.id)?a:null]}(s,r,n,o);if(null==l||null==c)return()=>{};let d=e=>{if(!e.defaultPrevented&&"Enter"===e.key){e.preventDefault();let c=n.findIndex(e=>e.id===l);if(c>=0){let e=n[c];bd(e,`No panel data found for index ${c}`);let l=i[c],{collapsedSize:d=0,collapsible:h,minSize:u=0}=e.constraints;if(null!=l&&h){let e=bm({delta:bf(l,d)?u-d:d-l,initialLayout:i,panelConstraints:n.map(e=>e.constraints),pivotIndices:bx(s,r,o),prevLayout:i,trigger:"keyboard"});i!==e&&a(e)}}}};return e.addEventListener("keydown",d),()=>{e.removeEventListener("keydown",d)}});return()=>{c.forEach(e=>e())}},[o,e,r,s,i,n,a])}({committedValuesRef:S,eagerValuesRef:C,groupId:f,layout:v,panelDataArray:C.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),(0,W.useEffect)(()=>{let{panelDataArray:r}=C.current;if(e){if(0===v.length||v.length!==r.length)return;let s=bT[e];null==s&&(s=function(e,r=10){let s=null;return(...i)=>{null!==s&&clearTimeout(s),s=setTimeout(()=>{e(...i)},r)}}(bR,100),bT[e]=s),s(e,[...r],new Map(b.current),v,c)}},[e,v,c]),(0,W.useEffect)(()=>{});let k=(0,W.useCallback)(e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:i}=C.current;if(e.constraints.collapsible){let n=i.map(e=>e.constraints),{collapsedSize:o=0,panelSize:a,pivotIndices:l}=bA(i,e,s);if(bd(null!=a,`Panel size not found for panel "${e.id}"`),!bu(a,o)){b.current.set(e.id,a);let c=bm({delta:bB(i,e)===i.length-1?a-o:o-a,initialLayout:s,panelConstraints:n,pivotIndices:l,prevLayout:s,trigger:"imperative-api"});bC(s,c)||(x(c),C.current.layout=c,r&&r(c),bS(i,c,y.current))}}},[]),j=(0,W.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:i,panelDataArray:n}=C.current;if(e.constraints.collapsible){let o=n.map(e=>e.constraints),{collapsedSize:a=0,panelSize:l=0,minSize:c=0,pivotIndices:d}=bA(n,e,i),h=null!=r?r:c;if(bu(l,a)){let r=b.current.get(e.id),a=null!=r&&r>=h?r:h,c=bm({delta:bB(n,e)===n.length-1?l-a:a-l,initialLayout:i,panelConstraints:o,pivotIndices:d,prevLayout:i,trigger:"imperative-api"});bC(i,c)||(x(c),C.current.layout=c,s&&s(c),bS(n,c,y.current))}}},[]),N=(0,W.useCallback)(e=>{let{layout:r,panelDataArray:s}=C.current,{panelSize:i}=bA(s,e,r);return bd(null!=i,`Panel size not found for panel "${e.id}"`),i},[]),E=(0,W.useCallback)((e,r)=>{let{panelDataArray:s}=C.current,i=bB(s,e);return function({defaultSize:e,dragState:r,layout:s,panelData:i,panelIndex:n,precision:o=3}){let a=s[n];return{flexBasis:0,flexGrow:null==a?void 0!=e?e.toPrecision(o):"1":1===i.length?"1":a.toPrecision(o),flexShrink:1,overflow:"hidden",pointerEvents:null!==r?"none":void 0}}({defaultSize:r,dragState:m,layout:v,panelData:s,panelIndex:i})},[m,v]),R=(0,W.useCallback)(e=>{let{layout:r,panelDataArray:s}=C.current,{collapsedSize:i=0,collapsible:n,panelSize:o}=bA(s,e,r);return bd(null!=o,`Panel size not found for panel "${e.id}"`),!0===n&&bu(o,i)},[]),M=(0,W.useCallback)(e=>{let{layout:r,panelDataArray:s}=C.current,{collapsedSize:i=0,collapsible:n,panelSize:o}=bA(s,e,r);return bd(null!=o,`Panel size not found for panel "${e.id}"`),!n||bh(o,i)>0},[]),D=(0,W.useCallback)(e=>{let{panelDataArray:r}=C.current;r.push(e),r.sort((e,r)=>{let s=e.order,i=r.order;return null==s&&null==i?0:null==s?-1:null==i?1:s-i}),C.current.panelDataArrayChanged=!0,_()},[_]);yB(()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;let{autoSaveId:s,onLayout:i,storage:n}=S.current,{layout:o,panelDataArray:a}=C.current,l=null;if(s){var e,r;let i=null!=(r=(null!=(e=bE(s,n))?e:{})[bN(a)])?r:null;i&&(b.current=new Map(Object.entries(i.expandToSizes)),l=i.layout)}null==l&&(l=function({panelDataArray:e}){let r=Array(e.length),s=e.map(e=>e.constraints),i=0,n=100;for(let o=0;o<e.length;o++){let e=s[o];bd(e,`Panel constraints not found for index ${o}`);let{defaultSize:a}=e;null!=a&&(i++,r[o]=a,n-=a)}for(let o=0;o<e.length;o++){let a=s[o];bd(a,`Panel constraints not found for index ${o}`);let{defaultSize:l}=a;if(null!=l)continue;let c=n/(e.length-i);i++,r[o]=c,n-=c}return r}({panelDataArray:a}));let c=bM({layout:l,panelConstraints:a.map(e=>e.constraints)});bb(o,c)||(x(c),C.current.layout=c,i&&i(c),bS(a,c,y.current))}}),yB(()=>{let e=C.current;return()=>{e.layout=[]}},[]);let T=(0,W.useCallback)(e=>{let r=!1,s=p.current;return s&&"rtl"===window.getComputedStyle(s,null).getPropertyValue("direction")&&(r=!0),function(s){var i,n;s.preventDefault();let o=p.current;if(!o)return()=>null;let{direction:a,dragState:l,id:c,keyboardResizeBy:d,onLayout:h}=S.current,{layout:u,panelDataArray:f}=C.current,{initialLayout:m}=null!=l?l:{},g=bx(c,e,o),v=function(e,r,s,i,n,o){if(yq(e)){let r="horizontal"===s,i=0;i=e.shiftKey?100:null!=n?n:10;let o=0;switch(e.key){case"ArrowDown":o=r?0:i;break;case"ArrowLeft":o=r?-i:0;break;case"ArrowRight":o=r?i:0;break;case"ArrowUp":o=r?0:-i;break;case"End":o=100;break;case"Home":o=-100}return o}return null==i?0:function(e,r,s,i,n){let o="horizontal"===s,a=by(r,n);bd(a,`No resize handle element found for id "${r}"`);let l=a.getAttribute(yT);bd(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=i,d=bw(s,e),h=b_(l,n);bd(h,`No group element found for id "${l}"`);let u=h.getBoundingClientRect();return(d-c)/(o?u.width:u.height)*100}(e,r,s,i,o)}(s,e,a,l,d,o),_="horizontal"===a;_&&r&&(v=-v);let b=bm({delta:v,initialLayout:null!=m?m:u,panelConstraints:f.map(e=>e.constraints),pivotIndices:g,prevLayout:u,trigger:yq(s)?"keyboard":"mouse-or-touch"}),k=!bC(u,b);(yV(s)||yY(s))&&w.current!=v&&((w.current=v,k||0===v)?y9.set(e,0):_?(i=v<0?y1:y2,y9.set(e,i)):(n=v<0?y5:y3,y9.set(e,n))),k&&(x(b),C.current.layout=b,h&&h(b),bS(f,b,y.current))}},[]),P=(0,W.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:i,panelDataArray:n}=C.current,o=n.map(e=>e.constraints),{panelSize:a,pivotIndices:l}=bA(n,e,i);bd(null!=a,`Panel size not found for panel "${e.id}"`);let c=bm({delta:bB(n,e)===n.length-1?a-r:r-a,initialLayout:i,panelConstraints:o,pivotIndices:l,prevLayout:i,trigger:"imperative-api"});bC(i,c)||(x(c),C.current.layout=c,s&&s(c),bS(n,c,y.current))},[]),L=(0,W.useCallback)((e,r)=>{let{layout:s,panelDataArray:i}=C.current,{collapsedSize:n=0,collapsible:o}=r,{collapsedSize:a=0,collapsible:l,maxSize:c=100,minSize:d=0}=e.constraints,{panelSize:h}=bA(i,e,s);null!=h&&(o&&l&&bu(h,n)?bu(n,a)||P(e,a):h<d?P(e,d):h>c&&P(e,c))},[P]),B=(0,W.useCallback)((e,r)=>{let{direction:s}=S.current,{layout:i}=C.current;if(!p.current)return;let n=by(e,p.current);bd(n,`Drag handle element not found for id "${e}"`);let o=bw(s,r);g({dragHandleId:e,dragHandleRect:n.getBoundingClientRect(),initialCursorPosition:o,initialLayout:i})},[]),A=(0,W.useCallback)(()=>{g(null)},[]),O=(0,W.useCallback)(e=>{let{panelDataArray:r}=C.current,s=bB(r,e);s>=0&&(r.splice(s,1),delete y.current[e.id],C.current.panelDataArrayChanged=!0,_())},[_]),I=(0,W.useMemo)(()=>({collapsePanel:k,direction:i,dragState:m,expandPanel:j,getPanelSize:N,getPanelStyle:E,groupId:f,isPanelCollapsed:R,isPanelExpanded:M,reevaluatePanelConstraints:L,registerPanel:D,registerResizeHandle:T,resizePanel:P,startDragging:B,stopDragging:A,unregisterPanel:O,panelGroupElement:p.current}),[k,m,i,j,N,E,f,R,M,L,D,T,P,B,A,O]);return(0,W.createElement)(yM.Provider,{value:I},(0,W.createElement)(h,{...u,children:r,className:s,id:o,ref:p,style:{display:"flex",flexDirection:"horizontal"===i?"row":"column",height:"100%",overflow:"hidden",width:"100%",...d},"data-panel-group":"",[yD]:i,[yT]:f}))}let bL=(0,W.forwardRef)((e,r)=>(0,W.createElement)(bP,{...e,forwardedRef:r}));function bB(e,r){return e.findIndex(e=>e===r||e.id===r.id)}function bA(e,r,s){let i=bB(e,r),n=i===e.length-1,o=s[i];return{...r.constraints,panelSize:o,pivotIndices:n?[i-1,i]:[i,i+1]}}function bO({children:e=null,className:r="",disabled:s=!1,hitAreaMargins:i,id:n,onBlur:o,onClick:a,onDragging:l,onFocus:c,onPointerDown:d,onPointerUp:h,style:u={},tabIndex:f=0,tagName:p="div",...m}){var g,v;let x=(0,W.useRef)(null),_=(0,W.useRef)({onClick:a,onDragging:l,onPointerDown:d,onPointerUp:h});(0,W.useEffect)(()=>{_.current.onClick=a,_.current.onDragging=l,_.current.onPointerDown=d,_.current.onPointerUp=h});let y=(0,W.useContext)(yM);if(null===y)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");let{direction:b,groupId:w,registerResizeHandle:S,startDragging:C,stopDragging:k,panelGroupElement:j}=y,N=yz(n),[E,R]=(0,W.useState)("inactive"),[M,D]=(0,W.useState)(!1),[T,P]=(0,W.useState)(null),L=(0,W.useRef)({state:E});yB(()=>{L.current.state=E}),(0,W.useEffect)(()=>{if(s)P(null);else{let e=S(N);P(()=>e)}},[s,N,S]);let B=null!=(g=null==i?void 0:i.coarse)?g:15,A=null!=(v=null==i?void 0:i.fine)?v:5;return(0,W.useEffect)(()=>{if(s||null==T)return;let e=x.current;bd(e,"Element ref not attached");let r=!1;return function(e,r,s,i,n){var o;let{ownerDocument:a}=r,l={direction:s,element:r,hitAreaMargins:i,setResizeHandlerState:n},c=null!=(o=y7.get(a))?o:0;return y7.set(a,c+1),be.add(l),bl(),function(){var r;y9.delete(e),be.delete(l);let s=null!=(r=y7.get(a))?r:1;if(y7.set(a,s-1),bl(),1===s&&y7.delete(a),y6.includes(l)){let e=y6.indexOf(l);e>=0&&y6.splice(e,1),bo(),n("up",!0,null)}}}(N,e,b,{coarse:B,fine:A},(e,s,i)=>{if(!s)return void R("inactive");switch(e){case"down":{R("drag"),r=!1,bd(i,'Expected event to be defined for "down" action'),C(N,i);let{onDragging:e,onPointerDown:s}=_.current;null==e||e(!0),null==s||s();break}case"move":{let{state:e}=L.current;r=!0,"drag"!==e&&R("hover"),bd(i,'Expected event to be defined for "move" action'),T(i);break}case"up":{R("hover"),k();let{onClick:e,onDragging:s,onPointerUp:i}=_.current;null==s||s(!1),null==i||i(),r||null==e||e()}}})},[B,b,s,A,S,N,T,C,k]),!function({disabled:e,handleId:r,resizeHandler:s,panelGroupElement:i}){(0,W.useEffect)(()=>{if(e||null==s||null==i)return;let n=by(r,i);if(null==n)return;let o=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),s(e);break;case"F6":{e.preventDefault();let s=n.getAttribute(yT);bd(s,`No group element found for id "${s}"`);let o=bg(s,i),a=bv(s,r,i);bd(null!==a,`No resize element found for id "${r}"`);let l=e.shiftKey?a>0?a-1:o.length-1:a+1<o.length?a+1:0;o[l].focus()}}};return n.addEventListener("keydown",o),()=>{n.removeEventListener("keydown",o)}},[i,e,r,s])}({disabled:s,handleId:N,resizeHandler:T,panelGroupElement:j}),(0,W.createElement)(p,{...m,children:e,className:r,id:n,onBlur:()=>{D(!1),null==o||o()},onFocus:()=>{D(!0),null==c||c()},ref:x,role:"separator",style:{touchAction:"none",userSelect:"none",...u},tabIndex:f,[yD]:b,[yT]:w,[yP]:"","data-resize-handle-active":"drag"===E?"pointer":M?"keyboard":void 0,"data-panel-resize-handle-enabled":!s,[yL]:N,"data-resize-handle-state":E})}bP.displayName="PanelGroup",bL.displayName="forwardRef(PanelGroup)",bO.displayName="PanelResizeHandle";let bI=({className:e,...r})=>(0,F.jsx)(bL,{className:(0,iu.cn)("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r}),bz=({withHandle:e,className:r,...s})=>(0,F.jsx)(bO,{className:(0,iu.cn)("relative flex w-px items-center justify-center bg-border/60 after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-[''] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:inset-x-0 data-[panel-group-direction=vertical]:after:-top-1 data-[panel-group-direction=vertical]:after:-bottom-1 data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:right-0 [&[data-resize-handle-active]]:bg-ring",r),...s,children:e&&(0,F.jsx)("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:(0,F.jsx)(lu,{className:"h-2.5 w-2.5"})})}),bF=(0,ic.default)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),bW=(0,ic.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function bH({status:e}){return e&&"idle"!==e?"assigned"===e?(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-yellow-500 shrink-0"}):"working"===e?(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-blue-500 animate-pulse shrink-0"}):(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-green-500 shrink-0"}):(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30 shrink-0"})}function b$({project:e}){let r=!!e.path,s=e.is_remote||!!e.remote_path;return r&&s?(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-purple-500 shrink-0"}):s?(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-blue-500 shrink-0"}):(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30 shrink-0"})}function bK({activeView:e,onViewChange:r,worktrees:s,selectedBranch:i,onBranchChange:n,currentProject:o,onCreateWorktreeOpen:a,onDeleteWorktree:l,workspaceStatuses:c,hasProject:d=!0,projects:h,onSelectProject:u,onCreateProjectOpen:f}){return(0,F.jsxs)("nav",{className:"w-52 border-r border-border/60 bg-sidebar flex flex-col p-3",children:[(0,F.jsxs)("div",{className:"space-y-0.5",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-3 mb-2",children:[(0,F.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Projects"}),(0,F.jsx)("button",{onClick:f,className:"p-0.5 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors text-muted-foreground",title:"Create new project",children:(0,F.jsx)(nD,{className:"h-3 w-3"})})]}),h&&h.length>0?(0,F.jsx)(gD,{delayDuration:300,children:(0,F.jsx)("div",{className:"flex flex-col gap-0.5 max-h-40 overflow-y-auto",children:h.map(s=>{let i=o?.id===s.id,n=i&&"project-info"===e;return(0,F.jsxs)(gT,{children:[(0,F.jsx)(gP,{asChild:!0,children:(0,F.jsxs)("button",{onClick:()=>{u?.(s),r("project-info")},className:(0,iu.cn)("w-full flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs transition-all duration-150 min-w-0","hover:bg-accent/80 hover:text-accent-foreground",n?"bg-primary/10 text-primary font-medium shadow-sm":i?"font-medium text-foreground":"text-muted-foreground"),children:[(0,F.jsx)(b$,{project:s}),(0,F.jsx)("span",{className:"truncate flex-1 text-left",children:s.name}),i&&(0,F.jsx)(i_,{className:"h-3 w-3 shrink-0 text-primary ml-auto"})]})}),(0,F.jsx)(gL,{side:"right",children:s.name})]},s.id)})})}):(0,F.jsx)("span",{className:"px-3 text-xs text-muted-foreground/60",children:"No projects yet"})]}),(0,F.jsxs)("div",{className:"mt-4 space-y-0.5",children:[(0,F.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70 px-3 mb-2 block",children:"Navigation"}),(0,F.jsxs)("button",{onClick:()=>{d&&(n?.(null),r("tasks"))},disabled:!d,className:(0,iu.cn)("w-full flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs font-medium transition-all duration-150",d?"hover:bg-accent/80 hover:text-accent-foreground":"text-muted-foreground/40 cursor-not-allowed","tasks"===e&&d?"bg-primary/10 text-primary shadow-sm":d?"text-muted-foreground":""),children:[(0,F.jsx)(vO,{className:"h-3 w-3 shrink-0"}),(0,F.jsx)("span",{children:"Tasks"})]}),(0,F.jsxs)("button",{onClick:()=>{d&&r("files")},disabled:!d,className:(0,iu.cn)("w-full flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs font-medium transition-all duration-150",d?"hover:bg-accent/80 hover:text-accent-foreground":"text-muted-foreground/40 cursor-not-allowed","files"===e&&d?"bg-primary/10 text-primary shadow-sm":d?"text-muted-foreground":""),children:[(0,F.jsx)(i_,{className:"h-3 w-3 shrink-0"}),(0,F.jsx)("span",{children:"Files"})]})]}),(0,F.jsxs)("div",{className:"mt-4 space-y-0.5",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-3 mb-2",children:[(0,F.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Workspace"}),o&&(0,F.jsx)("button",{onClick:a,className:"p-0.5 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors text-muted-foreground",title:"Create new worktree",children:(0,F.jsx)(nD,{className:"h-3 w-3"})})]}),s&&s.length>0&&(0,F.jsx)(gD,{delayDuration:300,children:(0,F.jsx)("div",{className:"flex flex-col gap-0.5",children:s.map(s=>(0,F.jsxs)("div",{className:"group relative flex items-center min-w-0",children:[(0,F.jsxs)(gT,{children:[(0,F.jsx)(gP,{asChild:!0,children:(0,F.jsxs)("button",{onClick:()=>{n?.(s.branch),r("workspace")},className:(0,iu.cn)("flex-1 min-w-0 flex items-center gap-2 rounded-lg pl-3 pr-6 py-1.5 text-xs transition-all duration-150 overflow-hidden","hover:bg-accent/80 hover:text-accent-foreground","workspace"===e&&i===s.branch?"bg-primary/10 text-primary font-medium shadow-sm":"text-muted-foreground"),children:[(0,F.jsx)(bH,{status:c?.get(null===s.branch?"":s.branch)}),(0,F.jsx)("span",{className:"truncate",children:s.branch??"main"})]})}),(0,F.jsx)(gL,{side:"right",children:s.branch??"main"})]}),null!==s.branch&&(0,F.jsx)("button",{onClick:e=>{e.stopPropagation(),l?.(s)},className:"absolute right-1.5 p-0.5 rounded-md opacity-0 group-hover:opacity-100 hover:bg-destructive/15 hover:text-destructive transition-all",title:"Delete worktree",children:(0,F.jsx)(ib,{className:"h-3 w-3"})})]},s.branch??"__main__"))})}),(!s||0===s.length)&&(0,F.jsxs)("button",{onClick:()=>r("workspace"),className:(0,iu.cn)("w-full flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-150","hover:bg-accent/80 hover:text-accent-foreground","workspace"===e?"bg-primary/10 text-primary shadow-sm":"text-muted-foreground"),children:[(0,F.jsx)(bF,{className:"h-4 w-4 shrink-0"}),(0,F.jsx)("span",{children:"Workspace"})]})]}),(0,F.jsxs)("div",{className:"mt-auto space-y-0.5",children:[(0,F.jsx)("div",{className:"border-t border-border/40 mb-3"}),(0,F.jsxs)("button",{onClick:()=>r("remote-servers"),className:(0,iu.cn)("w-full flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-150","hover:bg-accent/80 hover:text-accent-foreground","remote-servers"===e?"bg-primary/10 text-primary shadow-sm":"text-muted-foreground"),children:[(0,F.jsx)(iw,{className:"h-4 w-4 shrink-0"}),(0,F.jsx)("span",{children:"Remote Servers"})]}),(0,F.jsxs)("button",{onClick:()=>r("settings"),className:(0,iu.cn)("w-full flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-150","hover:bg-accent/80 hover:text-accent-foreground","settings"===e?"bg-primary/10 text-primary shadow-sm":"text-muted-foreground"),children:[(0,F.jsx)(bW,{className:"h-4 w-4 shrink-0"}),(0,F.jsx)("span",{children:"Settings"})]})]})]})}var il=il,bU="Checkbox",[bq,bV]=q(bU),[bY,bX]=bq(bU);function bG(e){let{__scopeCheckbox:r,checked:s,children:i,defaultChecked:n,disabled:o,form:a,name:l,onCheckedChange:c,required:d,value:h="on",internal_do_not_use_render:u}=e,[f,p]=X({prop:s,defaultProp:n??!1,onChange:c,caller:bU}),[m,g]=W.useState(null),[v,x]=W.useState(null),_=W.useRef(!1),y=!m||!!a||!!m.closest("form"),b={checked:f,disabled:o,setChecked:p,control:m,setControl:g,name:l,form:a,value:h,hasConsumerStoppedPropagationRef:_,required:d,defaultChecked:!b3(n)&&n,isFormControl:y,bubbleInput:v,setBubbleInput:x};return(0,F.jsx)(bY,{scope:r,...b,children:"function"==typeof u?u(b):i})}var bJ="CheckboxTrigger",bZ=W.forwardRef(({__scopeCheckbox:e,onKeyDown:r,onClick:s,...i},n)=>{let{control:o,value:a,disabled:l,checked:c,required:d,setControl:h,setChecked:u,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=bX(bJ,e),g=(0,U.useComposedRefs)(n,h),v=W.useRef(c);return W.useEffect(()=>{let e=o?.form;if(e){let r=()=>u(v.current);return e.addEventListener("reset",r),()=>e.removeEventListener("reset",r)}},[o,u]),(0,F.jsx)(Z.button,{type:"button",role:"checkbox","aria-checked":b3(c)?"mixed":c,"aria-required":d,"data-state":b4(c),"data-disabled":l?"":void 0,disabled:l,value:a,...i,ref:g,onKeyDown:K(r,e=>{"Enter"===e.key&&e.preventDefault()}),onClick:K(s,e=>{u(e=>!!b3(e)||!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});bZ.displayName=bJ;var bQ=W.forwardRef((e,r)=>{let{__scopeCheckbox:s,name:i,checked:n,defaultChecked:o,required:a,disabled:l,value:c,onCheckedChange:d,form:h,...u}=e;return(0,F.jsx)(bG,{__scopeCheckbox:s,checked:n,defaultChecked:o,disabled:l,required:a,onCheckedChange:d,name:i,form:h,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(bZ,{...u,ref:r,__scopeCheckbox:s}),e&&(0,F.jsx)(b5,{__scopeCheckbox:s})]})})});bQ.displayName=bU;var b0="CheckboxIndicator",b1=W.forwardRef((e,r)=>{let{__scopeCheckbox:s,forceMount:i,...n}=e,o=bX(b0,s);return(0,F.jsx)(t8,{present:i||b3(o.checked)||!0===o.checked,children:(0,F.jsx)(Z.span,{"data-state":b4(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:r,style:{pointerEvents:"none",...e.style}})})});b1.displayName=b0;var b2="CheckboxBubbleInput",b5=W.forwardRef(({__scopeCheckbox:e,...r},s)=>{let{control:i,hasConsumerStoppedPropagationRef:n,checked:o,defaultChecked:a,required:l,disabled:c,name:d,value:h,form:u,bubbleInput:f,setBubbleInput:p}=bX(b2,e),m=(0,U.useComposedRefs)(s,p),g=oW(o),v=tW(i);W.useEffect(()=>{if(!f)return;let e=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set,r=!n.current;if(g!==o&&e){let s=new Event("click",{bubbles:r});f.indeterminate=b3(o),e.call(f,!b3(o)&&o),f.dispatchEvent(s)}},[f,g,o,n]);let x=W.useRef(!b3(o)&&o);return(0,F.jsx)(Z.input,{type:"checkbox","aria-hidden":!0,defaultChecked:a??x.current,required:l,disabled:c,name:d,value:h,form:u,...r,tabIndex:-1,ref:m,style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});function b3(e){return"indeterminate"===e}function b4(e){return b3(e)?"indeterminate":e?"checked":"unchecked"}b5.displayName=b2,e.s(["Checkbox",()=>bQ,"CheckboxIndicator",()=>b1,"Indicator",()=>b1,"Root",()=>bQ,"createCheckboxScope",()=>bV,"unstable_BubbleInput",()=>b5,"unstable_CheckboxBubbleInput",()=>b5,"unstable_CheckboxProvider",()=>bG,"unstable_CheckboxTrigger",()=>bZ,"unstable_Provider",()=>bG,"unstable_Trigger",()=>bZ],85402);var b6=e.i(85402),b6=b6;function b8({className:e,...r}){return(0,F.jsx)(b6.Root,{"data-slot":"checkbox",className:(0,iu.cn)("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:(0,F.jsx)(b6.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:(0,F.jsx)(il.default,{className:"size-3.5"})})})}let b7={todo:{label:"To Do",color:"bg-muted text-muted-foreground"},in_progress:{label:"In Progress",color:"bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300"},done:{label:"Done",color:"bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300"},cancelled:{label:"Cancelled",color:"bg-neutral-100 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400 line-through"}},b9={low:{label:"Low",color:"bg-muted text-muted-foreground"},medium:{label:"Medium",color:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/40 dark:text-yellow-300"},high:{label:"High",color:"bg-orange-100 text-orange-800 dark:bg-orange-900/40 dark:text-orange-300"},urgent:{label:"Urgent",color:"bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300"}},we=["todo","in_progress","done","cancelled"],wt=["low","medium","high","urgent"];function wr({task:e,onUpdate:r,onDelete:s,onClick:i,worktrees:n,assignedBranches:o,onAssign:a}){let[l,c]=(0,W.useState)(!1),[d,h]=(0,W.useState)(e.title),u=(0,W.useRef)(null);(0,W.useEffect)(()=>{l&&(u.current?.focus(),u.current?.select())},[l]),(0,W.useEffect)(()=>{h(e.title)},[e.title]);let f=()=>{c(!1);let s=d.trim();s&&s!==e.title?r(e.id,{title:s}):h(e.title)},p="done"===e.status||"cancelled"===e.status;return(0,F.jsxs)(oL,{className:"group cursor-pointer",onClick:()=>i?.(e),children:[(0,F.jsx)(oA,{className:"w-10",onClick:e=>e.stopPropagation(),children:(0,F.jsx)(b8,{checked:"done"===e.status,onCheckedChange:s=>{r(e.id,{status:s?"done":"todo"})}})}),(0,F.jsx)(oA,{className:"font-medium",children:l?(0,F.jsx)("input",{ref:u,className:"w-full bg-transparent border-b border-primary outline-none text-sm py-0.5",value:d,onChange:e=>h(e.target.value),onBlur:f,onClick:e=>e.stopPropagation(),onKeyDown:r=>{"Enter"===r.key&&f(),"Escape"===r.key&&(h(e.title),c(!1))}}):(0,F.jsxs)("div",{children:[(0,F.jsx)("span",{className:`cursor-pointer hover:underline text-sm ${p?"line-through text-muted-foreground":""}`,onClick:e=>{e.stopPropagation(),c(!0)},children:e.title}),e.description&&(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate max-w-[400px] mt-0.5",children:e.description.length>80?e.description.slice(0,80)+"...":e.description})]})}),(0,F.jsx)(oA,{onClick:e=>e.stopPropagation(),children:(0,F.jsxs)(ip,{children:[(0,F.jsx)(im,{asChild:!0,children:(0,F.jsx)("button",{className:"focus:outline-none",children:(0,F.jsx)(ld,{variant:"outline",className:`cursor-pointer text-xs ${b7[e.status].color}`,children:b7[e.status].label})})}),(0,F.jsx)(ig,{align:"start",children:we.map(s=>(0,F.jsxs)(iv,{onClick:()=>r(e.id,{status:s}),children:[(0,F.jsx)("span",{className:`inline-block w-2 h-2 rounded-full mr-2 ${b7[s].color}`}),b7[s].label]},s))})]})}),(0,F.jsx)(oA,{onClick:e=>e.stopPropagation(),children:(0,F.jsxs)(ip,{children:[(0,F.jsx)(im,{asChild:!0,children:(0,F.jsx)("button",{className:"focus:outline-none",children:(0,F.jsx)(ld,{variant:"outline",className:`cursor-pointer text-xs ${b9[e.priority].color}`,children:b9[e.priority].label})})}),(0,F.jsx)(ig,{align:"start",children:wt.map(s=>(0,F.jsxs)(iv,{onClick:()=>r(e.id,{priority:s}),children:[(0,F.jsx)("span",{className:`inline-block w-2 h-2 rounded-full mr-2 ${b9[s].color}`}),b9[s].label]},s))})]})}),(0,F.jsx)(oA,{onClick:e=>e.stopPropagation(),children:(0,F.jsxs)(ip,{children:[(0,F.jsx)(im,{asChild:!0,children:(0,F.jsx)("button",{className:"focus:outline-none",children:(0,F.jsxs)(ld,{variant:"outline",className:`cursor-pointer text-xs ${null!==e.assigned_branch?"bg-blue-500/10 text-blue-600 border-blue-500/30":"text-muted-foreground"}`,children:[(0,F.jsx)(aV,{className:"h-3 w-3 mr-1"}),null!==e.assigned_branch?""===e.assigned_branch?"main":e.assigned_branch:"Unassigned"]})})}),(0,F.jsxs)(ig,{align:"start",children:[null!==e.assigned_branch&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(iv,{onClick:()=>a(e.id,null),children:"Unassign"}),(0,F.jsx)(ix,{})]}),n.filter(r=>{let s=null===r.branch?"":r.branch;return!(e.assigned_branch===s||o.has(s))}).map(r=>{let s=null===r.branch?"":r.branch,i=r.branch??"main";return(0,F.jsxs)(iv,{onClick:()=>a(e.id,s),children:[(0,F.jsx)(aV,{className:"h-3 w-3 mr-2"}),i]},s)})]})]})}),(0,F.jsx)(oA,{className:"text-muted-foreground text-xs",children:new Date(e.created_at).toLocaleDateString()}),(0,F.jsx)(oA,{className:"w-10",onClick:e=>e.stopPropagation(),children:(0,F.jsx)($.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>s(e.id),children:(0,F.jsx)(ib,{className:"h-3.5 w-3.5 text-muted-foreground"})})})]})}function ws({task:e,open:r,onOpenChange:s}){return e?(0,F.jsx)(ns,{open:r,onOpenChange:s,children:(0,F.jsxs)(no,{className:"sm:max-w-lg",children:[(0,F.jsx)(na,{children:(0,F.jsx)(nc,{className:"text-base leading-snug",children:e.title})}),(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(ld,{variant:"outline",className:`text-xs ${b7[e.status].color}`,children:b7[e.status].label}),(0,F.jsx)(ld,{variant:"outline",className:`text-xs ${b9[e.priority].color}`,children:b9[e.priority].label})]}),e.description&&(0,F.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:e.description}),(0,F.jsxs)("div",{className:"flex gap-4 text-xs text-muted-foreground pt-2 border-t",children:[(0,F.jsxs)("span",{children:["Created: ",new Date(e.created_at).toLocaleString()]}),(0,F.jsxs)("span",{children:["Updated: ",new Date(e.updated_at).toLocaleString()]})]})]})]})}):null}let wi={todo:0,in_progress:1,done:2,cancelled:3},wn={urgent:0,high:1,medium:2,low:3};function wo({tasks:e,onUpdate:r,onDelete:s,worktrees:i,onAssign:n}){let[o,a]=(0,W.useState)(null),[l,c]=(0,W.useState)("asc"),[d,h]=(0,W.useState)(null),[u,f]=(0,W.useState)(!1),p=e=>{o===e?c(e=>"asc"===e?"desc":"asc"):(a(e),c("asc"))},m=(0,W.useMemo)(()=>{if(!o)return e;let r="asc"===l?1:-1;return[...e].sort((e,s)=>{switch(o){case"title":return r*e.title.localeCompare(s.title);case"status":return r*(wi[e.status]-wi[s.status]);case"priority":return r*(wn[e.priority]-wn[s.priority]);case"created_at":return r*(new Date(e.created_at).getTime()-new Date(s.created_at).getTime());default:return 0}})},[e,o,l]),g=e=>o!==e?null:"asc"===l?" ↑":" ↓",v=(0,W.useMemo)(()=>new Set(e.filter(e=>null!==e.assigned_branch).map(e=>e.assigned_branch)),[e]);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(oD,{children:[(0,F.jsx)(oT,{children:(0,F.jsxs)(oL,{children:[(0,F.jsx)(oB,{className:"w-10"}),(0,F.jsxs)(oB,{className:"cursor-pointer select-none",onClick:()=>p("title"),children:["Title",g("title")]}),(0,F.jsxs)(oB,{className:"cursor-pointer select-none w-32",onClick:()=>p("status"),children:["Status",g("status")]}),(0,F.jsxs)(oB,{className:"cursor-pointer select-none w-28",onClick:()=>p("priority"),children:["Priority",g("priority")]}),(0,F.jsx)(oB,{className:"w-32",children:"Assign"}),(0,F.jsxs)(oB,{className:"cursor-pointer select-none w-28",onClick:()=>p("created_at"),children:["Created",g("created_at")]}),(0,F.jsx)(oB,{className:"w-10"})]})}),(0,F.jsxs)(oP,{children:[m.map(e=>(0,F.jsx)(wr,{task:e,onUpdate:r,onDelete:s,onClick:e=>{h(e),f(!0)},worktrees:i,assignedBranches:v,onAssign:n},e.id)),0===e.length&&(0,F.jsx)(oL,{children:(0,F.jsx)("td",{colSpan:7,className:"text-center text-muted-foreground py-12 text-sm",children:(0,F.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-foreground/60",children:"No tasks yet"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"Create one to get started."})]})})})]})]}),(0,F.jsx)(ws,{task:d,open:u,onOpenChange:f})]})}function wa({open:e,onOpenChange:r,onSubmit:s}){let[i,n]=(0,W.useState)(""),[o,a]=(0,W.useState)("todo"),[l,c]=(0,W.useState)("medium");return(0,F.jsx)(ns,{open:e,onOpenChange:r,children:(0,F.jsxs)(no,{className:"sm:max-w-md max-h-[85vh] flex flex-col",children:[(0,F.jsx)(na,{children:(0,F.jsx)(nc,{children:"Create Task"})}),(0,F.jsxs)("form",{onSubmit:e=>{e.preventDefault(),i.trim()&&(s({description:i.trim(),status:o,priority:l}),n(""),a("todo"),c("medium"),r(!1))},className:"space-y-4 overflow-y-auto min-h-0 px-0.5",children:[(0,F.jsx)("div",{className:"space-y-2",children:(0,F.jsx)(nu,{placeholder:"Describe the task...",value:i,onChange:e=>n(e.target.value),className:"max-h-[40vh]",rows:3,autoFocus:!0})}),(0,F.jsxs)("div",{className:"flex gap-3",children:[(0,F.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Status"}),(0,F.jsxs)(aB,{value:o,onValueChange:e=>a(e),children:[(0,F.jsx)(aO,{children:(0,F.jsx)(aA,{})}),(0,F.jsx)(aI,{children:we.map(e=>(0,F.jsx)(az,{value:e,children:b7[e].label},e))})]})]}),(0,F.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Priority"}),(0,F.jsxs)(aB,{value:l,onValueChange:e=>c(e),children:[(0,F.jsx)(aO,{children:(0,F.jsx)(aA,{})}),(0,F.jsx)(aI,{children:wt.map(e=>(0,F.jsx)(az,{value:e,children:b9[e].label},e))})]})]})]}),(0,F.jsxs)(nl,{children:[(0,F.jsx)($.Button,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,F.jsx)($.Button,{type:"submit",disabled:!i.trim(),children:"Create"})]})]})]})})}function wl({projectId:e,tasks:r,loading:s,worktrees:i,onCreateTask:n,onUpdateTask:o,onDeleteTask:a}){let[l,c]=(0,W.useState)(!1);return e?(0,F.jsxs)("div",{className:"flex flex-col h-full",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border/60 flex-shrink-0",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Tasks"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Manage and track your project tasks"})]}),(0,F.jsxs)($.Button,{size:"sm",onClick:()=>c(!0),className:"shadow-sm",children:[(0,F.jsx)(nD,{className:"h-3.5 w-3.5 mr-1.5"}),"New Task"]})]}),(0,F.jsx)("div",{className:"flex-1 overflow-auto px-5",children:s?(0,F.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading tasks..."}):(0,F.jsx)(wo,{tasks:r,onUpdate:o,onDelete:a,worktrees:i,onAssign:(e,r)=>{o(e,{assigned_branch:r})}})}),(0,F.jsx)(wa,{open:l,onOpenChange:c,onSubmit:n})]}):(0,F.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(nD,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to view tasks."})]})})}let wc=(0,ic.default)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]),wd=(0,ic.default)("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),wh=new Set(["ts","tsx","js","jsx","py","rb","go","rs","java","c","cpp","h","css","scss","html","vue","svelte","php","swift","kt","sh","bash","yaml","yml","toml","json","xml","sql","graphql","proto"]),wu=new Set(["md","txt","log","csv","env","gitignore","dockerignore","editorconfig"]);function wf({path:e}){let[r,s]=(0,W.useState)(!1),i=(0,W.useCallback)(r=>{r.stopPropagation(),navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),1500)},[e]);return(0,F.jsx)("button",{onClick:i,className:"p-0.5 rounded hover:bg-muted-foreground/20 transition-colors",title:`Copy path: ${e}`,children:r?(0,F.jsx)(iM.Check,{className:"h-3 w-3 text-green-500"}):(0,F.jsx)(iR.Copy,{className:"h-3 w-3 text-muted-foreground"})})}function wp({entry:e,path:r,depth:s,expandedDirs:i,directoryContents:n,loadingDirs:o,selectedFile:a,onToggleDirectory:l,onSelectFile:c}){var d,h,u;let f,p,m,g,v,x=i.has(r),_=o.has(r),y=n.get(r);if("directory"===e.type){let d=x?i_:oh;return(0,F.jsxs)("div",{children:[(0,F.jsxs)("div",{className:"group flex items-center w-full px-2 py-1 text-sm rounded-sm hover:bg-accent transition-colors cursor-pointer",style:{paddingLeft:`${16*s+8}px`},onClick:()=>l(r),children:[(0,F.jsxs)("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[_?(0,F.jsx)(iD,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,F.jsx)(x?aL:id,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,F.jsx)(d,{className:"h-4 w-4 shrink-0 text-blue-500"}),(0,F.jsx)("span",{className:"truncate",children:e.name})]}),(0,F.jsx)("div",{className:"shrink-0 hidden group-hover:block ml-1",children:(0,F.jsx)(wf,{path:r})})]}),x&&y&&(0,F.jsx)("div",{children:y.map(e=>{let d=r?`${r}/${e.name}`:e.name;return(0,F.jsx)(wp,{entry:e,path:d,depth:s+1,expandedDirs:i,directoryContents:n,loadingDirs:o,selectedFile:a,onToggleDirectory:l,onSelectFile:c},d)})})]})}let b=(d=e.name,f=d.split(".").pop()?.toLowerCase()??"",wh.has(f)?wd:wu.has(f)?vI:wc),w=a===r;return(0,F.jsxs)("div",{className:(0,iu.cn)("group flex items-center w-full px-2 py-1 text-sm rounded-sm transition-colors cursor-pointer",w?"bg-accent text-accent-foreground":"hover:bg-accent/50"),style:{paddingLeft:`${16*s+8+18}px`},onClick:()=>c(r),children:[(0,F.jsxs)("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[(0,F.jsx)(b,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsx)("span",{className:"truncate",children:e.name})]}),(0,F.jsxs)("div",{className:"shrink-0 flex items-center gap-2 ml-1",children:[(0,F.jsx)("span",{className:"text-[11px] text-muted-foreground/70 group-hover:hidden whitespace-nowrap w-[52px] text-right tabular-nums",children:e.mtime&&(h=e.mtime,p=Date.now(),v=Math.floor((g=Math.floor((m=Math.floor(Math.floor((p-new Date(h).getTime())/1e3)/60))/60))/24),m<1?"just now":m<60?`${m}m ago`:g<24?`${g}h ago`:v<30?`${v}d ago`:new Date(h).toLocaleDateString(void 0,{month:"short",day:"numeric"}))}),(0,F.jsx)("span",{className:"text-[11px] text-muted-foreground/70 group-hover:hidden whitespace-nowrap w-[52px] text-right tabular-nums",children:null!=e.size&&((u=e.size)<1024?`${u} B`:u<1048576?`${(u/1024).toFixed(1)} KB`:`${(u/1048576).toFixed(1)} MB`)}),(0,F.jsx)("div",{className:"hidden group-hover:block",children:(0,F.jsx)(wf,{path:r})})]})]})}function wm({entries:e,expandedDirs:r,directoryContents:s,loadingDirs:i,selectedFile:n,onToggleDirectory:o,onSelectFile:a}){return 0===e.length?(0,F.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-sm",children:"No files found."}):(0,F.jsx)("div",{className:"py-1",children:e.map(e=>{let l=e.name;return(0,F.jsx)(wp,{entry:e,path:l,depth:0,expandedDirs:r,directoryContents:s,loadingDirs:i,selectedFile:n,onToggleDirectory:o,onSelectFile:a},l)})})}var wg=e.i(166520);let wv=(0,ic.default)("file-exclamation-point",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var il=il,wx=e.i(829692),wx=wx,w_=e.i(615742);let wy=(0,W.createContext)({code:""}),wb={name:"line-numbers",line(e,r){e.children.unshift({type:"element",tagName:"span",properties:{className:["inline-block","min-w-10","mr-4","text-right","select-none","text-muted-foreground"]},children:[{type:"text",value:String(r)}]})}};async function ww(e,r,s=!1){let i=s?[wb]:[];return await Promise.all([(0,w_.codeToHtml)(e,{lang:r,theme:"one-light",transformers:i}),(0,w_.codeToHtml)(e,{lang:r,theme:"one-dark-pro",transformers:i})])}let wS=({code:e,language:r,showLineNumbers:s=!1,className:i,children:n,...o})=>{let[a,l]=(0,W.useState)(""),[c,d]=(0,W.useState)(""),h=(0,W.useRef)(!1);return(0,W.useEffect)(()=>(ww(e,r,s).then(([e,r])=>{h.current||(l(e),d(r),h.current=!0)}),()=>{h.current=!1}),[e,r,s]),(0,F.jsx)(wy.Provider,{value:{code:e},children:(0,F.jsx)("div",{className:(0,iu.cn)("group relative w-full overflow-hidden rounded-md border bg-background text-foreground",i),...o,children:(0,F.jsxs)("div",{className:"relative",children:[(0,F.jsx)("div",{className:"overflow-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",dangerouslySetInnerHTML:{__html:a}}),(0,F.jsx)("div",{className:"hidden overflow-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",dangerouslySetInnerHTML:{__html:c}}),n&&(0,F.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})})},wC=({onCopy:e,onError:r,timeout:s=2e3,children:i,className:n,...o})=>{let[a,l]=(0,W.useState)(!1),{code:c}=(0,W.useContext)(wy),d=async()=>{if(!navigator?.clipboard?.writeText)return void r?.(Error("Clipboard API not available"));try{await navigator.clipboard.writeText(c),l(!0),e?.(),setTimeout(()=>l(!1),s)}catch(e){r?.(e)}},h=a?il.default:wx.default;return(0,F.jsx)($.Button,{className:(0,iu.cn)("shrink-0",n),onClick:d,size:"icon",variant:"ghost",...o,children:i??(0,F.jsx)(h,{size:14})})};function wk({className:e,...r}){return(0,F.jsx)("div",{"data-slot":"skeleton",className:(0,iu.cn)("bg-accent animate-pulse rounded-md",e),...r})}let wj={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",cs:"csharp",css:"css",scss:"scss",html:"html",vue:"vue",svelte:"svelte",php:"php",swift:"swift",kt:"kotlin",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",toml:"toml",json:"json",xml:"xml",sql:"sql",graphql:"graphql",md:"markdown",mdx:"mdx",dockerfile:"dockerfile",makefile:"makefile",lua:"lua",r:"r",scala:"scala",zig:"zig"};function wN(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function wE({filePath:e,fileContent:r,loading:s,downloadUrl:i}){let n;if(!e)return(0,F.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Select a file to preview."});if(s)return(0,F.jsxs)("div",{className:"flex flex-col h-full",children:[(0,F.jsx)("div",{className:"flex items-center justify-between px-4 py-2 border-b flex-shrink-0",children:(0,F.jsx)(wk,{className:"h-4 w-48"})}),(0,F.jsxs)("div",{className:"flex-1 p-4",children:[(0,F.jsx)(wk,{className:"h-4 w-full mb-2"}),(0,F.jsx)(wk,{className:"h-4 w-3/4 mb-2"}),(0,F.jsx)(wk,{className:"h-4 w-5/6 mb-2"}),(0,F.jsx)(wk,{className:"h-4 w-2/3"})]})]});if(!r)return(0,F.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Failed to load file."});let o=()=>{i&&window.open(i,"_blank")};return(0,F.jsxs)("div",{className:"flex flex-col h-full",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b flex-shrink-0 gap-2",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,F.jsx)("span",{className:"text-sm font-mono truncate",children:e}),(0,F.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:wN(r.size)})]}),(0,F.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,F.jsx)($.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(e)},title:"Copy path",children:(0,F.jsx)(iR.Copy,{className:"h-3.5 w-3.5"})}),i&&(0,F.jsx)($.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:o,title:"Download",children:(0,F.jsx)(wg.Download,{className:"h-3.5 w-3.5"})})]})]}),(0,F.jsx)("div",{className:"flex-1 overflow-auto",children:r.tooLarge?(0,F.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[(0,F.jsx)(wv,{className:"h-10 w-10"}),(0,F.jsxs)("p",{className:"text-sm",children:["File too large to preview (",wN(r.size),")"]}),i&&(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:o,children:[(0,F.jsx)(wg.Download,{className:"h-4 w-4 mr-2"}),"Download"]})]}):r.binary?(0,F.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[(0,F.jsx)(wv,{className:"h-10 w-10"}),(0,F.jsxs)("p",{className:"text-sm",children:["Binary file (",wN(r.size),")"]}),i&&(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:o,children:[(0,F.jsx)(wg.Download,{className:"h-4 w-4 mr-2"}),"Download"]})]}):null!==r.content?(0,F.jsx)(wS,{code:r.content,language:"dockerfile"===(n=e.split("/").pop()?.toLowerCase()??"")?"dockerfile":"makefile"===n?"makefile":wj[n.split(".").pop()?.toLowerCase()??""]??"text",showLineNumbers:!0,className:"border-0 rounded-none",children:(0,F.jsx)(wC,{})}):(0,F.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Empty file."})})]})}function wR({projectId:e,project:r,selectedBranch:s}){let i=r&&!r.path?"remote":void 0,{rootEntries:n,directoryContents:o,expandedDirs:a,selectedFile:l,fileContent:c,fileLoading:d,rootLoading:h,loadingDirs:u,fetchRoot:f,toggleDirectory:p,selectFile:m}=function({projectId:e,branch:r,target:s}){let[i,n]=(0,W.useState)([]),[o,a]=(0,W.useState)(new Map),[l,c]=(0,W.useState)(new Set),[d,h]=(0,W.useState)(null),[u,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(!1),[g,v]=(0,W.useState)(!1),[x,_]=(0,W.useState)(new Set),y=(0,W.useRef)(0),b=(0,W.useCallback)(async()=>{if(!e)return;v(!0);let i=++y.current;try{let o=await iT.api.browseProjectDirectory(e,void 0,r,s);if(i!==y.current)return;n(o.items),a(new Map),c(new Set),h(null),f(null)}catch(e){if(console.error("Failed to browse root directory:",e),i!==y.current)return;n([])}finally{i===y.current&&v(!1)}},[e,r,s]),w=(0,W.useCallback)(async i=>{if(e&&(c(e=>{let r=new Set(e);return r.has(i)?r.delete(i):r.add(i),r}),!o.has(i))){_(e=>new Set(e).add(i));try{let n=await iT.api.browseProjectDirectory(e,i,r,s);a(e=>{let r=new Map(e);return r.set(i,n.items),r})}catch(e){console.error("Failed to browse directory:",e)}finally{_(e=>{let r=new Set(e);return r.delete(i),r})}}},[e,r,s,o]);return{rootEntries:i,directoryContents:o,expandedDirs:l,selectedFile:d,fileContent:u,fileLoading:p,rootLoading:g,loadingDirs:x,fetchRoot:b,toggleDirectory:w,selectFile:(0,W.useCallback)(async i=>{if(e){h(i),m(!0),f(null);try{let n=await iT.api.getFileContent(e,i,r,s);f(n)}catch(e){console.error("Failed to get file content:",e),f(null)}finally{m(!1)}}},[e,r,s])}}({projectId:e,branch:s,target:i});if((0,W.useEffect)(()=>{f()},[f]),!e)return(0,F.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(mQ,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to browse files."})]})});let g=l&&e?iT.api.getFileDownloadUrl(e,l,s,i):null;return(0,F.jsxs)("div",{className:"flex flex-col h-full",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border/60 flex-shrink-0",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Files"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Browse and preview project files"})]}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:f,title:"Refresh",children:(0,F.jsx)(mQ,{className:`h-3.5 w-3.5 ${h?"animate-spin":""}`})})]}),(0,F.jsxs)(bI,{direction:"horizontal",autoSaveId:"files-panels",className:"flex-1",children:[(0,F.jsx)(yW,{defaultSize:33,minSize:20,children:(0,F.jsx)(oc,{className:"h-full",children:h&&0===n.length?(0,F.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading files..."}):(0,F.jsx)(wm,{entries:n,expandedDirs:a,directoryContents:o,loadingDirs:u,selectedFile:l,onToggleDirectory:p,onSelectFile:m})})}),(0,F.jsx)(bz,{withHandle:!0}),(0,F.jsx)(yW,{defaultSize:67,minSize:25,children:(0,F.jsx)("div",{className:"h-full overflow-hidden",children:(0,F.jsx)(wE,{filePath:l,fileContent:c,loading:d,downloadUrl:g})})})]})]})}let wM=new Set(["workspace","tasks","files","remote-servers","settings","project-info"]),wD="tasks";function wT(){let e=window.location.pathname,r=new URLSearchParams(window.location.search),s=r.get("project");if(s){let e=r.get("tab");return{projectId:s,tab:e&&wM.has(e)?e:wD,branch:r.get("branch")}}let i=e.split("/").filter(Boolean);if(1===i.length&&wM.has(i[0])){let e=i[0];if("remote-servers"===e||"settings"===e)return{projectId:null,tab:e,branch:null}}let n=null,o=wD;if("p"===i[0]&&i[1]){n=i[1];let e=i[2];e&&wM.has(e)&&(o=e)}return{projectId:n,tab:o,branch:r.get("branch")}}function wP(e){let{projectId:r,tab:s,branch:i}=e;if("remote-servers"===s||"settings"===s)return`/${s}`;if(!r)return"/";let n=`/p/${r}`;return s&&s!==wD&&(n+=`/${s}`),i&&(n+=`?branch=${encodeURIComponent(i)}`),n}function wL(e){return null===e?"":e}function wB(e,r){let s=new Map(e);return s.set(wL(r),"working"),s}function wA(e,r){let s=new Map(e);return s.delete(wL(r)),s}function wO(){var e,r;let s,i,n,{projectId:o,tab:a,branch:l}=function(){let[e,r]=(0,W.useState)(wT);return(0,W.useEffect)(()=>{let e=()=>r(wT());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]),e}();(0,W.useEffect)(()=>{if(new URLSearchParams(window.location.search).has("project")){let e=wP({projectId:o,tab:a,branch:l});window.history.replaceState(null,"",e)}},[]);let[c,d]=(0,W.useState)(!1),[h,u]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1),[m,g]=(0,W.useState)(null),[v,x]=(0,W.useState)(l),[_,y]=(0,W.useState)(a),b=(0,W.useRef)(null),w=(0,W.useRef)(void 0),[S,C]=(0,W.useTransition)(),{projects:k,currentProject:j,loading:N,addProject:E,createProject:R,updateProject:M,deleteProject:D,selectProject:T}=function(e){let[r,s]=(0,W.useState)([]),[i,n]=(0,W.useState)(null),[o,a]=(0,W.useState)(!0),l=(0,W.useCallback)(async()=>{a(!0);try{let r=await iT.api.getProjects();if(s(r),r.length>0&&!i){let s=e?r.find(r=>r.id===e):null;n(s??r[0])}}finally{a(!1)}},[i,e]);(0,W.useEffect)(()=>{l()},[]);let c=async(e,r)=>{let o=await iT.api.updateProject(e,r);return s(r=>r.map(r=>r.id===e?o:r)),i?.id===e&&n(o),o},d=async e=>{await iT.api.deleteProject(e),s(r=>r.filter(r=>r.id!==e)),i?.id===e&&n(r.find(r=>r.id!==e)??null)};return{projects:r,currentProject:i,loading:o,addProject:e=>{s(r=>[e,...r]),n(e)},createProject:async e=>{let r=await iT.api.createProject(e);return s(e=>[r,...e]),n(r),r},updateProject:c,deleteProject:d,selectProject:e=>{n(e)},refresh:l}}(o),{worktrees:P,loading:L,refetch:B}=function(e){let[r,s]=(0,W.useState)([]),[i,n]=(0,W.useState)(!0),o=(0,W.useCallback)(async()=>{if(!e){s([]),n(!1);return}try{let r=await iT.api.getProjectWorktrees(e);s(r)}catch(e){console.error("Failed to fetch worktrees:",e),s([{branch:null}])}finally{n(!1)}},[e]);return(0,W.useEffect)(()=>{o()},[o]),{worktrees:r,loading:i,refetch:o}}(j?.id??null),{tasks:A,loading:O,createTask:I,updateTask:z,deleteTask:H,refetch:K}=function(e){let[r,s]=(0,W.useState)([]),[i,n]=(0,W.useState)(!0),o=(0,W.useCallback)(async()=>{if(!e){s([]),n(!1);return}try{let r=await iT.api.getTasks(e);s(r)}catch(e){console.error("Failed to fetch tasks:",e)}finally{n(!1)}},[e]);(0,W.useEffect)(()=>{o()},[o]);let a=(0,W.useCallback)(async r=>{if(!e)return null;try{let i=await iT.api.createTask(e,r);return s(e=>[...e,i]),i}catch(e){return console.error("Failed to create task:",e),null}},[e]),l=(0,W.useCallback)(async(e,i)=>{s(r=>r.map(r=>r.id===e?{...r,...i,updated_at:new Date().toISOString()}:r));try{let r=await iT.api.updateTask(e,i);return s(s=>s.map(s=>s.id===e?r:s)),r}catch(e){return console.error("Failed to update task:",e),s(r),null}},[r]),c=(0,W.useCallback)(async e=>{s(r=>r.filter(r=>r.id!==e));try{await iT.api.deleteTask(e)}catch(e){console.error("Failed to delete task:",e),s(r)}},[r]),d=(0,W.useCallback)(async i=>{if(e){s(i.map(e=>r.find(r=>r.id===e)).filter(e=>void 0!==e));try{await iT.api.reorderTasks(e,i)}catch(e){console.error("Failed to reorder tasks:",e),s(r)}}},[e,r]);return{tasks:r,loading:i,createTask:a,updateTask:l,deleteTask:c,reorderTasks:d,refetch:o}}(j?.id??null),{statuses:U,refetch:q}=function(e){let[r,s]=(0,W.useState)(new Map),i=(0,W.useRef)(null),n=(0,W.useCallback)(async()=>{if(!e)return void s(new Map);try{let r={},i=(0,iT.getAuthToken)();i&&(r.Authorization=`Bearer ${i}`);let n=await fetch(`${"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}/api/projects/${e}/agent-sessions`,{headers:r});if(!n.ok)return;let o=await n.json(),a=new Map;for(let e of o.sessions)a.has(e.branch)&&"running"!==e.status||a.set(e.branch,e.status);s(a)}catch{}},[e]);return(0,W.useEffect)(()=>(n(),i.current=setInterval(n,5e3),()=>{i.current&&clearInterval(i.current)}),[n]),{statuses:r,refetch:n,updateStatus:(0,W.useCallback)((e,r)=>{s(s=>{let i=new Map(s);return i.set(e,r),i})},[])}}(j?.id??null),[V,Y]=(0,W.useState)(new Map),X=(0,W.useMemo)(()=>(function(e,r,s,i,n){let o=new Map;if(!e)return o;let a=wL(n);for(let n of e){let e=wL(n.branch),l=r.get(e);if(void 0!==l){o.set(e,l);continue}let c=e===a?void 0:s.get(e),d=i.find(r=>r.assigned_branch===e);d&&"done"===d.status?o.set(e,"completed"):"running"===c?o.set(e,"working"):d?o.set(e,"assigned"):o.set(e,"idle")}return o})(P,V,U,A,v),[P,U,A,v,V]),G=(0,W.useCallback)(()=>{Y(e=>wB(e,v))},[v]),J=(0,W.useCallback)(()=>{Y(e=>{let r;return(r=new Map(e)).set(wL(v),"completed"),r}),K(),q()},[v,K,q]),Z=(0,W.useCallback)(()=>{q()},[q]),Q=(0,W.useCallback)((e,r)=>{Y(s=>{let i="running"===r?{realtimeStatuses:wB(s,e),shouldRefetchTasks:!1}:{realtimeStatuses:wA(s,e),shouldRefetchTasks:!0};return i.shouldRefetchTasks&&K(),i.realtimeStatuses}),q()},[q,K]),ee=(0,W.useCallback)(e=>{Y(r=>wA(r,e)),K(),q()},[K,q]),et=(0,W.useCallback)(()=>{K()},[K]);e=j?.id??null,r={onSessionStatus:Q,onSessionFinished:ee,onTaskChanged:et},s=(0,W.useRef)(r.onSessionStatus),i=(0,W.useRef)(r.onSessionFinished),n=(0,W.useRef)(r.onTaskChanged),(0,W.useEffect)(()=>{s.current=r.onSessionStatus,i.current=r.onSessionFinished,n.current=r.onTaskChanged}),(0,W.useEffect)(()=>{if(!e)return;let r=(0,iT.getAuthToken)(),o=r?`?token=${encodeURIComponent(r)}`:"",a=new EventSource(`${"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}/api/events${o}`);return a.onmessage=r=>{try{let o=JSON.parse(r.data);if(o.projectId!==e)return;"session:status"===o.type?s.current?.(o.branch,o.status):"session:finished"===o.type?i.current?.(o.branch):("task:created"===o.type||"task:updated"===o.type||"task:deleted"===o.type)&&n.current?.()}catch{}},()=>{a.close()}},[e]);let er=(0,W.useMemo)(()=>{let e=wL(v);return A.find(r=>r.assigned_branch===e)??null},[A,v]),es=(0,W.useCallback)(e=>{C(async()=>{await b.current?.submitMessage(e.description??e.title)})},[]),ei=(0,W.useCallback)(e=>{Y(e=>wA(e,v)),z(e,{assigned_branch:null})},[v,z]);(0,W.useEffect)(()=>{void 0!==w.current&&w.current!==j?.id&&x(null),w.current=j?.id},[j?.id]),(0,W.useEffect)(()=>{!L&&0!==P.length&&(P.some(e=>e.branch===v)||x(P[0].branch))},[P,L,v]),(0,W.useEffect)(()=>{if(N)return;let e=wP({projectId:j?.id,tab:_,branch:v});window.history.replaceState(null,"",e)},[j?.id,_,v,N]);let en=(0,W.useCallback)(e=>{B(),x(e)},[B]),eo=(0,W.useCallback)((e,r)=>{j&&r!==j.agent_mode?M(j.id,{agentMode:r}).then(()=>{b.current?.submitMessage(e)}):b.current?.submitMessage(e)},[j,M]),ea=(0,W.useCallback)(()=>{let e=`Please perform the following git operations for this worktree:
23
+
24
+ 1. Commit all current uncommitted changes with an appropriate commit message
25
+ 2. Fetch the latest changes from the remote main branch
26
+ 3. Rebase the current branch onto main (resolve any conflicts if needed)
27
+ 4. Merge the current branch into main
28
+
29
+ Please proceed step by step and let me know if there are any issues or conflicts that need manual resolution.`;b.current?.submitMessage(e)},[]),el=(0,W.useCallback)(async e=>{if(j)try{await M(j.id,{agentMode:e})}catch(e){console.error("Failed to update agent mode:",e)}},[j,M]),ec=(0,W.useCallback)(async e=>{if(j)try{await M(j.id,{executorMode:e})}catch(e){console.error("Failed to update executor mode:",e)}},[j,M]),ed=!j;return(0,F.jsxs)("div",{className:"h-screen flex flex-col w-full",children:[(0,F.jsxs)("div",{className:"border-b border-border/60 bg-card/80 backdrop-blur-sm px-4 h-12 flex items-center justify-between sticky top-0 z-10",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)("div",{className:"h-6 w-6 rounded-md bg-primary flex items-center justify-center",children:(0,F.jsx)("span",{className:"text-[10px] font-bold text-primary-foreground tracking-tighter",children:"VDX"})}),(0,F.jsx)("h1",{className:"text-sm font-semibold tracking-tight text-foreground",children:"VibeDeckX"})]}),(0,F.jsx)(aq,{})]}),(0,F.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,F.jsx)(bK,{activeView:_,onViewChange:y,worktrees:P,selectedBranch:v,onBranchChange:x,currentProject:j,onCreateWorktreeOpen:()=>u(!0),onDeleteWorktree:e=>{g(e),p(!0)},workspaceStatuses:X,hasProject:!ed,projects:k,onSelectProject:T,onCreateProjectOpen:()=>d(!0)}),(0,F.jsx)("div",{className:ed&&("workspace"===_||"tasks"===_||"files"===_||"project-info"===_)?"flex-1 overflow-hidden":"hidden",children:(0,F.jsx)("div",{className:"h-full flex items-center justify-center bg-background",children:(0,F.jsxs)("div",{className:"text-center space-y-6",children:[(0,F.jsx)("div",{className:"mx-auto w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center",children:(0,F.jsx)(nD,{className:"h-8 w-8 text-primary"})}),(0,F.jsx)("h1",{className:"text-3xl font-bold tracking-tight text-foreground",children:"Welcome to VibeDeckX"}),(0,F.jsx)("p",{className:"text-muted-foreground max-w-sm mx-auto leading-relaxed",children:"Create your first project to get started with AI-powered development."}),(0,F.jsxs)($.Button,{size:"lg",onClick:()=>d(!0),className:"shadow-md",children:[(0,F.jsx)(nD,{className:"h-5 w-5 mr-2"}),"Create Project"]})]})})}),(0,F.jsx)("div",{className:"workspace"!==_||ed?"hidden":"flex-1 overflow-hidden flex",children:(0,F.jsxs)(bI,{direction:"horizontal",autoSaveId:"workspace-panels",children:[(0,F.jsx)(yW,{defaultSize:33,minSize:25,children:(0,F.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[j&&(0,F.jsx)("div",{className:"px-4 py-3 border-b border-border/60 flex-shrink-0",children:(0,F.jsx)(oC,{project:j,selectedBranch:v,onUpdateProject:M,onDeleteProject:D,onSyncPrompt:eo,assignedTask:er,onStartTask:es,onResetTask:ei,startingTask:S})}),(0,F.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,F.jsx)(yR,{projectId:j?.id??null,branch:v})})]})}),(0,F.jsx)(bz,{withHandle:!0}),(0,F.jsx)(yW,{defaultSize:67,minSize:25,children:(0,F.jsx)("div",{className:"h-full flex flex-col overflow-hidden",children:(0,F.jsx)(gH,{projectId:j?.id??null,selectedBranch:v,onMergeRequest:ea,project:j,onExecutorModeChange:ec,agentSlot:(0,F.jsx)(yy,{ref:b,projectId:j?.id??null,branch:v,project:j,onAgentModeChange:el,onTaskCompleted:J,onSessionStarted:Z,onStatusChange:G})})})})]})}),(0,F.jsx)("div",{className:"tasks"!==_||ed?"hidden":"flex-1 overflow-hidden",children:(0,F.jsx)(wl,{projectId:j?.id??null,tasks:A,loading:O,worktrees:P,onCreateTask:I,onUpdateTask:z,onDeleteTask:H})}),(0,F.jsx)("div",{className:"files"!==_||ed?"hidden":"flex-1 overflow-hidden",children:(0,F.jsx)(wR,{projectId:j?.id??null,project:j,selectedBranch:v})}),(0,F.jsx)("div",{className:"project-info"!==_||ed?"hidden":"flex-1 overflow-hidden",children:j&&(0,F.jsx)(oj,{project:j,onProjectUpdated:M})}),(0,F.jsx)("div",{className:"remote-servers"!==_?"hidden":"flex-1 overflow-hidden",children:(0,F.jsxs)("div",{className:"h-full flex flex-col overflow-auto",children:[(0,F.jsxs)("div",{className:"border-b border-border/60 px-6 py-4 flex-shrink-0",children:[(0,F.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Remote Servers"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Manage your remote server connections"})]}),(0,F.jsx)("div",{className:"flex-1 px-6 py-5 flex justify-center",children:(0,F.jsx)("div",{className:"w-full max-w-2xl",children:(0,F.jsx)(oF,{})})})]})}),(0,F.jsx)("div",{className:"settings"!==_?"hidden":"flex-1 overflow-hidden",children:(0,F.jsx)(oM,{})})]}),j&&(0,F.jsx)(aH,{projectId:j.id,project:j,open:h,onOpenChange:u,onWorktreeCreated:en}),(0,F.jsx)(oN,{open:c,onOpenChange:d,onProjectCreated:e=>{E(e),y("project-info")}}),j&&(0,F.jsx)(a$,{projectId:j.id,worktree:m,open:f,onOpenChange:p,onWorktreeDeleted:B})]})}e.s(["default",()=>wO],837031)}]);