@agent-spaces/server 0.3.62 → 0.3.64

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 (367) hide show
  1. package/dist/adapters/agent-runtime-types.js +12 -0
  2. package/dist/adapters/claude-code-runtime/index.js +3 -0
  3. package/dist/adapters/claude-code-runtime/message-format.js +1 -1
  4. package/dist/adapters/codex-runtime.js +2 -2
  5. package/dist/adapters/git.js +161 -57
  6. package/dist/adapters/langchain-runtime.js +2 -2
  7. package/dist/adapters/open-agent-sdk-runtime.js +2 -2
  8. package/dist/agents/agent-designer.js +66 -12
  9. package/dist/agents/commit-agent.js +1 -0
  10. package/dist/agents/issue-agent-progress.js +4 -2
  11. package/dist/agents/issue-agent-runner.js +5 -5
  12. package/dist/agents/issue-task-controller.js +96 -15
  13. package/dist/app.js +123 -5
  14. package/dist/package.json +1 -1
  15. package/dist/routes/agent-commands.js +72 -0
  16. package/dist/routes/agent-sse.js +10 -2
  17. package/dist/routes/agent.js +15 -1
  18. package/dist/routes/database.js +345 -0
  19. package/dist/routes/git.js +52 -1
  20. package/dist/routes/hooks.js +88 -0
  21. package/dist/routes/issue.js +59 -1
  22. package/dist/routes/kanban.js +39 -0
  23. package/dist/routes/output-style.js +48 -0
  24. package/dist/routes/prompt-template.js +2 -2
  25. package/dist/routes/skill.js +86 -15
  26. package/dist/routes/task.js +13 -1
  27. package/dist/services/agent-commands.js +168 -0
  28. package/dist/services/builtin-tools/command-tools.js +117 -0
  29. package/dist/services/builtin-tools/database-tools.js +578 -0
  30. package/dist/services/builtin-tools/index.js +5 -0
  31. package/dist/services/builtin-tools/input-helpers.js +26 -0
  32. package/dist/services/builtin-tools/issue-tools.js +209 -0
  33. package/dist/services/builtin-tools/kanban-tools.js +277 -0
  34. package/dist/services/database-vector.js +244 -0
  35. package/dist/services/hook-engine.js +118 -0
  36. package/dist/services/issue.js +6 -0
  37. package/dist/services/kanban.js +50 -0
  38. package/dist/services/notification-hub/bot-agent.js +1 -0
  39. package/dist/services/output-style.js +134 -0
  40. package/dist/services/prompt-template.js +2 -2
  41. package/dist/services/skill.js +148 -35
  42. package/dist/storage/database-store.js +365 -0
  43. package/dist/storage/hook-store.js +55 -0
  44. package/dist/storage/kanban-store.js +142 -0
  45. package/dist/web/404.html +1 -1
  46. package/dist/web/__next.__PAGE__.txt +4 -4
  47. package/dist/web/__next._full.txt +26 -30
  48. package/dist/web/__next._head.txt +4 -4
  49. package/dist/web/__next._index.txt +14 -14
  50. package/dist/web/__next._tree.txt +3 -8
  51. package/dist/web/_next/static/chunks/0-9194nbxy_6d.js +1 -0
  52. package/dist/web/_next/static/chunks/0-f~0xmwl__u5.js +1 -0
  53. package/dist/web/_next/static/chunks/0.n~yfwf4~6w-.js +1 -0
  54. package/dist/web/_next/static/chunks/002_j970b9gdx.js +1 -0
  55. package/dist/web/_next/static/chunks/01iqv28_snwus.js +1 -0
  56. package/dist/web/_next/static/chunks/01~quun6sefgl.js +1 -0
  57. package/dist/web/_next/static/chunks/02mf61htij8g0.js +31 -0
  58. package/dist/web/_next/static/chunks/03scq1-0ykve3.js +1 -0
  59. package/dist/web/_next/static/chunks/04a4vsq2wknm4.js +1 -0
  60. package/dist/web/_next/static/chunks/04dg4l4hv11q2.js +3 -0
  61. package/dist/web/_next/static/chunks/04fxddw-y20~-.js +7 -0
  62. package/dist/web/_next/static/chunks/04w7~5ooz_pwm.js +1 -0
  63. package/dist/web/_next/static/chunks/05oc21sj24wtq.js +1 -0
  64. package/dist/web/_next/static/chunks/{0zd1o3u04~qvo.js → 05psi2gtx~bev.js} +7 -7
  65. package/dist/web/_next/static/chunks/{0-oog4zg4_m~m.css → 062f9zqctzg.b.css} +0 -3
  66. package/dist/web/_next/static/chunks/{12odetnu-lyrr.js → 06whz1~s_7pva.js} +12 -12
  67. package/dist/web/_next/static/chunks/08ckpwmmwlors.js +3 -0
  68. package/dist/web/_next/static/chunks/08k~meqbd8d6v.js +1 -0
  69. package/dist/web/_next/static/chunks/099h96wjsdb25.js +2 -0
  70. package/dist/web/_next/static/chunks/09h23logvq65m.js +1 -0
  71. package/dist/web/_next/static/chunks/{0njy89g5coeyi.js → 0_8dm7bxp18xo.js} +6 -6
  72. package/dist/web/_next/static/chunks/0_mvduwjsm35w.js +1 -0
  73. package/dist/web/_next/static/chunks/0_vi1a~g4wx46.js +3 -0
  74. package/dist/web/_next/static/chunks/0a5y-vhf4i5id.js +3 -0
  75. package/dist/web/_next/static/chunks/0ake2f3x2uan4.js +24 -0
  76. package/dist/web/_next/static/chunks/{0tvd~rxgf0oh_.js → 0bbmx45w_h5np.js} +1 -1
  77. package/dist/web/_next/static/chunks/0ck8dw_9-1cdx.js +1 -0
  78. package/dist/web/_next/static/chunks/{07a0rktf_nr5h.js → 0ctg5qmw7uu.1.js} +2 -2
  79. package/dist/web/_next/static/chunks/0ewceguykiut5.js +1 -0
  80. package/dist/web/_next/static/chunks/0f7cb9li~3jra.js +67 -0
  81. package/dist/web/_next/static/chunks/0fttswpzu69qx.js +1 -0
  82. package/dist/web/_next/static/chunks/0ghs9on7wodrm.js +1 -0
  83. package/dist/web/_next/static/chunks/0ghx3j_.-gdyd.js +1 -0
  84. package/dist/web/_next/static/chunks/{0202ia13sijwb.js → 0h18ej5yf974e.js} +1 -1
  85. package/dist/web/_next/static/chunks/0h9cu-k6z5o08.js +1 -0
  86. package/dist/web/_next/static/chunks/0i39jifmxla7q.js +1 -0
  87. package/dist/web/_next/static/chunks/0iuf30t0rjsjv.js +19 -0
  88. package/dist/web/_next/static/chunks/0jb4~3qqkw2ps.js +1 -0
  89. package/dist/web/_next/static/chunks/0k4zdm72k_bfy.js +1 -0
  90. package/dist/web/_next/static/chunks/{08o-zmr-40r5g.js → 0m11vvph7q94-.js} +1 -1
  91. package/dist/web/_next/static/chunks/0n6_4so_afuwk.js +71 -0
  92. package/dist/web/_next/static/chunks/0nb8.iteznuvx.js +1 -0
  93. package/dist/web/_next/static/chunks/0np.d~hc1-pmh.js +4 -0
  94. package/dist/web/_next/static/chunks/{0qpq0~_58fe9a.js → 0oaq67r7ix.vg.js} +1 -1
  95. package/dist/web/_next/static/chunks/{0d_dp_4ofz0l3.css → 0ojcao3hdm36s.css} +0 -1
  96. package/dist/web/_next/static/chunks/0os58q93stt7j.js +3 -0
  97. package/dist/web/_next/static/chunks/{0gig.k.rq8d0x.js → 0ppr271hz0xoq.js} +1 -1
  98. package/dist/web/_next/static/chunks/0s9lmk8iauou3.js +1 -0
  99. package/dist/web/_next/static/chunks/0sp_zbx~w0am7.js +1 -0
  100. package/dist/web/_next/static/chunks/0tel~zsv4z8l_.js +1 -0
  101. package/dist/web/_next/static/chunks/0twamv4wr_dbv.js +1 -0
  102. package/dist/web/_next/static/chunks/0uhol5wafdbl~.js +1 -0
  103. package/dist/web/_next/static/chunks/0v3a_x4vt42kx.js +5 -0
  104. package/dist/web/_next/static/chunks/{002-dxhags4dj.js → 0v6hte2z-32ca.js} +2 -2
  105. package/dist/web/_next/static/chunks/0v7q4mys.mnm..css +1 -0
  106. package/dist/web/_next/static/chunks/0vbqaynjq8ga..js +3 -0
  107. package/dist/web/_next/static/chunks/0xbaakj0dfc0..js +1 -0
  108. package/dist/web/_next/static/chunks/{0..g0jl-8qup7.js → 0xoo17yef_b8g.js} +1 -1
  109. package/dist/web/_next/static/chunks/0xt-8wk21gs7g.js +1 -0
  110. package/dist/web/_next/static/chunks/0za1r07-6az6w.js +1 -0
  111. package/dist/web/_next/static/chunks/0z~vqzbm_q371.js +1 -0
  112. package/dist/web/_next/static/chunks/0~3xm80~j9ddg.js +1 -0
  113. package/dist/web/_next/static/chunks/0~u.5r3-t7179.js +1 -0
  114. package/dist/web/_next/static/chunks/10l-9myrdo3x9.js +1 -0
  115. package/dist/web/_next/static/chunks/11-czmcci_55y.js +1 -0
  116. package/dist/web/_next/static/chunks/11k-.49r~1mfm.js +1 -0
  117. package/dist/web/_next/static/chunks/{0k.8qdk7oi_os.js → 128ugqd34tr_-.js} +1 -1
  118. package/dist/web/_next/static/chunks/12jm4gwmvq-0q.js +90 -0
  119. package/dist/web/_next/static/chunks/{0rke_patcovgr.js → 1442stwa0gbxe.js} +1 -1
  120. package/dist/web/_next/static/chunks/{0jokpgh485~28.js → 14hqmid8q4apf.js} +11 -11
  121. package/dist/web/_next/static/chunks/14s37n6h0_q3x.js +16 -0
  122. package/dist/web/_next/static/chunks/161ik5kfyuwtd.js +1 -0
  123. package/dist/web/_next/static/chunks/16sg-lflc8csx.js +1 -0
  124. package/dist/web/_next/static/chunks/17k~zbv0_4rep.js +1 -0
  125. package/dist/web/_next/static/chunks/17oc2l.ekcs8b.css +1 -0
  126. package/dist/web/_next/static/chunks/{turbopack-0lrdxynxb9-1t.js → turbopack-0ndm2zc_pdptk.js} +1 -1
  127. package/dist/web/_not-found/__next._full.txt +30 -31
  128. package/dist/web/_not-found/__next._head.txt +4 -4
  129. package/dist/web/_not-found/__next._index.txt +14 -14
  130. package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
  131. package/dist/web/_not-found/__next._not-found.txt +3 -3
  132. package/dist/web/_not-found/__next._tree.txt +3 -3
  133. package/dist/web/_not-found.html +1 -1
  134. package/dist/web/_not-found.txt +30 -31
  135. package/dist/web/index.html +1 -1
  136. package/dist/web/index.txt +26 -30
  137. package/dist/web/login/__next._full.txt +32 -36
  138. package/dist/web/login/__next._head.txt +4 -4
  139. package/dist/web/login/__next._index.txt +14 -14
  140. package/dist/web/login/__next._tree.txt +3 -8
  141. package/dist/web/login/__next.login.__PAGE__.txt +4 -4
  142. package/dist/web/login/__next.login.txt +3 -3
  143. package/dist/web/login.html +1 -1
  144. package/dist/web/login.txt +32 -36
  145. package/dist/web/settings/__next._full.txt +29 -34
  146. package/dist/web/settings/__next._head.txt +4 -4
  147. package/dist/web/settings/__next._index.txt +14 -14
  148. package/dist/web/settings/__next._tree.txt +3 -8
  149. package/dist/web/settings/__next.settings.__PAGE__.txt +4 -4
  150. package/dist/web/settings/__next.settings.txt +5 -5
  151. package/dist/web/settings/agents/__next._full.txt +27 -32
  152. package/dist/web/settings/agents/__next._head.txt +4 -4
  153. package/dist/web/settings/agents/__next._index.txt +14 -14
  154. package/dist/web/settings/agents/__next._tree.txt +3 -8
  155. package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +4 -4
  156. package/dist/web/settings/agents/__next.settings.agents.txt +3 -3
  157. package/dist/web/settings/agents/__next.settings.txt +5 -5
  158. package/dist/web/settings/agents.html +1 -1
  159. package/dist/web/settings/agents.txt +27 -32
  160. package/dist/web/settings/mcps/__next._full.txt +27 -32
  161. package/dist/web/settings/mcps/__next._head.txt +4 -4
  162. package/dist/web/settings/mcps/__next._index.txt +14 -14
  163. package/dist/web/settings/mcps/__next._tree.txt +3 -8
  164. package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +4 -4
  165. package/dist/web/settings/mcps/__next.settings.mcps.txt +3 -3
  166. package/dist/web/settings/mcps/__next.settings.txt +5 -5
  167. package/dist/web/settings/mcps.html +1 -1
  168. package/dist/web/settings/mcps.txt +27 -32
  169. package/dist/web/settings/models/__next._full.txt +27 -32
  170. package/dist/web/settings/models/__next._head.txt +4 -4
  171. package/dist/web/settings/models/__next._index.txt +14 -14
  172. package/dist/web/settings/models/__next._tree.txt +3 -8
  173. package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +4 -4
  174. package/dist/web/settings/models/__next.settings.models.txt +3 -3
  175. package/dist/web/settings/models/__next.settings.txt +5 -5
  176. package/dist/web/settings/models.html +1 -1
  177. package/dist/web/settings/models.txt +27 -32
  178. package/dist/web/settings/output-styles/__next._full.txt +38 -0
  179. package/dist/web/settings/output-styles/__next._head.txt +6 -0
  180. package/dist/web/settings/output-styles/__next._index.txt +15 -0
  181. package/dist/web/settings/output-styles/__next._tree.txt +3 -0
  182. package/dist/web/settings/output-styles/__next.settings.output-styles.__PAGE__.txt +9 -0
  183. package/dist/web/settings/output-styles/__next.settings.output-styles.txt +5 -0
  184. package/dist/web/settings/output-styles/__next.settings.txt +7 -0
  185. package/dist/web/settings/output-styles.html +1 -0
  186. package/dist/web/settings/output-styles.txt +38 -0
  187. package/dist/web/settings/prompts/__next._full.txt +27 -32
  188. package/dist/web/settings/prompts/__next._head.txt +4 -4
  189. package/dist/web/settings/prompts/__next._index.txt +14 -14
  190. package/dist/web/settings/prompts/__next._tree.txt +3 -8
  191. package/dist/web/settings/prompts/__next.settings.prompts.__PAGE__.txt +4 -4
  192. package/dist/web/settings/prompts/__next.settings.prompts.txt +3 -3
  193. package/dist/web/settings/prompts/__next.settings.txt +5 -5
  194. package/dist/web/settings/prompts.html +1 -1
  195. package/dist/web/settings/prompts.txt +27 -32
  196. package/dist/web/settings/providers/__next._full.txt +27 -32
  197. package/dist/web/settings/providers/__next._head.txt +4 -4
  198. package/dist/web/settings/providers/__next._index.txt +14 -14
  199. package/dist/web/settings/providers/__next._tree.txt +3 -8
  200. package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +4 -4
  201. package/dist/web/settings/providers/__next.settings.providers.txt +3 -3
  202. package/dist/web/settings/providers/__next.settings.txt +5 -5
  203. package/dist/web/settings/providers.html +1 -1
  204. package/dist/web/settings/providers.txt +27 -32
  205. package/dist/web/settings/skills/__next._full.txt +27 -32
  206. package/dist/web/settings/skills/__next._head.txt +4 -4
  207. package/dist/web/settings/skills/__next._index.txt +14 -14
  208. package/dist/web/settings/skills/__next._tree.txt +3 -8
  209. package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +4 -4
  210. package/dist/web/settings/skills/__next.settings.skills.txt +3 -3
  211. package/dist/web/settings/skills/__next.settings.txt +5 -5
  212. package/dist/web/settings/skills.html +1 -1
  213. package/dist/web/settings/skills.txt +27 -32
  214. package/dist/web/settings/tools/__next._full.txt +38 -0
  215. package/dist/web/settings/tools/__next._head.txt +6 -0
  216. package/dist/web/settings/tools/__next._index.txt +15 -0
  217. package/dist/web/settings/tools/__next._tree.txt +3 -0
  218. package/dist/web/settings/tools/__next.settings.tools.__PAGE__.txt +9 -0
  219. package/dist/web/settings/tools/__next.settings.tools.txt +5 -0
  220. package/dist/web/settings/tools/__next.settings.txt +7 -0
  221. package/dist/web/settings/tools.html +1 -0
  222. package/dist/web/settings/tools.txt +38 -0
  223. package/dist/web/settings.html +1 -1
  224. package/dist/web/settings.txt +29 -34
  225. package/dist/web/workflows/__next._full.txt +34 -37
  226. package/dist/web/workflows/__next._head.txt +4 -4
  227. package/dist/web/workflows/__next._index.txt +14 -14
  228. package/dist/web/workflows/__next._tree.txt +3 -8
  229. package/dist/web/workflows/__next.workflows.__PAGE__.txt +4 -4
  230. package/dist/web/workflows/__next.workflows.txt +3 -3
  231. package/dist/web/workflows.html +1 -1
  232. package/dist/web/workflows.txt +34 -37
  233. package/dist/web/workspace/_/__next._full.txt +32 -77
  234. package/dist/web/workspace/_/__next._head.txt +4 -4
  235. package/dist/web/workspace/_/__next._index.txt +14 -14
  236. package/dist/web/workspace/_/__next._tree.txt +4 -23
  237. package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +3 -18
  238. package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
  239. package/dist/web/workspace/_/__next.workspace.txt +3 -3
  240. package/dist/web/workspace/_.html +1 -1
  241. package/dist/web/workspace/_.txt +32 -77
  242. package/dist/web/workspaces/__next._full.txt +32 -38
  243. package/dist/web/workspaces/__next._head.txt +4 -4
  244. package/dist/web/workspaces/__next._index.txt +14 -14
  245. package/dist/web/workspaces/__next._tree.txt +3 -8
  246. package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
  247. package/dist/web/workspaces/__next.workspaces.txt +3 -3
  248. package/dist/web/workspaces.html +1 -1
  249. package/dist/web/workspaces.txt +32 -38
  250. package/dist/ws/agent-prompt.js +45 -8
  251. package/dist/ws/agent-runner.js +10 -6
  252. package/package.json +11 -10
  253. package/public/output-styles/carmack-mode.md +381 -0
  254. package/public/output-styles/codex-rigor-mode.md +114 -0
  255. package/public/output-styles/dhh-mode.md +265 -0
  256. package/public/output-styles/evan-you-mode.md +539 -0
  257. package/public/output-styles/index.json +37 -0
  258. package/public/output-styles/jobs-mode.md +369 -0
  259. package/public/output-styles/linus-mode.md +135 -0
  260. package/public/output-styles/uncle-bob-mode.md +221 -0
  261. package/public/prompt/andrej-karpathy-skills.md +65 -0
  262. package/public/prompt/claude-token-efficient-coding.md +35 -0
  263. package/public/prompt/index.json +12 -0
  264. package/public/skills/index.json +92 -0
  265. package/public/skills/planning-with-files/planning-with-files-zh/SKILL.md +243 -0
  266. package/public/skills/planning-with-files/planning-with-files-zh/scripts/check-complete.ps1 +44 -0
  267. package/public/skills/planning-with-files/planning-with-files-zh/scripts/check-complete.sh +46 -0
  268. package/public/skills/planning-with-files/planning-with-files-zh/scripts/init-session.ps1 +124 -0
  269. package/public/skills/planning-with-files/planning-with-files-zh/scripts/init-session.sh +124 -0
  270. package/public/skills/planning-with-files/planning-with-files-zh/scripts/session-catchup.py +438 -0
  271. package/public/skills/planning-with-files/planning-with-files-zh/templates/findings.md +29 -0
  272. package/public/skills/planning-with-files/planning-with-files-zh/templates/progress.md +40 -0
  273. package/public/skills/planning-with-files/planning-with-files-zh/templates/task_plan.md +58 -0
  274. package/public/skills/superpowers/brainstorming/SKILL.md +164 -0
  275. package/public/skills/superpowers/brainstorming/scripts/frame-template.html +214 -0
  276. package/public/skills/superpowers/brainstorming/scripts/helper.js +88 -0
  277. package/public/skills/superpowers/brainstorming/scripts/server.cjs +354 -0
  278. package/public/skills/superpowers/brainstorming/scripts/start-server.sh +148 -0
  279. package/public/skills/superpowers/brainstorming/scripts/stop-server.sh +56 -0
  280. package/public/skills/superpowers/brainstorming/spec-document-reviewer-prompt.md +49 -0
  281. package/public/skills/superpowers/brainstorming/visual-companion.md +287 -0
  282. package/public/skills/superpowers/dispatching-parallel-agents/SKILL.md +182 -0
  283. package/public/skills/superpowers/executing-plans/SKILL.md +70 -0
  284. package/public/skills/superpowers/finishing-a-development-branch/SKILL.md +251 -0
  285. package/public/skills/superpowers/receiving-code-review/SKILL.md +213 -0
  286. package/public/skills/superpowers/requesting-code-review/SKILL.md +103 -0
  287. package/public/skills/superpowers/requesting-code-review/code-reviewer.md +168 -0
  288. package/public/skills/superpowers/subagent-driven-development/SKILL.md +279 -0
  289. package/public/skills/superpowers/subagent-driven-development/code-quality-reviewer-prompt.md +25 -0
  290. package/public/skills/superpowers/subagent-driven-development/implementer-prompt.md +113 -0
  291. package/public/skills/superpowers/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  292. package/public/skills/superpowers/systematic-debugging/CREATION-LOG.md +119 -0
  293. package/public/skills/superpowers/systematic-debugging/SKILL.md +296 -0
  294. package/public/skills/superpowers/systematic-debugging/condition-based-waiting-example.ts +158 -0
  295. package/public/skills/superpowers/systematic-debugging/condition-based-waiting.md +115 -0
  296. package/public/skills/superpowers/systematic-debugging/defense-in-depth.md +122 -0
  297. package/public/skills/superpowers/systematic-debugging/find-polluter.sh +63 -0
  298. package/public/skills/superpowers/systematic-debugging/root-cause-tracing.md +169 -0
  299. package/public/skills/superpowers/systematic-debugging/test-academic.md +14 -0
  300. package/public/skills/superpowers/systematic-debugging/test-pressure-1.md +58 -0
  301. package/public/skills/superpowers/systematic-debugging/test-pressure-2.md +68 -0
  302. package/public/skills/superpowers/systematic-debugging/test-pressure-3.md +69 -0
  303. package/public/skills/superpowers/test-driven-development/SKILL.md +371 -0
  304. package/public/skills/superpowers/test-driven-development/testing-anti-patterns.md +299 -0
  305. package/public/skills/superpowers/using-git-worktrees/SKILL.md +215 -0
  306. package/public/skills/superpowers/using-superpowers/SKILL.md +117 -0
  307. package/public/skills/superpowers/using-superpowers/references/codex-tools.md +59 -0
  308. package/public/skills/superpowers/using-superpowers/references/copilot-tools.md +42 -0
  309. package/public/skills/superpowers/using-superpowers/references/gemini-tools.md +51 -0
  310. package/public/skills/superpowers/verification-before-completion/SKILL.md +139 -0
  311. package/public/skills/superpowers/writing-plans/SKILL.md +152 -0
  312. package/public/skills/superpowers/writing-plans/plan-document-reviewer-prompt.md +49 -0
  313. package/public/skills/superpowers/writing-skills/SKILL.md +655 -0
  314. package/public/skills/superpowers/writing-skills/anthropic-best-practices.md +1150 -0
  315. package/public/skills/superpowers/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  316. package/public/skills/superpowers/writing-skills/graphviz-conventions.dot +172 -0
  317. package/public/skills/superpowers/writing-skills/persuasion-principles.md +187 -0
  318. package/public/skills/superpowers/writing-skills/render-graphs.js +168 -0
  319. package/public/skills/superpowers/writing-skills/testing-skills-with-subagents.md +384 -0
  320. package/dist/web/_next/static/chunks/0-81wi7xr2nd-.js +0 -270
  321. package/dist/web/_next/static/chunks/00lca9lsasdm7.js +0 -1
  322. package/dist/web/_next/static/chunks/01gi~q0c6ez6..js +0 -1
  323. package/dist/web/_next/static/chunks/02shswpmybici.js +0 -1
  324. package/dist/web/_next/static/chunks/05tx6hzdtkgi9.js +0 -2
  325. package/dist/web/_next/static/chunks/07nbyndvzftr1.js +0 -3
  326. package/dist/web/_next/static/chunks/0bn~onkv~9xza.js +0 -1
  327. package/dist/web/_next/static/chunks/0g-0n6glz_z6w.js +0 -1
  328. package/dist/web/_next/static/chunks/0gyede80jpy3n.js +0 -4
  329. package/dist/web/_next/static/chunks/0hrbuvzuxrjfl.js +0 -1
  330. package/dist/web/_next/static/chunks/0i51q.5s_-.vh.css +0 -1
  331. package/dist/web/_next/static/chunks/0qf163pbrwy4z.js +0 -1
  332. package/dist/web/_next/static/chunks/0rnt-f3pjxb-d.js +0 -5
  333. package/dist/web/_next/static/chunks/0tgbcgsca9mrg.js +0 -1
  334. package/dist/web/_next/static/chunks/0tyhv6.y7~yxd.js +0 -1
  335. package/dist/web/_next/static/chunks/0u7_qd9hzqwac.js +0 -1
  336. package/dist/web/_next/static/chunks/0vuvql8rloda5.js +0 -1
  337. package/dist/web/_next/static/chunks/0wv0h27jafag4.js +0 -1
  338. package/dist/web/_next/static/chunks/0wwvc4zc2q6bn.js +0 -1
  339. package/dist/web/_next/static/chunks/0xmmk3vebw8xs.js +0 -1
  340. package/dist/web/_next/static/chunks/0xwqf.llmm_u2.js +0 -31
  341. package/dist/web/_next/static/chunks/0yo22_w53mo~5.js +0 -1
  342. package/dist/web/_next/static/chunks/12c0jp0qvlr1t.js +0 -1
  343. package/dist/web/_next/static/chunks/12pg1nn3v~~5k.js +0 -1
  344. package/dist/web/_next/static/chunks/16cyr8ilpx1nn.js +0 -1
  345. package/dist/web/_next/static/media/0a7740363b4d4863-s.1110aazvokzp..woff2 +0 -0
  346. package/dist/web/_next/static/media/0da9c7f357bd9d4d-s.0ek5sshv8wk3m.woff2 +0 -0
  347. package/dist/web/_next/static/media/1b99372b3eaef0c8-s.p.0gx2haw2tmll8.woff2 +0 -0
  348. package/dist/web/_next/static/media/41e95f694c5c4549-s.0r1jrq7neqdsq.woff2 +0 -0
  349. package/dist/web/_next/static/media/5c285b27cdda1fe8-s.p.0yo6-5yoeeudq.woff2 +0 -0
  350. package/dist/web/_next/static/media/5f9d24ebef5d5292-s.0esuu2f5si~v8.woff2 +0 -0
  351. package/dist/web/_next/static/media/6c55a692938ebbbc-s.0g6rbszwfgn9y.woff2 +0 -0
  352. package/dist/web/_next/static/media/8e6fa89aa22d24ec-s.p.0uvzar8hswo3p.woff2 +0 -0
  353. package/dist/web/_next/static/media/a218039a3287bcfd-s.p.17-1enzs_j91b.woff2 +0 -0
  354. package/dist/web/_next/static/media/b2ea385cb5ae8625-s.0kjod.kaq1k69.woff2 +0 -0
  355. package/dist/web/_next/static/media/bdc7e24a509eb931-s.0apt5mko2.qn3.woff2 +0 -0
  356. package/dist/web/_next/static/media/c3cb240f9c892514-s.163v2i5cux7-c.woff2 +0 -0
  357. package/dist/web/_next/static/media/e2334d715941921e-s.p.12skym0rqknxy.woff2 +0 -0
  358. package/public/avatars/1777813826407-bea0ja-minimax.svg +0 -1
  359. package/public/avatars/1777813967088-3xlvd0-minimax.svg +0 -1
  360. package/public/avatars/1777814041714-yp0qeq-minimax.svg +0 -1
  361. package/public/avatars/1777904986095-rg26je-icon.png +0 -0
  362. package/public/avatars/1778953228323-5je54x-user.jpg +0 -0
  363. package/public/avatars/1778954057880-g01q6y-user.jpg +0 -0
  364. /package/dist/web/_next/static/{GS3b40oeaeLxm7i9-ibaj → e8w3vd9Eov_LDYWj_0zsE}/_buildManifest.js +0 -0
  365. /package/dist/web/_next/static/{GS3b40oeaeLxm7i9-ibaj → e8w3vd9Eov_LDYWj_0zsE}/_clientMiddlewareManifest.js +0 -0
  366. /package/dist/web/_next/static/{GS3b40oeaeLxm7i9-ibaj → e8w3vd9Eov_LDYWj_0zsE}/_ssgManifest.js +0 -0
  367. /package/public/avatars/{1777815865622-08wp9m-user.jpg → user.jpg} +0 -0
@@ -0,0 +1,5 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,177053,e=>{"use strict";var t=e.i(344180),n=e.i(523592);{let e=window.fetch,t="__api_patched__";window[t]||(window[t]=!0,window.fetch=function(t,r){if("string"==typeof t&&t.startsWith("/api/")){let e=(0,n.getActiveServerUrl)();e&&(t=`${e}${t}`)}return e.call(window,t,r)})}var r=e.i(764556),a=e.i(799543),s=e.i(437122),i=e.i(233297),o=e.i(286117);e.s(["AuthGuard",0,function({children:e}){let n=(0,a.usePathname)(),l=(0,a.useRouter)(),[c,d]=(0,r.useState)(!1),u=(0,o.isLoginPath)(n);return((0,r.useEffect)(()=>{if(u)return void d(!0);if(!(0,s.isAuthenticated)())return void(0,i.tauriNavigate)(l,"/login",!0);let e=(0,s.getToken)();fetch("/api/auth/check",{headers:null!==e?{Authorization:`Bearer ${e}`}:{}}).then(e=>401===e.status||403===e.status?((0,s.removeToken)(),(0,i.tauriNavigate)(l,"/login",!0),null):e.ok?e.json():{authenticated:!0}).then(e=>{null!==e&&(e.authenticated?d(!0):((0,s.removeToken)(),(0,i.tauriNavigate)(l,"/login",!0)))}).catch(()=>d(!0))},[u,l]),u||c)?(0,t.jsx)(t.Fragment,{children:e}):null}],177053)},640376,e=>{"use strict";let t=(0,e.i(816709).create)((e,t)=>({open:!1,commands:[],setOpen:t=>e({open:t}),toggle:()=>e(e=>({open:!e.open})),register:n=>(e(e=>e.commands.some(e=>e.id===n.id)?e:{commands:[...e.commands,n]}),()=>t().unregister(n.id)),registerMany:t=>{let n=new Set(t.map(e=>e.id));return e(e=>({commands:[...e.commands.filter(e=>!n.has(e.id)),...t]})),()=>e(e=>({commands:e.commands.filter(e=>!n.has(e.id))}))},unregister:t=>e(e=>({commands:e.commands.filter(e=>e.id!==t)}))}));e.s(["useCommandPalette",0,t])},478189,(e,t,n)=>{"use strict";t.exports="/__open-stack-frame-in-editor"},994876,e=>{"use strict";var t=e.i(344180),n=e.i(799543),r=e.i(764556),a=e.i(370383),s=e.i(928542),i=e.i(294237),o=e.i(564822),l=e.i(465458),c=e.i(260218),d=e.i(681622);e.i(362962);var u=e.i(14452);e.i(613087);var m=e.i(638322),p=e.i(651850),p=p;let f="sidebar_state",h=r.createContext(null);function g(){let e=r.useContext(h);if(!e)throw Error("useSidebar must be used within a SidebarProvider.");return e}function x({defaultOpen:e=!0,open:n,onOpenChange:a,className:s,style:i,children:c,...d}){let u=(0,o.useIsMobile)(),[m,p]=r.useState(!1),[g,v]=r.useState(e),b=n??g;r.useEffect(()=>{if(void 0!==n)return;let e=document.cookie.match(RegExp(`(?:^|; )${f}=([^;]*)`));e&&v("true"===e[1])},[n]);let w=r.useCallback(e=>{let t="function"==typeof e?e(b):e;a?a(t):v(t),document.cookie=`${f}=${t}; path=/; max-age=604800`},[a,b]),j=r.useCallback(()=>u?p(e=>!e):w(e=>!e),[u,w,p]);r.useEffect(()=>{let e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),j())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[j]);let y=b||u&&m?"expanded":"collapsed",N=r.useMemo(()=>({state:y,open:b,setOpen:w,isMobile:u,openMobile:m,setOpenMobile:p,toggleSidebar:j}),[y,b,w,u,m,p,j]);return(0,t.jsx)(h.Provider,{value:N,children:(0,t.jsx)("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":"16rem","--sidebar-width-icon":"3rem",...i},className:(0,l.cn)("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",s),...d,children:c})})}function v({side:e="left",variant:n="sidebar",collapsible:r="offcanvas",className:a,children:s,dir:i,...o}){let{isMobile:c,state:d,openMobile:m,setOpenMobile:p}=g();return"none"===r?(0,t.jsx)("div",{"data-slot":"sidebar",className:(0,l.cn)("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",a),...o,children:s}):c?(0,t.jsx)(u.Sheet,{open:m,onOpenChange:p,...o,children:(0,t.jsxs)(u.SheetContent,{dir:i,"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:e,children:[(0,t.jsxs)(u.SheetHeader,{className:"sr-only",children:[(0,t.jsx)(u.SheetTitle,{children:"Sidebar"}),(0,t.jsx)(u.SheetDescription,{children:"Displays the mobile sidebar."})]}),(0,t.jsx)("div",{className:"flex h-full w-full flex-col",children:s})]})}):(0,t.jsxs)("div",{className:"group peer hidden text-sidebar-foreground md:block","data-state":d,"data-collapsible":"collapsed"===d?r:"","data-variant":n,"data-side":e,"data-slot":"sidebar",children:[(0,t.jsx)("div",{"data-slot":"sidebar-gap",className:(0,l.cn)("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===n||"inset"===n?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),(0,t.jsx)("div",{"data-slot":"sidebar-container","data-side":e,className:(0,l.cn)("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex","floating"===n||"inset"===n?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",a),...o,children:(0,t.jsx)("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"flex size-full flex-col overflow-hidden group-data-[variant=floating]:rounded-xl group-data-[variant=floating]:bg-transparent",children:s})})]})}function b({className:e,onClick:n,...r}){let{toggleSidebar:a}=g();return(0,t.jsxs)(c.Button,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon-sm",className:(0,l.cn)(e),onClick:e=>{n?.(e),a()},...r,children:[(0,t.jsx)(p.default,{}),(0,t.jsx)("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function w({className:e,...n}){return(0,t.jsx)("main",{"data-slot":"sidebar-inset",className:(0,l.cn)("relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",e),...n})}function j({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:(0,l.cn)("flex flex-col gap-2 p-2 shrink-0",e),...n})}function y({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:(0,l.cn)("flex flex-col gap-2 p-2 shrink-0",e),...n})}function N({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:(0,l.cn)("flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...n})}function k({className:e,...n}){return(0,t.jsx)("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:(0,l.cn)("flex w-full min-w-0 flex-col gap-0",e),...n})}function S({className:e,...n}){return(0,t.jsx)("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:(0,l.cn)("group/menu-item relative",e),...n})}let C=(0,i.cva)("peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function E({render:e,isActive:n=!1,variant:r="default",size:i="default",tooltip:o,className:c,...d}){let{isMobile:u,state:p}=g(),f=(0,s.useRender)({defaultTagName:"button",props:(0,a.mergeProps)({className:(0,l.cn)(C({variant:r,size:i}),c)},d),render:o?(0,t.jsx)(m.TooltipTrigger,{render:e}):e,state:{slot:"sidebar-menu-button",sidebar:"menu-button",size:i,active:n}});return o?("string"==typeof o&&(o={children:o}),(0,t.jsxs)(m.Tooltip,{children:[f,(0,t.jsx)(m.TooltipContent,{side:"right",align:"center",hidden:"collapsed"!==p||u,...o})]})):f}function D({className:e,...n}){return(0,t.jsx)("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:(0,l.cn)("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",e),...n})}function I({render:e,size:t="md",isActive:n=!1,className:r,...i}){return(0,s.useRender)({defaultTagName:"a",props:(0,a.mergeProps)({className:(0,l.cn)("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",r)},i),render:e,state:{slot:"sidebar-menu-sub-button",sidebar:"menu-sub-button",size:t,active:n}})}var M=e.i(244073),T=e.i(233297),P=e.i(341807),z=e.i(411649),A=e.i(451534),O=e.i(939760),L=e.i(325443),_=e.i(990336),R=e.i(100559),$=e.i(962562),F=e.i(137340),W=e.i(244644),B=e.i(327962),U=e.i(415360),H=e.i(426022),K=e.i(191202),V=e.i(433721);let q=(0,V.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);var X=e.i(227634),G=e.i(592039),J=e.i(164202),Y=e.i(119211),Z=e.i(683640),Q=e.i(324216),ee=e.i(588591),et=e.i(86477),en=e.i(549705),er=e.i(238300),ea=e.i(625873),es=e.i(756638),ei=e.i(841734),eo=e.i(22906),el=e.i(887836),ec=e.i(209988),ed=e.i(191118),eu=e.i(226624),em=e.i(917955),ep=e.i(188815),ef=e.i(129981),eh=e.i(953700),eg=e.i(111343),ex=e.i(401058);let ev=(0,V.default)("arrow-right-left",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);var eb=e.i(816709),ew=e.i(437122);let ej=(0,eb.create)(e=>({hooks:[],selectedName:null,loading:!1,fetchHooks:async t=>{e({loading:!0});try{let n=await (0,ew.fetchWithAuth)(`/api/workspaces/${t}/hooks`),r=await n.json();e({hooks:r,loading:!1})}catch{e({loading:!1})}},createHook:async(t,n)=>{let r={name:n,enabled:!0,hooks:{PreToolUse:[],PostToolUse:[]}};await (0,ew.fetchWithAuth)(`/api/workspaces/${t}/hooks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),e(e=>({hooks:[...e.hooks,r],selectedName:n}))},updateHook:async(t,n,r)=>{await (0,ew.fetchWithAuth)(`/api/workspaces/${t}/hooks/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),e(e=>({hooks:e.hooks.map(e=>e.name===n?r:e)}))},deleteHook:async(t,n)=>{await (0,ew.fetchWithAuth)(`/api/workspaces/${t}/hooks/${n}`,{method:"DELETE"}),e(e=>({hooks:e.hooks.filter(e=>e.name!==n),selectedName:e.selectedName===n?null:e.selectedName}))},uploadHook:async(t,n)=>{let r=await (0,ew.fetchWithAuth)(`/api/workspaces/${t}/hooks/upload`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})}),a=await r.json();e(e=>({hooks:[...e.hooks,a],selectedName:a.name}))},applyToWorkspace:async(e,t,n)=>{await (0,ew.fetchWithAuth)(`/api/workspaces/${e}/hooks/${t}/apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetWorkspaceId:n})})},setSelectedName:t=>e({selectedName:t}),reset:()=>e({hooks:[],selectedName:null,loading:!1})}));var ey=e.i(361031);e.i(462506);let eN=(0,el.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading editor..."})});function ek({open:e,onOpenChange:n,standalone:a}){(0,M.useTranslations)();let{hooks:s,selectedName:i,loading:o,fetchHooks:u,createHook:m,updateHook:p,deleteHook:f,uploadHook:h,applyToWorkspace:g,setSelectedName:x}=ej(),{workspaces:v}=(0,ey.useWorkspaceStore)(),b=v[0]?.id,[w,j]=(0,r.useState)(""),[y,N]=(0,r.useState)(""),[k,S]=(0,r.useState)(!1),[C,E]=(0,r.useState)(!1),[D,I]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e&&b&&u(b)},[e,b,u]);let T=s.find(e=>e.name===i);(0,r.useEffect)(()=>{T?(j(JSON.stringify(T,null,2)),I(!1)):j("")},[T]);let P=(0,r.useCallback)(async()=>{if(b&&i)try{let e=JSON.parse(w);await p(b,i,e),I(!1)}catch(e){console.error("Invalid JSON:",e instanceof Error?e.message:String(e))}},[b,i,w,p]),z=(0,r.useCallback)(async()=>{b&&y.trim()&&(await m(b,y.trim()),N(""),S(!1))},[b,y,m]),A=(0,r.useCallback)(async()=>{b&&i&&await f(b,i)},[b,i,f]),O=(0,r.useCallback)(()=>{let e=document.createElement("input");e.type="file",e.accept=".json",e.onchange=async e=>{let t=e.target.files?.[0];if(!t||!b)return;let n=await t.text();await h(b,n)},e.click()},[b,h]),L=(0,r.useCallback)(async e=>{b&&i&&(await g(b,i,e),E(!1))},[b,i,g]),_=(0,r.useCallback)(async(e,t)=>{if(!b)return;let n=s.find(t=>t.name===e);n&&await p(b,e,{...n,enabled:t})},[b,s,p]),R=(0,t.jsxs)("div",{className:"flex h-[500px]",children:[(0,t.jsxs)("div",{className:"w-52 border-r flex flex-col",children:[(0,t.jsxs)("div",{className:"p-2 border-b flex gap-1",children:[(0,t.jsx)(c.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>S(!0),children:(0,t.jsx)(eh.Plus,{className:"size-3.5"})}),(0,t.jsx)(c.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:O,children:(0,t.jsx)(ef.Upload,{className:"size-3.5"})})]}),k&&(0,t.jsxs)("div",{className:"p-2 border-b flex gap-1",children:[(0,t.jsx)(d.Input,{value:y,onChange:e=>N(e.target.value),placeholder:"hook name",className:"h-7 text-xs",onKeyDown:e=>"Enter"===e.key&&z(),autoFocus:!0}),(0,t.jsx)(c.Button,{size:"sm",className:"h-7 text-xs",onClick:z,children:"OK"})]}),(0,t.jsx)(ed.ScrollArea,{className:"flex-1",children:o?(0,t.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:"Loading..."}):0===s.length?(0,t.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:"No hooks"}):s.map(e=>(0,t.jsxs)("div",{className:(0,l.cn)("flex items-center gap-2 px-3 py-1.5 cursor-pointer text-xs hover:bg-accent",i===e.name&&"bg-accent"),onClick:()=>x(e.name),children:[(0,t.jsx)(eu.Switch,{checked:e.enabled,onCheckedChange:t=>_(e.name,t),className:"scale-75",onClick:e=>e.stopPropagation()}),(0,t.jsx)("span",{className:"truncate flex-1",children:e.name})]},e.name))})]}),(0,t.jsx)("div",{className:"flex-1 flex flex-col",children:T?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 border-b",children:[(0,t.jsx)("span",{className:"text-xs font-medium",children:T.name}),(0,t.jsxs)("div",{className:"flex gap-1",children:[(0,t.jsxs)(c.Button,{size:"sm",variant:"ghost",className:"h-7 text-xs gap-1",onClick:()=>E(!0),children:[(0,t.jsx)(ev,{className:"size-3"}),"Apply"]}),(0,t.jsxs)(c.Button,{size:"sm",variant:"ghost",className:"h-7 text-xs gap-1",onClick:P,disabled:!D,children:[(0,t.jsx)(eg.Save,{className:"size-3"}),"Save"]}),(0,t.jsxs)(em.DropdownMenu,{children:[(0,t.jsx)(em.DropdownMenuTrigger,{children:(0,t.jsx)(c.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",children:(0,t.jsx)(ex.MoreVertical,{className:"size-3"})})}),(0,t.jsx)(em.DropdownMenuContent,{align:"end",children:(0,t.jsxs)(em.DropdownMenuItem,{className:"text-destructive text-xs",onClick:A,children:[(0,t.jsx)(F.Trash2,{className:"size-3 mr-1"})," Delete"]})})]})]})]}),C&&(0,t.jsxs)("div",{className:"px-3 py-2 border-b bg-muted/50",children:[(0,t.jsx)("div",{className:"text-xs mb-1",children:"Apply to workspace:"}),(0,t.jsx)(ep.SearchSelect,{options:v.filter(e=>e.id!==b).map(e=>({value:e.id,label:e.name})),value:"",onChange:L,placeholder:"Select workspace..."})]}),(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)(eN,{height:"100%",language:"json",theme:"vs-dark",value:w,onChange:e=>{j(e||""),I(!0)},options:{minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on"}})})]}):(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Select a hook to edit"})})]});return a?R:(0,t.jsx)(ec.Dialog,{open:e,onOpenChange:n,children:(0,t.jsxs)(ec.DialogContent,{className:"!max-w-[80vw] p-0 overflow-hidden",children:[(0,t.jsxs)(ec.DialogHeader,{className:"px-4 pt-4",children:[(0,t.jsx)(ec.DialogTitle,{children:"Hooks"}),(0,t.jsx)(ec.DialogDescription,{children:"Manage per-tool-call hooks for this workspace"})]}),R]})})}var eS=e.i(996652),eC=e.i(460578),eE=e.i(611176),eD=e.i(887354),eI=e.i(989484),eM=e.i(973370),eT=e.i(977694),eP=e.i(239340);let ez=(0,el.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading editor..."})});function eA({open:e,onOpenChange:n}){let a=(0,M.useTranslations)("agentCommands"),s=(0,M.useTranslations)("common"),[i,o]=(0,r.useState)([]),[u,m]=(0,r.useState)([]),[p,f]=(0,r.useState)(!1),[h,g]=(0,r.useState)(""),[x,v]=(0,r.useState)(""),[b,w]=(0,r.useState)(""),[j,y]=(0,r.useState)(!1),[N,k]=(0,r.useState)([]),[S,C]=(0,r.useState)(null),[E,D]=(0,r.useState)(!1),[I,T]=(0,r.useState)(""),[P,z]=(0,r.useState)(""),[A,O]=(0,r.useState)(""),[L,_]=(0,r.useState)(""),[R,$]=(0,r.useState)(!1),[W,B]=(0,r.useState)(null),[U,H]=(0,r.useState)([]),[K,V]=(0,r.useState)(!1),q=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/agent-commands/agents");if(e.ok){let t=await e.json();o(t),t.length>0&&!x&&O(t[0].agentId)}}catch{}},[x]),X=(0,r.useCallback)(async()=>{f(!0);try{let e=await fetch("/api/agent-commands/all");e.ok&&m(await e.json())}catch{}f(!1)},[]);(0,r.useEffect)(()=>{e&&(q(),X())},[e,q,X]);let G=Array.from(new Set(u.map(e=>e.group).filter(Boolean))),J=u.filter(e=>{if(h){let t=h.toLowerCase();if(!e.name.toLowerCase().includes(t)&&!e.content.toLowerCase().includes(t))return!1}if(x&&e.agentId!==x)return!1;if(b){if("__none__"===b){if(e.group)return!1}else if(e.group!==b)return!1}return!0}),Y=async()=>{if(0===N.length)return;let e=x||(i.length>0?i[0].agentId:"");if(e){if(1===N.length){let t=await N[0].file.text(),n=N[0].file.name.replace(/\.(md|txt|markdown)$/i,"");k([]),y(!1),C(null),D(!0),T(n),_(t),O(e),z("");return}for(let t of N){let n=await t.file.text(),r=t.file.name.replace(/\.(md|txt|markdown)$/i,"");await fetch(`/api/agent-commands/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r,content:n})})}k([]),y(!1),X()}},Z=()=>{C(null),D(!1),T(""),_(""),z("")},Q=async()=>{if(I.trim()&&L.trim()&&A){$(!0);try{S?(await fetch(`/api/agent-commands/${A}/${S.name}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:L,group:P})})).ok&&(Z(),X()):(await fetch(`/api/agent-commands/${A}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:I,content:L,group:P||void 0})})).ok&&(Z(),X())}catch{}$(!1)}},ee=async e=>{try{let t=e.group?`?group=${encodeURIComponent(e.group)}`:"";(await fetch(`/api/agent-commands/${e.agentId}/${e.name}${t}`,{method:"DELETE"})).ok&&X()}catch{}},et=async()=>{if(W&&0!==U.length){V(!0);try{await fetch(`/api/agent-commands/${W.agentId}/${W.name}/apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({group:W.group,agentIds:U})}),B(null),X()}catch{}V(!1)}},en=e&&!S&&!E&&!W,er=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ec.DialogHeader,{children:(0,t.jsx)("div",{className:"flex items-center justify-between pr-8",children:(0,t.jsxs)("div",{className:"hidden md:block",children:[(0,t.jsx)(ec.DialogTitle,{children:a("title")}),(0,t.jsx)(ec.DialogDescription,{children:a("description")})]})})}),(0,t.jsxs)("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:[(0,t.jsxs)(eS.Popover,{open:j,onOpenChange:y,children:[(0,t.jsx)(eS.PopoverTrigger,{render:(0,t.jsxs)(c.Button,{variant:"outline",size:"sm",children:[(0,t.jsx)(ef.Upload,{className:"size-3.5 mr-1"}),a("import")]})}),(0,t.jsx)(eS.PopoverContent,{className:"w-80",align:"end",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:a("importTitle")}),(0,t.jsx)(eC.FileUpload,{value:N,onChange:k,accept:{"text/markdown":[".md",".txt"],"":[".md",".txt"]},placeholder:a("importPlaceholder"),maxFiles:10}),(0,t.jsx)(c.Button,{size:"sm",onClick:Y,disabled:0===N.length,className:"w-full",children:a("importConfirm")})]})})]}),(0,t.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:()=>{C(null),D(!0),T(""),_(""),z(""),O(x||(i.length>0?i[0].agentId:""))},children:[(0,t.jsx)(eh.Plus,{className:"size-3.5 mr-1"}),a("create")]})]}),(0,t.jsxs)("div",{className:"flex flex-1 min-h-0 gap-4 pt-2",children:[(0,t.jsx)(ed.ScrollArea,{className:"hidden md:block w-44 shrink-0",children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 pr-2",children:[(0,t.jsx)("div",{className:"space-y-1",children:(0,t.jsxs)(c.Button,{variant:x||b?"ghost":"secondary",size:"sm",className:"w-full justify-start",onClick:()=>{v(""),w("")},children:[(0,t.jsx)(eI.FileText,{className:"size-3.5 mr-1.5"}),a("allAgents")]})}),i.length>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground px-2",children:a("selectAgent")}),i.map(e=>(0,t.jsxs)(c.Button,{variant:x===e.agentId?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{v(e.agentId),w("")},children:[(0,t.jsx)(eE.AgentIcon,{agentId:e.agentId,name:e.agentName,avatarUrl:e.avatarUrl,className:"size-4 mr-1.5 rounded-full"}),(0,t.jsx)("span",{className:"truncate",children:e.agentName}),(0,t.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:e.commandCount})]},e.agentId))]}),G.length>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground px-2",children:a("filterGroups")}),G.map(e=>(0,t.jsxs)(c.Button,{variant:b===e?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{w(b===e?"":e),v("")},children:[(0,t.jsx)(eM.Folder,{className:"size-3.5 mr-1.5"}),(0,t.jsx)("span",{className:"truncate",children:e})]},e)),u.some(e=>!e.group)&&(0,t.jsxs)(c.Button,{variant:"__none__"===b?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{w("__none__"===b?"":"__none__"),v("")},children:[(0,t.jsx)(eI.FileText,{className:"size-3.5 mr-1.5"}),a("filterNoGroup")]})]})]})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-3 min-h-0",children:[(0,t.jsxs)("div",{className:"flex md:hidden flex-col gap-2",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(eD.Search,{className:"size-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(d.Input,{value:h,onChange:e=>g(e.target.value),placeholder:a("search"),className:"pl-8"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 overflow-x-auto",children:[(0,t.jsx)("button",{className:(0,l.cn)("px-2.5 py-1 rounded-md text-xs font-medium transition-colors shrink-0 border",x||b?"border-input text-muted-foreground":"bg-muted border-muted"),onClick:()=>{v(""),w("")},children:a("allAgents")}),i.slice(0,5).map(e=>(0,t.jsx)("button",{className:(0,l.cn)("px-2.5 py-1 rounded-md text-xs font-medium transition-colors shrink-0 border",x===e.agentId?"bg-muted border-muted":"border-input text-muted-foreground"),onClick:()=>{v(e.agentId),w("")},children:e.agentName},e.agentId))]})]}),(0,t.jsxs)("div",{className:"hidden md:block relative",children:[(0,t.jsx)(eD.Search,{className:"size-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(d.Input,{value:h,onChange:e=>g(e.target.value),placeholder:a("search"),className:"pl-8"})]}),(0,t.jsx)(ed.ScrollArea,{className:"flex-1 min-h-0",children:p?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:s("loading")}):0===J.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:a("empty")}):(0,t.jsx)("div",{className:"grid grid-cols-1 gap-3 pr-2",children:J.map(e=>{var n;let r;return(0,t.jsx)("div",{className:"rounded-xl border border-border bg-background p-4 hover:bg-accent/30 transition-colors cursor-pointer",onClick:()=>{C(e),D(!1),T(e.name),_(e.content),z(e.group),O(e.agentId)},children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"font-medium text-sm",children:e.name}),e.group&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:e.group}),!x&&(0,t.jsx)(eE.AgentIcon,{agentId:e.agentId,name:e.agentName||e.agentId,avatarUrl:(n=e.agentId,r=i.find(e=>e.agentId===n),r?.avatarUrl),className:"size-4 rounded-full"})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:e.content.slice(0,120).replace(/^#\s+/,"")})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)(c.Button,{variant:"outline",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>{B(e),H([])},children:[(0,t.jsx)(eT.Rocket,{className:"size-3 mr-0.5"}),a("apply")]}),(0,t.jsxs)(em.DropdownMenu,{children:[(0,t.jsx)(em.DropdownMenuTrigger,{render:(0,t.jsx)(c.Button,{variant:"ghost",size:"icon",className:"size-7"}),children:(0,t.jsx)(ex.MoreVertical,{className:"size-3.5"})}),(0,t.jsx)(em.DropdownMenuContent,{align:"end",children:(0,t.jsxs)(em.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>ee(e),children:[(0,t.jsx)(F.Trash2,{className:"size-3.5 mr-1.5"}),a("delete")]})})]})]})]})},`${e.agentId}-${e.group}-${e.name}`)})})})]})]})]});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ec.Dialog,{open:en,onOpenChange:n,children:(0,t.jsx)(ec.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:er})}),(0,t.jsx)(ec.Dialog,{open:!!S||E,onOpenChange:e=>{e||Z()},children:(0,t.jsxs)(ec.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:[(0,t.jsx)(ec.DialogHeader,{children:(0,t.jsxs)("div",{className:"flex items-center justify-between pr-8",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(ec.DialogTitle,{children:S?a("editTitle",{name:S.name}):a("createTitle")}),(0,t.jsx)(ec.DialogDescription,{children:a("editDescription")})]}),(0,t.jsxs)(c.Button,{size:"sm",onClick:Q,disabled:R||!I.trim()||!L.trim(),children:[(0,t.jsx)(eg.Save,{className:"size-3.5 mr-1"}),s("save")]})]})}),(0,t.jsxs)("div",{className:"flex items-center gap-2 pb-2",children:[(0,t.jsx)(d.Input,{value:I,onChange:e=>T(e.target.value),placeholder:a("namePlaceholder"),disabled:!!S,className:"flex-1"}),(0,t.jsx)(d.Input,{value:P,onChange:e=>z(e.target.value),placeholder:a("groupPlaceholder"),className:"w-40"})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(ez,{height:"100%",language:"markdown",value:L,onChange:e=>_(e||""),theme:"vs-dark",options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,padding:{top:8},renderLineHighlight:"gutter",wordWrap:"on"}})})]})}),(0,t.jsx)(eP.AgentPickerDialog,{open:!!W,onClose:()=>B(null),onConfirm:et,title:a("applyTitle",{name:W?.name||""}),description:a("applyDescription"),agents:i.map(e=>({id:e.agentId,name:e.agentName,avatarUrl:e.avatarUrl})),selected:U,onToggle:e=>H(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),cancelText:s("cancel"),confirmText:a("applyConfirm",{count:U.length}),loading:K})]})}var eO=e.i(113519),eL=e.i(256186),e_=e.i(650654),eR=e.i(249673),e$=e.i(315775),eF=e.i(267624);function eW({routes:e}){let{state:a,isMobile:s,setOpenMobile:i}=g(),o="collapsed"===a,[c,d]=(0,r.useState)(new Set),u=(0,n.useRouter)(),m=(0,M.useTranslations)("common"),p=e=>{s&&i(!1),(0,T.tauriNavigate)(u,e)};return(0,t.jsx)(k,{children:e.map(e=>{let n=!o&&c.has(e.id),r=!!e.subs?.length,a=r||!!e.onAdd;return(0,t.jsx)(S,{children:a?o?(0,t.jsxs)(eS.Popover,{children:[(0,t.jsx)(eS.PopoverTrigger,{render:(0,t.jsx)(E,{className:"justify-center text-muted-foreground hover:bg-sidebar-muted hover:text-foreground",tooltip:e.title}),children:e.icon}),(0,t.jsxs)(eS.PopoverContent,{side:"right",sideOffset:8,className:"w-56 p-1.5",children:[(0,t.jsx)("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground mb-1",children:e.title}),e.subs?.map(n=>(0,t.jsxs)("div",{className:"group/sub relative flex items-center",children:[n.onClick?(0,t.jsxs)("button",{type:"button",onClick:n.onClick,className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground cursor-pointer",children:[n.icon,n.title]}):(0,t.jsxs)("button",{type:"button",onClick:()=>p(n.link),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground cursor-pointer",children:[n.icon,n.title]}),n.menuItems&&n.menuItems.length>0&&(0,t.jsxs)(em.DropdownMenu,{children:[(0,t.jsx)(em.DropdownMenuTrigger,{className:"absolute right-1 flex items-center justify-center rounded-md p-0.5 opacity-0 group-hover/sub:opacity-100 hover:bg-accent transition-opacity cursor-pointer",onClick:e=>e.stopPropagation(),children:(0,t.jsx)(e$.MoreHorizontal,{className:"size-3.5 text-muted-foreground"})}),(0,t.jsx)(em.DropdownMenuContent,{align:"end",side:"right",children:n.menuItems.map(e=>(0,t.jsxs)(em.DropdownMenuItem,{variant:e.variant,onClick:e.onClick,children:[e.icon,e.label]},e.label))})]})]},`${e.id}-${n.title}`)),e.onAdd&&(0,t.jsxs)("button",{type:"button",onClick:e.onAdd,className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground mt-0.5 cursor-pointer",children:[(0,t.jsx)(eh.Plus,{className:"size-3.5"}),e.addLabel??m("add")]}),e.manageLink&&(0,t.jsxs)("button",{type:"button",onClick:()=>p(e.manageLink),className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground mt-0.5 cursor-pointer",children:[(0,t.jsx)(eF.LayoutGrid,{className:"size-3.5"}),m("manage")]})]})]}):(0,t.jsxs)(eL.Collapsible,{open:n,onOpenChange:t=>d(n=>{let r=new Set(n);return t?r.add(e.id):r.delete(e.id),r}),className:"w-full",children:[(0,t.jsxs)(eL.CollapsibleTrigger,{render:(0,t.jsx)(E,{className:(0,l.cn)("group/hdr flex flex-1 items-center rounded-lg px-2 transition-colors",n?"bg-sidebar-muted text-foreground":"text-muted-foreground hover:bg-sidebar-muted hover:text-foreground")}),children:[e.icon,(0,t.jsx)("span",{className:"ml-2 flex-1 text-sm font-medium",children:e.title}),r&&(0,t.jsx)("span",{children:n?(0,t.jsx)(eR.ChevronUp,{className:"size-4"}):(0,t.jsx)(e_.ChevronDown,{className:"size-4"})})]}),(0,t.jsx)(eL.CollapsibleContent,{children:(0,t.jsxs)(D,{className:"my-1 ml-3.5",children:[e.subs?.map(n=>(0,t.jsx)(S,{className:"h-auto",children:(0,t.jsxs)("div",{className:"group/sub relative flex items-center",children:[(0,t.jsx)(I,{render:n.onClick?(0,t.jsx)("button",{type:"button",onClick:n.onClick,className:"flex w-full items-center rounded-md px-4 py-1.5 text-sm font-medium text-muted-foreground hover:bg-sidebar-muted hover:text-foreground cursor-pointer"}):(0,t.jsx)("button",{type:"button",onClick:()=>p(n.link),className:"flex w-full items-center rounded-md px-4 py-1.5 text-sm font-medium text-muted-foreground hover:bg-sidebar-muted hover:text-foreground cursor-pointer"}),children:n.title}),n.menuItems&&n.menuItems.length>0&&(0,t.jsxs)(em.DropdownMenu,{children:[(0,t.jsx)(em.DropdownMenuTrigger,{className:"absolute right-1 flex items-center justify-center rounded-md p-0.5 opacity-0 group-hover/sub:opacity-100 hover:bg-sidebar-muted transition-opacity cursor-pointer",onClick:e=>e.stopPropagation(),children:(0,t.jsx)(e$.MoreHorizontal,{className:"size-3.5 text-muted-foreground"})}),(0,t.jsx)(em.DropdownMenuContent,{align:"end",side:"right",children:n.menuItems.map(e=>(0,t.jsxs)(em.DropdownMenuItem,{variant:e.variant,onClick:e.onClick,children:[e.icon,e.label]},e.label))})]})]})},`${e.id}-${n.title}`)),e.onAdd&&(0,t.jsx)(S,{children:(0,t.jsxs)("button",{type:"button",onClick:e.onAdd,className:"flex w-full items-center gap-2 rounded-md px-4 py-1.5 text-sm font-medium text-muted-foreground hover:bg-sidebar-muted hover:text-foreground cursor-pointer",children:[(0,t.jsx)(eh.Plus,{className:"size-3.5"}),e.addLabel??m("add")]})}),e.manageLink&&(0,t.jsx)(S,{children:(0,t.jsxs)("button",{type:"button",onClick:()=>p(e.manageLink),className:"flex w-full items-center gap-2 rounded-md px-4 py-1.5 text-sm font-medium text-muted-foreground hover:bg-sidebar-muted hover:text-foreground cursor-pointer",children:[(0,t.jsx)(eF.LayoutGrid,{className:"size-3.5"}),m("manage")]})})]})})]}):(0,t.jsxs)(E,{tooltip:e.title,render:(0,t.jsx)("button",{type:"button",onClick:()=>p(e.link),className:(0,l.cn)("flex items-center rounded-lg px-2 transition-colors cursor-pointer text-muted-foreground hover:bg-sidebar-muted hover:text-foreground",o&&"justify-center")}),children:[e.icon,!o&&(0,t.jsx)("span",{className:"ml-2 text-sm font-medium",children:e.title})]})},e.id)})})}var eB=e.i(36539),eB=eB,eU=e.i(875350),eH=e.i(506037),eK=e.i(487122),eV=e.i(238153),eq=e.i(492421),eX=e.i(632713),eG=e.i(539392),eJ=e.i(516467);function eY(e,t){let n=(0,eJ.toDate)(e)-(0,eJ.toDate)(t);return n<0?-1:n>0?1:n}var eZ=e.i(511518),eQ=e.i(731285),e0=e.i(936765);function e1(e,t){return function(e,t,n){var r;let a,s=(0,eq.getDefaultOptions)(),i=n?.locale??s.locale??eV.defaultLocale,o=eY(e,t);if(isNaN(o))throw RangeError("Invalid time value");let l=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:o}),[c,d]=(0,eG.normalizeDates)(n?.in,...o>0?[t,e]:[e,t]),u=(r=void 0,e=>{let t=(r?Math[r]:Math.trunc)(e);return 0===t?0:t})(((0,eJ.toDate)(d)-(0,eJ.toDate)(c))/1e3),m=Math.round((u-((0,eX.getTimezoneOffsetInMilliseconds)(d)-(0,eX.getTimezoneOffsetInMilliseconds)(c))/1e3)/60);if(m<2)if(n?.includeSeconds)if(u<5)return i.formatDistance("lessThanXSeconds",5,l);else if(u<10)return i.formatDistance("lessThanXSeconds",10,l);else if(u<20)return i.formatDistance("lessThanXSeconds",20,l);else if(u<40)return i.formatDistance("halfAMinute",0,l);else if(u<60)return i.formatDistance("lessThanXMinutes",1,l);else return i.formatDistance("xMinutes",1,l);else if(0===m)return i.formatDistance("lessThanXMinutes",1,l);else return i.formatDistance("xMinutes",m,l);if(m<45)return i.formatDistance("xMinutes",m,l);if(m<90)return i.formatDistance("aboutXHours",1,l);if(m<eZ.minutesInDay){let e=Math.round(m/60);return i.formatDistance("aboutXHours",e,l)}if(m<2520)return i.formatDistance("xDays",1,l);else if(m<eZ.minutesInMonth){let e=Math.round(m/eZ.minutesInDay);return i.formatDistance("xDays",e,l)}else if(m<2*eZ.minutesInMonth)return a=Math.round(m/eZ.minutesInMonth),i.formatDistance("aboutXMonths",a,l);if((a=function(e,t){var n;let r,a,[s,i,o]=(0,eG.normalizeDates)(void 0,e,e,t),l=eY(i,o),c=Math.abs((0,eQ.differenceInCalendarMonths)(i,o));if(c<1)return 0;1===i.getMonth()&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-l*c);let d=eY(i,o)===-l;+(r=(0,eJ.toDate)(s,void 0),n=void 0,(a=(0,eJ.toDate)(r,n?.in)).setHours(23,59,59,999),a)==+(0,e0.endOfMonth)(r,void 0)&&1===c&&1===eY(s,o)&&(d=!1);let u=l*(c-d);return 0===u?0:u}(d,c))<12){let e=Math.round(m/eZ.minutesInMonth);return i.formatDistance("xMonths",e,l)}{let e=a%12,t=Math.trunc(a/12);return e<3?i.formatDistance("aboutXYears",t,l):e<9?i.formatDistance("overXYears",t,l):i.formatDistance("almostXYears",t+1,l)}}(e,(0,eK.constructFrom)(e,Date.now()),t)}let e2=(0,V.default)("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]),e5={issue_completed:"✓",issue_failed:"✕",task_completed:"✓",task_failed:"✕"},e3={issue_completed:"text-green-600 bg-green-100 dark:bg-green-900/30 dark:text-green-400",issue_failed:"text-red-600 bg-red-100 dark:bg-red-900/30 dark:text-red-400",task_completed:"text-green-600 bg-green-100 dark:bg-green-900/30 dark:text-green-400",task_failed:"text-red-600 bg-red-100 dark:bg-red-900/30 dark:text-red-400"};function e4({open:e,onOpenChange:n,workspaceId:a,initialNotification:s}){let i=(0,M.useTranslations)("sidebar.notifications"),o=(0,eH.useNotificationStore)(e=>e.notifications),d=(0,eH.useNotificationStore)(e=>e.markRead),u=(0,eH.useNotificationStore)(e=>e.markAllRead),m=(0,eH.useNotificationStore)(e=>e.clearAll),[p,f]=(0,r.useState)(null),h=s&&!p?s:p;return(0,t.jsx)(ec.Dialog,{open:e,onOpenChange:e=>{e||f(null),n(e)},children:(0,t.jsxs)(ec.DialogContent,{className:"sm:max-w-lg max-h-[80vh] flex flex-col gap-0 overflow-hidden p-0",children:[(0,t.jsx)(ec.DialogHeader,{className:"px-6 py-4 border-b shrink-0",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ec.DialogTitle,{children:i("centerTitle")}),o.some(e=>!e.read)&&(0,t.jsx)("span",{className:"inline-flex items-center justify-center size-5 rounded-full bg-blue-500 text-[10px] font-medium text-white",children:o.filter(e=>!e.read).length})]}),o.some(e=>!e.read)&&(0,t.jsxs)(c.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>u(a),children:[(0,t.jsx)(e2,{className:"size-3.5"}),i("markAllRead")]})]})}),(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:h?(0,t.jsxs)("div",{className:"px-6 py-4",children:[(0,t.jsxs)("div",{className:(0,l.cn)("inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium mb-3",e3[h.type]??""),children:[e5[h.type]??""," ",h.type]}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:h.title}),h.description&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-3",children:h.description}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e1(new Date(h.createdAt),{addSuffix:!0})}),Object.keys(h.data).length>0&&(0,t.jsx)("pre",{className:"mt-3 text-xs bg-muted rounded p-3 overflow-auto",children:JSON.stringify(h.data,null,2)})]}):0===o.length?(0,t.jsx)("div",{className:"px-6 py-12 text-center text-sm text-muted-foreground",children:i("empty")}):(0,t.jsx)("div",{className:"divide-y",children:o.map(e=>(0,t.jsxs)("button",{className:(0,l.cn)("flex w-full items-start gap-3 px-6 py-3.5 text-left hover:bg-accent/50 transition-colors",!e.read&&"bg-accent/30"),onClick:()=>{e.read||d(a,e.id),f(e)},children:[(0,t.jsx)("div",{className:(0,l.cn)("mt-1 size-2 rounded-full shrink-0",e.read?"bg-transparent":"bg-blue-500")}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:e.title}),e.description&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-1 mt-0.5",children:e.description}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:e1(new Date(e.createdAt),{addSuffix:!0})})]})]},e.id))})}),o.length>0&&(0,t.jsx)("div",{className:"px-6 py-3 border-t shrink-0 flex justify-end",children:(0,t.jsxs)(c.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1 text-destructive",onClick:()=>{m(a),n(!1)},children:[(0,t.jsx)(eU.Trash2Icon,{className:"size-3.5"}),i("clearAll")]})})]})})}function e6({workspaceId:e}){let n=(0,M.useTranslations)("sidebar.notifications"),a=(0,eH.useNotificationStore)(e=>e.notifications),s=(0,eH.useNotificationStore)(e=>e.markRead),i=(0,eH.useNotificationStore)(e=>e.clearAll),o=a.filter(e=>!e.read).length,[d,u]=(0,r.useState)(!1),[m,p]=(0,r.useState)(!1),[f,h]=(0,r.useState)(null),g=a.slice(0,5);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(eS.Popover,{open:d,onOpenChange:u,children:[(0,t.jsxs)(eS.PopoverTrigger,{render:(0,t.jsx)(c.Button,{variant:"ghost",size:"icon",className:"rounded-full relative","aria-label":n("openAriaLabel")}),children:[(0,t.jsx)(eB.default,{className:"size-5"}),o>0&&(0,t.jsx)("span",{className:"absolute -top-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-red-500 text-[10px] font-medium text-white",children:o>9?"9+":o})]}),(0,t.jsxs)(eS.PopoverContent,{side:"right",className:"w-80 max-h-[70dvh] my-6 p-0",align:"start",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b",children:[(0,t.jsx)("span",{className:"text-sm font-semibold",children:n("title")}),a.length>0&&(0,t.jsx)("div",{className:"flex gap-1",children:(0,t.jsx)(c.Button,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(e),title:n("clearAll"),children:(0,t.jsx)(eU.Trash2Icon,{className:"size-3.5"})})})]}),(0,t.jsx)(ed.ScrollArea,{className:"max-h-[50dvh] overflow-hidden",children:0===g.length?(0,t.jsx)("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:n("empty")}):(0,t.jsx)("div",{className:"divide-y",children:g.map(n=>(0,t.jsxs)("button",{className:(0,l.cn)("flex w-full items-start gap-3 px-4 py-3 text-left hover:bg-accent/50 transition-colors",!n.read&&"bg-accent/30"),onClick:()=>{n.read||s(e,n.id),h(n),p(!0)},children:[(0,t.jsx)("div",{className:(0,l.cn)("mt-1 size-2 rounded-full shrink-0",n.read?"bg-transparent":"bg-blue-500")}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:n.title}),n.description&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-0.5",children:n.description}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:e1(new Date(n.createdAt),{addSuffix:!0})})]})]},n.id))})}),a.length>5&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"border-t"}),(0,t.jsx)("button",{className:"w-full px-4 py-2.5 text-sm text-muted-foreground hover:text-primary hover:bg-accent/30 transition-colors cursor-pointer",onClick:()=>{h(null),u(!1),p(!0)},children:n("viewAll")})]})]})]}),(0,t.jsx)(e4,{open:m,onOpenChange:p,workspaceId:e,initialNotification:f})]})}var e8=e.i(344118);let e9=(0,V.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);var e7=e.i(210),te=e.i(523592);function tt({open:e,onOpenChange:n,editingId:a,servers:s,onSave:i}){let o=(0,M.useTranslations)("sidebar"),l=(0,M.useTranslations)("common"),[u,m]=r.useState(""),[p,f]=r.useState(""),[h,g]=r.useState("");return r.useEffect(()=>{if(e&&a){let e=s.find(e=>e.id===a);e&&(m(e.name),f(e.url),g(e.secret||""))}else e&&(m(""),f(""),g(""))},[e,a,s]),(0,t.jsx)(ec.Dialog,{open:e,onOpenChange:n,children:(0,t.jsxs)(ec.DialogContent,{children:[(0,t.jsxs)(ec.DialogHeader,{children:[(0,t.jsx)(ec.DialogTitle,{children:o(a?"server.editServer":"server.addServer")}),(0,t.jsx)(ec.DialogDescription,{children:o(a?"server.editDescription":"server.addDescription")})]}),(0,t.jsxs)("div",{className:"space-y-4 py-2",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium",children:l("name")}),(0,t.jsx)(d.Input,{value:u,onChange:e=>m(e.target.value),placeholder:"My Server"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium",children:o("server.url")}),(0,t.jsx)(d.Input,{value:p,onChange:e=>f(e.target.value),placeholder:"http://192.168.1.100:3100",onKeyDown:e=>"Enter"===e.key&&e.preventDefault()})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium",children:o("server.secret")}),(0,t.jsx)(d.Input,{type:"password",value:h,onChange:e=>g(e.target.value),placeholder:o("server.secretPlaceholder"),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()})]})]}),(0,t.jsxs)(ec.DialogFooter,{children:[(0,t.jsx)(c.Button,{variant:"outline",onClick:()=>n(!1),children:l("cancel")}),(0,t.jsx)(c.Button,{onClick:()=>{if(!u.trim()||!p.trim())return;let e=p.trim().replace(/\/$/,"");/^https?:\/\//.test(e)||(e="http://"+e),a?i(s.map(t=>t.id===a?{...t,name:u.trim(),url:e,secret:h.trim()||void 0}:t)):i([...s,{id:Date.now().toString(),name:u.trim(),url:e,secret:h.trim()||void 0}]),n(!1)},disabled:!u.trim()||!p.trim(),children:l(a?"save":"add")})]})]})})}var tn=e.i(894920),tr=e.i(691223);function ta(){let{isMobile:e}=g(),n=(0,M.useTranslations)("sidebar"),[a,s]=r.useState(te.loadServers),[i,o]=r.useState(te.loadActiveId),[l,c]=r.useState(!1),[d,u]=r.useState(null),[m,p]=r.useState(!1),f=a.find(e=>e.id===i)||a[0],h=r.useCallback(e=>{tr.useEditorStore.getState().resetEditorState(),o(e.id),(0,te.saveActiveId)(e.id),(0,te.setActiveServerCookie)(e.url),window.location.href="/"},[]),x=r.useCallback(e=>{if("default"===e)return;let t=a.filter(t=>t.id!==e);if(s(t),(0,te.saveServers)(t),i===e){let e=t.find(e=>"default"===e.id)||t[0];e&&h(e)}},[i,a,h]);return f?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(k,{children:(0,t.jsx)(S,{children:(0,t.jsxs)(em.DropdownMenu,{children:[(0,t.jsxs)(em.DropdownMenuTrigger,{render:(0,t.jsx)(E,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"}),children:[(0,t.jsx)("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-background text-foreground",children:(0,t.jsx)(R.Server,{className:"size-4"})}),(0,t.jsxs)("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[(0,t.jsx)("span",{className:"truncate font-semibold",children:f.name}),(0,t.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:f.url.replace(/^https?:\/\//,"")})]}),(0,t.jsx)(e9,{className:"ml-auto"})]}),(0,t.jsxs)(em.DropdownMenuContent,{className:"w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg mb-4",align:"start",side:e?"bottom":"right",sideOffset:4,children:[(0,t.jsx)(em.DropdownMenuGroup,{children:(0,t.jsx)(em.DropdownMenuLabel,{className:"text-xs text-muted-foreground",children:n("server.servers")})}),a.map(e=>(0,t.jsxs)(em.DropdownMenuItem,{onClick:()=>h(e),className:"gap-2 p-2",children:[(0,t.jsx)("div",{className:"flex size-6 items-center justify-center rounded-sm border",children:(0,t.jsx)(R.Server,{className:"size-3.5 shrink-0"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-sm truncate",children:e.name}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:e.url})]}),e.id===i&&(0,t.jsx)(e8.Check,{className:"size-4 text-primary shrink-0"})]},e.id)),(0,t.jsx)(em.DropdownMenuSeparator,{}),(0,t.jsxs)(em.DropdownMenuItem,{className:"gap-2 p-2",onClick:()=>{u(null),c(!0)},children:[(0,t.jsx)("div",{className:"flex size-6 items-center justify-center rounded-md border bg-background",children:(0,t.jsx)(eh.Plus,{className:"size-4"})}),(0,t.jsx)("div",{className:"font-medium text-muted-foreground",children:n("server.addServer")})]}),(0,t.jsxs)(em.DropdownMenuItem,{className:"gap-2 p-2",onClick:()=>p(!0),children:[(0,t.jsx)("div",{className:"flex size-6 items-center justify-center rounded-md border bg-background",children:(0,t.jsx)(e7.Settings2,{className:"size-4"})}),(0,t.jsx)("div",{className:"font-medium text-muted-foreground",children:n("server.manageServers")})]})]})]})})}),(0,t.jsx)(tt,{open:l,onOpenChange:c,editingId:d,servers:a,onSave:e=>{s(e),(0,te.saveServers)(e);let t=d?e.find(e=>e.id===d):e[e.length-1];d&&t&&d===i&&(0,te.setActiveServerCookie)(t.url)}}),(0,t.jsx)(tn.ServerManagerDialog,{open:m,onOpenChange:p,servers:a,activeId:i,onUpdate:e=>{s(e),(0,te.saveServers)(e);let t=e.find(e=>e.id===i);t&&(0,te.setActiveServerCookie)(t.url)},onRemove:x,onSwitch:h})]}):null}var ts=e.i(524),ti=e.i(640376),to=e.i(31807),tl=e.i(327964),tc=e.i(250226),td=e.i(286117);function tu(e){return`/workspace/${e}`}function tm(){let{state:e,toggleSidebar:a}=g(),s=(0,n.usePathname)(),i=(0,n.useRouter)(),c=(0,M.useTranslations)("sidebar"),d=(0,M.useTranslations)("common"),u="collapsed"===e,m=(0,td.isWorkspacePath)(s),p=(0,o.useIsMobile)(),f=(0,td.workspaceIdFromLocation)(s,window.location.search),h=(0,ey.useWorkspaceStore)(e=>e.workspaces),x=(0,ey.useWorkspaceStore)(e=>e.setWorkspaces),w=(0,ey.useWorkspaceStore)(e=>e.upsertWorkspace),k=(0,ey.useWorkspaceStore)(e=>e.removeWorkspace),[S,C]=(0,r.useState)(!1),[E,D]=(0,r.useState)(!1),[I,V]=(0,r.useState)(!1),[el,ec]=(0,r.useState)(!1),[ed,eu]=(0,r.useState)(!1),[em,ep]=(0,r.useState)(!1),[ef,eh]=(0,r.useState)(!1),[eg,ex]=(0,r.useState)(!1),[ev,eb]=(0,r.useState)(!1),[ew,ej]=(0,r.useState)(!1),[eN,eS]=(0,r.useState)(!1),[eC,eE]=(0,r.useState)(!1),[eD,eI]=(0,r.useState)(null),[eM,eT]=(0,r.useState)(void 0),eP=(0,r.useCallback)(()=>{fetch("/api/workspaces").then(e=>e.json()).then(x).catch(()=>{})},[x]);(0,r.useEffect)(()=>{eP()},[eP]),(0,r.useEffect)(()=>{let e=()=>a(),t=e=>{let t=e.detail,n={agents:"/settings/agents",skills:"/settings/skills",prompts:"/settings/prompts","output-styles":"/settings/output-styles",mcps:"/settings/mcps",models:"/settings/models",providers:"/settings/providers",hooks:"/settings",commands:"/settings",settings:"/settings"};if(p&&n[t])return void i.push(n[t]);let r={agents:C,skills:eu,prompts:ep,"output-styles":eh,mcps:ex,models:V,providers:ec,hooks:eb,commands:ej,tools:eS,settings:D};r[t]&&r[t](!0)};return window.addEventListener("toggle-sidebar",e),window.addEventListener("open-dialog",t),()=>{window.removeEventListener("toggle-sidebar",e),window.removeEventListener("open-dialog",t)}},[a,p]);let ez=(0,ti.useCommandPalette)(e=>e.registerMany);(0,r.useEffect)(()=>{let e=(e,t)=>{p||!t?i.push(e):t(!0)};return ez([{id:"toggle-sidebar",label:"Toggle Sidebar",group:"View",icon:q,action:()=>a()},{id:"latest-channel",label:"Open Latest Channel",group:"Navigation",icon:X.Hash,action:()=>{let{channels:e,setActiveChannel:t}=to.useChannelStore.getState();e.length>0&&(t(e[e.length-1].id),tc.useMobilePanelStore.getState().setActivePanel("chat"))}},{id:"latest-issue",label:"Open Latest Issue",group:"Navigation",icon:G.CircleDot,action:()=>{let{issues:e,setActiveIssue:t}=tl.useIssueStore.getState();e.length>0&&(t(e[e.length-1].id),tc.useMobilePanelStore.getState().setActivePanel("issue-detail"))}},{id:"open-settings",label:"Open General Settings",group:"Settings",icon:O.Settings,action:()=>e("/settings",D)},{id:"open-agents",label:"Open Agent Settings",group:"Settings",icon:L.Bot,action:()=>e("/settings/agents",C)},{id:"open-skills",label:"Open Skills Settings",group:"Settings",icon:U.Sparkles,action:()=>e("/settings/skills",eu)},{id:"open-prompts",label:"Open Prompt Settings",group:"Settings",icon:H.MessageSquare,action:()=>e("/settings/prompts",ep)},{id:"open-output-styles",label:"Open Output Style Settings",group:"Settings",icon:$.Pencil,action:()=>e("/settings/output-styles",eh)},{id:"open-mcps",label:"Open MCP Settings",group:"Settings",icon:K.Plug,action:()=>e("/settings/mcps",ex)},{id:"open-models",label:"Open Model Settings",group:"Settings",icon:_.Brain,action:()=>{p?i.push("/settings/models"):(eT(void 0),V(!0))}},{id:"open-providers",label:"Open Provider Settings",group:"Settings",icon:R.Server,action:()=>e("/settings/providers",ec)},{id:"open-hooks",label:"Open Hook Settings",group:"Settings",icon:J.Zap,action:()=>{p?i.push("/settings"):eb(!0)}},{id:"open-commands",label:"Open Agent Commands",group:"Settings",icon:Z.Terminal,action:()=>{p?i.push("/settings"):ej(!0)}},{id:"open-tools",label:"Open Tools Settings",group:"Settings",icon:Y.Wrench,action:()=>{p?i.push("/settings/tools"):eS(!0)}},{id:"open-workflows",label:"Open Workflow Settings",group:"Navigation",icon:B.GitBranch,action:()=>{i.push("/workflows")}}])},[ez,a,p]);let eL=async e=>{if(eD){let t=await fetch(`/api/workspaces/${eD.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});w(await t.json())}else{let t=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});w(await t.json())}},e_=async e=>{if(await fetch(`/api/workspaces/${e.id}`,{method:"DELETE"}),k(e.id),f===e.id){let t=h.filter(t=>t.id!==e.id);(0,T.tauriNavigate)(i,t.length>0?tu(t[0].id):"/")}},eR=[{id:"home",title:c("nav.home"),icon:(0,t.jsx)(z.Home,{className:"size-4"}),link:"/"},{id:"workspaces",title:c("nav.workspaces"),icon:(0,t.jsx)(A.FolderOpen,{className:"size-4"}),link:"/",onAdd:()=>{eI(null),eE(!0)},addLabel:c("nav.addWorkspace"),manageLink:"/workspaces",subs:[...h.map(e=>({title:e.name,link:tu(e.id),icon:(0,t.jsx)(A.FolderOpen,{className:"size-4"}),menuItems:[{label:d("edit"),icon:(0,t.jsx)($.Pencil,{className:"size-3.5"}),onClick:()=>{eI(e),eE(!0)}},{label:d("open"),icon:(0,t.jsx)(W.FolderSearch,{className:"size-3.5"}),onClick:()=>fetch(`/api/workspaces/${e.id}/reveal`,{method:"POST"})},{label:d("delete"),icon:(0,t.jsx)(F.Trash2,{className:"size-3.5"}),variant:"destructive",onClick:()=>e_(e)}]}))]},{id:"workflows",title:c("nav.workflows"),icon:(0,t.jsx)(B.GitBranch,{className:"size-4"}),link:"/workflows"},{id:"settings",title:c("nav.settings"),icon:(0,t.jsx)(O.Settings,{className:"size-4"}),link:"#",subs:p?[{title:c("nav.general"),link:"/settings",icon:(0,t.jsx)(Y.Wrench,{className:"size-3.5"})},{title:c("nav.agents"),link:"/settings/agents",icon:(0,t.jsx)(L.Bot,{className:"size-3.5"})},{title:c("nav.skills"),link:"/settings/skills",icon:(0,t.jsx)(U.Sparkles,{className:"size-3.5"})},{title:c("nav.prompts"),link:"/settings/prompts",icon:(0,t.jsx)(H.MessageSquare,{className:"size-3.5"})},{title:c("nav.outputStyles"),link:"/settings/output-styles",icon:(0,t.jsx)($.Pencil,{className:"size-3.5"})},{title:c("nav.mcps"),link:"/settings/mcps",icon:(0,t.jsx)(K.Plug,{className:"size-3.5"})},{title:c("nav.tools"),link:"/settings/tools",icon:(0,t.jsx)(Y.Wrench,{className:"size-3.5"})},{title:c("nav.models"),link:"/settings/models",icon:(0,t.jsx)(_.Brain,{className:"size-3.5"})},{title:c("nav.providers"),link:"/settings/providers",icon:(0,t.jsx)(R.Server,{className:"size-3.5"})}]:[{title:c("nav.general"),link:"#",icon:(0,t.jsx)(Y.Wrench,{className:"size-3.5"}),onClick:()=>D(!0)},{title:c("nav.agents"),link:"#",icon:(0,t.jsx)(L.Bot,{className:"size-3.5"}),onClick:()=>C(!0)},{title:c("nav.skills"),link:"#",icon:(0,t.jsx)(U.Sparkles,{className:"size-3.5"}),onClick:()=>eu(!0)},{title:c("nav.prompts"),link:"#",icon:(0,t.jsx)(H.MessageSquare,{className:"size-3.5"}),onClick:()=>ep(!0)},{title:c("nav.outputStyles"),link:"#",icon:(0,t.jsx)($.Pencil,{className:"size-3.5"}),onClick:()=>eh(!0)},{title:c("nav.mcps"),link:"#",icon:(0,t.jsx)(K.Plug,{className:"size-3.5"}),onClick:()=>ex(!0)},{title:c("nav.tools"),link:"#",icon:(0,t.jsx)(Y.Wrench,{className:"size-3.5"}),onClick:()=>eS(!0)},{title:c("nav.models"),link:"#",icon:(0,t.jsx)(_.Brain,{className:"size-3.5"}),onClick:()=>{eT(void 0),V(!0)}},{title:c("nav.providers"),link:"#",icon:(0,t.jsx)(R.Server,{className:"size-3.5"}),onClick:()=>ec(!0)},{title:c("nav.hooks"),link:"#",icon:(0,t.jsx)(J.Zap,{className:"size-3.5"}),onClick:()=>eb(!0)},{title:c("nav.commands"),link:"#",icon:(0,t.jsx)(Z.Terminal,{className:"size-3.5"}),onClick:()=>ej(!0)}]}];return(0,t.jsxs)(v,{variant:"floating",collapsible:"icon",className:(0,l.cn)("overflow-hidden",m&&"bg-[#f2f3f5] dark:bg-[#0f1117]"),children:[(0,t.jsxs)(j,{className:(0,l.cn)("flex shrink-0 rounded-xl border border-border bg-card mx-2 mt-2 px-3 py-2.5 shadow-[0_1px_3px_rgba(0,0,0,0.04)]",u?"flex-row items-center justify-between gap-y-4 md:flex-col md:items-center md:justify-center":"flex-row items-center justify-between"),children:[(0,t.jsx)("a",{href:"#",className:"flex items-center gap-2",children:(0,t.jsx)(Q.UserIcon,{size:u?"sm":"md"})}),(0,t.jsxs)(P.motion.div,{className:(0,l.cn)("flex items-center gap-2",u?"flex-row md:flex-col-reverse":"flex-row"),initial:{opacity:0},animate:{opacity:1},transition:{duration:.8},children:[(0,t.jsx)(e6,{workspaceId:f??""}),(0,t.jsx)(b,{})]},u?"header-collapsed":"header-expanded")]}),(0,t.jsx)(N,{className:"min-h-0 overflow-y-auto group-data-[collapsible=icon]:overflow-y-auto gap-2 mx-2 my-2 rounded-xl border border-border bg-card p-2 shadow-[0_1px_3px_rgba(0,0,0,0.04)]",children:(0,t.jsx)(eW,{routes:eR})}),(0,t.jsx)(y,{className:"shrink-0 mx-2 mb-2 rounded-xl border border-border bg-card p-2 shadow-[0_1px_3px_rgba(0,0,0,0.04)]",children:(0,t.jsx)(ta,{})}),(0,t.jsx)(ee.AgentDialog,{open:S,onOpenChange:C}),(0,t.jsx)(ea.SkillsDialog,{open:ed,onOpenChange:eu}),(0,t.jsx)(es.PromptsDialog,{open:em,onOpenChange:ep}),(0,t.jsx)(ei.OutputStylesDialog,{open:ef,onOpenChange:eh}),(0,t.jsx)(eo.McpsDialog,{open:eg,onOpenChange:ex}),(0,t.jsx)(ek,{open:ev,onOpenChange:eb}),(0,t.jsx)(eA,{open:ew,onOpenChange:ej}),(0,t.jsx)(eO.ToolsDialog,{open:eN,onOpenChange:eS}),(0,t.jsx)(er.SettingsDialog,{open:E,onOpenChange:D}),(0,t.jsx)(et.ModelsDialog,{open:I,onOpenChange:V,initialProvider:eM}),(0,t.jsx)(en.ProvidersDialog,{open:el,onOpenChange:ec,onAddModel:e=>{eT(e),V(!0)}}),(0,t.jsx)(ts.WorkspaceDialog,{open:eC,onOpenChange:eE,workspace:eD,onSubmit:eL})]})}var tp=p;function tf(){let e=(0,ey.useWorkspaceStore)(e=>e.workspaces),{toggleSidebar:r}=g(),a=(0,n.useRouter)(),s=(0,n.usePathname)(),i=(0,n.useSearchParams)(),o=(0,td.workspaceIdFromLocation)(s,i.toString());return(0,t.jsxs)("div",{className:"flex items-center h-12 px-3 bg-transparent overflow-x-auto shrink-0",children:[(0,t.jsx)("button",{onClick:()=>r(),className:"flex items-center justify-center size-8 rounded-lg text-muted-foreground hover:bg-accent/50 transition-colors shrink-0 md:hidden cursor-pointer",children:(0,t.jsx)(tp.default,{size:16})}),(0,t.jsx)("div",{className:"flex items-center gap-1 rounded-xl p-1",children:e.map(e=>(0,t.jsx)("button",{onClick:()=>{var t;return(0,T.tauriNavigate)(a,(t=e.id,`/workspace/${t}`))},className:(0,l.cn)("flex items-center gap-1.5 px-3.5 h-7 text-[13px] font-medium rounded-lg transition-all whitespace-nowrap",o===e.id?"bg-primary text-primary-foreground shadow-[rgba(0,0,0,0.08)_0px_4px_6px]":"text-muted-foreground hover:text-foreground hover:bg-accent/50"),children:(0,t.jsx)("span",{className:"max-w-[160px] truncate",children:e.name})},e.id))})]})}e.i(8890);var th=e.i(478189);function tg(){let[e,t]=(0,r.useState)(!1),[n,a]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{a(!0)},[]),(0,r.useEffect)(()=>{if(!e)return;let n=e=>{e.preventDefault(),e.stopPropagation();let n=e.target;if(!(n instanceof HTMLElement))return;let r=function(e){let t=e.closest("[data-inspector-relative-path]");if(t?.dataset.inspectorRelativePath)return{relativePath:t.dataset.inspectorRelativePath,lineNumber:t.dataset.inspectorLine??"1",columnNumber:t.dataset.inspectorColumn??"1"};let n=function e(t){if(!t)return;let n=Object.keys(t).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"));return n?t[n]:e(t.parentElement)}(e);for(;n;){let e=n._debugSource??n._debugOwner?._debugSource;if(e?.fileName&&e.lineNumber)return{absolutePath:e.fileName,lineNumber:String(e.lineNumber),columnNumber:String(e.columnNumber??1)};n=n.return??void 0}}(n);console.debug("[react-dev-inspector] native click",r),t(!1),r?(e=>{if(!e)return;let t="codeInfo"in e?e.codeInfo:e,{lineNumber:n,columnNumber:r,relativePath:a,absolutePath:s}=t,i=!!a,o=i?a:s;if(!o)return console.error("[react-dev-inspector] Cannot open editor without source fileName",t);let l=i?`${th.default}/relative`:th.default;fetch(`${l}?${new URLSearchParams({fileName:o,lineNumber:n,colNumber:r})}`)})(r):console.warn("[react-dev-inspector] no React source info found",n)};return window.addEventListener("click",n,!0),()=>window.removeEventListener("click",n,!0)},[e]),null}e.s(["AppShell",0,function({children:e}){let a=(0,n.usePathname)(),[s,i]=(0,r.useState)(()=>{let e=localStorage.getItem("showWorkspaceTabs");return null===e||"false"!==e});return((0,r.useEffect)(()=>{let e=e=>i(e.detail);return window.addEventListener("workspace-tabs-visibility",e),()=>window.removeEventListener("workspace-tabs-visibility",e)},[]),(0,td.isLoginPath)(a))?(0,t.jsx)(t.Fragment,{children:e}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tg,{}),(0,t.jsxs)(x,{className:"h-[var(--app-content-height)] min-h-0 bg-[#f2f3f5] dark:bg-[#0f1117]",children:[(0,t.jsx)(tm,{}),(0,t.jsxs)(w,{className:"!bg-transparent",children:[s&&(0,t.jsx)(tf,{}),e]})]})]})}],994876)},984642,e=>{"use strict";var t=e.i(344180),n=e.i(640376),r=e.i(683640),a=e.i(417092);e.s(["ConsolePanel",0,function(){let e=(0,n.useCommandPalette)(e=>e.toggle),s=(0,n.useCommandPalette)(e=>e.open);return(0,t.jsx)(a.FloatingBall,{lsKey:"console-panel:pos",onClick:e,visible:!s,style:{background:"#3b82f6",color:"white",boxShadow:"0 4px 12px rgba(59,130,246,0.4)"},children:(0,t.jsx)(r.Terminal,{size:18})})}])},694819,e=>{"use strict";var t=e.i(764556),n=e.i(515104);function r(){let e=document.documentElement,t=window.visualViewport,r=(0,n.isNativeEnvironment)()&&/Android/i.test(navigator.userAgent)?window.__agentSpacesNativeInsets?.top??0:0,a=t?.height??window.innerHeight,s=t?Math.max(0,window.innerHeight-t.height-t.offsetTop):0,i=Math.max(s,(0,n.isNativeEnvironment)()&&/Android/i.test(navigator.userAgent)?window.__agentSpacesNativeInsets?.keyboard??0:0),o=s>0?a:Math.max(0,window.innerHeight-i),l=Math.max(0,o-r);e.style.setProperty("--app-viewport-height",`${o}px`),e.style.setProperty("--app-content-height",`${l}px`),e.style.setProperty("--keyboard-inset-height",`${i}px`),e.style.setProperty("--app-top-inset",`${r}px`)}e.s(["ViewportInsets",0,function(){return(0,t.useEffect)(()=>{r();let e=e=>(function(e){if(!(e instanceof HTMLElement&&e.matches("input, textarea, [contenteditable='true'], [contenteditable='']")))return;let t=()=>{r(),e.scrollIntoView({block:"nearest",inline:"nearest"})};t(),window.setTimeout(t,60),window.setTimeout(t,180),window.setTimeout(t,360)})(e.target),t=window.visualViewport;return t?.addEventListener("resize",r),t?.addEventListener("scroll",r),window.addEventListener("resize",r),window.addEventListener("orientationchange",r),window.addEventListener("agent-spaces-native-insets",r),document.addEventListener("focusin",e),()=>{t?.removeEventListener("resize",r),t?.removeEventListener("scroll",r),window.removeEventListener("resize",r),window.removeEventListener("orientationchange",r),window.removeEventListener("agent-spaces-native-insets",r),document.removeEventListener("focusin",e)}},[]),null}])},701341,e=>{"use strict";var t=e.i(344180),n=e.i(764556),r=e.i(515104);async function a(e){if(!(0,r.isFlutterEnvironment)())return;let t=window.__flutterBridge;if(t?.invoke)try{await t.invoke("setZoom",{scale:e/100})}catch{}}e.s(["ZoomWrapper",0,function({children:e}){return(0,n.useEffect)(()=>{let e=localStorage.getItem("pageZoom");if(e){let t=Number(e);t>=50&&t<=200&&a(t)}let t=e=>{let t=e.detail;"number"==typeof t&&t>=50&&t<=200&&a(t)};return window.addEventListener("zoom-change",t),()=>window.removeEventListener("zoom-change",t)},[]),(0,t.jsx)(t.Fragment,{children:e})}])},698679,e=>{"use strict";let t,n,r;var a,s,i,o,l,c,d,u,m,p=e.i(344180),f=e.i(764556),h=/[\\\/_+.#"@\[\(\{&]/,g=/[\\\/_+.#"@\[\(\{&]/g,x=/[\s-]/,v=/[\s-]/g;function b(e){return e.toLowerCase().replace(v," ")}function w(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function j(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function y(...e){return t=>{let n=!1,r=e.map(e=>{let r=j(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];"function"==typeof n?n():j(e[t],null)}}}}function N(...e){return f.useCallback(y(...e),e)}"u">typeof window&&window.document&&window.document.createElement;var k=globalThis?.document?f.useLayoutEffect:()=>{},S=f[" useId ".trim().toString()]||(()=>void 0),C=0;function E(e){let[t,n]=f.useState(S());return k(()=>{e||n(e=>e??String(C++))},[e]),e||(t?`radix-${t}`:"")}f[" useEffectEvent ".trim().toString()],f[" useInsertionEffect ".trim().toString()];var D=f[" useInsertionEffect ".trim().toString()]||k;Symbol("RADIX:SYNC_STATE");var I=e.i(106206);function M(e){var t;let n,r=(t=e,(n=f.forwardRef((e,t)=>{let{children:n,...r}=e;if(f.isValidElement(n)){var a;let e,s,i=(a=n,(s=(e=Object.getOwnPropertyDescriptor(a.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?a.ref:(s=(e=Object.getOwnPropertyDescriptor(a,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?a.props.ref:a.props.ref||a.ref),o=function(e,t){let n={...t};for(let r in t){let a=e[r],s=t[r];/^on[A-Z]/.test(r)?a&&s?n[r]=(...e)=>{let t=s(...e);return a(...e),t}:a&&(n[r]=a):"style"===r?n[r]={...a,...s}:"className"===r&&(n[r]=[a,s].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==f.Fragment&&(o.ref=t?y(t,i):i),f.cloneElement(n,o)}return f.Children.count(n)>1?f.Children.only(null):null})).displayName=`${t}.SlotClone`,n),a=f.forwardRef((e,t)=>{let{children:n,...a}=e,s=f.Children.toArray(n),i=s.find(P);if(i){let e=i.props.children,n=s.map(t=>t!==i?t:f.Children.count(e)>1?f.Children.only(null):f.isValidElement(e)?e.props.children:null);return(0,p.jsx)(r,{...a,ref:t,children:f.isValidElement(e)?f.cloneElement(e,void 0,n):null})}return(0,p.jsx)(r,{...a,ref:t,children:n})});return a.displayName=`${e}.Slot`,a}var T=Symbol("radix.slottable");function P(e){return f.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===T}var z=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=M(`Primitive.${t}`),r=f.forwardRef((e,r)=>{let{asChild:a,...s}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,p.jsx)(a?n:t,{...s,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function A(e){let t=f.useRef(e);return f.useEffect(()=>{t.current=e}),f.useMemo(()=>(...e)=>t.current?.(...e),[])}var O="dismissableLayer.update",L=f.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_=f.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:s,onInteractOutside:i,onDismiss:o,...l}=e,c=f.useContext(L),[d,m]=f.useState(null),h=d?.ownerDocument??globalThis?.document,[,g]=f.useState({}),x=N(t,e=>m(e)),v=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),j=v.indexOf(b),y=d?v.indexOf(d):-1,k=c.layersWithOutsidePointerEventsDisabled.size>0,S=y>=j,C=function(e,t=globalThis?.document){let n=A(e),r=f.useRef(!1),a=f.useRef(()=>{});return f.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){$("dismissableLayer.pointerDownOutside",n,s,{discrete:!0})},s={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",a.current),a.current=r,t.addEventListener("click",a.current,{once:!0})):r()}else t.removeEventListener("click",a.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",e),t.removeEventListener("click",a.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{let t=e.target,n=[...c.branches].some(e=>e.contains(t));S&&!n&&(a?.(e),i?.(e),e.defaultPrevented||o?.())},h),E=function(e,t=globalThis?.document){let n=A(e),r=f.useRef(!1);return f.useEffect(()=>{let e=e=>{e.target&&!r.current&&$("dismissableLayer.focusOutside",n,{originalEvent:e},{discrete:!1})};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{let t=e.target;![...c.branches].some(e=>e.contains(t))&&(s?.(e),i?.(e),e.defaultPrevented||o?.())},h);return!function(e,t=globalThis?.document){let n=A(e);f.useEffect(()=>{let e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}(e=>{y===c.layers.size-1&&(r?.(e),!e.defaultPrevented&&o&&(e.preventDefault(),o()))},h),f.useEffect(()=>{if(d)return n&&(0===c.layersWithOutsidePointerEventsDisabled.size&&(u=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),R(),()=>{n&&1===c.layersWithOutsidePointerEventsDisabled.size&&(h.body.style.pointerEvents=u)}},[d,h,n,c]),f.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),R())},[d,c]),f.useEffect(()=>{let e=()=>g({});return document.addEventListener(O,e),()=>document.removeEventListener(O,e)},[]),(0,p.jsx)(z.div,{...l,ref:x,style:{pointerEvents:k?S?"auto":"none":void 0,...e.style},onFocusCapture:w(e.onFocusCapture,E.onFocusCapture),onBlurCapture:w(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:w(e.onPointerDownCapture,C.onPointerDownCapture)})});function R(){let e=new CustomEvent(O);document.dispatchEvent(e)}function $(e,t,n,{discrete:r}){let a=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});if(t&&a.addEventListener(e,t,{once:!0}),r)a&&I.flushSync(()=>a.dispatchEvent(s));else a.dispatchEvent(s)}_.displayName="DismissableLayer",f.forwardRef((e,t)=>{let n=f.useContext(L),r=f.useRef(null),a=N(t,r);return f.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,p.jsx)(z.div,{...e,ref:a})}).displayName="DismissableLayerBranch";var F="focusScope.autoFocusOnMount",W="focusScope.autoFocusOnUnmount",B={bubbles:!1,cancelable:!0},U=f.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:s,...i}=e,[o,l]=f.useState(null),c=A(a),d=A(s),u=f.useRef(null),m=N(t,e=>l(e)),h=f.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;f.useEffect(()=>{if(r){let e=function(e){if(h.paused||!o)return;let t=e.target;o.contains(t)?u.current=t:V(u.current,{select:!0})},t=function(e){if(h.paused||!o)return;let t=e.relatedTarget;null!==t&&(o.contains(t)||V(u.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",t);let n=new MutationObserver(function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&V(o)});return o&&n.observe(o,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),n.disconnect()}}},[r,o,h.paused]),f.useEffect(()=>{if(o){q.add(h);let e=document.activeElement;if(!o.contains(e)){let t=new CustomEvent(F,B);o.addEventListener(F,c),o.dispatchEvent(t),t.defaultPrevented||(function(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(V(r,{select:t}),document.activeElement!==n)return}(H(o).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&V(o))}return()=>{o.removeEventListener(F,c),setTimeout(()=>{let t=new CustomEvent(W,B);o.addEventListener(W,d),o.dispatchEvent(t),t.defaultPrevented||V(e??document.body,{select:!0}),o.removeEventListener(W,d),q.remove(h)},0)}}},[o,c,d,h]);let g=f.useCallback(e=>{if(!n&&!r||h.paused)return;let t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,a=document.activeElement;if(t&&a){var s;let t,r=e.currentTarget,[i,o]=[K(t=H(s=r),s),K(t.reverse(),s)];i&&o?e.shiftKey||a!==o?e.shiftKey&&a===i&&(e.preventDefault(),n&&V(o,{select:!0})):(e.preventDefault(),n&&V(i,{select:!0})):a===r&&e.preventDefault()}},[n,r,h.paused]);return(0,p.jsx)(z.div,{tabIndex:-1,...i,ref:m,onKeyDown:g})});function H(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function K(e,t){for(let n of e)if(!function(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===t||e!==t);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(n,{upTo:t}))return n}function V(e,{select:t=!1}={}){if(e&&e.focus){var n;let r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&(n=e)instanceof HTMLInputElement&&"select"in n&&t&&e.select()}}U.displayName="FocusScope";var q=(r=[],{add(e){let t=r[0];e!==t&&t?.pause(),(r=X(r,e)).unshift(e)},remove(e){r=X(r,e),r[0]?.resume()}});function X(e,t){let n=[...e],r=n.indexOf(t);return -1!==r&&n.splice(r,1),n}var G=f.forwardRef((e,t)=>{let{container:n,...r}=e,[a,s]=f.useState(!1);k(()=>s(!0),[]);let i=n||a&&globalThis?.document?.body;return i?I.default.createPortal((0,p.jsx)(z.div,{...r,ref:t}),i):null});G.displayName="Portal";var J=e=>{var t;let n,r,{present:a,children:s}=e,i=function(e){var t,n;let[r,a]=f.useState(),s=f.useRef(null),i=f.useRef(e),o=f.useRef("none"),[l,c]=(t=e?"mounted":"unmounted",n={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},f.useReducer((e,t)=>n[e][t]??e,t));return f.useEffect(()=>{let e=Y(s.current);o.current="mounted"===l?e:"none"},[l]),k(()=>{let t=s.current,n=i.current;if(n!==e){let r=o.current,a=Y(t);e?c("MOUNT"):"none"===a||t?.display==="none"?c("UNMOUNT"):n&&r!==a?c("ANIMATION_OUT"):c("UNMOUNT"),i.current=e}},[e,c]),k(()=>{if(r){let e,t=r.ownerDocument.defaultView??window,n=n=>{let a=Y(s.current).includes(CSS.escape(n.animationName));if(n.target===r&&a&&(c("ANIMATION_END"),!i.current)){let n=r.style.animationFillMode;r.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=n)})}},a=e=>{e.target===r&&(o.current=Y(s.current))};return r.addEventListener("animationstart",a),r.addEventListener("animationcancel",n),r.addEventListener("animationend",n),()=>{t.clearTimeout(e),r.removeEventListener("animationstart",a),r.removeEventListener("animationcancel",n),r.removeEventListener("animationend",n)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:f.useCallback(e=>{s.current=e?getComputedStyle(e):null,a(e)},[])}}(a),o="function"==typeof s?s({present:i.isPresent}):f.Children.only(s),l=N(i.ref,(t=o,(r=(n=Object.getOwnPropertyDescriptor(t.props,"ref")?.get)&&"isReactWarning"in n&&n.isReactWarning)?t.ref:(r=(n=Object.getOwnPropertyDescriptor(t,"ref")?.get)&&"isReactWarning"in n&&n.isReactWarning)?t.props.ref:t.props.ref||t.ref));return"function"==typeof s||i.isPresent?f.cloneElement(o,{ref:l}):null};function Y(e){return e?.animationName||"none"}J.displayName="Presence";var Z=0;function Q(){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 ee=e.i(824627),et="right-scroll-bar-position",en="width-before-scroll-bar";function er(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var ea="u">typeof window?f.useLayoutEffect:f.useEffect,es=new WeakMap,ei=(void 0===a&&(a={}),(void 0===s&&(s=function(e){return e}),i=[],o=!1,l={read:function(){if(o)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return i.length?i[i.length-1]:null},useMedium:function(e){var t=s(e,o);return i.push(t),function(){i=i.filter(function(e){return e!==t})}},assignSyncMedium:function(e){for(o=!0;i.length;){var t=i;i=[],t.forEach(e)}i={push:function(t){return e(t)},filter:function(){return i}}},assignMedium:function(e){o=!0;var t=[];if(i.length){var n=i;i=[],n.forEach(e),t=i}var r=function(){var n=t;t=[],n.forEach(e)},a=function(){return Promise.resolve().then(r)};a(),i={push:function(e){t.push(e),a()},filter:function(e){return t=t.filter(e),i}}}}).options=(0,ee.__assign)({async:!0,ssr:!1},a),l),eo=function(){},el=f.forwardRef(function(e,t){var n,r,a,s,i=f.useRef(null),o=f.useState({onScrollCapture:eo,onWheelCapture:eo,onTouchMoveCapture:eo}),l=o[0],c=o[1],d=e.forwardProps,u=e.children,m=e.className,p=e.removeScrollBar,h=e.enabled,g=e.shards,x=e.sideCar,v=e.noRelative,b=e.noIsolation,w=e.inert,j=e.allowPinchZoom,y=e.as,N=e.gapMode,k=(0,ee.__rest)(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=(n=[i,t],r=function(e){return n.forEach(function(t){return er(t,e)})},(a=(0,f.useState)(function(){return{value:null,callback:r,facade:{get current(){return a.value},set current(value){var e=a.value;e!==value&&(a.value=value,a.callback(value,e))}}}})[0]).callback=r,s=a.facade,ea(function(){var e=es.get(s);if(e){var t=new Set(e),r=new Set(n),a=s.current;t.forEach(function(e){r.has(e)||er(e,null)}),r.forEach(function(e){t.has(e)||er(e,a)})}es.set(s,n)},[n]),s),C=(0,ee.__assign)((0,ee.__assign)({},k),l);return f.createElement(f.Fragment,null,h&&f.createElement(x,{sideCar:ei,removeScrollBar:p,shards:g,noRelative:v,noIsolation:b,inert:w,setCallbacks:c,allowPinchZoom:!!j,lockRef:i,gapMode:N}),d?f.cloneElement(f.Children.only(u),(0,ee.__assign)((0,ee.__assign)({},C),{ref:S})):f.createElement(void 0===y?"div":y,(0,ee.__assign)({},C,{className:m,ref:S}),u))});el.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},el.classNames={fullWidth:en,zeroRight:et};var ec=function(e){var t=e.sideCar,n=(0,ee.__rest)(e,["sideCar"]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error("Sidecar medium not found");return f.createElement(r,(0,ee.__assign)({},n))};ec.isSideCarExport=!0;var ed=function(){var e=0,t=null;return{add:function(n){if(0==e&&(t=function(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=m||("u">typeof __webpack_nonce__?__webpack_nonce__:void 0);return t&&e.setAttribute("nonce",t),e}())){var r,a;(r=t).styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n)),a=t,(document.head||document.getElementsByTagName("head")[0]).appendChild(a)}e++},remove:function(){--e||!t||(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},eu=function(){var e=ed();return function(t,n){f.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},em=function(){var e=eu();return function(t){return e(t.styles,t.dynamic),null}},ep={left:0,top:0,right:0,gap:0},ef=function(e){return parseInt(e||"",10)||0},eh=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],a=t["padding"===e?"paddingRight":"marginRight"];return[ef(n),ef(r),ef(a)]},eg=function(e){if(void 0===e&&(e="margin"),"u"<typeof window)return ep;var t=eh(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ex=em(),ev="data-scroll-locked",eb=function(e,t,n,r){var a=e.left,s=e.top,i=e.right,o=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(o,"px ").concat(r,";\n }\n body[").concat(ev,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(a,"px;\n padding-top: ").concat(s,"px;\n padding-right: ").concat(i,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(o,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(o,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(et," {\n right: ").concat(o,"px ").concat(r,";\n }\n \n .").concat(en," {\n margin-right: ").concat(o,"px ").concat(r,";\n }\n \n .").concat(et," .").concat(et," {\n right: 0 ").concat(r,";\n }\n \n .").concat(en," .").concat(en," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(ev,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(o,"px;\n }\n")},ew=function(){var e=parseInt(document.body.getAttribute(ev)||"0",10);return isFinite(e)?e:0},ej=function(){f.useEffect(function(){return document.body.setAttribute(ev,(ew()+1).toString()),function(){var e=ew()-1;e<=0?document.body.removeAttribute(ev):document.body.setAttribute(ev,e.toString())}},[])},ey=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,a=void 0===r?"margin":r;ej();var s=f.useMemo(function(){return eg(a)},[a]);return f.createElement(ex,{styles:eb(s,!t,a,n?"":"!important")})},eN=!1;if("u">typeof window)try{var ek=Object.defineProperty({},"passive",{get:function(){return eN=!0,!0}});window.addEventListener("test",ek,ek),window.removeEventListener("test",ek,ek)}catch(e){eN=!1}var eS=!!eN&&{passive:!1},eC=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&(n.overflowY!==n.overflowX||"TEXTAREA"===e.tagName||"visible"!==n[t])},eE=function(e,t){var n=t.ownerDocument,r=t;do{if("u">typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),eD(e,r)){var a=eI(e,r);if(a[1]>a[2])return!0}r=r.parentNode}while(r&&r!==n.body)return!1},eD=function(e,t){return"v"===e?eC(t,"overflowY"):eC(t,"overflowX")},eI=function(e,t){return"v"===e?[t.scrollTop,t.scrollHeight,t.clientHeight]:[t.scrollLeft,t.scrollWidth,t.clientWidth]},eM=function(e,t,n,r,a){var s,i=(s=window.getComputedStyle(t).direction,"h"===e&&"rtl"===s?-1:1),o=i*r,l=n.target,c=t.contains(l),d=!1,u=o>0,m=0,p=0;do{if(!l)break;var f=eI(e,l),h=f[0],g=f[1]-f[2]-i*h;(h||g)&&eD(e,l)&&(m+=g,p+=h);var x=l.parentNode;l=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!c&&l!==document.body||c&&(t.contains(l)||t===l))return u&&(a&&1>Math.abs(m)||!a&&o>m)?d=!0:!u&&(a&&1>Math.abs(p)||!a&&-o>p)&&(d=!0),d},eT=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},eP=function(e){return[e.deltaX,e.deltaY]},ez=function(e){return e&&"current"in e?e.current:e},eA=0,eO=[];let eL=(c=function(e){var t=f.useRef([]),n=f.useRef([0,0]),r=f.useRef(),a=f.useState(eA++)[0],s=f.useState(em)[0],i=f.useRef(e);f.useEffect(function(){i.current=e},[e]),f.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var t=(0,ee.__spreadArray)([e.lockRef.current],(e.shards||[]).map(ez),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var o=f.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!i.current.allowPinchZoom;var a,s=eT(e),o=n.current,l="deltaX"in e?e.deltaX:o[0]-s[0],c="deltaY"in e?e.deltaY:o[1]-s[1],d=e.target,u=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===d.type)return!1;var m=window.getSelection(),p=m&&m.anchorNode;if(p&&(p===d||p.contains(d)))return!1;var f=eE(u,d);if(!f)return!0;if(f?a=u:(a="v"===u?"h":"v",f=eE(u,d)),!f)return!1;if(!r.current&&"changedTouches"in e&&(l||c)&&(r.current=a),!a)return!0;var h=r.current||a;return eM(h,t,e,"h"===h?l:c,!0)},[]),l=f.useCallback(function(e){if(eO.length&&eO[eO.length-1]===s){var n="deltaY"in e?eP(e):eT(e),r=t.current.filter(function(t){var r;return t.name===e.type&&(t.target===e.target||e.target===t.shadowParent)&&(r=t.delta,r[0]===n[0]&&r[1]===n[1])})[0];if(r&&r.should){e.cancelable&&e.preventDefault();return}if(!r){var a=(i.current.shards||[]).map(ez).filter(Boolean).filter(function(t){return t.contains(e.target)});(a.length>0?o(e,a[0]):!i.current.noIsolation)&&e.cancelable&&e.preventDefault()}}},[]),c=f.useCallback(function(e,n,r,a){var s={name:e,delta:n,target:r,should:a,shadowParent:function(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}(r)};t.current.push(s),setTimeout(function(){t.current=t.current.filter(function(e){return e!==s})},1)},[]),d=f.useCallback(function(e){n.current=eT(e),r.current=void 0},[]),u=f.useCallback(function(t){c(t.type,eP(t),t.target,o(t,e.lockRef.current))},[]),m=f.useCallback(function(t){c(t.type,eT(t),t.target,o(t,e.lockRef.current))},[]);f.useEffect(function(){return eO.push(s),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:m}),document.addEventListener("wheel",l,eS),document.addEventListener("touchmove",l,eS),document.addEventListener("touchstart",d,eS),function(){eO=eO.filter(function(e){return e!==s}),document.removeEventListener("wheel",l,eS),document.removeEventListener("touchmove",l,eS),document.removeEventListener("touchstart",d,eS)}},[]);var p=e.removeScrollBar,h=e.inert;return f.createElement(f.Fragment,null,h?f.createElement(s,{styles:"\n .block-interactivity-".concat(a," {pointer-events: none;}\n .allow-interactivity-").concat(a," {pointer-events: all;}\n")}):null,p?f.createElement(ey,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},ei.useMedium(c),ec);var e_=f.forwardRef(function(e,t){return f.createElement(el,(0,ee.__assign)({},e,{ref:t,sideCar:eL}))});e_.classNames=el.classNames;var eR=new WeakMap,e$=new WeakMap,eF={},eW=0,eB=function(e){return e&&(e.host||eB(e.parentNode))},eU=function(e,t,n,r){var a=(Array.isArray(e)?e:[e]).map(function(e){if(t.contains(e))return e;var n=eB(e);return n&&t.contains(n)?n:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)}).filter(function(e){return!!e});eF[n]||(eF[n]=new WeakMap);var s=eF[n],i=[],o=new Set,l=new Set(a),c=function(e){!e||o.has(e)||(o.add(e),c(e.parentNode))};a.forEach(c);var d=function(e){!e||l.has(e)||Array.prototype.forEach.call(e.children,function(e){if(o.has(e))d(e);else try{var t=e.getAttribute(r),a=null!==t&&"false"!==t,l=(eR.get(e)||0)+1,c=(s.get(e)||0)+1;eR.set(e,l),s.set(e,c),i.push(e),1===l&&a&&e$.set(e,!0),1===c&&e.setAttribute(n,"true"),a||e.setAttribute(r,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return d(t),o.clear(),eW++,function(){i.forEach(function(e){var t=eR.get(e)-1,a=s.get(e)-1;eR.set(e,t),s.set(e,a),t||(e$.has(e)||e.removeAttribute(r),e$.delete(e)),a||e.removeAttribute(n)}),--eW||(eR=new WeakMap,eR=new WeakMap,e$=new WeakMap,eF={})}},eH=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),a=t||("u"<typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),eU(r,a,n,"aria-hidden")):function(){return null}},eK="Dialog",[eV,eq]=function(e,t=[]){let n=[],r=()=>{let t=n.map(e=>f.createContext(e));return function(n){let r=n?.[e]||t;return f.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){let a=f.createContext(r),s=n.length;n=[...n,r];let i=t=>{let{scope:n,children:r,...i}=t,o=n?.[e]?.[s]||a,l=f.useMemo(()=>i,Object.values(i));return(0,p.jsx)(o.Provider,{value:l,children:r})};return i.displayName=t+"Provider",[i,function(n,i){let o=i?.[e]?.[s]||a,l=f.useContext(o);if(l)return l;if(void 0!==r)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let a=n(e)[`__scope${r}`];return{...t,...a}},{});return f.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}(r,...t)]}(eK),[eX,eG]=eV(eK),eJ=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:s,modal:i=!0}=e,o=f.useRef(null),l=f.useRef(null),[c,d]=function({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[a,s,i]=function({defaultProp:e,onChange:t}){let[n,r]=f.useState(e),a=f.useRef(n),s=f.useRef(t);return D(()=>{s.current=t},[t]),f.useEffect(()=>{a.current!==n&&(s.current?.(n),a.current=n)},[n,a]),[n,r,s]}({defaultProp:t,onChange:n}),o=void 0!==e,l=o?e:a;{let t=f.useRef(void 0!==e);f.useEffect(()=>{let e=t.current;if(e!==o){let t=o?"controlled":"uncontrolled";console.warn(`${r} is changing from ${e?"controlled":"uncontrolled"} to ${t}. 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.`)}t.current=o},[o,r])}return[l,f.useCallback(t=>{if(o){let n="function"==typeof t?t(e):t;n!==e&&i.current?.(n)}else s(t)},[o,e,s,i])]}({prop:r,defaultProp:a??!1,onChange:s,caller:eK});return(0,p.jsx)(eX,{scope:t,triggerRef:o,contentRef:l,contentId:E(),titleId:E(),descriptionId:E(),open:c,onOpenChange:d,onOpenToggle:f.useCallback(()=>d(e=>!e),[d]),modal:i,children:n})};eJ.displayName=eK;var eY="DialogTrigger";f.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=eG(eY,n),s=N(t,a.triggerRef);return(0,p.jsx)(z.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":ta(a.open),...r,ref:s,onClick:w(e.onClick,a.onOpenToggle)})}).displayName=eY;var eZ="DialogPortal",[eQ,e0]=eV(eZ,{forceMount:void 0}),e1=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:a}=e,s=eG(eZ,t);return(0,p.jsx)(eQ,{scope:t,forceMount:n,children:f.Children.map(r,e=>(0,p.jsx)(J,{present:n||s.open,children:(0,p.jsx)(G,{asChild:!0,container:a,children:e})}))})};e1.displayName=eZ;var e2="DialogOverlay",e5=f.forwardRef((e,t)=>{let n=e0(e2,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,s=eG(e2,e.__scopeDialog);return s.modal?(0,p.jsx)(J,{present:r||s.open,children:(0,p.jsx)(e4,{...a,ref:t})}):null});e5.displayName=e2;var e3=M("DialogOverlay.RemoveScroll"),e4=f.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=eG(e2,n);return(0,p.jsx)(e_,{as:e3,allowPinchZoom:!0,shards:[a.contentRef],children:(0,p.jsx)(z.div,{"data-state":ta(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),e6="DialogContent",e8=f.forwardRef((e,t)=>{let n=e0(e6,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,s=eG(e6,e.__scopeDialog);return(0,p.jsx)(J,{present:r||s.open,children:s.modal?(0,p.jsx)(e9,{...a,ref:t}):(0,p.jsx)(e7,{...a,ref:t})})});e8.displayName=e6;var e9=f.forwardRef((e,t)=>{let n=eG(e6,e.__scopeDialog),r=f.useRef(null),a=N(t,n.contentRef,r);return f.useEffect(()=>{let e=r.current;if(e)return eH(e)},[]),(0,p.jsx)(te,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:w(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:w(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:w(e.onFocusOutside,e=>e.preventDefault())})}),e7=f.forwardRef((e,t)=>{let n=eG(e6,e.__scopeDialog),r=f.useRef(!1),a=f.useRef(!1);return(0,p.jsx)(te,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(a.current=!0));let s=t.target;n.triggerRef.current?.contains(s)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&a.current&&t.preventDefault()}})}),te=f.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:s,...i}=e,o=eG(e6,n),l=f.useRef(null),c=N(t,l);return f.useEffect(()=>{let e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Q()),document.body.insertAdjacentElement("beforeend",e[1]??Q()),Z++,()=>{1===Z&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Z--}},[]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(U,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:s,children:(0,p.jsx)(_,{role:"dialog",id:o.contentId,"aria-describedby":o.descriptionId,"aria-labelledby":o.titleId,"data-state":ta(o.open),...i,ref:c,onDismiss:()=>o.onOpenChange(!1)})}),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(tl,{titleId:o.titleId}),(0,p.jsx)(tc,{contentRef:l,descriptionId:o.descriptionId})]})]})}),tt="DialogTitle";f.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=eG(tt,n);return(0,p.jsx)(z.h2,{id:a.titleId,...r,ref:t})}).displayName=tt;var tn="DialogDescription";f.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=eG(tn,n);return(0,p.jsx)(z.p,{id:a.descriptionId,...r,ref:t})}).displayName=tn;var tr="DialogClose";function ta(e){return e?"open":"closed"}f.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=eG(tr,n);return(0,p.jsx)(z.button,{type:"button",...r,ref:t,onClick:w(e.onClick,()=>a.onOpenChange(!1))})}).displayName=tr;var ts="DialogTitleWarning",[ti,to]=(d={contentName:e6,titleName:tt,docsSlug:"dialog"},t=f.createContext(d),(n=e=>{let{children:n,...r}=e,a=f.useMemo(()=>r,Object.values(r));return(0,p.jsx)(t.Provider,{value:a,children:n})}).displayName=ts+"Provider",[n,function(e){let n=f.useContext(t);if(n)return n;if(void 0!==d)return d;throw Error(`\`${e}\` must be used within \`${ts}\``)}]),tl=({titleId:e})=>{let t=to(ts),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
2
+
3
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
4
+
5
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return f.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},tc=({contentRef:e,descriptionId:t})=>{let n=to("DialogDescriptionWarning"),r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${n.contentName}}.`;return f.useEffect(()=>{let n=e.current?.getAttribute("aria-describedby");t&&n&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},td='[cmdk-group=""]',tu='[cmdk-group-items=""]',tm='[cmdk-item=""]',tp=`${tm}:not([aria-disabled="true"])`,tf="cmdk-item-select",th="data-value",tg=(e,t,n)=>{var r;return r=e,function e(t,n,r,a,s,i,o){if(i===n.length)return s===t.length?1:.99;var l=`${s},${i}`;if(void 0!==o[l])return o[l];for(var c,d,u,m,p=a.charAt(i),f=r.indexOf(p,s),b=0;f>=0;)(c=e(t,n,r,a,f+1,i+1,o))>b&&(f===s?c*=1:h.test(t.charAt(f-1))?(c*=.8,(u=t.slice(s,f-1).match(g))&&s>0&&(c*=Math.pow(.999,u.length))):x.test(t.charAt(f-1))?(c*=.9,(m=t.slice(s,f-1).match(v))&&s>0&&(c*=Math.pow(.999,m.length))):(c*=.17,s>0&&(c*=Math.pow(.999,f-s))),t.charAt(f)!==n.charAt(i)&&(c*=.9999)),(c<.1&&r.charAt(f-1)===a.charAt(i+1)||a.charAt(i+1)===a.charAt(i)&&r.charAt(f-1)!==a.charAt(i))&&.1*(d=e(t,n,r,a,f+1,i+2,o))>c&&(c=.1*d),c>b&&(b=c),f=r.indexOf(p,f+1);return o[l]=b,b}(r=n&&n.length>0?`${r+" "+n.join(" ")}`:r,t,b(r),b(t),0,0,{})},tx=f.createContext(void 0),tv=f.createContext(void 0),tb=f.createContext(void 0),tw=f.forwardRef((e,t)=>{let n=tM(()=>{var t,n;return{search:"",value:null!=(n=null!=(t=e.value)?t:e.defaultValue)?n:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=tM(()=>new Set),a=tM(()=>new Map),s=tM(()=>new Map),i=tM(()=>new Set),o=tD(e),{label:l,children:c,value:d,onValueChange:u,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...v}=e,b=E(),w=E(),j=E(),y=f.useRef(null),N=tz();tI(()=>{if(void 0!==d){let e=d.trim();n.current.value=e,k.emit()}},[d]),tI(()=>{N(6,T)},[]);let k=f.useMemo(()=>({subscribe:e=>(i.current.add(e),()=>i.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var a,s,i,l;if(!Object.is(n.current[e],t)){if(n.current[e]=t,"search"===e)M(),D(),N(1,I);else if("value"===e){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let e=document.getElementById(j);e?e.focus():null==(a=document.getElementById(b))||a.focus()}if(N(7,()=>{var e;n.current.selectedItemId=null==(e=P())?void 0:e.id,k.emit()}),r||N(5,T),(null==(s=o.current)?void 0:s.value)!==void 0){null==(l=(i=o.current).onValueChange)||l.call(i,null!=t?t:"");return}}k.emit()}},emit:()=>{i.current.forEach(e=>e())}}),[]),S=f.useMemo(()=>({value:(e,t,r)=>{var a;t!==(null==(a=s.current.get(e))?void 0:a.value)&&(s.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,C(t,r)),N(2,()=>{D(),k.emit()}))},item:(e,t)=>(r.current.add(e),t&&(a.current.has(t)?a.current.get(t).add(e):a.current.set(t,new Set([e]))),N(3,()=>{M(),D(),n.current.value||I(),k.emit()}),()=>{s.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=P();N(4,()=>{M(),(null==t?void 0:t.getAttribute("id"))===e&&I(),k.emit()})}),group:e=>(a.current.has(e)||a.current.set(e,new Set),()=>{s.current.delete(e),a.current.delete(e)}),filter:()=>o.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>o.current.disablePointerSelection,listId:b,inputId:j,labelId:w,listInnerRef:y}),[]);function C(e,t){var r,a;let s=null!=(a=null==(r=o.current)?void 0:r.filter)?a:tg;return e?s(e,n.current.search,t):0}function D(){if(!n.current.search||!1===o.current.shouldFilter)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=a.current.get(n),s=0;r.forEach(t=>{s=Math.max(e.get(t),s)}),t.push([n,s])});let r=y.current;A().sort((t,n)=>{var r,a;let s=t.getAttribute("id"),i=n.getAttribute("id");return(null!=(r=e.get(i))?r:0)-(null!=(a=e.get(s))?a:0)}).forEach(e=>{let t=e.closest(tu);t?t.appendChild(e.parentElement===t?e:e.closest(`${tu} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${tu} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{var t;let n=null==(t=y.current)?void 0:t.querySelector(`${td}[${th}="${encodeURIComponent(e[0])}"]`);null==n||n.parentElement.appendChild(n)})}function I(){let e=A().find(e=>"true"!==e.getAttribute("aria-disabled")),t=null==e?void 0:e.getAttribute(th);k.setState("value",t||void 0)}function M(){var e,t,i,l;if(!n.current.search||!1===o.current.shouldFilter){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let c=0;for(let a of r.current){let r=C(null!=(t=null==(e=s.current.get(a))?void 0:e.value)?t:"",null!=(l=null==(i=s.current.get(a))?void 0:i.keywords)?l:[]);n.current.filtered.items.set(a,r),r>0&&c++}for(let[e,t]of a.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=c}function T(){var e,t,n;let r=P();r&&((null==(e=r.parentElement)?void 0:e.firstChild)===r&&(null==(n=null==(t=r.closest(td))?void 0:t.querySelector('[cmdk-group-heading=""]'))||n.scrollIntoView({block:"nearest"})),r.scrollIntoView({block:"nearest"}))}function P(){var e;return null==(e=y.current)?void 0:e.querySelector(`${tm}[aria-selected="true"]`)}function A(){var e;return Array.from((null==(e=y.current)?void 0:e.querySelectorAll(tp))||[])}function O(e){let t=A()[e];t&&k.setState("value",t.getAttribute(th))}function L(e){var t;let n=P(),r=A(),a=r.findIndex(e=>e===n),s=r[a+e];null!=(t=o.current)&&t.loop&&(s=a+e<0?r[r.length-1]:a+e===r.length?r[0]:r[a+e]),s&&k.setState("value",s.getAttribute(th))}function _(e){let t=P(),n=null==t?void 0:t.closest(td),r;for(;n&&!r;)r=null==(n=e>0?function(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}(n,td):function(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}(n,td))?void 0:n.querySelector(tp);r?k.setState("value",r.getAttribute(th)):L(e)}let R=()=>O(A().length-1),$=e=>{e.preventDefault(),e.metaKey?R():e.altKey?_(1):L(1)},F=e=>{e.preventDefault(),e.metaKey?O(0):e.altKey?_(-1):L(-1)};return f.createElement(z.div,{ref:t,tabIndex:-1,...v,"cmdk-root":"",onKeyDown:e=>{var t;null==(t=v.onKeyDown)||t.call(v,e);let n=e.nativeEvent.isComposing||229===e.keyCode;if(!(e.defaultPrevented||n))switch(e.key){case"n":case"j":x&&e.ctrlKey&&$(e);break;case"ArrowDown":$(e);break;case"p":case"k":x&&e.ctrlKey&&F(e);break;case"ArrowUp":F(e);break;case"Home":e.preventDefault(),O(0);break;case"End":e.preventDefault(),R();break;case"Enter":{e.preventDefault();let t=P();if(t){let e=new Event(tf);t.dispatchEvent(e)}}}}},f.createElement("label",{"cmdk-label":"",htmlFor:S.inputId,id:S.labelId,style:tO},l),tA(e,e=>f.createElement(tv.Provider,{value:k},f.createElement(tx.Provider,{value:S},e))))}),tj=f.forwardRef((e,t)=>{var n,r;let a=E(),s=f.useRef(null),i=f.useContext(tb),o=f.useContext(tx),l=tD(e),c=null!=(r=null==(n=l.current)?void 0:n.forceMount)?r:null==i?void 0:i.forceMount;tI(()=>{if(!c)return o.item(a,null==i?void 0:i.id)},[c]);let d=tP(a,s,[e.value,e.children,s],e.keywords),u=f.useContext(tv),m=tT(e=>e.value&&e.value===d.current),p=tT(e=>!!c||!1===o.filter()||!e.search||e.filtered.items.get(a)>0);function h(){var e,t;g(),null==(t=(e=l.current).onSelect)||t.call(e,d.current)}function g(){u.setState("value",d.current,!0)}if(f.useEffect(()=>{let t=s.current;if(!(!t||e.disabled))return t.addEventListener(tf,h),()=>t.removeEventListener(tf,h)},[p,e.onSelect,e.disabled]),!p)return null;let{disabled:x,value:v,onSelect:b,forceMount:w,keywords:j,...N}=e;return f.createElement(z.div,{ref:y(s,t),...N,id:a,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||o.getDisablePointerSelection()?void 0:g,onClick:x?void 0:h},e.children)}),ty=f.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:a,...s}=e,i=E(),o=f.useRef(null),l=f.useRef(null),c=E(),d=f.useContext(tx),u=tT(e=>!!a||!1===d.filter()||!e.search||e.filtered.groups.has(i));tI(()=>d.group(i),[]),tP(i,o,[e.value,e.heading,l]);let m=f.useMemo(()=>({id:i,forceMount:a}),[a]);return f.createElement(z.div,{ref:y(o,t),...s,"cmdk-group":"",role:"presentation",hidden:!u||void 0},n&&f.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),tA(e,e=>f.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},f.createElement(tb.Provider,{value:m},e))))}),tN=f.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,a=f.useRef(null),s=tT(e=>!e.search);return n||s?f.createElement(z.div,{ref:y(a,t),...r,"cmdk-separator":"",role:"separator"}):null}),tk=f.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,a=null!=e.value,s=f.useContext(tv),i=tT(e=>e.search),o=tT(e=>e.selectedItemId),l=f.useContext(tx);return f.useEffect(()=>{null!=e.value&&s.setState("search",e.value)},[e.value]),f.createElement(z.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":o,id:l.inputId,type:"text",value:a?e.value:i,onChange:e=>{a||s.setState("search",e.target.value),null==n||n(e.target.value)}})}),tS=f.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...a}=e,s=f.useRef(null),i=f.useRef(null),o=tT(e=>e.selectedItemId),l=f.useContext(tx);return f.useEffect(()=>{if(i.current&&s.current){let e=i.current,t=s.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty("--cmdk-list-height",n.toFixed(1)+"px")})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),f.createElement(z.div,{ref:y(s,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":o,"aria-label":r,id:l.listId},tA(e,e=>f.createElement("div",{ref:y(i,l.listInnerRef),"cmdk-list-sizer":""},e)))}),tC=f.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:s,container:i,...o}=e;return f.createElement(eJ,{open:n,onOpenChange:r},f.createElement(e1,{container:i},f.createElement(e5,{"cmdk-overlay":"",className:a}),f.createElement(e8,{"aria-label":e.label,"cmdk-dialog":"",className:s},f.createElement(tw,{ref:t,...o}))))}),tE=Object.assign(tw,{List:tS,Item:tj,Input:tk,Group:ty,Separator:tN,Dialog:tC,Empty:f.forwardRef((e,t)=>tT(e=>0===e.filtered.count)?f.createElement(z.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Loading:f.forwardRef((e,t)=>{let{progress:n,children:r,label:a="Loading...",...s}=e;return f.createElement(z.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},tA(e,e=>f.createElement("div",{"aria-hidden":!0},e)))})});function tD(e){let t=f.useRef(e);return tI(()=>{t.current=e}),t}var tI="u"<typeof window?f.useEffect:f.useLayoutEffect;function tM(e){let t=f.useRef();return void 0===t.current&&(t.current=e()),t}function tT(e){let t=f.useContext(tv),n=()=>e(t.snapshot());return f.useSyncExternalStore(t.subscribe,n,n)}function tP(e,t,n,r=[]){let a=f.useRef(),s=f.useContext(tx);return tI(()=>{var i;let o=(()=>{var e;for(let t of n){if("string"==typeof t)return t.trim();if("object"==typeof t&&"current"in t)return t.current?null==(e=t.current.textContent)?void 0:e.trim():a.current}})(),l=r.map(e=>e.trim());s.value(e,o,l),null==(i=t.current)||i.setAttribute(th,o),a.current=o}),a}var tz=()=>{let[e,t]=f.useState(),n=tM(()=>new Map);return tI(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function tA({asChild:e,children:t},n){let r;return e&&f.isValidElement(t)?f.cloneElement("function"==typeof(r=t.type)?r(t.props):"render"in r?r.render(t.props):t,{ref:t.ref},n(t.props.children)):n(t)}var tO={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"},tL=e.i(465458),t_=e.i(209988),tR=e.i(294237);function t$({className:e,...t}){return(0,p.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,tL.cn)("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",e),...t})}e.i(260218),e.i(681622),e.i(788010);let tF=(0,tR.cva)("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function tW({className:e,align:t="inline-start",...n}){return(0,p.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:(0,tL.cn)(tF({align:t}),e),onClick:e=>{e.target.closest("button")||e.currentTarget.parentElement?.querySelector("input")?.focus()},...n})}(0,tR.cva)("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});var tB=e.i(367914);function tU({className:e,...t}){return(0,p.jsx)(tE,{"data-slot":"command",className:(0,tL.cn)("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",e),...t})}function tH({title:e="Command Palette",description:t="Search for a command to run...",children:n,className:r,showCloseButton:a=!1,...s}){return(0,p.jsxs)(t_.Dialog,{...s,children:[(0,p.jsxs)(t_.DialogHeader,{className:"sr-only",children:[(0,p.jsx)(t_.DialogTitle,{children:e}),(0,p.jsx)(t_.DialogDescription,{children:t})]}),(0,p.jsx)(t_.DialogContent,{className:(0,tL.cn)("overflow-hidden rounded-xl! p-0",r),showCloseButton:a,children:n})]})}function tK({className:e,...t}){return(0,p.jsx)("div",{"data-slot":"command-input-wrapper",className:"p-1 pb-0",children:(0,p.jsxs)(t$,{className:"h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!",children:[(0,p.jsx)(tE.Input,{"data-slot":"command-input",className:(0,tL.cn)("w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t}),(0,p.jsx)(tW,{children:(0,p.jsx)(tB.SearchIcon,{className:"size-4 shrink-0 opacity-50"})})]})})}function tV({className:e,...t}){return(0,p.jsx)(tE.List,{"data-slot":"command-list",className:(0,tL.cn)("no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",e),...t})}function tq({className:e,...t}){return(0,p.jsx)(tE.Empty,{"data-slot":"command-empty",className:(0,tL.cn)("py-6 text-center text-sm",e),...t})}function tX({className:e,...t}){return(0,p.jsx)(tE.Group,{"data-slot":"command-group",className:(0,tL.cn)("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",e),...t})}function tG({className:e,children:t,...n}){return(0,p.jsx)(tE.Item,{"data-slot":"command-item",className:(0,tL.cn)("group/command-item relative flex w-full cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",e),...n,children:t})}function tJ({className:e,...t}){return(0,p.jsx)("span",{"data-slot":"command-shortcut",className:(0,tL.cn)("ml-auto text-xs tracking-widest text-muted-foreground group-data-selected/command-item:text-foreground",e),...t})}var tY=e.i(640376),tZ=e.i(227634),tQ=e.i(938306),t0=e.i(31807);let t1={prefix:"channel",aliases:["ch","c"],label:"Channel",icon:tZ.Hash,search:e=>{let{channels:t,setActiveChannel:n}=t0.useChannelStore.getState(),r=e.toLowerCase();return t.filter(e=>e.name.toLowerCase().includes(r)).map(e=>({id:e.id,label:e.name,description:e.type,icon:tQ.MessageCircle,action:()=>n(e.id)}))}};var t2=e.i(592039),t5=e.i(511800),t3=e.i(327964);let t4={prefix:"issue",aliases:["i","bug"],label:"Issue",icon:t2.CircleDot,search:e=>{let{issues:t,setActiveIssue:n}=t3.useIssueStore.getState(),r=e.toLowerCase();return t.filter(e=>e.title.toLowerCase().includes(r)||e.description?.toLowerCase().includes(r)).map(e=>({id:e.id,label:e.title,description:e.status,icon:t5.AlertCircle,action:()=>n(e.id)}))}};var t6=e.i(984178),t8=e.i(381253),t9=e.i(691223),t7=e.i(437122);let ne=new Set(["ts","tsx","js","jsx","py","rs","go","java","c","cpp","h","css","scss","html","json","yaml","yml","md","sql","sh"]),nt={prefix:"file",aliases:["f","open"],label:"File",icon:t6.FileIcon,search:async e=>{let{openFile:t}=t9.useEditorStore.getState(),{workspaceId:n}=t0.useChannelStore.getState();if(!n)return[];let r=await (0,t7.fetchWithAuth)(`/api/workspaces/${n}/search/files?q=${encodeURIComponent(e)}`);return r.ok?((await r.json()).results??[]).map(e=>{var r;let a;return{id:e.path,label:e.name,description:e.path,icon:(r=e.path,a=r.split(".").pop()?.toLowerCase()??"",ne.has(a)?t8.FileCode:t6.FileIcon),action:()=>t(n,e.path)}}):[]}};var nn=e.i(451534);let nr=(0,e.i(433721).default)("briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);var na=e.i(361031),ns=e.i(233297);let ni={prefix:"workspace",aliases:["w","ws"],label:"Workspace",icon:nn.FolderOpen,search:e=>{let{workspaces:t}=na.useWorkspaceStore.getState(),n=e.toLowerCase();return t.filter(e=>e.name.toLowerCase().includes(n)||e.boundDirs.some(e=>e.toLowerCase().includes(n))).map(e=>({id:e.id,label:e.name,description:e.boundDirs[0],icon:nr,action:()=>{let t=(0,ns.toStaticHref)(`/workspace/${e.id}`);window.location.href=t}}))}};var no=e.i(100559),nl=e.i(882469),nc=e.i(523592);let nd=[t1,t4,nt,ni,{prefix:"server",aliases:["s","sv"],label:"Server",icon:no.Server,search:e=>{let t=(0,nc.loadServers)(),n=(0,nc.loadActiveId)(),r=e.toLowerCase();return t.filter(e=>e.name.toLowerCase().includes(r)||e.url.toLowerCase().includes(r)).map(e=>({id:e.id,label:e.name+(e.id===n?" (active)":""),description:e.url,icon:nl.Globe,action:()=>{t9.useEditorStore.getState().resetEditorState(),(0,nc.saveActiveId)(e.id),(0,nc.setActiveServerCookie)(e.url),window.location.reload()}}))}}];function nu(e){for(let t of nd)for(let n of[t.prefix,...t.aliases])if(e===n+" "||e.startsWith(n+" "))return{provider:t,keyword:e.slice(n.length+1)};return null}var nm=e.i(244073);e.s(["CommandPalette",0,function(){let e=(0,nm.useTranslations)("commandPalette"),{open:t,setOpen:n,toggle:r,commands:a}=(0,tY.useCommandPalette)(),[s,i]=(0,f.useState)("");(0,f.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),r())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r]),(0,f.useEffect)(()=>{if(!t){i("");let e=document.querySelector("[cmdk-input]");e&&(e.value="")}},[t]);let o=(0,f.useMemo)(()=>nu(s),[s]),[l,c]=(0,f.useState)([]),[d,u]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let e=nu(s);if(!e){c([]),u(!1);return}let t=e.provider.search(e.keyword);if(t instanceof Promise){u(!0);let e=!1;return t.then(t=>{e||c(t)}).finally(()=>{e||u(!1)}),()=>{e=!0}}c(t),u(!1)},[s]);let m=(0,f.useMemo)(()=>{let e=new Map;for(let t of a){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return e},[a]),h=(0,f.useMemo)(()=>nd.map(e=>({id:`hint:${e.prefix}`,label:e.prefix,description:[...e.aliases].join(", "),icon:e.icon})),[]),g=!!o;return(0,p.jsx)(tH,{open:t,onOpenChange:n,title:e("title"),description:e("description"),children:(0,p.jsxs)(tU,{shouldFilter:!o,children:[(0,p.jsx)(tK,{placeholder:e("placeholder"),value:s,onValueChange:i}),(0,p.jsxs)(tV,{children:[(0,p.jsx)(tq,{children:e("empty")}),g&&(0,p.jsx)(tX,{heading:o.provider.label,children:d?(0,p.jsx)("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"..."}):0===l.length?(0,p.jsx)("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:e("noResults")}):l.slice(0,10).map(e=>(0,p.jsxs)(tG,{value:e.label,onSelect:()=>{n(!1),e.action()},children:[e.icon&&(0,p.jsx)(e.icon,{className:"size-4 shrink-0"}),(0,p.jsx)("span",{className:"truncate min-w-0",children:e.label}),e.description&&(0,p.jsx)("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground truncate max-w-[200px]",children:e.description})]},e.id))}),!o&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(tX,{heading:"Search",children:h.map(e=>(0,p.jsxs)(tG,{value:e.label,className:"data-selected:bg-transparent! [&>svg:last-child]:hidden!",onSelect:()=>i(e.label+" "),children:[e.icon&&(0,p.jsx)(e.icon,{className:"size-4 shrink-0"}),(0,p.jsx)("span",{className:"truncate min-w-0",children:e.label}),e.description&&(0,p.jsx)("span",{className:"ml-auto text-xs text-muted-foreground text-right shrink-0",children:e.description})]},e.id))}),[...m.entries()].map(([e,t])=>(0,p.jsx)(tX,{heading:e,children:t.map(e=>(0,p.jsxs)(tG,{value:e.label,onSelect:()=>{n(!1),e.action()},children:[e.icon&&(0,p.jsx)(e.icon,{className:"size-4 shrink-0"}),(0,p.jsx)("span",{className:"truncate min-w-0",children:e.label}),e.shortcut&&(0,p.jsx)(tJ,{children:e.shortcut})]},e.id))},e))]})]})]})})}],698679)}]);
@@ -1,2 +1,2 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,607452,e=>{"use strict";var t,n=e.i(344180);e.s([],885864),e.i(885864),e.i(8890);var r=e.i(764556),l=e.i(526850),i=e.i(535270),a=e.i(29905),s=e.i(106045),o=e.i(277642),u=e.i(602453),d=e.i(638144),c=e.i(139236),m=e.i(969490),f=e.i(464111);function p(e,t,n=(e,t)=>e===t){return e.length===t.length&&e.every((e,r)=>n(e,t[r]))}var x=e.i(410421),h=e.i(756432),v=e.i(125231),g=e.i(975698),b=e.i(380414),y=e.i(443124);function N(e,t){return e-t}function j(e,t,n,r,l,i){var a;let s,o=e;return o=(0,f.clamp)(o,n,r),l&&(a=(0,f.clamp)(o,i[t-1]||-1/0,i[t+1]||1/0),(s=i.slice())[t]=a,o=s.sort(N)),o}function C(e,t,n){return!Array.isArray(e)||Math.min(...e.reduce((e,t,n,r)=>(n===r.length-1||e.push(Math.abs(t-r[n+1])),e),[]))>=t*n}let E={activeThumbIndex:()=>null,max:()=>null,min:()=>null,minStepsBetweenValues:()=>null,step:()=>null,values:()=>null,...e.i(438904).fieldValidityMapping};var k=e.i(267805);let w=r.createContext(void 0);function S(){let e=r.useContext(w);if(void 0===e)throw Error((0,k.default)(62));return e}var R=e.i(742665);let I=r.forwardRef(function(e,t){let{"aria-labelledby":k,className:S,defaultValue:I,disabled:A=!1,id:P,format:M,largeStep:T=10,locale:D,render:O,max:F=100,min:L=0,minStepsBetweenValues:$=0,form:B,name:z,onValueChange:V,onValueCommitted:W,orientation:H="horizontal",step:K=1,thumbCollisionBehavior:_="push",thumbAlignment:U="center",value:q,style:G,...Y}=e,X=(0,c.useBaseUiId)(P),J=null==X?void 0:`${X}-label`,Q=(0,a.useStableCallback)(V),Z=(0,a.useStableCallback)(W),{clearErrors:ee}=(0,b.useFormContext)(),{state:et,disabled:en,name:er,setTouched:el,setDirty:ei,validityData:ea,shouldValidateOnChange:es,validation:eo}=(0,v.useFieldRootContext)(),{labelId:eu}=(0,y.useLabelableContext)(),[ed,ec]=r.useState(),em=k??eu??ed,ef=en||A,ep=er??z,[ex,eh]=(0,i.useControlled)({controlled:q,default:I??L,name:"Slider"}),ev=r.useRef(null),eg=r.useRef(null),eb=r.useRef([]),ey=r.useRef(null),eN=r.useRef(null),ej=r.useRef(-1),eC=r.useRef(null),eE=r.useRef(null),ek=r.useRef("none"),ew=(0,s.useValueAsRef)(M),[eS,eR]=r.useState(-1),[eI,eA]=r.useState(-1),[eP,eM]=r.useState(!1),[eT,eD]=r.useState(()=>new Map),[eO,eF]=r.useState([void 0,void 0]),eL=(0,a.useStableCallback)(e=>{eR(e),-1!==e&&eA(e)});(0,g.useRegisterFieldControl)(eg,{id:X,value:ex}),(0,d.useValueChanged)(ex,()=>{ee(ep),es()?eo.commit(ex):eo.commit(ex,!0);let e=ea.initialValue;ei(Array.isArray(ex)&&Array.isArray(e)?!p(ex,e):ex!==e)});let e$=(0,a.useStableCallback)(e=>{e&&(eg.current=e)}),eB=Array.isArray(ex),ez=r.useMemo(()=>eB?ex.slice().sort(N):[(0,f.clamp)(ex,L,F)],[F,L,eB,ex]),eV=(0,a.useStableCallback)((e,t)=>{if(Number.isNaN(e)||("number"==typeof e&&"number"==typeof ex?e===ex:!!(Array.isArray(e)&&Array.isArray(ex))&&p(e,ex)))return;let n=t??(0,u.createChangeEventDetails)(R.REASONS.none,void 0,void 0,{activeThumbIndex:-1});ek.current=n.reason;let r=n.event,l=new(r.constructor??Event)(r.type,r);Object.defineProperty(l,"target",{writable:!0,value:{value:e,name:ep}}),n.event=l,eE.current=e,Q(e,n),n.isCanceled||eh(e)}),eW=(0,a.useStableCallback)((e,t,n)=>{let r=j(e,t,L,F,eB,ez);if(C(r,K,$)){let e="key"in n?R.REASONS.keyboard:R.REASONS.inputChange;eV(r,(0,u.createChangeEventDetails)(e,n.nativeEvent,void 0,{activeThumbIndex:t})),el(!0),Z(eE.current??r,(0,u.createGenericEventDetails)(e,n.nativeEvent))}});(0,o.useIsoLayoutEffect)(()=>{let e=(0,x.activeElement)((0,l.ownerDocument)(ev.current));ef&&(0,x.contains)(ev.current,e)&&e.blur()},[ef]),ef&&-1!==eS&&eL(-1);let eH=r.useMemo(()=>({...et,activeThumbIndex:eS,disabled:ef,dragging:eP,orientation:H,max:F,min:L,minStepsBetweenValues:$,step:K,values:ez}),[et,eS,ef,eP,F,L,$,H,K,ez]),eK=r.useMemo(()=>({active:eS,controlRef:eg,disabled:ef,dragging:eP,validation:eo,formatOptionsRef:ew,handleInputChange:eW,indicatorPosition:eO,inset:"center"!==U,labelId:em,rootLabelId:J,largeStep:T,lastUsedThumbIndex:eI,lastChangedValueRef:eE,lastChangeReasonRef:ek,form:B,locale:D,max:F,min:L,minStepsBetweenValues:$,name:ep,onValueCommitted:Z,orientation:H,pressedInputRef:ey,pressedThumbCenterOffsetRef:eN,pressedThumbIndexRef:ej,pressedValuesRef:eC,registerFieldControlRef:e$,renderBeforeHydration:"edge"===U,setActive:eL,setDragging:eM,setIndicatorPosition:eF,setLabelId:ec,setValue:eV,state:eH,step:K,thumbCollisionBehavior:_,thumbMap:eT,thumbRefs:eb,values:ez}),[eS,eg,em,J,ef,eP,eo,ew,eW,eO,T,eI,eE,ek,B,D,F,L,$,ep,Z,H,ey,eN,ej,eC,e$,eL,eM,eF,ec,eV,eH,K,_,U,eT,eb,ez]),e_=(0,m.useRenderElement)("div",e,{state:eH,ref:[t,ev],props:[{"aria-labelledby":em,id:X,role:"group"},eo.getValidationProps,Y],stateAttributesMapping:E});return(0,n.jsx)(w.Provider,{value:eK,children:(0,n.jsx)(h.CompositeList,{elementsRef:eb,onMapChange:eD,children:e_})})});var A=e.i(92615),P=e.i(213700);let M=r.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;delete a.id;let{state:s,setLabelId:o,controlRef:u,rootLabelId:d}=S(),c=(0,P.useLabel)({id:d,setLabelId:o,focusControl:function(e,t){if(t){let n=(0,l.ownerDocument)(e.currentTarget).getElementById(t);if((0,A.isHTMLElement)(n))return void(0,P.focusElementWithVisible)(n)}let n=u.current?.querySelectorAll('input[type="range"]'),r=n?.length===1?n[0]:null;(0,A.isHTMLElement)(r)&&(0,P.focusElementWithVisible)(r)}});return(0,m.useRenderElement)("div",e,{ref:t,state:s,props:[c,a],stateAttributesMapping:E})});var T=e.i(842809);let D=r.forwardRef(function(e,t){let{"aria-live":n="off",render:l,className:i,children:a,style:s,...o}=e,{thumbMap:u,state:d,values:c,formatOptionsRef:f,locale:p}=S(),x=r.useMemo(()=>{let e="";for(let t of u.values())t?.inputId&&(e+=`${t.inputId} `);return""===e.trim()?void 0:e.trim()},[u]),h=r.useMemo(()=>{let e=[];for(let t=0;t<c.length;t+=1)e.push((0,T.formatNumber)(c[t],p,f.current??void 0));return e},[f,p,c]),v=r.useMemo(()=>{let e=[];for(let t=0;t<c.length;t+=1)e.push(h[t]||c[t]);return e.join(" – ")},[c,h]);return(0,m.useRenderElement)("output",e,{state:d,ref:t,props:[{"aria-live":n,children:"function"==typeof a?a(h,c):v,htmlFor:x},o],stateAttributesMapping:E})});var O=e.i(422561),F=e.i(859092),L=e.i(189131);function $(e){let t=e.getBoundingClientRect();return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}}function B(e){if(0===e)return 0;if(1>Math.abs(e)){let t=e.toExponential().split("e-"),n=t[0].split(".")[1];return(n?n.length:0)+parseInt(t[1],10)}let t=e.toString().split(".")[1];return t?t.length:0}function z(e,t,n){return Number((Math.round((e-n)/t)*t+n).toFixed(Math.max(B(t),B(n))))}function V({values:e,index:t,nextValue:n,min:r,max:l,step:i,minStepsBetweenValues:a,initialValues:s}){if(0===e.length)return[];let o=e.slice(),u=i*a,d=o.length-1,c=s??e;o[t]=(0,f.clamp)(n,r+t*u,l-(d-t)*u);for(let e=t+1;e<=d;e+=1){let t=o[e-1]+u,n=l-(d-e)*u,r=c[e]??o[e],i=Math.max(o[e],t);r<i&&(i=Math.max(r,t)),o[e]=(0,f.clamp)(i,t,n)}for(let e=t-1;e>=0;e-=1){let t=o[e+1]-u,n=r+e*u,l=c[e]??o[e],i=Math.min(o[e],t);l>i&&(i=Math.min(l,t)),o[e]=(0,f.clamp)(i,n,t)}for(let e=0;e<=d;e+=1)o[e]=Number(o[e].toFixed(12));return o}function W(e,t){if(null!=t.current&&e.changedTouches){for(let n=0;n<e.changedTouches.length;n+=1){let r=e.changedTouches[n];if(r.identifier===t.current)return{x:r.clientX,y:r.clientY}}return null}return{x:e.clientX,y:e.clientY}}let H=r.forwardRef(function(e,t){let{render:n,className:i,style:o,...d}=e,{disabled:c,dragging:p,inset:h,lastChangedValueRef:v,lastChangeReasonRef:g,max:b,min:y,minStepsBetweenValues:N,onValueCommitted:j,orientation:k,pressedInputRef:w,pressedThumbCenterOffsetRef:I,pressedThumbIndexRef:P,pressedValuesRef:M,registerFieldControlRef:T,renderBeforeHydration:D,setActive:B,setDragging:H,setValue:K,state:_,step:U,thumbCollisionBehavior:q,thumbRefs:G,values:Y}=S(),X=(0,L.useDirection)(),J=Y.length>1,Q="vertical"===k,Z=r.useRef(null),ee=r.useRef(null),et=(0,a.useStableCallback)(e=>{e&&null==ee.current&&null==ee.current&&(ee.current=getComputedStyle(e))}),en=r.useRef(null),er=r.useRef(0),el=r.useRef(0),ei=(0,s.useValueAsRef)(Y),ea=(0,a.useStableCallback)(e=>{P.current!==e&&(P.current=e);let t=G.current[e];if(!t){I.current=null,w.current=null;return}w.current=t.querySelector('input[type="range"]')}),es=(0,a.useStableCallback)(e=>{let t=Z.current;if(!t)return null;let{width:n,height:r,bottom:l,left:i,right:a}=t.getBoundingClientRect(),s=function(e,t){if(!e)return{start:0,end:0};function n(e){let t=null!=e?parseFloat(e):0;return Number.isNaN(t)?0:t}let r=t?"Top":"InlineStart",l=t?"Bottom":"InlineEnd";return{start:n(e[`border${r}Width`])+n(e[`padding${r}`]),end:n(e[`border${l}Width`])+n(e[`padding${l}`])}}(ee.current,Q),o=el.current,u=(Q?r:n)-s.start-s.end-2*o,d=I.current??0,c=e.x-d,m=e.y-d,p=Q?l-m-s.end:("rtl"===X?a-c:c-i)-s.start,x=(b-y)*(0,f.clamp)((p-o)/u,0,1)+y;if(x=z(x,U,y),x=(0,f.clamp)(x,y,b),!J)return{value:x,thumbIndex:0,didSwap:!1};let h=P.current;if(h<0)return null;let v=function({behavior:e,values:t,currentValues:n,initialValues:r,pressedIndex:l,nextValue:i,min:a,max:s,step:o,minStepsBetweenValues:u}){let d=n??t,c=r??t;if(!(d.length>1))return{value:i,thumbIndex:0,didSwap:!1};let m=o*u;switch(e){case"swap":{let e=d[l],t=d.slice(),n=t[l-1],r=t[l+1],p=null!=n?n+m:a,x=null!=r?r-m:s,h=Number((0,f.clamp)(i,p,x).toFixed(12));t[l]=h;let v=i>e,g=i<e,b=v&&null!=r&&i>=r-1e-7,y=g&&null!=n&&i<=n+1e-7;if(!b&&!y)return{value:t,thumbIndex:l,didSwap:!1};let N=b?l+1:l-1,j=t.map((e,t)=>{if(t===l)return h;let n=c[t];return null!=n?n:d[t]}),C=i;C=b?Math.max(i,t[N]):Math.min(i,t[N]);let E=V({values:t,index:N,nextValue:C,min:a,max:s,step:o,minStepsBetweenValues:u,initialValues:j}),k=b?N-1:N+1;if(k>=0&&k<E.length){let e=E[k-1],t=E[k+1],n=null!=e?e+m:a;n=Math.max(n,a+k*m);let r=null!=t?t-m:s;r=Math.min(r,s-(E.length-1-k)*m);let l=(0,f.clamp)(h,n,r);E[k]=Number(l.toFixed(12))}return{value:E,thumbIndex:N,didSwap:!0}}case"push":return{value:V({values:d,index:l,nextValue:i,min:a,max:s,step:o,minStepsBetweenValues:u}),thumbIndex:l,didSwap:!1};default:{let e=d.slice(),t=e[l-1],n=e[l+1],r=null!=t?t+m:a,o=null!=n?n-m:s,u=(0,f.clamp)(i,r,o);return e[l]=Number(u.toFixed(12)),{value:e,thumbIndex:l,didSwap:!1}}}}({behavior:q,values:Y,currentValues:ei.current??Y,initialValues:M.current,pressedIndex:h,nextValue:x,min:y,max:b,step:U,minStepsBetweenValues:N});return"swap"===q&&v.didSwap?ea(v.thumbIndex):P.current=v.thumbIndex,v}),eo=(0,a.useStableCallback)(e=>{M.current=J?Y.slice():null,ei.current=Y;let t=P.current,n=t;if(t>-1&&t<Y.length){if(Y[t]===b){let e=t;for(;e>0&&Y[e-1]===b;)e-=1;n=e}}else{let t,r=Q?"y":"x";n=-1;for(let l=0;l<G.current.length;l+=1){let i=G.current[l];if((0,A.isElement)(i)){let a=$(i),s=Math.abs(e[r]-a[r]);(void 0===t||s<=t)&&(n=l,t=s)}}}if(n>-1&&n!==t&&ea(n),h){let e=G.current[n];(0,A.isElement)(e)&&(el.current=e.getBoundingClientRect()[Q?"height":"width"]/2)}}),eu=(0,a.useStableCallback)(e=>{let t=G.current?.[e]?.querySelector('input[type="range"]');t&&t.focus({preventScroll:!0,focusVisible:!1})}),ed=(0,a.useStableCallback)(e=>{let t=W(e,en);if(null==t)return;if(er.current+=1,"pointermove"===e.type&&0===e.buttons)return void ec(e);let n=es(t);null!=n&&C(n.value,U,N)&&(!p&&er.current>2&&H(!0),K(n.value,(0,u.createChangeEventDetails)(R.REASONS.drag,e,void 0,{activeThumbIndex:n.thumbIndex})),ei.current=Array.isArray(n.value)?n.value:[n.value],n.didSwap&&eu(n.thumbIndex))});function ec(e){B(-1),H(!1),w.current=null,I.current=null;let t=W(e,en),n=null!=t?es(t):null;if(null!=n){let t=g.current;j(v.current??n.value,(0,u.createGenericEventDetails)(t,e))}"pointerType"in e&&Z.current?.hasPointerCapture(e.pointerId)&&Z.current?.releasePointerCapture(e.pointerId),P.current=-1,en.current=null,M.current=null,ef()}let em=(0,a.useStableCallback)(e=>{if(c)return;let t=e.changedTouches[0];null!=t&&(en.current=t.identifier);let n=W(e,en);if(null!=n){eo(n);let t=es(n);if(null==t)return;eu(t.thumbIndex),K(t.value,(0,u.createChangeEventDetails)(R.REASONS.trackPress,e,void 0,{activeThumbIndex:t.thumbIndex})),ei.current=Array.isArray(t.value)?t.value:[t.value],t.didSwap&&eu(t.thumbIndex)}er.current=0;let r=(0,l.ownerDocument)(Z.current);r.addEventListener("touchmove",ed,{passive:!0}),r.addEventListener("touchend",ec,{passive:!0})}),ef=(0,a.useStableCallback)(()=>{let e=(0,l.ownerDocument)(Z.current);e.removeEventListener("pointermove",ed),e.removeEventListener("pointerup",ec),e.removeEventListener("touchmove",ed),e.removeEventListener("touchend",ec),M.current=null}),ep=(0,F.useAnimationFrame)();return r.useEffect(()=>{let e=Z.current;if(!e)return()=>ef();let t=(0,O.addEventListener)(e,"touchstart",em,{passive:!0});return()=>{t(),ep.cancel(),ef()}},[ef,em,Z,ep]),r.useEffect(()=>{c&&ef()},[c,ef]),(0,m.useRenderElement)("div",e,{state:_,ref:[t,T,Z,et],props:[{"data-base-ui-slider-control":D?"":void 0,onPointerDown(e){let t=Z.current,n=(0,x.getTarget)(e.nativeEvent);if(!t||c||e.defaultPrevented||!(0,A.isElement)(n)||0!==e.button)return;let r=W(e,en);if(null!=r){eo(r);let n=es(r);if(null==n)return;(0,x.contains)(G.current[n.thumbIndex],(0,x.activeElement)((0,l.ownerDocument)(t)))?e.preventDefault():ep.request(()=>{eu(n.thumbIndex)}),H(!0),null==I.current&&(K(n.value,(0,u.createChangeEventDetails)(R.REASONS.trackPress,e.nativeEvent,void 0,{activeThumbIndex:n.thumbIndex})),ei.current=Array.isArray(n.value)?n.value:[n.value],n.didSwap&&eu(n.thumbIndex))}e.nativeEvent.pointerId&&t.setPointerCapture(e.nativeEvent.pointerId),er.current=0;let i=(0,l.ownerDocument)(Z.current);i.addEventListener("pointermove",ed,{passive:!0}),i.addEventListener("pointerup",ec,{once:!0})}},d],stateAttributesMapping:E})}),K=r.forwardRef(function(e,t){let{render:n,className:r,style:l,...i}=e,{state:a}=S();return(0,m.useRenderElement)("div",e,{state:a,ref:t,props:[{style:{position:"relative"}},i],stateAttributesMapping:E})});var _=e.i(204133),U=e.i(236706),q=e.i(370383),G=e.i(517432),Y=e.i(203922),X=e.i(100229),J=e.i(296615),Q=e.i(394394),Z=e.i(922970),ee=e.i(575665);let et=((t={}).index="data-index",t.dragging="data-dragging",t.orientation="data-orientation",t.disabled="data-disabled",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.focused="data-focused",t),en=new Set([X.ARROW_UP,X.ARROW_DOWN,X.ARROW_LEFT,X.ARROW_RIGHT,X.HOME,X.END,X.PAGE_UP,X.PAGE_DOWN]);function er(e,t,n,r,l){let i=Number((1===n?e+t:e-t).toFixed(Math.max(B(e),B(t),B(r))));return(0,f.clamp)(i,r,l)}let el=r.forwardRef(function(e,t){let l,{render:i,children:s,className:u,"aria-describedby":d,"aria-label":f,"aria-labelledby":p,disabled:x=!1,getAriaLabel:h,getAriaValueText:g,id:b,index:y,inputRef:N,onBlur:C,onFocus:k,onKeyDown:w,tabIndex:R,style:I,...A}=e,{nonce:P}=(0,Q.useCSPContext)(),M=(0,c.useBaseUiId)(b),{active:D,lastUsedThumbIndex:O,controlRef:F,disabled:B,validation:V,formatOptionsRef:W,handleInputChange:H,inset:K,labelId:el,largeStep:ei,locale:ea,max:es,min:eo,minStepsBetweenValues:eu,form:ed,name:ec,orientation:em,pressedInputRef:ef,pressedThumbCenterOffsetRef:ep,pressedThumbIndexRef:ex,renderBeforeHydration:eh,setActive:ev,setIndicatorPosition:eg,state:eb,step:ey,values:eN}=S(),ej=(0,L.useDirection)(),eC=eN.length>1,eE="vertical"===em,ek="rtl"===ej,{setTouched:ew,setFocused:eS,validationMode:eR}=(0,v.useFieldRootContext)(),eI=r.useRef(null),eA=r.useRef(null),eP=r.useRef(!1),eM=(0,c.useBaseUiId)(),eT=(0,ee.useLabelableId)(),eD=eC?eM:eT,eO=r.useMemo(()=>({inputId:eD}),[eD]),{ref:eF,index:eL}=(0,J.useCompositeListItem)({metadata:eO}),e$=eC?y??eL:0,eB=e$===eN.length-1,ez=eN[e$],eV=(0,Y.valueToPercent)(ez,eo,es),[eW,eH]=r.useState(),eK=(0,G.useIsHydrating)(),e_=O>=0&&O<eN.length?O:-1,eU=(0,a.useStableCallback)(()=>{let e=F.current,t=eI.current;if(!e||!t)return;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),l=eE?"height":"width",i=r[l]-n[l],a=(n[l]/2+i*eV/100)/r[l]*100,s=Number.isFinite(a)?a:void 0;eH(s),0===e$?eg(e=>[s,e[1]]):eB&&eg(e=>[e[0],s])});(0,o.useIsoLayoutEffect)(()=>{K&&queueMicrotask(eU)},[eU,K]),(0,o.useIsoLayoutEffect)(()=>{K&&eU()},[eU,K,eV]),(0,o.useIsoLayoutEffect)(()=>{if(!K||"function"!=typeof ResizeObserver)return;let e=F.current,t=eI.current;if(!e||!t)return;let n=new ResizeObserver(eU);return n.observe(e),n.observe(t),()=>{n.disconnect()}},[F,eU,K]);let eq=r.useCallback(()=>{let e,t=eE?"bottom":"insetInlineStart",n=eE?"left":"top";return(eC?D===e$?e=2:e_===e$&&(e=1):D===e$&&(e=1),K)?{"--position":`${eW??0}%`,visibility:eh&&eK||void 0===eW?"hidden":void 0,position:"absolute",[t]:"var(--position)",[n]:"50%",translate:`${(eE||!ek?-1:1)*50}% ${(eE?1:-1)*50}%`,zIndex:e}:Number.isFinite(eV)?{position:"absolute",[t]:`${eV}%`,[n]:"50%",translate:`${(eE||!ek?-1:1)*50}% ${(eE?1:-1)*50}%`,zIndex:e}:U.visuallyHidden},[D,e$,K,eK,eW,eC,eh,ek,e_,eV,eE]);"vertical"===em&&(l=ek?"vertical-rl":"vertical-lr");let eG="function"==typeof h?h(e$):f,eY=(0,q.mergeProps)({"aria-label":eG,"aria-labelledby":p??(null==eG?el:void 0),"aria-describedby":d,"aria-orientation":em,"aria-valuenow":ez,"aria-valuetext":"function"==typeof g?g((0,T.formatNumber)(ez,ea,W.current??void 0),ez,e$):function(e,t,n,r){if(!(t<0))return 2===e.length?0===t?`${(0,T.formatNumber)(e[t],r,n)} start range`:`${(0,T.formatNumber)(e[t],r,n)} end range`:n?(0,T.formatNumber)(e[t],r,n):void 0}(eN,e$,W.current??void 0,ea),disabled:x||B,form:ed,id:eD,max:es,min:eo,name:ec,onChange(e){H(e.currentTarget.valueAsNumber,e$,e)},onFocus(e){let t=eP.current;eP.current=!1,ev(e$),eS(!0),t&&e.stopPropagation()},onBlur(e){eP.current?e.stopPropagation():eI.current&&(ev(-1),ew(!0),eS(!1),"onBlur"===eR&&V.commit(j(ez,e$,eo,es,eC,eN)))},onKeyDown(e){if(!en.has(e.key))return;X.COMPOSITE_KEYS.has(e.key)&&e.stopPropagation();let t=null,n=z(ez,ey,eo);switch(e.key){case X.ARROW_UP:t=er(n,e.shiftKey?ei:ey,1,eo,es);break;case X.ARROW_RIGHT:t=er(n,e.shiftKey?ei:ey,ek?-1:1,eo,es);break;case X.ARROW_DOWN:t=er(n,e.shiftKey?ei:ey,-1,eo,es);break;case X.ARROW_LEFT:t=er(n,e.shiftKey?ei:ey,ek?1:-1,eo,es);break;case X.PAGE_UP:t=er(n,ei,1,eo,es);break;case X.PAGE_DOWN:t=er(n,ei,-1,eo,es);break;case X.END:t=es,eC&&(t=Number.isFinite(eN[e$+1])?eN[e$+1]-ey*eu:es);break;case X.HOME:t=eo,eC&&(t=Number.isFinite(eN[e$-1])?eN[e$-1]+ey*eu:eo)}if(null!==t){let n=e.currentTarget;(0,Z.matchesFocusVisible)(n)||(eP.current=!0,n.blur(),n.focus({preventScroll:!0,focusVisible:!0})),H(t,e$,e),e.preventDefault()}},step:ey,style:{...U.visuallyHidden,width:"100%",height:"100%",writingMode:l},tabIndex:R??void 0,type:"range",value:ez??""},V.getInputValidationProps),eX=(0,_.useMergedRefs)(eA,V.inputRef,N);return(0,m.useRenderElement)("div",e,{state:eb,ref:[t,eF,eI],props:[{[et.index]:e$,children:(0,n.jsxs)(r.Fragment,{children:[s,(0,n.jsx)("input",{ref:eX,...eY,suppressHydrationWarning:!0}),K&&eK&&eh&&eB&&(0,n.jsx)("script",{nonce:P,dangerouslySetInnerHTML:{__html:'!function(){const t=document.currentScript?.parentElement;if(!t)return;const e=t.closest("[data-base-ui-slider-control]");if(!e)return;const r=e.querySelector("[data-base-ui-slider-indicator]"),i=e.getBoundingClientRect(),n="vertical"===e.getAttribute("data-orientation")?"height":"width",o=e.querySelectorAll(\'input[type="range"]\'),l=o.length>1,s=o.length-1;let a=null,u=null;for(let t=0;t<o.length;t+=1){const e=o[t],y=parseFloat(e.getAttribute("value")??"");if(Number.isNaN(y))return;const c=e.parentElement;if(!c)return;const p=parseFloat(e.getAttribute("max")??"100"),g=parseFloat(e.getAttribute("min")??"0"),b=c?.getBoundingClientRect(),d=i[n]-b[n],m=100*(y-g)/(p-g),v=(b[n]/2+d*m/100)/i[n]*100;c.style.setProperty("--position",`${v}%`),Number.isFinite(v)&&(c.style.removeProperty("visibility"),r&&(0===t?(a=v,r.style.setProperty("--start-position",`${v}%`),l||r.style.removeProperty("visibility")):t===s&&(u=v-(a??0),r.style.setProperty("--end-position",`${v}%`),r.style.setProperty("--relative-size",`${u}%`),r.style.removeProperty("visibility"))))}}();'},suppressHydrationWarning:!0})]}),id:M,onBlur:C,onFocus:k,onPointerDown(e){if(ex.current=e$,null!=eI.current){let t="horizontal"===em?"x":"y",n=$(eI.current);ep.current=("horizontal"===em?e.clientX:e.clientY)-n[t]}null!=eA.current&&ef.current!==eA.current&&(ef.current=eA.current)},style:eq(),suppressHydrationWarning:eh||void 0},A],stateAttributesMapping:E})}),ei=r.forwardRef(function(e,t){var n,r;let l,i,a,s,{render:o,className:u,style:d,...c}=e,{indicatorPosition:f,inset:p,max:x,min:h,orientation:v,renderBeforeHydration:g,state:b,values:y}=S(),N=(0,G.useIsHydrating)(),j="vertical"===v,C=y.length>1,k=p?(n=f[0],r=f[1],l=void 0===n||C&&void 0===r?"hidden":void 0,i=j?"bottom":"insetInlineStart",a=j?"height":"width",((s={visibility:g&&N?"hidden":l,position:j?"absolute":"relative",[j?"width":"height"]:"inherit"})["--start-position"]=`${n??0}%`,C)?(s["--relative-size"]=`${(r??0)-(n??0)}%`,s[i]="var(--start-position)",s[a]="var(--relative-size)"):(s[i]=0,s[a]="var(--start-position)"),s):function(e,t,n,r){let l=e?"bottom":"insetInlineStart",i=e?"height":"width",a={position:e?"absolute":"relative",[e?"width":"height"]:"inherit"};if(!t)return a[l]=0,a[i]=`${n}%`,a;let s=r-n;return a[l]=`${n}%`,a[i]=`${s}%`,a}(j,C,(0,Y.valueToPercent)(y[0],h,x),(0,Y.valueToPercent)(y[y.length-1],h,x));return(0,m.useRenderElement)("div",e,{state:b,ref:t,props:[{"data-base-ui-slider-indicator":g?"":void 0,style:k,suppressHydrationWarning:g||void 0},c],stateAttributesMapping:E})});e.s(["Control",0,H,"Indicator",0,ei,"Label",0,M,"Root",0,I,"Thumb",0,el,"Track",0,K,"Value",0,D],414857);var ea=e.i(414857),ea=ea,es=e.i(465458);e.s(["Slider",0,function({className:e,defaultValue:t,value:r,min:l=0,max:i=100,...a}){let s=Array.isArray(r)?r:void 0!==r?[r]:Array.isArray(t)?t:[l,i];return(0,n.jsx)(ea.Root,{className:(0,es.cn)("data-horizontal:w-full data-vertical:h-full",e),"data-slot":"slider",defaultValue:t,value:r,min:l,max:i,thumbAlignment:"edge",...a,children:(0,n.jsxs)(ea.Control,{className:"relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col",children:[(0,n.jsx)(ea.Track,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted select-none data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1",children:(0,n.jsx)(ea.Indicator,{"data-slot":"slider-range",className:"bg-primary select-none data-horizontal:h-full data-vertical:w-full"})}),Array.from({length:s.length},(e,t)=>(0,n.jsx)(ea.Thumb,{"data-slot":"slider-thumb",className:"relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50"},t))]})})}],607452)},86477,e=>{"use strict";var t=e.i(344180),n=e.i(764556),r=e.i(244073),l=e.i(209988),i=e.i(260218),a=e.i(681622),s=e.i(607452),o=e.i(562918),u=e.i(226624),d=e.i(767467),c=e.i(990336),m=e.i(953700),f=e.i(137340),p=e.i(368942);let x={vision:"bg-blue-500/10 text-blue-600 border-blue-200",reasoning:"bg-purple-500/10 text-purple-600 border-purple-200",embedding:"bg-green-500/10 text-green-600 border-green-200"},h=[{label:"8K",value:8192},{label:"16K",value:16384},{label:"32K",value:32768},{label:"64K",value:65536},{label:"128K",value:128e3},{label:"200K",value:2e5},{label:"256K",value:256e3},{label:"1M",value:1e6}],v=["low","medium","high"];function g({groups:e,providerNames:n,onEdit:l,onDelete:a}){let s=(0,r.useTranslations)("models"),u=n.length>0?n:["Other"],d=Object.keys(e).sort((e,t)=>{let n=u.indexOf(e),r=u.indexOf(t);return n>=0&&r>=0?n-r:n>=0?-1:r>=0?1:e.localeCompare(t)});return(0,t.jsxs)("div",{className:"flex flex-col p-4 gap-4",children:[d.map(n=>(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2 px-1",children:n}),(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:e[n].map(e=>{var n;return(0,t.jsxs)("div",{className:"group flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>l(e),children:[(0,t.jsx)(c.Brain,{className:"size-4 text-muted-foreground shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground font-mono ml-2",children:e.modelId}),e.cost?(0,t.jsxs)("span",{className:"ml-2 text-[11px] text-muted-foreground font-mono",children:["$",N(e.cost.inputPerMillion),"/$",N(e.cost.outputPerMillion)]}):null,e.maxContextTokens?(0,t.jsxs)("span",{className:"ml-2 text-[11px] text-muted-foreground font-mono",children:[(n=e.maxContextTokens,new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}).format(n))," ",s("list.contextAbbr")]}):null]}),(0,t.jsx)("div",{className:"flex items-center gap-1",children:["vision","reasoning","embedding"].map(n=>e[n]?(0,t.jsx)(o.Badge,{variant:"outline",className:`text-[10px] h-5 px-1.5 ${x[n]}`,children:s(`capability.${n}`)},n):null)}),(0,t.jsx)(i.Button,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:t=>{t.stopPropagation(),a(e.id)},children:(0,t.jsx)(f.Trash2,{className:"size-3 text-destructive"})})]},e.id)})})]},n)),0===d.length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,t.jsx)(c.Brain,{className:"size-10 mb-2 opacity-30"}),(0,t.jsx)("p",{className:"text-sm",children:s("list.empty")})]})]})}function b({draft:e,providerNames:l,onChange:i}){let o=(0,r.useTranslations)("models"),d=(0,n.useRef)(!1),[c,m]=(0,n.useState)(()=>(function(e){if(!e)return h.length;let t=h.findIndex(t=>t.value===e);return t>=0?t:h.length})(e.maxContextTokens)),f=l.length>0?l:["Other"];return(0,t.jsxs)("div",{className:"flex flex-col gap-5 p-5",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.details")}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.modelId")}),(0,t.jsx)(a.Input,{value:e.modelId||"",onChange:e=>{let t=e.target.value;i("modelId",t),d.current||i("name",t)},placeholder:o("form.modelIdPlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.displayName")}),(0,t.jsx)(a.Input,{value:e.name||"",onChange:e=>{d.current=!0,i("name",e.target.value)},placeholder:o("form.displayNamePlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.provider")}),(0,t.jsx)("select",{value:e.provider||"Other",onChange:e=>i("provider",e.target.value),className:"h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring dark:bg-input/30",children:f.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.context")}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.maxContextTokens")}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(s.Slider,{min:0,max:h.length,step:1,value:c,onValueChange:e=>{m(e),e<h.length&&i("maxContextTokens",h[e].value)},className:"flex-1"}),c<h.length?(0,t.jsx)("span",{className:"text-sm tabular-nums min-w-[3.5rem] text-right",children:h[c].label}):(0,t.jsx)(a.Input,{type:"number",min:"1",step:"1",value:e.maxContextTokens??"",onChange:e=>i("maxContextTokens",function(e){if(!e.trim())return;let t=Number(e);return Number.isFinite(t)&&t>0?Math.floor(t):void 0}(e.target.value)),placeholder:o("form.customContextPlaceholder"),className:"h-7 w-24 text-sm tabular-nums"})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.thinking")}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-input px-3 py-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("label",{className:"text-sm font-medium",children:o("form.enableThinking")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:o("form.enableThinkingHelper")})]}),(0,t.jsx)(u.Switch,{checked:e.thinkingEnabled??!0,onCheckedChange:e=>i("thinkingEnabled",e)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.effort")}),(0,t.jsx)("select",{value:e.thinkingEffort||"medium",onChange:e=>i("thinkingEffort",e.target.value),disabled:!(e.thinkingEnabled??!0),className:"h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30",children:v.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.cost")}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.inputPerMillion")}),(0,t.jsx)(a.Input,{type:"number",min:"0",step:"0.0001",value:e.cost?.inputPerMillion??0,onChange:t=>i("cost",{inputPerMillion:y(t.target.value),outputPerMillion:e.cost?.outputPerMillion??0}),placeholder:o("form.costPlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.outputPerMillion")}),(0,t.jsx)(a.Input,{type:"number",min:"0",step:"0.0001",value:e.cost?.outputPerMillion??0,onChange:t=>i("cost",{inputPerMillion:e.cost?.inputPerMillion??0,outputPerMillion:y(t.target.value)}),placeholder:o("form.costPlaceholder")})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.capabilities")}),(0,t.jsx)("div",{className:"flex items-center gap-1.5",children:["vision","reasoning","embedding"].map(n=>{let r=!!e[n];return(0,t.jsx)("button",{type:"button",onClick:()=>i(n,!r),className:`rounded-md border px-2 py-1 text-xs font-medium transition-colors cursor-pointer
2
- ${r?x[n]:"text-muted-foreground border-input hover:bg-muted/50"}`,children:o(`capability.${n}`)},n)})})]})]})}function y(e){let t=Number(e);return Number.isFinite(t)&&t>=0?t:0}function N(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:4}).format(e)}e.s(["ModelsDialog",0,function({open:e,onOpenChange:a,initialProvider:s,standalone:o}){let u=(0,r.useTranslations)("models"),c=(0,r.useTranslations)("common"),{models:f,providers:x,ensure:h,addModel:v,updateModel:y,removeModel:N}=(0,p.useLLMStore)(),j=x.map(e=>e.name),[C,E]=(0,n.useState)(null),[k,w]=(0,n.useState)(null),[S,R]=(0,n.useState)(!1),[I,A]=(0,n.useState)(!1),[P,M]=(0,n.useState)(null),T=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(!e){T.current=!1;return}queueMicrotask(()=>{R(!0),M(null)}),h().finally(()=>R(!1))},[e,h]),(0,n.useEffect)(()=>{e&&s&&!k&&!T.current&&(T.current=!0,queueMicrotask(()=>{E(null),w({modelId:"",name:"",provider:s,cost:{inputPerMillion:0,outputPerMillion:0},maxContextTokens:128e3,thinkingEnabled:!0,thinkingEffort:"medium",vision:!1,reasoning:!1,embedding:!1})}))},[e,s,k]);let D=()=>{E(null),w(null)},O=()=>{E(null),w({modelId:"",name:"",provider:"Other",cost:{inputPerMillion:0,outputPerMillion:0},maxContextTokens:128e3,thinkingEnabled:!0,thinkingEffort:"medium",vision:!1,reasoning:!1,embedding:!1})},F=async()=>{if(k&&k.modelId&&k.name){A(!0),M(null);try{let e=!C,t=await fetch(e?"/api/models":`/api/models/${C.id}`,{method:e?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});if(!t.ok)throw Error();let n=await t.json();e?v(n):y(n),D()}catch{M(u("error.saveFailed"))}finally{A(!1)}}},L=async e=>{if(confirm(u("confirm.delete"))){A(!0);try{if(!(await fetch(`/api/models/${e}`,{method:"DELETE"})).ok)throw Error();N(e),C?.id===e&&D()}catch{M(u("error.deleteFailed"))}finally{A(!1)}}},$=function(e){let t={};for(let n of e){let e=n.provider||"Other";(t[e]??=[]).push(n)}return t}(f),B=(0,t.jsxs)(t.Fragment,{children:[!o&&(0,t.jsxs)("div",{className:"flex items-center gap-3 border-b px-5 py-4",children:[k&&(0,t.jsx)(i.Button,{variant:"ghost",size:"icon-sm",onClick:D,children:(0,t.jsx)(d.ArrowLeft,{className:"size-4"})}),(0,t.jsxs)(l.DialogHeader,{className:"flex-1 space-y-0",children:[(0,t.jsx)(l.DialogTitle,{className:"text-base",children:k?C?u("dialog.editTitle"):u("dialog.addTitle"):u("dialog.title")}),(0,t.jsx)(l.DialogDescription,{className:"text-xs",children:k?u("dialog.editDescription"):u("dialog.listDescription")})]}),!k&&(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",onClick:O,className:"mr-6",children:[(0,t.jsx)(m.Plus,{className:"size-3.5"}),u("dialog.add")]})]}),o&&!k&&(0,t.jsx)("div",{className:"flex items-center justify-end px-5 py-3 border-b",children:(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",onClick:O,children:[(0,t.jsx)(m.Plus,{className:"size-3.5"}),u("dialog.add")]})}),o&&k&&(0,t.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b",children:[(0,t.jsx)(i.Button,{variant:"ghost",size:"icon-sm",onClick:D,children:(0,t.jsx)(d.ArrowLeft,{className:"size-4"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h2",{className:"text-base font-medium truncate",children:C?u("dialog.editTitle"):u("dialog.addTitle")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:u("dialog.editDescription")})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[P&&(0,t.jsx)("div",{className:"mx-5 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:P}),S?(0,t.jsx)("div",{className:"py-12 text-center text-sm text-muted-foreground",children:u("dialog.loading")}):k?(0,t.jsx)(b,{draft:k,providerNames:j,onChange:(e,t)=>{w(n=>n?{...n,[e]:t}:n)}}):(0,t.jsx)(g,{groups:$,providerNames:j,onEdit:e=>{E(e),w({...e,thinkingEnabled:e.thinkingEnabled??!0,thinkingEffort:e.thinkingEffort??"medium"})},onDelete:L})]}),k&&(0,t.jsxs)("div",{className:"flex justify-end gap-2 border-t px-5 py-3",children:[(0,t.jsx)(i.Button,{variant:"outline",size:"sm",onClick:D,disabled:I,children:c("cancel")}),(0,t.jsx)(i.Button,{size:"sm",onClick:F,disabled:I||!k.modelId||!k.name,children:c(I?"saving":"save")})]})]});return o?(0,t.jsx)("div",{className:"h-full flex flex-col",children:B}):(0,t.jsx)(l.Dialog,{open:e,onOpenChange:e=>{e||D(),a(e)},children:(0,t.jsx)(l.DialogContent,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col p-0 gap-0",children:B})})}])}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,607452,e=>{"use strict";var t,n=e.i(344180);e.s([],885864),e.i(885864),e.i(8890);var r=e.i(764556),l=e.i(526850),i=e.i(535270),a=e.i(29905),s=e.i(106045),o=e.i(277642),u=e.i(602453),d=e.i(638144),c=e.i(139236),m=e.i(969490),f=e.i(464111);function p(e,t,n=(e,t)=>e===t){return e.length===t.length&&e.every((e,r)=>n(e,t[r]))}var x=e.i(410421),h=e.i(756432),v=e.i(125231),g=e.i(975698),b=e.i(380414),y=e.i(443124);function N(e,t){return e-t}function j(e,t,n,r,l,i){var a;let s,o=e;return o=(0,f.clamp)(o,n,r),l&&(a=(0,f.clamp)(o,i[t-1]||-1/0,i[t+1]||1/0),(s=i.slice())[t]=a,o=s.sort(N)),o}function C(e,t,n){return!Array.isArray(e)||Math.min(...e.reduce((e,t,n,r)=>(n===r.length-1||e.push(Math.abs(t-r[n+1])),e),[]))>=t*n}let E={activeThumbIndex:()=>null,max:()=>null,min:()=>null,minStepsBetweenValues:()=>null,step:()=>null,values:()=>null,...e.i(438904).fieldValidityMapping};var k=e.i(267805);let w=r.createContext(void 0);function S(){let e=r.useContext(w);if(void 0===e)throw Error((0,k.default)(62));return e}var R=e.i(742665);let I=r.forwardRef(function(e,t){let{"aria-labelledby":k,className:S,defaultValue:I,disabled:A=!1,id:P,format:M,largeStep:T=10,locale:D,render:O,max:F=100,min:L=0,minStepsBetweenValues:$=0,form:B,name:z,onValueChange:V,onValueCommitted:W,orientation:H="horizontal",step:K=1,thumbCollisionBehavior:_="push",thumbAlignment:U="center",value:q,style:G,...Y}=e,X=(0,c.useBaseUiId)(P),J=null==X?void 0:`${X}-label`,Q=(0,a.useStableCallback)(V),Z=(0,a.useStableCallback)(W),{clearErrors:ee}=(0,b.useFormContext)(),{state:et,disabled:en,name:er,setTouched:el,setDirty:ei,validityData:ea,shouldValidateOnChange:es,validation:eo}=(0,v.useFieldRootContext)(),{labelId:eu}=(0,y.useLabelableContext)(),[ed,ec]=r.useState(),em=k??eu??ed,ef=en||A,ep=er??z,[ex,eh]=(0,i.useControlled)({controlled:q,default:I??L,name:"Slider"}),ev=r.useRef(null),eg=r.useRef(null),eb=r.useRef([]),ey=r.useRef(null),eN=r.useRef(null),ej=r.useRef(-1),eC=r.useRef(null),eE=r.useRef(null),ek=r.useRef("none"),ew=(0,s.useValueAsRef)(M),[eS,eR]=r.useState(-1),[eI,eA]=r.useState(-1),[eP,eM]=r.useState(!1),[eT,eD]=r.useState(()=>new Map),[eO,eF]=r.useState([void 0,void 0]),eL=(0,a.useStableCallback)(e=>{eR(e),-1!==e&&eA(e)});(0,g.useRegisterFieldControl)(eg,{id:X,value:ex}),(0,d.useValueChanged)(ex,()=>{ee(ep),es()?eo.commit(ex):eo.commit(ex,!0);let e=ea.initialValue;ei(Array.isArray(ex)&&Array.isArray(e)?!p(ex,e):ex!==e)});let e$=(0,a.useStableCallback)(e=>{e&&(eg.current=e)}),eB=Array.isArray(ex),ez=r.useMemo(()=>eB?ex.slice().sort(N):[(0,f.clamp)(ex,L,F)],[F,L,eB,ex]),eV=(0,a.useStableCallback)((e,t)=>{if(Number.isNaN(e)||("number"==typeof e&&"number"==typeof ex?e===ex:!!(Array.isArray(e)&&Array.isArray(ex))&&p(e,ex)))return;let n=t??(0,u.createChangeEventDetails)(R.REASONS.none,void 0,void 0,{activeThumbIndex:-1});ek.current=n.reason;let r=n.event,l=new(r.constructor??Event)(r.type,r);Object.defineProperty(l,"target",{writable:!0,value:{value:e,name:ep}}),n.event=l,eE.current=e,Q(e,n),n.isCanceled||eh(e)}),eW=(0,a.useStableCallback)((e,t,n)=>{let r=j(e,t,L,F,eB,ez);if(C(r,K,$)){let e="key"in n?R.REASONS.keyboard:R.REASONS.inputChange;eV(r,(0,u.createChangeEventDetails)(e,n.nativeEvent,void 0,{activeThumbIndex:t})),el(!0),Z(eE.current??r,(0,u.createGenericEventDetails)(e,n.nativeEvent))}});(0,o.useIsoLayoutEffect)(()=>{let e=(0,x.activeElement)((0,l.ownerDocument)(ev.current));ef&&(0,x.contains)(ev.current,e)&&e.blur()},[ef]),ef&&-1!==eS&&eL(-1);let eH=r.useMemo(()=>({...et,activeThumbIndex:eS,disabled:ef,dragging:eP,orientation:H,max:F,min:L,minStepsBetweenValues:$,step:K,values:ez}),[et,eS,ef,eP,F,L,$,H,K,ez]),eK=r.useMemo(()=>({active:eS,controlRef:eg,disabled:ef,dragging:eP,validation:eo,formatOptionsRef:ew,handleInputChange:eW,indicatorPosition:eO,inset:"center"!==U,labelId:em,rootLabelId:J,largeStep:T,lastUsedThumbIndex:eI,lastChangedValueRef:eE,lastChangeReasonRef:ek,form:B,locale:D,max:F,min:L,minStepsBetweenValues:$,name:ep,onValueCommitted:Z,orientation:H,pressedInputRef:ey,pressedThumbCenterOffsetRef:eN,pressedThumbIndexRef:ej,pressedValuesRef:eC,registerFieldControlRef:e$,renderBeforeHydration:"edge"===U,setActive:eL,setDragging:eM,setIndicatorPosition:eF,setLabelId:ec,setValue:eV,state:eH,step:K,thumbCollisionBehavior:_,thumbMap:eT,thumbRefs:eb,values:ez}),[eS,eg,em,J,ef,eP,eo,ew,eW,eO,T,eI,eE,ek,B,D,F,L,$,ep,Z,H,ey,eN,ej,eC,e$,eL,eM,eF,ec,eV,eH,K,_,U,eT,eb,ez]),e_=(0,m.useRenderElement)("div",e,{state:eH,ref:[t,ev],props:[{"aria-labelledby":em,id:X,role:"group"},eo.getValidationProps,Y],stateAttributesMapping:E});return(0,n.jsx)(w.Provider,{value:eK,children:(0,n.jsx)(h.CompositeList,{elementsRef:eb,onMapChange:eD,children:e_})})});var A=e.i(92615),P=e.i(213700);let M=r.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;delete a.id;let{state:s,setLabelId:o,controlRef:u,rootLabelId:d}=S(),c=(0,P.useLabel)({id:d,setLabelId:o,focusControl:function(e,t){if(t){let n=(0,l.ownerDocument)(e.currentTarget).getElementById(t);if((0,A.isHTMLElement)(n))return void(0,P.focusElementWithVisible)(n)}let n=u.current?.querySelectorAll('input[type="range"]'),r=n?.length===1?n[0]:null;(0,A.isHTMLElement)(r)&&(0,P.focusElementWithVisible)(r)}});return(0,m.useRenderElement)("div",e,{ref:t,state:s,props:[c,a],stateAttributesMapping:E})});var T=e.i(842809);let D=r.forwardRef(function(e,t){let{"aria-live":n="off",render:l,className:i,children:a,style:s,...o}=e,{thumbMap:u,state:d,values:c,formatOptionsRef:f,locale:p}=S(),x=r.useMemo(()=>{let e="";for(let t of u.values())t?.inputId&&(e+=`${t.inputId} `);return""===e.trim()?void 0:e.trim()},[u]),h=r.useMemo(()=>{let e=[];for(let t=0;t<c.length;t+=1)e.push((0,T.formatNumber)(c[t],p,f.current??void 0));return e},[f,p,c]),v=r.useMemo(()=>{let e=[];for(let t=0;t<c.length;t+=1)e.push(h[t]||c[t]);return e.join(" – ")},[c,h]);return(0,m.useRenderElement)("output",e,{state:d,ref:t,props:[{"aria-live":n,children:"function"==typeof a?a(h,c):v,htmlFor:x},o],stateAttributesMapping:E})});var O=e.i(422561),F=e.i(859092),L=e.i(189131);function $(e){let t=e.getBoundingClientRect();return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}}function B(e){if(0===e)return 0;if(1>Math.abs(e)){let t=e.toExponential().split("e-"),n=t[0].split(".")[1];return(n?n.length:0)+parseInt(t[1],10)}let t=e.toString().split(".")[1];return t?t.length:0}function z(e,t,n){return Number((Math.round((e-n)/t)*t+n).toFixed(Math.max(B(t),B(n))))}function V({values:e,index:t,nextValue:n,min:r,max:l,step:i,minStepsBetweenValues:a,initialValues:s}){if(0===e.length)return[];let o=e.slice(),u=i*a,d=o.length-1,c=s??e;o[t]=(0,f.clamp)(n,r+t*u,l-(d-t)*u);for(let e=t+1;e<=d;e+=1){let t=o[e-1]+u,n=l-(d-e)*u,r=c[e]??o[e],i=Math.max(o[e],t);r<i&&(i=Math.max(r,t)),o[e]=(0,f.clamp)(i,t,n)}for(let e=t-1;e>=0;e-=1){let t=o[e+1]-u,n=r+e*u,l=c[e]??o[e],i=Math.min(o[e],t);l>i&&(i=Math.min(l,t)),o[e]=(0,f.clamp)(i,n,t)}for(let e=0;e<=d;e+=1)o[e]=Number(o[e].toFixed(12));return o}function W(e,t){if(null!=t.current&&e.changedTouches){for(let n=0;n<e.changedTouches.length;n+=1){let r=e.changedTouches[n];if(r.identifier===t.current)return{x:r.clientX,y:r.clientY}}return null}return{x:e.clientX,y:e.clientY}}let H=r.forwardRef(function(e,t){let{render:n,className:i,style:o,...d}=e,{disabled:c,dragging:p,inset:h,lastChangedValueRef:v,lastChangeReasonRef:g,max:b,min:y,minStepsBetweenValues:N,onValueCommitted:j,orientation:k,pressedInputRef:w,pressedThumbCenterOffsetRef:I,pressedThumbIndexRef:P,pressedValuesRef:M,registerFieldControlRef:T,renderBeforeHydration:D,setActive:B,setDragging:H,setValue:K,state:_,step:U,thumbCollisionBehavior:q,thumbRefs:G,values:Y}=S(),X=(0,L.useDirection)(),J=Y.length>1,Q="vertical"===k,Z=r.useRef(null),ee=r.useRef(null),et=(0,a.useStableCallback)(e=>{e&&null==ee.current&&null==ee.current&&(ee.current=getComputedStyle(e))}),en=r.useRef(null),er=r.useRef(0),el=r.useRef(0),ei=(0,s.useValueAsRef)(Y),ea=(0,a.useStableCallback)(e=>{P.current!==e&&(P.current=e);let t=G.current[e];if(!t){I.current=null,w.current=null;return}w.current=t.querySelector('input[type="range"]')}),es=(0,a.useStableCallback)(e=>{let t=Z.current;if(!t)return null;let{width:n,height:r,bottom:l,left:i,right:a}=t.getBoundingClientRect(),s=function(e,t){if(!e)return{start:0,end:0};function n(e){let t=null!=e?parseFloat(e):0;return Number.isNaN(t)?0:t}let r=t?"Top":"InlineStart",l=t?"Bottom":"InlineEnd";return{start:n(e[`border${r}Width`])+n(e[`padding${r}`]),end:n(e[`border${l}Width`])+n(e[`padding${l}`])}}(ee.current,Q),o=el.current,u=(Q?r:n)-s.start-s.end-2*o,d=I.current??0,c=e.x-d,m=e.y-d,p=Q?l-m-s.end:("rtl"===X?a-c:c-i)-s.start,x=(b-y)*(0,f.clamp)((p-o)/u,0,1)+y;if(x=z(x,U,y),x=(0,f.clamp)(x,y,b),!J)return{value:x,thumbIndex:0,didSwap:!1};let h=P.current;if(h<0)return null;let v=function({behavior:e,values:t,currentValues:n,initialValues:r,pressedIndex:l,nextValue:i,min:a,max:s,step:o,minStepsBetweenValues:u}){let d=n??t,c=r??t;if(!(d.length>1))return{value:i,thumbIndex:0,didSwap:!1};let m=o*u;switch(e){case"swap":{let e=d[l],t=d.slice(),n=t[l-1],r=t[l+1],p=null!=n?n+m:a,x=null!=r?r-m:s,h=Number((0,f.clamp)(i,p,x).toFixed(12));t[l]=h;let v=i>e,g=i<e,b=v&&null!=r&&i>=r-1e-7,y=g&&null!=n&&i<=n+1e-7;if(!b&&!y)return{value:t,thumbIndex:l,didSwap:!1};let N=b?l+1:l-1,j=t.map((e,t)=>{if(t===l)return h;let n=c[t];return null!=n?n:d[t]}),C=i;C=b?Math.max(i,t[N]):Math.min(i,t[N]);let E=V({values:t,index:N,nextValue:C,min:a,max:s,step:o,minStepsBetweenValues:u,initialValues:j}),k=b?N-1:N+1;if(k>=0&&k<E.length){let e=E[k-1],t=E[k+1],n=null!=e?e+m:a;n=Math.max(n,a+k*m);let r=null!=t?t-m:s;r=Math.min(r,s-(E.length-1-k)*m);let l=(0,f.clamp)(h,n,r);E[k]=Number(l.toFixed(12))}return{value:E,thumbIndex:N,didSwap:!0}}case"push":return{value:V({values:d,index:l,nextValue:i,min:a,max:s,step:o,minStepsBetweenValues:u}),thumbIndex:l,didSwap:!1};default:{let e=d.slice(),t=e[l-1],n=e[l+1],r=null!=t?t+m:a,o=null!=n?n-m:s,u=(0,f.clamp)(i,r,o);return e[l]=Number(u.toFixed(12)),{value:e,thumbIndex:l,didSwap:!1}}}}({behavior:q,values:Y,currentValues:ei.current??Y,initialValues:M.current,pressedIndex:h,nextValue:x,min:y,max:b,step:U,minStepsBetweenValues:N});return"swap"===q&&v.didSwap?ea(v.thumbIndex):P.current=v.thumbIndex,v}),eo=(0,a.useStableCallback)(e=>{M.current=J?Y.slice():null,ei.current=Y;let t=P.current,n=t;if(t>-1&&t<Y.length){if(Y[t]===b){let e=t;for(;e>0&&Y[e-1]===b;)e-=1;n=e}}else{let t,r=Q?"y":"x";n=-1;for(let l=0;l<G.current.length;l+=1){let i=G.current[l];if((0,A.isElement)(i)){let a=$(i),s=Math.abs(e[r]-a[r]);(void 0===t||s<=t)&&(n=l,t=s)}}}if(n>-1&&n!==t&&ea(n),h){let e=G.current[n];(0,A.isElement)(e)&&(el.current=e.getBoundingClientRect()[Q?"height":"width"]/2)}}),eu=(0,a.useStableCallback)(e=>{let t=G.current?.[e]?.querySelector('input[type="range"]');t&&t.focus({preventScroll:!0,focusVisible:!1})}),ed=(0,a.useStableCallback)(e=>{let t=W(e,en);if(null==t)return;if(er.current+=1,"pointermove"===e.type&&0===e.buttons)return void ec(e);let n=es(t);null!=n&&C(n.value,U,N)&&(!p&&er.current>2&&H(!0),K(n.value,(0,u.createChangeEventDetails)(R.REASONS.drag,e,void 0,{activeThumbIndex:n.thumbIndex})),ei.current=Array.isArray(n.value)?n.value:[n.value],n.didSwap&&eu(n.thumbIndex))});function ec(e){B(-1),H(!1),w.current=null,I.current=null;let t=W(e,en),n=null!=t?es(t):null;if(null!=n){let t=g.current;j(v.current??n.value,(0,u.createGenericEventDetails)(t,e))}"pointerType"in e&&Z.current?.hasPointerCapture(e.pointerId)&&Z.current?.releasePointerCapture(e.pointerId),P.current=-1,en.current=null,M.current=null,ef()}let em=(0,a.useStableCallback)(e=>{if(c)return;let t=e.changedTouches[0];null!=t&&(en.current=t.identifier);let n=W(e,en);if(null!=n){eo(n);let t=es(n);if(null==t)return;eu(t.thumbIndex),K(t.value,(0,u.createChangeEventDetails)(R.REASONS.trackPress,e,void 0,{activeThumbIndex:t.thumbIndex})),ei.current=Array.isArray(t.value)?t.value:[t.value],t.didSwap&&eu(t.thumbIndex)}er.current=0;let r=(0,l.ownerDocument)(Z.current);r.addEventListener("touchmove",ed,{passive:!0}),r.addEventListener("touchend",ec,{passive:!0})}),ef=(0,a.useStableCallback)(()=>{let e=(0,l.ownerDocument)(Z.current);e.removeEventListener("pointermove",ed),e.removeEventListener("pointerup",ec),e.removeEventListener("touchmove",ed),e.removeEventListener("touchend",ec),M.current=null}),ep=(0,F.useAnimationFrame)();return r.useEffect(()=>{let e=Z.current;if(!e)return()=>ef();let t=(0,O.addEventListener)(e,"touchstart",em,{passive:!0});return()=>{t(),ep.cancel(),ef()}},[ef,em,Z,ep]),r.useEffect(()=>{c&&ef()},[c,ef]),(0,m.useRenderElement)("div",e,{state:_,ref:[t,T,Z,et],props:[{"data-base-ui-slider-control":D?"":void 0,onPointerDown(e){let t=Z.current,n=(0,x.getTarget)(e.nativeEvent);if(!t||c||e.defaultPrevented||!(0,A.isElement)(n)||0!==e.button)return;let r=W(e,en);if(null!=r){eo(r);let n=es(r);if(null==n)return;(0,x.contains)(G.current[n.thumbIndex],(0,x.activeElement)((0,l.ownerDocument)(t)))?e.preventDefault():ep.request(()=>{eu(n.thumbIndex)}),H(!0),null==I.current&&(K(n.value,(0,u.createChangeEventDetails)(R.REASONS.trackPress,e.nativeEvent,void 0,{activeThumbIndex:n.thumbIndex})),ei.current=Array.isArray(n.value)?n.value:[n.value],n.didSwap&&eu(n.thumbIndex))}e.nativeEvent.pointerId&&t.setPointerCapture(e.nativeEvent.pointerId),er.current=0;let i=(0,l.ownerDocument)(Z.current);i.addEventListener("pointermove",ed,{passive:!0}),i.addEventListener("pointerup",ec,{once:!0})}},d],stateAttributesMapping:E})}),K=r.forwardRef(function(e,t){let{render:n,className:r,style:l,...i}=e,{state:a}=S();return(0,m.useRenderElement)("div",e,{state:a,ref:t,props:[{style:{position:"relative"}},i],stateAttributesMapping:E})});var _=e.i(204133),U=e.i(236706),q=e.i(370383),G=e.i(517432),Y=e.i(203922),X=e.i(100229),J=e.i(296615),Q=e.i(394394),Z=e.i(922970),ee=e.i(575665);let et=((t={}).index="data-index",t.dragging="data-dragging",t.orientation="data-orientation",t.disabled="data-disabled",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.focused="data-focused",t),en=new Set([X.ARROW_UP,X.ARROW_DOWN,X.ARROW_LEFT,X.ARROW_RIGHT,X.HOME,X.END,X.PAGE_UP,X.PAGE_DOWN]);function er(e,t,n,r,l){let i=Number((1===n?e+t:e-t).toFixed(Math.max(B(e),B(t),B(r))));return(0,f.clamp)(i,r,l)}let el=r.forwardRef(function(e,t){let l,{render:i,children:s,className:u,"aria-describedby":d,"aria-label":f,"aria-labelledby":p,disabled:x=!1,getAriaLabel:h,getAriaValueText:g,id:b,index:y,inputRef:N,onBlur:C,onFocus:k,onKeyDown:w,tabIndex:R,style:I,...A}=e,{nonce:P}=(0,Q.useCSPContext)(),M=(0,c.useBaseUiId)(b),{active:D,lastUsedThumbIndex:O,controlRef:F,disabled:B,validation:V,formatOptionsRef:W,handleInputChange:H,inset:K,labelId:el,largeStep:ei,locale:ea,max:es,min:eo,minStepsBetweenValues:eu,form:ed,name:ec,orientation:em,pressedInputRef:ef,pressedThumbCenterOffsetRef:ep,pressedThumbIndexRef:ex,renderBeforeHydration:eh,setActive:ev,setIndicatorPosition:eg,state:eb,step:ey,values:eN}=S(),ej=(0,L.useDirection)(),eC=eN.length>1,eE="vertical"===em,ek="rtl"===ej,{setTouched:ew,setFocused:eS,validationMode:eR}=(0,v.useFieldRootContext)(),eI=r.useRef(null),eA=r.useRef(null),eP=r.useRef(!1),eM=(0,c.useBaseUiId)(),eT=(0,ee.useLabelableId)(),eD=eC?eM:eT,eO=r.useMemo(()=>({inputId:eD}),[eD]),{ref:eF,index:eL}=(0,J.useCompositeListItem)({metadata:eO}),e$=eC?y??eL:0,eB=e$===eN.length-1,ez=eN[e$],eV=(0,Y.valueToPercent)(ez,eo,es),[eW,eH]=r.useState(),eK=(0,G.useIsHydrating)(),e_=O>=0&&O<eN.length?O:-1,eU=(0,a.useStableCallback)(()=>{let e=F.current,t=eI.current;if(!e||!t)return;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),l=eE?"height":"width",i=r[l]-n[l],a=(n[l]/2+i*eV/100)/r[l]*100,s=Number.isFinite(a)?a:void 0;eH(s),0===e$?eg(e=>[s,e[1]]):eB&&eg(e=>[e[0],s])});(0,o.useIsoLayoutEffect)(()=>{K&&queueMicrotask(eU)},[eU,K]),(0,o.useIsoLayoutEffect)(()=>{K&&eU()},[eU,K,eV]),(0,o.useIsoLayoutEffect)(()=>{if(!K||"function"!=typeof ResizeObserver)return;let e=F.current,t=eI.current;if(!e||!t)return;let n=new ResizeObserver(eU);return n.observe(e),n.observe(t),()=>{n.disconnect()}},[F,eU,K]);let eq=r.useCallback(()=>{let e,t=eE?"bottom":"insetInlineStart",n=eE?"left":"top";return(eC?D===e$?e=2:e_===e$&&(e=1):D===e$&&(e=1),K)?{"--position":`${eW??0}%`,visibility:eh&&eK||void 0===eW?"hidden":void 0,position:"absolute",[t]:"var(--position)",[n]:"50%",translate:`${(eE||!ek?-1:1)*50}% ${(eE?1:-1)*50}%`,zIndex:e}:Number.isFinite(eV)?{position:"absolute",[t]:`${eV}%`,[n]:"50%",translate:`${(eE||!ek?-1:1)*50}% ${(eE?1:-1)*50}%`,zIndex:e}:U.visuallyHidden},[D,e$,K,eK,eW,eC,eh,ek,e_,eV,eE]);"vertical"===em&&(l=ek?"vertical-rl":"vertical-lr");let eG="function"==typeof h?h(e$):f,eY=(0,q.mergeProps)({"aria-label":eG,"aria-labelledby":p??(null==eG?el:void 0),"aria-describedby":d,"aria-orientation":em,"aria-valuenow":ez,"aria-valuetext":"function"==typeof g?g((0,T.formatNumber)(ez,ea,W.current??void 0),ez,e$):function(e,t,n,r){if(!(t<0))return 2===e.length?0===t?`${(0,T.formatNumber)(e[t],r,n)} start range`:`${(0,T.formatNumber)(e[t],r,n)} end range`:n?(0,T.formatNumber)(e[t],r,n):void 0}(eN,e$,W.current??void 0,ea),disabled:x||B,form:ed,id:eD,max:es,min:eo,name:ec,onChange(e){H(e.currentTarget.valueAsNumber,e$,e)},onFocus(e){let t=eP.current;eP.current=!1,ev(e$),eS(!0),t&&e.stopPropagation()},onBlur(e){eP.current?e.stopPropagation():eI.current&&(ev(-1),ew(!0),eS(!1),"onBlur"===eR&&V.commit(j(ez,e$,eo,es,eC,eN)))},onKeyDown(e){if(!en.has(e.key))return;X.COMPOSITE_KEYS.has(e.key)&&e.stopPropagation();let t=null,n=z(ez,ey,eo);switch(e.key){case X.ARROW_UP:t=er(n,e.shiftKey?ei:ey,1,eo,es);break;case X.ARROW_RIGHT:t=er(n,e.shiftKey?ei:ey,ek?-1:1,eo,es);break;case X.ARROW_DOWN:t=er(n,e.shiftKey?ei:ey,-1,eo,es);break;case X.ARROW_LEFT:t=er(n,e.shiftKey?ei:ey,ek?1:-1,eo,es);break;case X.PAGE_UP:t=er(n,ei,1,eo,es);break;case X.PAGE_DOWN:t=er(n,ei,-1,eo,es);break;case X.END:t=es,eC&&(t=Number.isFinite(eN[e$+1])?eN[e$+1]-ey*eu:es);break;case X.HOME:t=eo,eC&&(t=Number.isFinite(eN[e$-1])?eN[e$-1]+ey*eu:eo)}if(null!==t){let n=e.currentTarget;(0,Z.matchesFocusVisible)(n)||(eP.current=!0,n.blur(),n.focus({preventScroll:!0,focusVisible:!0})),H(t,e$,e),e.preventDefault()}},step:ey,style:{...U.visuallyHidden,width:"100%",height:"100%",writingMode:l},tabIndex:R??void 0,type:"range",value:ez??""},V.getInputValidationProps),eX=(0,_.useMergedRefs)(eA,V.inputRef,N);return(0,m.useRenderElement)("div",e,{state:eb,ref:[t,eF,eI],props:[{[et.index]:e$,children:(0,n.jsxs)(r.Fragment,{children:[s,(0,n.jsx)("input",{ref:eX,...eY,suppressHydrationWarning:!0}),K&&eK&&eh&&eB&&(0,n.jsx)("script",{nonce:P,dangerouslySetInnerHTML:{__html:'!function(){const t=document.currentScript?.parentElement;if(!t)return;const e=t.closest("[data-base-ui-slider-control]");if(!e)return;const r=e.querySelector("[data-base-ui-slider-indicator]"),i=e.getBoundingClientRect(),n="vertical"===e.getAttribute("data-orientation")?"height":"width",o=e.querySelectorAll(\'input[type="range"]\'),l=o.length>1,s=o.length-1;let a=null,u=null;for(let t=0;t<o.length;t+=1){const e=o[t],y=parseFloat(e.getAttribute("value")??"");if(Number.isNaN(y))return;const c=e.parentElement;if(!c)return;const p=parseFloat(e.getAttribute("max")??"100"),g=parseFloat(e.getAttribute("min")??"0"),b=c?.getBoundingClientRect(),d=i[n]-b[n],m=100*(y-g)/(p-g),v=(b[n]/2+d*m/100)/i[n]*100;c.style.setProperty("--position",`${v}%`),Number.isFinite(v)&&(c.style.removeProperty("visibility"),r&&(0===t?(a=v,r.style.setProperty("--start-position",`${v}%`),l||r.style.removeProperty("visibility")):t===s&&(u=v-(a??0),r.style.setProperty("--end-position",`${v}%`),r.style.setProperty("--relative-size",`${u}%`),r.style.removeProperty("visibility"))))}}();'},suppressHydrationWarning:!0})]}),id:M,onBlur:C,onFocus:k,onPointerDown(e){if(ex.current=e$,null!=eI.current){let t="horizontal"===em?"x":"y",n=$(eI.current);ep.current=("horizontal"===em?e.clientX:e.clientY)-n[t]}null!=eA.current&&ef.current!==eA.current&&(ef.current=eA.current)},style:eq(),suppressHydrationWarning:eh||void 0},A],stateAttributesMapping:E})}),ei=r.forwardRef(function(e,t){var n,r;let l,i,a,s,{render:o,className:u,style:d,...c}=e,{indicatorPosition:f,inset:p,max:x,min:h,orientation:v,renderBeforeHydration:g,state:b,values:y}=S(),N=(0,G.useIsHydrating)(),j="vertical"===v,C=y.length>1,k=p?(n=f[0],r=f[1],l=void 0===n||C&&void 0===r?"hidden":void 0,i=j?"bottom":"insetInlineStart",a=j?"height":"width",((s={visibility:g&&N?"hidden":l,position:j?"absolute":"relative",[j?"width":"height"]:"inherit"})["--start-position"]=`${n??0}%`,C)?(s["--relative-size"]=`${(r??0)-(n??0)}%`,s[i]="var(--start-position)",s[a]="var(--relative-size)"):(s[i]=0,s[a]="var(--start-position)"),s):function(e,t,n,r){let l=e?"bottom":"insetInlineStart",i=e?"height":"width",a={position:e?"absolute":"relative",[e?"width":"height"]:"inherit"};if(!t)return a[l]=0,a[i]=`${n}%`,a;let s=r-n;return a[l]=`${n}%`,a[i]=`${s}%`,a}(j,C,(0,Y.valueToPercent)(y[0],h,x),(0,Y.valueToPercent)(y[y.length-1],h,x));return(0,m.useRenderElement)("div",e,{state:b,ref:t,props:[{"data-base-ui-slider-indicator":g?"":void 0,style:k,suppressHydrationWarning:g||void 0},c],stateAttributesMapping:E})});e.s(["Control",0,H,"Indicator",0,ei,"Label",0,M,"Root",0,I,"Thumb",0,el,"Track",0,K,"Value",0,D],414857);var ea=e.i(414857),ea=ea,es=e.i(465458);e.s(["Slider",0,function({className:e,defaultValue:t,value:r,min:l=0,max:i=100,...a}){let s=Array.isArray(r)?r:void 0!==r?[r]:Array.isArray(t)?t:[l,i];return(0,n.jsx)(ea.Root,{className:(0,es.cn)("data-horizontal:w-full data-vertical:h-full",e),"data-slot":"slider",defaultValue:t,value:r,min:l,max:i,thumbAlignment:"edge",...a,children:(0,n.jsxs)(ea.Control,{className:"relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col",children:[(0,n.jsx)(ea.Track,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted select-none data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1",children:(0,n.jsx)(ea.Indicator,{"data-slot":"slider-range",className:"bg-primary select-none data-horizontal:h-full data-vertical:w-full"})}),Array.from({length:s.length},(e,t)=>(0,n.jsx)(ea.Thumb,{"data-slot":"slider-thumb",className:"relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50"},t))]})})}],607452)},86477,e=>{"use strict";var t=e.i(344180),n=e.i(764556),r=e.i(244073),l=e.i(209988),i=e.i(260218),a=e.i(681622),s=e.i(607452),o=e.i(562918),u=e.i(226624),d=e.i(767467),c=e.i(990336),m=e.i(953700),f=e.i(137340),p=e.i(368942);let x={vision:"bg-blue-500/10 text-blue-600 border-blue-200",reasoning:"bg-purple-500/10 text-purple-600 border-purple-200",embedding:"bg-green-500/10 text-green-600 border-green-200"},h=[{label:"8K",value:8192},{label:"16K",value:16384},{label:"32K",value:32768},{label:"64K",value:65536},{label:"128K",value:128e3},{label:"200K",value:2e5},{label:"256K",value:256e3},{label:"1M",value:1e6}],v=["low","medium","high"];function g({groups:e,providerNames:n,onEdit:l,onDelete:a}){let s=(0,r.useTranslations)("models"),u=n.length>0?n:["Other"],d=Object.keys(e).sort((e,t)=>{let n=u.indexOf(e),r=u.indexOf(t);return n>=0&&r>=0?n-r:n>=0?-1:r>=0?1:e.localeCompare(t)});return(0,t.jsxs)("div",{className:"flex flex-col p-4 gap-4",children:[d.map(n=>(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2 px-1",children:n}),(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:e[n].map(e=>{var n;return(0,t.jsxs)("div",{className:"group flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>l(e),children:[(0,t.jsx)(c.Brain,{className:"size-4 text-muted-foreground shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground font-mono ml-2",children:e.modelId}),e.cost?(0,t.jsxs)("span",{className:"ml-2 text-[11px] text-muted-foreground font-mono",children:["$",N(e.cost.inputPerMillion),"/$",N(e.cost.outputPerMillion)]}):null,e.maxContextTokens?(0,t.jsxs)("span",{className:"ml-2 text-[11px] text-muted-foreground font-mono",children:[(n=e.maxContextTokens,new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}).format(n))," ",s("list.contextAbbr")]}):null]}),(0,t.jsx)("div",{className:"flex items-center gap-1",children:["vision","reasoning","embedding"].map(n=>e[n]?(0,t.jsx)(o.Badge,{variant:"outline",className:`text-[10px] h-5 px-1.5 ${x[n]}`,children:s(`capability.${n}`)},n):null)}),(0,t.jsx)(i.Button,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:t=>{t.stopPropagation(),a(e.id)},children:(0,t.jsx)(f.Trash2,{className:"size-3 text-destructive"})})]},e.id)})})]},n)),0===d.length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,t.jsx)(c.Brain,{className:"size-10 mb-2 opacity-30"}),(0,t.jsx)("p",{className:"text-sm",children:s("list.empty")})]})]})}function b({draft:e,providerNames:l,onChange:i}){let o=(0,r.useTranslations)("models"),d=(0,n.useRef)(!1),[c,m]=(0,n.useState)(()=>(function(e){if(!e)return h.length;let t=h.findIndex(t=>t.value===e);return t>=0?t:h.length})(e.maxContextTokens)),f=l.length>0?[...l,"Other"]:["Other"];return(0,t.jsxs)("div",{className:"flex flex-col gap-5 p-5",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.details")}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.modelId")}),(0,t.jsx)(a.Input,{value:e.modelId||"",onChange:e=>{let t=e.target.value;i("modelId",t),d.current||i("name",t)},placeholder:o("form.modelIdPlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.displayName")}),(0,t.jsx)(a.Input,{value:e.name||"",onChange:e=>{d.current=!0,i("name",e.target.value)},placeholder:o("form.displayNamePlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.provider")}),(0,t.jsx)("select",{value:e.provider||"Other",onChange:e=>i("provider",e.target.value),className:"h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring dark:bg-input/30",children:f.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.context")}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.maxContextTokens")}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(s.Slider,{min:0,max:h.length,step:1,value:c,onValueChange:e=>{m(e),e<h.length&&i("maxContextTokens",h[e].value)},className:"flex-1"}),c<h.length?(0,t.jsx)("span",{className:"text-sm tabular-nums min-w-[3.5rem] text-right",children:h[c].label}):(0,t.jsx)(a.Input,{type:"number",min:"1",step:"1",value:e.maxContextTokens??"",onChange:e=>i("maxContextTokens",function(e){if(!e.trim())return;let t=Number(e);return Number.isFinite(t)&&t>0?Math.floor(t):void 0}(e.target.value)),placeholder:o("form.customContextPlaceholder"),className:"h-7 w-24 text-sm tabular-nums"})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.thinking")}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-input px-3 py-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("label",{className:"text-sm font-medium",children:o("form.enableThinking")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:o("form.enableThinkingHelper")})]}),(0,t.jsx)(u.Switch,{checked:e.thinkingEnabled??!0,onCheckedChange:e=>i("thinkingEnabled",e)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.effort")}),(0,t.jsx)("select",{value:e.thinkingEffort||"medium",onChange:e=>i("thinkingEffort",e.target.value),disabled:!(e.thinkingEnabled??!0),className:"h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30",children:v.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.cost")}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.inputPerMillion")}),(0,t.jsx)(a.Input,{type:"number",min:"0",step:"0.0001",value:e.cost?.inputPerMillion??0,onChange:t=>i("cost",{inputPerMillion:y(t.target.value),outputPerMillion:e.cost?.outputPerMillion??0}),placeholder:o("form.costPlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:o("form.outputPerMillion")}),(0,t.jsx)(a.Input,{type:"number",min:"0",step:"0.0001",value:e.cost?.outputPerMillion??0,onChange:t=>i("cost",{inputPerMillion:e.cost?.inputPerMillion??0,outputPerMillion:y(t.target.value)}),placeholder:o("form.costPlaceholder")})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("form.capabilities")}),(0,t.jsx)("div",{className:"flex items-center gap-1.5",children:["vision","reasoning","embedding"].map(n=>{let r=!!e[n];return(0,t.jsx)("button",{type:"button",onClick:()=>i(n,!r),className:`rounded-md border px-2 py-1 text-xs font-medium transition-colors cursor-pointer
2
+ ${r?x[n]:"text-muted-foreground border-input hover:bg-muted/50"}`,children:o(`capability.${n}`)},n)})})]})]})}function y(e){let t=Number(e);return Number.isFinite(t)&&t>=0?t:0}function N(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:4}).format(e)}e.s(["ModelsDialog",0,function({open:e,onOpenChange:a,initialProvider:s,standalone:o}){let u=(0,r.useTranslations)("models"),c=(0,r.useTranslations)("common"),{models:f,providers:x,ensure:h,addModel:v,updateModel:y,removeModel:N}=(0,p.useLLMStore)(),j=x.map(e=>e.name),[C,E]=(0,n.useState)(null),[k,w]=(0,n.useState)(null),[S,R]=(0,n.useState)(!1),[I,A]=(0,n.useState)(!1),[P,M]=(0,n.useState)(null),T=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(!e){T.current=!1;return}queueMicrotask(()=>{R(!0),M(null)}),h().finally(()=>R(!1))},[e,h]),(0,n.useEffect)(()=>{e&&s&&!k&&!T.current&&(T.current=!0,queueMicrotask(()=>{E(null),w({modelId:"",name:"",provider:s,cost:{inputPerMillion:0,outputPerMillion:0},maxContextTokens:128e3,thinkingEnabled:!0,thinkingEffort:"medium",vision:!1,reasoning:!1,embedding:!1})}))},[e,s,k]);let D=()=>{E(null),w(null)},O=()=>{E(null),w({modelId:"",name:"",provider:j.length>0?j[0]:"Other",cost:{inputPerMillion:0,outputPerMillion:0},maxContextTokens:128e3,thinkingEnabled:!0,thinkingEffort:"medium",vision:!1,reasoning:!1,embedding:!1})},F=async()=>{if(k&&k.modelId&&k.name){A(!0),M(null);try{let e=!C,t=await fetch(e?"/api/models":`/api/models/${C.id}`,{method:e?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});if(!t.ok)throw Error();let n=await t.json();e?v(n):y(n),D()}catch{M(u("error.saveFailed"))}finally{A(!1)}}},L=async e=>{if(confirm(u("confirm.delete"))){A(!0);try{if(!(await fetch(`/api/models/${e}`,{method:"DELETE"})).ok)throw Error();N(e),C?.id===e&&D()}catch{M(u("error.deleteFailed"))}finally{A(!1)}}},$=function(e){let t={};for(let n of e){let e=n.provider||"Other";(t[e]??=[]).push(n)}return t}(f),B=(0,t.jsxs)(t.Fragment,{children:[!o&&(0,t.jsxs)("div",{className:"flex items-center gap-3 border-b px-5 py-4",children:[k&&(0,t.jsx)(i.Button,{variant:"ghost",size:"icon-sm",onClick:D,children:(0,t.jsx)(d.ArrowLeft,{className:"size-4"})}),(0,t.jsxs)(l.DialogHeader,{className:"flex-1 space-y-0",children:[(0,t.jsx)(l.DialogTitle,{className:"text-base",children:k?C?u("dialog.editTitle"):u("dialog.addTitle"):u("dialog.title")}),(0,t.jsx)(l.DialogDescription,{className:"text-xs",children:k?u("dialog.editDescription"):u("dialog.listDescription")})]}),!k&&(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",onClick:O,className:"mr-6",children:[(0,t.jsx)(m.Plus,{className:"size-3.5"}),u("dialog.add")]})]}),o&&!k&&(0,t.jsx)("div",{className:"flex items-center justify-end px-5 py-3 border-b",children:(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",onClick:O,children:[(0,t.jsx)(m.Plus,{className:"size-3.5"}),u("dialog.add")]})}),o&&k&&(0,t.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b",children:[(0,t.jsx)(i.Button,{variant:"ghost",size:"icon-sm",onClick:D,children:(0,t.jsx)(d.ArrowLeft,{className:"size-4"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h2",{className:"text-base font-medium truncate",children:C?u("dialog.editTitle"):u("dialog.addTitle")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:u("dialog.editDescription")})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[P&&(0,t.jsx)("div",{className:"mx-5 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:P}),S?(0,t.jsx)("div",{className:"py-12 text-center text-sm text-muted-foreground",children:u("dialog.loading")}):k?(0,t.jsx)(b,{draft:k,providerNames:j,onChange:(e,t)=>{w(n=>n?{...n,[e]:t}:n)}}):(0,t.jsx)(g,{groups:$,providerNames:j,onEdit:e=>{E(e),w({...e,thinkingEnabled:e.thinkingEnabled??!0,thinkingEffort:e.thinkingEffort??"medium"})},onDelete:L})]}),k&&(0,t.jsxs)("div",{className:"flex justify-end gap-2 border-t px-5 py-3",children:[(0,t.jsx)(i.Button,{variant:"outline",size:"sm",onClick:D,disabled:I,children:c("cancel")}),(0,t.jsx)(i.Button,{size:"sm",onClick:F,disabled:I||!k.modelId||!k.name,children:c(I?"saving":"save")})]})]});return o?(0,t.jsx)("div",{className:"h-full flex flex-col",children:B}):(0,t.jsx)(l.Dialog,{open:e,onOpenChange:e=>{e||D(),a(e)},children:(0,t.jsx)(l.DialogContent,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col p-0 gap-0",children:B})})}])}]);