@agent-spaces/server 0.3.65 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/dist/adapters/agent-runtime.js +8 -0
  2. package/dist/adapters/codex-function-tool-bridge.js +152 -0
  3. package/dist/adapters/codex-runtime.js +23 -4
  4. package/dist/adapters/git.js +25 -3
  5. package/dist/adapters/hermes-runtime.js +813 -0
  6. package/dist/adapters/langchain-runtime.js +384 -21
  7. package/dist/adapters/oh-my-pi-runtime.js +858 -0
  8. package/dist/adapters/open-agent-sdk-runtime.js +202 -5
  9. package/dist/adapters/open-agent-sdk-runtime.test.js +35 -0
  10. package/dist/agents/agent-message-parts.js +52 -2
  11. package/dist/agents/issue-task-controller.js +71 -2
  12. package/dist/agents/pull-request-agent.js +115 -0
  13. package/dist/agents/scheduler-agent.js +1 -1
  14. package/dist/agents/title-generator-agent.js +120 -0
  15. package/dist/app.js +61 -4
  16. package/dist/middleware/auth.js +1 -1
  17. package/dist/package.json +2 -1
  18. package/dist/routes/agent-sse.js +70 -6
  19. package/dist/routes/channel.js +23 -2
  20. package/dist/routes/chat-run.js +191 -0
  21. package/dist/routes/chat.js +142 -0
  22. package/dist/routes/command.js +16 -0
  23. package/dist/routes/data.js +189 -0
  24. package/dist/routes/git.js +10 -1
  25. package/dist/routes/import.js +199 -0
  26. package/dist/routes/issue.js +17 -5
  27. package/dist/routes/notification.js +10 -0
  28. package/dist/routes/plugin.js +69 -0
  29. package/dist/routes/version.js +95 -0
  30. package/dist/routes/workflow-hook.js +71 -0
  31. package/dist/routes/workflow.js +282 -7
  32. package/dist/routes/workspace.js +13 -4
  33. package/dist/routes/worktree.js +93 -0
  34. package/dist/services/agent.js +123 -36
  35. package/dist/services/ai-text.js +185 -0
  36. package/dist/services/builtin-tools/index.js +1 -0
  37. package/dist/services/builtin-tools/workflow-editor-tools.js +509 -0
  38. package/dist/services/builtin-tools/workflow-exec-tools.js +320 -0
  39. package/dist/services/chat.js +134 -0
  40. package/dist/services/command-process-manager.js +16 -0
  41. package/dist/services/execution-manager.js +1346 -0
  42. package/dist/services/generated-title.js +59 -0
  43. package/dist/services/gitignore.js +22 -18
  44. package/dist/services/interaction-manager.js +114 -0
  45. package/dist/services/issue-retry.js +25 -0
  46. package/dist/services/notification-center.js +9 -0
  47. package/dist/services/output-style.js +8 -1
  48. package/dist/services/plugin.js +257 -0
  49. package/dist/services/prompt-template.js +8 -1
  50. package/dist/services/pty.js +20 -0
  51. package/dist/services/search.js +16 -6
  52. package/dist/services/skill.js +2 -0
  53. package/dist/services/version.js +69 -0
  54. package/dist/services/workflow-command-runner.js +24 -0
  55. package/dist/services/workflow-trigger-service.js +137 -0
  56. package/dist/services/workflow.js +219 -39
  57. package/dist/services/workspace.js +23 -1
  58. package/dist/services/worktree.js +207 -0
  59. package/dist/storage/agent-store.js +8 -0
  60. package/dist/storage/chat-store.js +151 -0
  61. package/dist/storage/database-store.js +6 -0
  62. package/dist/storage/json-store.js +2 -1
  63. package/dist/storage/kanban-store.js +6 -0
  64. package/dist/storage/workflow-store.js +386 -22
  65. package/dist/storage/worktree-store.js +33 -0
  66. package/dist/web/404.html +1 -1
  67. package/dist/web/__next.__PAGE__.txt +4 -4
  68. package/dist/web/__next._full.txt +21 -21
  69. package/dist/web/__next._head.txt +4 -4
  70. package/dist/web/__next._index.txt +13 -13
  71. package/dist/web/__next._tree.txt +2 -2
  72. package/dist/web/_next/static/chunks/{08x85faoz58i7.js → 0-92u-tiuy40a.js} +4 -4
  73. package/dist/web/_next/static/chunks/{0db14450oqzhg.js → 0-yizd8osmas2.js} +1 -1
  74. package/dist/web/_next/static/chunks/0.ln~3mnv8.69.js +1 -0
  75. package/dist/web/_next/static/chunks/{11cchuwoupmbf.js → 01y3e9pemva7b.js} +10 -10
  76. package/dist/web/_next/static/chunks/02l~tmzrgny.~.js +1 -0
  77. package/dist/web/_next/static/chunks/03f1bwuynjdmk.js +1 -0
  78. package/dist/web/_next/static/chunks/04cb4kc9r2pd1.js +1 -0
  79. package/dist/web/_next/static/chunks/04de6ha5_e3pp.js +1 -0
  80. package/dist/web/_next/static/chunks/09he0p79ov1rn.js +1 -0
  81. package/dist/web/_next/static/chunks/09vpocs4zuc8h.js +1 -0
  82. package/dist/web/_next/static/chunks/0_o2exgr0e_nh.js +1 -0
  83. package/dist/web/_next/static/chunks/{0xbaakj0dfc0..js → 0_y9nskc-xt2k.js} +1 -1
  84. package/dist/web/_next/static/chunks/0clnj-1fi6u8j.js +3 -0
  85. package/dist/web/_next/static/chunks/0gv40by0zzxs_.js +1 -0
  86. package/dist/web/_next/static/chunks/0iusr8y88.kjg.js +1 -0
  87. package/dist/web/_next/static/chunks/{0-a.-hl3wv99k.js → 0j-8418fxvkd1.js} +1 -1
  88. package/dist/web/_next/static/chunks/0j.wxxyoclma5.js +1 -0
  89. package/dist/web/_next/static/chunks/{0.6b64sy0g5.3.js → 0jq.16sozqik..js} +1 -1
  90. package/dist/web/_next/static/chunks/0jw8xdk_fpnp0.css +1 -0
  91. package/dist/web/_next/static/chunks/0l1lkd-wcotma.js +1 -0
  92. package/dist/web/_next/static/chunks/{0u6h-hqc_i52e.js → 0ncxf_zr4n839.js} +1 -1
  93. package/dist/web/_next/static/chunks/0ndo7um~v7vco.js +1 -0
  94. package/dist/web/_next/static/chunks/0ngk.~kan8wq_.js +1 -0
  95. package/dist/web/_next/static/chunks/0ppr271hz0xoq.js +1 -0
  96. package/dist/web/_next/static/chunks/0rt9bofnn6qvn.js +1 -0
  97. package/dist/web/_next/static/chunks/0t64.9jd00hio.js +3 -0
  98. package/dist/web/_next/static/chunks/0taui9--5n6-5.js +1 -0
  99. package/dist/web/_next/static/chunks/0ty39169lh~z3.js +1 -0
  100. package/dist/web/_next/static/chunks/0v8nof~waedlu.js +1 -0
  101. package/dist/web/_next/static/chunks/{0-pi.67w.ymsr.js → 0vcfoagnpf.aw.js} +1 -1
  102. package/dist/web/_next/static/chunks/{0vis~lx0nxgn-.js → 0wwwq.gyyz0vg.js} +3 -3
  103. package/dist/web/_next/static/chunks/0x5lak8yz7pm7.js +1 -0
  104. package/dist/web/_next/static/chunks/0xon_.4-o0_zq.js +7 -0
  105. package/dist/web/_next/static/chunks/0zjnrbt7inime.js +1 -0
  106. package/dist/web/_next/static/chunks/0zwebpitvpuv1.js +1 -0
  107. package/dist/web/_next/static/chunks/0~02o4g-o6n~m.js +1 -0
  108. package/dist/web/_next/static/chunks/{0w7.tb29958zj.js → 0~fjezp.k4qk3.js} +1 -1
  109. package/dist/web/_next/static/chunks/0~sh93re1-_rp.js +1 -0
  110. package/dist/web/_next/static/chunks/10_niiq0k6o-p.js +5 -0
  111. package/dist/web/_next/static/chunks/12tjr0_2ccrtq.js +2 -0
  112. package/dist/web/_next/static/chunks/12x5.go_x9mfk.js +1 -0
  113. package/dist/web/_next/static/chunks/{0l2w0qz1ea7ql.js → 12~5dk9i9d16t.js} +2 -2
  114. package/dist/web/_next/static/chunks/13iye4rv5p31b.js +1 -0
  115. package/dist/web/_next/static/chunks/{01~quun6sefgl.js → 13~y-b.b9rrw4.js} +1 -1
  116. package/dist/web/_next/static/chunks/151wzhb5q0lo5.js +1 -0
  117. package/dist/web/_not-found/__next._full.txt +19 -19
  118. package/dist/web/_not-found/__next._head.txt +4 -4
  119. package/dist/web/_not-found/__next._index.txt +13 -13
  120. package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
  121. package/dist/web/_not-found/__next._not-found.txt +3 -3
  122. package/dist/web/_not-found/__next._tree.txt +2 -2
  123. package/dist/web/_not-found.html +1 -1
  124. package/dist/web/_not-found.txt +19 -19
  125. package/dist/web/index.html +1 -1
  126. package/dist/web/index.txt +21 -21
  127. package/dist/web/login/__next._full.txt +21 -21
  128. package/dist/web/login/__next._head.txt +4 -4
  129. package/dist/web/login/__next._index.txt +13 -13
  130. package/dist/web/login/__next._tree.txt +2 -2
  131. package/dist/web/login/__next.login.__PAGE__.txt +4 -4
  132. package/dist/web/login/__next.login.txt +3 -3
  133. package/dist/web/login.html +1 -1
  134. package/dist/web/login.txt +21 -21
  135. package/dist/web/settings/__next._full.txt +23 -23
  136. package/dist/web/settings/__next._head.txt +4 -4
  137. package/dist/web/settings/__next._index.txt +13 -13
  138. package/dist/web/settings/__next._tree.txt +2 -2
  139. package/dist/web/settings/__next.settings.__PAGE__.txt +4 -4
  140. package/dist/web/settings/__next.settings.txt +5 -5
  141. package/dist/web/settings/agents/__next._full.txt +23 -23
  142. package/dist/web/settings/agents/__next._head.txt +4 -4
  143. package/dist/web/settings/agents/__next._index.txt +13 -13
  144. package/dist/web/settings/agents/__next._tree.txt +2 -2
  145. package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +4 -4
  146. package/dist/web/settings/agents/__next.settings.agents.txt +3 -3
  147. package/dist/web/settings/agents/__next.settings.txt +5 -5
  148. package/dist/web/settings/agents.html +1 -1
  149. package/dist/web/settings/agents.txt +23 -23
  150. package/dist/web/settings/mcps/__next._full.txt +23 -23
  151. package/dist/web/settings/mcps/__next._head.txt +4 -4
  152. package/dist/web/settings/mcps/__next._index.txt +13 -13
  153. package/dist/web/settings/mcps/__next._tree.txt +2 -2
  154. package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +4 -4
  155. package/dist/web/settings/mcps/__next.settings.mcps.txt +3 -3
  156. package/dist/web/settings/mcps/__next.settings.txt +5 -5
  157. package/dist/web/settings/mcps.html +1 -1
  158. package/dist/web/settings/mcps.txt +23 -23
  159. package/dist/web/settings/models/__next._full.txt +23 -23
  160. package/dist/web/settings/models/__next._head.txt +4 -4
  161. package/dist/web/settings/models/__next._index.txt +13 -13
  162. package/dist/web/settings/models/__next._tree.txt +2 -2
  163. package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +4 -4
  164. package/dist/web/settings/models/__next.settings.models.txt +3 -3
  165. package/dist/web/settings/models/__next.settings.txt +5 -5
  166. package/dist/web/settings/models.html +1 -1
  167. package/dist/web/settings/models.txt +23 -23
  168. package/dist/web/settings/output-styles/__next._full.txt +23 -23
  169. package/dist/web/settings/output-styles/__next._head.txt +4 -4
  170. package/dist/web/settings/output-styles/__next._index.txt +13 -13
  171. package/dist/web/settings/output-styles/__next._tree.txt +2 -2
  172. package/dist/web/settings/output-styles/__next.settings.output-styles.__PAGE__.txt +4 -4
  173. package/dist/web/settings/output-styles/__next.settings.output-styles.txt +3 -3
  174. package/dist/web/settings/output-styles/__next.settings.txt +5 -5
  175. package/dist/web/settings/output-styles.html +1 -1
  176. package/dist/web/settings/output-styles.txt +23 -23
  177. package/dist/web/settings/prompts/__next._full.txt +23 -23
  178. package/dist/web/settings/prompts/__next._head.txt +4 -4
  179. package/dist/web/settings/prompts/__next._index.txt +13 -13
  180. package/dist/web/settings/prompts/__next._tree.txt +2 -2
  181. package/dist/web/settings/prompts/__next.settings.prompts.__PAGE__.txt +4 -4
  182. package/dist/web/settings/prompts/__next.settings.prompts.txt +3 -3
  183. package/dist/web/settings/prompts/__next.settings.txt +5 -5
  184. package/dist/web/settings/prompts.html +1 -1
  185. package/dist/web/settings/prompts.txt +23 -23
  186. package/dist/web/settings/providers/__next._full.txt +23 -23
  187. package/dist/web/settings/providers/__next._head.txt +4 -4
  188. package/dist/web/settings/providers/__next._index.txt +13 -13
  189. package/dist/web/settings/providers/__next._tree.txt +2 -2
  190. package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +4 -4
  191. package/dist/web/settings/providers/__next.settings.providers.txt +3 -3
  192. package/dist/web/settings/providers/__next.settings.txt +5 -5
  193. package/dist/web/settings/providers.html +1 -1
  194. package/dist/web/settings/providers.txt +23 -23
  195. package/dist/web/settings/skills/__next._full.txt +23 -23
  196. package/dist/web/settings/skills/__next._head.txt +4 -4
  197. package/dist/web/settings/skills/__next._index.txt +13 -13
  198. package/dist/web/settings/skills/__next._tree.txt +2 -2
  199. package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +4 -4
  200. package/dist/web/settings/skills/__next.settings.skills.txt +3 -3
  201. package/dist/web/settings/skills/__next.settings.txt +5 -5
  202. package/dist/web/settings/skills.html +1 -1
  203. package/dist/web/settings/skills.txt +23 -23
  204. package/dist/web/settings/tools/__next._full.txt +23 -23
  205. package/dist/web/settings/tools/__next._head.txt +4 -4
  206. package/dist/web/settings/tools/__next._index.txt +13 -13
  207. package/dist/web/settings/tools/__next._tree.txt +2 -2
  208. package/dist/web/settings/tools/__next.settings.tools.__PAGE__.txt +4 -4
  209. package/dist/web/settings/tools/__next.settings.tools.txt +3 -3
  210. package/dist/web/settings/tools/__next.settings.txt +5 -5
  211. package/dist/web/settings/tools.html +1 -1
  212. package/dist/web/settings/tools.txt +23 -23
  213. package/dist/web/settings.html +1 -1
  214. package/dist/web/settings.txt +23 -23
  215. package/dist/web/workflows/__next._full.txt +22 -22
  216. package/dist/web/workflows/__next._head.txt +4 -4
  217. package/dist/web/workflows/__next._index.txt +13 -13
  218. package/dist/web/workflows/__next._tree.txt +2 -2
  219. package/dist/web/workflows/__next.workflows.__PAGE__.txt +4 -4
  220. package/dist/web/workflows/__next.workflows.txt +3 -3
  221. package/dist/web/workflows.html +1 -1
  222. package/dist/web/workflows.txt +22 -22
  223. package/dist/web/workspace/_/__next._full.txt +20 -20
  224. package/dist/web/workspace/_/__next._head.txt +4 -4
  225. package/dist/web/workspace/_/__next._index.txt +13 -13
  226. package/dist/web/workspace/_/__next._tree.txt +2 -2
  227. package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +3 -3
  228. package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
  229. package/dist/web/workspace/_/__next.workspace.txt +3 -3
  230. package/dist/web/workspace/_.html +1 -1
  231. package/dist/web/workspace/_.txt +20 -20
  232. package/dist/web/workspaces/__next._full.txt +21 -21
  233. package/dist/web/workspaces/__next._head.txt +4 -4
  234. package/dist/web/workspaces/__next._index.txt +13 -13
  235. package/dist/web/workspaces/__next._tree.txt +2 -2
  236. package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
  237. package/dist/web/workspaces/__next.workspaces.txt +3 -3
  238. package/dist/web/workspaces.html +1 -1
  239. package/dist/web/workspaces.txt +21 -21
  240. package/dist/ws/agent-prompt.js +36 -3
  241. package/dist/ws/agent-runner.js +30 -18
  242. package/dist/ws/chat-handler.js +89 -0
  243. package/dist/ws/connection-manager.js +49 -2
  244. package/dist/ws/execution-channels.js +88 -0
  245. package/dist/ws/handler.js +32 -5
  246. package/dist/ws/message-parts.js +130 -12
  247. package/dist/ws/terminal-handler.js +26 -0
  248. package/package.json +13 -1
  249. package/public/avatars/user.jpg +0 -0
  250. package/dist/web/_next/static/chunks/0-v_p6j5u3_9l.js +0 -1
  251. package/dist/web/_next/static/chunks/0.-x29t-8gk0r.js +0 -1
  252. package/dist/web/_next/static/chunks/0.l5e8~r7_0~p.js +0 -1
  253. package/dist/web/_next/static/chunks/0.n~yfwf4~6w-.js +0 -1
  254. package/dist/web/_next/static/chunks/00-syqzi-6zxr.js +0 -1
  255. package/dist/web/_next/static/chunks/02j4sr9psucf-.js +0 -1
  256. package/dist/web/_next/static/chunks/06si8l0doqe8p.js +0 -1
  257. package/dist/web/_next/static/chunks/08kfx8on9oty~.js +0 -1
  258. package/dist/web/_next/static/chunks/08ugbvzr20drp.js +0 -2
  259. package/dist/web/_next/static/chunks/0_cqojbge48kq.js +0 -5
  260. package/dist/web/_next/static/chunks/0d6~~lv0-6kex.js +0 -3
  261. package/dist/web/_next/static/chunks/0gdwop9cnpmtu.js +0 -1
  262. package/dist/web/_next/static/chunks/0ghx3j_.-gdyd.js +0 -1
  263. package/dist/web/_next/static/chunks/0kbvoxla7f751.js +0 -1
  264. package/dist/web/_next/static/chunks/0paaat8y96ayc.js +0 -7
  265. package/dist/web/_next/static/chunks/0pq318f8xgafg.js +0 -1
  266. package/dist/web/_next/static/chunks/0t6s8of0qr6nc.js +0 -1
  267. package/dist/web/_next/static/chunks/0xt-8wk21gs7g.js +0 -1
  268. package/dist/web/_next/static/chunks/0yd.m1afqg.2t.js +0 -3
  269. package/dist/web/_next/static/chunks/0yhbr8hl09b-5.js +0 -1
  270. package/dist/web/_next/static/chunks/0z~vqzbm_q371.js +0 -1
  271. package/dist/web/_next/static/chunks/0~~_ltu6dx_ch.js +0 -1
  272. package/dist/web/_next/static/chunks/12oxcgyhpaxw~.js +0 -1
  273. package/dist/web/_next/static/chunks/1452eibz62gs6.css +0 -1
  274. package/dist/web/_next/static/chunks/16zlreiems5cn.js +0 -1
  275. package/dist/web/_next/static/chunks/18awqjk9-o5m0.js +0 -1
  276. /package/dist/web/_next/static/{x4-CsKe6qUQyFDWVtfvUg → rGXyAK8rgod1NjF3bLZAY}/_buildManifest.js +0 -0
  277. /package/dist/web/_next/static/{x4-CsKe6qUQyFDWVtfvUg → rGXyAK8rgod1NjF3bLZAY}/_clientMiddlewareManifest.js +0 -0
  278. /package/dist/web/_next/static/{x4-CsKe6qUQyFDWVtfvUg → rGXyAK8rgod1NjF3bLZAY}/_ssgManifest.js +0 -0
@@ -0,0 +1,3 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,843982,(e,t,i)=>{"use strict";function l({widthInt:e,heightInt:t,blurWidth:i,blurHeight:r,blurDataURL:s,objectFit:n}){let o=i?40*i:e,a=r?40*r:t,d=o&&a?`viewBox='0 0 ${o} ${a}'`:"";return`%3Csvg xmlns='http://www.w3.org/2000/svg' ${d}%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='${d?"none":"contain"===n?"xMidYMid":"cover"===n?"xMidYMid slice":"none"}' style='filter: url(%23b);' href='${s}'/%3E%3C/svg%3E`}Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"getImageBlurSvg",{enumerable:!0,get:function(){return l}})},500680,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var l={VALID_LOADERS:function(){return s},imageConfigDefault:function(){return n}};for(var r in l)Object.defineProperty(i,r,{enumerable:!0,get:l[r]});let s=["default","imgix","cloudinary","akamai","custom"],n={deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],path:"/_next/image",loader:"default",loaderFile:"",domains:[],disableStaticImages:!1,minimumCacheTTL:14400,formats:["image/webp"],maximumDiskCacheSize:void 0,maximumRedirects:3,maximumResponseBody:5e7,dangerouslyAllowLocalIP:!1,dangerouslyAllowSVG:!1,contentSecurityPolicy:"script-src 'none'; frame-src 'none'; sandbox;",contentDispositionType:"attachment",localPatterns:void 0,remotePatterns:[],qualities:[75],unoptimized:!1,customCacheHandler:!1}},622398,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"getImgProps",{enumerable:!0,get:function(){return d}}),e.r(837121);let l=e.r(745137),r=e.r(843982),s=e.r(500680),n=["-moz-initial","fill","none","scale-down",void 0];function o(e){return void 0!==e.default}function a(e){return void 0===e?e:"number"==typeof e?Number.isFinite(e)?e:NaN:"string"==typeof e&&/^[0-9]+$/.test(e)?parseInt(e,10):NaN}function d({src:e,sizes:t,unoptimized:i=!1,priority:c=!1,preload:p=!1,loading:f,className:u,quality:_,width:m,height:g,fill:y=!1,style:h,overrideSrc:x,onLoad:j,onLoadingComplete:v,placeholder:b="empty",blurDataURL:C,fetchPriority:w,decoding:k="async",layout:N,objectFit:P,objectPosition:S,lazyBoundary:I,lazyRoot:O,...D},z){var T;let M,E,F,{imgConf:R,showAltText:$,blurComplete:L,defaultLoader:A}=z,U=R||s.imageConfigDefault;if("allSizes"in U)M=U;else{let e=[...U.deviceSizes,...U.imageSizes].sort((e,t)=>e-t),t=U.deviceSizes.sort((e,t)=>e-t),i=U.qualities?.sort((e,t)=>e-t);M={...U,allSizes:e,deviceSizes:t,qualities:i}}if(void 0===A)throw Object.defineProperty(Error("images.loaderFile detected but the file is missing default export.\nRead more: https://nextjs.org/docs/messages/invalid-images-config"),"__NEXT_ERROR_CODE",{value:"E163",enumerable:!1,configurable:!0});let B=D.loader||A;delete D.loader,delete D.srcSet;let q="__next_img_default"in B;if(q){if("custom"===M.loader)throw Object.defineProperty(Error(`Image with src "${e}" is missing "loader" prop.
2
+ Read more: https://nextjs.org/docs/messages/next-image-missing-loader`),"__NEXT_ERROR_CODE",{value:"E252",enumerable:!1,configurable:!0})}else{let e=B;B=t=>{let{config:i,...l}=t;return e(l)}}if(N){"fill"===N&&(y=!0);let e={intrinsic:{maxWidth:"100%",height:"auto"},responsive:{width:"100%",height:"auto"}}[N];e&&(h={...h,...e});let i={responsive:"100vw",fill:"100vw"}[N];i&&!t&&(t=i)}let W="",H=a(m),G=a(g);if((T=e)&&"object"==typeof T&&(o(T)||void 0!==T.src)){let t=o(e)?e.default:e;if(!t.src)throw Object.defineProperty(Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include src. Received ${JSON.stringify(t)}`),"__NEXT_ERROR_CODE",{value:"E460",enumerable:!1,configurable:!0});if(!t.height||!t.width)throw Object.defineProperty(Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include height and width. Received ${JSON.stringify(t)}`),"__NEXT_ERROR_CODE",{value:"E48",enumerable:!1,configurable:!0});if(E=t.blurWidth,F=t.blurHeight,C=C||t.blurDataURL,W=t.src,!y)if(H||G){if(H&&!G){let e=H/t.width;G=Math.round(t.height*e)}else if(!H&&G){let e=G/t.height;H=Math.round(t.width*e)}}else H=t.width,G=t.height}let V=!c&&!p&&("lazy"===f||void 0===f);(!(e="string"==typeof e?e:W)||e.startsWith("data:")||e.startsWith("blob:"))&&(i=!0,V=!1),M.unoptimized&&(i=!0),q&&!M.dangerouslyAllowSVG&&e.split("?",1)[0].endsWith(".svg")&&(i=!0);let J=a(_),K=Object.assign(y?{position:"absolute",height:"100%",width:"100%",left:0,top:0,right:0,bottom:0,objectFit:P,objectPosition:S}:{},$?{}:{color:"transparent"},h),X=L||"empty"===b?null:"blur"===b?`url("data:image/svg+xml;charset=utf-8,${(0,r.getImageBlurSvg)({widthInt:H,heightInt:G,blurWidth:E,blurHeight:F,blurDataURL:C||"",objectFit:K.objectFit})}")`:`url("${b}")`,Q=n.includes(K.objectFit)?"fill"===K.objectFit?"100% 100%":"cover":K.objectFit,Y=X?{backgroundSize:Q,backgroundPosition:K.objectPosition||"50% 50%",backgroundRepeat:"no-repeat",backgroundImage:X}:{},Z=function({config:e,src:t,unoptimized:i,width:r,quality:s,sizes:n,loader:o}){if(i){if(t.startsWith("/")&&!t.startsWith("//")){let e=(0,l.getDeploymentId)();if(e){let i=t.indexOf("?");if(-1!==i){let l=new URLSearchParams(t.slice(i+1));l.get("dpl")||(l.append("dpl",e),t=t.slice(0,i)+"?"+l.toString())}else t+=`?dpl=${e}`}}return{src:t,srcSet:void 0,sizes:void 0}}let{widths:a,kind:d}=function({deviceSizes:e,allSizes:t},i,l){if(l){let i=/(^|\s)(1?\d?\d)vw/g,r=[];for(let e;e=i.exec(l);)r.push(parseInt(e[2]));if(r.length){let i=.01*Math.min(...r);return{widths:t.filter(t=>t>=e[0]*i),kind:"w"}}return{widths:t,kind:"w"}}return"number"!=typeof i?{widths:e,kind:"w"}:{widths:[...new Set([i,2*i].map(e=>t.find(t=>t>=e)||t[t.length-1]))],kind:"x"}}(e,r,n),c=a.length-1;return{sizes:n||"w"!==d?n:"100vw",srcSet:a.map((i,l)=>`${o({config:e,src:t,quality:s,width:i})} ${"w"===d?i:l+1}${d}`).join(", "),src:o({config:e,src:t,quality:s,width:a[c]})}}({config:M,src:e,unoptimized:i,width:H,quality:J,sizes:t,loader:B}),ee=V?"lazy":f;return{props:{...D,loading:ee,fetchPriority:w,width:H,height:G,decoding:k,className:u,style:{...K,...Y},sizes:Z.sizes,srcSet:Z.srcSet,src:x||Z.src},meta:{unoptimized:i,preload:p||c,placeholder:b,fill:y}}}},852824,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"default",{enumerable:!0,get:function(){return o}});let l=e.r(764556),r="u"<typeof window,s=r?()=>{}:l.useLayoutEffect,n=r?()=>{}:l.useEffect;function o(e){let{headManager:t,reduceComponentsToState:i}=e;function o(){if(t&&t.mountedInstances){let e=l.Children.toArray(Array.from(t.mountedInstances).filter(Boolean));t.updateHead(i(e))}}return r&&(t?.mountedInstances?.add(e.children),o()),s(()=>(t?.mountedInstances?.add(e.children),()=>{t?.mountedInstances?.delete(e.children)})),s(()=>(t&&(t._pendingUpdate=o),()=>{t&&(t._pendingUpdate=o)})),n(()=>(t&&t._pendingUpdate&&(t._pendingUpdate(),t._pendingUpdate=null),()=>{t&&t._pendingUpdate&&(t._pendingUpdate(),t._pendingUpdate=null)})),null}},120333,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var l={default:function(){return m},defaultHead:function(){return p}};for(var r in l)Object.defineProperty(i,r,{enumerable:!0,get:l[r]});let s=e.r(481258),n=e.r(744066),o=e.r(344180),a=n._(e.r(764556)),d=s._(e.r(852824)),c=e.r(57426);function p(){return[(0,o.jsx)("meta",{charSet:"utf-8"},"charset"),(0,o.jsx)("meta",{name:"viewport",content:"width=device-width"},"viewport")]}function f(e,t){return"string"==typeof t||"number"==typeof t?e:t.type===a.default.Fragment?e.concat(a.default.Children.toArray(t.props.children).reduce((e,t)=>"string"==typeof t||"number"==typeof t?e:e.concat(t),[])):e.concat(t)}e.r(837121);let u=["name","httpEquiv","charSet","itemProp"];function _(e){let t,i,l,r;return e.reduce(f,[]).reverse().concat(p().reverse()).filter((t=new Set,i=new Set,l=new Set,r={},e=>{let s=!0,n=!1;if(e.key&&"number"!=typeof e.key&&e.key.indexOf("$")>0){n=!0;let i=e.key.slice(e.key.indexOf("$")+1);t.has(i)?s=!1:t.add(i)}switch(e.type){case"title":case"base":i.has(e.type)?s=!1:i.add(e.type);break;case"meta":for(let t=0,i=u.length;t<i;t++){let i=u[t];if(e.props.hasOwnProperty(i))if("charSet"===i)l.has(i)?s=!1:l.add(i);else{let t=e.props[i],l=r[i]||new Set;("name"!==i||!n)&&l.has(t)?s=!1:(l.add(t),r[i]=l)}}}return s})).reverse().map((e,t)=>{let i=e.key||t;return a.default.cloneElement(e,{key:i})})}let m=function({children:e}){let t=(0,a.useContext)(c.HeadManagerContext);return(0,o.jsx)(d.default,{reduceComponentsToState:_,headManager:t,children:e})};("function"==typeof i.default||"object"==typeof i.default&&null!==i.default)&&void 0===i.default.__esModule&&(Object.defineProperty(i.default,"__esModule",{value:!0}),Object.assign(i.default,i),t.exports=i.default)},914272,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"ImageConfigContext",{enumerable:!0,get:function(){return s}});let l=e.r(481258)._(e.r(764556)),r=e.r(500680),s=l.default.createContext(r.imageConfigDefault)},338431,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"RouterContext",{enumerable:!0,get:function(){return l}});let l=e.r(481258)._(e.r(764556)).default.createContext(null)},741186,(e,t,i)=>{"use strict";function l(e,t){let i=e||75;return t?.qualities?.length?t.qualities.reduce((e,t)=>Math.abs(t-i)<Math.abs(e-i)?t:e,t.qualities[0]):i}Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"findClosestQuality",{enumerable:!0,get:function(){return l}})},99552,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"default",{enumerable:!0,get:function(){return n}});let l=e.r(741186),r=e.r(745137);function s({config:e,src:t,width:i,quality:n}){let o=(0,r.getDeploymentId)();if(t.startsWith("/")&&!t.startsWith("//")){let e=t.indexOf("?");if(-1!==e){let i=new URLSearchParams(t.slice(e+1)),l=i.get("dpl");if(l){o=l,i.delete("dpl");let r=i.toString();t=t.slice(0,e)+(r?"?"+r:"")}}}if(t.startsWith("/")&&t.includes("?")&&e.localPatterns?.length===1&&"**"===e.localPatterns[0].pathname&&""===e.localPatterns[0].search)throw Object.defineProperty(Error(`Image with src "${t}" is using a query string which is not configured in images.localPatterns.
3
+ Read more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns`),"__NEXT_ERROR_CODE",{value:"E871",enumerable:!1,configurable:!0});let a=(0,l.findClosestQuality)(n,e);return`${e.path}?url=${encodeURIComponent(t)}&w=${i}&q=${a}${t.startsWith("/")&&o?`&dpl=${o}`:""}`}s.__next_img_default=!0;let n=s},822862,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"useMergedRef",{enumerable:!0,get:function(){return r}});let l=e.r(764556);function r(e,t){let i=(0,l.useRef)(null),r=(0,l.useRef)(null);return(0,l.useCallback)(l=>{if(null===l){let e=i.current;e&&(i.current=null,e());let t=r.current;t&&(r.current=null,t())}else e&&(i.current=s(e,l)),t&&(r.current=s(t,l))},[e,t])}function s(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let i=e(t);return"function"==typeof i?i:()=>e(null)}}("function"==typeof i.default||"object"==typeof i.default&&null!==i.default)&&void 0===i.default.__esModule&&(Object.defineProperty(i.default,"__esModule",{value:!0}),Object.assign(i.default,i),t.exports=i.default)},810034,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"Image",{enumerable:!0,get:function(){return j}});let l=e.r(481258),r=e.r(744066),s=e.r(344180),n=r._(e.r(764556)),o=l._(e.r(106206)),a=l._(e.r(120333)),d=e.r(622398),c=e.r(500680),p=e.r(914272);e.r(837121);let f=e.r(338431),u=l._(e.r(99552)),_=e.r(822862),m={deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],qualities:[75],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!1};function g(e,t,i,l,r,s,n){let o=e?.src;e&&e["data-loaded-src"]!==o&&(e["data-loaded-src"]=o,("decode"in e?e.decode():Promise.resolve()).catch(()=>{}).then(()=>{if(e.parentElement&&e.isConnected){if("empty"!==t&&r(!0),i?.current){let t=new Event("load");Object.defineProperty(t,"target",{writable:!1,value:e});let l=!1,r=!1;i.current({...t,nativeEvent:t,currentTarget:e,target:e,isDefaultPrevented:()=>l,isPropagationStopped:()=>r,persist:()=>{},preventDefault:()=>{l=!0,t.preventDefault()},stopPropagation:()=>{r=!0,t.stopPropagation()}})}l?.current&&l.current(e)}}))}function y(e){return n.use?{fetchPriority:e}:{fetchpriority:e}}"u"<typeof window&&(globalThis.__NEXT_IMAGE_IMPORTED=!0);let h=(0,n.forwardRef)(({src:e,srcSet:t,sizes:i,height:l,width:r,decoding:o,className:a,style:d,fetchPriority:c,placeholder:p,loading:f,unoptimized:u,fill:m,onLoadRef:h,onLoadingCompleteRef:x,setBlurComplete:j,setShowAltText:v,sizesInput:b,onLoad:C,onError:w,...k},N)=>{let P=(0,n.useCallback)(e=>{e&&(w&&(e.src=e.src),e.complete&&g(e,p,h,x,j,u,b))},[e,p,h,x,j,w,u,b]),S=(0,_.useMergedRef)(N,P);return(0,s.jsx)("img",{...k,...y(c),loading:f,width:r,height:l,decoding:o,"data-nimg":m?"fill":"1",className:a,style:d,sizes:i,srcSet:t,src:e,ref:S,onLoad:e=>{g(e.currentTarget,p,h,x,j,u,b)},onError:e=>{v(!0),"empty"!==p&&j(!0),w&&w(e)}})});function x({isAppRouter:e,imgAttributes:t}){let i={as:"image",imageSrcSet:t.srcSet,imageSizes:t.sizes,crossOrigin:t.crossOrigin,referrerPolicy:t.referrerPolicy,...y(t.fetchPriority)};return e&&o.default.preload?(o.default.preload(t.src,i),null):(0,s.jsx)(a.default,{children:(0,s.jsx)("link",{rel:"preload",href:t.srcSet?void 0:t.src,...i},"__nimg-"+t.src+t.srcSet+t.sizes)})}let j=(0,n.forwardRef)((e,t)=>{let i=(0,n.useContext)(f.RouterContext),l=(0,n.useContext)(p.ImageConfigContext),r=(0,n.useMemo)(()=>{let e=m||l||c.imageConfigDefault,t=[...e.deviceSizes,...e.imageSizes].sort((e,t)=>e-t),i=e.deviceSizes.sort((e,t)=>e-t),r=e.qualities?.sort((e,t)=>e-t);return{...e,allSizes:t,deviceSizes:i,qualities:r,localPatterns:"u"<typeof window?l?.localPatterns:e.localPatterns}},[l]),{onLoad:o,onLoadingComplete:a}=e,_=(0,n.useRef)(o);(0,n.useEffect)(()=>{_.current=o},[o]);let g=(0,n.useRef)(a);(0,n.useEffect)(()=>{g.current=a},[a]);let[y,j]=(0,n.useState)(!1),[v,b]=(0,n.useState)(!1),{props:C,meta:w}=(0,d.getImgProps)(e,{defaultLoader:u.default,imgConf:r,blurComplete:y,showAltText:v});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(h,{...C,unoptimized:w.unoptimized,placeholder:w.placeholder,fill:w.fill,onLoadRef:_,onLoadingCompleteRef:g,setBlurComplete:j,setShowAltText:b,sizesInput:e.sizes,ref:t}),w.preload?(0,s.jsx)(x,{isAppRouter:!i,imgAttributes:C}):null]})});("function"==typeof i.default||"object"==typeof i.default&&null!==i.default)&&void 0===i.default.__esModule&&(Object.defineProperty(i.default,"__esModule",{value:!0}),Object.assign(i.default,i),t.exports=i.default)},776785,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var l={default:function(){return c},getImageProps:function(){return d}};for(var r in l)Object.defineProperty(i,r,{enumerable:!0,get:l[r]});let s=e.r(481258),n=e.r(622398),o=e.r(810034),a=s._(e.r(99552));function d(e){let{props:t}=(0,n.getImgProps)(e,{defaultLoader:a.default,imgConf:{deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],qualities:[75],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!1}});for(let[e,i]of Object.entries(t))void 0===i&&delete t[e];return{props:t}}let c=o.Image},253937,(e,t,i)=>{t.exports=e.r(776785)},359209,e=>{"use strict";var t=e.i(344180),i=e.i(253937);let l={".ts":"file_type_typescript",".tsx":"file_type_reactts",".js":"file_type_js",".jsx":"file_type_reactjs",".mjs":"file_type_js",".cjs":"file_type_js",".json":"file_type_json",".json5":"file_type_json5",".jsonc":"file_type_json",".md":"file_type_markdown",".mdx":"file_type_mdx",".css":"file_type_css",".scss":"file_type_scss",".less":"file_type_less",".html":"file_type_html",".svg":"file_type_svg",".png":"file_type_image",".jpg":"file_type_image",".jpeg":"file_type_image",".gif":"file_type_image",".webp":"file_type_webp",".ico":"file_type_favicon",".yaml":"file_type_yaml",".yml":"file_type_yaml",".toml":"file_type_toml",".xml":"file_type_xml",".graphql":"file_type_graphql",".gql":"file_type_graphql",".prisma":"file_type_prisma",".sql":"file_type_sql",".sh":"file_type_shell",".bash":"file_type_shell",".zsh":"file_type_shell",".py":"file_type_python",".rb":"file_type_ruby",".go":"file_type_go",".rs":"file_type_rust",".java":"file_type_java",".kt":"file_type_kotlin",".swift":"file_type_swift",".c":"file_type_c",".cpp":"file_type_cpp",".h":"file_type_cheader",".hpp":"file_type_cppheader",".cs":"file_type_csharp",".php":"file_type_php",".vue":"file_type_vue",".svelte":"file_type_svelte",".dart":"file_type_dartlang",".lua":"file_type_lua",".r":"file_type_r",".ex":"file_type_elixir",".exs":"file_type_elixir",".erl":"file_type_erlang",".hs":"file_type_haskell",".scala":"file_type_scala",".clj":"file_type_clojure",".cljs":"file_type_clojurescript",".coffee":"file_type_coffeescript",".dockerfile":"file_type_docker",".makefile":"file_type_makefile",".txt":"file_type_text",".log":"file_type_log",".env":"file_type_config",".gitignore":"file_type_git",".editorconfig":"file_type_editorconfig",".prettierrc":"file_type_prettier",".eslintrc":"file_type_eslint",".lock":"file_type_lock",".wasm":"file_type_wasm",".pdf":"file_type_pdf",".mp4":"file_type_video",".webm":"file_type_video",".mov":"file_type_video",".avi":"file_type_video",".mkv":"file_type_video",".flv":"file_type_video",".mp3":"file_type_audio",".wav":"file_type_audio",".ogg":"file_type_audio",".flac":"file_type_audio",".aac":"file_type_audio",".m4a":"file_type_audio",".wma":"file_type_audio",".zip":"file_type_zip",".tar":"file_type_zip",".gz":"file_type_zip"},r={"tsconfig.json":"file_type_tsconfig","tsconfig.build.json":"file_type_tsconfig","jsconfig.json":"file_type_jsconfig","package.json":"file_type_npm","package-lock.json":"file_type_npm","pnpm-lock.yaml":"file_type_pnpm","pnpm-workspace.yaml":"file_type_pnpm",".pnpmfile.cjs":"file_type_pnpm","yarn.lock":"file_type_yarn",".yarnrc":"file_type_yarn","next.config.ts":"file_type_next","next.config.js":"file_type_next","next.config.mjs":"file_type_next","vite.config.ts":"file_type_vite","vite.config.js":"file_type_vite","tailwind.config.ts":"file_type_tailwind","tailwind.config.js":"file_type_tailwind","postcss.config.mjs":"file_type_postcss","postcss.config.js":"file_type_postcss",".eslintrc":"file_type_eslint",".eslintrc.js":"file_type_eslint",".eslintrc.json":"file_type_eslint",".eslintrc.cjs":"file_type_eslint",".prettierrc":"file_type_prettier",".prettierrc.js":"file_type_prettier",".prettierrc.json":"file_type_prettier",".gitignore":"file_type_git",".gitattributes":"file_type_git",".editorconfig":"file_type_editorconfig",dockerfile:"file_type_docker","docker-compose.yml":"file_type_docker","docker-compose.yaml":"file_type_docker",makefile:"file_type_makefile","readme.md":"file_type_markdown",license:"file_type_license","license.md":"file_type_license",".env":"file_type_config",".env.local":"file_type_config",".env.development":"file_type_config",".env.production":"file_type_config",".env.test":"file_type_config",".npmrc":"file_type_npm",".babelrc":"file_type_babel","babel.config.js":"file_type_babel","babel.config.json":"file_type_babel",".babelrc.js":"file_type_babel",".babelrc.json":"file_type_babel","jest.config.ts":"file_type_jest","jest.config.js":"file_type_jest","vitest.config.ts":"file_type_vite","vitest.config.js":"file_type_vite","webpack.config.js":"file_type_webpack","webpack.config.ts":"file_type_webpack","rollup.config.js":"file_type_rollup","rollup.config.ts":"file_type_rollup","renovate.json":"file_type_renovate",".prettierignore":"file_type_prettier",".eslintignore":"file_type_eslint",".dockerignore":"file_type_docker",prisma:"file_type_prisma"},s={src:"folder_type_src",lib:"folder_type_library",dist:"folder_type_dist",build:"folder_type_dist",out:"folder_type_dist",public:"folder_type_public",assets:"folder_type_asset",static:"folder_type_asset",components:"folder_type_component",pages:"folder_type_view",views:"folder_type_view",routes:"folder_type_route",api:"folder_type_api",server:"folder_type_server",client:"folder_type_client",test:"folder_type_test",tests:"folder_type_test",__tests__:"folder_type_test",spec:"folder_type_test",specs:"folder_type_test",e2e:"folder_type_e2e",docs:"folder_type_docs",config:"folder_type_config",configs:"folder_type_config",scripts:"folder_type_script",styles:"folder_type_style",css:"folder_type_css",images:"folder_type_images",img:"folder_type_images",icons:"folder_type_images",fonts:"folder_type_fonts",types:"folder_type_typescript",typings:"folder_type_typings",hooks:"folder_type_hook",utils:"folder_type_helper",helpers:"folder_type_helper",tools:"folder_type_tools",services:"folder_type_services",middleware:"folder_type_middleware",models:"folder_type_model",store:"folder_type_redux",stores:"folder_type_redux",state:"folder_type_redux",node_modules:"folder_type_node",".git":"folder_type_git",".github":"folder_type_github",".vscode":"folder_type_vscode",".idea":"folder_type_idea",docker:"folder_type_docker",".docker":"folder_type_docker",kubernetes:"folder_type_kubernetes",k8s:"folder_type_kubernetes",".husky":"folder_type_husky",coverage:"folder_type_coverage",".next":"folder_type_next",".nuxt":"folder_type_nuxt",ios:"folder_type_ios",android:"folder_type_android",app:"folder_type_app",packages:"folder_type_package",modules:"folder_type_module",plugins:"folder_type_plugin",templates:"folder_type_template",i18n:"folder_type_locale",locales:"folder_type_locale",lang:"folder_type_locale",translations:"folder_type_locale",prisma:"folder_type_db",db:"folder_type_db",database:"folder_type_db",migrations:"folder_type_db",seeds:"folder_type_db",storybook:"folder_type_story",stories:"folder_type_story",".storybook":"folder_type_story",".cache":"folder_type_temp",temp:"folder_type_temp",tmp:"folder_type_temp"};e.s(["FileIconImg",0,function({name:e}){return(0,t.jsx)(i.default,{src:function(e){let t,i=e.toLowerCase();if(r[i])return`/icons/${r[i]}.svg`;let s=(t=e.lastIndexOf("."))>=0?e.slice(t).toLowerCase():"";return s&&l[s]?`/icons/${l[s]}.svg`:"/icons/default_file.svg"}(e),alt:e,width:16,height:16,className:"size-4 shrink-0",unoptimized:!0})},"FolderIconImg",0,function({name:e,isOpen:l}){let r;return(0,t.jsx)(i.default,{src:(r=s[e.toLowerCase()])?`/icons/${r}${l?"_opened":""}.svg`:l?"/icons/default_folder_opened.svg":"/icons/default_folder.svg",alt:e,width:16,height:16,className:"size-4 shrink-0",unoptimized:!0})}])},751962,687204,231352,833237,e=>{"use strict";var t=e.i(344180),i=e.i(932031),l=e.i(984178),r=e.i(383171),s=e.i(415955),n=e.i(137340),o=e.i(307858),a=e.i(129981),d=e.i(159619),c=e.i(198699),p=e.i(433721);let f=(0,p.default)("file-plus",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);e.s(["FilePlus",0,f],687204);var u=e.i(486657),_=e.i(962562);let m=(0,p.default)("move-right",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);var g=e.i(683640),y=e.i(764556),h=e.i(256186),x=e.i(940361),j=e.i(209988),v=e.i(260218),b=e.i(465458),C=e.i(193251),w=e.i(791298);let k=(0,p.default)("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]);var N=e.i(244073),P=e.i(524360),S=e.i(360112);function I({filePath:e,workspaceId:i,boundDir:l,onRename:r,onMove:s,onCopyItem:a,onDelete:c}){let p=(0,N.useTranslations)("editor");return(0,t.jsxs)(x.ContextMenuContent,{children:[r&&(0,t.jsxs)(x.ContextMenuItem,{onClick:r,children:[(0,t.jsx)(_.Pencil,{className:"size-4"}),p("rename")]}),s&&(0,t.jsxs)(x.ContextMenuItem,{onClick:s,children:[(0,t.jsx)(m,{className:"size-4"}),p("move")]}),a&&(0,t.jsxs)(x.ContextMenuItem,{onClick:a,children:[(0,t.jsx)(d.Copy,{className:"size-4"}),p("copyFile")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:async()=>{let t,l=e.split("/").pop()||"file",r=e.substring(0,e.lastIndexOf("/")),s=l.lastIndexOf(".");t=s>0?l.substring(0,s)+" copy"+l.substring(s):l+" copy";let n=r?`${r}/${t}`:t;(await fetch(`/api/workspaces/${i}/files/copy`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({srcPath:e,destPath:n})})).ok?S.toast.success(p("duplicateSuccess")):S.toast.error(p("duplicateFailed"))},children:[(0,t.jsx)(k,{className:"size-4"}),p("duplicateFile")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>{let t=l?l.replace(/\/+$/,"")+"/"+e:e;navigator.clipboard.writeText(t)},children:[(0,t.jsx)(d.Copy,{className:"size-4"}),p("copyPath")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>{fetch(`/api/workspaces/${i}/files/reveal?path=${encodeURIComponent(e)}`,{method:"POST"})},children:[(0,t.jsx)(o.ExternalLink,{className:"size-4"}),p("revealInFinder")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>{let t=(l?l.replace(/\/+$/,"")+"/"+e:e).replace(/\/[^/]+$/,"");P.useTerminalStore.getState().createSession(void 0,t)},children:[(0,t.jsx)(g.Terminal,{className:"size-4"}),p("openInTerminal")]}),c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x.ContextMenuSeparator,{}),(0,t.jsxs)(x.ContextMenuItem,{onClick:c,className:"text-destructive focus:text-destructive",children:[(0,t.jsx)(n.Trash2,{className:"size-4"}),p("deleteFileTitle")]})]}),(0,t.jsx)(x.ContextMenuSeparator,{}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>{let t=`/api/workspaces/${i}/files/download?path=${encodeURIComponent(e)}`,l=document.createElement("a");l.href=t,l.download="",document.body.appendChild(l),l.click(),document.body.removeChild(l)},children:[(0,t.jsx)(C.Download,{className:"size-4"}),p("download")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>{let t=`${window.location.origin}/api/workspaces/${i}/files/download?path=${encodeURIComponent(e)}`;navigator.clipboard.writeText(t)},children:[(0,t.jsx)(w.Link,{className:"size-4"}),p("copyDownloadUrl")]})]})}e.s(["FileContextMenu",0,I],231352);var O=e.i(359209);let D=(0,y.createContext)({expandedPaths:new Set,togglePath:()=>void 0}),z=(0,y.createContext)({path:"",name:"",isExpanded:!1,ignored:!1}),T=({path:e,name:l,folderIcon:p,ignored:u,className:C,children:w,...k})=>{let{expandedPaths:S,togglePath:I,selectedPath:O,onFileSelect:T,workspaceId:M,onDelete:E,onImport:$,onCopyPath:L,onCreateFile:A,onCreateFolder:U,onRename:B,onMove:q,onCopyItem:W,onLoadDirectory:H,loadingDirs:G,boundDir:V}=(0,y.useContext)(D),J=(0,y.useContext)(z),K=S.has(e),X=u||J.ignored,Q=O===e,Y=!!G?.has(e),Z=(0,N.useTranslations)("editor"),ee=(0,N.useTranslations)("common"),[et,ei]=(0,y.useState)(!1),el=()=>{fetch(`/api/workspaces/${M}/files/reveal?path=${encodeURIComponent(e)}`,{method:"POST"})};return(0,t.jsxs)(z.Provider,{value:{path:e,name:l,isExpanded:K,ignored:X},children:[(0,t.jsxs)(x.ContextMenu,{children:[(0,t.jsx)(h.Collapsible,{onOpenChange:()=>{let t=!K;I(e),t&&H&&H(e)},open:K,children:(0,t.jsxs)("div",{className:C,role:"treeitem","aria-selected":!1,tabIndex:0,...k,children:[(0,t.jsx)(x.ContextMenuTrigger,{className:"contents",children:(0,t.jsxs)("div",{className:"group/folder relative",children:[(0,t.jsxs)(h.CollapsibleTrigger,{className:(0,b.cn)("flex w-full items-center gap-1 rounded px-2 py-1 pr-16 text-left transition-colors hover:bg-muted/50",Q&&"bg-muted",X&&"opacity-50"),children:[(0,t.jsx)(i.ChevronRightIcon,{className:(0,b.cn)("size-4 shrink-0 text-muted-foreground transition-transform",K&&"rotate-90")}),(0,t.jsx)(F,{children:p?p(K):K?(0,t.jsx)(s.FolderOpenIcon,{className:"size-4 text-blue-500"}):(0,t.jsx)(r.FolderIcon,{className:"size-4 text-blue-500"})}),(0,t.jsx)(R,{children:l}),Y&&(0,t.jsx)("span",{className:"size-3 border border-muted-foreground border-t-transparent rounded-full animate-spin shrink-0"})]}),(0,t.jsxs)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-1 invisible group-hover/folder:visible",onClick:e=>e.stopPropagation(),children:[(0,t.jsx)("button",{onClick:el,className:"p-0.5 rounded hover:bg-accent cursor-pointer",title:Z("revealInFinder"),children:(0,t.jsx)(o.ExternalLink,{className:"size-3 text-muted-foreground"})}),(0,t.jsx)("button",{onClick:()=>ei(!0),className:"p-0.5 rounded hover:bg-accent cursor-pointer",title:ee("delete"),children:(0,t.jsx)(n.Trash2,{className:"size-3 text-muted-foreground hover:text-destructive"})})]})]})}),(0,t.jsx)(h.CollapsibleContent,{children:(0,t.jsx)("div",{className:"ml-4 border-l pl-2",children:Y?(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 text-xs text-muted-foreground",children:[(0,t.jsx)("span",{className:"size-3 border border-muted-foreground border-t-transparent rounded-full animate-spin shrink-0"}),(0,t.jsx)("span",{children:Z("loading")})]}):w})})]})}),(0,t.jsxs)(x.ContextMenuContent,{children:[(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>B?.(e),children:[(0,t.jsx)(_.Pencil,{className:"size-4"}),Z("rename")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>q?.(e),children:[(0,t.jsx)(m,{className:"size-4"}),Z("move")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>W?.(e),children:[(0,t.jsx)(d.Copy,{className:"size-4"}),Z("copyFile")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>$?.(e),children:[(0,t.jsx)(a.Upload,{className:"size-4"}),Z("importFile")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>{let t=V?V.replace(/\/+$/,"")+"/"+e:e;navigator.clipboard.writeText(t)},children:[(0,t.jsx)(d.Copy,{className:"size-4"}),Z("copyPath")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>A?.(e),children:[(0,t.jsx)(f,{className:"size-4"}),Z("newFile")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>U?.(e),children:[(0,t.jsx)(c.FolderPlus,{className:"size-4"}),Z("newFolder")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:el,children:[(0,t.jsx)(o.ExternalLink,{className:"size-4"}),Z("revealInFinder")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>{let t=V?V.replace(/\/+$/,"")+"/"+e:e;P.useTerminalStore.getState().createSession(void 0,t)},children:[(0,t.jsx)(g.Terminal,{className:"size-4"}),Z("openInTerminal")]}),(0,t.jsxs)(x.ContextMenuItem,{onClick:()=>ei(!0),className:"text-destructive focus:text-destructive",children:[(0,t.jsx)(n.Trash2,{className:"size-4"}),ee("delete")]})]})]}),(0,t.jsx)(j.Dialog,{open:et,onOpenChange:ei,children:(0,t.jsxs)(j.DialogContent,{className:"sm:max-w-[400px]",children:[(0,t.jsx)(j.DialogHeader,{children:(0,t.jsxs)(j.DialogTitle,{className:"flex items-center gap-2",children:[(0,t.jsx)(n.Trash2,{className:"size-5 text-destructive"}),Z("deleteFolderTitle")]})}),(0,t.jsx)(j.DialogDescription,{children:Z("deleteFolderDesc",{name:l})}),(0,t.jsxs)(j.DialogFooter,{children:[(0,t.jsx)(v.Button,{variant:"outline",onClick:()=>ei(!1),children:ee("cancel")}),(0,t.jsx)(v.Button,{variant:"destructive",onClick:()=>{ei(!1),E?.(e)},children:ee("delete")})]})]})})]})},M=(0,y.createContext)({path:"",name:""}),E=({path:e,name:i,icon:r,ignored:s,className:a,children:d,...c})=>{let{selectedPath:p,onFileSelect:f,workspaceId:_,onDelete:m,onRename:g,onMove:h,onCopyItem:C,fileSizeMap:w,boundDir:k}=(0,y.useContext)(D),P=(0,y.useContext)(z),S=s||P.ignored,O=p===e,T=(0,N.useTranslations)("editor"),E=(0,N.useTranslations)("common"),[L,A]=(0,y.useState)(!1),[U,B]=(0,y.useState)(!1),q=(0,y.useRef)(null);(0,y.useEffect)(()=>{O&&q.current&&q.current.scrollIntoView({block:"nearest",inline:"nearest"})},[O]);let W=w?.[e],H=null!=W&&W>1048576,G=(0,y.useCallback)(()=>{H?A(!0):f?.(e)},[H,f,e]),V=(0,y.useCallback)(()=>{A(!1),f?.(e)},[f,e]);return(0,t.jsxs)(M.Provider,{value:{path:e,name:i},children:[(0,t.jsxs)(x.ContextMenu,{children:[(0,t.jsx)(x.ContextMenuTrigger,{className:"contents",children:(0,t.jsx)("div",{ref:q,className:(0,b.cn)("group/file flex cursor-pointer items-center gap-1 rounded px-2 py-1 transition-colors hover:bg-muted/50",O&&"bg-muted",S&&"opacity-50",a),onClick:G,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&G()},role:"treeitem","aria-selected":!1,tabIndex:0,...c,children:d??(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"size-4"}),(0,t.jsx)(F,{children:r??(0,t.jsx)(l.FileIcon,{className:"size-4 text-muted-foreground"})}),(0,t.jsx)(R,{children:i}),(0,t.jsxs)($,{children:[(0,t.jsx)("button",{onClick:()=>{fetch(`/api/workspaces/${_}/files/reveal?path=${encodeURIComponent(e)}`,{method:"POST"})},className:"p-0.5 rounded hover:bg-accent cursor-pointer",title:T("revealInFinder"),children:(0,t.jsx)(o.ExternalLink,{className:"size-3 text-muted-foreground"})}),(0,t.jsx)("button",{onClick:()=>B(!0),className:"p-0.5 rounded hover:bg-accent cursor-pointer",title:E("delete"),children:(0,t.jsx)(n.Trash2,{className:"size-3 text-muted-foreground hover:text-destructive"})})]})]})})}),(0,t.jsx)(I,{filePath:e,workspaceId:_,boundDir:k,onRename:()=>g?.(e),onMove:()=>h?.(e),onCopyItem:()=>C?.(e),onDelete:()=>B(!0)})]}),(0,t.jsx)(j.Dialog,{open:L,onOpenChange:A,children:(0,t.jsxs)(j.DialogContent,{className:"sm:max-w-[400px]",children:[(0,t.jsx)(j.DialogHeader,{children:(0,t.jsxs)(j.DialogTitle,{className:"flex items-center gap-2",children:[(0,t.jsx)(u.AlertTriangle,{className:"size-5 text-yellow-500"}),T("fileTooLargeTitle")]})}),(0,t.jsx)(j.DialogDescription,{className:"break-all",children:T("fileTooLargeDesc",{name:i,size:W<1024?`${W} B`:W<1048576?`${(W/1024).toFixed(1)} KB`:`${(W/1048576).toFixed(1)} MB`})}),(0,t.jsxs)(j.DialogFooter,{children:[(0,t.jsx)(v.Button,{variant:"outline",onClick:()=>A(!1),children:E("cancel")}),(0,t.jsx)(v.Button,{onClick:V,children:T("openAnyway")})]})]})}),(0,t.jsx)(j.Dialog,{open:U,onOpenChange:B,children:(0,t.jsxs)(j.DialogContent,{className:"sm:max-w-[400px]",children:[(0,t.jsx)(j.DialogHeader,{children:(0,t.jsxs)(j.DialogTitle,{className:"flex items-center gap-2",children:[(0,t.jsx)(n.Trash2,{className:"size-5 text-destructive"}),T("deleteFileTitle")]})}),(0,t.jsx)(j.DialogDescription,{children:T("deleteFileDesc",{name:i})}),(0,t.jsxs)(j.DialogFooter,{children:[(0,t.jsx)(v.Button,{variant:"outline",onClick:()=>B(!1),children:E("cancel")}),(0,t.jsx)(v.Button,{variant:"destructive",onClick:()=>{B(!1),m?.(e)},children:E("delete")})]})]})})]})},F=({className:e,children:i,...l})=>(0,t.jsx)("span",{className:(0,b.cn)("shrink-0",e),...l,children:i}),R=({className:e,children:i,...l})=>(0,t.jsx)("span",{className:(0,b.cn)("truncate flex-1 min-w-0",e),...l,children:i}),$=({className:e,children:i,...l})=>(0,t.jsx)("div",{className:(0,b.cn)("ml-auto flex items-center gap-1 shrink-0 invisible group-hover/file:visible",e),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:"group",...l,children:i});function L({nodes:e,getNodeId:i,getChildren:l,renderNode:r,activeId:s,expandedIds:n,draggedOverId:o,level:a=0,indent:d=12,onDragStart:c,onDragOver:p,onDragLeave:f,onDrop:u,onDragEnd:_,shouldRenderChildren:m}){return e.map(e=>{let g=i(e),h=l(e),x={level:a,hasChildren:h.length>0,isExpanded:!n||!!n[g],isActive:s===g,isDraggedOver:o===g},j={draggable:!!c,style:{paddingLeft:`${Math.max(4,a*d)}px`},onDragStart:c?e=>{e.stopPropagation(),c(e,g)}:void 0,onDragOver:p?e=>{e.stopPropagation(),p(e,g)}:void 0,onDragLeave:f,onDrop:u?e=>{e.stopPropagation(),u(e,g)}:void 0,onDragEnd:_?e=>{e.stopPropagation(),_(e)}:void 0},v=x.hasChildren&&(m?.(e,x)??!0);return(0,t.jsx)(y.Fragment,{children:r({node:e,state:x,rowProps:j,children:v?(0,t.jsx)(L,{nodes:h,getNodeId:i,getChildren:l,renderNode:r,activeId:s,expandedIds:n,draggedOverId:o,level:a+1,indent:d,onDragStart:c,onDragOver:p,onDragLeave:f,onDrop:u,onDragEnd:_,shouldRenderChildren:m}):null})},g)})}e.s(["FileTree",0,({expanded:e,defaultExpanded:i=new Set,selectedPath:l,onFileSelect:r,onExpandedChange:s,workspaceId:n,onDelete:o,onImport:a,onCopyPath:d,onCreateFile:c,onCreateFolder:p,onRename:f,onMove:u,onCopyItem:_,onLoadDirectory:m,loadingDirs:g,boundDir:h,fileSizeMap:x,refreshInterval:j,ignoredPaths:v,draggedOverPath:C,onItemDragStart:w,onItemDragOver:k,onItemDragLeave:N,onItemDrop:P,onItemDragEnd:S,rootDropTargetId:I,onRootDropLineDragOver:O,onRootDropLineDragEnter:z,onRootDropLineDragLeave:T,onRootDropLineDrop:M,className:E,children:F,...R})=>{let[$,L]=(0,y.useState)(i),A=e??$;return(0,y.useEffect)(()=>{if(!j||!m||0===A.size)return;let e=setInterval(()=>{A.forEach(e=>m(e))},j);return()=>clearInterval(e)},[j,m,A]),(0,t.jsx)(D.Provider,{value:{expandedPaths:A,togglePath:e=>{let t=new Set(A);t.has(e)?t.delete(e):t.add(e),L(t),s?.(t)},selectedPath:l,onFileSelect:r,workspaceId:n,onDelete:o,onImport:a,onCopyPath:d,onCreateFile:c,onCreateFolder:p,onRename:f,onMove:u,onCopyItem:_,onLoadDirectory:m,loadingDirs:g,boundDir:h,fileSizeMap:x,ignoredPaths:v,draggedOverPath:C,onItemDragStart:w,onItemDragOver:k,onItemDragLeave:N,onItemDrop:P,onItemDragEnd:S,rootDropTargetId:I,onRootDropLineDragOver:O,onRootDropLineDragEnter:z,onRootDropLineDragLeave:T,onRootDropLineDrop:M},children:(0,t.jsx)("div",{className:(0,b.cn)("flex flex-col bg-background font-mono text-sm h-full",E),role:"tree",...R,children:(0,t.jsx)("div",{className:"p-2 flex-1 min-h-0 overflow-y-auto overflow-x-auto",children:F})})})},"FileTreeNodes",0,function({nodes:e}){let{draggedOverPath:i,onItemDragStart:l,onItemDragOver:r,onItemDragLeave:s,onItemDrop:n,onItemDragEnd:o,rootDropTargetId:a,onRootDropLineDragOver:d,onRootDropLineDragEnter:c,onRootDropLineDragLeave:p,onRootDropLineDrop:f}=(0,y.useContext)(D);return(0,t.jsx)(L,{nodes:e,getNodeId:e=>e.path,getChildren:e=>"directory"===e.type?e.children??[]:[],draggedOverId:i,onDragStart:l,onDragOver:r,onDragLeave:s,onDrop:n,onDragEnd:o,renderNode:({node:e,state:l,rowProps:r,children:s})=>{let n=a?`${a}:${e.path}`:void 0,o=0===l.level&&"directory"===e.type&&f?(0,t.jsx)("div",{className:"flex h-1.5 items-center px-2",draggable:!1,onDragEnterCapture:n?e=>c?.(e,n):void 0,onDragOverCapture:n?e=>d?.(e,n):void 0,onDragLeaveCapture:n?e=>p?.(e,n):void 0,onDropCapture:n?e=>f(e,n):void 0,onDragEnter:n?e=>c?.(e,n):void 0,onDragOver:n?e=>d?.(e,n):void 0,onDragLeave:n?e=>p?.(e,n):void 0,onDrop:n?e=>f(e,n):void 0,children:(0,t.jsx)("div",{className:(0,b.cn)("h-px flex-1 rounded-full bg-primary opacity-0 transition-opacity",n&&i===n&&"opacity-100")})}):null;return"directory"===e.type?(0,t.jsxs)(t.Fragment,{children:[o,(0,t.jsx)(T,{...r,style:void 0,path:e.path,name:e.name,ignored:e.ignored,className:(0,b.cn)(l.isDraggedOver&&"rounded border border-dashed border-primary/40 bg-primary/5",r.className),folderIcon:i=>(0,t.jsx)(O.FolderIconImg,{name:e.name,isOpen:i}),children:s},e.path)]}):(0,t.jsx)(E,{...r,style:void 0,path:e.path,name:e.name,icon:(0,t.jsx)(O.FileIconImg,{name:e.name}),ignored:e.ignored,className:(0,b.cn)(l.isDraggedOver&&"border border-dashed border-primary/40 bg-primary/5",r.className)},e.path)}})},"NestedTree",0,L],751962);var A=e.i(681622),U=e.i(812057),B=e.i(434805),q=e.i(460578),W=e.i(62669),H=e.i(882469);let G=(0,p.default)("folder-input",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);var V=e.i(437122);e.s(["ImportFileDialog",0,function({open:e,onOpenChange:i,workspaceId:l,targetPath:r,onImported:s,accept:n,onUploadFiles:o}){let d=(0,N.useTranslations)("editor"),[c,p]=(0,y.useState)(!1),[f,u]=(0,y.useState)(""),[_,m]=(0,y.useState)(""),[g,h]=(0,y.useState)([]),x=(0,y.useCallback)(()=>{u(""),m(""),h([]),p(!1)},[]),b=(0,y.useCallback)(e=>{e||x(),i(e)},[i,x]),C=async()=>{if(f.trim()){p(!0);try{(await (0,V.fetchWithAuth)(`/api/workspaces/${l}/files/import-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:f.trim(),targetDir:r})})).ok?(S.toast.success(d("importSuccess")),s(),b(!1)):S.toast.error(d("importFailed"))}catch{S.toast.error(d("importFailed"))}finally{p(!1)}}},w=async()=>{if(_.trim()){p(!0);try{(await (0,V.fetchWithAuth)(`/api/workspaces/${l}/files/import-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({absPath:_.trim(),targetDir:r})})).ok?(S.toast.success(d("importSuccess")),s(),b(!1)):S.toast.error(d("importFailed"))}catch{S.toast.error(d("importFailed"))}finally{p(!1)}}},k=async()=>{if(0!==g.length){p(!0);try{if(o)await o(g.map(e=>e.file)),S.toast.success(d("importSuccess")),s(),b(!1);else{let e=await Promise.all(g.map(async e=>{var t;return{name:e.file.name,content:await (t=e.file,new Promise((e,i)=>{let l=new FileReader;l.onload=()=>{let t=l.result;e(t.split(",")[1]||t)},l.onerror=i,l.readAsDataURL(t)}))}}));(await (0,V.fetchWithAuth)(`/api/workspaces/${l}/files/upload`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetDir:r,files:e})})).ok?(S.toast.success(d("importSuccess")),s(),b(!1)):S.toast.error(d("importFailed"))}}catch{S.toast.error(d("importFailed"))}finally{p(!1)}}};return(0,t.jsx)(j.Dialog,{open:e,onOpenChange:b,children:(0,t.jsxs)(j.DialogContent,{className:"sm:max-w-[520px]",children:[(0,t.jsxs)(j.DialogHeader,{children:[(0,t.jsx)(j.DialogTitle,{children:d("importFile")}),(0,t.jsx)(j.DialogDescription,{children:d("importFileDesc")})]}),(0,t.jsxs)(U.Tabs,{defaultValue:"upload",className:"w-full flex flex-col gap-3",children:[(0,t.jsxs)(U.TabsList,{className:"w-full grid grid-cols-3",children:[(0,t.jsxs)(U.TabsTrigger,{value:"upload",className:"gap-1 text-xs",children:[(0,t.jsx)(a.Upload,{className:"size-3"}),d("importUpload")]}),(0,t.jsxs)(U.TabsTrigger,{value:"url",className:"gap-1 text-xs",children:[(0,t.jsx)(H.Globe,{className:"size-3"}),d("importOnline")]}),(0,t.jsxs)(U.TabsTrigger,{value:"internal",className:"gap-1 text-xs",children:[(0,t.jsx)(G,{className:"size-3"}),d("importInternal")]})]}),(0,t.jsxs)(U.TabsContent,{value:"upload",className:"space-y-3 pt-2",children:[(0,t.jsx)(q.FileUpload,{value:g,onChange:h,accept:n}),(0,t.jsx)(v.Button,{className:"w-full",onClick:k,disabled:0===g.length||c,children:c?(0,t.jsx)(W.Loader2,{className:"size-4 animate-spin"}):d("importUpload")})]}),(0,t.jsxs)(U.TabsContent,{value:"url",className:"space-y-3 pt-2",children:[(0,t.jsx)(A.Input,{placeholder:"https://example.com/file.js",value:f,onChange:e=>u(e.target.value),onKeyDown:e=>"Enter"===e.key&&C()}),(0,t.jsx)(v.Button,{className:"w-full",onClick:C,disabled:!f.trim()||c,children:c?(0,t.jsx)(W.Loader2,{className:"size-4 animate-spin"}):d("importOnline")})]}),(0,t.jsxs)(U.TabsContent,{value:"internal",className:"space-y-3 pt-2",children:[(0,t.jsx)(B.FolderPicker,{value:_,onChange:m,allowFiles:!0}),(0,t.jsx)(v.Button,{className:"w-full",onClick:w,disabled:!_.trim()||c,children:c?(0,t.jsx)(W.Loader2,{className:"size-4 animate-spin"}):d("importInternal")})]})]})]})})}],833237)}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,450158,t=>{"use strict";let e=(0,t.i(433721).default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);t.s(["Minus",0,e],450158)},237597,t=>{"use strict";let e=(0,t.i(433721).default)("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);t.s(["Edit3",0,e],237597)},579820,t=>{"use strict";let e=(0,t.i(433721).default)("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);t.s(["Layers",0,e],579820)},735207,t=>{"use strict";let e=(0,t.i(433721).default)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);t.s(["default",0,e])},588785,t=>{"use strict";let e=(0,t.i(433721).default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);t.s(["Maximize2",0,e],588785)},867295,t=>{"use strict";let e=(0,t.i(433721).default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);t.s(["default",0,e])},332277,t=>{"use strict";var e=t.i(867295);t.s(["Eye",()=>e.default])},303867,t=>{"use strict";let e=(0,t.i(433721).default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);t.s(["Code",0,e],303867)},791298,t=>{"use strict";let e=(0,t.i(433721).default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);t.s(["Link",0,e],791298)},293818,t=>{"use strict";let e=(0,t.i(433721).default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);t.s(["SlidersHorizontal",0,e],293818)}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,595390,e=>{"use strict";var n=e.i(344180),s=e.i(764556),a=e.i(681622),t=e.i(611176),l=e.i(972846);let i=e=>!["scheduler","task_creator","bot"].includes(e.description||"")&&"agent-generator"!==e.id;e.s(["MemberPicker",0,function({candidates:e,selected:r,onToggle:c,searchPlaceholder:d,emptyText:o,label:m,filter:u}){let[x,h]=(0,s.useState)(""),p=e.filter(u??i).sort((e,n)=>(e.sortIndex??0)-(n.sortIndex??0)).filter(e=>`${e.label} ${e.description||""}`.toLowerCase().includes(x.toLowerCase()));return(0,n.jsxs)("div",{className:"space-y-2",children:[m&&(0,n.jsx)("label",{className:"text-sm font-medium",children:m}),(0,n.jsx)(a.Input,{value:x,onChange:e=>h(e.target.value),placeholder:d}),(0,n.jsxs)("div",{className:"max-h-40 overflow-y-auto space-y-0.5",children:[0===p.length&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground py-2 text-center",children:o||"No items found"}),p.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>c(e.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,n.jsx)(t.AgentIcon,{agentId:"user"!==e.id?e.id:void 0,name:e.label,className:"size-5 rounded-full"}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block truncate",children:e.label}),e.description&&(0,n.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,n.jsx)("div",{className:`flex items-center justify-center size-4 rounded border shrink-0 ${r.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input"}`})]},e.id))]}),r.length>0&&(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.map(s=>{let a=e.find(e=>e.id===s),i=a?.label||s;return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs max-w-[160px] min-w-0",children:["user"===s?(0,n.jsx)("span",{className:"truncate",children:i}):(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 min-w-0",children:[(0,n.jsx)(t.AgentIcon,{agentId:s,name:i,className:"size-3.5 rounded-full shrink-0"}),(0,n.jsx)("span",{className:"truncate",children:i})]}),(0,n.jsx)("button",{type:"button",onClick:()=>c(s),className:"hover:text-destructive shrink-0 cursor-pointer",children:(0,n.jsx)(l.X,{className:"size-3"})})]},s)})})]})}])},272736,e=>{"use strict";function n(e){return e.name?.trim()||e.role}e.s(["getAgentDisplayName",0,n,"getMemberDisplayName",0,function(e,s){if("user"===s)return"user";let a=e.find(e=>e.id===s);return a?n(a):s},"normalizeChannelMembersToAgentIds",0,function(e,n){let s=new Set(e.map(e=>e.id)),a=[],t=new Set;for(let e of n)s.has(e)&&(t.has(e)||(t.add(e),a.push(e)));return a}])},478117,e=>{"use strict";var n=e.i(344180),s=e.i(764556),a=e.i(244073),t=e.i(209988),l=e.i(681622),i=e.i(260218),r=e.i(595390),c=e.i(272736);e.s(["ChannelDialog",0,function({open:e,onOpenChange:d,channel:o,agents:m=[],onSubmit:u}){let x=(0,a.useTranslations)("chat"),h=(0,a.useTranslations)("common"),[p,g]=(0,s.useState)(""),[f,j]=(0,s.useState)("general"),[b,N]=(0,s.useState)([]),[v,y]=(0,s.useState)(""),[k,w]=(0,s.useState)(0),C=m.filter(e=>!1!==e.enabled).map((e,n)=>({id:e.id,label:(0,c.getMemberDisplayName)(m,e.id),sortIndex:n})),D=1===b.length?b[0]:null;(0,s.useEffect)(()=>{e&&queueMicrotask(()=>{o?(g(o.name),j(o.type),N([...o.members])):(g(""),j("general"),N([])),y(""),w(e=>e+1)})},[e,o]);let I=()=>{u({name:p.trim(),type:f,members:b,initialMessage:D&&v.trim()?v.trim():void 0}),d(!1)};return(0,n.jsx)(t.Dialog,{open:e,onOpenChange:d,children:(0,n.jsxs)(t.DialogContent,{className:"sm:max-w-md max-h-[85vh] p-0 gap-0 flex flex-col overflow-hidden",children:[(0,n.jsxs)(t.DialogHeader,{className:"px-4 py-4 shrink-0",children:[(0,n.jsx)(t.DialogTitle,{children:x(o?"channel.edit":"channel.create")}),(0,n.jsx)(t.DialogDescription,{children:x(o?"channel.edit":"channel.create")})]}),(0,n.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 pb-4",children:(0,n.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("label",{className:"text-sm font-medium",children:h("name")}),(0,n.jsx)(l.Input,{value:p,onChange:e=>g(e.target.value),placeholder:x("channel.namePlaceholder"),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()})]}),(0,n.jsx)(r.MemberPicker,{candidates:C,selected:b,onToggle:e=>{N(n=>n.includes(e)?n.filter(n=>n!==e):[...n,e])},label:x("channel.members"),searchPlaceholder:x("channel.addMember"),emptyText:x("channel.noAgents")||"No agents found"},k),D&&!o&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("label",{className:"text-sm font-medium",children:x("channel.initialMessage")}),(0,n.jsx)(l.Input,{value:v,onChange:e=>y(e.target.value),placeholder:x("channel.initialMessagePlaceholder"),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),I())}})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,n.jsx)(i.Button,{variant:"outline",onClick:()=>d(!1),children:h("cancel")}),(0,n.jsx)(i.Button,{onClick:I,children:h(o?"save":"create")})]})]})})]})})}])},694205,e=>{e.n(e.i(478117))}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,940361,e=>{"use strict";var t=e.i(344180);e.s([],2365),e.i(2365);var s=e.i(764556),n=e.i(394822),r=e.i(174465),i=e.i(648224),a=e.i(35359);e.i(8890);var o=e.i(422561),l=e.i(526850),c=e.i(232449),d=e.i(410421),u=e.i(150129),m=e.i(969490),x=e.i(602453),p=e.i(817955),h=e.i(742665),f=e.i(87709);let g=s.forwardRef(function(e,t){let{render:n,className:i,style:g,...v}=e,{setAnchor:j,actionsRef:w,internalBackdropRef:b,backdropRef:k,positionerRef:y,allowMouseUpTriggerRef:C,initialCursorPointRef:N,rootId:M}=(0,r.useContextMenuRootContext)(!1),{store:S}=(0,a.useMenuRootContext)(!1),D=S.useState("open"),T=S.useState("disabled"),I=s.useRef(null),A=s.useRef(null),R=(0,c.useTimeout)(),z=(0,c.useTimeout)(),_=s.useRef(!1);function P(e,t,s){let n=s.type.startsWith("touch");N.current={x:e,y:t},j({getBoundingClientRect:()=>DOMRect.fromRect({width:10*!!n,height:10*!!n,x:e,y:t})}),_.current=!1,w.current?.setOpen(!0,(0,x.createChangeEventDetails)(h.REASONS.triggerPress,s)),z.start(500,()=>{_.current=!0})}function O(){R.clear(),A.current=null}return s.useEffect(()=>{let e=(0,l.ownerDocument)(I.current);return(0,o.addEventListener)(e,"contextmenu",function(e){if(T)return;let t=(0,d.getTarget)(e);((0,d.contains)(I.current,t)||(0,d.contains)(b.current,t)||(0,d.contains)(k.current,t))&&e.preventDefault()})},[k,T,b]),(0,m.useRenderElement)("div",e,{state:{open:D},ref:[I,t],props:[{onContextMenu:function(e){if(T)return;C.current=!0,(0,u.stopEvent)(e),P(e.clientX,e.clientY,e.nativeEvent);let t=(0,l.ownerDocument)(I.current);(0,o.addEventListener)(t,"mouseup",e=>{if(C.current=!1,!_.current)return;z.clear(),_.current=!1;let t=(0,d.getTarget)(e);(0,d.contains)(y.current,t)||M&&t&&(0,f.findRootOwnerId)(t)===M||w.current?.setOpen(!1,(0,x.createChangeEventDetails)(h.REASONS.cancelOpen,e))},{once:!0})},onTouchStart:function(e){if(!T&&(C.current=!1,1===e.touches.length)){e.stopPropagation();let t=e.touches[0];A.current={x:t.clientX,y:t.clientY},R.start(500,()=>{A.current&&P(A.current.x,A.current.y,e.nativeEvent)})}},onTouchMove:function(e){if(R.isStarted()&&A.current&&1===e.touches.length){let t=e.touches[0],s=Math.abs(t.clientX-A.current.x),n=Math.abs(t.clientY-A.current.y);(s>10||n>10)&&R.clear()}},onTouchEnd:O,onTouchCancel:O,style:{WebkitTouchCallout:"none"}},v],stateAttributesMapping:p.pressableTriggerOpenStateMapping})});var v=e.i(487455),j=e.i(293209),w=e.i(503662),b=e.i(33427),k=e.i(324573),y=e.i(582883),C=e.i(277658),N=e.i(349204),M=e.i(28051),S=e.i(597375),D=e.i(81752),T=e.i(59354),I=e.i(300637),A=e.i(281478),R=e.i(65255),z=e.i(327794),_=e.i(362962);e.s(["Arrow",()=>k.MenuArrow,"Backdrop",()=>v.MenuBackdrop,"CheckboxItem",()=>M.MenuCheckboxItem,"CheckboxItemIndicator",()=>S.MenuCheckboxItemIndicator,"Group",()=>y.MenuGroup,"GroupLabel",()=>C.MenuGroupLabel,"Item",()=>N.MenuItem,"LinkItem",()=>D.MenuLinkItem,"Popup",()=>b.MenuPopup,"Portal",()=>j.MenuPortal,"Positioner",()=>w.MenuPositioner,"RadioGroup",()=>T.MenuRadioGroup,"RadioItem",()=>I.MenuRadioItem,"RadioItemIndicator",()=>A.MenuRadioItemIndicator,"Root",0,function(e){let[o,l]=s.useState({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,x:0,y:0})}),c=s.useRef(null),d=s.useRef(null),u=s.useRef(null),m=s.useRef(null),x=s.useRef(!0),p=s.useRef(null),h=(0,n.useId)(),f=s.useMemo(()=>({anchor:o,setAnchor:l,actionsRef:u,backdropRef:c,internalBackdropRef:d,positionerRef:m,allowMouseUpTriggerRef:x,initialCursorPointRef:p,rootId:h}),[o,h]);return(0,t.jsx)(r.ContextMenuRootContext.Provider,{value:f,children:(0,t.jsx)(a.MenuRootContext.Provider,{value:void 0,children:(0,t.jsx)(i.Menu.Root,{...e})})})},"Separator",()=>_.Separator,"SubmenuRoot",()=>R.MenuSubmenuRoot,"SubmenuTrigger",()=>z.MenuSubmenuTrigger,"Trigger",0,g],912001);var P=e.i(912001),P=P,O=e.i(465458),W=e.i(932031);function E({className:e,align:s="start",alignOffset:n=4,side:r="right",sideOffset:i=0,...a}){return(0,t.jsx)(P.Portal,{children:(0,t.jsx)(P.Positioner,{className:"isolate z-50 outline-none",align:s,alignOffset:n,side:r,sideOffset:i,children:(0,t.jsx)(P.Popup,{"data-slot":"context-menu-content",className:(0,O.cn)("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...a})})})}e.i(299648),e.s(["ContextMenu",0,function({...e}){return(0,t.jsx)(P.Root,{"data-slot":"context-menu",...e})},"ContextMenuContent",0,E,"ContextMenuItem",0,function({className:e,inset:s,variant:n="default",...r}){return(0,t.jsx)(P.Item,{"data-slot":"context-menu-item","data-inset":s,"data-variant":n,className:(0,O.cn)("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",e),...r})},"ContextMenuSeparator",0,function({className:e,...s}){return(0,t.jsx)(P.Separator,{"data-slot":"context-menu-separator",className:(0,O.cn)("-mx-1 my-1 h-px bg-border",e),...s})},"ContextMenuSub",0,function({...e}){return(0,t.jsx)(P.SubmenuRoot,{"data-slot":"context-menu-sub",...e})},"ContextMenuSubContent",0,function({...e}){return(0,t.jsx)(E,{"data-slot":"context-menu-sub-content",className:"shadow-lg",side:"right",...e})},"ContextMenuSubTrigger",0,function({className:e,inset:s,children:n,...r}){return(0,t.jsxs)(P.SubmenuTrigger,{"data-slot":"context-menu-sub-trigger","data-inset":s,className:(0,O.cn)("flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,(0,t.jsx)(W.ChevronRightIcon,{className:"ml-auto"})]})},"ContextMenuTrigger",0,function({className:e,...s}){return(0,t.jsx)(P.Trigger,{"data-slot":"context-menu-trigger",className:(0,O.cn)("select-none",e),...s})}],940361)},595390,e=>{"use strict";var t=e.i(344180),s=e.i(764556),n=e.i(681622),r=e.i(611176),i=e.i(972846);let a=e=>!["scheduler","task_creator","bot"].includes(e.description||"")&&"agent-generator"!==e.id;e.s(["MemberPicker",0,function({candidates:e,selected:o,onToggle:l,searchPlaceholder:c,emptyText:d,label:u,filter:m}){let[x,p]=(0,s.useState)(""),h=e.filter(m??a).sort((e,t)=>(e.sortIndex??0)-(t.sortIndex??0)).filter(e=>`${e.label} ${e.description||""}`.toLowerCase().includes(x.toLowerCase()));return(0,t.jsxs)("div",{className:"space-y-2",children:[u&&(0,t.jsx)("label",{className:"text-sm font-medium",children:u}),(0,t.jsx)(n.Input,{value:x,onChange:e=>p(e.target.value),placeholder:c}),(0,t.jsxs)("div",{className:"max-h-40 overflow-y-auto space-y-0.5",children:[0===h.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-2 text-center",children:d||"No items found"}),h.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>l(e.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,t.jsx)(r.AgentIcon,{agentId:"user"!==e.id?e.id:void 0,name:e.label,className:"size-5 rounded-full"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate",children:e.label}),e.description&&(0,t.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,t.jsx)("div",{className:`flex items-center justify-center size-4 rounded border shrink-0 ${o.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input"}`})]},e.id))]}),o.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:o.map(s=>{let n=e.find(e=>e.id===s),a=n?.label||s;return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs max-w-[160px] min-w-0",children:["user"===s?(0,t.jsx)("span",{className:"truncate",children:a}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 min-w-0",children:[(0,t.jsx)(r.AgentIcon,{agentId:s,name:a,className:"size-3.5 rounded-full shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:a})]}),(0,t.jsx)("button",{type:"button",onClick:()=>l(s),className:"hover:text-destructive shrink-0 cursor-pointer",children:(0,t.jsx)(i.X,{className:"size-3"})})]},s)})})]})}])},272736,e=>{"use strict";function t(e){return e.name?.trim()||e.role}e.s(["getAgentDisplayName",0,t,"getMemberDisplayName",0,function(e,s){if("user"===s)return"user";let n=e.find(e=>e.id===s);return n?t(n):s},"normalizeChannelMembersToAgentIds",0,function(e,t){let s=new Set(e.map(e=>e.id)),n=[],r=new Set;for(let e of t)s.has(e)&&(r.has(e)||(r.add(e),n.push(e)));return n}])},302773,e=>{"use strict";let t=(0,e.i(816709).create)((e,t)=>({workflows:[],currentWorkflow:null,isLoading:!1,loadWorkflows:async()=>{e({isLoading:!0});try{let t=await fetch("/api/workflows"),s=await t.json();e({workflows:s,isLoading:!1})}catch{e({isLoading:!1})}},createWorkflow:async t=>{let s=await fetch("/api/workflows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await s.json();return e(e=>({workflows:[...e.workflows,n]})),n},updateWorkflow:async(e,s)=>{let n=await fetch(`/api/workflows/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),r=await n.json();t().upsertWorkflow(r)},deleteWorkflow:async e=>{await fetch(`/api/workflows/${e}`,{method:"DELETE"}),t().removeWorkflow(e)},duplicateWorkflow:async t=>{let s=await fetch(`/api/workflows/${t}/duplicate`,{method:"POST"}),n=await s.json();e(e=>({workflows:[...e.workflows,n]}))},setCurrentWorkflow:t=>e({currentWorkflow:t}),upsertWorkflow:t=>{e(e=>{let s=e.workflows.findIndex(e=>e.id===t.id);if(-1!==s){let n=[...e.workflows];return n[s]=t,{workflows:n}}return{workflows:[...e.workflows,t]}})},removeWorkflow:t=>{e(e=>({workflows:e.workflows.filter(e=>e.id!==t),currentWorkflow:e.currentWorkflow?.id===t?null:e.currentWorkflow}))}}));e.s(["useWorkflowStore",0,t])},249063,e=>{"use strict";var t=e.i(344180),s=e.i(764556),n=e.i(244073),r=e.i(209988),i=e.i(681622),a=e.i(260218),o=e.i(788010),l=e.i(595390),c=e.i(272736),d=e.i(302773);e.s(["CreateIssueDialog",0,function({open:e,onOpenChange:u,agents:m=[],defaultDescription:x,onSubmit:p}){let[h,f]=(0,s.useState)(""),[g,v]=(0,s.useState)(""),[j,w]=(0,s.useState)([]),[b,k]=(0,s.useState)(""),{workflows:y,loadWorkflows:C}=(0,d.useWorkflowStore)(),N=(0,n.useTranslations)("issue"),M=(0,n.useTranslations)("common"),S=m.filter(e=>!1!==e.enabled).map((e,t)=>({id:e.id,label:(0,c.getMemberDisplayName)(m,e.id),sortIndex:t}));(0,s.useEffect)(()=>{e&&C()},[e,C]),(0,s.useEffect)(()=>{e&&x&&v(x)},[e,x]);let D=e=>{e||(f(""),v(""),w([]),k("")),u(e)};return(0,t.jsx)(r.Dialog,{open:e,onOpenChange:D,children:(0,t.jsxs)(r.DialogContent,{className:"sm:max-w-md",children:[(0,t.jsxs)(r.DialogHeader,{children:[(0,t.jsx)(r.DialogTitle,{children:N("create.title")}),(0,t.jsx)(r.DialogDescription,{children:N("create.description")})]}),(0,t.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,t.jsx)(i.Input,{placeholder:N("create.titlePlaceholder"),value:h,onChange:e=>f(e.target.value),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,t.jsx)(o.Textarea,{placeholder:N("create.descriptionPlaceholder"),value:g,onChange:e=>v(e.target.value),rows:3}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Workflow Template"}),(0,t.jsxs)("select",{value:b,onChange:e=>{let t=e.target.value;if(k(t),t){let e=y.find(e=>e.id===t);if(e){let t=e.nodes.filter(e=>"agent"===e.type).map(e=>e.data.agentConfigId);w(e=>Array.from(new Set([...e,...t])))}}},className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[(0,t.jsx)("option",{value:"",children:"None (use default pipeline)"}),y.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name," (",e.nodes.length," agents)"]},e.id))]})]}),(0,t.jsx)(l.MemberPicker,{candidates:S,selected:j,onToggle:e=>{w(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},label:N("create.membersLabel"),searchPlaceholder:N("create.searchAgent"),emptyText:N("create.noAgents")},String(e)),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(a.Button,{variant:"outline",onClick:()=>D(!1),children:M("cancel")}),(0,t.jsx)(a.Button,{onClick:()=>{h.trim()&&(p({title:h.trim(),description:g.trim(),members:j,workflowId:b||void 0}),D(!1))},disabled:!h.trim(),children:N("create.submit")})]})]})]})})}])},79882,e=>{"use strict";let t=(0,e.i(433721).default)("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);e.s(["Archive",0,t],79882)},414053,725161,e=>{"use strict";var t=e.i(433721);let s=(0,t.default)("archive-restore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);e.s(["ArchiveRestore",0,s],414053);let n=(0,t.default)("arrow-up-down",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);e.s(["ArrowUpDown",0,n],725161)},358989,e=>{"use strict";var t=e.i(344180),s=e.i(764556),n=e.i(244073),r=e.i(209988),i=e.i(260218),a=e.i(681622),o=e.i(788010),l=e.i(595390),c=e.i(272736),d=e.i(302773);let u=["draft","planned","in_progress","review_pending","changes_requested","approved","completed","archived"];e.s(["EditIssueDialog",0,function({issue:e,open:m,onOpenChange:x,agents:p=[],onSave:h}){let[f,g]=(0,s.useState)(e.title),[v,j]=(0,s.useState)(e.description),[w,b]=(0,s.useState)(e.status),[k,y]=(0,s.useState)(e.members||[]),[C,N]=(0,s.useState)(!1),[M,S]=(0,s.useState)(e.workflowId??""),{workflows:D,loadWorkflows:T}=(0,d.useWorkflowStore)(),I=(0,n.useTranslations)("issue"),A=(0,n.useTranslations)("common");(0,s.useEffect)(()=>{m&&(g(e.title),j(e.description),b(e.status),y(e.members?.length?[...e.members]:[]),S(e.workflowId??""))},[m,e]),(0,s.useEffect)(()=>{m&&T()},[m,T]);let R=async()=>{if(f.trim()){N(!0);try{await h({title:f.trim(),description:v.trim(),status:w,members:k,workflowId:"__none__"===M?null:M||null}),x(!1)}finally{N(!1)}}},z=(0,s.useMemo)(()=>p.filter(e=>!1!==e.enabled).map((e,t)=>({id:e.id,label:(0,c.getMemberDisplayName)(p,e.id),description:e.role,sortIndex:t})),[p]);return(0,t.jsx)(r.Dialog,{open:m,onOpenChange:x,children:(0,t.jsxs)(r.DialogContent,{className:"sm:max-w-md max-h-[85vh] p-0 gap-0 flex flex-col overflow-hidden",children:[(0,t.jsxs)(r.DialogHeader,{className:"px-4 py-4 shrink-0",children:[(0,t.jsx)(r.DialogTitle,{children:I("edit.title")}),(0,t.jsx)(r.DialogDescription,{children:I("edit.description")})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 pb-4",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(a.Input,{placeholder:I("edit.titlePlaceholder"),value:f,onChange:e=>g(e.target.value),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,t.jsx)(o.Textarea,{placeholder:I("edit.descriptionPlaceholder"),value:v,onChange:e=>j(e.target.value),rows:3}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:I("edit.statusLabel")}),(0,t.jsx)("select",{value:w,onChange:e=>b(e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:u.map(e=>(0,t.jsx)("option",{value:e,children:I(`status.${e}`)},e))})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Workflow Template"}),(0,t.jsxs)("select",{value:M||"__none__",onChange:e=>(e=>{if(S(e),!e)return;let t=D.find(t=>t.id===e);if(!t)return;let s=t.nodes.filter(e=>"agent"===e.type).map(e=>e.data.agentConfigId);y(e=>Array.from(new Set([...e,...s])))})("__none__"===e.target.value?"":e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[(0,t.jsx)("option",{value:"__none__",children:"None (use default pipeline)"}),D.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name," (",e.nodes.length," agents)"]},e.id))]})]}),(0,t.jsx)(l.MemberPicker,{candidates:z,selected:k,onToggle:e=>{y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},label:I("edit.membersLabel"),searchPlaceholder:I("edit.searchAgent"),emptyText:I("edit.noAgents")}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,t.jsx)(i.Button,{variant:"outline",onClick:()=>x(!1),children:A("cancel")}),(0,t.jsx)(i.Button,{onClick:R,disabled:!f.trim()||C,children:A(C?"saving":"save")})]})]})})]})})}])},308557,e=>{"use strict";var t=e.i(344180),s=e.i(764556),n=e.i(244073),r=e.i(327964),i=e.i(355819),a=e.i(562918),o=e.i(260218),l=e.i(191118),c=e.i(940361),d=e.i(256186),u=e.i(917955),m=e.i(734649),x=e.i(953700),p=e.i(592039),h=e.i(962562),f=e.i(137340),g=e.i(612505),g=g,v=e.i(79882),j=e.i(414053),w=e.i(315775),b=e.i(992764),k=e.i(344118),y=e.i(725161),C=e.i(613087),N=e.i(465458),M=e.i(249063),S=e.i(358989);let D={draft:"bg-muted text-muted-foreground",planned:"bg-blue-500/10 text-blue-600 dark:text-blue-400",in_progress:"bg-amber-500/10 text-amber-600 dark:text-amber-400",review_pending:"bg-purple-500/10 text-purple-600 dark:text-purple-400",changes_requested:"bg-orange-500/10 text-orange-600 dark:text-orange-400",approved:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",completed:"bg-green-600/10 text-green-600 dark:text-green-400",archived:"bg-muted text-muted-foreground",error:"bg-destructive/10 text-destructive"},T=["in_progress","review_pending","changes_requested","draft","planned","approved","completed","error"],I=["today","yesterday","thisWeek","earlier"],A={today:"timeToday",yesterday:"timeYesterday",thisWeek:"timeThisWeek",earlier:"timeEarlier"};e.s(["IssueList",0,function({workspaceId:e}){let{issues:R,activeIssueId:z,loading:_,loadIssues:P,createIssue:O,updateIssue:W,updateIssueStatus:E,deleteIssue:B,setActiveIssue:L}=(0,r.useIssueStore)(),{agents:$,ensure:G}=(0,i.useAgentStore)(),[q,U]=(0,s.useState)(!1),[Y,H]=(0,s.useState)(null),[K,X]=(0,s.useState)(!1),[F,J]=(0,s.useState)("status"),[V,Q]=(0,s.useState)({}),[Z,ee]=(0,s.useState)(!1),[et,es]=(0,s.useState)("createdAt"),[en,er]=(0,s.useState)("desc"),ei=(0,n.useTranslations)("issue"),ea=(0,n.useTranslations)("common");(0,s.useEffect)(()=>{P(e),G()},[e,P,G]);let eo=async t=>{await O(e,t.title,t.description,t.members,t.workflowId)},el=(0,s.useMemo)(()=>R.filter(e=>"archived"!==e.status),[R]),ec=(0,s.useMemo)(()=>R.filter(e=>"archived"===e.status),[R]),ed=(0,s.useMemo)(()=>{let e=[...el];return e.sort((e,t)=>{let s=0;switch(et){case"createdAt":s=new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime();break;case"updatedAt":s=new Date(e.updatedAt).getTime()-new Date(t.updatedAt).getTime();break;case"status":{let n=T.indexOf(e.status),r=T.indexOf(t.status);s=(-1===n?99:n)-(-1===r?99:r)}}return"desc"===en?-s:s}),e},[el,et,en]),eu=T.map(e=>({status:e,items:ed.filter(t=>t.status===e)})).filter(e=>e.items.length>0),em=(0,s.useMemo)(()=>{let e={};for(let t of ed){let s=function(e){let t=new Date(e),s=new Date,n=new Date(s.getFullYear(),s.getMonth(),s.getDate()),r=new Date(n.getTime()-864e5),i=new Date(n.getTime()-6048e5);return t>=n?"today":t>=r?"yesterday":t>=i?"thisWeek":"earlier"}(t.createdAt);e[s]||(e[s]=[]),e[s].push(t)}return I.filter(t=>e[t]?.length).map(t=>({key:t,label:ea(A[t]),items:e[t]}))},[ed,ea]),ex=s=>(0,t.jsxs)(c.ContextMenu,{children:[(0,t.jsxs)(c.ContextMenuTrigger,{onClick:()=>L(s.id),className:`w-full text-left px-3 py-2 hover:bg-accent/50 transition-colors flex items-start gap-2 ${z===s.id?"bg-accent":""}`,children:[(0,t.jsx)(p.CircleDot,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-sm font-medium truncate",children:s.title}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:ei("list.taskCount",{count:s.tasks.length})})]}),(0,t.jsx)(a.Badge,{variant:"outline",className:`text-[10px] shrink-0 border-none ${D[s.status]}`,children:ei(`status.${s.status}`)})]}),(0,t.jsxs)(c.ContextMenuContent,{children:[(0,t.jsxs)(c.ContextMenuItem,{onClick:()=>H(s),children:[(0,t.jsx)(h.Pencil,{className:"size-4 mr-2"}),ea("edit")]}),(0,t.jsx)(c.ContextMenuSeparator,{}),(0,t.jsxs)(c.ContextMenuItem,{onClick:()=>ep(s),children:[(0,t.jsx)(v.Archive,{className:"size-4 mr-2"}),ei("list.archive")]}),(0,t.jsx)(c.ContextMenuSeparator,{}),(0,t.jsxs)(c.ContextMenuItem,{variant:"destructive",onClick:()=>B(e,s.id),children:[(0,t.jsx)(f.Trash2,{className:"size-4 mr-2"}),ea("delete")]})]})]},s.id),ep=async t=>{let s="archived"===t.status?"completed":"archived";await E(e,t.id,s)},eh=async()=>{await Promise.all(ec.map(t=>B(e,t.id))),ee(!1)};return _?(0,t.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,t.jsx)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b text-xs font-medium text-muted-foreground shrink-0",children:(0,t.jsx)("span",{children:ei("list.title")})}),(0,t.jsx)("div",{className:"p-2 space-y-1",children:(0,t.jsx)(C.SkeletonGroup,{count:5,children:e=>(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md",children:[(0,t.jsx)(C.Skeleton,{className:"size-4 rounded-full shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 space-y-1.5",children:[(0,t.jsx)(C.Skeleton,{className:"h-4 w-3/4"}),(0,t.jsx)(C.Skeleton,{className:"h-3 w-1/2"})]}),(0,t.jsx)(C.Skeleton,{className:"h-4 w-12 rounded-full"})]},e)})})]}):(0,t.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b text-xs font-medium text-muted-foreground shrink-0",children:[(0,t.jsx)("span",{children:ei("list.title")}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,t.jsx)("button",{onClick:()=>U(!0),className:"p-0.5 hover:bg-accent rounded cursor-pointer",children:(0,t.jsx)(x.Plus,{className:"size-3.5"})}),(0,t.jsxs)(u.DropdownMenu,{children:[(0,t.jsx)(u.DropdownMenuTrigger,{className:"p-0.5 hover:bg-accent rounded",children:(0,t.jsx)(y.ArrowUpDown,{className:"size-3.5"})}),(0,t.jsx)(u.DropdownMenuContent,{align:"end",className:"min-w-40",children:[{field:"createdAt",label:ea("sortByCreated")},{field:"updatedAt",label:ea("sortByLastReply")},{field:"status",label:ea("sortByStatus")}].map(({field:e,label:s})=>(0,t.jsxs)(u.DropdownMenuItem,{onClick:()=>{et===e?er(e=>"asc"===e?"desc":"asc"):(es(e),er("desc"))},children:[et===e&&(0,t.jsx)(k.Check,{className:"size-3.5"}),s,et===e&&(0,t.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"asc"===en?"↑":"↓"})]},e))})]}),(0,t.jsxs)(u.DropdownMenu,{children:[(0,t.jsx)(u.DropdownMenuTrigger,{className:"p-0.5 hover:bg-accent rounded",children:(0,t.jsx)(w.MoreHorizontal,{className:"size-3.5"})}),(0,t.jsxs)(u.DropdownMenuContent,{align:"end",className:"min-w-48",children:[(0,t.jsxs)(u.DropdownMenuItem,{onClick:()=>J("none"),children:["none"===F&&(0,t.jsx)(k.Check,{className:"size-3.5"}),ea("groupNone")]}),(0,t.jsxs)(u.DropdownMenuItem,{onClick:()=>J("time"),children:["time"===F&&(0,t.jsx)(k.Check,{className:"size-3.5"}),ea("groupByTime")]}),(0,t.jsxs)(u.DropdownMenuItem,{onClick:()=>J("status"),children:["status"===F&&(0,t.jsx)(k.Check,{className:"size-3.5"}),ea("groupByStatus")]}),(0,t.jsx)(u.DropdownMenuSeparator,{}),(0,t.jsxs)(u.DropdownMenuItem,{disabled:0===ec.length,onClick:()=>ee(!0),children:[(0,t.jsx)(f.Trash2,{className:"size-3.5"}),ei("list.clearArchived")]})]})]})]})]}),(0,t.jsxs)(l.ScrollArea,{className:"min-h-0 flex-1 overflow-hidden",children:[0===eu.length&&0===ec.length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 px-4 text-center py-12",children:[(0,t.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,t.jsx)(g.default,{className:"h-5 w-5 text-muted-foreground"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:ei("list.emptyTitle")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:ei("list.emptyDescription")})]}),(0,t.jsxs)(o.Button,{size:"sm",variant:"outline",onClick:()=>U(!0),children:[(0,t.jsx)(x.Plus,{className:"h-3.5 w-3.5 mr-1"}),ei("list.addIssue")]})]}),"none"===F&&ed.map(e=>ex(e)),"status"===F&&eu.map(e=>(0,t.jsxs)(d.Collapsible,{open:!1!==V[e.status],onOpenChange:t=>Q(s=>({...s,[e.status]:t})),children:[(0,t.jsxs)(d.CollapsibleTrigger,{className:"flex items-center gap-1 w-full px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent transition-colors",children:[(0,t.jsx)(b.ChevronRight,{className:(0,N.cn)("size-3 transition-transform",!1!==V[e.status]&&"rotate-90")}),ei(`status.${e.status}`)," (",e.items.length,")"]}),(0,t.jsx)(d.CollapsibleContent,{children:e.items.map(e=>ex(e))})]},e.status)),"time"===F&&em.map(e=>(0,t.jsxs)(d.Collapsible,{open:!1!==V[e.key],onOpenChange:t=>Q(s=>({...s,[e.key]:t})),children:[(0,t.jsxs)(d.CollapsibleTrigger,{className:"flex items-center gap-1 w-full px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent transition-colors",children:[(0,t.jsx)(b.ChevronRight,{className:(0,N.cn)("size-3 transition-transform",!1!==V[e.key]&&"rotate-90")}),e.label," (",e.items.length,")"]}),(0,t.jsx)(d.CollapsibleContent,{children:e.items.map(e=>ex(e))})]},e.key)),ec.length>0&&(0,t.jsxs)(d.Collapsible,{open:K,onOpenChange:X,children:[(0,t.jsxs)(d.CollapsibleTrigger,{className:"flex items-center gap-1 w-full px-3 py-1 text-xs font-medium text-muted-foreground hover:bg-accent transition-colors",children:[(0,t.jsx)(b.ChevronRight,{className:(0,N.cn)("size-3 transition-transform",K&&"rotate-90")}),(0,t.jsx)(v.Archive,{className:"size-3"}),ei("list.archived")," (",ec.length,")"]}),(0,t.jsx)(d.CollapsibleContent,{children:ec.map(s=>(0,t.jsxs)(c.ContextMenu,{children:[(0,t.jsxs)(c.ContextMenuTrigger,{onClick:()=>L(s.id),className:`w-full text-left px-3 py-2 hover:bg-accent/50 transition-colors flex items-start gap-2 opacity-60 ${z===s.id?"bg-accent opacity-100":""}`,children:[(0,t.jsx)(p.CircleDot,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-sm font-medium truncate",children:s.title}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:ei("list.taskCount",{count:s.tasks.length})})]}),(0,t.jsx)(a.Badge,{variant:"outline",className:`text-[10px] shrink-0 border-none ${D.archived}`,children:ei("status.archived")})]}),(0,t.jsxs)(c.ContextMenuContent,{children:[(0,t.jsxs)(c.ContextMenuItem,{onClick:()=>ep(s),children:[(0,t.jsx)(j.ArchiveRestore,{className:"size-4 mr-2"}),ei("list.unarchive")]}),(0,t.jsx)(c.ContextMenuSeparator,{}),(0,t.jsxs)(c.ContextMenuItem,{variant:"destructive",onClick:()=>B(e,s.id),children:[(0,t.jsx)(f.Trash2,{className:"size-4 mr-2"}),ea("delete")]})]})]},s.id))})]})]}),(0,t.jsx)(M.CreateIssueDialog,{open:q,onOpenChange:U,agents:$,onSubmit:eo}),Y&&(0,t.jsx)(S.EditIssueDialog,{issue:Y,open:!!Y,onOpenChange:e=>{e||H(null)},agents:$,onSave:async t=>{await W(e,Y.id,t),H(null)}}),(0,t.jsx)(m.AlertDialog,{open:Z,onOpenChange:ee,children:(0,t.jsxs)(m.AlertDialogContent,{children:[(0,t.jsxs)(m.AlertDialogHeader,{children:[(0,t.jsx)(m.AlertDialogTitle,{children:ei("list.clearArchived")}),(0,t.jsx)(m.AlertDialogDescription,{children:ei("list.clearArchivedConfirm",{count:ec.length})})]}),(0,t.jsxs)(m.AlertDialogFooter,{children:[(0,t.jsx)(m.AlertDialogCancel,{children:ea("cancel")}),(0,t.jsx)(m.AlertDialogAction,{onClick:eh,children:ea("delete")})]})]})})]})}],308557)},783481,e=>{e.n(e.i(308557))}]);
@@ -5,4 +5,4 @@
5
5
  ${n} [data-chart=${e}] {
6
6
  ${r.map(([e,r])=>{let n=r.theme?.[t]??r.color;return n?` --color-${e}: ${n};`:null}).join("\n")}
7
7
  }
8
- `).join("\n")}}):null},wC=function(e){var t,r,n,i,o,a,l,s,u,c,d=t_(e,wi),{active:f,allowEscapeViewBox:p,animationDuration:h,animationEasing:g,content:m,filterNull:v,isAnimationActive:y,offset:b,payloadUniqBy:x,position:w,reverseDirection:O,useTranslate3d:S,wrapperStyle:j,cursor:M,shared:C,trigger:_,defaultIndex:P,portal:k,axisId:E}=d,D=tX(),N="number"==typeof P?String(P):P;(0,q.useEffect)(()=>{D(hn({shared:C,trigger:_,axisId:E,active:f,defaultIndex:N}))},[D,C,_,E,f,N]);var A=i7(),T=v8(),I=t1(e=>hv(e,C)),{activeIndex:R,isActive:F}=null!=(u=t1(e=>mA(e,I,_,N)))?u:{},z=t1(e=>mN(e,I,_,N)),L=t1(e=>mD(e,I,_,N)),B=t1(e=>mE(e,I,_,N)),V=(0,q.useContext)(yv),W=null!=(c=null!=f?f:F)&&c,[U,H]=xZ([z,W]),$="axis"===I?L:void 0;t=t1(e=>((e,t,r)=>{if(null!=t){var n=hC(e);return"axis"===t?"hover"===r?n.axisInteraction.hover.dataKey:n.axisInteraction.click.dataKey:"hover"===r?n.itemInteraction.hover.dataKey:n.itemInteraction.click.dataKey}})(e,I,_)),r=t1(gu),n=t1(a$),i=t1(aU),o=t1(aH),l=null==(a=t1(yp))?void 0:a.active,s=i7(),(0,q.useEffect)(()=>{if(!l&&null!=i&&null!=n){var e=hc({active:W,coordinate:B,dataKey:t,index:R,label:"number"==typeof $?String($):$,sourceViewBox:s,graphicalItemId:r});yc.emit(yd,i,e,n)}},[l,B,t,r,R,$,n,i,o,W,s]);var G=null!=k?k:V;if(null==G||null==A||null==I)return null;var Y=null!=z?z:wn;W||(Y=wn),v&&Y.length&&(Y=xK(Y.filter(e=>null!=e.value&&(!0!==e.hide||d.includeHidden)),x,wr));var K=Y.length>0,Z=wt(wt({},d),{},{payload:Y,label:$,active:W,activeIndex:R,coordinate:B,accessibilityLayer:T}),X=q.createElement(xY,{allowEscapeViewBox:p,animationDuration:h,animationEasing:g,isAnimationActive:y,active:W,coordinate:B,hasPayload:K,offset:b,position:w,reverseDirection:O,useTranslate3d:S,viewBox:A,wrapperStyle:j,lastBoundingBox:U,innerRef:H,hasPortalFromProps:!!k},q.isValidElement(m)?q.cloneElement(m,Z):"function"==typeof m?q.createElement(m,Z):q.createElement(xV,Z));return q.createElement(q.Fragment,null,(0,ox.createPortal)(X,G),W&&q.createElement(x9,{cursor:M,tooltipEventType:I,coordinate:B,payload:Y,index:R}))};function w_({active:e,payload:t,className:r,indicator:n="dot",hideLabel:i=!1,hideIndicator:o=!1,label:a,labelFormatter:l,labelClassName:s,formatter:u,color:c,nameKey:d,labelKey:f}){let{config:p}=function(){let e=q.useContext(wS);if(!e)throw Error("useChart must be used within a <ChartContainer />");return e}(),h=q.useMemo(()=>{if(i||!t?.length)return null;let[e]=t,r=`${f??e?.dataKey??e?.name??"value"}`,n=wP(p,e,r),o=f||"string"!=typeof a?n?.label:p[a]?.label??a;return l?(0,Y.jsx)("div",{className:(0,xk.cn)("font-medium",s),children:l(o,t)}):o?(0,Y.jsx)("div",{className:(0,xk.cn)("font-medium",s),children:o}):null},[a,l,t,i,s,p,f]);if(!e||!t?.length)return null;let g=1===t.length&&"dot"!==n;return(0,Y.jsxs)("div",{className:(0,xk.cn)("grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[g?null:h,(0,Y.jsx)("div",{className:"grid gap-1.5",children:t.filter(e=>"none"!==e.type).map((e,t)=>{let r=`${d??e.name??e.dataKey??"value"}`,i=wP(p,e,r),a=c??e.payload?.fill??e.color;return(0,Y.jsx)("div",{className:(0,xk.cn)("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===n&&"items-center"),children:u&&e?.value!==void 0&&e.name?u(e.value,e.name,e,t,e.payload):(0,Y.jsxs)(Y.Fragment,{children:[i?.icon?(0,Y.jsx)(i.icon,{}):!o&&(0,Y.jsx)("div",{className:(0,xk.cn)("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",{"h-2.5 w-2.5":"dot"===n,"w-1":"line"===n,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===n,"my-0.5":g&&"dashed"===n}),style:{"--color-bg":a,"--color-border":a}}),(0,Y.jsxs)("div",{className:(0,xk.cn)("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[(0,Y.jsxs)("div",{className:"grid gap-1.5",children:[g?h:null,(0,Y.jsx)("span",{className:"text-muted-foreground",children:i?.label??e.name})]}),null!=e.value&&(0,Y.jsx)("span",{className:"font-mono font-medium text-foreground tabular-nums",children:"number"==typeof e.value?e.value.toLocaleString():String(e.value)})]})]})},t)})})]})}function wP(e,t,r){if("object"!=typeof t||null===t)return;let n="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0,i=r;return r in t&&"string"==typeof t[r]?i=t[r]:n&&r in n&&"string"==typeof n[r]&&(i=n[r]),i in e?e[i]:e[r]}var wk=e.i(226651),wk=wk;function wE({className:e,...t}){return(0,Y.jsx)("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:(0,xk.cn)("mx-auto flex w-full justify-center",e),...t})}function wD({className:e,...t}){return(0,Y.jsx)("ul",{"data-slot":"pagination-content",className:(0,xk.cn)("flex items-center gap-0.5",e),...t})}function wN({...e}){return(0,Y.jsx)("li",{"data-slot":"pagination-item",...e})}function wA({className:e,...t}){return(0,Y.jsxs)("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:(0,xk.cn)("flex size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4",e),...t,children:[(0,Y.jsx)(wk.default,{}),(0,Y.jsx)("span",{className:"sr-only",children:"More pages"})]})}var wT=e.i(996652),wI=e.i(613087);function wR({className:e,...t}){return(0,Y.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,Y.jsx)("table",{"data-slot":"table",className:(0,xk.cn)("w-full caption-bottom text-sm",e),...t})})}function wF({className:e,...t}){return(0,Y.jsx)("thead",{"data-slot":"table-header",className:(0,xk.cn)("[&_tr]:border-b",e),...t})}function wz({className:e,...t}){return(0,Y.jsx)("tbody",{"data-slot":"table-body",className:(0,xk.cn)("[&_tr:last-child]:border-0",e),...t})}function wL({className:e,...t}){return(0,Y.jsx)("tr",{"data-slot":"table-row",className:(0,xk.cn)("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function wB({className:e,...t}){return(0,Y.jsx)("th",{"data-slot":"table-head",className:(0,xk.cn)("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",e),...t})}function wV({className:e,...t}){return(0,Y.jsx)("td",{"data-slot":"table-cell",className:(0,xk.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",e),...t})}var wW=e.i(638322),wU=e.i(962562),wH=e.i(601039),w$=e.i(953700),wG=e.i(137340),wY=e.i(209988),wq=e.i(681622),wK=e.i(817854);let wZ=[{value:"zhipu",label:"智谱 (ZhiPu)",authMode:"headers"},{value:"minimax",label:"MiniMax",authMode:"cookie"},{value:"aicode",label:"AI Code",authMode:"cookie"}],wX={zhipu:[{key:"Authorization",value:""}]},wQ=1;function wJ(e){return wX[e]?.map(e=>({...e,id:wQ++}))??[]}function w0(e){return wZ.find(t=>t.value===e)?.authMode??"headers"}function w1(e){var t;return{id:e.id,provider:e.provider,label:e.label,cookie:e.cookie??"",headers:(t=e.headers)&&0!==Object.keys(t).length?Object.entries(t).map(([e,t])=>({id:wQ++,key:e,value:t})):[]}}function w2({onChange:e,editConfig:t,onEditClear:r}){let n=(0,Z.useTranslations)("home"),[i,o]=(0,q.useState)(!1),[a,l]=(0,q.useState)([]),[s,u]=(0,q.useState)(null),c=(0,q.useCallback)(async()=>{let e=await fetch("/api/subscriptions");e.ok&&l(await e.json())},[]);(0,q.useEffect)(()=>{t&&(u(w1(t)),o(!0))},[t]),(0,q.useEffect)(()=>{i&&c()},[i,c]);let d=async()=>{if(!s)return;let t=w0(s.provider),r={provider:s.provider,label:s.label||s.provider};if("cookie"===t)r.cookie=s.cookie;else{let e;r.headers=(e=s.headers.filter(e=>e.key.trim()).map(e=>[e.key.trim(),e.value])).length>0?Object.fromEntries(e):void 0}let n=s.id?`/api/subscriptions/${s.id}`:"/api/subscriptions",i=s.id?"PUT":"POST";(await fetch(n,{method:i,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).ok&&(u(null),await c(),e?.())},f=async t=>{await fetch(`/api/subscriptions/${t}`,{method:"DELETE"}),await c(),e?.()},p=(e,t,r)=>{s&&u({...s,headers:s.headers.map(n=>n.id===e?{...n,[t]:r}:n)})},h=s?w0(s.provider):null,g=s&&("cookie"===h?!!s.cookie.trim():s.headers.some(e=>e.key.trim()&&e.value.trim()));return(0,Y.jsxs)(wY.Dialog,{open:i,onOpenChange:e=>{o(e),e||(u(null),r?.())},children:[(0,Y.jsx)(wY.DialogTrigger,{nativeButton:!0,render:(0,Y.jsxs)(yQ.Button,{variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs",children:[(0,Y.jsx)(w$.Plus,{className:"size-3.5"}),n("subscription.addPlatform")]})}),(0,Y.jsxs)(wY.DialogContent,{className:"sm:max-w-lg",children:[(0,Y.jsx)(wY.DialogHeader,{children:(0,Y.jsx)(wY.DialogTitle,{className:"text-sm",children:n(s?.id?"subscription.editTitle":"subscription.title")})}),(0,Y.jsxs)("div",{className:"space-y-3",children:[!s&&a.map(e=>(0,Y.jsxs)("div",{className:"flex items-center justify-between rounded-md border px-3 py-2",children:[(0,Y.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,Y.jsx)("span",{className:"text-xs font-medium",children:e.label}),(0,Y.jsxs)("span",{className:"text-[10px] text-muted-foreground capitalize",children:["(",e.provider,")"]})]}),(0,Y.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,Y.jsx)(yQ.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:()=>u(w1(e)),children:(0,Y.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-3 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Y.jsx)("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),(0,Y.jsx)("path",{d:"m15 5 4 4"})]})}),(0,Y.jsx)(yQ.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:()=>f(e.id),children:(0,Y.jsx)(wG.Trash2,{className:"size-3 text-muted-foreground"})})]})]},e.id)),!s&&0===a.length&&(0,Y.jsx)("p",{className:"text-center text-xs text-muted-foreground py-2",children:n("subscription.empty")}),s&&h&&(0,Y.jsxs)("div",{className:"space-y-3 rounded-md border p-3",children:[(0,Y.jsxs)("div",{className:"space-y-1.5",children:[(0,Y.jsx)(wK.Label,{className:"text-xs",children:n("subscription.platform")}),(0,Y.jsx)("div",{className:"flex gap-1.5",children:wZ.map(e=>(0,Y.jsx)(yQ.Button,{size:"sm",variant:s.provider===e.value?"default":"secondary",className:"h-7 text-xs",onClick:()=>{var t;return t=e.value,void(s&&u({...s,provider:t,cookie:"",headers:wJ(t)}))},children:e.label},e.value))})]}),(0,Y.jsxs)("div",{className:"space-y-1.5",children:[(0,Y.jsx)(wK.Label,{className:"text-xs",children:n("subscription.label")}),(0,Y.jsx)(wq.Input,{className:"h-8 text-xs",value:s.label,onChange:e=>u({...s,label:e.target.value}),placeholder:n("subscription.labelPlaceholder")})]}),"cookie"===h&&(0,Y.jsxs)("div",{className:"space-y-1.5",children:[(0,Y.jsx)(wK.Label,{className:"text-xs",children:"Cookie"}),(0,Y.jsx)(wq.Input,{className:"h-8 text-xs font-mono",value:s.cookie,onChange:e=>u({...s,cookie:e.target.value}),placeholder:n("subscription.cookiePlaceholder")})]}),"headers"===h&&(0,Y.jsxs)("div",{className:"space-y-1.5",children:[(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsx)(wK.Label,{className:"text-xs",children:n("subscription.headers")}),(0,Y.jsxs)(yQ.Button,{variant:"ghost",size:"sm",className:"h-5 text-[10px] gap-0.5 px-1",onClick:()=>{s&&u({...s,headers:[...s.headers,{id:wQ++,key:"",value:""}]})},children:[(0,Y.jsx)(w$.Plus,{className:"size-2.5"})," ",n("subscription.addHeader")]})]}),(0,Y.jsxs)("div",{className:"space-y-1.5",children:[s.headers.map(e=>(0,Y.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,Y.jsx)(wq.Input,{className:"h-7 flex-[2] text-xs font-mono",value:e.key,onChange:t=>p(e.id,"key",t.target.value),placeholder:"Header-Key"}),(0,Y.jsx)(wq.Input,{className:"h-7 flex-[3] text-xs font-mono",value:e.value,onChange:t=>p(e.id,"value",t.target.value),placeholder:"value"}),(0,Y.jsx)(yQ.Button,{variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:()=>{var t;return t=e.id,void(s&&u({...s,headers:s.headers.filter(e=>e.id!==t)}))},children:(0,Y.jsx)(wG.Trash2,{className:"size-3 text-muted-foreground"})})]},e.id)),0===s.headers.length&&(0,Y.jsx)("p",{className:"text-[10px] text-muted-foreground text-center py-1",children:n("subscription.noHeaders")})]})]}),(0,Y.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,Y.jsx)(yQ.Button,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>u(null),children:n("subscription.cancel")}),(0,Y.jsx)(yQ.Button,{size:"sm",className:"h-7 text-xs",onClick:d,disabled:!g,children:n("subscription.save")})]})]}),!s&&(0,Y.jsxs)(yQ.Button,{size:"sm",variant:"outline",className:"w-full h-7 text-xs gap-1",onClick:()=>((e="zhipu")=>{u({provider:e,label:"",cookie:"",headers:wJ(e)})})(),children:[(0,Y.jsx)(w$.Plus,{className:"size-3"}),n("subscription.add")]})]})]})]})}let w3={TIME_LIMIT:"时间额度",TOKENS_LIMIT:"Token 额度","MiniMax-M*":"MiniMax-M*","coding-plan-vlm":"Coding Plan VLM","coding-plan-search":"Coding Plan Search",balance:"余额",bonusBalance:"赠送余额"};function w6(){let e=(0,Z.useTranslations)("home"),[t,r]=(0,q.useState)([]),[n,i]=(0,q.useState)(new Map),[o,a]=(0,q.useState)(!1),[l,s]=(0,q.useState)(0),[u,c]=(0,q.useState)(null),d=(0,q.useCallback)(async()=>{let e=await fetch("/api/subscriptions");e.ok&&r(await e.json())},[]),f=(0,q.useCallback)(async e=>{a(!0);let t=new Map;await Promise.allSettled(e.map(async e=>{try{let r=await fetch(`/api/subscriptions/${e.id}/quota`);if(r.ok)t.set(e.id,{data:await r.json()});else{let n=await r.json().catch(()=>({}));t.set(e.id,{error:n.error??`${r.status} ${r.statusText}`})}}catch(r){t.set(e.id,{error:r instanceof Error?r.message:"Network error"})}})),i(t),a(!1)},[]);(0,q.useEffect)(()=>{d()},[d,l]),(0,q.useEffect)(()=>{t.length>0&&f(t)},[t,f]);let p=()=>s(e=>e+1),h=e=>(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Y.jsx)("span",{className:"text-xs font-medium",children:e.label}),(0,Y.jsxs)("span",{className:"text-[10px] text-muted-foreground capitalize",children:["(",e.provider,")"]})]}),(0,Y.jsx)(yQ.Button,{variant:"ghost",size:"icon",className:"size-5",onClick:()=>c(e),children:(0,Y.jsx)(wU.Pencil,{className:"size-3 text-muted-foreground"})})]});return 0===t.length?(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("subscription.planTitle")}),(0,Y.jsx)(w2,{onChange:p})]}):(0,Y.jsxs)("div",{className:"space-y-3",children:[(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("subscription.planTitle")}),(0,Y.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,Y.jsx)(yQ.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:()=>f(t),disabled:o,children:(0,Y.jsx)(wH.RefreshCw,{className:`size-3 text-muted-foreground ${o?"animate-spin":""}`})}),(0,Y.jsx)(w2,{onChange:p,editConfig:u,onEditClear:()=>c(null)})]})]}),t.map(t=>{let r=n.get(t.id);if(!r)return(0,Y.jsxs)("div",{className:"rounded-md border px-3 py-2 space-y-2",children:[h(t),(0,Y.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,Y.jsxs)("div",{className:"rounded-md bg-muted/30 px-3 py-2 space-y-1",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-12"}),(0,Y.jsx)(wI.Skeleton,{className:"h-5 w-16"})]}),(0,Y.jsxs)("div",{className:"rounded-md bg-muted/30 px-3 py-2 space-y-1",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-12"}),(0,Y.jsx)(wI.Skeleton,{className:"h-5 w-16"})]})]})]},t.id);if("error"in r)return(0,Y.jsxs)("div",{className:"rounded-md border border-red-200 bg-red-50 dark:border-red-900 dark:bg-red-950/30 px-3 py-2",children:[h(t),(0,Y.jsx)("p",{className:"mt-1 text-[11px] text-red-600 dark:text-red-400",children:r.error})]},t.id);let i=r.data,o=i.limits.some(e=>"balance"===e.type||"bonusBalance"===e.type);return(0,Y.jsxs)("div",{className:"space-y-2 rounded-md border px-3 py-2.5",children:[h(t),o?(0,Y.jsx)("div",{className:"grid grid-cols-2 gap-2",children:i.limits.map((e,t)=>(0,Y.jsxs)("div",{className:"rounded-md bg-muted/50 px-3 py-2",children:[(0,Y.jsx)("div",{className:"text-[10px] text-muted-foreground",children:w3[e.type]||e.type}),(0,Y.jsx)("div",{className:"mt-0.5 font-semibold text-sm tabular-nums",children:e.currentValue?.toFixed(2)??"—"})]},t))}):i.limits.map((t,r)=>{let n=function(e){if("TIME_LIMIT"===e.type){if(void 0!==e.currentValue&&void 0!==e.usage)return`${e.currentValue} / ${e.usage}`;if(void 0!==e.percentage)return`${e.percentage}%`}if(void 0!==e.remaining&&void 0!==e.usage){let t=e.remaining+e.usage;return`${e.remaining} / ${t}`}return null}(t),i=t.percentage;return(0,Y.jsxs)("div",{className:"space-y-1",children:[(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsx)("span",{className:"text-[11px] text-muted-foreground",children:w3[t.type]||t.type}),n&&(0,Y.jsx)("span",{className:"font-mono text-[11px] tabular-nums",children:n})]}),void 0!==i&&(0,Y.jsx)("div",{className:"h-1 overflow-hidden rounded-full bg-muted",children:(0,Y.jsx)("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:`${Math.min(100,i)}%`}})}),t.usageDetails&&t.usageDetails.length>0&&(0,Y.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 pl-2",children:t.usageDetails.map(e=>(0,Y.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e.modelCode,": ",e.usage]},e.modelCode))}),t.nextResetTime&&(0,Y.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e("subscription.resetAt")," ",new Date(t.nextResetTime).toLocaleString()]})]},r)})]},t.id)})]})}let w5=[[/claude/i,"anthropic"],[/gpt|o1-|o3-|o4-|chatgpt/i,"openai"],[/gemini/i,"gemini"],[/deepseek/i,"deepseek"],[/qwen/i,"alibaba"],[/glm|chatglm/i,"zhipu"],[/moonshot|kimi/i,"kimi"],[/doubao/i,"doubao"],[/llama/i,"meta"],[/mistral/i,"mistral"],[/codestral/i,"mistral"]];function w4(e){if(!e)return"";for(let[t,r]of w5)if(t.test(e))return(0,yZ.resolveServerAssetUrl)(`/static/provider-icons/${r}.svg`);return""}let w7=[{key:"today",days:1},{key:"7d",days:7},{key:"30d",days:30},{key:"1y",days:365}];function w8(){let e=(0,Z.useTranslations)("home"),[t,r]=(0,q.useState)("30d"),[n,i]=(0,q.useState)(),[o,a]=(0,q.useState)(null),l=(0,q.useCallback)(t=>{let r=Date.now()-new Date(t).getTime();if(!Number.isFinite(r)||r<0)return e("time.justNow");let n=Math.floor(r/6e4);if(n<1)return e("time.justNow");if(n<60)return e("time.minutesAgo",{n:n});let i=Math.floor(n/60);return i<24?e("time.hoursAgo",{n:i}):e("time.daysAgo",{n:Math.floor(i/24)})},[e]),s=[{accessorKey:"role",header:e("table.agent"),cell:({row:e})=>{let{role:t,runtime:r}=e.original;return(0,Y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,Y.jsx)("span",{className:"font-medium text-xs capitalize",children:t}),r&&(0,Y.jsx)("span",{className:"text-muted-foreground text-[10px]",children:r})]})}},{accessorKey:"model",header:e("table.model"),cell:({row:t})=>{let r=t.original.model,n=w4(r);return(0,Y.jsxs)("div",{className:"flex items-center gap-2",children:[n?(0,Y.jsx)("img",{src:n,alt:"",className:"size-4 shrink-0 rounded-sm"}):(0,Y.jsx)("span",{className:(0,xk.cn)("flex size-4 shrink-0 items-center justify-center rounded-sm text-[9px] font-semibold",(0,xk.textColorClass)(r??"?")),children:r?.charAt(0).toUpperCase()??"?"}),(0,Y.jsx)("span",{className:"truncate text-xs max-w-40",children:r||e("table.modelUnknown")})]})}},{accessorKey:"summary",header:e("table.summary"),cell:({row:e})=>(0,Y.jsx)("span",{className:"line-clamp-2 text-xs text-muted-foreground max-w-64",children:e.original.summary||"—"})},{accessorKey:"totalCostUsd",header:e("table.cost"),cell:({row:t})=>{let{inputCostUsd:r,outputCostUsd:n,totalCostUsd:i}=t.original;return(0,Y.jsxs)("div",{className:"flex flex-col gap-0.5 font-mono text-xs tabular-nums",children:[(0,Y.jsx)("span",{children:Ol(i)}),(0,Y.jsxs)(wW.Tooltip,{children:[(0,Y.jsxs)(wW.TooltipTrigger,{render:(0,Y.jsx)("span",{className:"text-muted-foreground text-[10px] cursor-default"}),children:[Oa(t.original.inputTokens)," ",e("table.tokensIn")," / ",Oa(t.original.outputTokens)," ",e("table.tokensOut")]}),(0,Y.jsxs)(wW.TooltipContent,{side:"bottom",className:"text-xs",children:[e("table.total")," ",Oa(t.original.totalTokens)," · ",e("table.cacheHit")," ",t.original.inputTokens>0?Math.round(t.original.cachedInputTokens/t.original.inputTokens*100):0,"%"]})]})]})}},{accessorKey:"status",header:e("table.status"),cell:({row:e})=>{let t=e.original.status;return(0,Y.jsx)(yX.Badge,{className:(0,xk.cn)("rounded-sm px-1.5 text-[10px] capitalize",{completed:"bg-emerald-500/10 text-emerald-600",active:"bg-blue-500/10 text-blue-600",idle:"bg-muted text-muted-foreground",blocked:"bg-amber-500/10 text-amber-600",crashed:"bg-red-500/10 text-red-600"}[t]??"bg-muted text-muted-foreground"),children:t})}},{accessorKey:"durationMs",header:e("table.duration"),cell:({row:e})=>{let{startedAt:t,completedAt:r}=e.original,n=new Date(r).getTime()-new Date(t).getTime();return(0,Y.jsx)("span",{className:"font-mono text-xs tabular-nums",children:Os(Number.isFinite(n)&&n>0?n:0)})}},{accessorKey:"completedAt",header:e("table.time"),cell:({row:e})=>(0,Y.jsx)("span",{className:"text-muted-foreground text-xs",children:l(e.original.completedAt)})}],u=(0,q.useCallback)(()=>"custom"===t&&n?function(e,t){let[r,n]=(0,yH.normalizeDates)(void 0,e,t),i=yG(r,n),o=Math.abs((0,y$.differenceInCalendarDays)(r,n));r.setDate(r.getDate()-i*o);let a=Number(yG(r,n)===-i),l=i*(o-a);return 0===l?0:l}(n.to,n.from)+1:w7.find(e=>e.key===t)?.days??30,[t,n]);if((0,q.useEffect)(()=>{let e=new AbortController,t=u();return fetch(`/api/agents/usage/dashboard?days=${t}`,{signal:e.signal}).then(e=>e.ok?e.json():null).then(e=>a(e)).catch(()=>a(null)),()=>e.abort()},[u]),null===o)return(0,Y.jsxs)(xA.Card,{className:"col-span-full gap-0 overflow-hidden rounded-lg py-0",children:[(0,Y.jsxs)("div",{className:"flex items-center gap-3 border-b px-4 py-3",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-5 w-32"}),(0,Y.jsx)("div",{className:"flex items-center gap-1",children:w7.map(e=>(0,Y.jsx)(wI.Skeleton,{className:"h-5 w-8 rounded-full"},e.key))})]}),(0,Y.jsx)("div",{className:"grid grid-cols-2 border-b sm:grid-cols-4",children:Array.from({length:4},(e,t)=>(0,Y.jsxs)("div",{className:"px-4 py-3 space-y-2",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-16"}),(0,Y.jsx)(wI.Skeleton,{className:"h-6 w-20"}),(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-12"})]},t))}),(0,Y.jsxs)("div",{className:"grid border-b lg:grid-cols-3",children:[(0,Y.jsxs)("div",{className:"border-b p-4 lg:col-span-2 lg:border-r lg:border-b-0",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-24 mb-3"}),(0,Y.jsx)("div",{className:"flex h-[132px] items-end gap-2",children:Array.from({length:14},(e,t)=>(0,Y.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col items-center gap-1",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-8"}),(0,Y.jsx)(wI.Skeleton,{className:"h-16 w-full rounded-sm"})]},t))})]}),(0,Y.jsxs)("div",{className:"p-4",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-20 mb-3"}),(0,Y.jsx)("div",{className:"space-y-2.5",children:Array.from({length:4},(e,t)=>(0,Y.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Y.jsx)(wI.Skeleton,{className:"size-4 rounded-full"}),(0,Y.jsx)(wI.Skeleton,{className:"h-3 flex-1"}),(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-12"})]},t))})]})]})]});let c=o.totals??{requests:0,inputTokens:0,outputTokens:0,totalTokens:0,totalCostUsd:0,avgDurationMs:0},d=o.daily??[],f=o.byModel??[],p=o.recent??[],h=Math.max(1,...d.map(e=>e.totalTokens)),g=Math.max(1,...f.map(e=>e.costUsd));return(0,Y.jsxs)(xA.Card,{className:"col-span-full gap-0 overflow-hidden rounded-lg py-0",children:[(0,Y.jsxs)("div",{className:"flex items-center gap-3 border-b px-4 py-3",children:[(0,Y.jsx)("span",{className:"font-medium text-sm",children:e("title")}),(0,Y.jsxs)("div",{className:"flex items-center gap-1",children:[w7.map(n=>(0,Y.jsx)(yX.Badge,{variant:t===n.key?"default":"secondary",className:"h-5 cursor-pointer rounded-full font-normal text-[10px] transition-colors",onClick:()=>{r(n.key),i(void 0)},children:e(`period.${"7d"===n.key?"7d":"30d"===n.key?"30d":"1y"===n.key?"1y":n.key}`)},n.key)),(0,Y.jsxs)(wT.Popover,{children:[(0,Y.jsx)(wT.PopoverTrigger,{nativeButton:!1,render:(0,Y.jsx)(yX.Badge,{variant:"custom"===t?"default":"secondary",className:"h-5 cursor-pointer rounded-full font-normal text-[10px] transition-colors",children:e("period.custom")})}),(0,Y.jsx)(wT.PopoverContent,{className:"w-auto p-0",align:"start",children:(0,Y.jsx)(xD,{mode:"range",defaultMonth:n?.from??yK(new Date,-30,void 0),selected:n?{from:n.from,to:n.to}:void 0,onSelect:e=>{e?.from&&e?.to&&(i({from:e.from,to:e.to}),r("custom"))},numberOfMonths:2})})]})]})]}),(0,Y.jsxs)("div",{className:"grid grid-cols-2 border-b sm:grid-cols-4",children:[(0,Y.jsx)(Oe,{label:e("metric.agentRuns"),value:Oo(c.requests),helper:e("metric.agentRunsHelper"),icon:eo.Zap,totalCostLabel:e("metric.totalCost")}),(0,Y.jsx)(Oe,{label:e("metric.tokensUsed"),value:Oa(c.totalTokens),helper:`${Oa(c.inputTokens)} ${e("metric.tokensIn")}`,icon:en.Cpu,totalCostLabel:e("metric.totalCost")}),(0,Y.jsx)(Oe,{label:e("metric.totalCost"),value:Ol(c.totalCostUsd),helper:e("metric.totalCostHelper"),icon:ei,totalCostLabel:e("metric.totalCost")}),(0,Y.jsx)(Oe,{label:e("metric.avgDuration"),value:Os(c.avgDurationMs),helper:e("metric.avgDurationHelper"),icon:er,last:!0,totalCostLabel:e("metric.totalCost")})]}),(0,Y.jsxs)("div",{className:"grid border-b lg:grid-cols-3",children:[(0,Y.jsxs)("div",{className:"border-b p-4 lg:col-span-2 lg:border-r lg:border-b-0",children:[(0,Y.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("chart.dailyTokenUsage")}),(0,Y.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Y.jsx)(Ot,{className:"bg-foreground",label:e("chart.input")}),(0,Y.jsx)(Ot,{className:"bg-foreground/40",label:e("chart.output")})]})]}),(0,Y.jsxs)("div",{className:"flex h-[132px] items-end gap-2 sm:gap-3",children:[d.slice(-14).map(e=>{let t=Math.max(3,e.inputTokens/h*100),r=Math.max(3,(e.inputTokens+e.outputTokens)/h*100);return(0,Y.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col items-center gap-1",children:[(0,Y.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground tabular-nums",children:Oa(e.totalTokens)}),(0,Y.jsxs)("div",{className:"relative h-20 w-full",children:[(0,Y.jsx)("div",{className:"absolute inset-x-0 bottom-0 h-full rounded-sm bg-muted/40"}),(0,Y.jsx)("div",{className:"absolute inset-x-0 bottom-0 rounded-t-sm bg-foreground/40",style:{height:`${r}%`}}),(0,Y.jsx)("div",{className:"absolute inset-x-0 bottom-0 rounded-t-sm bg-foreground",style:{height:`${t}%`}})]}),(0,Y.jsx)("span",{className:"text-[10px] text-muted-foreground",children:e.label})]},e.date)}),0===d.length?(0,Y.jsx)(Oi,{label:e("chart.noTokenData")}):null]})]}),(0,Y.jsxs)("div",{className:"p-4",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("chart.costByModel")}),(0,Y.jsx)("div",{className:"mt-3 space-y-2.5",children:0===f.length?(0,Y.jsx)("p",{className:"text-muted-foreground text-xs",children:e("chart.noUsageRecords")}):f.map((e,t)=>{let r;return(0,Y.jsxs)("div",{className:"rounded-md px-2 py-1.5 transition-colors hover:bg-muted/50",children:[(0,Y.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,Y.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(r=w4(e.model))?(0,Y.jsx)("img",{src:r,alt:"",className:"size-4 shrink-0 rounded-sm"}):(0,Y.jsx)("span",{className:(0,xk.cn)("flex size-4 shrink-0 items-center justify-center rounded-sm text-[9px] font-semibold",(0,xk.textColorClass)(e.model??"?")),children:e.model?.charAt(0).toUpperCase()??"?"}),(0,Y.jsx)("span",{className:"truncate text-xs",children:e.model})]}),(0,Y.jsx)("span",{className:"font-mono text-xs font-semibold tabular-nums",children:Ol(e.costUsd)})]}),(0,Y.jsx)("div",{className:"mt-1 h-1 overflow-hidden rounded-full bg-muted",children:(0,Y.jsx)("div",{className:(0,xk.cn)("h-full rounded-full",0===t?"bg-foreground":"bg-foreground/60"),style:{width:`${Math.max(4,e.costUsd/g*100)}%`}})})]},e.model)})})]})]}),(0,Y.jsxs)("div",{className:"grid border-b lg:grid-cols-2",children:[(0,Y.jsxs)("div",{className:"border-b p-4 lg:border-r lg:border-b-0",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("chart.tokenDistribution")}),(0,Y.jsx)(Or,{inputTokens:c.inputTokens,outputTokens:c.outputTokens})]}),(0,Y.jsxs)("div",{className:"p-4",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("chart.costDistribution")}),(0,Y.jsx)(On,{byModel:f,totalCost:c.totalCostUsd})]})]}),(0,Y.jsx)("div",{className:"p-4",children:(0,Y.jsx)(w6,{})}),(0,Y.jsx)(w9,{data:p,columns:s,formatRelative:l})]})}function w9({data:e,columns:t,formatRelative:r}){let n=(0,Z.useTranslations)("home"),[i,o]=(0,q.useState)({pageIndex:0,pageSize:5}),a=function(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[r]=q.useState(()=>({current:function(e){var t,r;let n=[...e$,...null!=(t=e._features)?t:[]],i={_features:n},o=i._features.reduce((e,t)=>Object.assign(e,null==t.getDefaultOptions?void 0:t.getDefaultOptions(i)),{}),a={...null!=(r=e.initialState)?r:{}};i._features.forEach(e=>{var t;a=null!=(t=null==e.getInitialState?void 0:e.getInitialState(a))?t:a});let l=[],s=!1,u={_features:n,options:{...o,...e},initialState:a,_queue:e=>{l.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;l.length;)l.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{i.setState(i.initialState)},setOptions:e=>{var t;t=ea(e,i.options),i.options=i.options.mergeOptions?i.options.mergeOptions(o,t):{...o,...t}},getState:()=>i.options.state,setState:e=>{null==i.options.onStateChange||i.options.onStateChange(e)},_getRowId:(e,t,r)=>{var n;return null!=(n=null==i.options.getRowId?void 0:i.options.getRowId(e,t,r))?n:`${r?[r.id,t].join("."):t}`},getCoreRowModel:()=>(i._getCoreRowModel||(i._getCoreRowModel=i.options.getCoreRowModel(i)),i._getCoreRowModel()),getRowModel:()=>i.getPaginationRowModel(),getRow:(e,t)=>{let r=(t?i.getPrePaginationRowModel():i.getRowModel()).rowsById[e];if(!r&&!(r=i.getCoreRowModel().rowsById[e]))throw Error();return r},_getDefaultColumnDef:eu(()=>[i.options.defaultColumn],e=>{var t;return e=null!=(t=e)?t:{},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t,r;return null!=(t=null==(r=e.renderValue())||null==r.toString?void 0:r.toString())?t:null},...i._features.reduce((e,t)=>Object.assign(e,null==t.getDefaultColumnDef?void 0:t.getDefaultColumnDef()),{}),...e}},ec(e,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>i.options.columns,getAllColumns:eu(()=>[i._getColumnDefs()],e=>{let t=function(e,r,n){return void 0===n&&(n=0),e.map(e=>{let o=function(e,t,r,n){var i,o;let a,l={...e._getDefaultColumnDef(),...t},s=l.accessorKey,u=null!=(i=null!=(o=l.id)?o:s?"function"==typeof String.prototype.replaceAll?s.replaceAll(".","_"):s.replace(/\./g,"_"):void 0)?i:"string"==typeof l.header?l.header:void 0;if(l.accessorFn?a=l.accessorFn:s&&(a=s.includes(".")?e=>{let t=e;for(let e of s.split(".")){var r;t=null==(r=t)?void 0:r[e]}return t}:e=>e[l.accessorKey]),!u)throw Error();let c={id:`${String(u)}`,accessorFn:a,parent:n,depth:r,columnDef:l,columns:[],getFlatColumns:eu(()=>[!0],()=>{var e;return[c,...null==(e=c.columns)?void 0:e.flatMap(e=>e.getFlatColumns())]},ec(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:eu(()=>[e._getOrderColumnsFn()],e=>{var t;return null!=(t=c.columns)&&t.length?e(c.columns.flatMap(e=>e.getLeafColumns())):[c]},ec(e.options,"debugColumns","column.getLeafColumns"))};for(let t of e._features)null==t.createColumn||t.createColumn(c,e);return c}(i,e,n,r);return o.columns=e.columns?t(e.columns,o,n+1):[],o})};return t(e)},ec(e,"debugColumns","getAllColumns")),getAllFlatColumns:eu(()=>[i.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),ec(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:eu(()=>[i.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),ec(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:eu(()=>[i.getAllColumns(),i._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),ec(e,"debugColumns","getAllLeafColumns")),getColumn:e=>i._getAllFlatColumnsById()[e]};Object.assign(i,u);for(let e=0;e<i._features.length;e++){let t=i._features[e];null==t||null==t.createTable||t.createTable(i)}return i}(t)})),[n,i]=q.useState(()=>r.current.initialState);return r.current.setOptions(t=>({...t,...e,state:{...n,...e.state},onStateChange:t=>{i(t),null==e.onStateChange||e.onStateChange(t)}})),r.current}({data:e,columns:t,getCoreRowModel:e=>eu(()=>[e.options.data],t=>{let r={rows:[],flatRows:[],rowsById:{}},n=function(t,i,o){void 0===i&&(i=0);let a=[];for(let s=0;s<t.length;s++){let u=eh(e,e._getRowId(t[s],s,o),t[s],s,i,void 0,null==o?void 0:o.id);if(r.flatRows.push(u),r.rowsById[u.id]=u,a.push(u),e.options.getSubRows){var l;u.originalSubRows=e.options.getSubRows(t[s],s),null!=(l=u.originalSubRows)&&l.length&&(u.subRows=n(u.originalSubRows,i+1,u))}}return a};return r.rows=n(t),r},ec(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex())),getPaginationRowModel:e=>eu(()=>[e.getState().pagination,e.getPrePaginationRowModel(),e.options.paginateExpandedRows?void 0:e.getState().expanded],(t,r)=>{let n;if(!r.rows.length)return r;let{pageSize:i,pageIndex:o}=t,{rows:a,flatRows:l,rowsById:s}=r,u=i*o;if(a=a.slice(u,u+i),e.options.paginateExpandedRows)n={rows:a,flatRows:l,rowsById:s};else{var c;let e,t;c={rows:a,flatRows:l,rowsById:s},e=[],t=r=>{var n;e.push(r),null!=(n=r.subRows)&&n.length&&r.getIsExpanded()&&r.subRows.forEach(t)},c.rows.forEach(t),n={rows:e,flatRows:c.flatRows,rowsById:c.rowsById}}n.flatRows=[];let d=e=>{n.flatRows.push(e),e.subRows.length&&e.subRows.forEach(d)};return n.rows.forEach(d),n},ec(e.options,"debugTable","getPaginationRowModel")),getSortedRowModel:e=>eu(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,r)=>{if(!r.rows.length||!(null!=t&&t.length))return r;let n=e.getState().sorting,i=[],o=n.filter(t=>{var r;return null==(r=e.getColumn(t.id))?void 0:r.getCanSort()}),a={};o.forEach(t=>{let r=e.getColumn(t.id);r&&(a[t.id]={sortUndefined:r.columnDef.sortUndefined,invertSorting:r.columnDef.invertSorting,sortingFn:r.getSortingFn()})});let l=e=>{let t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let n=0;n<o.length;n+=1){var r;let i=o[n],l=a[i.id],s=l.sortUndefined,u=null!=(r=null==i?void 0:i.desc)&&r,c=0;if(s){let r=e.getValue(i.id),n=t.getValue(i.id),o=void 0===r,a=void 0===n;if(o||a){if("first"===s)return o?-1:1;if("last"===s)return o?1:-1;c=o&&a?0:o?s:-s}}if(0===c&&(c=l.sortingFn(e,t,i.id)),0!==c)return u&&(c*=-1),l.invertSorting&&(c*=-1),c}return e.index-t.index}),t.forEach(e=>{var t;i.push(e),null!=(t=e.subRows)&&t.length&&(e.subRows=l(e.subRows))}),t};return{rows:l(r.rows),flatRows:i,rowsById:r.rowsById}},ec(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex())),getFilteredRowModel:e=>eu(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,r,n)=>{var i,o,a,l,s,u,c,d,f,p;let h,g,m,v,y,b,x,w,O,S;if(!t.rows.length||!(null!=r&&r.length)&&!n){for(let e=0;e<t.flatRows.length;e++)t.flatRows[e].columnFilters={},t.flatRows[e].columnFiltersMeta={};return t}let j=[],M=[];(null!=r?r:[]).forEach(t=>{var r;let n=e.getColumn(t.id);if(!n)return;let i=n.getFilterFn();i&&j.push({id:t.id,filterFn:i,resolvedValue:null!=(r=null==i.resolveFilterValue?void 0:i.resolveFilterValue(t.value))?r:t.value})});let C=(null!=r?r:[]).map(e=>e.id),_=e.getGlobalFilterFn(),P=e.getAllLeafColumns().filter(e=>e.getCanGlobalFilter());n&&_&&P.length&&(C.push("__global__"),P.forEach(e=>{var t;M.push({id:e.id,filterFn:_,resolvedValue:null!=(t=null==_.resolveFilterValue?void 0:_.resolveFilterValue(n))?t:n})}));for(let e=0;e<t.flatRows.length;e++){let r=t.flatRows[e];if(r.columnFilters={},j.length)for(let e=0;e<j.length;e++){let t=(h=j[e]).id;r.columnFilters[t]=h.filterFn(r,t,h.resolvedValue,e=>{r.columnFiltersMeta[t]=e})}if(M.length){for(let e=0;e<M.length;e++){let t=(g=M[e]).id;if(g.filterFn(r,t,g.resolvedValue,e=>{r.columnFiltersMeta[t]=e})){r.columnFilters.__global__=!0;break}}!0!==r.columnFilters.__global__&&(r.columnFilters.__global__=!1)}}return i=t.rows,o=e=>{for(let t=0;t<C.length;t++)if(!1===e.columnFilters[C[t]])return!1;return!0},e.options.filterFromLeafRows?(a=i,l=o,m=[],v={},y=null!=(u=(s=e).options.maxLeafRowFilterDepth)?u:100,{rows:(b=function(e,t){void 0===t&&(t=0);let r=[];for(let i=0;i<e.length;i++){var n;let o=e[i],a=eh(s,o.id,o.original,o.index,o.depth,void 0,o.parentId);if(a.columnFilters=o.columnFilters,null!=(n=o.subRows)&&n.length&&t<y){if(a.subRows=b(o.subRows,t+1),l(o=a)&&!a.subRows.length||l(o)||a.subRows.length){r.push(o),v[o.id]=o,m.push(o);continue}}else l(o=a)&&(r.push(o),v[o.id]=o,m.push(o))}return r})(a),flatRows:m,rowsById:v}):(c=i,d=o,x=[],w={},O=null!=(p=(f=e).options.maxLeafRowFilterDepth)?p:100,{rows:(S=function(e,t){void 0===t&&(t=0);let r=[];for(let i=0;i<e.length;i++){let o=e[i];if(d(o)){var n;if(null!=(n=o.subRows)&&n.length&&t<O){let e=eh(f,o.id,o.original,o.index,o.depth,void 0,o.parentId);e.subRows=S(o.subRows,t+1),o=e}r.push(o),x.push(o),w[o.id]=o}}return r})(c),flatRows:x,rowsById:w})},ec(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex())),onPaginationChange:o,state:{pagination:i}}),{pages:l,showLeftEllipsis:s,showRightEllipsis:u}=function({currentPage:e,totalPages:t,paginationItemsToDisplay:r}){let n=function(){if(t<=r)return Array.from({length:t},(e,t)=>t+1);let n=Math.floor(r/2),i={start:e-n,end:e+n},o={start:Math.max(1,i.start),end:Math.min(t,i.end)};return 1===o.start&&(o.end=Math.min(r,t)),o.end===t&&(o.start=Math.max(1,t-r+1)),Array.from({length:o.end-o.start+1},(e,t)=>o.start+t)}(),i=n.length>0&&n[0]>1&&n[0]>2,o=n.length>0&&n[n.length-1]<t&&n[n.length-1]<t-1;return{pages:n,showLeftEllipsis:i,showRightEllipsis:o}}({currentPage:a.getState().pagination.pageIndex+1,totalPages:a.getPageCount(),paginationItemsToDisplay:2});return 0===e.length?(0,Y.jsx)("div",{className:"p-6 text-center text-xs text-muted-foreground",children:n("table.emptyMessage")}):(0,Y.jsxs)("div",{className:"w-full",children:[(0,Y.jsx)("div",{className:"border-b",children:(0,Y.jsxs)(wR,{children:[(0,Y.jsx)(wF,{children:a.getHeaderGroups().map(e=>(0,Y.jsx)(wL,{children:e.headers.map(e=>(0,Y.jsx)(wB,{className:"text-muted-foreground h-10 first:pl-4",children:e.isPlaceholder?null:eG(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,Y.jsx)(wz,{children:a.getRowModel().rows?.length?a.getRowModel().rows.map(e=>(0,Y.jsx)(wL,{children:e.getVisibleCells().map(e=>(0,Y.jsx)(wV,{className:"first:pl-4 py-2.5",children:eG(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,Y.jsx)(wL,{children:(0,Y.jsx)(wV,{colSpan:t.length,className:"h-24 text-center",children:n("table.noResults")})})})]})}),(0,Y.jsxs)("div",{className:"flex items-center justify-between gap-3 px-6 py-3 max-sm:flex-col md:max-lg:flex-col",children:[(0,Y.jsxs)("p",{className:"text-muted-foreground text-sm whitespace-nowrap","aria-live":"polite",children:[n("pagination.showing")," ",(0,Y.jsxs)("span",{children:[5*a.getState().pagination.pageIndex+1," ",n("pagination.to")," ",Math.min((a.getState().pagination.pageIndex+1)*5,a.getRowCount())]})," ",n("pagination.of")," ",(0,Y.jsx)("span",{children:a.getRowCount()})," ",n("pagination.entries")]}),(0,Y.jsx)(wE,{className:"mx-0 ml-auto w-auto justify-end",children:(0,Y.jsxs)(wD,{children:[(0,Y.jsx)(wN,{children:(0,Y.jsxs)(yQ.Button,{className:"disabled:pointer-events-none disabled:opacity-50",variant:"ghost",onClick:()=>a.previousPage(),disabled:!a.getCanPreviousPage(),"aria-label":n("pagination.prevAriaLabel"),children:[(0,Y.jsx)(ee,{"aria-hidden":"true"}),n("pagination.previous")]})}),s&&(0,Y.jsx)(wN,{children:(0,Y.jsx)(wA,{})}),l.map(e=>{let t=e===a.getState().pagination.pageIndex+1;return(0,Y.jsx)(wN,{children:(0,Y.jsx)(yQ.Button,{size:"icon",className:(0,xk.cn)(!t&&"bg-primary/10 text-primary hover:bg-primary/20"),onClick:()=>a.setPageIndex(e-1),"aria-current":t?"page":void 0,children:e})},e)}),u&&(0,Y.jsx)(wN,{children:(0,Y.jsx)(wA,{})}),(0,Y.jsx)(wN,{children:(0,Y.jsxs)(yQ.Button,{className:"disabled:pointer-events-none disabled:opacity-50",variant:"ghost",onClick:()=>a.nextPage(),disabled:!a.getCanNextPage(),"aria-label":n("pagination.nextAriaLabel"),children:[n("pagination.next"),(0,Y.jsx)(et.ChevronRightIcon,{"aria-hidden":"true"})]})})]})})]})]})}function Oe({label:e,value:t,helper:r,icon:n,last:i,totalCostLabel:o}){return(0,Y.jsxs)("div",{className:(0,xk.cn)("px-4 py-3",!i&&"border-r"),children:[(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsx)("span",{className:"text-muted-foreground text-xs",children:e}),(0,Y.jsx)(n,{className:"size-3.5 text-muted-foreground"})]}),(0,Y.jsx)("div",{className:"mt-1 font-semibold text-2xl tabular-nums",children:t}),(0,Y.jsxs)("div",{className:"mt-1 flex items-center gap-1",children:[e===o?(0,Y.jsx)(X.ArrowDown,{className:"size-3 text-emerald-500"}):(0,Y.jsx)(Q.ArrowUp,{className:"size-3 text-emerald-500"}),(0,Y.jsx)("span",{className:"text-muted-foreground text-[10px]",children:r})]})]})}function Ot({className:e,label:t}){return(0,Y.jsxs)("span",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[(0,Y.jsx)("span",{className:(0,xk.cn)("size-2 rounded-sm",e)}),t]})}function Or({inputTokens:e,outputTokens:t}){let r=(0,Z.useTranslations)("home"),n=e+t,i={input:{label:r("chart.input"),color:"var(--primary)"},output:{label:r("chart.output"),color:"color-mix(in oklab, var(--primary) 40%, transparent)"}};return(0,Y.jsxs)("div",{className:"mt-2",children:[(0,Y.jsx)(wj,{config:i,className:"mx-auto h-40 w-full",children:(0,Y.jsxs)(yU,{margin:{top:0,bottom:0,left:0,right:0},children:[(0,Y.jsx)(wC,{cursor:!1,content:(0,Y.jsx)(w_,{hideLabel:!0})}),(0,Y.jsx)(g8,{data:[{key:"input",value:e,fill:"var(--color-input)"},{key:"output",value:t,fill:"var(--color-output)"}],dataKey:"value",nameKey:"key",startAngle:90,endAngle:450,innerRadius:48,outerRadius:68,paddingAngle:2,children:(0,Y.jsx)(aS,{content:({viewBox:e})=>{if(e&&"cx"in e&&"cy"in e)return(0,Y.jsxs)("text",{x:e.cx,y:e.cy,textAnchor:"middle",dominantBaseline:"middle",children:[(0,Y.jsx)("tspan",{x:e.cx,y:(e.cy||0)-8,className:"fill-card-foreground text-sm font-medium",children:Oa(n)}),(0,Y.jsx)("tspan",{x:e.cx,y:(e.cy||0)+10,className:"fill-muted-foreground text-[10px]",children:r("chart.tokens")})]})}})})]})}),(0,Y.jsxs)("div",{className:"flex items-center justify-center gap-4",children:[(0,Y.jsx)(Ot,{className:"bg-primary",label:`${r("chart.input")} ${n?Math.round(e/n*100):0}%`}),(0,Y.jsx)(Ot,{className:"bg-primary/40",label:`${r("chart.output")} ${n?Math.round(t/n*100):0}%`})]})]})}function On({byModel:e,totalCost:t}){let r=(0,Z.useTranslations)("home");if(0===e.length)return(0,Y.jsx)("p",{className:"mt-4 text-center text-xs text-muted-foreground",children:r("chart.noCostData")});let n=e.slice(0,5),i=n.map(e=>({key:e.model,value:e.costUsd,fill:(0,xk.textToColor)(e.model)})),o=Object.fromEntries(n.map(e=>[e.model,{label:e.model,color:(0,xk.textToColor)(e.model)}]));return(0,Y.jsxs)("div",{className:"mt-2",children:[(0,Y.jsx)(wj,{config:o,className:"mx-auto h-40 w-full",children:(0,Y.jsxs)(yU,{margin:{top:0,bottom:0,left:0,right:0},children:[(0,Y.jsx)(wC,{cursor:!1,content:(0,Y.jsx)(w_,{hideLabel:!0})}),(0,Y.jsx)(g8,{data:i,dataKey:"value",nameKey:"key",startAngle:90,endAngle:450,innerRadius:48,outerRadius:68,paddingAngle:2,children:(0,Y.jsx)(aS,{content:({viewBox:e})=>{if(e&&"cx"in e&&"cy"in e)return(0,Y.jsxs)("text",{x:e.cx,y:e.cy,textAnchor:"middle",dominantBaseline:"middle",children:[(0,Y.jsx)("tspan",{x:e.cx,y:(e.cy||0)-8,className:"fill-card-foreground text-sm font-medium",children:Ol(t)}),(0,Y.jsx)("tspan",{x:e.cx,y:(e.cy||0)+10,className:"fill-muted-foreground text-[10px]",children:r("chart.totalCost")})]})}})})]})}),(0,Y.jsx)("div",{className:"mt-1 space-y-0.5",children:n.map(e=>(0,Y.jsxs)("div",{className:"flex items-center justify-between px-1",children:[(0,Y.jsx)("span",{className:"truncate text-[10px]",children:e.model}),(0,Y.jsx)("span",{className:"font-mono text-[10px] tabular-nums",children:Ol(e.costUsd)})]},e.model))})]})}function Oi({label:e}){return(0,Y.jsx)("div",{className:"flex flex-1 items-center justify-center rounded-md border border-dashed text-xs text-muted-foreground",children:e})}function Oo(e){return new Intl.NumberFormat("en-US").format(e)}function Oa(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:Oo(e)}function Ol(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:4}).format(e)}function Os(e){return e?e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.round(e/6e4)}m`:"0ms"}var Ou=e.i(524),Oc=e.i(361031);function Od({initialWorkspaces:e}){let t=(0,Oc.useWorkspaceStore)(e=>e.setWorkspaces),r=(0,Oc.useWorkspaceStore)(e=>e.upsertWorkspace),[n,i]=(0,q.useState)(!1);(0,q.useEffect)(()=>{t(e)},[e,t]);let o=async e=>{let t=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});r(await t.json())};return(0,Y.jsxs)("div",{className:"flex h-full w-full flex-col overflow-auto",children:[(0,Y.jsx)("main",{className:"w-full flex-1 px-4 py-6 sm:px-6",children:(0,Y.jsx)(w8,{})}),(0,Y.jsx)(Ou.WorkspaceDialog,{open:n,onOpenChange:i,onSubmit:o})]})}var Of=e.i(437122),Op=e.i(233297);e.s(["default",0,function(){let[e,t]=(0,q.useState)([]),r=(0,K.useRouter)();return(0,q.useEffect)(()=>{fetch("/api/workspaces",{headers:(0,Of.authHeaders)()}).then(e=>e.ok?e.json():[]).then(e=>{if(t(e),"true"===localStorage.getItem("autoActivateWorkspace")&&!sessionStorage.getItem("autoActivateSkipped")){let t=localStorage.getItem("lastWorkspaceId");t&&e.some(e=>e.id===t)&&(sessionStorage.setItem("autoActivateSkipped","1"),(0,Op.tauriNavigate)(r,`/workspace/${t}`,!0))}})},[r]),(0,Y.jsx)(Od,{initialWorkspaces:e})}],330997)}]);
8
+ `).join("\n")}}):null},wC=function(e){var t,r,n,i,o,a,l,s,u,c,d=t_(e,wi),{active:f,allowEscapeViewBox:p,animationDuration:h,animationEasing:g,content:m,filterNull:v,isAnimationActive:y,offset:b,payloadUniqBy:x,position:w,reverseDirection:O,useTranslate3d:S,wrapperStyle:j,cursor:M,shared:C,trigger:_,defaultIndex:P,portal:k,axisId:E}=d,D=tX(),N="number"==typeof P?String(P):P;(0,q.useEffect)(()=>{D(hn({shared:C,trigger:_,axisId:E,active:f,defaultIndex:N}))},[D,C,_,E,f,N]);var A=i7(),T=v8(),I=t1(e=>hv(e,C)),{activeIndex:R,isActive:F}=null!=(u=t1(e=>mA(e,I,_,N)))?u:{},z=t1(e=>mN(e,I,_,N)),L=t1(e=>mD(e,I,_,N)),B=t1(e=>mE(e,I,_,N)),V=(0,q.useContext)(yv),W=null!=(c=null!=f?f:F)&&c,[U,H]=xZ([z,W]),$="axis"===I?L:void 0;t=t1(e=>((e,t,r)=>{if(null!=t){var n=hC(e);return"axis"===t?"hover"===r?n.axisInteraction.hover.dataKey:n.axisInteraction.click.dataKey:"hover"===r?n.itemInteraction.hover.dataKey:n.itemInteraction.click.dataKey}})(e,I,_)),r=t1(gu),n=t1(a$),i=t1(aU),o=t1(aH),l=null==(a=t1(yp))?void 0:a.active,s=i7(),(0,q.useEffect)(()=>{if(!l&&null!=i&&null!=n){var e=hc({active:W,coordinate:B,dataKey:t,index:R,label:"number"==typeof $?String($):$,sourceViewBox:s,graphicalItemId:r});yc.emit(yd,i,e,n)}},[l,B,t,r,R,$,n,i,o,W,s]);var G=null!=k?k:V;if(null==G||null==A||null==I)return null;var Y=null!=z?z:wn;W||(Y=wn),v&&Y.length&&(Y=xK(Y.filter(e=>null!=e.value&&(!0!==e.hide||d.includeHidden)),x,wr));var K=Y.length>0,Z=wt(wt({},d),{},{payload:Y,label:$,active:W,activeIndex:R,coordinate:B,accessibilityLayer:T}),X=q.createElement(xY,{allowEscapeViewBox:p,animationDuration:h,animationEasing:g,isAnimationActive:y,active:W,coordinate:B,hasPayload:K,offset:b,position:w,reverseDirection:O,useTranslate3d:S,viewBox:A,wrapperStyle:j,lastBoundingBox:U,innerRef:H,hasPortalFromProps:!!k},q.isValidElement(m)?q.cloneElement(m,Z):"function"==typeof m?q.createElement(m,Z):q.createElement(xV,Z));return q.createElement(q.Fragment,null,(0,ox.createPortal)(X,G),W&&q.createElement(x9,{cursor:M,tooltipEventType:I,coordinate:B,payload:Y,index:R}))};function w_({active:e,payload:t,className:r,indicator:n="dot",hideLabel:i=!1,hideIndicator:o=!1,label:a,labelFormatter:l,labelClassName:s,formatter:u,color:c,nameKey:d,labelKey:f}){let{config:p}=function(){let e=q.useContext(wS);if(!e)throw Error("useChart must be used within a <ChartContainer />");return e}(),h=q.useMemo(()=>{if(i||!t?.length)return null;let[e]=t,r=`${f??e?.dataKey??e?.name??"value"}`,n=wP(p,e,r),o=f||"string"!=typeof a?n?.label:p[a]?.label??a;return l?(0,Y.jsx)("div",{className:(0,xk.cn)("font-medium",s),children:l(o,t)}):o?(0,Y.jsx)("div",{className:(0,xk.cn)("font-medium",s),children:o}):null},[a,l,t,i,s,p,f]);if(!e||!t?.length)return null;let g=1===t.length&&"dot"!==n;return(0,Y.jsxs)("div",{className:(0,xk.cn)("grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[g?null:h,(0,Y.jsx)("div",{className:"grid gap-1.5",children:t.filter(e=>"none"!==e.type).map((e,t)=>{let r=`${d??e.name??e.dataKey??"value"}`,i=wP(p,e,r),a=c??e.payload?.fill??e.color;return(0,Y.jsx)("div",{className:(0,xk.cn)("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground","dot"===n&&"items-center"),children:u&&e?.value!==void 0&&e.name?u(e.value,e.name,e,t,e.payload):(0,Y.jsxs)(Y.Fragment,{children:[i?.icon?(0,Y.jsx)(i.icon,{}):!o&&(0,Y.jsx)("div",{className:(0,xk.cn)("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",{"h-2.5 w-2.5":"dot"===n,"w-1":"line"===n,"w-0 border-[1.5px] border-dashed bg-transparent":"dashed"===n,"my-0.5":g&&"dashed"===n}),style:{"--color-bg":a,"--color-border":a}}),(0,Y.jsxs)("div",{className:(0,xk.cn)("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[(0,Y.jsxs)("div",{className:"grid gap-1.5",children:[g?h:null,(0,Y.jsx)("span",{className:"text-muted-foreground",children:i?.label??e.name})]}),null!=e.value&&(0,Y.jsx)("span",{className:"font-mono font-medium text-foreground tabular-nums",children:"number"==typeof e.value?e.value.toLocaleString():String(e.value)})]})]})},t)})})]})}function wP(e,t,r){if("object"!=typeof t||null===t)return;let n="payload"in t&&"object"==typeof t.payload&&null!==t.payload?t.payload:void 0,i=r;return r in t&&"string"==typeof t[r]?i=t[r]:n&&r in n&&"string"==typeof n[r]&&(i=n[r]),i in e?e[i]:e[r]}var wk=e.i(226651),wk=wk;function wE({className:e,...t}){return(0,Y.jsx)("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:(0,xk.cn)("mx-auto flex w-full justify-center",e),...t})}function wD({className:e,...t}){return(0,Y.jsx)("ul",{"data-slot":"pagination-content",className:(0,xk.cn)("flex items-center gap-0.5",e),...t})}function wN({...e}){return(0,Y.jsx)("li",{"data-slot":"pagination-item",...e})}function wA({className:e,...t}){return(0,Y.jsxs)("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:(0,xk.cn)("flex size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4",e),...t,children:[(0,Y.jsx)(wk.default,{}),(0,Y.jsx)("span",{className:"sr-only",children:"More pages"})]})}var wT=e.i(996652),wI=e.i(613087);function wR({className:e,...t}){return(0,Y.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,Y.jsx)("table",{"data-slot":"table",className:(0,xk.cn)("w-full caption-bottom text-sm",e),...t})})}function wF({className:e,...t}){return(0,Y.jsx)("thead",{"data-slot":"table-header",className:(0,xk.cn)("[&_tr]:border-b",e),...t})}function wz({className:e,...t}){return(0,Y.jsx)("tbody",{"data-slot":"table-body",className:(0,xk.cn)("[&_tr:last-child]:border-0",e),...t})}function wL({className:e,...t}){return(0,Y.jsx)("tr",{"data-slot":"table-row",className:(0,xk.cn)("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function wB({className:e,...t}){return(0,Y.jsx)("th",{"data-slot":"table-head",className:(0,xk.cn)("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",e),...t})}function wV({className:e,...t}){return(0,Y.jsx)("td",{"data-slot":"table-cell",className:(0,xk.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",e),...t})}var wW=e.i(638322),wU=e.i(962562),wH=e.i(601039),w$=e.i(953700),wG=e.i(137340),wY=e.i(209988),wq=e.i(681622),wK=e.i(817854);let wZ=[{value:"zhipu",label:"智谱 (ZhiPu)",authMode:"headers"},{value:"minimax",label:"MiniMax",authMode:"cookie"},{value:"aicode",label:"AI Code",authMode:"cookie"}],wX={zhipu:[{key:"Authorization",value:""}]},wQ=1;function wJ(e){return wX[e]?.map(e=>({...e,id:wQ++}))??[]}function w0(e){return wZ.find(t=>t.value===e)?.authMode??"headers"}function w1(e){var t;return{id:e.id,provider:e.provider,label:e.label,cookie:e.cookie??"",headers:(t=e.headers)&&0!==Object.keys(t).length?Object.entries(t).map(([e,t])=>({id:wQ++,key:e,value:t})):[]}}function w2({onChange:e,editConfig:t,onEditClear:r}){let n=(0,Z.useTranslations)("home"),[i,o]=(0,q.useState)(!1),[a,l]=(0,q.useState)([]),[s,u]=(0,q.useState)(null),c=(0,q.useCallback)(async()=>{let e=await fetch("/api/subscriptions");e.ok&&l(await e.json())},[]);(0,q.useEffect)(()=>{t&&(u(w1(t)),o(!0))},[t]),(0,q.useEffect)(()=>{i&&c()},[i,c]);let d=async()=>{if(!s)return;let t=w0(s.provider),r={provider:s.provider,label:s.label||s.provider};if("cookie"===t)r.cookie=s.cookie;else{let e;r.headers=(e=s.headers.filter(e=>e.key.trim()).map(e=>[e.key.trim(),e.value])).length>0?Object.fromEntries(e):void 0}let n=s.id?`/api/subscriptions/${s.id}`:"/api/subscriptions",i=s.id?"PUT":"POST";(await fetch(n,{method:i,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).ok&&(u(null),await c(),e?.())},f=async t=>{await fetch(`/api/subscriptions/${t}`,{method:"DELETE"}),await c(),e?.()},p=(e,t,r)=>{s&&u({...s,headers:s.headers.map(n=>n.id===e?{...n,[t]:r}:n)})},h=s?w0(s.provider):null,g=s&&("cookie"===h?!!s.cookie.trim():s.headers.some(e=>e.key.trim()&&e.value.trim()));return(0,Y.jsxs)(wY.Dialog,{open:i,onOpenChange:e=>{o(e),e||(u(null),r?.())},children:[(0,Y.jsx)(wY.DialogTrigger,{nativeButton:!0,render:(0,Y.jsxs)(yQ.Button,{variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs",children:[(0,Y.jsx)(w$.Plus,{className:"size-3.5"}),n("subscription.addPlatform")]})}),(0,Y.jsxs)(wY.DialogContent,{className:"sm:max-w-lg",children:[(0,Y.jsx)(wY.DialogHeader,{children:(0,Y.jsx)(wY.DialogTitle,{className:"text-sm",children:n(s?.id?"subscription.editTitle":"subscription.title")})}),(0,Y.jsxs)("div",{className:"space-y-3",children:[!s&&a.map(e=>(0,Y.jsxs)("div",{className:"flex items-center justify-between rounded-md border px-3 py-2",children:[(0,Y.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,Y.jsx)("span",{className:"text-xs font-medium",children:e.label}),(0,Y.jsxs)("span",{className:"text-[10px] text-muted-foreground capitalize",children:["(",e.provider,")"]})]}),(0,Y.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,Y.jsx)(yQ.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:()=>u(w1(e)),children:(0,Y.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"size-3 text-muted-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,Y.jsx)("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),(0,Y.jsx)("path",{d:"m15 5 4 4"})]})}),(0,Y.jsx)(yQ.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:()=>f(e.id),children:(0,Y.jsx)(wG.Trash2,{className:"size-3 text-muted-foreground"})})]})]},e.id)),!s&&0===a.length&&(0,Y.jsx)("p",{className:"text-center text-xs text-muted-foreground py-2",children:n("subscription.empty")}),s&&h&&(0,Y.jsxs)("div",{className:"space-y-3 rounded-md border p-3",children:[(0,Y.jsxs)("div",{className:"space-y-1.5",children:[(0,Y.jsx)(wK.Label,{className:"text-xs",children:n("subscription.platform")}),(0,Y.jsx)("div",{className:"flex gap-1.5",children:wZ.map(e=>(0,Y.jsx)(yQ.Button,{size:"sm",variant:s.provider===e.value?"default":"secondary",className:"h-7 text-xs",onClick:()=>{var t;return t=e.value,void(s&&u({...s,provider:t,cookie:"",headers:wJ(t)}))},children:e.label},e.value))})]}),(0,Y.jsxs)("div",{className:"space-y-1.5",children:[(0,Y.jsx)(wK.Label,{className:"text-xs",children:n("subscription.label")}),(0,Y.jsx)(wq.Input,{className:"h-8 text-xs",value:s.label,onChange:e=>u({...s,label:e.target.value}),placeholder:n("subscription.labelPlaceholder")})]}),"cookie"===h&&(0,Y.jsxs)("div",{className:"space-y-1.5",children:[(0,Y.jsx)(wK.Label,{className:"text-xs",children:"Cookie"}),(0,Y.jsx)(wq.Input,{className:"h-8 text-xs font-mono",value:s.cookie,onChange:e=>u({...s,cookie:e.target.value}),placeholder:n("subscription.cookiePlaceholder")})]}),"headers"===h&&(0,Y.jsxs)("div",{className:"space-y-1.5",children:[(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsx)(wK.Label,{className:"text-xs",children:n("subscription.headers")}),(0,Y.jsxs)(yQ.Button,{variant:"ghost",size:"sm",className:"h-5 text-[10px] gap-0.5 px-1",onClick:()=>{s&&u({...s,headers:[...s.headers,{id:wQ++,key:"",value:""}]})},children:[(0,Y.jsx)(w$.Plus,{className:"size-2.5"})," ",n("subscription.addHeader")]})]}),(0,Y.jsxs)("div",{className:"space-y-1.5",children:[s.headers.map(e=>(0,Y.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,Y.jsx)(wq.Input,{className:"h-7 flex-[2] text-xs font-mono",value:e.key,onChange:t=>p(e.id,"key",t.target.value),placeholder:"Header-Key"}),(0,Y.jsx)(wq.Input,{className:"h-7 flex-[3] text-xs font-mono",value:e.value,onChange:t=>p(e.id,"value",t.target.value),placeholder:"value"}),(0,Y.jsx)(yQ.Button,{variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:()=>{var t;return t=e.id,void(s&&u({...s,headers:s.headers.filter(e=>e.id!==t)}))},children:(0,Y.jsx)(wG.Trash2,{className:"size-3 text-muted-foreground"})})]},e.id)),0===s.headers.length&&(0,Y.jsx)("p",{className:"text-[10px] text-muted-foreground text-center py-1",children:n("subscription.noHeaders")})]})]}),(0,Y.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,Y.jsx)(yQ.Button,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>u(null),children:n("subscription.cancel")}),(0,Y.jsx)(yQ.Button,{size:"sm",className:"h-7 text-xs",onClick:d,disabled:!g,children:n("subscription.save")})]})]}),!s&&(0,Y.jsxs)(yQ.Button,{size:"sm",variant:"outline",className:"w-full h-7 text-xs gap-1",onClick:()=>((e="zhipu")=>{u({provider:e,label:"",cookie:"",headers:wJ(e)})})(),children:[(0,Y.jsx)(w$.Plus,{className:"size-3"}),n("subscription.add")]})]})]})]})}function w3(){let e=(0,Z.useTranslations)("home"),[t,r]=(0,q.useState)([]),[n,i]=(0,q.useState)(new Map),[o,a]=(0,q.useState)(!1),[l,s]=(0,q.useState)(0),[u,c]=(0,q.useState)(null),d=(0,q.useCallback)(async()=>{let e=await fetch("/api/subscriptions");e.ok&&r(await e.json())},[]),f=(0,q.useCallback)(async t=>{a(!0);let r=new Map;await Promise.allSettled(t.map(async t=>{try{let e=await fetch(`/api/subscriptions/${t.id}/quota`);if(e.ok)r.set(t.id,{data:await e.json()});else{let n=await e.json().catch(()=>({}));r.set(t.id,{error:n.error??`${e.status} ${e.statusText}`})}}catch(n){r.set(t.id,{error:n instanceof Error?n.message:e("subscription.networkError")})}})),i(r),a(!1)},[]);(0,q.useEffect)(()=>{d()},[d,l]),(0,q.useEffect)(()=>{t.length>0&&f(t)},[t,f]);let p=()=>s(e=>e+1),h=e=>(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Y.jsx)("span",{className:"text-xs font-medium",children:e.label}),(0,Y.jsxs)("span",{className:"text-[10px] text-muted-foreground capitalize",children:["(",e.provider,")"]})]}),(0,Y.jsx)(yQ.Button,{variant:"ghost",size:"icon",className:"size-5",onClick:()=>c(e),children:(0,Y.jsx)(wU.Pencil,{className:"size-3 text-muted-foreground"})})]});return 0===t.length?(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("subscription.planTitle")}),(0,Y.jsx)(w2,{onChange:p})]}):(0,Y.jsxs)("div",{className:"space-y-3",children:[(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("subscription.planTitle")}),(0,Y.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,Y.jsx)(yQ.Button,{variant:"ghost",size:"icon",className:"size-6",onClick:()=>f(t),disabled:o,children:(0,Y.jsx)(wH.RefreshCw,{className:`size-3 text-muted-foreground ${o?"animate-spin":""}`})}),(0,Y.jsx)(w2,{onChange:p,editConfig:u,onEditClear:()=>c(null)})]})]}),t.map(t=>{let r=n.get(t.id);if(!r)return(0,Y.jsxs)("div",{className:"rounded-md border px-3 py-2 space-y-2",children:[h(t),(0,Y.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,Y.jsxs)("div",{className:"rounded-md bg-muted/30 px-3 py-2 space-y-1",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-12"}),(0,Y.jsx)(wI.Skeleton,{className:"h-5 w-16"})]}),(0,Y.jsxs)("div",{className:"rounded-md bg-muted/30 px-3 py-2 space-y-1",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-12"}),(0,Y.jsx)(wI.Skeleton,{className:"h-5 w-16"})]})]})]},t.id);if("error"in r)return(0,Y.jsxs)("div",{className:"rounded-md border border-red-200 bg-red-50 dark:border-red-900 dark:bg-red-950/30 px-3 py-2",children:[h(t),(0,Y.jsx)("p",{className:"mt-1 text-[11px] text-red-600 dark:text-red-400",children:r.error})]},t.id);let i=r.data,o=i.limits.some(e=>"balance"===e.type||"bonusBalance"===e.type);return(0,Y.jsxs)("div",{className:"space-y-2 rounded-md border px-3 py-2.5",children:[h(t),o?(0,Y.jsx)("div",{className:"grid grid-cols-2 gap-2",children:i.limits.map((t,r)=>(0,Y.jsxs)("div",{className:"rounded-md bg-muted/50 px-3 py-2",children:[(0,Y.jsx)("div",{className:"text-[10px] text-muted-foreground",children:e(`subscription.limitTypes.${t.type}`)||t.type}),(0,Y.jsx)("div",{className:"mt-0.5 font-semibold text-sm tabular-nums",children:t.currentValue?.toFixed(2)??"—"})]},r))}):i.limits.map((t,r)=>{let n=function(e){if("TIME_LIMIT"===e.type){if(void 0!==e.currentValue&&void 0!==e.usage)return`${e.currentValue} / ${e.usage}`;if(void 0!==e.percentage)return`${e.percentage}%`}if(void 0!==e.remaining&&void 0!==e.usage){let t=e.remaining+e.usage;return`${e.remaining} / ${t}`}return null}(t),i=t.percentage;return(0,Y.jsxs)("div",{className:"space-y-1",children:[(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsx)("span",{className:"text-[11px] text-muted-foreground",children:e(`subscription.limitTypes.${t.type}`)||t.type}),n&&(0,Y.jsx)("span",{className:"font-mono text-[11px] tabular-nums",children:n})]}),void 0!==i&&(0,Y.jsx)("div",{className:"h-1 overflow-hidden rounded-full bg-muted",children:(0,Y.jsx)("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:`${Math.min(100,i)}%`}})}),t.usageDetails&&t.usageDetails.length>0&&(0,Y.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 pl-2",children:t.usageDetails.map(e=>(0,Y.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e.modelCode,": ",e.usage]},e.modelCode))}),t.nextResetTime&&(0,Y.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e("subscription.resetAt")," ",new Date(t.nextResetTime).toLocaleString()]})]},r)})]},t.id)})]})}let w6=[[/claude/i,"anthropic"],[/gpt|o1-|o3-|o4-|chatgpt/i,"openai"],[/gemini/i,"gemini"],[/deepseek/i,"deepseek"],[/qwen/i,"alibaba"],[/glm|chatglm/i,"zhipu"],[/moonshot|kimi/i,"kimi"],[/doubao/i,"doubao"],[/llama/i,"meta"],[/mistral/i,"mistral"],[/codestral/i,"mistral"]];function w5(e){if(!e)return"";for(let[t,r]of w6)if(t.test(e))return(0,yZ.resolveServerAssetUrl)(`/static/provider-icons/${r}.svg`);return""}let w4=[{key:"today",days:1},{key:"7d",days:7},{key:"30d",days:30},{key:"1y",days:365}];function w7(){let e=(0,Z.useTranslations)("home"),[t,r]=(0,q.useState)("30d"),[n,i]=(0,q.useState)(),[o,a]=(0,q.useState)(null),l=(0,q.useCallback)(t=>{let r=Date.now()-new Date(t).getTime();if(!Number.isFinite(r)||r<0)return e("time.justNow");let n=Math.floor(r/6e4);if(n<1)return e("time.justNow");if(n<60)return e("time.minutesAgo",{n:n});let i=Math.floor(n/60);return i<24?e("time.hoursAgo",{n:i}):e("time.daysAgo",{n:Math.floor(i/24)})},[e]),s=[{accessorKey:"role",header:e("table.agent"),cell:({row:e})=>{let{role:t,runtime:r}=e.original;return(0,Y.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,Y.jsx)("span",{className:"font-medium text-xs capitalize",children:t}),r&&(0,Y.jsx)("span",{className:"text-muted-foreground text-[10px]",children:r})]})}},{accessorKey:"model",header:e("table.model"),cell:({row:t})=>{let r=t.original.model,n=w5(r);return(0,Y.jsxs)("div",{className:"flex items-center gap-2",children:[n?(0,Y.jsx)("img",{src:n,alt:"",className:"size-4 shrink-0 rounded-sm"}):(0,Y.jsx)("span",{className:(0,xk.cn)("flex size-4 shrink-0 items-center justify-center rounded-sm text-[9px] font-semibold",(0,xk.textColorClass)(r??"?")),children:r?.charAt(0).toUpperCase()??"?"}),(0,Y.jsx)("span",{className:"truncate text-xs max-w-40",children:r||e("table.modelUnknown")})]})}},{accessorKey:"summary",header:e("table.summary"),cell:({row:e})=>(0,Y.jsx)("span",{className:"line-clamp-2 text-xs text-muted-foreground max-w-64",children:e.original.summary||"—"})},{accessorKey:"totalCostUsd",header:e("table.cost"),cell:({row:t})=>{let{inputCostUsd:r,outputCostUsd:n,totalCostUsd:i}=t.original;return(0,Y.jsxs)("div",{className:"flex flex-col gap-0.5 font-mono text-xs tabular-nums",children:[(0,Y.jsx)("span",{children:Oa(i)}),(0,Y.jsxs)(wW.Tooltip,{children:[(0,Y.jsxs)(wW.TooltipTrigger,{render:(0,Y.jsx)("span",{className:"text-muted-foreground text-[10px] cursor-default"}),children:[Oo(t.original.inputTokens)," ",e("table.tokensIn")," / ",Oo(t.original.outputTokens)," ",e("table.tokensOut")]}),(0,Y.jsxs)(wW.TooltipContent,{side:"bottom",className:"text-xs",children:[e("table.total")," ",Oo(t.original.totalTokens)," · ",e("table.cacheHit")," ",t.original.inputTokens>0?Math.round(t.original.cachedInputTokens/t.original.inputTokens*100):0,"%"]})]})]})}},{accessorKey:"status",header:e("table.status"),cell:({row:e})=>{let t=e.original.status;return(0,Y.jsx)(yX.Badge,{className:(0,xk.cn)("rounded-sm px-1.5 text-[10px] capitalize",{completed:"bg-emerald-500/10 text-emerald-600",active:"bg-blue-500/10 text-blue-600",idle:"bg-muted text-muted-foreground",blocked:"bg-amber-500/10 text-amber-600",crashed:"bg-red-500/10 text-red-600"}[t]??"bg-muted text-muted-foreground"),children:t})}},{accessorKey:"durationMs",header:e("table.duration"),cell:({row:e})=>{let{startedAt:t,completedAt:r}=e.original,n=new Date(r).getTime()-new Date(t).getTime();return(0,Y.jsx)("span",{className:"font-mono text-xs tabular-nums",children:Ol(Number.isFinite(n)&&n>0?n:0)})}},{accessorKey:"completedAt",header:e("table.time"),cell:({row:e})=>(0,Y.jsx)("span",{className:"text-muted-foreground text-xs",children:l(e.original.completedAt)})}],u=(0,q.useCallback)(()=>"custom"===t&&n?function(e,t){let[r,n]=(0,yH.normalizeDates)(void 0,e,t),i=yG(r,n),o=Math.abs((0,y$.differenceInCalendarDays)(r,n));r.setDate(r.getDate()-i*o);let a=Number(yG(r,n)===-i),l=i*(o-a);return 0===l?0:l}(n.to,n.from)+1:w4.find(e=>e.key===t)?.days??30,[t,n]);if((0,q.useEffect)(()=>{let e=new AbortController,t=u();return fetch(`/api/agents/usage/dashboard?days=${t}`,{signal:e.signal}).then(e=>e.ok?e.json():null).then(e=>a(e)).catch(()=>a(null)),()=>e.abort()},[u]),null===o)return(0,Y.jsxs)(xA.Card,{className:"col-span-full gap-0 overflow-hidden rounded-lg py-0",children:[(0,Y.jsxs)("div",{className:"flex items-center gap-3 border-b px-4 py-3",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-5 w-32"}),(0,Y.jsx)("div",{className:"flex items-center gap-1",children:w4.map(e=>(0,Y.jsx)(wI.Skeleton,{className:"h-5 w-8 rounded-full"},e.key))})]}),(0,Y.jsx)("div",{className:"grid grid-cols-2 border-b sm:grid-cols-4",children:Array.from({length:4},(e,t)=>(0,Y.jsxs)("div",{className:"px-4 py-3 space-y-2",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-16"}),(0,Y.jsx)(wI.Skeleton,{className:"h-6 w-20"}),(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-12"})]},t))}),(0,Y.jsxs)("div",{className:"grid border-b lg:grid-cols-3",children:[(0,Y.jsxs)("div",{className:"border-b p-4 lg:col-span-2 lg:border-r lg:border-b-0",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-24 mb-3"}),(0,Y.jsx)("div",{className:"flex h-[132px] items-end gap-2",children:Array.from({length:14},(e,t)=>(0,Y.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col items-center gap-1",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-8"}),(0,Y.jsx)(wI.Skeleton,{className:"h-16 w-full rounded-sm"})]},t))})]}),(0,Y.jsxs)("div",{className:"p-4",children:[(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-20 mb-3"}),(0,Y.jsx)("div",{className:"space-y-2.5",children:Array.from({length:4},(e,t)=>(0,Y.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Y.jsx)(wI.Skeleton,{className:"size-4 rounded-full"}),(0,Y.jsx)(wI.Skeleton,{className:"h-3 flex-1"}),(0,Y.jsx)(wI.Skeleton,{className:"h-3 w-12"})]},t))})]})]})]});let c=o.totals??{requests:0,inputTokens:0,outputTokens:0,totalTokens:0,totalCostUsd:0,avgDurationMs:0},d=o.daily??[],f=o.byModel??[],p=o.recent??[],h=Math.max(1,...d.map(e=>e.totalTokens)),g=Math.max(1,...f.map(e=>e.costUsd));return(0,Y.jsxs)(xA.Card,{className:"col-span-full gap-0 overflow-hidden rounded-lg py-0",children:[(0,Y.jsxs)("div",{className:"flex items-center gap-3 border-b px-4 py-3",children:[(0,Y.jsx)("span",{className:"font-medium text-sm",children:e("title")}),(0,Y.jsxs)("div",{className:"flex items-center gap-1",children:[w4.map(n=>(0,Y.jsx)(yX.Badge,{variant:t===n.key?"default":"secondary",className:"h-5 cursor-pointer rounded-full font-normal text-[10px] transition-colors",onClick:()=>{r(n.key),i(void 0)},children:e(`period.${"7d"===n.key?"7d":"30d"===n.key?"30d":"1y"===n.key?"1y":n.key}`)},n.key)),(0,Y.jsxs)(wT.Popover,{children:[(0,Y.jsx)(wT.PopoverTrigger,{nativeButton:!1,render:(0,Y.jsx)(yX.Badge,{variant:"custom"===t?"default":"secondary",className:"h-5 cursor-pointer rounded-full font-normal text-[10px] transition-colors",children:e("period.custom")})}),(0,Y.jsx)(wT.PopoverContent,{className:"w-auto p-0",align:"start",children:(0,Y.jsx)(xD,{mode:"range",defaultMonth:n?.from??yK(new Date,-30,void 0),selected:n?{from:n.from,to:n.to}:void 0,onSelect:e=>{e?.from&&e?.to&&(i({from:e.from,to:e.to}),r("custom"))},numberOfMonths:2})})]})]})]}),(0,Y.jsxs)("div",{className:"grid grid-cols-2 border-b sm:grid-cols-4",children:[(0,Y.jsx)(w9,{label:e("metric.agentRuns"),value:Oi(c.requests),helper:e("metric.agentRunsHelper"),icon:eo.Zap,totalCostLabel:e("metric.totalCost")}),(0,Y.jsx)(w9,{label:e("metric.tokensUsed"),value:Oo(c.totalTokens),helper:`${Oo(c.inputTokens)} ${e("metric.tokensIn")}`,icon:en.Cpu,totalCostLabel:e("metric.totalCost")}),(0,Y.jsx)(w9,{label:e("metric.totalCost"),value:Oa(c.totalCostUsd),helper:e("metric.totalCostHelper"),icon:ei,totalCostLabel:e("metric.totalCost")}),(0,Y.jsx)(w9,{label:e("metric.avgDuration"),value:Ol(c.avgDurationMs),helper:e("metric.avgDurationHelper"),icon:er,last:!0,totalCostLabel:e("metric.totalCost")})]}),(0,Y.jsxs)("div",{className:"grid border-b lg:grid-cols-3",children:[(0,Y.jsxs)("div",{className:"border-b p-4 lg:col-span-2 lg:border-r lg:border-b-0",children:[(0,Y.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("chart.dailyTokenUsage")}),(0,Y.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Y.jsx)(Oe,{className:"bg-foreground",label:e("chart.input")}),(0,Y.jsx)(Oe,{className:"bg-foreground/40",label:e("chart.output")})]})]}),(0,Y.jsxs)("div",{className:"flex h-[132px] items-end gap-2 sm:gap-3",children:[d.slice(-14).map(e=>{let t=Math.max(3,e.inputTokens/h*100),r=Math.max(3,(e.inputTokens+e.outputTokens)/h*100);return(0,Y.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col items-center gap-1",children:[(0,Y.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground tabular-nums",children:Oo(e.totalTokens)}),(0,Y.jsxs)("div",{className:"relative h-20 w-full",children:[(0,Y.jsx)("div",{className:"absolute inset-x-0 bottom-0 h-full rounded-sm bg-muted/40"}),(0,Y.jsx)("div",{className:"absolute inset-x-0 bottom-0 rounded-t-sm bg-foreground/40",style:{height:`${r}%`}}),(0,Y.jsx)("div",{className:"absolute inset-x-0 bottom-0 rounded-t-sm bg-foreground",style:{height:`${t}%`}})]}),(0,Y.jsx)("span",{className:"text-[10px] text-muted-foreground",children:e.label})]},e.date)}),0===d.length?(0,Y.jsx)(On,{label:e("chart.noTokenData")}):null]})]}),(0,Y.jsxs)("div",{className:"p-4",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("chart.costByModel")}),(0,Y.jsx)("div",{className:"mt-3 space-y-2.5",children:0===f.length?(0,Y.jsx)("p",{className:"text-muted-foreground text-xs",children:e("chart.noUsageRecords")}):f.map((e,t)=>{let r;return(0,Y.jsxs)("div",{className:"rounded-md px-2 py-1.5 transition-colors hover:bg-muted/50",children:[(0,Y.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,Y.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(r=w5(e.model))?(0,Y.jsx)("img",{src:r,alt:"",className:"size-4 shrink-0 rounded-sm"}):(0,Y.jsx)("span",{className:(0,xk.cn)("flex size-4 shrink-0 items-center justify-center rounded-sm text-[9px] font-semibold",(0,xk.textColorClass)(e.model??"?")),children:e.model?.charAt(0).toUpperCase()??"?"}),(0,Y.jsx)("span",{className:"truncate text-xs",children:e.model})]}),(0,Y.jsx)("span",{className:"font-mono text-xs font-semibold tabular-nums",children:Oa(e.costUsd)})]}),(0,Y.jsx)("div",{className:"mt-1 h-1 overflow-hidden rounded-full bg-muted",children:(0,Y.jsx)("div",{className:(0,xk.cn)("h-full rounded-full",0===t?"bg-foreground":"bg-foreground/60"),style:{width:`${Math.max(4,e.costUsd/g*100)}%`}})})]},e.model)})})]})]}),(0,Y.jsxs)("div",{className:"grid border-b lg:grid-cols-2",children:[(0,Y.jsxs)("div",{className:"border-b p-4 lg:border-r lg:border-b-0",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("chart.tokenDistribution")}),(0,Y.jsx)(Ot,{inputTokens:c.inputTokens,outputTokens:c.outputTokens})]}),(0,Y.jsxs)("div",{className:"p-4",children:[(0,Y.jsx)("span",{className:"font-medium text-xs",children:e("chart.costDistribution")}),(0,Y.jsx)(Or,{byModel:f,totalCost:c.totalCostUsd})]})]}),(0,Y.jsx)("div",{className:"p-4",children:(0,Y.jsx)(w3,{})}),(0,Y.jsx)(w8,{data:p,columns:s,formatRelative:l})]})}function w8({data:e,columns:t,formatRelative:r}){let n=(0,Z.useTranslations)("home"),[i,o]=(0,q.useState)({pageIndex:0,pageSize:5}),a=function(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[r]=q.useState(()=>({current:function(e){var t,r;let n=[...e$,...null!=(t=e._features)?t:[]],i={_features:n},o=i._features.reduce((e,t)=>Object.assign(e,null==t.getDefaultOptions?void 0:t.getDefaultOptions(i)),{}),a={...null!=(r=e.initialState)?r:{}};i._features.forEach(e=>{var t;a=null!=(t=null==e.getInitialState?void 0:e.getInitialState(a))?t:a});let l=[],s=!1,u={_features:n,options:{...o,...e},initialState:a,_queue:e=>{l.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;l.length;)l.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{i.setState(i.initialState)},setOptions:e=>{var t;t=ea(e,i.options),i.options=i.options.mergeOptions?i.options.mergeOptions(o,t):{...o,...t}},getState:()=>i.options.state,setState:e=>{null==i.options.onStateChange||i.options.onStateChange(e)},_getRowId:(e,t,r)=>{var n;return null!=(n=null==i.options.getRowId?void 0:i.options.getRowId(e,t,r))?n:`${r?[r.id,t].join("."):t}`},getCoreRowModel:()=>(i._getCoreRowModel||(i._getCoreRowModel=i.options.getCoreRowModel(i)),i._getCoreRowModel()),getRowModel:()=>i.getPaginationRowModel(),getRow:(e,t)=>{let r=(t?i.getPrePaginationRowModel():i.getRowModel()).rowsById[e];if(!r&&!(r=i.getCoreRowModel().rowsById[e]))throw Error();return r},_getDefaultColumnDef:eu(()=>[i.options.defaultColumn],e=>{var t;return e=null!=(t=e)?t:{},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t,r;return null!=(t=null==(r=e.renderValue())||null==r.toString?void 0:r.toString())?t:null},...i._features.reduce((e,t)=>Object.assign(e,null==t.getDefaultColumnDef?void 0:t.getDefaultColumnDef()),{}),...e}},ec(e,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>i.options.columns,getAllColumns:eu(()=>[i._getColumnDefs()],e=>{let t=function(e,r,n){return void 0===n&&(n=0),e.map(e=>{let o=function(e,t,r,n){var i,o;let a,l={...e._getDefaultColumnDef(),...t},s=l.accessorKey,u=null!=(i=null!=(o=l.id)?o:s?"function"==typeof String.prototype.replaceAll?s.replaceAll(".","_"):s.replace(/\./g,"_"):void 0)?i:"string"==typeof l.header?l.header:void 0;if(l.accessorFn?a=l.accessorFn:s&&(a=s.includes(".")?e=>{let t=e;for(let e of s.split(".")){var r;t=null==(r=t)?void 0:r[e]}return t}:e=>e[l.accessorKey]),!u)throw Error();let c={id:`${String(u)}`,accessorFn:a,parent:n,depth:r,columnDef:l,columns:[],getFlatColumns:eu(()=>[!0],()=>{var e;return[c,...null==(e=c.columns)?void 0:e.flatMap(e=>e.getFlatColumns())]},ec(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:eu(()=>[e._getOrderColumnsFn()],e=>{var t;return null!=(t=c.columns)&&t.length?e(c.columns.flatMap(e=>e.getLeafColumns())):[c]},ec(e.options,"debugColumns","column.getLeafColumns"))};for(let t of e._features)null==t.createColumn||t.createColumn(c,e);return c}(i,e,n,r);return o.columns=e.columns?t(e.columns,o,n+1):[],o})};return t(e)},ec(e,"debugColumns","getAllColumns")),getAllFlatColumns:eu(()=>[i.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),ec(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:eu(()=>[i.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),ec(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:eu(()=>[i.getAllColumns(),i._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),ec(e,"debugColumns","getAllLeafColumns")),getColumn:e=>i._getAllFlatColumnsById()[e]};Object.assign(i,u);for(let e=0;e<i._features.length;e++){let t=i._features[e];null==t||null==t.createTable||t.createTable(i)}return i}(t)})),[n,i]=q.useState(()=>r.current.initialState);return r.current.setOptions(t=>({...t,...e,state:{...n,...e.state},onStateChange:t=>{i(t),null==e.onStateChange||e.onStateChange(t)}})),r.current}({data:e,columns:t,getCoreRowModel:e=>eu(()=>[e.options.data],t=>{let r={rows:[],flatRows:[],rowsById:{}},n=function(t,i,o){void 0===i&&(i=0);let a=[];for(let s=0;s<t.length;s++){let u=eh(e,e._getRowId(t[s],s,o),t[s],s,i,void 0,null==o?void 0:o.id);if(r.flatRows.push(u),r.rowsById[u.id]=u,a.push(u),e.options.getSubRows){var l;u.originalSubRows=e.options.getSubRows(t[s],s),null!=(l=u.originalSubRows)&&l.length&&(u.subRows=n(u.originalSubRows,i+1,u))}}return a};return r.rows=n(t),r},ec(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex())),getPaginationRowModel:e=>eu(()=>[e.getState().pagination,e.getPrePaginationRowModel(),e.options.paginateExpandedRows?void 0:e.getState().expanded],(t,r)=>{let n;if(!r.rows.length)return r;let{pageSize:i,pageIndex:o}=t,{rows:a,flatRows:l,rowsById:s}=r,u=i*o;if(a=a.slice(u,u+i),e.options.paginateExpandedRows)n={rows:a,flatRows:l,rowsById:s};else{var c;let e,t;c={rows:a,flatRows:l,rowsById:s},e=[],t=r=>{var n;e.push(r),null!=(n=r.subRows)&&n.length&&r.getIsExpanded()&&r.subRows.forEach(t)},c.rows.forEach(t),n={rows:e,flatRows:c.flatRows,rowsById:c.rowsById}}n.flatRows=[];let d=e=>{n.flatRows.push(e),e.subRows.length&&e.subRows.forEach(d)};return n.rows.forEach(d),n},ec(e.options,"debugTable","getPaginationRowModel")),getSortedRowModel:e=>eu(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,r)=>{if(!r.rows.length||!(null!=t&&t.length))return r;let n=e.getState().sorting,i=[],o=n.filter(t=>{var r;return null==(r=e.getColumn(t.id))?void 0:r.getCanSort()}),a={};o.forEach(t=>{let r=e.getColumn(t.id);r&&(a[t.id]={sortUndefined:r.columnDef.sortUndefined,invertSorting:r.columnDef.invertSorting,sortingFn:r.getSortingFn()})});let l=e=>{let t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let n=0;n<o.length;n+=1){var r;let i=o[n],l=a[i.id],s=l.sortUndefined,u=null!=(r=null==i?void 0:i.desc)&&r,c=0;if(s){let r=e.getValue(i.id),n=t.getValue(i.id),o=void 0===r,a=void 0===n;if(o||a){if("first"===s)return o?-1:1;if("last"===s)return o?1:-1;c=o&&a?0:o?s:-s}}if(0===c&&(c=l.sortingFn(e,t,i.id)),0!==c)return u&&(c*=-1),l.invertSorting&&(c*=-1),c}return e.index-t.index}),t.forEach(e=>{var t;i.push(e),null!=(t=e.subRows)&&t.length&&(e.subRows=l(e.subRows))}),t};return{rows:l(r.rows),flatRows:i,rowsById:r.rowsById}},ec(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex())),getFilteredRowModel:e=>eu(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,r,n)=>{var i,o,a,l,s,u,c,d,f,p;let h,g,m,v,y,b,x,w,O,S;if(!t.rows.length||!(null!=r&&r.length)&&!n){for(let e=0;e<t.flatRows.length;e++)t.flatRows[e].columnFilters={},t.flatRows[e].columnFiltersMeta={};return t}let j=[],M=[];(null!=r?r:[]).forEach(t=>{var r;let n=e.getColumn(t.id);if(!n)return;let i=n.getFilterFn();i&&j.push({id:t.id,filterFn:i,resolvedValue:null!=(r=null==i.resolveFilterValue?void 0:i.resolveFilterValue(t.value))?r:t.value})});let C=(null!=r?r:[]).map(e=>e.id),_=e.getGlobalFilterFn(),P=e.getAllLeafColumns().filter(e=>e.getCanGlobalFilter());n&&_&&P.length&&(C.push("__global__"),P.forEach(e=>{var t;M.push({id:e.id,filterFn:_,resolvedValue:null!=(t=null==_.resolveFilterValue?void 0:_.resolveFilterValue(n))?t:n})}));for(let e=0;e<t.flatRows.length;e++){let r=t.flatRows[e];if(r.columnFilters={},j.length)for(let e=0;e<j.length;e++){let t=(h=j[e]).id;r.columnFilters[t]=h.filterFn(r,t,h.resolvedValue,e=>{r.columnFiltersMeta[t]=e})}if(M.length){for(let e=0;e<M.length;e++){let t=(g=M[e]).id;if(g.filterFn(r,t,g.resolvedValue,e=>{r.columnFiltersMeta[t]=e})){r.columnFilters.__global__=!0;break}}!0!==r.columnFilters.__global__&&(r.columnFilters.__global__=!1)}}return i=t.rows,o=e=>{for(let t=0;t<C.length;t++)if(!1===e.columnFilters[C[t]])return!1;return!0},e.options.filterFromLeafRows?(a=i,l=o,m=[],v={},y=null!=(u=(s=e).options.maxLeafRowFilterDepth)?u:100,{rows:(b=function(e,t){void 0===t&&(t=0);let r=[];for(let i=0;i<e.length;i++){var n;let o=e[i],a=eh(s,o.id,o.original,o.index,o.depth,void 0,o.parentId);if(a.columnFilters=o.columnFilters,null!=(n=o.subRows)&&n.length&&t<y){if(a.subRows=b(o.subRows,t+1),l(o=a)&&!a.subRows.length||l(o)||a.subRows.length){r.push(o),v[o.id]=o,m.push(o);continue}}else l(o=a)&&(r.push(o),v[o.id]=o,m.push(o))}return r})(a),flatRows:m,rowsById:v}):(c=i,d=o,x=[],w={},O=null!=(p=(f=e).options.maxLeafRowFilterDepth)?p:100,{rows:(S=function(e,t){void 0===t&&(t=0);let r=[];for(let i=0;i<e.length;i++){let o=e[i];if(d(o)){var n;if(null!=(n=o.subRows)&&n.length&&t<O){let e=eh(f,o.id,o.original,o.index,o.depth,void 0,o.parentId);e.subRows=S(o.subRows,t+1),o=e}r.push(o),x.push(o),w[o.id]=o}}return r})(c),flatRows:x,rowsById:w})},ec(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex())),onPaginationChange:o,state:{pagination:i}}),{pages:l,showLeftEllipsis:s,showRightEllipsis:u}=function({currentPage:e,totalPages:t,paginationItemsToDisplay:r}){let n=function(){if(t<=r)return Array.from({length:t},(e,t)=>t+1);let n=Math.floor(r/2),i={start:e-n,end:e+n},o={start:Math.max(1,i.start),end:Math.min(t,i.end)};return 1===o.start&&(o.end=Math.min(r,t)),o.end===t&&(o.start=Math.max(1,t-r+1)),Array.from({length:o.end-o.start+1},(e,t)=>o.start+t)}(),i=n.length>0&&n[0]>1&&n[0]>2,o=n.length>0&&n[n.length-1]<t&&n[n.length-1]<t-1;return{pages:n,showLeftEllipsis:i,showRightEllipsis:o}}({currentPage:a.getState().pagination.pageIndex+1,totalPages:a.getPageCount(),paginationItemsToDisplay:2});return 0===e.length?(0,Y.jsx)("div",{className:"p-6 text-center text-xs text-muted-foreground",children:n("table.emptyMessage")}):(0,Y.jsxs)("div",{className:"w-full",children:[(0,Y.jsx)("div",{className:"border-b",children:(0,Y.jsxs)(wR,{children:[(0,Y.jsx)(wF,{children:a.getHeaderGroups().map(e=>(0,Y.jsx)(wL,{children:e.headers.map(e=>(0,Y.jsx)(wB,{className:"text-muted-foreground h-10 first:pl-4",children:e.isPlaceholder?null:eG(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,Y.jsx)(wz,{children:a.getRowModel().rows?.length?a.getRowModel().rows.map(e=>(0,Y.jsx)(wL,{children:e.getVisibleCells().map(e=>(0,Y.jsx)(wV,{className:"first:pl-4 py-2.5",children:eG(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,Y.jsx)(wL,{children:(0,Y.jsx)(wV,{colSpan:t.length,className:"h-24 text-center",children:n("table.noResults")})})})]})}),(0,Y.jsxs)("div",{className:"flex items-center justify-between gap-3 px-6 py-3 max-sm:flex-col md:max-lg:flex-col",children:[(0,Y.jsxs)("p",{className:"text-muted-foreground text-sm whitespace-nowrap","aria-live":"polite",children:[n("pagination.showing")," ",(0,Y.jsxs)("span",{children:[5*a.getState().pagination.pageIndex+1," ",n("pagination.to")," ",Math.min((a.getState().pagination.pageIndex+1)*5,a.getRowCount())]})," ",n("pagination.of")," ",(0,Y.jsx)("span",{children:a.getRowCount()})," ",n("pagination.entries")]}),(0,Y.jsx)(wE,{className:"mx-0 ml-auto w-auto justify-end",children:(0,Y.jsxs)(wD,{children:[(0,Y.jsx)(wN,{children:(0,Y.jsxs)(yQ.Button,{className:"disabled:pointer-events-none disabled:opacity-50",variant:"ghost",onClick:()=>a.previousPage(),disabled:!a.getCanPreviousPage(),"aria-label":n("pagination.prevAriaLabel"),children:[(0,Y.jsx)(ee,{"aria-hidden":"true"}),n("pagination.previous")]})}),s&&(0,Y.jsx)(wN,{children:(0,Y.jsx)(wA,{})}),l.map(e=>{let t=e===a.getState().pagination.pageIndex+1;return(0,Y.jsx)(wN,{children:(0,Y.jsx)(yQ.Button,{size:"icon",className:(0,xk.cn)(!t&&"bg-primary/10 text-primary hover:bg-primary/20"),onClick:()=>a.setPageIndex(e-1),"aria-current":t?"page":void 0,children:e})},e)}),u&&(0,Y.jsx)(wN,{children:(0,Y.jsx)(wA,{})}),(0,Y.jsx)(wN,{children:(0,Y.jsxs)(yQ.Button,{className:"disabled:pointer-events-none disabled:opacity-50",variant:"ghost",onClick:()=>a.nextPage(),disabled:!a.getCanNextPage(),"aria-label":n("pagination.nextAriaLabel"),children:[n("pagination.next"),(0,Y.jsx)(et.ChevronRightIcon,{"aria-hidden":"true"})]})})]})})]})]})}function w9({label:e,value:t,helper:r,icon:n,last:i,totalCostLabel:o}){return(0,Y.jsxs)("div",{className:(0,xk.cn)("px-4 py-3",!i&&"border-r"),children:[(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsx)("span",{className:"text-muted-foreground text-xs",children:e}),(0,Y.jsx)(n,{className:"size-3.5 text-muted-foreground"})]}),(0,Y.jsx)("div",{className:"mt-1 font-semibold text-2xl tabular-nums",children:t}),(0,Y.jsxs)("div",{className:"mt-1 flex items-center gap-1",children:[e===o?(0,Y.jsx)(X.ArrowDown,{className:"size-3 text-emerald-500"}):(0,Y.jsx)(Q.ArrowUp,{className:"size-3 text-emerald-500"}),(0,Y.jsx)("span",{className:"text-muted-foreground text-[10px]",children:r})]})]})}function Oe({className:e,label:t}){return(0,Y.jsxs)("span",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[(0,Y.jsx)("span",{className:(0,xk.cn)("size-2 rounded-sm",e)}),t]})}function Ot({inputTokens:e,outputTokens:t}){let r=(0,Z.useTranslations)("home"),n=e+t,i={input:{label:r("chart.input"),color:"var(--primary)"},output:{label:r("chart.output"),color:"color-mix(in oklab, var(--primary) 40%, transparent)"}};return(0,Y.jsxs)("div",{className:"mt-2",children:[(0,Y.jsx)(wj,{config:i,className:"mx-auto h-40 w-full",children:(0,Y.jsxs)(yU,{margin:{top:0,bottom:0,left:0,right:0},children:[(0,Y.jsx)(wC,{cursor:!1,content:(0,Y.jsx)(w_,{hideLabel:!0})}),(0,Y.jsx)(g8,{data:[{key:"input",value:e,fill:"var(--color-input)"},{key:"output",value:t,fill:"var(--color-output)"}],dataKey:"value",nameKey:"key",startAngle:90,endAngle:450,innerRadius:48,outerRadius:68,paddingAngle:2,children:(0,Y.jsx)(aS,{content:({viewBox:e})=>{if(e&&"cx"in e&&"cy"in e)return(0,Y.jsxs)("text",{x:e.cx,y:e.cy,textAnchor:"middle",dominantBaseline:"middle",children:[(0,Y.jsx)("tspan",{x:e.cx,y:(e.cy||0)-8,className:"fill-card-foreground text-sm font-medium",children:Oo(n)}),(0,Y.jsx)("tspan",{x:e.cx,y:(e.cy||0)+10,className:"fill-muted-foreground text-[10px]",children:r("chart.tokens")})]})}})})]})}),(0,Y.jsxs)("div",{className:"flex items-center justify-center gap-4",children:[(0,Y.jsx)(Oe,{className:"bg-primary",label:`${r("chart.input")} ${n?Math.round(e/n*100):0}%`}),(0,Y.jsx)(Oe,{className:"bg-primary/40",label:`${r("chart.output")} ${n?Math.round(t/n*100):0}%`})]})]})}function Or({byModel:e,totalCost:t}){let r=(0,Z.useTranslations)("home");if(0===e.length)return(0,Y.jsx)("p",{className:"mt-4 text-center text-xs text-muted-foreground",children:r("chart.noCostData")});let n=e.slice(0,5),i=n.map(e=>({key:e.model,value:e.costUsd,fill:(0,xk.textToColor)(e.model)})),o=Object.fromEntries(n.map(e=>[e.model,{label:e.model,color:(0,xk.textToColor)(e.model)}]));return(0,Y.jsxs)("div",{className:"mt-2",children:[(0,Y.jsx)(wj,{config:o,className:"mx-auto h-40 w-full",children:(0,Y.jsxs)(yU,{margin:{top:0,bottom:0,left:0,right:0},children:[(0,Y.jsx)(wC,{cursor:!1,content:(0,Y.jsx)(w_,{hideLabel:!0})}),(0,Y.jsx)(g8,{data:i,dataKey:"value",nameKey:"key",startAngle:90,endAngle:450,innerRadius:48,outerRadius:68,paddingAngle:2,children:(0,Y.jsx)(aS,{content:({viewBox:e})=>{if(e&&"cx"in e&&"cy"in e)return(0,Y.jsxs)("text",{x:e.cx,y:e.cy,textAnchor:"middle",dominantBaseline:"middle",children:[(0,Y.jsx)("tspan",{x:e.cx,y:(e.cy||0)-8,className:"fill-card-foreground text-sm font-medium",children:Oa(t)}),(0,Y.jsx)("tspan",{x:e.cx,y:(e.cy||0)+10,className:"fill-muted-foreground text-[10px]",children:r("chart.totalCost")})]})}})})]})}),(0,Y.jsx)("div",{className:"mt-1 space-y-0.5",children:n.map(e=>(0,Y.jsxs)("div",{className:"flex items-center justify-between px-1",children:[(0,Y.jsx)("span",{className:"truncate text-[10px]",children:e.model}),(0,Y.jsx)("span",{className:"font-mono text-[10px] tabular-nums",children:Oa(e.costUsd)})]},e.model))})]})}function On({label:e}){return(0,Y.jsx)("div",{className:"flex flex-1 items-center justify-center rounded-md border border-dashed text-xs text-muted-foreground",children:e})}function Oi(e){return new Intl.NumberFormat("en-US").format(e)}function Oo(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:Oi(e)}function Oa(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:4}).format(e)}function Ol(e){return e?e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.round(e/6e4)}m`:"0ms"}var Os=e.i(524),Ou=e.i(361031);function Oc({initialWorkspaces:e}){let t=(0,Ou.useWorkspaceStore)(e=>e.setWorkspaces),r=(0,Ou.useWorkspaceStore)(e=>e.upsertWorkspace),n=(0,Ou.useWorkspaceStore)(e=>e.createDialogOpen),i=(0,Ou.useWorkspaceStore)(e=>e.setCreateDialogOpen),[o,a]=(0,q.useState)(!1);(0,q.useEffect)(()=>{t(e)},[e,t]);let l=async e=>{let t=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});r(await t.json())};return(0,Y.jsxs)("div",{className:"flex h-full w-full flex-col overflow-auto",children:[(0,Y.jsx)("main",{className:"w-full flex-1 px-4 py-6 sm:px-6",children:(0,Y.jsx)(w7,{})}),(0,Y.jsx)(Os.WorkspaceDialog,{open:o||n,onOpenChange:e=>{a(e),e||i(!1)},onSubmit:l})]})}var Od=e.i(437122),Of=e.i(233297);e.s(["default",0,function(){let[e,t]=(0,q.useState)([]),r=(0,K.useRouter)();return(0,q.useEffect)(()=>{fetch("/api/workspaces",{headers:(0,Od.authHeaders)()}).then(e=>e.ok?e.json():[]).then(e=>{if(t(e),"true"===localStorage.getItem("autoActivateWorkspace")&&!sessionStorage.getItem("autoActivateSkipped")){let t=localStorage.getItem("lastWorkspaceId");t&&e.some(e=>e.id===t)&&(sessionStorage.setItem("autoActivateSkipped","1"),(0,Of.tauriNavigate)(r,`/workspace/${t}`,!0))}})},[r]),(0,Y.jsx)(Oc,{initialWorkspaces:e})}],330997)}]);