omniroute 1.7.12 → 1.7.13

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 (437) hide show
  1. package/app/.env +122 -0
  2. package/app/.next/BUILD_ID +1 -1
  3. package/app/.next/app-path-routes-manifest.json +49 -49
  4. package/app/.next/build-manifest.json +3 -3
  5. package/app/.next/prerender-manifest.json +3 -3
  6. package/app/.next/required-server-files.json +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/analytics/page.js +2 -2
  8. package/app/.next/server/app/(dashboard)/dashboard/analytics/page.js.nft.json +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page.js +2 -2
  11. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page.js.nft.json +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page.js +2 -2
  14. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page.js.nft.json +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +3 -3
  17. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +2 -2
  20. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/costs/page.js +2 -2
  23. package/app/.next/server/app/(dashboard)/dashboard/costs/page.js.nft.json +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +2 -2
  26. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/health/page.js +2 -2
  29. package/app/.next/server/app/(dashboard)/dashboard/health/page.js.nft.json +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  31. package/app/.next/server/app/(dashboard)/dashboard/limits/page.js +2 -2
  32. package/app/.next/server/app/(dashboard)/dashboard/limits/page.js.nft.json +1 -1
  33. package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
  34. package/app/.next/server/app/(dashboard)/dashboard/logs/page.js +2 -2
  35. package/app/.next/server/app/(dashboard)/dashboard/logs/page.js.nft.json +1 -1
  36. package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
  37. package/app/.next/server/app/(dashboard)/dashboard/media/page.js +2 -2
  38. package/app/.next/server/app/(dashboard)/dashboard/media/page.js.nft.json +1 -1
  39. package/app/.next/server/app/(dashboard)/dashboard/media/page_client-reference-manifest.js +1 -1
  40. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page.js +2 -2
  41. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page.js.nft.json +1 -1
  42. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
  43. package/app/.next/server/app/(dashboard)/dashboard/page.js +2 -2
  44. package/app/.next/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  45. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  46. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +2 -2
  47. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  48. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  49. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  50. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  51. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  52. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +2 -2
  53. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  54. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +2 -2
  56. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  57. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  58. package/app/.next/server/app/(dashboard)/dashboard/settings/page.js +2 -2
  59. package/app/.next/server/app/(dashboard)/dashboard/settings/page.js.nft.json +1 -1
  60. package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
  61. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page.js +2 -2
  62. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page.js.nft.json +1 -1
  63. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  64. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +3 -3
  65. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
  66. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  67. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +2 -2
  68. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
  69. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  70. package/app/.next/server/app/_global-error/page.js +3 -3
  71. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  72. package/app/.next/server/app/_global-error.html +2 -2
  73. package/app/.next/server/app/_global-error.rsc +4 -4
  74. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +4 -4
  75. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  76. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  77. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  78. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
  79. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  80. package/app/.next/server/app/_not-found/page.js +2 -2
  81. package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
  82. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  83. package/app/.next/server/app/api/auth/login/route.js +1 -1
  84. package/app/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  85. package/app/.next/server/app/api/auth/logout/route.js +1 -1
  86. package/app/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  87. package/app/.next/server/app/api/auth/status/route.js +1 -1
  88. package/app/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  89. package/app/.next/server/app/api/cache/route.js +1 -1
  90. package/app/.next/server/app/api/cache/route_client-reference-manifest.js +1 -1
  91. package/app/.next/server/app/api/cache/stats/route.js +1 -1
  92. package/app/.next/server/app/api/cache/stats/route_client-reference-manifest.js +1 -1
  93. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  94. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route_client-reference-manifest.js +1 -1
  95. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +2 -2
  96. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route_client-reference-manifest.js +1 -1
  97. package/app/.next/server/app/api/cli-tools/backups/route.js +2 -2
  98. package/app/.next/server/app/api/cli-tools/backups/route_client-reference-manifest.js +1 -1
  99. package/app/.next/server/app/api/cli-tools/claude-settings/route.js +2 -2
  100. package/app/.next/server/app/api/cli-tools/claude-settings/route_client-reference-manifest.js +1 -1
  101. package/app/.next/server/app/api/cli-tools/cline-settings/route.js +2 -2
  102. package/app/.next/server/app/api/cli-tools/cline-settings/route_client-reference-manifest.js +1 -1
  103. package/app/.next/server/app/api/cli-tools/codex-profiles/route.js +2 -2
  104. package/app/.next/server/app/api/cli-tools/codex-profiles/route_client-reference-manifest.js +1 -1
  105. package/app/.next/server/app/api/cli-tools/codex-settings/route.js +2 -2
  106. package/app/.next/server/app/api/cli-tools/codex-settings/route_client-reference-manifest.js +1 -1
  107. package/app/.next/server/app/api/cli-tools/droid-settings/route.js +2 -2
  108. package/app/.next/server/app/api/cli-tools/droid-settings/route_client-reference-manifest.js +1 -1
  109. package/app/.next/server/app/api/cli-tools/guide-settings/[toolId]/route.js +1 -1
  110. package/app/.next/server/app/api/cli-tools/guide-settings/[toolId]/route_client-reference-manifest.js +1 -1
  111. package/app/.next/server/app/api/cli-tools/kilo-settings/route.js +2 -2
  112. package/app/.next/server/app/api/cli-tools/kilo-settings/route_client-reference-manifest.js +1 -1
  113. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
  114. package/app/.next/server/app/api/cli-tools/openclaw-settings/route_client-reference-manifest.js +1 -1
  115. package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route.js +2 -2
  116. package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route_client-reference-manifest.js +1 -1
  117. package/app/.next/server/app/api/cli-tools/status/route.js +2 -2
  118. package/app/.next/server/app/api/cli-tools/status/route_client-reference-manifest.js +1 -1
  119. package/app/.next/server/app/api/cloud/auth/route.js +1 -1
  120. package/app/.next/server/app/api/cloud/auth/route_client-reference-manifest.js +1 -1
  121. package/app/.next/server/app/api/cloud/credentials/update/route.js +1 -1
  122. package/app/.next/server/app/api/cloud/credentials/update/route_client-reference-manifest.js +1 -1
  123. package/app/.next/server/app/api/cloud/model/resolve/route.js +1 -1
  124. package/app/.next/server/app/api/cloud/model/resolve/route_client-reference-manifest.js +1 -1
  125. package/app/.next/server/app/api/cloud/models/alias/route.js +1 -1
  126. package/app/.next/server/app/api/cloud/models/alias/route_client-reference-manifest.js +1 -1
  127. package/app/.next/server/app/api/combos/[id]/route.js +1 -1
  128. package/app/.next/server/app/api/combos/[id]/route_client-reference-manifest.js +1 -1
  129. package/app/.next/server/app/api/combos/metrics/route.js +1 -1
  130. package/app/.next/server/app/api/combos/metrics/route_client-reference-manifest.js +1 -1
  131. package/app/.next/server/app/api/combos/route.js +1 -1
  132. package/app/.next/server/app/api/combos/route_client-reference-manifest.js +1 -1
  133. package/app/.next/server/app/api/combos/test/route.js +1 -1
  134. package/app/.next/server/app/api/combos/test/route_client-reference-manifest.js +1 -1
  135. package/app/.next/server/app/api/compliance/audit-log/route.js +1 -1
  136. package/app/.next/server/app/api/compliance/audit-log/route_client-reference-manifest.js +1 -1
  137. package/app/.next/server/app/api/db-backups/export/route.js +1 -1
  138. package/app/.next/server/app/api/db-backups/export/route_client-reference-manifest.js +1 -1
  139. package/app/.next/server/app/api/db-backups/exportAll/route.js +1 -1
  140. package/app/.next/server/app/api/db-backups/exportAll/route_client-reference-manifest.js +1 -1
  141. package/app/.next/server/app/api/db-backups/import/route.js +1 -1
  142. package/app/.next/server/app/api/db-backups/import/route_client-reference-manifest.js +1 -1
  143. package/app/.next/server/app/api/db-backups/route.js +1 -1
  144. package/app/.next/server/app/api/db-backups/route_client-reference-manifest.js +1 -1
  145. package/app/.next/server/app/api/evals/[suiteId]/route.js +1 -1
  146. package/app/.next/server/app/api/evals/[suiteId]/route_client-reference-manifest.js +1 -1
  147. package/app/.next/server/app/api/evals/route.js +1 -1
  148. package/app/.next/server/app/api/evals/route_client-reference-manifest.js +1 -1
  149. package/app/.next/server/app/api/fallback/chains/route.js +2 -2
  150. package/app/.next/server/app/api/fallback/chains/route_client-reference-manifest.js +1 -1
  151. package/app/.next/server/app/api/init/route.js +1 -1
  152. package/app/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  153. package/app/.next/server/app/api/keys/[id]/route.js +1 -1
  154. package/app/.next/server/app/api/keys/[id]/route_client-reference-manifest.js +1 -1
  155. package/app/.next/server/app/api/keys/route.js +1 -1
  156. package/app/.next/server/app/api/keys/route_client-reference-manifest.js +1 -1
  157. package/app/.next/server/app/api/logs/console/route.js +1 -1
  158. package/app/.next/server/app/api/logs/console/route_client-reference-manifest.js +1 -1
  159. package/app/.next/server/app/api/models/alias/route.js +1 -1
  160. package/app/.next/server/app/api/models/alias/route_client-reference-manifest.js +1 -1
  161. package/app/.next/server/app/api/models/availability/route.js +1 -1
  162. package/app/.next/server/app/api/models/availability/route_client-reference-manifest.js +1 -1
  163. package/app/.next/server/app/api/models/catalog/route.js +2 -2
  164. package/app/.next/server/app/api/models/catalog/route_client-reference-manifest.js +1 -1
  165. package/app/.next/server/app/api/models/route.js +2 -2
  166. package/app/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
  167. package/app/.next/server/app/api/monitoring/health/route.js +2 -2
  168. package/app/.next/server/app/api/monitoring/health/route_client-reference-manifest.js +1 -1
  169. package/app/.next/server/app/api/oauth/[provider]/[action]/route.js +2 -2
  170. package/app/.next/server/app/api/oauth/[provider]/[action]/route_client-reference-manifest.js +1 -1
  171. package/app/.next/server/app/api/oauth/cursor/auto-import/route.js +1 -1
  172. package/app/.next/server/app/api/oauth/cursor/auto-import/route_client-reference-manifest.js +1 -1
  173. package/app/.next/server/app/api/oauth/cursor/import/route.js +1 -1
  174. package/app/.next/server/app/api/oauth/cursor/import/route_client-reference-manifest.js +1 -1
  175. package/app/.next/server/app/api/oauth/kiro/auto-import/route.js +1 -1
  176. package/app/.next/server/app/api/oauth/kiro/auto-import/route_client-reference-manifest.js +1 -1
  177. package/app/.next/server/app/api/oauth/kiro/import/route.js +1 -1
  178. package/app/.next/server/app/api/oauth/kiro/import/route_client-reference-manifest.js +1 -1
  179. package/app/.next/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
  180. package/app/.next/server/app/api/oauth/kiro/social-authorize/route_client-reference-manifest.js +1 -1
  181. package/app/.next/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  182. package/app/.next/server/app/api/oauth/kiro/social-exchange/route_client-reference-manifest.js +1 -1
  183. package/app/.next/server/app/api/policies/route.js +2 -2
  184. package/app/.next/server/app/api/policies/route_client-reference-manifest.js +1 -1
  185. package/app/.next/server/app/api/pricing/defaults/route.js +1 -1
  186. package/app/.next/server/app/api/pricing/defaults/route_client-reference-manifest.js +1 -1
  187. package/app/.next/server/app/api/pricing/models/route.js +1 -1
  188. package/app/.next/server/app/api/pricing/models/route_client-reference-manifest.js +1 -1
  189. package/app/.next/server/app/api/pricing/route.js +1 -1
  190. package/app/.next/server/app/api/pricing/route_client-reference-manifest.js +1 -1
  191. package/app/.next/server/app/api/provider-metrics/route.js +2 -2
  192. package/app/.next/server/app/api/provider-metrics/route_client-reference-manifest.js +1 -1
  193. package/app/.next/server/app/api/provider-models/route.js +1 -1
  194. package/app/.next/server/app/api/provider-models/route_client-reference-manifest.js +1 -1
  195. package/app/.next/server/app/api/provider-nodes/[id]/route.js +1 -1
  196. package/app/.next/server/app/api/provider-nodes/[id]/route_client-reference-manifest.js +1 -1
  197. package/app/.next/server/app/api/provider-nodes/route.js +2 -2
  198. package/app/.next/server/app/api/provider-nodes/route_client-reference-manifest.js +1 -1
  199. package/app/.next/server/app/api/provider-nodes/validate/route.js +1 -1
  200. package/app/.next/server/app/api/provider-nodes/validate/route_client-reference-manifest.js +1 -1
  201. package/app/.next/server/app/api/providers/[id]/models/route.js +2 -2
  202. package/app/.next/server/app/api/providers/[id]/models/route_client-reference-manifest.js +1 -1
  203. package/app/.next/server/app/api/providers/[id]/route.js +1 -1
  204. package/app/.next/server/app/api/providers/[id]/route_client-reference-manifest.js +1 -1
  205. package/app/.next/server/app/api/providers/[id]/test/route.js +1 -1
  206. package/app/.next/server/app/api/providers/[id]/test/route_client-reference-manifest.js +1 -1
  207. package/app/.next/server/app/api/providers/client/route.js +1 -1
  208. package/app/.next/server/app/api/providers/client/route_client-reference-manifest.js +1 -1
  209. package/app/.next/server/app/api/providers/route.js +2 -2
  210. package/app/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
  211. package/app/.next/server/app/api/providers/test-batch/route.js +1 -1
  212. package/app/.next/server/app/api/providers/test-batch/route_client-reference-manifest.js +1 -1
  213. package/app/.next/server/app/api/providers/validate/route.js +1 -1
  214. package/app/.next/server/app/api/providers/validate/route_client-reference-manifest.js +1 -1
  215. package/app/.next/server/app/api/rate-limit/route.js +1 -1
  216. package/app/.next/server/app/api/rate-limit/route_client-reference-manifest.js +1 -1
  217. package/app/.next/server/app/api/rate-limits/route.js +1 -1
  218. package/app/.next/server/app/api/rate-limits/route_client-reference-manifest.js +1 -1
  219. package/app/.next/server/app/api/resilience/reset/route.js +1 -1
  220. package/app/.next/server/app/api/resilience/reset/route_client-reference-manifest.js +1 -1
  221. package/app/.next/server/app/api/resilience/route.js +1 -1
  222. package/app/.next/server/app/api/resilience/route_client-reference-manifest.js +1 -1
  223. package/app/.next/server/app/api/restart/route.js +1 -1
  224. package/app/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
  225. package/app/.next/server/app/api/sessions/route.js +1 -1
  226. package/app/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -1
  227. package/app/.next/server/app/api/settings/background-degradation/route.js +1 -1
  228. package/app/.next/server/app/api/settings/background-degradation/route_client-reference-manifest.js +1 -1
  229. package/app/.next/server/app/api/settings/combo-defaults/route.js +1 -1
  230. package/app/.next/server/app/api/settings/combo-defaults/route_client-reference-manifest.js +1 -1
  231. package/app/.next/server/app/api/settings/ip-filter/route.js +1 -1
  232. package/app/.next/server/app/api/settings/ip-filter/route_client-reference-manifest.js +1 -1
  233. package/app/.next/server/app/api/settings/model-aliases/route.js +1 -1
  234. package/app/.next/server/app/api/settings/model-aliases/route_client-reference-manifest.js +1 -1
  235. package/app/.next/server/app/api/settings/proxy/route.js +1 -1
  236. package/app/.next/server/app/api/settings/proxy/route_client-reference-manifest.js +1 -1
  237. package/app/.next/server/app/api/settings/proxy/test/route.js +1 -1
  238. package/app/.next/server/app/api/settings/proxy/test/route_client-reference-manifest.js +1 -1
  239. package/app/.next/server/app/api/settings/require-login/route.js +1 -1
  240. package/app/.next/server/app/api/settings/require-login/route_client-reference-manifest.js +1 -1
  241. package/app/.next/server/app/api/settings/route.js +1 -1
  242. package/app/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
  243. package/app/.next/server/app/api/settings/system-prompt/route.js +1 -1
  244. package/app/.next/server/app/api/settings/system-prompt/route_client-reference-manifest.js +1 -1
  245. package/app/.next/server/app/api/settings/thinking-budget/route.js +1 -1
  246. package/app/.next/server/app/api/settings/thinking-budget/route_client-reference-manifest.js +1 -1
  247. package/app/.next/server/app/api/shutdown/route.js +1 -1
  248. package/app/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  249. package/app/.next/server/app/api/storage/health/route.js +1 -1
  250. package/app/.next/server/app/api/storage/health/route_client-reference-manifest.js +1 -1
  251. package/app/.next/server/app/api/sync/cloud/route.js +1 -1
  252. package/app/.next/server/app/api/sync/cloud/route_client-reference-manifest.js +1 -1
  253. package/app/.next/server/app/api/sync/initialize/route.js +1 -1
  254. package/app/.next/server/app/api/sync/initialize/route_client-reference-manifest.js +1 -1
  255. package/app/.next/server/app/api/tags/route.js +1 -1
  256. package/app/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
  257. package/app/.next/server/app/api/telemetry/summary/route.js +1 -1
  258. package/app/.next/server/app/api/telemetry/summary/route_client-reference-manifest.js +1 -1
  259. package/app/.next/server/app/api/token-health/route.js +1 -1
  260. package/app/.next/server/app/api/token-health/route_client-reference-manifest.js +1 -1
  261. package/app/.next/server/app/api/translator/detect/route.js +1 -1
  262. package/app/.next/server/app/api/translator/detect/route_client-reference-manifest.js +1 -1
  263. package/app/.next/server/app/api/translator/history/route.js +1 -1
  264. package/app/.next/server/app/api/translator/history/route_client-reference-manifest.js +1 -1
  265. package/app/.next/server/app/api/translator/load/route.js +1 -1
  266. package/app/.next/server/app/api/translator/load/route_client-reference-manifest.js +1 -1
  267. package/app/.next/server/app/api/translator/save/route.js +1 -1
  268. package/app/.next/server/app/api/translator/save/route_client-reference-manifest.js +1 -1
  269. package/app/.next/server/app/api/translator/send/route.js +1 -1
  270. package/app/.next/server/app/api/translator/send/route_client-reference-manifest.js +1 -1
  271. package/app/.next/server/app/api/translator/translate/route.js +1 -1
  272. package/app/.next/server/app/api/translator/translate/route_client-reference-manifest.js +1 -1
  273. package/app/.next/server/app/api/usage/[connectionId]/route.js +1 -1
  274. package/app/.next/server/app/api/usage/[connectionId]/route_client-reference-manifest.js +1 -1
  275. package/app/.next/server/app/api/usage/analytics/route.js +1 -1
  276. package/app/.next/server/app/api/usage/analytics/route_client-reference-manifest.js +1 -1
  277. package/app/.next/server/app/api/usage/budget/route.js +2 -2
  278. package/app/.next/server/app/api/usage/budget/route_client-reference-manifest.js +1 -1
  279. package/app/.next/server/app/api/usage/call-logs/[id]/route.js +1 -1
  280. package/app/.next/server/app/api/usage/call-logs/[id]/route_client-reference-manifest.js +1 -1
  281. package/app/.next/server/app/api/usage/call-logs/route.js +1 -1
  282. package/app/.next/server/app/api/usage/call-logs/route_client-reference-manifest.js +1 -1
  283. package/app/.next/server/app/api/usage/history/route.js +1 -1
  284. package/app/.next/server/app/api/usage/history/route_client-reference-manifest.js +1 -1
  285. package/app/.next/server/app/api/usage/logs/route.js +1 -1
  286. package/app/.next/server/app/api/usage/logs/route_client-reference-manifest.js +1 -1
  287. package/app/.next/server/app/api/usage/proxy-logs/route.js +1 -1
  288. package/app/.next/server/app/api/usage/proxy-logs/route_client-reference-manifest.js +1 -1
  289. package/app/.next/server/app/api/usage/request-logs/route.js +1 -1
  290. package/app/.next/server/app/api/usage/request-logs/route_client-reference-manifest.js +1 -1
  291. package/app/.next/server/app/api/v1/api/chat/route.js +1 -1
  292. package/app/.next/server/app/api/v1/api/chat/route_client-reference-manifest.js +1 -1
  293. package/app/.next/server/app/api/v1/audio/speech/route.js +1 -1
  294. package/app/.next/server/app/api/v1/audio/speech/route_client-reference-manifest.js +1 -1
  295. package/app/.next/server/app/api/v1/audio/transcriptions/route.js +1 -1
  296. package/app/.next/server/app/api/v1/audio/transcriptions/route_client-reference-manifest.js +1 -1
  297. package/app/.next/server/app/api/v1/chat/completions/route.js +1 -1
  298. package/app/.next/server/app/api/v1/chat/completions/route_client-reference-manifest.js +1 -1
  299. package/app/.next/server/app/api/v1/embeddings/route.js +1 -1
  300. package/app/.next/server/app/api/v1/embeddings/route_client-reference-manifest.js +1 -1
  301. package/app/.next/server/app/api/v1/images/generations/route.js +1 -1
  302. package/app/.next/server/app/api/v1/images/generations/route_client-reference-manifest.js +1 -1
  303. package/app/.next/server/app/api/v1/messages/count_tokens/route.js +1 -1
  304. package/app/.next/server/app/api/v1/messages/count_tokens/route_client-reference-manifest.js +1 -1
  305. package/app/.next/server/app/api/v1/messages/route.js +1 -1
  306. package/app/.next/server/app/api/v1/messages/route_client-reference-manifest.js +1 -1
  307. package/app/.next/server/app/api/v1/models/route.js +2 -2
  308. package/app/.next/server/app/api/v1/models/route_client-reference-manifest.js +1 -1
  309. package/app/.next/server/app/api/v1/moderations/route.js +1 -1
  310. package/app/.next/server/app/api/v1/moderations/route_client-reference-manifest.js +1 -1
  311. package/app/.next/server/app/api/v1/music/generations/route.js +1 -1
  312. package/app/.next/server/app/api/v1/music/generations/route_client-reference-manifest.js +1 -1
  313. package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route.js +1 -1
  314. package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route_client-reference-manifest.js +1 -1
  315. package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route.js +1 -1
  316. package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route_client-reference-manifest.js +1 -1
  317. package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route.js +1 -1
  318. package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route_client-reference-manifest.js +1 -1
  319. package/app/.next/server/app/api/v1/rerank/route.js +1 -1
  320. package/app/.next/server/app/api/v1/rerank/route_client-reference-manifest.js +1 -1
  321. package/app/.next/server/app/api/v1/responses/route.js +1 -1
  322. package/app/.next/server/app/api/v1/responses/route_client-reference-manifest.js +1 -1
  323. package/app/.next/server/app/api/v1/route.js +1 -1
  324. package/app/.next/server/app/api/v1/route_client-reference-manifest.js +1 -1
  325. package/app/.next/server/app/api/v1/videos/generations/route.js +1 -1
  326. package/app/.next/server/app/api/v1/videos/generations/route_client-reference-manifest.js +1 -1
  327. package/app/.next/server/app/api/v1beta/models/[...path]/route.js +1 -1
  328. package/app/.next/server/app/api/v1beta/models/[...path]/route_client-reference-manifest.js +1 -1
  329. package/app/.next/server/app/api/v1beta/models/route.js +2 -2
  330. package/app/.next/server/app/api/v1beta/models/route_client-reference-manifest.js +1 -1
  331. package/app/.next/server/app/callback/page.js +2 -2
  332. package/app/.next/server/app/callback/page.js.nft.json +1 -1
  333. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  334. package/app/.next/server/app/docs/page.js +3 -3
  335. package/app/.next/server/app/docs/page.js.nft.json +1 -1
  336. package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  337. package/app/.next/server/app/forbidden/page.js +2 -2
  338. package/app/.next/server/app/forbidden/page.js.nft.json +1 -1
  339. package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
  340. package/app/.next/server/app/forgot-password/page.js +2 -2
  341. package/app/.next/server/app/forgot-password/page.js.nft.json +1 -1
  342. package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
  343. package/app/.next/server/app/landing/page.js +2 -2
  344. package/app/.next/server/app/landing/page.js.nft.json +1 -1
  345. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  346. package/app/.next/server/app/login/page.js +2 -2
  347. package/app/.next/server/app/login/page.js.nft.json +1 -1
  348. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  349. package/app/.next/server/app/page.js +2 -2
  350. package/app/.next/server/app/page.js.nft.json +1 -1
  351. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  352. package/app/.next/server/app/privacy/page.js +2 -2
  353. package/app/.next/server/app/privacy/page.js.nft.json +1 -1
  354. package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  355. package/app/.next/server/app/terms/page.js +2 -2
  356. package/app/.next/server/app/terms/page.js.nft.json +1 -1
  357. package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
  358. package/app/.next/server/app-paths-manifest.json +49 -49
  359. package/app/.next/server/chunks/2180.js +1 -1
  360. package/app/.next/server/chunks/2910.js +1 -1
  361. package/app/.next/server/chunks/3498.js +1 -1
  362. package/app/.next/server/chunks/3801.js +2 -0
  363. package/app/.next/server/chunks/4488.js +1 -1
  364. package/app/.next/server/chunks/7109.js +1 -1
  365. package/app/.next/server/chunks/8020.js +3 -3
  366. package/app/.next/server/chunks/9548.js +1 -0
  367. package/app/.next/server/chunks/9824.js +2 -2
  368. package/app/.next/server/middleware-build-manifest.js +1 -1
  369. package/app/.next/server/middleware.js +3 -3
  370. package/app/.next/server/next-font-manifest.js +1 -1
  371. package/app/.next/server/next-font-manifest.json +1 -1
  372. package/app/.next/server/pages/500.html +2 -2
  373. package/app/.next/server/server-reference-manifest.js +1 -1
  374. package/app/.next/server/server-reference-manifest.json +1 -1
  375. package/app/.next/static/chunks/{5846-87d36f43a6a3659e.js → 5846-0ee1f53245d92ec3.js} +1 -1
  376. package/app/.next/static/chunks/{993-035473765d7d1871.js → 993-9f36b0b069ca090e.js} +2 -2
  377. package/app/.next/static/chunks/app/(dashboard)/dashboard/analytics/loading-ce5214cdf489c9df.js +1 -0
  378. package/app/.next/static/chunks/app/(dashboard)/dashboard/analytics/{page-52f76c7c91444ec2.js → page-20786f2c7fdbab57.js} +1 -1
  379. package/app/.next/static/chunks/app/(dashboard)/dashboard/api-manager/page-12d772841a253032.js +1 -0
  380. package/app/.next/static/chunks/app/(dashboard)/dashboard/audit-log/page-c9b98846b8479f3f.js +1 -0
  381. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/page-5e34630a5dc32825.js +15 -0
  382. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/{page-3dce7fccfcf177dd.js → page-85a3e6a423aceded.js} +1 -1
  383. package/app/.next/static/chunks/app/(dashboard)/dashboard/costs/{page-3ed2a7685adf9b91.js → page-cdb8071441476da9.js} +1 -1
  384. package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-3f3a5f45e045051f.js +1 -0
  385. package/app/.next/static/chunks/app/(dashboard)/dashboard/health/{page-9a6519bf1468f16e.js → page-b480b3cb318782d7.js} +1 -1
  386. package/app/.next/static/chunks/app/(dashboard)/dashboard/limits/page-0ae1d6cc5fc4671f.js +1 -0
  387. package/app/.next/static/chunks/app/(dashboard)/dashboard/logs/{page-833d24f322a20f5a.js → page-ffdc1dcf074c7528.js} +1 -1
  388. package/app/.next/static/chunks/app/(dashboard)/dashboard/media/page-72b768421394b42c.js +1 -0
  389. package/app/.next/static/chunks/app/(dashboard)/dashboard/onboarding/{page-d424641c7e428be9.js → page-5378e9473a20cd6a.js} +1 -1
  390. package/app/.next/static/chunks/app/(dashboard)/dashboard/page-5c87e49261a22fd5.js +1 -0
  391. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-b38f2d03bae8166a.js +1 -0
  392. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/{error-2f0177a2197dd556.js → error-f0730d6d62d02e82.js} +1 -1
  393. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/{loading-99ab4d478260d53b.js → loading-59cbccd6d5185ca9.js} +1 -1
  394. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-a7fb36872be60fe0.js +1 -0
  395. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/{page-1f022385b812b987.js → page-40dc5ac82df708e9.js} +1 -1
  396. package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/{error-e844916e39172c8b.js → error-cc85c3ff1f63aea6.js} +1 -1
  397. package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/{loading-bb068659ee679ff4.js → loading-19fc771a287bcb4c.js} +1 -1
  398. package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/{page-cea3403400ee20c8.js → page-2442cf2a6452a899.js} +1 -1
  399. package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/pricing/{page-a4b8b03ffb39da1d.js → page-69eb8b0eb0e9de00.js} +1 -1
  400. package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/{page-83b07523f81d6282.js → page-534e13a69cb60a4f.js} +1 -1
  401. package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/{page-9cc99ab874fc36e7.js → page-86a076d820931a30.js} +1 -1
  402. package/app/.next/static/chunks/app/(dashboard)/{layout-00d5d56af65098a9.js → layout-16302e54f9ef3d0e.js} +1 -1
  403. package/app/.next/static/chunks/app/callback/{page-585a53f7dc6a30f1.js → page-0f0ebc0820dd18a5.js} +1 -1
  404. package/app/.next/static/chunks/app/docs/{page-2fe9dcbeb3f738c0.js → page-3658b3f15df3a19e.js} +1 -1
  405. package/app/.next/static/chunks/app/{error-0d59fc4efafbc38c.js → error-f918d9961a2368d3.js} +1 -1
  406. package/app/.next/static/chunks/app/forbidden/page-77657dfa95e61cd8.js +1 -0
  407. package/app/.next/static/chunks/app/forgot-password/page-be3bacc125c30a6b.js +1 -0
  408. package/app/.next/static/chunks/app/global-error-504ff9093e2a997d.js +1 -0
  409. package/app/.next/static/chunks/app/landing/page-75b0c988db383cfc.js +1 -0
  410. package/app/.next/static/chunks/app/{layout-108592eafb959363.js → layout-070972eb026af319.js} +1 -1
  411. package/app/.next/static/chunks/app/login/{page-121c612ee459e7c2.js → page-6c769465e407368f.js} +1 -1
  412. package/app/.next/static/chunks/app/not-found-11b712c853d93172.js +1 -0
  413. package/app/.next/static/chunks/app/privacy/{page-2fe9dcbeb3f738c0.js → page-3658b3f15df3a19e.js} +1 -1
  414. package/app/.next/static/chunks/app/terms/{page-2fe9dcbeb3f738c0.js → page-3658b3f15df3a19e.js} +1 -1
  415. package/app/.next/static/chunks/{main-app-c9da11a8061df107.js → main-app-ae230f6bf51a5edb.js} +1 -1
  416. package/app/package.json +1 -1
  417. package/app/server.js +1 -1
  418. package/package.json +1 -1
  419. package/app/.next/server/chunks/5248.js +0 -1
  420. package/app/.next/server/chunks/5393.js +0 -2
  421. package/app/.next/static/chunks/app/(dashboard)/dashboard/analytics/loading-6f1750506292c630.js +0 -1
  422. package/app/.next/static/chunks/app/(dashboard)/dashboard/api-manager/page-1dd4d0c348a7b0a6.js +0 -1
  423. package/app/.next/static/chunks/app/(dashboard)/dashboard/audit-log/page-e5bf8955e7b9a4f5.js +0 -1
  424. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/page-77ab26722f5c56c7.js +0 -15
  425. package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-84be54df40abf969.js +0 -1
  426. package/app/.next/static/chunks/app/(dashboard)/dashboard/limits/page-f4a2d6d07df5ddc4.js +0 -1
  427. package/app/.next/static/chunks/app/(dashboard)/dashboard/media/page-1d0ca9b5d3eaf7cd.js +0 -1
  428. package/app/.next/static/chunks/app/(dashboard)/dashboard/page-388840686801f3f5.js +0 -1
  429. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-9c8ffb212f855704.js +0 -1
  430. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-31cdb6e15134d8c2.js +0 -1
  431. package/app/.next/static/chunks/app/forbidden/page-df886dfa2d5bd9fa.js +0 -1
  432. package/app/.next/static/chunks/app/forgot-password/page-2a495f0b0c653ab4.js +0 -1
  433. package/app/.next/static/chunks/app/global-error-41eef2a698918fc1.js +0 -1
  434. package/app/.next/static/chunks/app/landing/page-9d540ab1716f8e3e.js +0 -1
  435. package/app/.next/static/chunks/app/not-found-1dbd8c3e506fe00f.js +0 -1
  436. /package/app/.next/static/{JKW3SWuOlZ-iZJt5gdVEf → aCT5wOLH_n6lt0LkCh2w7}/_buildManifest.js +0 -0
  437. /package/app/.next/static/{JKW3SWuOlZ-iZJt5gdVEf → aCT5wOLH_n6lt0LkCh2w7}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";exports.id=9824,exports.ids=[9824],exports.modules={1237:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(67484),f=c(65953),g=c(53156);function h({isOpen:a,onClose:b,title:c="Manual Configuration",configs:h=[]}){let[i,j]=(0,e.useState)(null),k=async(a,b)=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(a);else{let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.left="-9999px",b.style.top="-9999px",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select(),document.execCommand("copy"),document.body.removeChild(b)}j(b),setTimeout(()=>j(null),2e3)}catch(a){console.log("Failed to copy:",a)}};return(0,d.jsx)(f.default,{isOpen:a,onClose:b,title:c,size:"xl",children:(0,d.jsx)("div",{className:"flex flex-col gap-4",children:h.map((a,b)=>(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-text-main",children:a.filename}),(0,d.jsxs)(g.default,{variant:"ghost",size:"sm",onClick:()=>k(a.content,b),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:i===b?"check":"content_copy"}),i===b?"Copied!":"Copy"]})]}),(0,d.jsx)("pre",{className:"px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs overflow-x-auto whitespace-pre-wrap break-all max-h-60 overflow-y-auto border border-border",children:a.content})]},b))})})}},2490:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(31846);function f({children:a,title:b,subtitle:c,icon:f,action:g,padding:h="md",hover:i=!1,className:j,...k}){return(0,d.jsxs)("div",{className:(0,e.cn)("bg-surface","border border-black/5 dark:border-white/5","rounded-lg shadow-sm",i&&"hover:shadow-md hover:border-primary/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[h],j),...k,children:[(b||g)&&(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[f&&(0,d.jsx)("div",{className:"p-2 rounded-lg bg-bg text-text-muted",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:f})}),(0,d.jsxs)("div",{children:[b&&(0,d.jsx)("h3",{className:"text-text-main font-semibold",children:b}),c&&(0,d.jsx)("p",{className:"text-sm text-text-muted",children:c})]})]}),g]}),a]})}f.Section=function({children:a,className:b,...c}){return(0,d.jsx)("div",{className:(0,e.cn)("p-4 rounded-lg","bg-black/[0.02] dark:bg-white/[0.02]","border border-black/5 dark:border-white/5",b),...c,children:a})},f.Row=function({children:a,className:b,...c}){return(0,d.jsx)("div",{className:(0,e.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-black/5 dark:border-white/5 last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]",b),...c,children:a})},f.ListItem=function({children:a,actions:b,className:c,...f}){return(0,d.jsxs)("div",{className:(0,e.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]","transition-colors",c),...f,children:[(0,d.jsx)("div",{className:"flex-1 min-w-0",children:a}),b&&(0,d.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",children:b})]})}},4355:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(31846);let f={default:"bg-black/5 dark:bg-white/10 text-text-muted",primary:"bg-primary/10 text-primary",success:"bg-green-500/10 text-green-600 dark:text-green-400",warning:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",error:"bg-red-500/10 text-red-600 dark:text-red-400",info:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},g={sm:"px-2 py-0.5 text-[10px]",md:"px-2.5 py-1 text-xs",lg:"px-3 py-1.5 text-sm"};function h({children:a,variant:b="default",size:c="md",dot:h=!1,icon:i,className:j}){return(0,d.jsxs)("span",{className:(0,e.cn)("inline-flex items-center gap-1.5 rounded-full font-semibold",f[b],g[c],j),children:[h&&(0,d.jsx)("span",{"aria-hidden":"true",className:(0,e.cn)("size-1.5 rounded-full","success"===b&&"bg-green-500","warning"===b&&"bg-yellow-500","error"===b&&"bg-red-500","info"===b&&"bg-blue-500","primary"===b&&"bg-primary","default"===b&&"bg-gray-500")}),i&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:i}),a]})}},8744:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(29824),i=c(73295);function j({isOpen:a,provider:b,providerInfo:c,onSuccess:f,onClose:g,idcConfig:j}){let[k,l]=(0,e.useState)("waiting"),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(!1),y=(0,e.useRef)(null),{copied:z,copy:A}=(0,i.C)(),[B,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)("/callback?code=...");(0,e.useRef)(!1),(0,e.useRef)(!1);let[F,G]=(0,e.useState)(!1),H=["antigravity","gemini-cli"],I=(0,e.useCallback)(async(a,c)=>{if(m)try{let d=await fetch(`/api/oauth/${b}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:a,redirectUri:m.redirectUri,codeVerifier:m.codeVerifier,state:c})}),e=await d.json();if(!d.ok)throw Error(e.error);l("success"),f?.()}catch(a){a.message?.toLowerCase().includes("redirect_uri_mismatch")&&H.includes(b)?r("redirect_uri_mismatch: As credenciais padr\xe3o do Google OAuth s\xf3 funcionam em localhost. Para uso remoto, configure suas pr\xf3prias credenciais OAuth nas vari\xe1veis de ambiente: "+("antigravity"===b?"ANTIGRAVITY_OAUTH_CLIENT_ID e ANTIGRAVITY_OAUTH_CLIENT_SECRET":"GEMINI_OAUTH_CLIENT_ID e GEMINI_OAUTH_CLIENT_SECRET")+". Veja o README, se\xe7\xe3o 'OAuth em Servidor Remoto'."):r(a.message),l("error")}},[m,b,f]),J=(0,e.useCallback)(async(a,c,d,e)=>{x(!0);for(let g=0;g<60;g++){await new Promise(a=>setTimeout(a,1e3*d));try{let g=await fetch(`/api/oauth/${b}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:a,codeVerifier:c,extraData:e})}),h=await g.json();if(h.success){l("success"),x(!1),f?.();return}if("expired_token"===h.error||"access_denied"===h.error)throw Error(h.errorDescription||h.error);"slow_down"===h.error&&(d=Math.min(d+5,30))}catch(a){r(a.message),l("error"),x(!1);return}}r("Authorization timeout"),l("error"),x(!1)},[b,f]),K=(0,e.useCallback)(async()=>{if(b)try{let a;if(r(null),"github"===b||"qwen"===b||"kiro"===b||"kimi-coding"===b||"kilocode"===b){t(!0),l("waiting");let a=await fetch(`/api/oauth/${b}/device-code`),c=await a.json();if(!a.ok)throw Error(c.error);v(c);let d=c.verification_uri_complete||c.verification_uri;d&&window.open(d,"oauth_verify");let e="kiro"===b?{_clientId:c._clientId,_clientSecret:c._clientSecret}:null;J(c.device_code,c.codeVerifier,c.interval||5,e);return}if("codex"===b&&B){try{let a=await fetch("/api/oauth/codex/start-callback-server"),b=await a.json();if(!a.ok)throw Error(b.error);n({...b,redirectUri:b.redirectUri}),l("waiting"),window.open(b.authUrl,"oauth_auth"),x(!0);for(let a=0;a<150;a++){await new Promise(a=>setTimeout(a,2e3));let a=await fetch("/api/oauth/codex/poll-callback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),b=await a.json();if(b.success){l("success"),x(!1),f?.();return}if(b.error&&!b.pending)throw Error(b.errorDescription||b.error)}throw x(!1),Error("Authorization timeout")}catch(a){x(!1),l("input"),r(a.message+" — You can paste the callback URL manually below.")}return}if("codex"===b||"openai"===b)a="http://localhost:1455/auth/callback";else if(H.includes(b)){let b=window.location.port||"20128";a=`http://localhost:${b}/callback`}else if(B){let b=window.location.port||("https:"===window.location.protocol?"443":"80");a=`http://localhost:${b}/callback`}else{let b=process.env.NEXT_PUBLIC_BASE_URL,c=b&&"http://localhost:20128"!==b?b.replace(/\/$/,""):window.location.origin;a=`${c}/callback`}let c=await fetch(`/api/oauth/${b}/authorize?redirect_uri=${encodeURIComponent(a)}`),d=await c.json();if(!c.ok)throw Error(d.error);n({...d,redirectUri:a}),F?(l("waiting"),y.current=window.open(d.authUrl,"oauth_popup","width=600,height=700"),y.current||l("input")):(l("input"),window.open(d.authUrl,"oauth_auth"))}catch(a){r(a.message),l("error")}},[b,B,F,J,f]),L=async()=>{try{r(null);let a=new URL(o),b=a.searchParams.get("code"),c=a.searchParams.get("state"),d=a.searchParams.get("error");if(d)throw Error(a.searchParams.get("error_description")||d);if(!b)throw Error("No authorization code found in URL");await I(b,c)}catch(a){r(a.message),l("error")}};return b&&c?(0,d.jsx)(h.aF,{isOpen:a,title:`Connect ${c.name}`,onClose:g,size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:["waiting"===k&&!s&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Waiting for Authorization"}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Complete the authorization in the popup window."}),(0,d.jsx)(h.$n,{variant:"ghost",onClick:()=>l("input"),children:"Popup blocked? Enter URL manually"})]}),"waiting"===k&&s&&u&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"text-center py-4",children:[(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the URL below and enter the code:"}),(0,d.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,d.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Verification URL"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"flex-1 text-sm break-all",children:u.verification_uri}),(0,d.jsx)(h.$n,{size:"sm",variant:"ghost",icon:"verify_url"===z?"check":"content_copy",onClick:()=>A(u.verification_uri,"verify_url")})]})]}),(0,d.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,d.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,d.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,d.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:u.user_code}),(0,d.jsx)(h.$n,{size:"sm",variant:"ghost",icon:"user_code"===z?"check":"content_copy",onClick:()=>A(u.user_code,"user_code")})]})]})]}),w&&(0,d.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"input"===k&&!s&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"space-y-4",children:[!F&&H.includes(b)&&(0,d.jsxs)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-200",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"warning"}),(0,d.jsx)("strong",{children:"Acesso remoto + Google OAuth:"})," As credenciais padr\xe3o s\xf3 aceitam redirect para ",(0,d.jsx)("code",{children:"localhost"}),". Ap\xf3s autorizar, o browser tentar\xe1 abrir",(0,d.jsx)("code",{children:"localhost"})," — copie essa URL completa e cole abaixo. Para uso totalmente remoto sem esse passo manual,"," ",(0,d.jsx)("a",{href:"https://github.com/diegosouzapw/OmniRoute#oauth-em-servidor-remoto",target:"_blank",rel:"noreferrer",className:"underline",children:"configure suas pr\xf3prias credenciais OAuth"}),"."]}),!F&&!H.includes(b)&&(0,d.jsxs)("div",{className:"rounded-lg border border-blue-500/30 bg-blue-500/10 p-3 text-xs text-blue-200",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"info"}),(0,d.jsx)("strong",{children:"Remote access:"})," Since you're accessing OmniRoute remotely, after authorizing you'll see an error page (localhost not found). That's expected — just copy the full URL from your browser's address bar and paste it below."]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.pd,{value:m?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,d.jsx)(h.$n,{variant:"secondary",icon:"auth_url"===z?"check":"content_copy",onClick:()=>A(m?.authUrl,"auth_url"),children:"Copy"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser."}),(0,d.jsx)(h.pd,{value:o,onChange:a=>p(a.target.value),placeholder:D,className:"font-mono text-xs"})]})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:L,fullWidth:!0,disabled:!o,children:"Connect"}),(0,d.jsx)(h.$n,{onClick:g,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===k&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,d.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",c.name," account has been connected."]}),(0,d.jsx)(h.$n,{onClick:g,fullWidth:!0,children:"Done"})]}),"error"===k&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,d.jsx)("p",{className:"text-sm text-red-600 mb-4",children:q}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:K,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,d.jsx)(h.$n,{onClick:g,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}j.propTypes={isOpen:g().bool.isRequired,provider:g().string,providerInfo:g().shape({name:g().string}),onSuccess:g().func,onClose:g().func.isRequired}},16116:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(49885),f=c.n(e),g=c(59869);function h({children:a}){return(0,d.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,d.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,d.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,d.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,d.jsx)(g.default,{variant:"card"})}),(0,d.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:a})]})}h.propTypes={children:f().node.isRequired}},17908:(a,b,c)=>{function d(a){try{return new Date(a).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"-"}}function e(a){return a?a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`:"-"}function f(a){if(!a||"-"===a)return"-";let b=a.indexOf("@");return b>3?a.slice(0,3)+"***"+a.slice(b):a.length>8?a.slice(0,5)+"***":a}function g(a,b){if(!a&&!b)return"—";let c=a||"key";return b?`${c} (${function(a,b=2,c=2){return a?a.length<=b+c?`${a.slice(0,1)}***`:`${a.slice(0,b)}***${a.slice(-c)}`:""}(b,4,4)})`:c}function h(a){return a>=1e9?`${(a/1e9).toFixed(1)}B`:a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:new Intl.NumberFormat().format(a||0)}function i(a){return new Intl.NumberFormat().format(a||0)}function j(a){return`$${(a||0).toFixed(2)}`}function k(a,b=50){if(!a)return"-";try{let c=new URL(a),d=c.hostname+c.pathname;return d.length>b?d.slice(0,b)+"…":d}catch{return a.length>b?a.slice(0,b)+"…":a}}c.d(b,{F0:()=>j,Ib:()=>f,VK:()=>h,VO:()=>g,Y1:()=>k,a3:()=>e,fU:()=>d,xW:()=>i})},18732:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(35005),f=c(67484);let g={success:"✓",error:"✕",warning:"⚠",info:"ℹ"},h={success:{bg:"rgba(16, 185, 129, 0.15)",border:"rgba(16, 185, 129, 0.4)",icon:"#10b981"},error:{bg:"rgba(239, 68, 68, 0.15)",border:"rgba(239, 68, 68, 0.4)",icon:"#ef4444"},warning:{bg:"rgba(245, 158, 11, 0.15)",border:"rgba(245, 158, 11, 0.4)",icon:"#f59e0b"},info:{bg:"rgba(59, 130, 246, 0.15)",border:"rgba(59, 130, 246, 0.4)",icon:"#3b82f6"}};function i({notification:a,onDismiss:b}){let[c,e]=(0,f.useState)(!1),i=h[a.type]||h.info;return(0,d.jsxs)("div",{role:"alert","aria-live":"polite",style:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px 16px",borderRadius:"10px",backgroundColor:i.bg,border:`1px solid ${i.border}`,backdropFilter:"blur(12px)",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",minWidth:"320px",maxWidth:"420px",animation:c?"toastOut 0.2s ease-in forwards":"toastIn 0.3s ease-out forwards",transition:"all 0.2s ease"},children:[(0,d.jsx)("span",{style:{fontSize:"18px",color:i.icon,fontWeight:"bold",lineHeight:1,marginTop:"2px"},children:g[a.type]}),(0,d.jsxs)("div",{style:{flex:1,minWidth:0},children:[a.title&&(0,d.jsx)("div",{style:{fontWeight:600,fontSize:"14px",color:"var(--text-primary, #fff)",marginBottom:"2px"},children:a.title}),(0,d.jsx)("div",{style:{fontSize:"13px",color:"var(--text-secondary, #ccc)",lineHeight:1.4},children:a.message})]}),a.dismissible&&(0,d.jsx)("button",{onClick:()=>{e(!0),setTimeout(()=>b(a.id),200)},"aria-label":"Dismiss notification",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary, #999)",fontSize:"16px",padding:"0 2px",lineHeight:1,opacity:.6,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity="0.6",children:"\xd7"})]})}function j(){let{notifications:a,removeNotification:b}=(0,e.i)();return 0===a.length?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("style",{children:`
1
+ "use strict";exports.id=9824,exports.ids=[9824],exports.modules={1237:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(67484),f=c(65953),g=c(53156);function h({isOpen:a,onClose:b,title:c="Manual Configuration",configs:h=[]}){let[i,j]=(0,e.useState)(null),k=async(a,b)=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(a);else{let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.left="-9999px",b.style.top="-9999px",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select(),document.execCommand("copy"),document.body.removeChild(b)}j(b),setTimeout(()=>j(null),2e3)}catch(a){console.log("Failed to copy:",a)}};return(0,d.jsx)(f.default,{isOpen:a,onClose:b,title:c,size:"xl",children:(0,d.jsx)("div",{className:"flex flex-col gap-4",children:h.map((a,b)=>(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-text-main",children:a.filename}),(0,d.jsxs)(g.default,{variant:"ghost",size:"sm",onClick:()=>k(a.content,b),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:i===b?"check":"content_copy"}),i===b?"Copied!":"Copy"]})]}),(0,d.jsx)("pre",{className:"px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs overflow-x-auto whitespace-pre-wrap break-all max-h-60 overflow-y-auto border border-border",children:a.content})]},b))})})}},2490:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(31846);function f({children:a,title:b,subtitle:c,icon:f,action:g,padding:h="md",hover:i=!1,className:j,...k}){return(0,d.jsxs)("div",{className:(0,e.cn)("bg-surface","border border-black/5 dark:border-white/5","rounded-lg shadow-sm",i&&"hover:shadow-md hover:border-primary/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[h],j),...k,children:[(b||g)&&(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[f&&(0,d.jsx)("div",{className:"p-2 rounded-lg bg-bg text-text-muted",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:f})}),(0,d.jsxs)("div",{children:[b&&(0,d.jsx)("h3",{className:"text-text-main font-semibold",children:b}),c&&(0,d.jsx)("p",{className:"text-sm text-text-muted",children:c})]})]}),g]}),a]})}f.Section=function({children:a,className:b,...c}){return(0,d.jsx)("div",{className:(0,e.cn)("p-4 rounded-lg","bg-black/[0.02] dark:bg-white/[0.02]","border border-black/5 dark:border-white/5",b),...c,children:a})},f.Row=function({children:a,className:b,...c}){return(0,d.jsx)("div",{className:(0,e.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-black/5 dark:border-white/5 last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]",b),...c,children:a})},f.ListItem=function({children:a,actions:b,className:c,...f}){return(0,d.jsxs)("div",{className:(0,e.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]","transition-colors",c),...f,children:[(0,d.jsx)("div",{className:"flex-1 min-w-0",children:a}),b&&(0,d.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",children:b})]})}},4355:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(31846);let f={default:"bg-black/5 dark:bg-white/10 text-text-muted",primary:"bg-primary/10 text-primary",success:"bg-green-500/10 text-green-600 dark:text-green-400",warning:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",error:"bg-red-500/10 text-red-600 dark:text-red-400",info:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},g={sm:"px-2 py-0.5 text-[10px]",md:"px-2.5 py-1 text-xs",lg:"px-3 py-1.5 text-sm"};function h({children:a,variant:b="default",size:c="md",dot:h=!1,icon:i,className:j}){return(0,d.jsxs)("span",{className:(0,e.cn)("inline-flex items-center gap-1.5 rounded-full font-semibold",f[b],g[c],j),children:[h&&(0,d.jsx)("span",{"aria-hidden":"true",className:(0,e.cn)("size-1.5 rounded-full","success"===b&&"bg-green-500","warning"===b&&"bg-yellow-500","error"===b&&"bg-red-500","info"===b&&"bg-blue-500","primary"===b&&"bg-primary","default"===b&&"bg-gray-500")}),i&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:i}),a]})}},8744:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(29824),i=c(73295);function j({isOpen:a,provider:b,providerInfo:c,onSuccess:f,onClose:g,idcConfig:j}){let[k,l]=(0,e.useState)("waiting"),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(!1),y=(0,e.useRef)(null),{copied:z,copy:A}=(0,i.C)(),[B,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)("/callback?code=...");(0,e.useRef)(!1),(0,e.useRef)(!1);let[F,G]=(0,e.useState)(!1),H=["antigravity","gemini-cli"],I=(0,e.useCallback)(async(a,c)=>{if(m)try{let d=await fetch(`/api/oauth/${b}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:a,redirectUri:m.redirectUri,codeVerifier:m.codeVerifier,state:c})}),e=await d.json();if(!d.ok)throw Error(e.error);l("success"),f?.()}catch(a){a.message?.toLowerCase().includes("redirect_uri_mismatch")&&H.includes(b)?r("redirect_uri_mismatch: As credenciais padr\xe3o do Google OAuth s\xf3 funcionam em localhost. Para uso remoto, configure suas pr\xf3prias credenciais OAuth nas vari\xe1veis de ambiente: "+("antigravity"===b?"ANTIGRAVITY_OAUTH_CLIENT_ID e ANTIGRAVITY_OAUTH_CLIENT_SECRET":"GEMINI_OAUTH_CLIENT_ID e GEMINI_OAUTH_CLIENT_SECRET")+". Veja o README, se\xe7\xe3o 'OAuth em Servidor Remoto'."):r(a.message),l("error")}},[m,b,f]),J=(0,e.useCallback)(async(a,c,d,e)=>{x(!0);for(let g=0;g<60;g++){await new Promise(a=>setTimeout(a,1e3*d));try{let g=await fetch(`/api/oauth/${b}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:a,codeVerifier:c,extraData:e})}),h=await g.json();if(h.success){l("success"),x(!1),f?.();return}if("expired_token"===h.error||"access_denied"===h.error)throw Error(h.errorDescription||h.error);"slow_down"===h.error&&(d=Math.min(d+5,30))}catch(a){r(a.message),l("error"),x(!1);return}}r("Authorization timeout"),l("error"),x(!1)},[b,f]),K=(0,e.useCallback)(async()=>{if(b)try{let a;if(r(null),"github"===b||"qwen"===b||"kiro"===b||"kimi-coding"===b||"kilocode"===b){t(!0),l("waiting");let a=await fetch(`/api/oauth/${b}/device-code`),c=await a.json();if(!a.ok)throw Error(c.error);v(c);let d=c.verification_uri_complete||c.verification_uri;d&&window.open(d,"oauth_verify");let e="kiro"===b?{_clientId:c._clientId,_clientSecret:c._clientSecret}:null;J(c.device_code,c.codeVerifier,c.interval||5,e);return}if("codex"===b&&B){try{let a=await fetch("/api/oauth/codex/start-callback-server"),b=await a.json();if(!a.ok)throw Error(b.error);n({...b,redirectUri:b.redirectUri}),l("waiting"),window.open(b.authUrl,"oauth_auth"),x(!0);for(let a=0;a<150;a++){await new Promise(a=>setTimeout(a,2e3));let a=await fetch("/api/oauth/codex/poll-callback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),b=await a.json();if(b.success){l("success"),x(!1),f?.();return}if(b.error&&!b.pending)throw Error(b.errorDescription||b.error)}throw x(!1),Error("Authorization timeout")}catch(a){x(!1),l("input"),r(a.message+" — You can paste the callback URL manually below.")}return}if("codex"===b||"openai"===b)a="http://localhost:1455/auth/callback";else if(H.includes(b)){let b=window.location.port||"20128";a=`http://localhost:${b}/callback`}else if(B){let b=window.location.port||("https:"===window.location.protocol?"443":"80");a=`http://localhost:${b}/callback`}else{let b=window.location.origin;a=`${b}/callback`}let c=await fetch(`/api/oauth/${b}/authorize?redirect_uri=${encodeURIComponent(a)}`),d=await c.json();if(!c.ok)throw Error(d.error);n({...d,redirectUri:a}),F?(l("waiting"),y.current=window.open(d.authUrl,"oauth_popup","width=600,height=700"),y.current||l("input")):(l("input"),window.open(d.authUrl,"oauth_auth"))}catch(a){r(a.message),l("error")}},[b,B,F,J,f]),L=async()=>{try{r(null);let a=new URL(o),b=a.searchParams.get("code"),c=a.searchParams.get("state"),d=a.searchParams.get("error");if(d)throw Error(a.searchParams.get("error_description")||d);if(!b)throw Error("No authorization code found in URL");await I(b,c)}catch(a){r(a.message),l("error")}};return b&&c?(0,d.jsx)(h.aF,{isOpen:a,title:`Connect ${c.name}`,onClose:g,size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:["waiting"===k&&!s&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Waiting for Authorization"}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Complete the authorization in the popup window."}),(0,d.jsx)(h.$n,{variant:"ghost",onClick:()=>l("input"),children:"Popup blocked? Enter URL manually"})]}),"waiting"===k&&s&&u&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"text-center py-4",children:[(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the URL below and enter the code:"}),(0,d.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,d.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Verification URL"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"flex-1 text-sm break-all",children:u.verification_uri}),(0,d.jsx)(h.$n,{size:"sm",variant:"ghost",icon:"verify_url"===z?"check":"content_copy",onClick:()=>A(u.verification_uri,"verify_url")})]})]}),(0,d.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,d.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,d.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,d.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:u.user_code}),(0,d.jsx)(h.$n,{size:"sm",variant:"ghost",icon:"user_code"===z?"check":"content_copy",onClick:()=>A(u.user_code,"user_code")})]})]})]}),w&&(0,d.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"input"===k&&!s&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"space-y-4",children:[!F&&H.includes(b)&&(0,d.jsxs)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-200",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"warning"}),(0,d.jsx)("strong",{children:"Acesso remoto + Google OAuth:"})," As credenciais padr\xe3o s\xf3 aceitam redirect para ",(0,d.jsx)("code",{children:"localhost"}),". Ap\xf3s autorizar, o browser tentar\xe1 abrir",(0,d.jsx)("code",{children:"localhost"})," — copie essa URL completa e cole abaixo. Para uso totalmente remoto sem esse passo manual,"," ",(0,d.jsx)("a",{href:"https://github.com/diegosouzapw/OmniRoute#oauth-em-servidor-remoto",target:"_blank",rel:"noreferrer",className:"underline",children:"configure suas pr\xf3prias credenciais OAuth"}),"."]}),!F&&!H.includes(b)&&(0,d.jsxs)("div",{className:"rounded-lg border border-blue-500/30 bg-blue-500/10 p-3 text-xs text-blue-200",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"info"}),(0,d.jsx)("strong",{children:"Remote access:"})," Since you're accessing OmniRoute remotely, after authorizing you'll see an error page (localhost not found). That's expected — just copy the full URL from your browser's address bar and paste it below."]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.pd,{value:m?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,d.jsx)(h.$n,{variant:"secondary",icon:"auth_url"===z?"check":"content_copy",onClick:()=>A(m?.authUrl,"auth_url"),children:"Copy"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser."}),(0,d.jsx)(h.pd,{value:o,onChange:a=>p(a.target.value),placeholder:D,className:"font-mono text-xs"})]})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:L,fullWidth:!0,disabled:!o,children:"Connect"}),(0,d.jsx)(h.$n,{onClick:g,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===k&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,d.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",c.name," account has been connected."]}),(0,d.jsx)(h.$n,{onClick:g,fullWidth:!0,children:"Done"})]}),"error"===k&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,d.jsx)("p",{className:"text-sm text-red-600 mb-4",children:q}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:K,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,d.jsx)(h.$n,{onClick:g,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}j.propTypes={isOpen:g().bool.isRequired,provider:g().string,providerInfo:g().shape({name:g().string}),onSuccess:g().func,onClose:g().func.isRequired}},16116:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(49885),f=c.n(e),g=c(59869);function h({children:a}){return(0,d.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,d.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,d.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,d.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,d.jsx)(g.default,{variant:"card"})}),(0,d.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:a})]})}h.propTypes={children:f().node.isRequired}},17908:(a,b,c)=>{function d(a){try{return new Date(a).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"-"}}function e(a){return a?a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`:"-"}function f(a){if(!a||"-"===a)return"-";let b=a.indexOf("@");return b>3?a.slice(0,3)+"***"+a.slice(b):a.length>8?a.slice(0,5)+"***":a}function g(a,b){if(!a&&!b)return"—";let c=a||"key";return b?`${c} (${function(a,b=2,c=2){return a?a.length<=b+c?`${a.slice(0,1)}***`:`${a.slice(0,b)}***${a.slice(-c)}`:""}(b,4,4)})`:c}function h(a){return a>=1e9?`${(a/1e9).toFixed(1)}B`:a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:new Intl.NumberFormat().format(a||0)}function i(a){return new Intl.NumberFormat().format(a||0)}function j(a){return`$${(a||0).toFixed(2)}`}function k(a,b=50){if(!a)return"-";try{let c=new URL(a),d=c.hostname+c.pathname;return d.length>b?d.slice(0,b)+"…":d}catch{return a.length>b?a.slice(0,b)+"…":a}}c.d(b,{F0:()=>j,Ib:()=>f,VK:()=>h,VO:()=>g,Y1:()=>k,a3:()=>e,fU:()=>d,xW:()=>i})},18732:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(35005),f=c(67484);let g={success:"✓",error:"✕",warning:"⚠",info:"ℹ"},h={success:{bg:"rgba(16, 185, 129, 0.15)",border:"rgba(16, 185, 129, 0.4)",icon:"#10b981"},error:{bg:"rgba(239, 68, 68, 0.15)",border:"rgba(239, 68, 68, 0.4)",icon:"#ef4444"},warning:{bg:"rgba(245, 158, 11, 0.15)",border:"rgba(245, 158, 11, 0.4)",icon:"#f59e0b"},info:{bg:"rgba(59, 130, 246, 0.15)",border:"rgba(59, 130, 246, 0.4)",icon:"#3b82f6"}};function i({notification:a,onDismiss:b}){let[c,e]=(0,f.useState)(!1),i=h[a.type]||h.info;return(0,d.jsxs)("div",{role:"alert","aria-live":"polite",style:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px 16px",borderRadius:"10px",backgroundColor:i.bg,border:`1px solid ${i.border}`,backdropFilter:"blur(12px)",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",minWidth:"320px",maxWidth:"420px",animation:c?"toastOut 0.2s ease-in forwards":"toastIn 0.3s ease-out forwards",transition:"all 0.2s ease"},children:[(0,d.jsx)("span",{style:{fontSize:"18px",color:i.icon,fontWeight:"bold",lineHeight:1,marginTop:"2px"},children:g[a.type]}),(0,d.jsxs)("div",{style:{flex:1,minWidth:0},children:[a.title&&(0,d.jsx)("div",{style:{fontWeight:600,fontSize:"14px",color:"var(--text-primary, #fff)",marginBottom:"2px"},children:a.title}),(0,d.jsx)("div",{style:{fontSize:"13px",color:"var(--text-secondary, #ccc)",lineHeight:1.4},children:a.message})]}),a.dismissible&&(0,d.jsx)("button",{onClick:()=>{e(!0),setTimeout(()=>b(a.id),200)},"aria-label":"Dismiss notification",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary, #999)",fontSize:"16px",padding:"0 2px",lineHeight:1,opacity:.6,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity="0.6",children:"\xd7"})]})}function j(){let{notifications:a,removeNotification:b}=(0,e.i)();return 0===a.length?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("style",{children:`
2
2
  @keyframes toastIn {
3
3
  from { opacity: 0; transform: translateX(100%) scale(0.95); }
4
4
  to { opacity: 1; transform: translateX(0) scale(1); }
@@ -13,7 +13,7 @@
13
13
  `,children:a.name},a.id)})})]}),Object.entries(y).map(([a,b])=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,d.jsx)("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:b.color}}),(0,d.jsx)("span",{className:"text-xs font-medium text-primary",children:b.name}),(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",b.models.length,")"]})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:b.models.map(a=>{let b=f===a.value;return(0,d.jsxs)("button",{onClick:()=>z(a),className:`
14
14
  px-2 py-1 rounded-xl text-xs font-medium transition-all border hover:cursor-pointer
15
15
  ${b?"bg-primary text-white border-primary":"bg-surface border-border text-text-main hover:border-primary/50 hover:bg-primary/5"}
16
- `,children:[a.name,a.isCustom?" ★":""]},a.id)})})]},a)),0===Object.keys(y).length&&0===x.length&&(0,d.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,d.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}l.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,onSelect:g().func.isRequired,selectedModel:g().string,activeProviders:g().arrayOf(g().shape({provider:g().string.isRequired})),title:g().string,modelAliases:g().object}},29518:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(67484),f=c(31846);function g({label:a,type:b="text",placeholder:c,value:g,onChange:h,error:i,hint:j,icon:k,disabled:l=!1,required:m=!1,className:n,inputClassName:o,id:p,...q}){let r=(0,e.useId)(),s=p||r,t=i?`${s}-error`:void 0,u=j&&!i?`${s}-hint`:void 0,v=[t,u].filter(Boolean).join(" ")||void 0;return(0,d.jsxs)("div",{className:(0,f.cn)("flex flex-col gap-1.5",n),children:[a&&(0,d.jsxs)("label",{htmlFor:s,className:"text-sm font-medium text-text-main",children:[a,m&&(0,d.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,d.jsxs)("div",{className:"relative",children:[k&&(0,d.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-text-muted",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:k})}),(0,d.jsx)("input",{id:s,type:b,placeholder:c,value:g,onChange:h,disabled:l,required:m,"aria-required":m||void 0,"aria-invalid":!!i||void 0,"aria-describedby":v,className:(0,f.cn)("w-full py-2 px-3 text-sm text-text-main","bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md","placeholder-text-muted/60","focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none","transition-all shadow-inner disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",k&&"pl-10",i?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",o),...q})]}),i&&(0,d.jsxs)("p",{id:t,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),i]}),j&&!i&&(0,d.jsx)("p",{id:u,className:"text-xs text-text-muted",children:j})]})}},29824:(a,b,c)=>{c.d(b,{Ex:()=>j.default,$n:()=>d.default,Zp:()=>g.default,Qv:()=>i.CardSkeleton,G9:()=>u.default,bQ:()=>y.default,pp:()=>w.default,Qn:()=>x.default,pd:()=>e.default,Mh:()=>t.default,uR:()=>o.default,aF:()=>h.default,rq:()=>n.default,LF:()=>m.default,KN:()=>r.default,Lo:()=>s.default,y7:()=>q.default,Iz:()=>v.default,l6:()=>f.default,UW:()=>l.default,lM:()=>k.default,cn:()=>p.default});var d=c(53156),e=c(29518),f=c(59256),g=c(2490),h=c(65953),i=c(22746);c(45567);var j=c(4355),k=c(65472),l=c(59869);c(75146),c(65892),c(42546),c(22245);var m=c(8744),n=c(29494),o=c(1237);c(82054);var p=c(62688),q=c(46230),r=c(56589),s=c(73979);c(98004);var t=c(41371);c(53140);var u=c(27309),v=c(86059);c(77088);var w=c(85974);c(18732);var x=c(67083);c(52198);var y=c(50818);c(47047),c(16116)},31846:(a,b,c)=>{c.d(b,{cn:()=>d});function d(...a){return a.filter(Boolean).join(" ").replace(/\s+/g," ").trim()}},35005:(a,b,c)=>{c.d(b,{i:()=>f});var d=c(31417);let e=0,f=(0,d.v)((a,b)=>({notifications:[],addNotification:c=>{let d=++e,f={id:d,type:c.type||"info",message:c.message,title:c.title||null,duration:c.duration??5e3,dismissible:c.dismissible??!0,createdAt:Date.now()};return a(a=>({notifications:[...a.notifications,f]})),f.duration>0&&setTimeout(()=>{b().removeNotification(d)},f.duration),d},removeNotification:b=>{a(a=>({notifications:a.notifications.filter(a=>a.id!==b)}))},clearAll:()=>a({notifications:[]}),success:(a,c)=>b().addNotification({type:"success",message:a,title:c}),error:(a,c)=>b().addNotification({type:"error",message:a,title:c,duration:8e3}),warning:(a,c)=>b().addNotification({type:"warning",message:a,title:c}),info:(a,c)=>b().addNotification({type:"info",message:a,title:c})}))},37627:(a,b,c)=>{c.d(b,{Gp:()=>f,Ie:()=>g,Kf:()=>e,RY:()=>d,Yh:()=>k,_Z:()=>j,ng:()=>i});let d={github:{bg:"#6e40c9",text:"#fff",label:"GitHub"},kiro:{bg:"#FF9900",text:"#000",label:"Kiro"},antigravity:{bg:"#4285F4",text:"#fff",label:"AG"},claude:{bg:"#D97757",text:"#fff",label:"Claude"},codex:{bg:"#10A37F",text:"#fff",label:"Codex"},gemini:{bg:"#34A853",text:"#fff",label:"Gemini"},qwen:{bg:"#6366F1",text:"#fff",label:"Qwen"},iflow:{bg:"#EC4899",text:"#fff",label:"iFlow"},fireworks:{bg:"#F97316",text:"#fff",label:"Fireworks"},kimi:{bg:"#06B6D4",text:"#fff",label:"Kimi"},"gemini-cli":{bg:"#34A853",text:"#fff",label:"Gemini CLI"}},e={openai:{bg:"#10A37F",text:"#fff",label:"OpenAI"},claude:{bg:"#D97757",text:"#fff",label:"Claude"},gemini:{bg:"#4285F4",text:"#fff",label:"Gemini"},warmup:{bg:"#F59E0B",text:"#000",label:"Warmup"},bypass:{bg:"#6B7280",text:"#fff",label:"Bypass"}},f={http:{bg:"#3B82F6",text:"#fff",label:"HTTP"},https:{bg:"#10B981",text:"#fff",label:"HTTPS"},socks5:{bg:"#8B5CF6",text:"#fff",label:"SOCKS5"}},g={key:{bg:"#F59E0B",text:"#000",label:"Key"},combo:{bg:"#8B5CF6",text:"#fff",label:"Combo"},provider:{bg:"#3B82F6",text:"#fff",label:"Provider"},global:{bg:"#6B7280",text:"#fff",label:"Global"},direct:{bg:"#374151",text:"#9CA3AF",label:"Direct"}},h=["#D97757","#60A5FA","#34D399","#A78BFA","#F472B6","#FBBF24","#38BDF8","#FB923C","#818CF8","#2DD4BF","#E879F9","#F87171","#4ADE80","#C084FC","#FB7185"];function i(a){return h[a%h.length]}function j(a){return a>=200&&a<300?{bg:"#059669",text:"#fff"}:a>=400&&a<500?{bg:"#D97706",text:"#fff"}:a>=500?{bg:"#DC2626",text:"#fff"}:0===a?{bg:"#6366F1",text:"#fff"}:{bg:"#6B7280",text:"#fff"}}function k(a){return"success"===a?{bg:"#059669",text:"#fff"}:"error"===a?{bg:"#DC2626",text:"#fff"}:"timeout"===a?{bg:"#D97706",text:"#fff"}:{bg:"#6B7280",text:"#fff"}}},41371:(a,b,c)=>{c.d(b,{default:()=>k});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(8744),i=c(98004),j=c(53140);function k({isOpen:a,providerInfo:b,onSuccess:c,onClose:f}){let[g,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(null),p=(0,e.useCallback)((a,b)=>{"builder-id"===a?k("builder-id"):"idc"===a?(k("idc"),o(b)):"social"===a?(k("social"),m(b.provider)):"import"===a&&c?.()},[c]),q=()=>{k(null),m(null),o(null)};return g?"builder-id"===g||"idc"===g?(0,d.jsx)(h.default,{isOpen:a,provider:"kiro",providerInfo:b,onSuccess:()=>{k(null),o(null),c?.()},onClose:q,idcConfig:n}):"social"===g&&l?(0,d.jsx)(j.default,{isOpen:a,provider:l,onSuccess:()=>{k(null),m(null),c?.()},onClose:q}):null:(0,d.jsx)(i.default,{isOpen:a,onMethodSelect:p,onClose:f})}k.propTypes={isOpen:g().bool.isRequired,providerInfo:g().shape({name:g().string}),onSuccess:g().func,onClose:g().func.isRequired}},42546:(a,b,c)=>{c.d(b,{default:()=>u});var d=c(48249),e=c(19099),f=c(2116),g=c.n(f),h=c(81220),i=c(49885),j=c.n(i),k=c(29824),l=c(77360),m=c(67484);let n={healthy:{icon:"check_circle",color:"#22c55e",tooltip:"All tokens healthy"},warning:{icon:"warning",color:"#f59e0b",tooltip:"Some tokens need attention"},error:{icon:"error",color:"#ef4444",tooltip:"Token refresh failures detected"},unknown:{icon:"help",color:"#6b7280",tooltip:"Health status unknown"}};function o(){let a=(0,l.c)("stats"),[b,c]=(0,m.useState)(null),[e,f]=(0,m.useState)(!1);if(!b||0===b.total)return null;let g=n[b.status]||n.unknown;return(0,d.jsxs)("div",{className:"relative",onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[(0,d.jsxs)("button",{className:"flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-surface/30 transition-colors",title:g.tooltip,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",style:{color:g.color},children:g.icon}),b.errored>0&&(0,d.jsx)("span",{className:"text-xs font-medium",style:{color:g.color},children:b.errored})]}),e&&(0,d.jsxs)("div",{className:"absolute top-full right-0 mt-1 z-50 min-w-[200px] p-3 rounded-lg shadow-lg",style:{background:"rgba(15, 15, 25, 0.95)",border:"1px solid rgba(255,255,255,0.1)",backdropFilter:"blur(12px)"},children:[(0,d.jsx)("p",{className:"text-xs font-medium text-text-main mb-2",children:a("tokenHealth")}),(0,d.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,d.jsxs)("div",{className:"flex justify-between",children:[(0,d.jsx)("span",{className:"text-text-muted",children:a("totalOAuth")}),(0,d.jsx)("span",{className:"text-text-main",children:b.total})]}),(0,d.jsxs)("div",{className:"flex justify-between",children:[(0,d.jsx)("span",{className:"text-emerald-400",children:a("healthy")}),(0,d.jsx)("span",{className:"text-text-main",children:b.healthy})]}),b.errored>0&&(0,d.jsxs)("div",{className:"flex justify-between",children:[(0,d.jsx)("span",{className:"text-red-400",children:a("errored")}),(0,d.jsx)("span",{className:"text-text-main",children:b.errored})]}),b.warning>0&&(0,d.jsxs)("div",{className:"flex justify-between",children:[(0,d.jsx)("span",{className:"text-amber-400",children:a("warning")}),(0,d.jsx)("span",{className:"text-text-main",children:b.warning})]}),b.lastCheckAt&&(0,d.jsxs)("div",{className:"flex justify-between mt-1 pt-1 border-t border-white/5",children:[(0,d.jsx)("span",{className:"text-text-muted",children:a("lastCheck")}),(0,d.jsx)("span",{className:"text-text-muted",children:new Date(b.lastCheckAt).toLocaleTimeString()})]})]})]})]})}let p=[{code:"en",label:"EN",name:"English",flag:"\uD83C\uDDFA\uD83C\uDDF8"},{code:"pt-BR",label:"PT-BR",name:"Portugu\xeas (Brasil)",flag:"\uD83C\uDDE7\uD83C\uDDF7"},{code:"es",label:"ES",name:"Espa\xf1ol",flag:"\uD83C\uDDEA\uD83C\uDDF8"},{code:"fr",label:"FR",name:"Fran\xe7ais",flag:"\uD83C\uDDEB\uD83C\uDDF7"},{code:"it",label:"IT",name:"Italiano",flag:"\uD83C\uDDEE\uD83C\uDDF9"},{code:"ru",label:"RU",name:"Русский",flag:"\uD83C\uDDF7\uD83C\uDDFA"},{code:"zh-CN",label:"ZH-CN",name:"中文 (简体)",flag:"\uD83C\uDDE8\uD83C\uDDF3"},{code:"de",label:"DE",name:"Deutsch",flag:"\uD83C\uDDE9\uD83C\uDDEA"},{code:"in",label:"IN",name:"हिन्दी",flag:"\uD83C\uDDEE\uD83C\uDDF3"},{code:"th",label:"TH",name:"ไทย",flag:"\uD83C\uDDF9\uD83C\uDDED"},{code:"uk-UA",label:"UK-UA",name:"Українська",flag:"\uD83C\uDDFA\uD83C\uDDE6"},{code:"ar",label:"AR",name:"العربية",flag:"\uD83C\uDDF8\uD83C\uDDE6"},{code:"ja",label:"JA",name:"日本語",flag:"\uD83C\uDDEF\uD83C\uDDF5"},{code:"vi",label:"VI",name:"Tiếng Việt",flag:"\uD83C\uDDFB\uD83C\uDDF3"},{code:"bg",label:"BG",name:"Български",flag:"\uD83C\uDDE7\uD83C\uDDEC"},{code:"da",label:"DA",name:"Dansk",flag:"\uD83C\uDDE9\uD83C\uDDF0"},{code:"fi",label:"FI",name:"Suomi",flag:"\uD83C\uDDEB\uD83C\uDDEE"},{code:"he",label:"HE",name:"עברית",flag:"\uD83C\uDDEE\uD83C\uDDF1"},{code:"hu",label:"HU",name:"Magyar",flag:"\uD83C\uDDED\uD83C\uDDFA"},{code:"id",label:"ID",name:"Bahasa Indonesia",flag:"\uD83C\uDDEE\uD83C\uDDE9"},{code:"ko",label:"KO",name:"한국어",flag:"\uD83C\uDDF0\uD83C\uDDF7"},{code:"ms",label:"MS",name:"Bahasa Melayu",flag:"\uD83C\uDDF2\uD83C\uDDFE"},{code:"nl",label:"NL",name:"Nederlands",flag:"\uD83C\uDDF3\uD83C\uDDF1"},{code:"no",label:"NO",name:"Norsk",flag:"\uD83C\uDDF3\uD83C\uDDF4"},{code:"pt",label:"PT",name:"Portugu\xeas (Portugal)",flag:"\uD83C\uDDF5\uD83C\uDDF9"},{code:"ro",label:"RO",name:"Rom\xe2nă",flag:"\uD83C\uDDF7\uD83C\uDDF4"},{code:"pl",label:"PL",name:"Polski",flag:"\uD83C\uDDF5\uD83C\uDDF1"},{code:"sk",label:"SK",name:"Slovenčina",flag:"\uD83C\uDDF8\uD83C\uDDF0"},{code:"sv",label:"SV",name:"Svenska",flag:"\uD83C\uDDF8\uD83C\uDDEA"},{code:"phi",label:"PHI",name:"Filipino",flag:"\uD83C\uDDF5\uD83C\uDDED"}],q="NEXT_LOCALE";var r=c(89400);function s(){let a=(0,r.Ym)(),b=(0,e.useRouter)(),[c,f]=(0,m.useState)(!1),g=(0,m.useRef)(null),h=p.find(b=>b.code===a)||p[0];return(0,d.jsxs)("div",{ref:g,className:"relative",children:[(0,d.jsxs)("button",{onClick:()=>f(!c),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-sm font-medium text-text-main hover:bg-surface-hover transition-all border border-transparent hover:border-border",title:h.name,children:[(0,d.jsx)("span",{className:"text-base leading-none",children:h.flag}),(0,d.jsx)("span",{className:"text-xs font-semibold tracking-wide",children:h.label}),(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] text-text-muted transition-transform ${c?"rotate-180":""}`,children:"expand_more"})]}),c&&(0,d.jsx)("div",{className:"absolute right-0 top-full mt-1 w-56 max-h-80 rounded-xl border border-border bg-bg shadow-xl z-50 overflow-y-auto animate-in fade-in slide-in-from-top-1 duration-150",children:p.map(c=>(0,d.jsxs)("button",{onClick:()=>(c=>{if(c===a)return void f(!1);document.cookie=`${q}=${c};path=/;max-age=31536000;samesite=lax`;try{localStorage.setItem(q,c)}catch{}f(!1),b.refresh()})(c.code),className:`w-full flex items-center gap-2.5 px-3 py-2.5 text-sm transition-colors ${c.code===a?"bg-primary/10 text-primary font-semibold":"text-text-main hover:bg-surface-hover"}`,children:[(0,d.jsx)("span",{className:"text-base leading-none",children:c.flag}),(0,d.jsx)("span",{className:"flex-1 text-left",children:c.name}),c.code===a&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"check"})]},c.code))})]})}var t=c(17084);function u({onMenuClick:a,showMenuButton:b=!0}){let c=(0,e.usePathname)(),f=(0,e.useRouter)(),i=(0,l.c)("header"),{title:j,description:m,breadcrumbs:n}=function(a){let b=(0,l.c)("header");if(!a)return{title:"",description:"",breadcrumbs:[]};let c=a.match(/\/providers\/([^/]+)$/);if(c){let a=c[1],d=t.zN[a]||t.IS[a]||t.fg[a];if(d)return{title:d.name,description:"",breadcrumbs:[{label:b("providers"),href:"/dashboard/providers"},{label:d.name,image:`/providers/${d.id}.png`}]};if(a.startsWith(t.JH))return{title:b("openaiCompatible"),description:"",breadcrumbs:[{label:b("providers"),href:"/dashboard/providers"},{label:b("openaiCompatible"),image:"/providers/oai-cc.png"}]};if(a.startsWith(t.DI))return{title:b("anthropicCompatible"),description:"",breadcrumbs:[{label:b("providers"),href:"/dashboard/providers"},{label:b("anthropicCompatible"),image:"/providers/anthropic-m.png"}]}}return a.includes("/providers")?{title:b("providers"),description:b("providerDescription"),breadcrumbs:[]}:a.includes("/combos")?{title:b("combos"),description:b("comboDescription"),breadcrumbs:[]}:a.includes("/usage")?{title:b("usage"),description:b("usageDescription"),breadcrumbs:[]}:a.includes("/analytics")?{title:b("analytics"),description:b("analyticsDescription"),breadcrumbs:[]}:a.includes("/cli-tools")?{title:b("cliTools"),description:b("cliToolsDescription"),breadcrumbs:[]}:"/dashboard"===a?{title:b("home"),description:b("homeDescription"),breadcrumbs:[]}:a.includes("/endpoint")?{title:b("endpoint"),description:b("endpointDescription"),breadcrumbs:[]}:a.includes("/profile")?{title:b("settings"),description:b("settingsDescription"),breadcrumbs:[]}:{title:"",description:"",breadcrumbs:[]}}(c),p=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&(f.push("/login"),f.refresh())}catch(a){console.error("Failed to logout:",a)}};return(0,d.jsxs)("header",{className:"flex items-center justify-between px-8 py-5 border-b border-black/5 dark:border-white/5 bg-bg/80 backdrop-blur-xl z-10 sticky top-0",children:[(0,d.jsx)("div",{className:"flex items-center gap-3 lg:hidden",children:b&&(0,d.jsx)("button",{onClick:a,className:"text-text-main hover:text-primary transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined",children:"menu"})})}),(0,d.jsx)("div",{className:"hidden lg:flex flex-col",children:n.length>0?(0,d.jsx)("div",{className:"flex items-center gap-2",children:n.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[b>0&&(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-base",children:"chevron_right"}),a.href?(0,d.jsx)(g(),{href:a.href,className:"text-text-muted hover:text-primary transition-colors",children:a.label}):(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[a.image&&(0,d.jsx)(h.default,{src:a.image,alt:a.label,width:28,height:28,className:"object-contain rounded max-w-[28px] max-h-[28px]",sizes:"28px",onError:a=>{a.currentTarget.style.display="none"}}),(0,d.jsx)("h1",{className:"text-2xl font-semibold text-text-main tracking-tight",children:a.label})]})]},`${a.label}-${a.href||"current"}`))}):j?(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-2xl font-semibold text-text-main tracking-tight",children:j}),m&&(0,d.jsx)("p",{className:"text-sm text-text-muted",children:m})]}):null}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-auto",children:[(0,d.jsx)(s,{}),(0,d.jsx)(k.UW,{}),(0,d.jsx)(o,{}),(0,d.jsx)("button",{onClick:p,className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-red-500 hover:bg-red-500/10 transition-all",title:i("logout"),children:(0,d.jsx)("span",{className:"material-symbols-outlined",children:"logout"})})]})]})}u.propTypes={onMenuClick:j().func,showMenuButton:j().bool}},45567:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(31846);function f({src:a,alt:b="Avatar",name:c,size:f="md",className:g}){let h={xs:"size-6 text-xs",sm:"size-8 text-sm",md:"size-10 text-base",lg:"size-12 text-lg",xl:"size-16 text-xl"};return a?(0,d.jsx)("div",{className:(0,e.cn)("rounded-full bg-cover bg-center bg-no-repeat","ring-2 ring-white dark:ring-surface-dark shadow-sm",h[f],g),style:{backgroundImage:`url(${a})`},role:"img","aria-label":b}):(0,d.jsx)("div",{className:(0,e.cn)("rounded-full flex items-center justify-center font-semibold text-white","ring-2 ring-white dark:ring-surface-dark shadow-sm",h[f],(a=>{if(!a)return"bg-primary";let b=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"],c=a.charCodeAt(0)%b.length;return b[c]})(c),g),role:"img","aria-label":b,children:(a=>{if(!a)return"?";let b=a.split(" ");return b.length>=2?`${b[0][0]}${b[1][0]}`.toUpperCase():a.substring(0,2).toUpperCase()})(c)})}},46230:(a,b,c)=>{c.d(b,{default:()=>p});var d=c(48249),e=c(67484),f=c(2490),g=c(37627),h=c(17908);function i({title:a,json:b,onCopy:c}){let[f,g]=(0,e.useState)(!1),h=async()=>{!1!==await c()&&(g(!0),setTimeout(()=>g(!1),2e3))};return(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsx)("h3",{className:"text-[11px] text-text-muted uppercase tracking-wider font-bold",children:a}),(0,d.jsxs)("button",{onClick:h,className:"flex items-center gap-1 px-2 py-1 text-xs text-text-muted hover:text-text-primary transition-colors","aria-label":`Copy ${a}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:f?"check":"content_copy"}),f?"Copied!":"Copy"]})]}),(0,d.jsx)("pre",{className:"p-4 rounded-xl bg-black/30 border border-border overflow-x-auto text-xs font-mono text-text-primary max-h-[600px] overflow-y-auto leading-relaxed whitespace-pre-wrap break-words",children:b})]})}function j({log:a,detail:b,loading:c,onClose:e,onCopy:f}){let j=(0,g._Z)(a.status),k=a.sourceFormat||a.provider,l=g.Kf[k]||g.Kf[a.provider]||{bg:"#6B7280",text:"#fff",label:(k||a.provider||"-").toUpperCase()},m=g.RY[a.provider]||{bg:"#374151",text:"#fff",label:(a.provider||"-").toUpperCase()},n=b?.requestBody?JSON.stringify(b.requestBody,null,2):null,o=b?.responseBody?JSON.stringify(b.responseBody,null,2):null;return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:e,role:"dialog","aria-modal":"true","aria-label":"Request log detail",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,d.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[900px] max-h-[90vh] overflow-y-auto shadow-2xl",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold",style:{backgroundColor:j.bg,color:j.text},children:a.status}),(0,d.jsx)("span",{className:"font-bold text-lg",children:a.method}),(0,d.jsx)("span",{className:"text-text-muted font-mono text-sm",children:a.path})]}),(0,d.jsx)("button",{onClick:e,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close detail modal",children:(0,d.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,d.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 p-4 bg-bg-subtle rounded-xl border border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Time"}),(0,d.jsx)("div",{className:"text-sm font-medium",children:(a=>{try{let b=new Date(a);return b.toLocaleDateString("pt-BR")+", "+b.toLocaleTimeString("en-US",{hour12:!1})}catch{return a}})(a.timestamp)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Duration"}),(0,d.jsx)("div",{className:"text-sm font-medium",children:(0,h.a3)(a.duration)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Tokens (I/O)"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("span",{className:"px-2 py-0.5 rounded bg-primary/20 text-primary text-xs font-bold",children:["In: ",(b?.tokens?.in||a.tokens?.in||0).toLocaleString()]}),(0,d.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-400 text-xs font-bold",children:["Out: ",(b?.tokens?.out||a.tokens?.out||0).toLocaleString()]})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Model"}),(0,d.jsx)("div",{className:"text-sm font-medium text-primary font-mono",children:a.model})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:m.bg,color:m.text},children:m.label})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Protocol"}),(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:l.bg,color:l.text},children:l.label})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Account"}),(0,d.jsx)("div",{className:"text-sm font-medium",children:b?.account||a.account||"-"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"API Key"}),(0,d.jsx)("div",{className:"text-sm font-medium",title:b?.apiKeyName||b?.apiKeyId||a.apiKeyName||a.apiKeyId||"No API key",children:(0,h.VO)(b?.apiKeyName||a.apiKeyName,b?.apiKeyId||a.apiKeyId)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Combo"}),b?.comboName||a.comboName?(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded-full text-[10px] font-bold bg-violet-500/20 text-violet-300 border border-violet-500/30",children:b?.comboName||a.comboName}):(0,d.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]})]}),(b?.error||a.error)&&(0,d.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,d.jsx)("div",{className:"text-[10px] text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,d.jsx)("div",{className:"text-sm text-red-300 font-mono",children:b?.error||a.error})]}),c?(0,d.jsx)("div",{className:"p-8 text-center text-text-muted animate-pulse",children:"Loading request details..."}):(0,d.jsxs)(d.Fragment,{children:[n&&(0,d.jsx)(i,{title:"Request Payload",json:n,onCopy:()=>f(n)}),o&&(0,d.jsx)(i,{title:"Response Payload",json:o,onCopy:()=>f(o)}),!n&&!o&&!c&&(0,d.jsxs)("div",{className:"p-6 text-center text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40",children:"info"}),(0,d.jsx)("p",{className:"text-sm",children:"No payload data available for this log entry."}),(0,d.jsx)("p",{className:"text-xs mt-1",children:"Request/response bodies are only captured for non-streaming calls or when streaming completes normally."})]})]})]})]})]})}let k=[{key:"all",label:"All"},{key:"error",label:"Errors",icon:"error"},{key:"ok",label:"Success",icon:"check_circle"},{key:"combo",label:"Combo",icon:"hub"}],l=[{key:"status",label:"Status"},{key:"model",label:"Model"},{key:"provider",label:"Provider"},{key:"protocol",label:"Protocol"},{key:"account",label:"Account"},{key:"apiKey",label:"API Key"},{key:"combo",label:"Combo"},{key:"tokens",label:"Tokens"},{key:"duration",label:"Duration"},{key:"time",label:"Time"}],m=Object.fromEntries(l.map(a=>[a.key,!0]));function n(a,b){if(!a)return"-";if(a.startsWith("openai-compatible-")||a.startsWith("anthropic-compatible-")){if(b?.length){let c=b.find(b=>b.id===a||b.prefix===a);if(c?.name)return c.name}if(a.startsWith("openai-compatible-")){let b=a.replace("openai-compatible-",""),c=b.split("-");return c.length>1&&c[1]?.length>=8?"OAI-COMPAT":`OAI: ${b.slice(0,16).toUpperCase()}`}if(a.startsWith("anthropic-compatible-")){let b=a.replace("anthropic-compatible-",""),c=b.split("-");return c.length>1&&c[1]?.length>=8?"ANT-COMPAT":`ANT: ${b.slice(0,16).toUpperCase()}`}}return null}function o(a){return(a?.tokens?.in||0)+(a?.tokens?.out||0)}function p(){let[a,b]=(0,e.useState)([]),[c,i]=(0,e.useState)(!0),[p,q]=(0,e.useState)(!0),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)("all"),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)(""),[z,A]=(0,e.useState)(""),[B,C]=(0,e.useState)(""),[D,E]=(0,e.useState)("newest"),[F,G]=(0,e.useState)(null),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)(null);(0,e.useRef)(null),(0,e.useRef)(!1);let[L,M]=(0,e.useState)([]),[N,O]=(0,e.useState)(()=>m),P=(0,e.useCallback)(a=>{O(b=>{let c={...b,[a]:!b[a]};try{localStorage.setItem("loggerVisibleColumns",JSON.stringify(c))}catch{}return c})},[]),Q=(0,e.useCallback)(async(a=!1)=>{a&&i(!0);try{let a=new URLSearchParams;r&&a.set("search",r),"error"===t&&a.set("status","error"),"ok"===t&&a.set("status","ok"),"combo"===t&&a.set("combo","1"),v&&a.set("model",v),z&&a.set("provider",z),x&&a.set("account",x),B&&a.set("apiKey",B),a.set("limit","300");let c=await fetch(`/api/usage/call-logs?${a}`);if(c.ok){let a=await c.json();b(a)}}catch(a){console.error("Failed to fetch call logs:",a)}finally{a&&i(!1)}},[r,t,v,x,z,B]),R=(0,e.useMemo)(()=>"combo"===t?a.filter(a=>a.comboName):a,[t,a]),S=(0,e.useMemo)(()=>{let a=[...R];return a.sort((a,b)=>{switch(D){case"oldest":return new Date(a.timestamp).getTime()-new Date(b.timestamp).getTime();case"tokens_desc":return o(b)-o(a);case"tokens_asc":return o(a)-o(b);case"duration_desc":return(b.duration||0)-(a.duration||0);case"duration_asc":return(a.duration||0)-(b.duration||0);case"status_desc":return(b.status||0)-(a.status||0);case"status_asc":return(a.status||0)-(b.status||0);case"model_asc":return(a.model||"").localeCompare(b.model||"");case"model_desc":return(b.model||"").localeCompare(a.model||"");default:return new Date(b.timestamp).getTime()-new Date(a.timestamp).getTime()}}),a},[R,D]),T=async a=>{G(a),I(!0),K(null);try{let b=await fetch(`/api/usage/call-logs/${a.id}`);if(b.ok){let a=await b.json();K(a)}}catch(a){console.error("Failed to fetch log detail:",a)}finally{I(!1)}},U=async a=>{try{return await navigator.clipboard.writeText(a),!0}catch{try{let b=document.createElement("textarea");return b.value=a,b.style.position="fixed",b.style.left="-9999px",document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b),!0}catch{return!1}}},V=[...new Set(a.map(a=>a.account).filter(a=>a&&"-"!==a))],W=[...new Set(a.map(a=>a.model).filter(Boolean))].sort(),X=[...new Set(a.map(a=>a.provider).filter(a=>a&&"-"!==a))].sort(),Y=[...new Set(a.map(a=>a.apiKeyId||a.apiKeyName).filter(Boolean))].sort(),Z=R.length,$=R.filter(a=>a.status>=200&&a.status<300).length,_=R.filter(a=>a.status>=400).length,aa=a.filter(a=>a.comboName).length,ab=Y.length;return(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,d.jsxs)("button",{onClick:()=>q(!p),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${p?"bg-red-500/10 border-red-500/30 text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,d.jsx)("span",{className:`w-2 h-2 rounded-full ${p?"bg-red-500 animate-pulse":"bg-text-muted"}`}),p?"Recording":"Paused"]}),(0,d.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,d.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,d.jsx)("input",{type:"text",placeholder:"Search model, provider, account, API key, combo...",value:r,onChange:a=>s(a.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,d.jsxs)("select",{value:z,onChange:a=>A(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,d.jsx)("option",{value:"",children:"All Providers"}),X.map(a=>{let b=n(a,L),c=g.RY[a];return(0,d.jsx)("option",{value:a,children:b||c?.label||a.toUpperCase()},a)})]}),(0,d.jsxs)("select",{value:v,onChange:a=>w(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[180px]",children:[(0,d.jsx)("option",{value:"",children:"All Models"}),W.map(a=>(0,d.jsx)("option",{value:a,children:a},a))]}),(0,d.jsxs)("select",{value:x,onChange:a=>y(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,d.jsx)("option",{value:"",children:"All Accounts"}),V.map(a=>(0,d.jsx)("option",{value:a,children:a},a))]}),(0,d.jsxs)("select",{value:B,onChange:a=>C(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[160px]",children:[(0,d.jsx)("option",{value:"",children:"All API Keys"}),Y.map(b=>{let c=a.find(a=>(a.apiKeyId||a.apiKeyName)===b),e=(0,h.VO)(c?.apiKeyName,c?.apiKeyId);return(0,d.jsx)("option",{value:b,children:e},b)})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[Z," total"]}),(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 font-mono",children:[$," OK"]}),_>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-400 font-mono",children:[_," ERR"]}),aa>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-violet-500/10 text-violet-300 font-mono",children:[aa," combo"]}),ab>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-primary/10 text-primary font-mono",children:[ab," keys"]}),(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[S.length," shown"]})]}),(0,d.jsxs)("select",{value:D,onChange:a=>E(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[150px]",title:"Sort logs",children:[(0,d.jsx)("option",{value:"newest",children:"Newest"}),(0,d.jsx)("option",{value:"oldest",children:"Oldest"}),(0,d.jsx)("option",{value:"tokens_desc",children:"Tokens ↓"}),(0,d.jsx)("option",{value:"tokens_asc",children:"Tokens ↑"}),(0,d.jsx)("option",{value:"duration_desc",children:"Duration ↓"}),(0,d.jsx)("option",{value:"duration_asc",children:"Duration ↑"}),(0,d.jsx)("option",{value:"status_desc",children:"Status ↓"}),(0,d.jsx)("option",{value:"status_asc",children:"Status ↑"}),(0,d.jsx)("option",{value:"model_asc",children:"Model A-Z"}),(0,d.jsx)("option",{value:"model_desc",children:"Model Z-A"})]}),(0,d.jsx)("button",{onClick:()=>Q(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[k.map(a=>(0,d.jsxs)("button",{onClick:()=>u(t===a.key?"all":a.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${t===a.key?"error"===a.key?"bg-red-500/20 text-red-400 border-red-500/40":"ok"===a.key?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"combo"===a.key?"bg-violet-500/20 text-violet-300 border-violet-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[a.icon&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:a.icon}),a.label]},a.key)),X.length>0&&(0,d.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),X.map(a=>{let b=n(a,L),c=g.RY[a]||{bg:"#374151",text:"#fff",label:b||a.toUpperCase()},e=b||c.label,f=z===a;return(0,d.jsx)("button",{onClick:()=>A(f?"":a),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${f?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:f?c.bg:`${c.bg}33`,color:f?c.text:c.bg},children:e},a)})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,d.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),l.map(a=>(0,d.jsx)("button",{onClick:()=>P(a.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${N[a.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:a.label},a.key))]}),(0,d.jsx)(f.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,d.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:c&&0===a.length?(0,d.jsx)("div",{className:"p-8 text-center text-text-muted",children:"Loading logs..."}):0===a.length?(0,d.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"receipt_long"}),"No logs recorded yet. Make some API calls to see them here."]}):0===S.length?(0,d.jsx)("div",{className:"p-8 text-center text-text-muted",children:"No logs match the current filters."}):(0,d.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,d.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:(0,d.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:[N.status&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Status"}),N.model&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Model"}),N.provider&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Provider"}),N.protocol&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Protocol"}),N.account&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Account"}),N.apiKey&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"API Key"}),N.combo&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Combo"}),N.tokens&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Tokens"}),N.duration&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Duration"}),N.time&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Time"})]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border/30",children:S.map(a=>{let b=(0,g._Z)(a.status),c=a.sourceFormat||a.provider,e=g.Kf[c]||g.Kf[a.provider]||{bg:"#6B7280",text:"#fff",label:(c||a.provider||"-").toUpperCase()},f=n(a.provider,L),i=g.RY[a.provider]||{bg:"#374151",text:"#fff",label:f||(a.provider||"-").toUpperCase()},j=f||i.label,k=a.status>=400;return(0,d.jsxs)("tr",{onClick:()=>T(a),className:`cursor-pointer hover:bg-primary/5 transition-colors ${k?"bg-red-500/5":""}`,children:[N.status&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[36px] text-center",style:{backgroundColor:b.bg,color:b.text},children:a.status||"..."})}),N.model&&(0,d.jsx)("td",{className:"px-3 py-2 font-medium text-primary font-mono text-[11px]",children:a.model}),N.provider&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:i.bg,color:i.text},children:j})}),N.protocol&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:e.bg,color:e.text},children:e.label})}),N.account&&(0,d.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[120px]",title:a.account,children:(0,h.Ib)(a.account)}),N.apiKey&&(0,d.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[140px]",title:a.apiKeyName||a.apiKeyId||"No API key",children:(0,h.VO)(a.apiKeyName,a.apiKeyId)}),N.combo&&(0,d.jsx)("td",{className:"px-3 py-2",children:a.comboName?(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded-full text-[9px] font-bold bg-violet-500/20 text-violet-300 border border-violet-500/30",children:a.comboName}):(0,d.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),N.tokens&&(0,d.jsxs)("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:[(0,d.jsx)("span",{className:"text-text-muted",children:"I:"})," ",(0,d.jsx)("span",{className:"text-primary",children:a.tokens?.in?.toLocaleString()||0}),(0,d.jsx)("span",{className:"mx-1 text-border",children:"|"}),(0,d.jsx)("span",{className:"text-text-muted",children:"O:"})," ",(0,d.jsx)("span",{className:"text-emerald-400",children:a.tokens?.out?.toLocaleString()||0})]}),N.duration&&(0,d.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,h.a3)(a.duration)}),N.time&&(0,d.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,h.fU)(a.timestamp)})]},a.id)})})]})})}),(0,d.jsxs)("div",{className:"text-[10px] text-text-muted italic",children:["Call logs are also saved as JSON files to ",(0,d.jsx)("code",{children:"{DATA_DIR}/call_logs/"})," with 7-day rotation."]}),F&&(0,d.jsx)(j,{log:F,detail:J,loading:H,onClose:()=>{G(null),K(null)},onCopy:U})]})}},47047:(a,b,c)=>{c.d(b,{default:()=>k});var d=c(48249),e=c(67484),f=c(65892),g=c(42546),h=c(77088),i=c(18732);function j(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)("");return((0,e.useCallback)(async()=>{try{(await fetch("/api/monitoring/health",{signal:AbortSignal.timeout(3e3)})).ok?a&&(b(!1),f("")):(b(!0),f("Server is experiencing issues. Some features may be unavailable."))}catch{b(!0),f("Server is unreachable. Reconnecting...")}},[a]),a)?(0,d.jsxs)("div",{className:"bg-amber-500/10 border-b border-amber-500/20 px-4 py-2.5 flex items-center justify-between gap-3 animate-in slide-in-from-top",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-amber-500 text-[18px] animate-pulse",children:"warning"}),(0,d.jsx)("span",{className:"text-sm text-amber-200",children:c})]}),(0,d.jsx)("button",{onClick:()=>b(!1),className:"p-1 rounded hover:bg-white/5 text-text-muted hover:text-text-main transition-colors","aria-label":"Dismiss",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}):null}function k({children:a}){let[b,c]=(0,e.useState)(!1),[k,l]=(0,e.useState)(()=>!1);return(0,d.jsxs)("div",{className:"flex h-screen w-full overflow-hidden bg-bg",children:[b&&(0,d.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 lg:hidden",onClick:()=>c(!1)}),(0,d.jsx)("div",{className:"hidden lg:flex",children:(0,d.jsx)(f.default,{collapsed:k,onToggleCollapse:()=>{let a=!k;l(a),localStorage.setItem("sidebar-collapsed",String(a))}})}),(0,d.jsx)("div",{className:`fixed inset-y-0 left-0 z-50 transform lg:hidden transition-transform duration-300 ease-in-out ${b?"translate-x-0":"-translate-x-full"}`,children:(0,d.jsx)(f.default,{onClose:()=>c(!1)})}),(0,d.jsxs)("main",{id:"main-content",className:"flex flex-col flex-1 h-full min-w-0 relative transition-colors duration-300",children:[(0,d.jsx)(g.default,{onMenuClick:()=>c(!0)}),(0,d.jsx)(j,{}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-6 lg:p-10",children:(0,d.jsxs)("div",{className:"max-w-7xl mx-auto",children:[(0,d.jsx)(h.default,{}),a]})})]}),(0,d.jsx)(i.default,{})]})}},50818:(a,b,c)=>{c.d(b,{default:()=>e});var d=c(48249);function e({columns:a=[],data:b=[],renderCell:c,renderHeader:e,onRowClick:f,selectedId:g,loading:h=!1,maxHeight:i="calc(100vh - 320px)",emptyIcon:j="\uD83D\uDCED",emptyMessage:k="No data found"}){return h?(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,d.jsx)("span",{style:{animation:"spin 1s linear infinite",marginRight:"8px"},children:"⏳"}),"Loading...",(0,d.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}):0===b.length?(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,d.jsx)("span",{style:{fontSize:"32px",marginBottom:"8px",opacity:.6},children:j}),k]}):(0,d.jsx)("div",{style:{overflow:"auto",maxHeight:i,borderRadius:"8px"},children:(0,d.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px",tableLayout:"auto"},children:[(0,d.jsx)("thead",{children:(0,d.jsx)("tr",{children:a.map(a=>(0,d.jsx)("th",{style:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"var(--text-secondary, #888)",borderBottom:"1px solid rgba(255,255,255,0.08)",position:"sticky",top:0,background:"var(--bg-table-header, rgba(15,15,25,0.95))",zIndex:1,whiteSpace:"nowrap",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px"},children:e?e(a):a.label},a.key))})}),(0,d.jsx)("tbody",{children:b.map((b,e)=>(0,d.jsx)("tr",{onClick:()=>f?.(b),style:{cursor:f?"pointer":"default",background:b.id===g?"rgba(99,102,241,0.1)":e%2==0?"transparent":"rgba(255,255,255,0.02)",transition:"background 0.15s"},onMouseEnter:a=>{b.id!==g&&(a.currentTarget.style.background="rgba(255,255,255,0.04)")},onMouseLeave:a=>{b.id!==g&&(a.currentTarget.style.background=e%2==0?"transparent":"rgba(255,255,255,0.02)")},children:a.map(a=>(0,d.jsx)("td",{style:{padding:"6px 10px",borderBottom:"1px solid rgba(255,255,255,0.04)",whiteSpace:"nowrap",maxWidth:a.maxWidth||"200px",overflow:"hidden",textOverflow:"ellipsis"},children:c(b,a)},a.key))},b.id||e))})]})})}},52198:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(67484);function f({columns:a=[],visible:b={},onToggle:c}){let[f,g]=(0,e.useState)(!1),h=(0,e.useRef)(null);return(0,d.jsxs)("div",{ref:h,style:{position:"relative"},children:[(0,d.jsxs)("button",{onClick:()=>g(!f),title:"Toggle columns",style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-secondary, #888)",fontSize:"13px",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[(0,d.jsx)("span",{style:{fontSize:"14px"},children:"⚙️"}),"Columns"]}),f&&(0,d.jsx)("div",{style:{position:"absolute",top:"100%",right:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"8px",zIndex:50,minWidth:"160px",backdropFilter:"blur(12px)"},children:a.map(a=>(0,d.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 8px",cursor:"pointer",fontSize:"12px",color:b[a.key]?"var(--text-primary, #e0e0e0)":"var(--text-secondary, #888)",borderRadius:"4px"},children:[(0,d.jsx)("input",{type:"checkbox",checked:b[a.key]??!0,onChange:()=>c(a.key),style:{accentColor:"#6366f1"}}),a.label]},a.key))})]})}},53140:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(29824),i=c(73295);function j({isOpen:a,provider:b,onSuccess:c,onClose:f}){let[g,j]=(0,e.useState)("loading"),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(null),{copied:s,copy:t}=(0,i.C)(),u=async()=>{try{let a;r(null);try{a=new URL(o)}catch(a){throw Error("Invalid callback URL format")}let d=a.searchParams.get("code");a.searchParams.get("state");let e=a.searchParams.get("error");if(e)throw Error(a.searchParams.get("error_description")||e);if(!d)throw Error("No authorization code found in URL");let f=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:d,codeVerifier:m.codeVerifier,provider:b})}),g=await f.json();if(!f.ok)throw Error(g.error);j("success"),c?.()}catch(a){r(a.message),j("error")}},v="google"===b?"Google":"GitHub";return(0,d.jsx)(h.aF,{isOpen:a,title:`Connect Kiro via ${v}`,onClose:f,size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,d.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",v," authentication"]})]}),"input"===g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.pd,{value:k,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,d.jsx)(h.$n,{variant:"secondary",icon:"auth_url"===s?"check":"content_copy",onClick:()=>t(k,"auth_url"),children:"Copy"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,d.jsx)(h.pd,{value:o,onChange:a=>p(a.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:u,fullWidth:!0,disabled:!o,children:"Connect"}),(0,d.jsx)(h.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,d.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",v," has been connected."]}),(0,d.jsx)(h.$n,{onClick:f,fullWidth:!0,children:"Done"})]}),"error"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,d.jsx)("p",{className:"text-sm text-red-600 mb-4",children:q}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:()=>j("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,d.jsx)(h.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}j.propTypes={isOpen:g().bool.isRequired,provider:g().oneOf(["google","github"]).isRequired,onSuccess:g().func,onClose:g().func.isRequired}},53156:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(31846);let f={primary:"bg-gradient-to-b from-primary to-primary-hover text-white shadow-sm",secondary:"bg-white dark:bg-white/10 border border-black/10 dark:border-white/10 text-text-main hover:bg-black/5 dark:hover:bg-white/5",outline:"border border-black/15 dark:border-white/15 text-text-main hover:bg-black/5",ghost:"text-text-muted hover:bg-black/5 dark:hover:bg-white/5 hover:text-text-main",danger:"bg-red-500 text-white hover:bg-red-600 shadow-sm"},g={sm:"h-7 px-3 text-xs rounded-md",md:"h-9 px-4 text-sm rounded-lg",lg:"h-11 px-6 text-sm rounded-lg"};function h({children:a,variant:b="primary",size:c="md",icon:h,iconRight:i,disabled:j=!1,loading:k=!1,fullWidth:l=!1,className:m,...n}){return(0,d.jsxs)("button",{type:"button",className:(0,e.cn)("inline-flex items-center justify-center gap-2 font-medium transition-all duration-200 cursor-pointer","active:scale-[0.99] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",f[b],g[c],l&&"w-full",m),disabled:j||k,"aria-busy":k||void 0,...n,children:[k?(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px] pointer-events-none","aria-hidden":"true",children:"progress_activity"}):h?(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] pointer-events-none","aria-hidden":"true",children:h}):null,a,i&&!k&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] pointer-events-none","aria-hidden":"true",children:i})]})}},56589:(a,b,c)=>{c.d(b,{default:()=>m});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(65953),i=c(53156);let j=[{value:"http",label:"HTTP"},{value:"https",label:"HTTPS"},{value:"socks5",label:"SOCKS5"}],k="true"===process.env.NEXT_PUBLIC_ENABLE_SOCKS5_PROXY?j:j.filter(a=>"socks5"!==a.value),l={global:"Global",provider:"Provider",combo:"Combo",key:"Key",direct:"Direct (none)"};function m({isOpen:a,onClose:b,level:c,levelId:f,levelLabel:g,onSaved:j}){let[m,n]=(0,e.useState)(k[0]?.value||"http"),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(""),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(null),[E,F]=(0,e.useState)(!0),[G,H]=(0,e.useState)(null),[I,J]=(0,e.useState)(!1),[K,L]=(0,e.useState)(null),M=a=>"socks5"===a?"1080":"https"===a?"443":"8080",N=async()=>{if(o.trim()){L(null),z(!0);try{let a={type:m,host:o.trim(),port:q.trim()||M(m),username:s.trim(),password:u.trim()},b=await fetch("/api/settings/proxy",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:c,id:f,proxy:a})}),d=await b.json().catch(()=>({}));if(!b.ok)return void L(d?.error?.message||"Failed to save proxy configuration");J(!0),j?.()}catch(a){console.error("Error saving proxy:",a),L(a.message||"Failed to save proxy configuration")}finally{z(!1)}}},O=async()=>{L(null),z(!0);try{let a=new URLSearchParams({level:c});f&&a.set("id",f);let b=await fetch(`/api/settings/proxy?${a}`,{method:"DELETE"}),d=await b.json().catch(()=>({}));if(!b.ok)return void L(d?.error?.message||"Failed to clear proxy configuration");n(k[0]?.value||"http"),p(""),r(""),t(""),v(""),x(!1),L(null),J(!1),D(null),j?.()}catch(a){console.error("Error clearing proxy:",a),L(a.message||"Failed to clear proxy configuration")}finally{z(!1)}},P=async()=>{if(o.trim()){L(null),B(!0),D(null);try{let a={type:m,host:o.trim(),port:q.trim()||M(m),username:s.trim(),password:u.trim()},b=await fetch("/api/settings/proxy/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxy:a})}),c=await b.json().catch(()=>({}));if(!b.ok){let a=c?.error?.message||"Connection failed";D({success:!1,error:a}),L(a);return}D(c)}catch(a){D({success:!1,error:a.message}),L(a.message||"Connection failed")}finally{B(!1)}}},Q="global"===c?"Global Proxy Configuration":`${l[c]} Proxy — ${g||f||""}`;return(0,d.jsx)(h.default,{isOpen:a,onClose:b,title:Q,maxWidth:"lg",children:E?(0,d.jsx)("div",{className:"py-8 text-center text-text-muted animate-pulse",children:"Loading proxy configuration..."}):(0,d.jsxs)("div",{className:"flex flex-col gap-5",children:["global"!==c&&!I&&G&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-blue-500/10 border border-blue-500/20 text-sm",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-blue-400 text-base",children:"subdirectory_arrow_right"}),(0,d.jsxs)("span",{className:"text-blue-300",children:["Inheriting from ",(0,d.jsx)("strong",{children:G.level}),": ",G.proxy?.type,"://",G.proxy?.host,":",G.proxy?.port]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Proxy Type"}),(0,d.jsx)("div",{className:"flex gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:k.map(a=>(0,d.jsx)("button",{onClick:()=>n(a.value),className:`flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all ${m===a.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,children:a.label},a.value))})]}),(0,d.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,d.jsxs)("div",{className:"col-span-2",children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Host"}),(0,d.jsx)("input",{type:"text",value:o,onChange:a=>p(a.target.value),placeholder:"1.2.3.4 or proxy.example.com",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Port"}),(0,d.jsx)("input",{type:"text",value:q,onChange:a=>r(a.target.value),placeholder:M(m),className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("button",{onClick:()=>x(!w),className:"flex items-center gap-2 text-sm text-text-muted hover:text-text-primary transition-colors",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-base",children:w?"expand_less":"expand_more"}),"Authentication (optional)"]}),w&&(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Username"}),(0,d.jsx)("input",{type:"text",value:s,onChange:a=>t(a.target.value),placeholder:"Username",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Password"}),(0,d.jsx)("input",{type:"password",value:u,onChange:a=>v(a.target.value),placeholder:"Password",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]})]})]}),K&&(0,d.jsx)("div",{className:"px-4 py-3 rounded-lg border border-red-500/30 bg-red-500/10 text-sm text-red-400",children:K}),C&&(0,d.jsxs)("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border ${C.success?"bg-emerald-500/10 border-emerald-500/30":"bg-red-500/10 border-red-500/30"}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-xl ${C.success?"text-emerald-400":"text-red-400"}`,children:C.success?"check_circle":"error"}),(0,d.jsx)("div",{className:"flex-1",children:C.success?(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"text-sm font-medium text-emerald-400",children:"Connected"}),(0,d.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["IP: ",(0,d.jsx)("span",{className:"font-mono text-emerald-300",children:C.publicIp}),C.latencyMs&&` \xb7 ${C.latencyMs}ms`]})]}):(0,d.jsxs)("div",{className:"text-sm text-red-400",children:[C.error||"Connection failed",C.latencyMs&&(0,d.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["(",C.latencyMs,"ms)"]})]})})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-border",children:[(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(i.default,{size:"sm",variant:"secondary",icon:"speed",onClick:P,loading:A,disabled:!o.trim(),children:"Test Connection"}),I&&(0,d.jsx)(i.default,{size:"sm",variant:"ghost",icon:"delete",onClick:O,disabled:y,className:"!text-red-400 hover:!bg-red-500/10",children:"Clear"})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(i.default,{size:"sm",variant:"secondary",onClick:b,children:"Cancel"}),(0,d.jsx)(i.default,{size:"sm",icon:"save",onClick:N,loading:y,disabled:!o.trim(),children:"Save"})]})]})]})})}m.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,level:g().oneOf(["global","provider","combo","key"]).isRequired,levelId:g().string,levelLabel:g().string,onSaved:g().func}},59256:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(67484),f=c(31846);function g({label:a,options:b=[],value:c,onChange:g,placeholder:h="Select an option",error:i,hint:j,disabled:k=!1,required:l=!1,className:m,selectClassName:n,id:o,...p}){let q=(0,e.useId)(),r=o||q,s=i?`${r}-error`:void 0,t=j&&!i?`${r}-hint`:void 0,u=[s,t].filter(Boolean).join(" ")||void 0;return(0,d.jsxs)("div",{className:(0,f.cn)("flex flex-col gap-1.5",m),children:[a&&(0,d.jsxs)("label",{htmlFor:r,className:"text-sm font-medium text-text-main",children:[a,l&&(0,d.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsxs)("select",{id:r,value:c,onChange:g,disabled:k,required:l,"aria-required":l||void 0,"aria-invalid":!!i||void 0,"aria-describedby":u,className:(0,f.cn)("w-full py-2 px-3 pr-10 text-sm text-text-main","bg-surface border border-black/10 dark:border-white/10 rounded-md appearance-none","focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none","transition-all disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",i?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",n),...p,children:[(0,d.jsx)("option",{value:"",disabled:!0,className:"bg-surface text-text-muted",children:h}),b.map(a=>(0,d.jsx)("option",{value:a.value,className:"bg-surface text-text-main",children:a.label},a.value))]}),(0,d.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-text-muted","aria-hidden":"true",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"expand_more"})})]}),i&&(0,d.jsxs)("p",{id:s,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),i]}),j&&!i&&(0,d.jsx)("p",{id:t,className:"text-xs text-text-muted",children:j})]})}},59869:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(89132),f=c(31846);function g({className:a,variant:b="default"}){let{theme:c,toggleTheme:g,isDark:h}=(0,e.D)(),i={default:(0,f.cn)("flex items-center justify-center size-10 rounded-full","text-text-muted","hover:bg-black/5","hover:text-text-main","transition-colors"),card:(0,f.cn)("flex items-center justify-center size-11 rounded-full","bg-surface/60","hover:bg-surface","border border-border","backdrop-blur-md shadow-sm hover:shadow-md","text-text-muted-light hover:text-primary","hover:text-primary","transition-all group")};return(0,d.jsx)("button",{onClick:g,className:(0,f.cn)(i[b],a),"aria-label":`Switch to ${h?"light":"dark"} mode`,title:`Switch to ${h?"light":"dark"} mode`,children:(0,d.jsx)("span",{className:(0,f.cn)("material-symbols-outlined text-[22px]","card"===b&&"transition-transform duration-300 group-hover:rotate-12"),children:h?"light_mode":"dark_mode"})})}},62688:(a,b,c)=>{c.d(b,{default:()=>L});var d=c(48249),e=c(67484),f=c(2490),g=c(22746),h=c(17908),i=c(37627),j=c(83673),k=c(37930),l=c(22393),m=c(54206),n=c(40369),o=c(37538),p=c(20525),q=c(51831),r=c(73855),s=c(93237),t=c(21621),u=c(75829);function v({active:a,payload:b,label:c,formatter:e}){return a&&b?.length?(0,d.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[c&&(0,d.jsx)("div",{className:"font-semibold text-text-main mb-1",children:c}),b.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:a.color}}),(0,d.jsxs)("span",{children:[a.name,":"]}),(0,d.jsx)("span",{className:"font-mono font-medium text-text-main",children:e?e(a.value):a.value})]},b))]}):null}function w({active:a,sortOrder:b}){return a?(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"asc"===b?"expand_less":"expand_more"}):(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-0 group-hover:opacity-30",children:"unfold_more"})}function x({icon:a,label:b,value:c,subValue:e,color:g="text-text-main"}){return(0,d.jsxs)(f.default,{className:"px-4 py-3 flex flex-col gap-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted text-xs uppercase font-semibold tracking-wider",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:a}),b]}),(0,d.jsx)("span",{className:`text-2xl font-bold ${g}`,children:c}),e&&(0,d.jsx)("span",{className:"text-xs text-text-muted",children:e})]})}function y({activityMap:a}){let b=(0,e.useMemo)(()=>{let b=new Date,c=[],d=0;for(let e=364;e>=0;e--){let f=new Date(b);f.setDate(f.getDate()-e);let g=`${f.getFullYear()}-${String(f.getMonth()+1).padStart(2,"0")}-${String(f.getDate()).padStart(2,"0")}`,h=a?.[g]||0;h>d&&(d=h),c.push({date:g,value:h,dayOfWeek:f.getDay()})}return{days:c,maxVal:d}},[a]),c=(0,e.useMemo)(()=>{let a=[],c=[],d=b.days[0]?.dayOfWeek||0;for(let a=0;a<d;a++)c.push(null);for(let d of b.days)c.push(d),7===c.length&&(a.push(c),c=[]);return c.length>0&&a.push(c),a},[b]),g=(0,e.useMemo)(()=>{let a=[],b=-1;return c.forEach((c,d)=>{let e=c.find(a=>null!==a);if(e){let c=new Date(e.date).getMonth();c!==b&&(a.push({weekIdx:d,label:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c]}),b=c)}}),a},[c]);return(0,d.jsxs)(f.default,{className:"p-4 h-full",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Activity"}),(0,d.jsxs)("span",{className:"text-xs text-text-muted",children:[Object.keys(a||{}).length," active days \xb7"," ",(0,h.VK)(Object.values(a||{}).reduce((a,b)=>a+b,0))," tokens \xb7 365 days"]})]}),(0,d.jsx)("div",{className:"flex gap-[3px] mb-1 ml-6",style:{fontSize:"10px"},children:g.map((a,b)=>(0,d.jsx)("span",{className:"text-text-muted",style:{position:"relative",left:`${13*a.weekIdx}px`,marginLeft:0===b?0:"-20px"},children:a.label},b))}),(0,d.jsxs)("div",{className:"flex gap-[3px] overflow-x-auto",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-[3px] shrink-0 text-[10px] text-text-muted pr-1",children:[(0,d.jsx)("span",{className:"h-[10px]"}),(0,d.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Mon"}),(0,d.jsx)("span",{className:"h-[10px]"}),(0,d.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Wed"}),(0,d.jsx)("span",{className:"h-[10px]"}),(0,d.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Fri"}),(0,d.jsx)("span",{className:"h-[10px]"})]}),c.map((a,c)=>(0,d.jsx)("div",{className:"flex flex-col gap-[3px]",children:a.map((a,c)=>(0,d.jsx)("div",{title:a?`${a.date}: ${(0,h.xW)(a.value)} tokens`:"",className:`w-[10px] h-[10px] rounded-[2px] ${a?function(a){if(!a||0===a)return"bg-white/[0.04]";let c=Math.min(a/(b.maxVal||1),1);return c<.25?"bg-primary/20":c<.5?"bg-primary/40":c<.75?"bg-primary/60":"bg-primary/90"}(a.value):"bg-transparent"}`},c))},c))]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 mt-2 ml-6 text-[10px] text-text-muted",children:[(0,d.jsx)("span",{children:"Less"}),(0,d.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-white/[0.04]"}),(0,d.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/20"}),(0,d.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/40"}),(0,d.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/60"}),(0,d.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/90"}),(0,d.jsx)("span",{children:"More"})]})]})}function z({dailyTrend:a}){let b=(0,e.useMemo)(()=>(a||[]).map(a=>({date:a.date.slice(5),Input:a.promptTokens,Output:a.completionTokens,Cost:a.cost||0})),[a]),c=(0,e.useMemo)(()=>b.some(a=>a.Cost>0),[b]);return b.length?(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token & Cost Trend"}),(0,d.jsx)(j.u,{width:"100%",height:140,children:(0,d.jsxs)(k.X,{data:b,margin:{top:0,right:40*!!c,left:0,bottom:0},children:[(0,d.jsx)(l.W,{dataKey:"date",tick:{fontSize:9,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:Math.max(Math.floor(b.length/6),0)}),c&&(0,d.jsx)(m.h,{yAxisId:"cost",orientation:"right",tick:{fontSize:8,fill:"#f59e0b"},axisLine:!1,tickLine:!1,tickFormatter:a=>`$${a.toFixed(2)}`,width:36}),(0,d.jsx)(n.m,{content:(0,d.jsx)(A,{}),cursor:{fill:"rgba(255,255,255,0.04)"}}),(0,d.jsx)(o.yP,{dataKey:"Input",stackId:"a",fill:"var(--primary)",opacity:.7,radius:[0,0,0,0],animationDuration:600}),(0,d.jsx)(o.yP,{dataKey:"Output",stackId:"a",fill:"#10b981",opacity:.7,radius:[3,3,0,0],animationDuration:600}),c&&(0,d.jsx)(p.N1,{yAxisId:"cost",type:"monotone",dataKey:"Cost",stroke:"#f59e0b",strokeWidth:2,dot:!1,animationDuration:600})]})}),(0,d.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-text-muted",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-primary/70"})," Input"]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500/70"})," Output"]}),c&&(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500/70"})," Cost ($)"]})]})]}):(0,d.jsxs)(f.default,{className:"p-4",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token Trend"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function A({active:a,payload:b,label:c}){return a&&b?.length?(0,d.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[c&&(0,d.jsx)("div",{className:"font-semibold text-text-main mb-1",children:c}),b.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:a.color}}),(0,d.jsxs)("span",{children:[a.name,":"]}),(0,d.jsx)("span",{className:"font-mono font-medium text-text-main",children:"Cost"===a.name?(0,h.F0)(a.value):(0,h.VK)(a.value)})]},b))]}):null}function B({byAccount:a}){let b=(0,e.useMemo)(()=>a||[],[a]),c=b.length>0,g=(0,e.useMemo)(()=>b.slice(0,8).map((a,b)=>({name:a.account,value:a.totalTokens,fill:(0,i.ng)(b)})),[b]);return c?(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,d.jsxs)("div",{className:"flex items-center gap-4",children:[(0,d.jsx)(j.u,{width:120,height:120,children:(0,d.jsxs)(q.r,{children:[(0,d.jsx)(r.Fq,{data:g,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:g.map((a,b)=>(0,d.jsx)(s.f,{fill:a.fill,stroke:"none"},b))}),(0,d.jsx)(n.m,{content:(0,d.jsx)(v,{formatter:h.VK})})]})}),(0,d.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:g.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:a.fill}}),(0,d.jsx)("span",{className:"truncate text-text-main",children:a.name})]}),(0,d.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,h.VK)(a.value)})]},b))})]})]}):(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function C({byApiKey:a}){let b=(0,e.useMemo)(()=>a||[],[a]),c=b.length>0,g=(0,e.useMemo)(()=>b.slice(0,8).map((a,b)=>({name:(0,h.VO)(a.apiKeyName,a.apiKeyId),fullName:a.apiKeyName||a.apiKeyId||"unknown",value:a.totalTokens,fill:(0,i.ng)(b)})),[b]);return c?(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,d.jsxs)("div",{className:"flex items-center gap-4",children:[(0,d.jsx)(j.u,{width:120,height:120,children:(0,d.jsxs)(q.r,{children:[(0,d.jsx)(r.Fq,{data:g,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:g.map((a,b)=>(0,d.jsx)(s.f,{fill:a.fill,stroke:"none"},b))}),(0,d.jsx)(n.m,{content:(0,d.jsx)(v,{formatter:h.VK})})]})}),(0,d.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:g.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:a.fill}}),(0,d.jsx)("span",{className:"truncate text-text-main",title:a.fullName,children:a.name})]}),(0,d.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,h.VK)(a.value)})]},`${a.fullName}-${b}`))})]})]}):(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function D({byApiKey:a}){let[b,c]=(0,e.useState)(""),[g,i]=(0,e.useState)("totalTokens"),[j,k]=(0,e.useState)("desc"),l=(0,e.useMemo)(()=>a||[],[a]),m=(0,e.useMemo)(()=>{let a=b.trim().toLowerCase();return a?l.filter(b=>(b.apiKeyName||"").toLowerCase().includes(a)||(b.apiKeyId||"").toLowerCase().includes(a)):l},[l,b]),n=(0,e.useMemo)(()=>{let a=[...m];return a.sort((a,b)=>{let c=a[g]??0,d=b[g]??0;return"string"==typeof c?"asc"===j?c.localeCompare(d):d.localeCompare(c):"asc"===j?c-d:d-c}),a},[m,g,j]),o=(0,e.useCallback)(a=>{g===a?k(a=>"asc"===a?"desc":"asc"):(i(a),k("desc"))},[g]);return l.length>0?(0,d.jsxs)(f.default,{className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between gap-3",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"API Key Breakdown"}),(0,d.jsx)("input",{type:"text",value:b,onChange:a=>c(a.target.value),placeholder:"Filter API key...",className:"w-full max-w-[220px] px-3 py-1.5 rounded-lg bg-bg-subtle border border-border text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,d.jsxs)("tr",{children:[(0,d.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>o("apiKeyName"),children:["API Key ",(0,d.jsx)(w,{active:"apiKeyName"===g,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>o("requests"),children:["Requests ",(0,d.jsx)(w,{active:"requests"===g,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>o("promptTokens"),children:["Input ",(0,d.jsx)(w,{active:"promptTokens"===g,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>o("completionTokens"),children:["Output"," ",(0,d.jsx)(w,{active:"completionTokens"===g,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>o("totalTokens"),children:["Total Tokens"," ",(0,d.jsx)(w,{active:"totalTokens"===g,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>o("cost"),children:["Cost ",(0,d.jsx)(w,{active:"cost"===g,sortOrder:j})]})]})}),(0,d.jsxs)("tbody",{className:"divide-y divide-border",children:[n.map((a,b)=>(0,d.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,d.jsx)("td",{className:"px-4 py-2.5",children:(0,d.jsx)("span",{className:"font-medium",title:a.apiKeyName||a.apiKeyId||"unknown",children:(0,h.VO)(a.apiKeyName,a.apiKeyId)})}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,h.xW)(a.requests)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,h.VK)(a.promptTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,h.VK)(a.completionTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,h.VK)(a.totalTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,h.F0)(a.cost)})]},`${a.apiKeyId||a.apiKeyName||"key"}-${b}`)),0===n.length&&(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:6,className:"px-4 py-8 text-center text-text-muted",children:"No API key matches this filter."})})]})]})})]}):(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"API Key Breakdown"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function E({activityMap:a}){let b=(0,e.useMemo)(()=>{if(!a)return null;let b=new Date,c=null,d=0;for(let e=0;e<7;e++){let f=new Date(b);f.setDate(f.getDate()-e);let g=`${f.getFullYear()}-${String(f.getMonth()+1).padStart(2,"0")}-${String(f.getDate()).padStart(2,"0")}`,h=a[g]||0;h>d&&(d=h,c=g)}if(!c||0===d)return null;let e=new Date(c+"T12:00:00");return{weekday:["domingo","segunda","ter\xe7a","quarta","quinta","sexta","s\xe1bado"][e.getDay()],label:`${e.getDate()} de ${["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"][e.getMonth()]}`,tokens:d}},[a]);return(0,d.jsxs)(f.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,d.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"Most Active Day"}),b?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-xl font-bold capitalize",style:{lineHeight:1.2},children:b.weekday}),(0,d.jsxs)("span",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:[b.label," \xb7 ",(0,h.VK)(b.tokens)," tokens"]})]}):(0,d.jsx)("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Sem dados nos \xfaltimos 7 dias"})]})}function F({activityMap:a}){let b=(0,e.useMemo)(()=>{if(!a)return[];let b=new Date,c=[],d=0;for(let e=6;e>=0;e--){let f=new Date(b);f.setDate(f.getDate()-e);let g=`${f.getFullYear()}-${String(f.getMonth()+1).padStart(2,"0")}-${String(f.getDate()).padStart(2,"0")}`,h=a[g]||0;h>d&&(d=h);let i=["DOM","SEG","TER","QUA","QUI","SEX","S\xc1B"];c.push({key:g,val:h,label:i[f.getDay()]})}return c.map(a=>({...a,intensity:d>0?a.val/d:0}))},[a]);return(0,d.jsxs)(f.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,d.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Weekly"}),(0,d.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,justifyContent:"center"},children:b.map((a,b)=>{var c;return(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[(0,d.jsx)("div",{title:`${a.key}: ${(0,h.xW)(a.val)} tokens`,style:{width:36,height:36,borderRadius:8,...0===(c=a.intensity)?{background:"rgba(255,255,255,0.04)"}:{background:`rgba(229, 77, 94, ${(.15+.75*c).toFixed(2)})`},transition:"all 0.2s",cursor:"default"}}),(0,d.jsx)("span",{style:{fontSize:9,fontWeight:600,color:"var(--text-muted)",letterSpacing:"0.03em"},children:a.label})]},b)})})]})}function G({byModel:a,summary:b}){let[c,g]=(0,e.useState)("totalTokens"),[j,k]=(0,e.useState)("desc"),l=(0,e.useCallback)(a=>{c===a?k(a=>"asc"===a?"desc":"asc"):(g(a),k("desc"))},[c]),m=(0,e.useMemo)(()=>{let b=[...a||[]];return b.sort((a,b)=>{let d=a[c]??0,e=b[c]??0;return"string"==typeof d?"asc"===j?d.localeCompare(e):e.localeCompare(d):"asc"===j?d-e:e-d}),b},[a,c,j]);return(0,d.jsxs)(f.default,{className:"overflow-hidden",children:[(0,d.jsx)("div",{className:"p-4 border-b border-border",children:(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Model Breakdown"})}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,d.jsxs)("tr",{children:[(0,d.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>l("model"),children:["Model ",(0,d.jsx)(w,{active:"model"===c,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("requests"),children:["Requests ",(0,d.jsx)(w,{active:"requests"===c,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("promptTokens"),children:["Input ",(0,d.jsx)(w,{active:"promptTokens"===c,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("completionTokens"),children:["Output"," ",(0,d.jsx)(w,{active:"completionTokens"===c,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("totalTokens"),children:["Total ",(0,d.jsx)(w,{active:"totalTokens"===c,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("cost"),children:["Cost ",(0,d.jsx)(w,{active:"cost"===c,sortOrder:j})]}),(0,d.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border",children:m.map((a,b)=>(0,d.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,d.jsx)("td",{className:"px-4 py-2.5",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,i.ng)(b)}}),(0,d.jsx)("span",{className:"font-medium",children:a.model})]})}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,h.xW)(a.requests)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,h.VK)(a.promptTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,h.VK)(a.completionTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,h.VK)(a.totalTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,h.F0)(a.cost)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,d.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,d.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${a.pct}%`,backgroundColor:(0,i.ng)(b)}})}),(0,d.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[a.pct,"%"]})]})})]},a.model))})]})})]})}let H=["#f59e0b","#ef4444","#8b5cf6","#10b981","#06b6d4","#ec4899","#f97316","#6366f1","#14b8a6","#a855f7"];function I({byProvider:a}){let b=(0,e.useMemo)(()=>a||[],[a]),c=b.length>0&&b.some(a=>a.cost>0),g=(0,e.useMemo)(()=>b.filter(a=>a.cost>0).sort((a,b)=>b.cost-a.cost).slice(0,8).map((a,b)=>({name:a.provider,value:a.cost,fill:H[b%H.length]})),[b]);return c?(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,d.jsxs)("div",{className:"flex items-center gap-4",children:[(0,d.jsx)(j.u,{width:120,height:120,children:(0,d.jsxs)(q.r,{children:[(0,d.jsx)(r.Fq,{data:g,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:g.map((a,b)=>(0,d.jsx)(s.f,{fill:a.fill,stroke:"none"},b))}),(0,d.jsx)(n.m,{content:(0,d.jsx)(v,{formatter:h.F0})})]})}),(0,d.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:g.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:a.fill}}),(0,d.jsx)("span",{className:"truncate text-text-main capitalize",children:a.name})]}),(0,d.jsx)("span",{className:"font-mono font-medium text-amber-500 shrink-0",children:(0,h.F0)(a.value)})]},b))})]})]}):(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No cost data"})]})}function J({dailyByModel:a,modelNames:b}){let c=(0,e.useMemo)(()=>a||[],[a]),g=(0,e.useMemo)(()=>b||[],[b]),k=(0,e.useMemo)(()=>c.map(a=>{let b={...a};if(a.date){let c=a.date.split("-");b.dateLabel=`${c[1]}/${c[2]}`}return b}),[c]);return c.length&&g.length?(0,d.jsxs)(f.default,{className:"p-4",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,d.jsx)(j.u,{width:"100%",height:240,children:(0,d.jsxs)(t.Q,{data:k,margin:{top:4,right:4,left:0,bottom:0},children:[(0,d.jsx)(l.W,{dataKey:"dateLabel",tick:{fontSize:10,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),(0,d.jsx)(m.h,{tick:{fontSize:10,fill:"var(--text-muted)"},tickFormatter:a=>(0,h.VK)(a),axisLine:!1,tickLine:!1,width:50}),(0,d.jsx)(n.m,{content:(0,d.jsx)(v,{formatter:h.VK})}),g.map((a,b)=>(0,d.jsx)(u.Gk,{type:"monotone",dataKey:a,stackId:"1",stroke:(0,i.ng)(b),fill:(0,i.ng)(b),fillOpacity:.4,strokeWidth:1.5,animationDuration:600},a))]})}),(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 text-[10px] text-text-muted",children:g.map((a,b)=>(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,i.ng)(b)}}),a]},a))})]}):(0,d.jsxs)(f.default,{className:"p-4",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function K({byProvider:a}){let[b,c]=(0,e.useState)("totalTokens"),[g,i]=(0,e.useState)("desc"),j=(0,e.useMemo)(()=>a||[],[a]),k=(0,e.useMemo)(()=>j.reduce((a,b)=>a+b.totalTokens,0),[j]),l=(0,e.useCallback)(a=>{b===a?i(a=>"asc"===a?"desc":"asc"):(c(a),i("desc"))},[b]),m=(0,e.useMemo)(()=>{let a=[...j];return a.sort((a,c)=>{let d=a[b]??0,e=c[b]??0;return"string"==typeof d?"asc"===g?d.localeCompare(e):e.localeCompare(d):"asc"===g?d-e:e-d}),a},[j,b,g]);return j.length?(0,d.jsxs)(f.default,{className:"overflow-hidden",children:[(0,d.jsx)("div",{className:"p-4 border-b border-border",children:(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Provider Breakdown"})}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,d.jsxs)("tr",{children:[(0,d.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>l("provider"),children:["Provider ",(0,d.jsx)(w,{active:"provider"===b,sortOrder:g})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("requests"),children:["Requests ",(0,d.jsx)(w,{active:"requests"===b,sortOrder:g})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("promptTokens"),children:["Input ",(0,d.jsx)(w,{active:"promptTokens"===b,sortOrder:g})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("completionTokens"),children:["Output"," ",(0,d.jsx)(w,{active:"completionTokens"===b,sortOrder:g})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("totalTokens"),children:["Total ",(0,d.jsx)(w,{active:"totalTokens"===b,sortOrder:g})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("cost"),children:["Cost ",(0,d.jsx)(w,{active:"cost"===b,sortOrder:g})]}),(0,d.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border",children:m.map((a,b)=>{let c=k>0?(a.totalTokens/k*100).toFixed(1):"0";return(0,d.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,d.jsx)("td",{className:"px-4 py-2.5",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:H[b%H.length]}}),(0,d.jsx)("span",{className:"font-medium capitalize",children:a.provider})]})}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,h.xW)(a.requests)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,h.VK)(a.promptTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,h.VK)(a.completionTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,h.VK)(a.totalTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,h.F0)(a.cost)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,d.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,d.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${c}%`,backgroundColor:H[b%H.length]}})}),(0,d.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[c,"%"]})]})})]},a.provider)})})]})})]}):(0,d.jsxs)(f.default,{className:"p-4",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Provider Breakdown"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function L(){let[a,b]=(0,e.useState)("30d"),[c,i]=(0,e.useState)(null),[j,k]=(0,e.useState)(!0),[l,m]=(0,e.useState)(null);(0,e.useCallback)(async()=>{try{k(!0);let b=await fetch(`/api/usage/analytics?range=${a}`);if(!b.ok)throw Error("Failed to fetch");let c=await b.json();i(c),m(null)}catch(a){m(a.message)}finally{k(!1)}},[a]);let n=(0,e.useMemo)(()=>{let a=c?.byModel||[];return a.length>0?a[0].model:"—"},[c]),o=(0,e.useMemo)(()=>{let a=c?.byProvider||[];return a.length>0?a[0].provider:"—"},[c]),p=(0,e.useMemo)(()=>{let a=c?.weeklyPattern||[];if(!a.length)return"—";let b=a.reduce((a,b)=>a.avgTokens>b.avgTokens?a:b,a[0]);return b.avgTokens>0?b.day:"—"},[c]),q=(0,e.useMemo)(()=>(c?.byProvider||[]).length,[c]);if(j&&!c)return(0,d.jsx)(g.CardSkeleton,{});if(l)return(0,d.jsxs)(f.default,{className:"p-6 text-center text-red-500",children:["Error: ",l]});let r=c?.summary||{},s=r.totalRequests>0?Math.round(r.totalTokens/r.totalRequests):0,t=r.totalRequests>0?r.totalCost/r.totalRequests:0,u=r.completionTokens>0?(r.promptTokens/r.completionTokens).toFixed(1):"—";return(0,d.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-primary text-[22px]",children:"analytics"}),"Usage Analytics"]}),(0,d.jsx)("div",{className:"flex items-center gap-1 bg-black/[0.03] dark:bg-white/[0.03] rounded-lg p-1 border border-black/5 dark:border-white/5",children:[{value:"1d",label:"1D"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"90d",label:"90D"},{value:"ytd",label:"YTD"},{value:"all",label:"All"}].map(c=>(0,d.jsx)("button",{onClick:()=>b(c.value),className:`px-3 py-1 rounded-md text-xs font-semibold transition-all ${a===c.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:c.label},c.value))})]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-7 gap-3",children:[(0,d.jsx)(x,{icon:"generating_tokens",label:"Total Tokens",value:(0,h.VK)(r.totalTokens),subValue:`${(0,h.xW)(r.totalRequests)} requests`}),(0,d.jsx)(x,{icon:"input",label:"Input Tokens",value:(0,h.VK)(r.promptTokens),color:"text-primary"}),(0,d.jsx)(x,{icon:"output",label:"Output Tokens",value:(0,h.VK)(r.completionTokens),color:"text-emerald-500"}),(0,d.jsx)(x,{icon:"payments",label:"Est. Cost",value:(0,h.F0)(r.totalCost),color:"text-amber-500"}),(0,d.jsx)(x,{icon:"group",label:"Accounts",value:r.uniqueAccounts||0}),(0,d.jsx)(x,{icon:"vpn_key",label:"API Keys",value:r.uniqueApiKeys||0}),(0,d.jsx)(x,{icon:"model_training",label:"Models",value:r.uniqueModels||0})]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-7 gap-3",children:[(0,d.jsx)(x,{icon:"speed",label:"Avg Tokens/Req",value:(0,h.VK)(s),color:"text-cyan-500"}),(0,d.jsx)(x,{icon:"request_quote",label:"Cost/Request",value:(0,h.F0)(t),color:"text-orange-500"}),(0,d.jsx)(x,{icon:"compare_arrows",label:"I/O Ratio",value:`${u}x`,color:"text-violet-500"}),(0,d.jsx)(x,{icon:"star",label:"Top Model",value:n,color:"text-pink-500"}),(0,d.jsx)(x,{icon:"cloud",label:"Top Provider",value:o,color:"text-teal-500"}),(0,d.jsx)(x,{icon:"today",label:"Busiest Day",value:p,color:"text-rose-500"}),(0,d.jsx)(x,{icon:"dns",label:"Providers",value:q,color:"text-indigo-500"})]}),(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:16,alignItems:"stretch"},children:[(0,d.jsx)(y,{activityMap:c?.activityMap}),(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,d.jsx)(E,{activityMap:c?.activityMap}),(0,d.jsx)(F,{activityMap:c?.activityMap})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,d.jsx)(z,{dailyTrend:c?.dailyTrend}),(0,d.jsx)(I,{byProvider:c?.byProvider})]}),(0,d.jsx)(J,{dailyByModel:c?.dailyByModel,modelNames:c?.modelNames}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,d.jsx)(B,{byAccount:c?.byAccount}),(0,d.jsx)(C,{byApiKey:c?.byApiKey})]}),(0,d.jsx)(K,{byProvider:c?.byProvider}),(0,d.jsx)(D,{byApiKey:c?.byApiKey}),(0,d.jsx)(G,{byModel:c?.byModel,summary:r})]})}},65472:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(31846);function f({checked:a=!1,onChange:b,label:c,description:f,disabled:g=!1,size:h="md",className:i}){let j={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}};return(0,d.jsxs)("div",{className:(0,e.cn)("flex items-center gap-3",g&&"opacity-50 cursor-not-allowed",i),children:[(0,d.jsx)("button",{type:"button",role:"switch","aria-checked":a,"aria-label":c?void 0:f||"Toggle",disabled:g,onClick:()=>{!g&&b&&b(!a)},className:(0,e.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-1 focus:ring-primary/30",a?"bg-primary":"bg-black/10 dark:bg-white/20",j[h].track,g&&"cursor-not-allowed"),children:(0,d.jsx)("span",{"aria-hidden":"true",className:(0,e.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",a?j[h].translate:"translate-x-0.5",j[h].thumb,"mt-0.5")})}),(c||f)&&(0,d.jsxs)("div",{className:"flex flex-col",children:[c&&(0,d.jsx)("span",{className:"text-sm font-medium text-text-main",children:c}),f&&(0,d.jsx)("span",{className:"text-xs text-text-muted",children:f})]})]})}},65892:(a,b,c)=>{c.d(b,{default:()=>w});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(2116),i=c.n(h),j=c(19099),k=c(31846),l=c(73959),m=c(75033),n=c(53156),o=c(65953);let p={connected:{icon:"cloud_done",color:"text-green-500",label:"Cloud"},syncing:{icon:"cloud_sync",color:"text-blue-400 animate-pulse",label:"Syncing..."},disconnected:{icon:"cloud_off",color:"text-amber-500",label:"Cloud Off"},error:{icon:"cloud_off",color:"text-red-400",label:"Cloud Error"},disabled:{icon:"cloud_off",color:"text-text-muted/50",label:"Disabled"}};function q({collapsed:a=!1}){let[b,c]=(0,e.useState)("disabled"),[f,g]=(0,e.useState)(null),h=(0,e.useRef)(!0),i=(0,j.useRouter)();if((0,e.useCallback)(async()=>{try{let a=await fetch("/api/sync/cloud");if(!h.current)return;if(!a.ok)return void c("disconnected");let b=await a.json();if(!h.current)return;b.enabled?b.syncing?c("syncing"):b.connected?(c("connected"),b.lastSync&&g(new Date(b.lastSync))):c("disconnected"):c("disabled")}catch{h.current&&c("disconnected")}},[]),"disabled"===b)return null;let k=p[b];return(0,d.jsxs)("button",{onClick:()=>i.push("/dashboard/endpoint"),className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg hover:bg-white/5 transition-colors cursor-pointer w-full",title:f?`Cloud ${"connected"===b?"connected":"disconnected"} — Last sync: ${f.toLocaleTimeString()}`:k.label,"aria-label":`Cloud sync status: ${k.label}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[16px] ${k.color}`,"aria-hidden":"true",children:k.icon}),!a&&(0,d.jsx)("span",{className:`truncate ${"connected"===b?"text-green-500":"text-text-muted"}`,children:k.label})]})}var r=c(77360);let s=[{href:"/dashboard",i18nKey:"home",icon:"home",exact:!0},{href:"/dashboard/endpoint",i18nKey:"endpoint",icon:"api"},{href:"/dashboard/api-manager",i18nKey:"apiManager",icon:"vpn_key"},{href:"/dashboard/providers",i18nKey:"providers",icon:"dns"},{href:"/dashboard/combos",i18nKey:"combos",icon:"layers"},{href:"/dashboard/logs",i18nKey:"logs",icon:"description"},{href:"/dashboard/costs",i18nKey:"costs",icon:"account_balance_wallet"},{href:"/dashboard/analytics",i18nKey:"analytics",icon:"analytics"},{href:"/dashboard/limits",i18nKey:"limits",icon:"tune"},{href:"/dashboard/health",i18nKey:"health",icon:"health_and_safety"},{href:"/dashboard/cli-tools",i18nKey:"cliTools",icon:"terminal"},{href:"/dashboard/media",i18nKey:"media",icon:"auto_awesome"}],t=[{href:"/dashboard/translator",i18nKey:"translator",icon:"translate"}],u=[{href:"/dashboard/settings",i18nKey:"settings",icon:"settings"}],v=[{href:"/docs",i18nKey:"docs",icon:"menu_book"},{href:"https://github.com/diegosouzapw/OmniRoute/issues",i18nKey:"issues",icon:"bug_report",external:!0}];function w({onClose:a,collapsed:b=!1,onToggleCollapse:c}){let f=(0,j.usePathname)(),g=(0,r.c)("sidebar"),h=(0,r.c)("common"),[p,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)(!1),H=async()=>{A(!0);try{await fetch("/api/shutdown",{method:"POST"})}catch(a){}A(!1),w(!1),E(!0)},I=async()=>{C(!0);try{await fetch("/api/restart",{method:"POST"})}catch(a){}C(!1),y(!1),E(!0),setTimeout(()=>{globalThis.location.reload()},3e3)},J=a=>a.map(a=>({...a,label:g(a.i18nKey)})),K=J(s),L=J(t),M=J(u),N=J(v),O=c=>{var e;let g=!c.external&&(e=c.href,c.exact?f===e:f.startsWith(e)),h=(0,k.cn)("flex items-center gap-3 rounded-lg transition-all group",b?"justify-center px-2 py-2.5":"px-4 py-2",g?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),j=(0,k.cn)("material-symbols-outlined text-[18px]",g?"fill-1":"group-hover:text-primary transition-colors"),l=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:j,children:c.icon}),!b&&(0,d.jsx)("span",{className:"text-sm font-medium",children:c.label})]});return c.external?(0,d.jsx)("a",{href:c.href,target:"_blank",rel:"noopener noreferrer",onClick:a,title:b?c.label:void 0,className:h,children:l},c.href):(0,d.jsx)(i(),{href:c.href,onClick:a,title:b?c.label:void 0,className:h,children:l},c.href)};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("aside",{className:(0,k.cn)("flex flex-col border-r border-black/5 dark:border-white/5 bg-vibrancy backdrop-blur-xl transition-all duration-300 ease-in-out",b?"w-16":"w-72"),children:[(0,d.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:absolute focus:z-50 focus:p-3 focus:bg-primary focus:text-white focus:rounded-md focus:m-2",children:"Skip to content"}),(0,d.jsxs)("div",{className:(0,k.cn)("flex items-center gap-2 pt-5 pb-2",b?"px-3 justify-center":"px-6"),"aria-hidden":"true",children:[(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"}),!b&&(0,d.jsx)("div",{className:"flex-1"}),c&&(0,d.jsx)("button",{onClick:c,title:b?"Expand sidebar":"Collapse sidebar","aria-expanded":!b,"aria-label":b?"Expand sidebar":"Collapse sidebar",className:(0,k.cn)("p-1 rounded-md text-text-muted/50 hover:text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",b&&"mt-2"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:b?"chevron_right":"chevron_left"})})]}),(0,d.jsx)("div",{className:(0,k.cn)("py-4",b?"px-2":"px-6"),children:(0,d.jsxs)(i(),{href:"/dashboard",className:(0,k.cn)("flex items-center",b?"justify-center":"gap-3"),children:[(0,d.jsx)("div",{className:"flex items-center justify-center size-9 rounded bg-linear-to-br from-[#E54D5E] to-[#C93D4E] shrink-0",children:(0,d.jsx)(m.A,{size:20,className:"text-white"})}),!b&&(0,d.jsxs)("div",{className:"flex flex-col",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:l.vQ.name}),(0,d.jsxs)("span",{className:"text-xs text-text-muted",children:["v",l.vQ.version]})]})]})}),(0,d.jsxs)("nav",{"aria-label":"Main navigation",className:(0,k.cn)("flex-1 py-2 space-y-1 overflow-y-auto custom-scrollbar",b?"px-2":"px-4"),children:[K.map(O),F&&(0,d.jsxs)("div",{className:"pt-4 mt-2",children:[!b&&(0,d.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"Debug"}),b&&(0,d.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),L.map(O)]}),(0,d.jsxs)("div",{className:"pt-4 mt-2",children:[!b&&(0,d.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"System"}),b&&(0,d.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),M.map(O)]}),(0,d.jsxs)("div",{className:"pt-4 mt-2",children:[!b&&(0,d.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"Help"}),b&&(0,d.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),N.map(O)]})]}),(0,d.jsx)(q,{collapsed:b}),(0,d.jsxs)("div",{className:(0,k.cn)("border-t border-black/5 dark:border-white/5",b?"p-2 flex flex-col gap-1":"p-3 flex gap-2"),children:[(0,d.jsxs)("button",{onClick:()=>y(!0),title:g("restart"),className:(0,k.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-amber-500 hover:bg-amber-500/10 border border-amber-500/20 hover:border-amber-500/40",b?"p-2":"flex-1 px-3 py-2 text-sm"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"restart_alt"}),!b&&g("restart")]}),(0,d.jsxs)("button",{onClick:()=>w(!0),title:g("shutdown"),className:(0,k.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-red-500 hover:bg-red-500/10 border border-red-500/20 hover:border-red-500/40",b?"p-2":"flex-1 px-3 py-2 text-sm"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"}),!b&&g("shutdown")]})]})]}),(0,d.jsx)(o.ConfirmModal,{isOpen:p,onClose:()=>w(!1),onConfirm:H,title:g("shutdown"),message:g("shutdownConfirm"),confirmText:g("shutdown"),cancelText:h("cancel"),variant:"danger",loading:z}),(0,d.jsx)(o.ConfirmModal,{isOpen:x,onClose:()=>y(!1),onConfirm:I,title:g("restart"),message:g("restartConfirm"),confirmText:g("restart"),cancelText:h("cancel"),variant:"warning",loading:B}),D&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,d.jsxs)("div",{className:"text-center p-8",children:[(0,d.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,d.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,d.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped or is restarting."}),(0,d.jsx)(n.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}w.propTypes={onClose:g().func,collapsed:g().bool,onToggleCollapse:g().func}},65953:(a,b,c)=>{c.d(b,{ConfirmModal:()=>i,default:()=>h});var d=c(48249),e=c(67484),f=c(31846),g=c(53156);function h({isOpen:a,onClose:b,title:c,children:g,footer:h,size:i="md",closeOnOverlay:j=!0,showCloseButton:k=!0,className:l}){let m=(0,e.useId)(),n=(0,e.useRef)(null);return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:j?b:void 0,"aria-hidden":"true"}),(0,d.jsxs)("div",{ref:n,role:"dialog","aria-modal":"true","aria-labelledby":c?m:void 0,className:(0,f.cn)("relative w-full bg-surface","border border-black/10 dark:border-white/10","rounded-xl shadow-2xl","animate-in fade-in zoom-in-95 duration-200",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[i],l),children:[(c||k)&&(0,d.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-black/5 dark:border-white/5",children:[(0,d.jsxs)("div",{className:"flex items-center",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mr-4","aria-hidden":"true",children:[(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),c&&(0,d.jsx)("h2",{id:m,className:"text-lg font-semibold text-text-main",children:c})]}),k&&(0,d.jsx)("button",{onClick:b,"aria-label":"Close",className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"close"})})]}),(0,d.jsx)("div",{className:"p-6 max-h-[calc(80vh-140px)] overflow-y-auto",children:g}),h&&(0,d.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-black/5 dark:border-white/5",children:h})]})]}):null}function i({isOpen:a,onClose:b,onConfirm:c,title:e="Confirm",message:f,confirmText:i="Confirm",cancelText:j="Cancel",variant:k="danger",loading:l=!1}){return(0,d.jsx)(h,{isOpen:a,onClose:b,title:e,size:"sm",footer:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.default,{variant:"ghost",onClick:b,disabled:l,children:j}),(0,d.jsx)(g.default,{variant:k,onClick:c,loading:l,children:i})]}),children:(0,d.jsx)("p",{className:"text-text-muted",children:f})})}},67083:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(67484);function f({searchValue:a="",onSearchChange:b,placeholder:c="Search...",filters:f=[],activeFilters:g={},onFilterChange:h,children:i}){let[j,k]=(0,e.useState)(null),l=(0,e.useCallback)(()=>{b(""),f.forEach(a=>h(a.key,"")),k(null)},[b,f,h]),m=a||Object.values(g).some(a=>a&&""!==a);return(0,d.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",padding:"8px 0"},children:[(0,d.jsxs)("div",{style:{position:"relative",flex:"1 1 200px",minWidth:"200px"},children:[(0,d.jsx)("input",{type:"text",value:a,onChange:a=>b(a.target.value),placeholder:c,style:{width:"100%",padding:"8px 12px 8px 32px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-primary, #e0e0e0)",fontSize:"13px",outline:"none"}}),(0,d.jsx)("span",{style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",opacity:.4,fontSize:"14px",pointerEvents:"none"},children:"\uD83D\uDD0D"})]}),f.map(a=>(0,d.jsxs)("div",{style:{position:"relative"},children:[(0,d.jsxs)("button",{onClick:()=>k(j===a.key?null:a.key),style:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${g[a.key]?"rgba(99,102,241,0.5)":"rgba(255,255,255,0.1)"}`,background:g[a.key]?"rgba(99,102,241,0.15)":"rgba(255,255,255,0.05)",color:g[a.key]?"#818cf8":"var(--text-secondary, #888)",fontSize:"12px",cursor:"pointer",whiteSpace:"nowrap"},children:[a.label,g[a.key]?` \xb7 ${g[a.key]}`:""]}),j===a.key&&(0,d.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"4px",zIndex:50,minWidth:"120px",backdropFilter:"blur(12px)"},children:[(0,d.jsx)("button",{onClick:()=>{h(a.key,""),k(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:"none",border:"none",color:"#888",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:"All"}),(a.options||[]).map(b=>(0,d.jsx)("button",{onClick:()=>{h(a.key,b),k(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:g[a.key]===b?"rgba(99,102,241,0.2)":"none",border:"none",color:g[a.key]===b?"#818cf8":"var(--text-primary, #e0e0e0)",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:b},b))]})]},a.key)),m&&(0,d.jsx)("button",{onClick:l,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid rgba(239,68,68,0.3)",background:"rgba(239,68,68,0.1)",color:"#ef4444",fontSize:"12px",cursor:"pointer"},children:"Clear"}),i]})}},73295:(a,b,c)=>{c.d(b,{C:()=>f});var d=c(67484);function e(a){let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.left="-9999px",b.style.top="-9999px",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select();try{document.execCommand("copy")}catch{}document.body.removeChild(b)}function f(a=2e3){let[b,c]=(0,d.useState)(null),g=(0,d.useRef)(null);return{copied:b,copy:(0,d.useCallback)(async(b,d="default")=>{try{navigator.clipboard&&window.isSecureContext?await navigator.clipboard.writeText(b):e(b)}catch{e(b)}c(d),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{c(null)},a)},[a])}}},73979:(a,b,c)=>{c.d(b,{default:()=>m});var d=c(48249),e=c(67484),f=c(2490),g=c(37627),h=c(17908);function i({log:a,onClose:b}){let c=(0,g.Yh)(a.status),e=g.Gp[a.proxy?.type]||{bg:"#6B7280",text:"#fff",label:a.proxy?.type||"-"},f=g.Ie[a.level]||g.Ie.direct,i=g.RY[a.provider]||{bg:"#374151",text:"#fff",label:(a.provider||"-").toUpperCase()};return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:b,role:"dialog","aria-modal":"true","aria-label":"Proxy log detail",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,d.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[700px] max-h-[90vh] overflow-y-auto shadow-2xl",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold uppercase",style:{backgroundColor:c.bg,color:c.text},children:a.status}),(0,d.jsx)("span",{className:"font-bold text-lg",children:"Proxy Event"})]}),(0,d.jsx)("button",{onClick:b,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close proxy detail modal",children:(0,d.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,d.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 p-4 bg-bg-subtle rounded-xl border border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Time"}),(0,d.jsx)("div",{className:"text-sm font-medium",children:(a=>{try{let b=new Date(a);return b.toLocaleDateString("pt-BR")+", "+b.toLocaleTimeString("en-US",{hour12:!1})}catch{return a}})(a.timestamp)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Latency"}),(0,d.jsx)("div",{className:"text-sm font-medium",children:(0,h.a3)(a.latencyMs)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Public IP"}),(0,d.jsx)("div",{className:"text-sm font-medium font-mono text-emerald-400",children:a.publicIp||"—"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Proxy"}),(0,d.jsx)("div",{className:"text-sm font-medium font-mono text-primary",children:a.proxy?`${a.proxy.type}://${a.proxy.host}:${a.proxy.port}`:"Direct"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Type"}),(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:e.bg,color:e.text},children:e.label})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Level"}),(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:f.bg,color:f.text},children:f.label})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),a.provider?(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:i.bg,color:i.text},children:i.label}):(0,d.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"TLS Fingerprint"}),a.tlsFingerprint?(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},children:[(0,d.jsx)("span",{style:{fontSize:"12px"},children:"\uD83D\uDD12"})," Chrome 124"]}):(0,d.jsx)("div",{className:"text-sm text-text-muted",children:"Direct (native)"})]}),(0,d.jsxs)("div",{className:"col-span-2",children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Target URL"}),(0,d.jsx)("div",{className:"text-sm font-medium font-mono text-text-muted break-all",children:a.targetUrl||"—"})]})]}),a.error&&(0,d.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,d.jsx)("div",{className:"text-[10px] text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,d.jsx)("div",{className:"text-sm text-red-300 font-mono",children:a.error})]}),a.proxy&&(0,d.jsxs)("div",{className:"p-4 rounded-xl bg-bg-subtle border border-border",children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-2 font-bold",children:"Proxy Configuration"}),(0,d.jsx)("pre",{className:"text-xs font-mono text-text-primary bg-black/20 rounded-lg p-3 overflow-x-auto",children:JSON.stringify(a.proxy,null,2)})]})]})]})]})}let j=[{key:"all",label:"All"},{key:"error",label:"Errors",icon:"error"},{key:"ok",label:"Success",icon:"check_circle"},{key:"timeout",label:"Timeout",icon:"timer_off"}],k=[{key:"status",label:"Status"},{key:"proxy",label:"Proxy"},{key:"tls",label:"TLS"},{key:"type",label:"Type"},{key:"level",label:"Level"},{key:"provider",label:"Provider"},{key:"target",label:"Target"},{key:"latency",label:"Latency"},{key:"ip",label:"Public IP"},{key:"time",label:"Time"}],l=Object.fromEntries(k.map(a=>[a.key,!0]));function m(){let[a,b]=(0,e.useState)([]),[c,m]=(0,e.useState)(!0),[n,o]=(0,e.useState)(!0),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)("all"),[t,u]=(0,e.useState)(""),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)(""),[z,A]=(0,e.useState)("newest"),[B,C]=(0,e.useState)(null);(0,e.useRef)(null),(0,e.useRef)(!1);let[D,E]=(0,e.useState)(()=>l),F=(0,e.useCallback)(a=>{E(b=>{let c={...b,[a]:!b[a]};try{localStorage.setItem("proxyLoggerVisibleColumns",JSON.stringify(c))}catch{}return c})},[]),G=(0,e.useCallback)(async(a=!1)=>{a&&m(!0);try{let a=new URLSearchParams;p&&a.set("search",p),"error"===r&&a.set("status","error"),"ok"===r&&a.set("status","ok"),"timeout"===r&&a.set("status","timeout"),t&&a.set("type",t),v&&a.set("provider",v),x&&a.set("level",x),a.set("limit","300");let c=await fetch(`/api/usage/proxy-logs?${a}`);if(c.ok){let a=await c.json();b(a)}}catch(a){console.error("Failed to fetch proxy logs:",a)}finally{a&&m(!1)}},[p,r,t,v,x]),H=(0,e.useMemo)(()=>{let b=[...a];return b.sort((a,b)=>{switch(z){case"oldest":return new Date(a.timestamp).getTime()-new Date(b.timestamp).getTime();case"latency_desc":return(b.latencyMs||0)-(a.latencyMs||0);case"latency_asc":return(a.latencyMs||0)-(b.latencyMs||0);default:return new Date(b.timestamp).getTime()-new Date(a.timestamp).getTime()}}),b},[a,z]),I=[...new Set(a.map(a=>a.provider).filter(Boolean))].sort(),J=[...new Set(a.map(a=>a.proxy?.type).filter(Boolean))].sort(),K=[...new Set(a.map(a=>a.level).filter(Boolean))].sort(),L=a.length,M=a.filter(a=>"success"===a.status).length,N=a.filter(a=>"error"===a.status).length,O=a.filter(a=>"timeout"===a.status).length,P=a.filter(a=>"direct"===a.level).length,Q=a.filter(a=>a.tlsFingerprint).length;return(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,d.jsxs)("button",{onClick:()=>o(!n),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${n?"bg-red-500/10 border-red-500/30 text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,d.jsx)("span",{className:`w-2 h-2 rounded-full ${n?"bg-red-500 animate-pulse":"bg-text-muted"}`}),n?"Recording":"Paused"]}),(0,d.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,d.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,d.jsx)("input",{type:"text",placeholder:"Search host, provider, target, IP...",value:p,onChange:a=>q(a.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,d.jsxs)("select",{value:t,onChange:a=>u(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,d.jsx)("option",{value:"",children:"All Types"}),J.map(a=>(0,d.jsx)("option",{value:a,children:(g.Gp[a]?.label||a).toUpperCase()},a))]}),(0,d.jsxs)("select",{value:x,onChange:a=>y(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,d.jsx)("option",{value:"",children:"All Levels"}),K.map(a=>(0,d.jsx)("option",{value:a,children:g.Ie[a]?.label||a},a))]}),(0,d.jsxs)("select",{value:v,onChange:a=>w(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,d.jsx)("option",{value:"",children:"All Providers"}),I.map(a=>{let b=g.RY[a];return(0,d.jsx)("option",{value:a,children:b?.label||a.toUpperCase()},a)})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[L," total"]}),(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 font-mono",children:[M," OK"]}),N>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-400 font-mono",children:[N," ERR"]}),O>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-amber-500/10 text-amber-400 font-mono",children:[O," TMO"]}),P>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-gray-500/10 text-gray-400 font-mono",children:[P," direct"]}),Q>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-cyan-500/10 text-cyan-400 font-mono",children:["\uD83D\uDD12 ",Q," TLS"]})]}),(0,d.jsxs)("select",{value:z,onChange:a=>A(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,d.jsx)("option",{value:"newest",children:"Newest"}),(0,d.jsx)("option",{value:"oldest",children:"Oldest"}),(0,d.jsx)("option",{value:"latency_desc",children:"Latency ↓"}),(0,d.jsx)("option",{value:"latency_asc",children:"Latency ↑"})]}),(0,d.jsx)("button",{onClick:()=>G(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[j.map(a=>(0,d.jsxs)("button",{onClick:()=>s(r===a.key?"all":a.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${r===a.key?"error"===a.key?"bg-red-500/20 text-red-400 border-red-500/40":"ok"===a.key?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"timeout"===a.key?"bg-amber-500/20 text-amber-400 border-amber-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[a.icon&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:a.icon}),a.label]},a.key)),I.length>0&&(0,d.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),I.map(a=>{let b=g.RY[a]||{bg:"#374151",text:"#fff",label:a.toUpperCase()},c=v===a;return(0,d.jsx)("button",{onClick:()=>w(c?"":a),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${c?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:c?b.bg:`${b.bg}33`,color:c?b.text:b.bg},children:b.label},a)})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,d.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),k.map(a=>(0,d.jsx)("button",{onClick:()=>F(a.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${D[a.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:a.label},a.key))]}),(0,d.jsx)(f.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,d.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:c&&0===a.length?(0,d.jsx)("div",{className:"p-8 text-center text-text-muted",children:"Loading proxy logs..."}):0===a.length?(0,d.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"vpn_lock"}),"No proxy logs yet. Configure proxies and make API calls to see them here."]}):0===H.length?(0,d.jsx)("div",{className:"p-8 text-center text-text-muted",children:"No logs match the current filters."}):(0,d.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,d.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:(0,d.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:[D.status&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Status"}),D.proxy&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Proxy"}),D.tls&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"TLS"}),D.type&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Type"}),D.level&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Level"}),D.provider&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Provider"}),D.target&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Target"}),D.latency&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Latency"}),D.ip&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Public IP"}),D.time&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Time"})]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border/30",children:H.map(a=>{let b=(0,g.Yh)(a.status),c=g.Gp[a.proxy?.type]||{bg:"#6B7280",text:"#fff",label:a.proxy?.type||"-"},e=g.Ie[a.level]||g.Ie.direct,f=g.RY[a.provider]||{bg:"#374151",text:"#fff",label:(a.provider||"-").toUpperCase()},i="error"===a.status||"timeout"===a.status;return(0,d.jsxs)("tr",{onClick:()=>C(B?.id===a.id?null:a),className:`cursor-pointer hover:bg-primary/5 transition-colors ${i?"bg-red-500/5":""}`,children:[D.status&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[50px] text-center uppercase",style:{backgroundColor:b.bg,color:b.text},children:a.status})}),D.proxy&&(0,d.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-primary",children:a.proxy?`${a.proxy.host}:${a.proxy.port}`:"—"}),D.tls&&(0,d.jsx)("td",{className:"px-3 py-2",children:a.tlsFingerprint?(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},title:"Chrome 124 TLS Fingerprint",children:[(0,d.jsx)("span",{style:{fontSize:"10px"},children:"\uD83D\uDD12"})," TLS"]}):(0,d.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),D.type&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:c.bg,color:c.text},children:c.label})}),D.level&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:e.bg,color:e.text},children:e.label})}),D.provider&&(0,d.jsx)("td",{className:"px-3 py-2",children:a.provider?(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:f.bg,color:f.text},children:f.label}):(0,d.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),D.target&&(0,d.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[200px] font-mono text-[10px]",title:a.targetUrl,children:(0,h.Y1)(a.targetUrl)}),D.latency&&(0,d.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,h.a3)(a.latencyMs)}),D.ip&&(0,d.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-emerald-400",children:a.publicIp||"—"}),D.time&&(0,d.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,h.fU)(a.timestamp)})]},a.id)})})]})})}),B&&(0,d.jsx)(i,{log:B,onClose:()=>C(null)})]})}},75033:(a,b,c)=>{c.d(b,{A:()=>g});var d=c(48249),e=c(49885),f=c.n(e);function g({size:a=20,className:b=""}){return(0,d.jsxs)("svg",{width:a,height:a,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:b,children:[(0,d.jsx)("circle",{cx:"16",cy:"16",r:"3",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"24",cy:"8",r:"2",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"8",cy:"24",r:"2",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"24",cy:"24",r:"2",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"16",cy:"5",r:"1.5",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"16",cy:"27",r:"1.5",fill:"currentColor"}),(0,d.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,d.jsx)("line",{x1:"16",y1:"13",x2:"24",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,d.jsx)("line",{x1:"16",y1:"19",x2:"8",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,d.jsx)("line",{x1:"16",y1:"19",x2:"24",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,d.jsx)("line",{x1:"16",y1:"13",x2:"16",y2:"5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,d.jsx)("line",{x1:"16",y1:"19",x2:"16",y2:"27",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})}g.propTypes={size:f().number,className:f().string}},77088:(a,b,c)=>{c.d(b,{default:()=>i});var d=c(48249),e=c(19099),f=c(2116),g=c.n(f);let h={dashboard:"Dashboard",providers:"Providers",combos:"Combos",settings:"Settings",logs:"Logs","audit-log":"Audit Log",console:"Console",logger:"Logger",translator:"Translator",playground:"Playground",add:"Add",edit:"Edit",keys:"API Keys",models:"Models"};function i(){let a=(0,e.usePathname)();if(!a||"/dashboard"===a)return null;let b=a.split("/").filter(Boolean),c=b.map((a,c)=>({label:h[a]||a.charAt(0).toUpperCase()+a.slice(1),href:"/"+b.slice(0,c+1).join("/"),isLast:c===b.length-1}));return(0,d.jsx)("nav",{"aria-label":"Breadcrumb",style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:"var(--text-secondary, #888)",padding:"8px 0",marginBottom:"8px"},children:c.map((a,b)=>(0,d.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[b>0&&(0,d.jsx)("span",{style:{opacity:.4,fontSize:"11px"},"aria-hidden":"true",children:"›"}),a.isLast?(0,d.jsx)("span",{"aria-current":"page",style:{color:"var(--text-primary, #e0e0e0)",fontWeight:500},children:a.label}):(0,d.jsx)(g(),{href:a.href,style:{color:"var(--text-secondary, #888)",textDecoration:"none",transition:"color 0.15s"},onMouseEnter:a=>a.currentTarget.style.color="var(--accent, #818cf8)",onMouseLeave:a=>a.currentTarget.style.color="var(--text-secondary, #888)",children:a.label})]},a.href))})}},82054:(a,b,c)=>{c.d(b,{default:()=>p});var d=c(48249),e=c(77360),f=c(67484),g=c(49885),h=c.n(g),i=c(19099),j=c(2490),k=c(4355),l=c(22746),m=c(17908);function n({field:a,currentSort:b,currentOrder:c}){return b!==a?(0,d.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,d.jsx)("span",{className:"ml-1",children:"asc"===c?"↑":"↓"})}function o({data:a,colorClass:b="bg-primary"}){let c=Math.max(...a,1);return(0,d.jsx)("div",{className:"flex items-end gap-1 h-8 w-24",children:a.slice(-9).map((a,e)=>(0,d.jsx)("div",{className:`flex-1 rounded-t-sm transition-all duration-500 ${b}`,style:{height:`${Math.max(a/c*100,5)}%`},title:String(a)},`bar-${e}-${a}`))})}function p(){let a=(0,e.c)("stats"),b=(0,i.useRouter)(),c=(0,i.useSearchParams)(),g=c.get("sortBy")||"rawModel",h=c.get("sortOrder")||"asc",[p,q]=(0,f.useState)(null),[r,s]=(0,f.useState)(!0),[t,u]=(0,f.useState)(!0),[v,w]=(0,f.useState)("tokens"),[x,y]=(0,f.useState)(5e3),z=(0,f.useRef)(0),A=a=>{let d=new URLSearchParams(c.toString());g===a?d.set("sortOrder","asc"===h?"desc":"asc"):(d.set("sortBy",a),d.set("sortOrder","asc")),b.replace(`?${d.toString()}`,{scroll:!1})},B=(0,f.useCallback)((a,b={})=>Object.entries(a||{}).map(([a,c])=>{let d=(c.promptTokens||0)+(c.completionTokens||0),e=c.cost||0,f=d>0?(c.promptTokens||0)*(e/d):0,g=d>0?(c.completionTokens||0)*(e/d):0;return{...c,key:a,totalTokens:d,totalCost:e,inputCost:f,outputCost:g,pending:b[a]||0}}).sort((a,b)=>{let c=a[g],d=b[g];return("string"==typeof c&&(c=c.toLowerCase()),"string"==typeof d&&(d=d.toLowerCase()),c<d)?"asc"===h?-1:1:c>d?"asc"===h?1:-1:0}),[g,h]),C=(0,f.useMemo)(()=>B(p?.byModel,p?.pending?.byModel),[p?.byModel,p?.pending?.byModel,B]),D=(0,f.useMemo)(()=>{let a={};return p?.pending?.byAccount&&Object.entries(p.byAccount||{}).forEach(([b,c])=>{let d=p.pending.byAccount[c.connectionId];if(d){let e=c.provider?`${c.rawModel} (${c.provider})`:c.rawModel;a[b]=d[e]||0}}),B(p?.byAccount,a)},[p?.byAccount,p?.pending?.byAccount,B]);if((0,f.useCallback)(async(a=!0)=>{a&&s(!0);try{let a=await fetch("/api/usage/history");if(a.ok){let b=await a.json();q(b);let c=b.totalRequests||0;c>z.current?y(5e3):y(a=>Math.min(2*a,6e4)),z.current=c}}catch(a){console.error("Failed to fetch usage stats:",a)}finally{a&&s(!1)}},[]),r)return(0,d.jsx)(l.CardSkeleton,{});if(!p)return(0,d.jsx)("div",{className:"text-text-muted",children:a("failedToLoad")});let E=a=>(0,m.xW)(a),F=a=>{if(!a)return"Never";let b=new Date(a),c=Math.floor((new Date().getTime()-b.getTime())/6e4);return c<1?"Just now":c<60?`${c}m ago`:c<1440?`${Math.floor(c/60)}h ago`:b.toLocaleDateString()};return(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("h2",{className:"text-xl font-semibold",children:a("usageOverview")}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:[(0,d.jsx)("button",{onClick:()=>w("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"}),(0,d.jsx)("button",{onClick:()=>w("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"})]}),(0,d.jsxs)("div",{className:"text-sm font-medium text-text-muted flex items-center gap-2",children:[(0,d.jsxs)("span",{children:["Auto Refresh (",x/1e3,"s)"]}),(0,d.jsx)("button",{type:"button",onClick:()=>u(!t),role:"switch","aria-checked":t,"aria-label":"Toggle auto refresh",className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary/50 ${t?"bg-primary":"bg-bg-subtle border border-border"}`,children:(0,d.jsx)("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${t?"translate-x-5":"translate-x-1"}`})})]})]})]}),(p.activeRequests||[]).length>0&&(0,d.jsx)(j.default,{className:"p-3 border-primary/20 bg-primary/5",children:(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 text-primary font-semibold text-sm uppercase tracking-wider",children:[(0,d.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,d.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"}),(0,d.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-primary"})]}),"Active Requests"]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-3",children:p.activeRequests.map(a=>(0,d.jsxs)("div",{className:"px-3 py-1.5 rounded-md bg-bg-subtle border border-primary/20 text-xs font-mono shadow-sm",children:[(0,d.jsx)("span",{className:"text-primary font-bold",children:a.model}),(0,d.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,d.jsx)("span",{className:"text-text",children:a.provider}),(0,d.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,d.jsx)("span",{className:"text-text font-medium",children:a.account}),a.count>1&&(0,d.jsxs)("span",{className:"ml-2 px-1.5 py-0.5 rounded bg-primary text-white font-bold",children:["x",a.count]})]},`${a.model}-${a.provider}-${a.account}`))})]})}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,d.jsx)(j.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,d.jsxs)("div",{className:"flex justify-between items-start",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Requests"}),(0,d.jsx)("span",{className:"text-2xl font-bold",children:E(p.totalRequests)})]}),(0,d.jsx)(o,{data:(p.last10Minutes||[]).map(a=>a.requests),colorClass:"bg-text-muted/30"})]})}),(0,d.jsx)(j.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,d.jsxs)("div",{className:"flex justify-between items-start",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Input Tokens"}),(0,d.jsx)("span",{className:"text-2xl font-bold text-primary",children:E(p.totalPromptTokens)})]}),(0,d.jsx)(o,{data:(p.last10Minutes||[]).map(a=>a.promptTokens),colorClass:"bg-primary/50"})]})}),(0,d.jsx)(j.default,{className:"px-4 py-2 flex flex-col gap-1",children:(0,d.jsxs)("div",{className:"flex justify-between items-start gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:a("outputTokens")}),(0,d.jsx)("span",{className:"text-2xl font-bold text-success",children:E(p.totalCompletionTokens)})]}),(0,d.jsx)("div",{className:"w-px bg-border self-stretch mx-2"}),(0,d.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:a("totalCost")}),(0,d.jsx)("span",{className:"text-2xl font-bold text-warning",children:(0,m.F0)(p.totalCost)})]})]})})]}),(0,d.jsxs)(j.default,{className:"overflow-hidden",children:[(0,d.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,d.jsx)("h3",{className:"font-semibold",children:"Usage by Model"})}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,d.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,d.jsxs)("tr",{children:[(0,d.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("rawModel"),children:["Model ",(0,d.jsx)(n,{field:"rawModel",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("provider"),children:["Provider"," ",(0,d.jsx)(n,{field:"provider",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("requests"),children:["Requests"," ",(0,d.jsx)(n,{field:"requests",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("lastUsed"),children:["Last Used"," ",(0,d.jsx)(n,{field:"lastUsed",currentSort:g,currentOrder:h})]}),"tokens"===v?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("promptTokens"),children:["Input Tokens"," ",(0,d.jsx)(n,{field:"promptTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("completionTokens"),children:["Output Tokens"," ",(0,d.jsx)(n,{field:"completionTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("totalTokens"),children:["Total Tokens"," ",(0,d.jsx)(n,{field:"totalTokens",currentSort:g,currentOrder:h})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("promptTokens"),children:["Input Cost"," ",(0,d.jsx)(n,{field:"promptTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("completionTokens"),children:["Output Cost"," ",(0,d.jsx)(n,{field:"completionTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("cost"),children:["Total Cost"," ",(0,d.jsx)(n,{field:"cost",currentSort:g,currentOrder:h})]})]})]})}),(0,d.jsxs)("tbody",{className:"divide-y divide-border",children:[C.map(a=>(0,d.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,d.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(k.default,{variant:a.pending>0?"primary":"default",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:E(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:F(a.lastUsed)}),"tokens"===v?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(a.promptTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(a.completionTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:E(a.totalTokens)})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(a.inputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(a.outputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(a.totalCost)})]})]},a.key)),0===C.length&&(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:8,className:"px-6 py-8 text-center text-text-muted",children:"No usage recorded yet. Make some requests to see data here."})})]})]})})]}),(0,d.jsxs)(j.default,{className:"overflow-hidden",children:[(0,d.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,d.jsx)("h3",{className:"font-semibold",children:"Usage by Account"})}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,d.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,d.jsxs)("tr",{children:[(0,d.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("rawModel"),children:["Model ",(0,d.jsx)(n,{field:"rawModel",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("provider"),children:["Provider"," ",(0,d.jsx)(n,{field:"provider",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("accountName"),children:["Account"," ",(0,d.jsx)(n,{field:"accountName",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("requests"),children:["Requests"," ",(0,d.jsx)(n,{field:"requests",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("lastUsed"),children:["Last Used"," ",(0,d.jsx)(n,{field:"lastUsed",currentSort:g,currentOrder:h})]}),"tokens"===v?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("promptTokens"),children:["Input Tokens"," ",(0,d.jsx)(n,{field:"promptTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("completionTokens"),children:["Output Tokens"," ",(0,d.jsx)(n,{field:"completionTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("totalTokens"),children:["Total Tokens"," ",(0,d.jsx)(n,{field:"totalTokens",currentSort:g,currentOrder:h})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("promptTokens"),children:["Input Cost"," ",(0,d.jsx)(n,{field:"promptTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("completionTokens"),children:["Output Cost"," ",(0,d.jsx)(n,{field:"completionTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("cost"),children:["Total Cost"," ",(0,d.jsx)(n,{field:"cost",currentSort:g,currentOrder:h})]})]})]})}),(0,d.jsxs)("tbody",{className:"divide-y divide-border",children:[D.map(a=>(0,d.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,d.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(k.default,{variant:a.pending>0?"primary":"default",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)("span",{className:`font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.accountName||`Account ${a.connectionId?.slice(0,8)}...`})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:E(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:F(a.lastUsed)}),"tokens"===v?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(a.promptTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(a.completionTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:E(a.totalTokens)})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(a.inputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(a.outputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(a.totalCost)})]})]},a.key)),0===D.length&&(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:9,className:"px-6 py-8 text-center text-text-muted",children:"No account-specific usage recorded yet. Make requests using OAuth accounts to see data here."})})]})]})})]})]})}n.propTypes={field:h().string.isRequired,currentSort:h().string.isRequired,currentOrder:h().string.isRequired},o.propTypes={data:h().arrayOf(h().number).isRequired,colorClass:h().string}},85974:(a,b,c)=>{c.d(b,{default:()=>e});var d=c(48249);function e({icon:a="\uD83D\uDCED",title:b="Nothing here yet",description:c="",actionLabel:e="",onAction:f=null}){return(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",minHeight:"200px"},children:[(0,d.jsx)("div",{style:{fontSize:"48px",marginBottom:"16px",opacity:.8,animation:"emptyBounce 2s ease-in-out infinite"},role:"img","aria-hidden":"true",children:a}),(0,d.jsx)("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary, #e0e0e0)",marginBottom:"8px",margin:0},children:b}),c&&(0,d.jsx)("p",{style:{fontSize:"14px",color:"var(--text-secondary, #888)",maxWidth:"320px",lineHeight:1.5,marginTop:"8px"},children:c}),e&&f&&(0,d.jsx)("button",{onClick:f,style:{marginTop:"20px",padding:"10px 24px",borderRadius:"8px",border:"1px solid rgba(99, 102, 241, 0.4)",background:"rgba(99, 102, 241, 0.15)",color:"#818cf8",fontSize:"14px",fontWeight:500,cursor:"pointer",transition:"all 0.2s ease"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(99, 102, 241, 0.25)",a.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(99, 102, 241, 0.15)",a.currentTarget.style.transform="translateY(0)"},children:e}),(0,d.jsx)("style",{children:`
16
+ `,children:[a.name,a.isCustom?" ★":""]},a.id)})})]},a)),0===Object.keys(y).length&&0===x.length&&(0,d.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,d.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}l.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,onSelect:g().func.isRequired,selectedModel:g().string,activeProviders:g().arrayOf(g().shape({provider:g().string.isRequired})),title:g().string,modelAliases:g().object}},29518:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(67484),f=c(31846);function g({label:a,type:b="text",placeholder:c,value:g,onChange:h,error:i,hint:j,icon:k,disabled:l=!1,required:m=!1,className:n,inputClassName:o,id:p,...q}){let r=(0,e.useId)(),s=p||r,t=i?`${s}-error`:void 0,u=j&&!i?`${s}-hint`:void 0,v=[t,u].filter(Boolean).join(" ")||void 0;return(0,d.jsxs)("div",{className:(0,f.cn)("flex flex-col gap-1.5",n),children:[a&&(0,d.jsxs)("label",{htmlFor:s,className:"text-sm font-medium text-text-main",children:[a,m&&(0,d.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,d.jsxs)("div",{className:"relative",children:[k&&(0,d.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-text-muted",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:k})}),(0,d.jsx)("input",{id:s,type:b,placeholder:c,value:g,onChange:h,disabled:l,required:m,"aria-required":m||void 0,"aria-invalid":!!i||void 0,"aria-describedby":v,className:(0,f.cn)("w-full py-2 px-3 text-sm text-text-main","bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md","placeholder-text-muted/60","focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none","transition-all shadow-inner disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",k&&"pl-10",i?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",o),...q})]}),i&&(0,d.jsxs)("p",{id:t,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),i]}),j&&!i&&(0,d.jsx)("p",{id:u,className:"text-xs text-text-muted",children:j})]})}},29824:(a,b,c)=>{c.d(b,{Ex:()=>j.default,$n:()=>d.default,Zp:()=>g.default,Qv:()=>i.CardSkeleton,G9:()=>u.default,bQ:()=>y.default,pp:()=>w.default,Qn:()=>x.default,pd:()=>e.default,Mh:()=>t.default,uR:()=>o.default,aF:()=>h.default,rq:()=>n.default,LF:()=>m.default,KN:()=>r.default,Lo:()=>s.default,y7:()=>q.default,Iz:()=>v.default,l6:()=>f.default,UW:()=>l.default,lM:()=>k.default,cn:()=>p.default});var d=c(53156),e=c(29518),f=c(59256),g=c(2490),h=c(65953),i=c(22746);c(45567);var j=c(4355),k=c(65472),l=c(59869);c(75146),c(65892),c(42546),c(22245);var m=c(8744),n=c(29494),o=c(1237);c(82054);var p=c(62688),q=c(46230),r=c(56589),s=c(73979);c(98004);var t=c(41371);c(53140);var u=c(27309),v=c(86059);c(77088);var w=c(85974);c(18732);var x=c(67083);c(52198);var y=c(50818);c(47047),c(16116)},31846:(a,b,c)=>{c.d(b,{cn:()=>d});function d(...a){return a.filter(Boolean).join(" ").replace(/\s+/g," ").trim()}},35005:(a,b,c)=>{c.d(b,{i:()=>f});var d=c(31417);let e=0,f=(0,d.v)((a,b)=>({notifications:[],addNotification:c=>{let d=++e,f={id:d,type:c.type||"info",message:c.message,title:c.title||null,duration:c.duration??5e3,dismissible:c.dismissible??!0,createdAt:Date.now()};return a(a=>({notifications:[...a.notifications,f]})),f.duration>0&&setTimeout(()=>{b().removeNotification(d)},f.duration),d},removeNotification:b=>{a(a=>({notifications:a.notifications.filter(a=>a.id!==b)}))},clearAll:()=>a({notifications:[]}),success:(a,c)=>b().addNotification({type:"success",message:a,title:c}),error:(a,c)=>b().addNotification({type:"error",message:a,title:c,duration:8e3}),warning:(a,c)=>b().addNotification({type:"warning",message:a,title:c}),info:(a,c)=>b().addNotification({type:"info",message:a,title:c})}))},37627:(a,b,c)=>{c.d(b,{Gp:()=>f,Ie:()=>g,Kf:()=>e,RY:()=>d,Yh:()=>k,_Z:()=>j,ng:()=>i});let d={github:{bg:"#6e40c9",text:"#fff",label:"GitHub"},kiro:{bg:"#FF9900",text:"#000",label:"Kiro"},antigravity:{bg:"#4285F4",text:"#fff",label:"AG"},claude:{bg:"#D97757",text:"#fff",label:"Claude"},codex:{bg:"#10A37F",text:"#fff",label:"Codex"},gemini:{bg:"#34A853",text:"#fff",label:"Gemini"},qwen:{bg:"#6366F1",text:"#fff",label:"Qwen"},iflow:{bg:"#EC4899",text:"#fff",label:"iFlow"},fireworks:{bg:"#F97316",text:"#fff",label:"Fireworks"},kimi:{bg:"#06B6D4",text:"#fff",label:"Kimi"},"gemini-cli":{bg:"#34A853",text:"#fff",label:"Gemini CLI"}},e={openai:{bg:"#10A37F",text:"#fff",label:"OpenAI"},claude:{bg:"#D97757",text:"#fff",label:"Claude"},gemini:{bg:"#4285F4",text:"#fff",label:"Gemini"},warmup:{bg:"#F59E0B",text:"#000",label:"Warmup"},bypass:{bg:"#6B7280",text:"#fff",label:"Bypass"}},f={http:{bg:"#3B82F6",text:"#fff",label:"HTTP"},https:{bg:"#10B981",text:"#fff",label:"HTTPS"},socks5:{bg:"#8B5CF6",text:"#fff",label:"SOCKS5"}},g={key:{bg:"#F59E0B",text:"#000",label:"Key"},combo:{bg:"#8B5CF6",text:"#fff",label:"Combo"},provider:{bg:"#3B82F6",text:"#fff",label:"Provider"},global:{bg:"#6B7280",text:"#fff",label:"Global"},direct:{bg:"#374151",text:"#9CA3AF",label:"Direct"}},h=["#D97757","#60A5FA","#34D399","#A78BFA","#F472B6","#FBBF24","#38BDF8","#FB923C","#818CF8","#2DD4BF","#E879F9","#F87171","#4ADE80","#C084FC","#FB7185"];function i(a){return h[a%h.length]}function j(a){return a>=200&&a<300?{bg:"#059669",text:"#fff"}:a>=400&&a<500?{bg:"#D97706",text:"#fff"}:a>=500?{bg:"#DC2626",text:"#fff"}:0===a?{bg:"#6366F1",text:"#fff"}:{bg:"#6B7280",text:"#fff"}}function k(a){return"success"===a?{bg:"#059669",text:"#fff"}:"error"===a?{bg:"#DC2626",text:"#fff"}:"timeout"===a?{bg:"#D97706",text:"#fff"}:{bg:"#6B7280",text:"#fff"}}},41371:(a,b,c)=>{c.d(b,{default:()=>k});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(8744),i=c(98004),j=c(53140);function k({isOpen:a,providerInfo:b,onSuccess:c,onClose:f}){let[g,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(null),p=(0,e.useCallback)((a,b)=>{"builder-id"===a?k("builder-id"):"idc"===a?(k("idc"),o(b)):"social"===a?(k("social"),m(b.provider)):"import"===a&&c?.()},[c]),q=()=>{k(null),m(null),o(null)};return g?"builder-id"===g||"idc"===g?(0,d.jsx)(h.default,{isOpen:a,provider:"kiro",providerInfo:b,onSuccess:()=>{k(null),o(null),c?.()},onClose:q,idcConfig:n}):"social"===g&&l?(0,d.jsx)(j.default,{isOpen:a,provider:l,onSuccess:()=>{k(null),m(null),c?.()},onClose:q}):null:(0,d.jsx)(i.default,{isOpen:a,onMethodSelect:p,onClose:f})}k.propTypes={isOpen:g().bool.isRequired,providerInfo:g().shape({name:g().string}),onSuccess:g().func,onClose:g().func.isRequired}},42546:(a,b,c)=>{c.d(b,{default:()=>u});var d=c(48249),e=c(19099),f=c(2116),g=c.n(f),h=c(81220),i=c(49885),j=c.n(i),k=c(29824),l=c(77360),m=c(67484);let n={healthy:{icon:"check_circle",color:"#22c55e",tooltip:"All tokens healthy"},warning:{icon:"warning",color:"#f59e0b",tooltip:"Some tokens need attention"},error:{icon:"error",color:"#ef4444",tooltip:"Token refresh failures detected"},unknown:{icon:"help",color:"#6b7280",tooltip:"Health status unknown"}};function o(){let a=(0,l.c)("stats"),[b,c]=(0,m.useState)(null),[e,f]=(0,m.useState)(!1);if(!b||0===b.total)return null;let g=n[b.status]||n.unknown;return(0,d.jsxs)("div",{className:"relative",onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[(0,d.jsxs)("button",{className:"flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-surface/30 transition-colors",title:g.tooltip,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",style:{color:g.color},children:g.icon}),b.errored>0&&(0,d.jsx)("span",{className:"text-xs font-medium",style:{color:g.color},children:b.errored})]}),e&&(0,d.jsxs)("div",{className:"absolute top-full right-0 mt-1 z-50 min-w-[200px] p-3 rounded-lg shadow-lg",style:{background:"rgba(15, 15, 25, 0.95)",border:"1px solid rgba(255,255,255,0.1)",backdropFilter:"blur(12px)"},children:[(0,d.jsx)("p",{className:"text-xs font-medium text-text-main mb-2",children:a("tokenHealth")}),(0,d.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,d.jsxs)("div",{className:"flex justify-between",children:[(0,d.jsx)("span",{className:"text-text-muted",children:a("totalOAuth")}),(0,d.jsx)("span",{className:"text-text-main",children:b.total})]}),(0,d.jsxs)("div",{className:"flex justify-between",children:[(0,d.jsx)("span",{className:"text-emerald-400",children:a("healthy")}),(0,d.jsx)("span",{className:"text-text-main",children:b.healthy})]}),b.errored>0&&(0,d.jsxs)("div",{className:"flex justify-between",children:[(0,d.jsx)("span",{className:"text-red-400",children:a("errored")}),(0,d.jsx)("span",{className:"text-text-main",children:b.errored})]}),b.warning>0&&(0,d.jsxs)("div",{className:"flex justify-between",children:[(0,d.jsx)("span",{className:"text-amber-400",children:a("warning")}),(0,d.jsx)("span",{className:"text-text-main",children:b.warning})]}),b.lastCheckAt&&(0,d.jsxs)("div",{className:"flex justify-between mt-1 pt-1 border-t border-white/5",children:[(0,d.jsx)("span",{className:"text-text-muted",children:a("lastCheck")}),(0,d.jsx)("span",{className:"text-text-muted",children:new Date(b.lastCheckAt).toLocaleTimeString()})]})]})]})]})}let p=[{code:"en",label:"EN",name:"English",flag:"\uD83C\uDDFA\uD83C\uDDF8"},{code:"pt-BR",label:"PT-BR",name:"Portugu\xeas (Brasil)",flag:"\uD83C\uDDE7\uD83C\uDDF7"},{code:"es",label:"ES",name:"Espa\xf1ol",flag:"\uD83C\uDDEA\uD83C\uDDF8"},{code:"fr",label:"FR",name:"Fran\xe7ais",flag:"\uD83C\uDDEB\uD83C\uDDF7"},{code:"it",label:"IT",name:"Italiano",flag:"\uD83C\uDDEE\uD83C\uDDF9"},{code:"ru",label:"RU",name:"Русский",flag:"\uD83C\uDDF7\uD83C\uDDFA"},{code:"zh-CN",label:"ZH-CN",name:"中文 (简体)",flag:"\uD83C\uDDE8\uD83C\uDDF3"},{code:"de",label:"DE",name:"Deutsch",flag:"\uD83C\uDDE9\uD83C\uDDEA"},{code:"in",label:"IN",name:"हिन्दी",flag:"\uD83C\uDDEE\uD83C\uDDF3"},{code:"th",label:"TH",name:"ไทย",flag:"\uD83C\uDDF9\uD83C\uDDED"},{code:"uk-UA",label:"UK-UA",name:"Українська",flag:"\uD83C\uDDFA\uD83C\uDDE6"},{code:"ar",label:"AR",name:"العربية",flag:"\uD83C\uDDF8\uD83C\uDDE6"},{code:"ja",label:"JA",name:"日本語",flag:"\uD83C\uDDEF\uD83C\uDDF5"},{code:"vi",label:"VI",name:"Tiếng Việt",flag:"\uD83C\uDDFB\uD83C\uDDF3"},{code:"bg",label:"BG",name:"Български",flag:"\uD83C\uDDE7\uD83C\uDDEC"},{code:"da",label:"DA",name:"Dansk",flag:"\uD83C\uDDE9\uD83C\uDDF0"},{code:"fi",label:"FI",name:"Suomi",flag:"\uD83C\uDDEB\uD83C\uDDEE"},{code:"he",label:"HE",name:"עברית",flag:"\uD83C\uDDEE\uD83C\uDDF1"},{code:"hu",label:"HU",name:"Magyar",flag:"\uD83C\uDDED\uD83C\uDDFA"},{code:"id",label:"ID",name:"Bahasa Indonesia",flag:"\uD83C\uDDEE\uD83C\uDDE9"},{code:"ko",label:"KO",name:"한국어",flag:"\uD83C\uDDF0\uD83C\uDDF7"},{code:"ms",label:"MS",name:"Bahasa Melayu",flag:"\uD83C\uDDF2\uD83C\uDDFE"},{code:"nl",label:"NL",name:"Nederlands",flag:"\uD83C\uDDF3\uD83C\uDDF1"},{code:"no",label:"NO",name:"Norsk",flag:"\uD83C\uDDF3\uD83C\uDDF4"},{code:"pt",label:"PT",name:"Portugu\xeas (Portugal)",flag:"\uD83C\uDDF5\uD83C\uDDF9"},{code:"ro",label:"RO",name:"Rom\xe2nă",flag:"\uD83C\uDDF7\uD83C\uDDF4"},{code:"pl",label:"PL",name:"Polski",flag:"\uD83C\uDDF5\uD83C\uDDF1"},{code:"sk",label:"SK",name:"Slovenčina",flag:"\uD83C\uDDF8\uD83C\uDDF0"},{code:"sv",label:"SV",name:"Svenska",flag:"\uD83C\uDDF8\uD83C\uDDEA"},{code:"phi",label:"PHI",name:"Filipino",flag:"\uD83C\uDDF5\uD83C\uDDED"}],q="NEXT_LOCALE";var r=c(89400);function s(){let a=(0,r.Ym)(),b=(0,e.useRouter)(),[c,f]=(0,m.useState)(!1),g=(0,m.useRef)(null),h=p.find(b=>b.code===a)||p[0];return(0,d.jsxs)("div",{ref:g,className:"relative",children:[(0,d.jsxs)("button",{onClick:()=>f(!c),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-sm font-medium text-text-main hover:bg-surface-hover transition-all border border-transparent hover:border-border",title:h.name,children:[(0,d.jsx)("span",{className:"text-base leading-none",children:h.flag}),(0,d.jsx)("span",{className:"text-xs font-semibold tracking-wide",children:h.label}),(0,d.jsx)("span",{className:`material-symbols-outlined text-[14px] text-text-muted transition-transform ${c?"rotate-180":""}`,children:"expand_more"})]}),c&&(0,d.jsx)("div",{className:"absolute right-0 top-full mt-1 w-56 max-h-80 rounded-xl border border-border bg-bg shadow-xl z-50 overflow-y-auto animate-in fade-in slide-in-from-top-1 duration-150",children:p.map(c=>(0,d.jsxs)("button",{onClick:()=>(c=>{if(c===a)return void f(!1);document.cookie=`${q}=${c};path=/;max-age=31536000;samesite=lax`;try{localStorage.setItem(q,c)}catch{}f(!1),b.refresh()})(c.code),className:`w-full flex items-center gap-2.5 px-3 py-2.5 text-sm transition-colors ${c.code===a?"bg-primary/10 text-primary font-semibold":"text-text-main hover:bg-surface-hover"}`,children:[(0,d.jsx)("span",{className:"text-base leading-none",children:c.flag}),(0,d.jsx)("span",{className:"flex-1 text-left",children:c.name}),c.code===a&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"check"})]},c.code))})]})}var t=c(17084);function u({onMenuClick:a,showMenuButton:b=!0}){let c=(0,e.usePathname)(),f=(0,e.useRouter)(),i=(0,l.c)("header"),{title:j,description:m,breadcrumbs:n}=function(a){let b=(0,l.c)("header");if(!a)return{title:"",description:"",breadcrumbs:[]};let c=a.match(/\/providers\/([^/]+)$/);if(c){let a=c[1],d=t.zN[a]||t.IS[a]||t.fg[a];if(d)return{title:d.name,description:"",breadcrumbs:[{label:b("providers"),href:"/dashboard/providers"},{label:d.name,image:`/providers/${d.id}.png`}]};if(a.startsWith(t.JH))return{title:b("openaiCompatible"),description:"",breadcrumbs:[{label:b("providers"),href:"/dashboard/providers"},{label:b("openaiCompatible"),image:"/providers/oai-cc.png"}]};if(a.startsWith(t.DI))return{title:b("anthropicCompatible"),description:"",breadcrumbs:[{label:b("providers"),href:"/dashboard/providers"},{label:b("anthropicCompatible"),image:"/providers/anthropic-m.png"}]}}return a.includes("/providers")?{title:b("providers"),description:b("providerDescription"),breadcrumbs:[]}:a.includes("/combos")?{title:b("combos"),description:b("comboDescription"),breadcrumbs:[]}:a.includes("/usage")?{title:b("usage"),description:b("usageDescription"),breadcrumbs:[]}:a.includes("/analytics")?{title:b("analytics"),description:b("analyticsDescription"),breadcrumbs:[]}:a.includes("/cli-tools")?{title:b("cliTools"),description:b("cliToolsDescription"),breadcrumbs:[]}:"/dashboard"===a?{title:b("home"),description:b("homeDescription"),breadcrumbs:[]}:a.includes("/endpoint")?{title:b("endpoint"),description:b("endpointDescription"),breadcrumbs:[]}:a.includes("/profile")?{title:b("settings"),description:b("settingsDescription"),breadcrumbs:[]}:{title:"",description:"",breadcrumbs:[]}}(c),p=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&(f.push("/login"),f.refresh())}catch(a){console.error("Failed to logout:",a)}};return(0,d.jsxs)("header",{className:"flex items-center justify-between px-8 py-5 border-b border-black/5 dark:border-white/5 bg-bg/80 backdrop-blur-xl z-10 sticky top-0",children:[(0,d.jsx)("div",{className:"flex items-center gap-3 lg:hidden",children:b&&(0,d.jsx)("button",{onClick:a,className:"text-text-main hover:text-primary transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined",children:"menu"})})}),(0,d.jsx)("div",{className:"hidden lg:flex flex-col",children:n.length>0?(0,d.jsx)("div",{className:"flex items-center gap-2",children:n.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[b>0&&(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-base",children:"chevron_right"}),a.href?(0,d.jsx)(g(),{href:a.href,className:"text-text-muted hover:text-primary transition-colors",children:a.label}):(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[a.image&&(0,d.jsx)(h.default,{src:a.image,alt:a.label,width:28,height:28,className:"object-contain rounded max-w-[28px] max-h-[28px]",sizes:"28px",onError:a=>{a.currentTarget.style.display="none"}}),(0,d.jsx)("h1",{className:"text-2xl font-semibold text-text-main tracking-tight",children:a.label})]})]},`${a.label}-${a.href||"current"}`))}):j?(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-2xl font-semibold text-text-main tracking-tight",children:j}),m&&(0,d.jsx)("p",{className:"text-sm text-text-muted",children:m})]}):null}),(0,d.jsxs)("div",{className:"flex items-center gap-3 ml-auto",children:[(0,d.jsx)(s,{}),(0,d.jsx)(k.UW,{}),(0,d.jsx)(o,{}),(0,d.jsx)("button",{onClick:p,className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-red-500 hover:bg-red-500/10 transition-all",title:i("logout"),children:(0,d.jsx)("span",{className:"material-symbols-outlined",children:"logout"})})]})]})}u.propTypes={onMenuClick:j().func,showMenuButton:j().bool}},45567:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(31846);function f({src:a,alt:b="Avatar",name:c,size:f="md",className:g}){let h={xs:"size-6 text-xs",sm:"size-8 text-sm",md:"size-10 text-base",lg:"size-12 text-lg",xl:"size-16 text-xl"};return a?(0,d.jsx)("div",{className:(0,e.cn)("rounded-full bg-cover bg-center bg-no-repeat","ring-2 ring-white dark:ring-surface-dark shadow-sm",h[f],g),style:{backgroundImage:`url(${a})`},role:"img","aria-label":b}):(0,d.jsx)("div",{className:(0,e.cn)("rounded-full flex items-center justify-center font-semibold text-white","ring-2 ring-white dark:ring-surface-dark shadow-sm",h[f],(a=>{if(!a)return"bg-primary";let b=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"],c=a.charCodeAt(0)%b.length;return b[c]})(c),g),role:"img","aria-label":b,children:(a=>{if(!a)return"?";let b=a.split(" ");return b.length>=2?`${b[0][0]}${b[1][0]}`.toUpperCase():a.substring(0,2).toUpperCase()})(c)})}},46230:(a,b,c)=>{c.d(b,{default:()=>p});var d=c(48249),e=c(67484),f=c(2490),g=c(37627),h=c(17908);function i({title:a,json:b,onCopy:c}){let[f,g]=(0,e.useState)(!1),h=async()=>{!1!==await c()&&(g(!0),setTimeout(()=>g(!1),2e3))};return(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsx)("h3",{className:"text-[11px] text-text-muted uppercase tracking-wider font-bold",children:a}),(0,d.jsxs)("button",{onClick:h,className:"flex items-center gap-1 px-2 py-1 text-xs text-text-muted hover:text-text-primary transition-colors","aria-label":`Copy ${a}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:f?"check":"content_copy"}),f?"Copied!":"Copy"]})]}),(0,d.jsx)("pre",{className:"p-4 rounded-xl bg-black/30 border border-border overflow-x-auto text-xs font-mono text-text-primary max-h-[600px] overflow-y-auto leading-relaxed whitespace-pre-wrap break-words",children:b})]})}function j({log:a,detail:b,loading:c,onClose:e,onCopy:f}){let j=(0,g._Z)(a.status),k=a.sourceFormat||a.provider,l=g.Kf[k]||g.Kf[a.provider]||{bg:"#6B7280",text:"#fff",label:(k||a.provider||"-").toUpperCase()},m=g.RY[a.provider]||{bg:"#374151",text:"#fff",label:(a.provider||"-").toUpperCase()},n=b?.requestBody?JSON.stringify(b.requestBody,null,2):null,o=b?.responseBody?JSON.stringify(b.responseBody,null,2):null;return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:e,role:"dialog","aria-modal":"true","aria-label":"Request log detail",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,d.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[900px] max-h-[90vh] overflow-y-auto shadow-2xl",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold",style:{backgroundColor:j.bg,color:j.text},children:a.status}),(0,d.jsx)("span",{className:"font-bold text-lg",children:a.method}),(0,d.jsx)("span",{className:"text-text-muted font-mono text-sm",children:a.path})]}),(0,d.jsx)("button",{onClick:e,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close detail modal",children:(0,d.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,d.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 p-4 bg-bg-subtle rounded-xl border border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Time"}),(0,d.jsx)("div",{className:"text-sm font-medium",children:(a=>{try{let b=new Date(a);return b.toLocaleDateString("pt-BR")+", "+b.toLocaleTimeString("en-US",{hour12:!1})}catch{return a}})(a.timestamp)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Duration"}),(0,d.jsx)("div",{className:"text-sm font-medium",children:(0,h.a3)(a.duration)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Tokens (I/O)"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("span",{className:"px-2 py-0.5 rounded bg-primary/20 text-primary text-xs font-bold",children:["In: ",(b?.tokens?.in||a.tokens?.in||0).toLocaleString()]}),(0,d.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/20 text-emerald-400 text-xs font-bold",children:["Out: ",(b?.tokens?.out||a.tokens?.out||0).toLocaleString()]})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Model"}),(0,d.jsx)("div",{className:"text-sm font-medium text-primary font-mono",children:a.model})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:m.bg,color:m.text},children:m.label})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Protocol"}),(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:l.bg,color:l.text},children:l.label})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Account"}),(0,d.jsx)("div",{className:"text-sm font-medium",children:b?.account||a.account||"-"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"API Key"}),(0,d.jsx)("div",{className:"text-sm font-medium",title:b?.apiKeyName||b?.apiKeyId||a.apiKeyName||a.apiKeyId||"No API key",children:(0,h.VO)(b?.apiKeyName||a.apiKeyName,b?.apiKeyId||a.apiKeyId)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Combo"}),b?.comboName||a.comboName?(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded-full text-[10px] font-bold bg-violet-500/20 text-violet-300 border border-violet-500/30",children:b?.comboName||a.comboName}):(0,d.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]})]}),(b?.error||a.error)&&(0,d.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,d.jsx)("div",{className:"text-[10px] text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,d.jsx)("div",{className:"text-sm text-red-300 font-mono",children:b?.error||a.error})]}),c?(0,d.jsx)("div",{className:"p-8 text-center text-text-muted animate-pulse",children:"Loading request details..."}):(0,d.jsxs)(d.Fragment,{children:[n&&(0,d.jsx)(i,{title:"Request Payload",json:n,onCopy:()=>f(n)}),o&&(0,d.jsx)(i,{title:"Response Payload",json:o,onCopy:()=>f(o)}),!n&&!o&&!c&&(0,d.jsxs)("div",{className:"p-6 text-center text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[32px] mb-2 block opacity-40",children:"info"}),(0,d.jsx)("p",{className:"text-sm",children:"No payload data available for this log entry."}),(0,d.jsx)("p",{className:"text-xs mt-1",children:"Request/response bodies are only captured for non-streaming calls or when streaming completes normally."})]})]})]})]})]})}let k=[{key:"all",label:"All"},{key:"error",label:"Errors",icon:"error"},{key:"ok",label:"Success",icon:"check_circle"},{key:"combo",label:"Combo",icon:"hub"}],l=[{key:"status",label:"Status"},{key:"model",label:"Model"},{key:"provider",label:"Provider"},{key:"protocol",label:"Protocol"},{key:"account",label:"Account"},{key:"apiKey",label:"API Key"},{key:"combo",label:"Combo"},{key:"tokens",label:"Tokens"},{key:"duration",label:"Duration"},{key:"time",label:"Time"}],m=Object.fromEntries(l.map(a=>[a.key,!0]));function n(a,b){if(!a)return"-";if(a.startsWith("openai-compatible-")||a.startsWith("anthropic-compatible-")){if(b?.length){let c=b.find(b=>b.id===a||b.prefix===a);if(c?.name)return c.name}if(a.startsWith("openai-compatible-")){let b=a.replace("openai-compatible-",""),c=b.split("-");return c.length>1&&c[1]?.length>=8?"OAI-COMPAT":`OAI: ${b.slice(0,16).toUpperCase()}`}if(a.startsWith("anthropic-compatible-")){let b=a.replace("anthropic-compatible-",""),c=b.split("-");return c.length>1&&c[1]?.length>=8?"ANT-COMPAT":`ANT: ${b.slice(0,16).toUpperCase()}`}}return null}function o(a){return(a?.tokens?.in||0)+(a?.tokens?.out||0)}function p(){let[a,b]=(0,e.useState)([]),[c,i]=(0,e.useState)(!0),[p,q]=(0,e.useState)(!0),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)("all"),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)(""),[z,A]=(0,e.useState)(""),[B,C]=(0,e.useState)(""),[D,E]=(0,e.useState)("newest"),[F,G]=(0,e.useState)(null),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)(null);(0,e.useRef)(null),(0,e.useRef)(!1);let[L,M]=(0,e.useState)([]),[N,O]=(0,e.useState)(()=>m),P=(0,e.useCallback)(a=>{O(b=>{let c={...b,[a]:!b[a]};try{localStorage.setItem("loggerVisibleColumns",JSON.stringify(c))}catch{}return c})},[]),Q=(0,e.useCallback)(async(a=!1)=>{a&&i(!0);try{let a=new URLSearchParams;r&&a.set("search",r),"error"===t&&a.set("status","error"),"ok"===t&&a.set("status","ok"),"combo"===t&&a.set("combo","1"),v&&a.set("model",v),z&&a.set("provider",z),x&&a.set("account",x),B&&a.set("apiKey",B),a.set("limit","300");let c=await fetch(`/api/usage/call-logs?${a}`);if(c.ok){let a=await c.json();b(a)}}catch(a){console.error("Failed to fetch call logs:",a)}finally{a&&i(!1)}},[r,t,v,x,z,B]),R=(0,e.useMemo)(()=>"combo"===t?a.filter(a=>a.comboName):a,[t,a]),S=(0,e.useMemo)(()=>{let a=[...R];return a.sort((a,b)=>{switch(D){case"oldest":return new Date(a.timestamp).getTime()-new Date(b.timestamp).getTime();case"tokens_desc":return o(b)-o(a);case"tokens_asc":return o(a)-o(b);case"duration_desc":return(b.duration||0)-(a.duration||0);case"duration_asc":return(a.duration||0)-(b.duration||0);case"status_desc":return(b.status||0)-(a.status||0);case"status_asc":return(a.status||0)-(b.status||0);case"model_asc":return(a.model||"").localeCompare(b.model||"");case"model_desc":return(b.model||"").localeCompare(a.model||"");default:return new Date(b.timestamp).getTime()-new Date(a.timestamp).getTime()}}),a},[R,D]),T=async a=>{G(a),I(!0),K(null);try{let b=await fetch(`/api/usage/call-logs/${a.id}`);if(b.ok){let a=await b.json();K(a)}}catch(a){console.error("Failed to fetch log detail:",a)}finally{I(!1)}},U=async a=>{try{return await navigator.clipboard.writeText(a),!0}catch{try{let b=document.createElement("textarea");return b.value=a,b.style.position="fixed",b.style.left="-9999px",document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b),!0}catch{return!1}}},V=[...new Set(a.map(a=>a.account).filter(a=>a&&"-"!==a))],W=[...new Set(a.map(a=>a.model).filter(Boolean))].sort(),X=[...new Set(a.map(a=>a.provider).filter(a=>a&&"-"!==a))].sort(),Y=[...new Set(a.map(a=>a.apiKeyId||a.apiKeyName).filter(Boolean))].sort(),Z=R.length,$=R.filter(a=>a.status>=200&&a.status<300).length,_=R.filter(a=>a.status>=400).length,aa=a.filter(a=>a.comboName).length,ab=Y.length;return(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,d.jsxs)("button",{onClick:()=>q(!p),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${p?"bg-red-500/10 border-red-500/30 text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,d.jsx)("span",{className:`w-2 h-2 rounded-full ${p?"bg-red-500 animate-pulse":"bg-text-muted"}`}),p?"Recording":"Paused"]}),(0,d.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,d.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,d.jsx)("input",{type:"text",placeholder:"Search model, provider, account, API key, combo...",value:r,onChange:a=>s(a.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,d.jsxs)("select",{value:z,onChange:a=>A(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,d.jsx)("option",{value:"",children:"All Providers"}),X.map(a=>{let b=n(a,L),c=g.RY[a];return(0,d.jsx)("option",{value:a,children:b||c?.label||a.toUpperCase()},a)})]}),(0,d.jsxs)("select",{value:v,onChange:a=>w(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[180px]",children:[(0,d.jsx)("option",{value:"",children:"All Models"}),W.map(a=>(0,d.jsx)("option",{value:a,children:a},a))]}),(0,d.jsxs)("select",{value:x,onChange:a=>y(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,d.jsx)("option",{value:"",children:"All Accounts"}),V.map(a=>(0,d.jsx)("option",{value:a,children:a},a))]}),(0,d.jsxs)("select",{value:B,onChange:a=>C(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[160px]",children:[(0,d.jsx)("option",{value:"",children:"All API Keys"}),Y.map(b=>{let c=a.find(a=>(a.apiKeyId||a.apiKeyName)===b),e=(0,h.VO)(c?.apiKeyName,c?.apiKeyId);return(0,d.jsx)("option",{value:b,children:e},b)})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[Z," total"]}),(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 font-mono",children:[$," OK"]}),_>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-400 font-mono",children:[_," ERR"]}),aa>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-violet-500/10 text-violet-300 font-mono",children:[aa," combo"]}),ab>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-primary/10 text-primary font-mono",children:[ab," keys"]}),(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[S.length," shown"]})]}),(0,d.jsxs)("select",{value:D,onChange:a=>E(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[150px]",title:"Sort logs",children:[(0,d.jsx)("option",{value:"newest",children:"Newest"}),(0,d.jsx)("option",{value:"oldest",children:"Oldest"}),(0,d.jsx)("option",{value:"tokens_desc",children:"Tokens ↓"}),(0,d.jsx)("option",{value:"tokens_asc",children:"Tokens ↑"}),(0,d.jsx)("option",{value:"duration_desc",children:"Duration ↓"}),(0,d.jsx)("option",{value:"duration_asc",children:"Duration ↑"}),(0,d.jsx)("option",{value:"status_desc",children:"Status ↓"}),(0,d.jsx)("option",{value:"status_asc",children:"Status ↑"}),(0,d.jsx)("option",{value:"model_asc",children:"Model A-Z"}),(0,d.jsx)("option",{value:"model_desc",children:"Model Z-A"})]}),(0,d.jsx)("button",{onClick:()=>Q(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[k.map(a=>(0,d.jsxs)("button",{onClick:()=>u(t===a.key?"all":a.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${t===a.key?"error"===a.key?"bg-red-500/20 text-red-400 border-red-500/40":"ok"===a.key?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"combo"===a.key?"bg-violet-500/20 text-violet-300 border-violet-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[a.icon&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:a.icon}),a.label]},a.key)),X.length>0&&(0,d.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),X.map(a=>{let b=n(a,L),c=g.RY[a]||{bg:"#374151",text:"#fff",label:b||a.toUpperCase()},e=b||c.label,f=z===a;return(0,d.jsx)("button",{onClick:()=>A(f?"":a),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${f?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:f?c.bg:`${c.bg}33`,color:f?c.text:c.bg},children:e},a)})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,d.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),l.map(a=>(0,d.jsx)("button",{onClick:()=>P(a.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${N[a.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:a.label},a.key))]}),(0,d.jsx)(f.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,d.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:c&&0===a.length?(0,d.jsx)("div",{className:"p-8 text-center text-text-muted",children:"Loading logs..."}):0===a.length?(0,d.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"receipt_long"}),"No logs recorded yet. Make some API calls to see them here."]}):0===S.length?(0,d.jsx)("div",{className:"p-8 text-center text-text-muted",children:"No logs match the current filters."}):(0,d.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,d.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:(0,d.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:[N.status&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Status"}),N.model&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Model"}),N.provider&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Provider"}),N.protocol&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Protocol"}),N.account&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Account"}),N.apiKey&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"API Key"}),N.combo&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Combo"}),N.tokens&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Tokens"}),N.duration&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Duration"}),N.time&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Time"})]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border/30",children:S.map(a=>{let b=(0,g._Z)(a.status),c=a.sourceFormat||a.provider,e=g.Kf[c]||g.Kf[a.provider]||{bg:"#6B7280",text:"#fff",label:(c||a.provider||"-").toUpperCase()},f=n(a.provider,L),i=g.RY[a.provider]||{bg:"#374151",text:"#fff",label:f||(a.provider||"-").toUpperCase()},j=f||i.label,k=a.status>=400;return(0,d.jsxs)("tr",{onClick:()=>T(a),className:`cursor-pointer hover:bg-primary/5 transition-colors ${k?"bg-red-500/5":""}`,children:[N.status&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[36px] text-center",style:{backgroundColor:b.bg,color:b.text},children:a.status||"..."})}),N.model&&(0,d.jsx)("td",{className:"px-3 py-2 font-medium text-primary font-mono text-[11px]",children:a.model}),N.provider&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:i.bg,color:i.text},children:j})}),N.protocol&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:e.bg,color:e.text},children:e.label})}),N.account&&(0,d.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[120px]",title:a.account,children:(0,h.Ib)(a.account)}),N.apiKey&&(0,d.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[140px]",title:a.apiKeyName||a.apiKeyId||"No API key",children:(0,h.VO)(a.apiKeyName,a.apiKeyId)}),N.combo&&(0,d.jsx)("td",{className:"px-3 py-2",children:a.comboName?(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded-full text-[9px] font-bold bg-violet-500/20 text-violet-300 border border-violet-500/30",children:a.comboName}):(0,d.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),N.tokens&&(0,d.jsxs)("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:[(0,d.jsx)("span",{className:"text-text-muted",children:"I:"})," ",(0,d.jsx)("span",{className:"text-primary",children:a.tokens?.in?.toLocaleString()||0}),(0,d.jsx)("span",{className:"mx-1 text-border",children:"|"}),(0,d.jsx)("span",{className:"text-text-muted",children:"O:"})," ",(0,d.jsx)("span",{className:"text-emerald-400",children:a.tokens?.out?.toLocaleString()||0})]}),N.duration&&(0,d.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,h.a3)(a.duration)}),N.time&&(0,d.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,h.fU)(a.timestamp)})]},a.id)})})]})})}),(0,d.jsxs)("div",{className:"text-[10px] text-text-muted italic",children:["Call logs are also saved as JSON files to ",(0,d.jsx)("code",{children:"{DATA_DIR}/call_logs/"})," with 7-day rotation."]}),F&&(0,d.jsx)(j,{log:F,detail:J,loading:H,onClose:()=>{G(null),K(null)},onCopy:U})]})}},47047:(a,b,c)=>{c.d(b,{default:()=>k});var d=c(48249),e=c(67484),f=c(65892),g=c(42546),h=c(77088),i=c(18732);function j(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)("");return((0,e.useCallback)(async()=>{try{(await fetch("/api/monitoring/health",{signal:AbortSignal.timeout(3e3)})).ok?a&&(b(!1),f("")):(b(!0),f("Server is experiencing issues. Some features may be unavailable."))}catch{b(!0),f("Server is unreachable. Reconnecting...")}},[a]),a)?(0,d.jsxs)("div",{className:"bg-amber-500/10 border-b border-amber-500/20 px-4 py-2.5 flex items-center justify-between gap-3 animate-in slide-in-from-top",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-amber-500 text-[18px] animate-pulse",children:"warning"}),(0,d.jsx)("span",{className:"text-sm text-amber-200",children:c})]}),(0,d.jsx)("button",{onClick:()=>b(!1),className:"p-1 rounded hover:bg-white/5 text-text-muted hover:text-text-main transition-colors","aria-label":"Dismiss",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}):null}function k({children:a}){let[b,c]=(0,e.useState)(!1),[k,l]=(0,e.useState)(()=>!1);return(0,d.jsxs)("div",{className:"flex h-screen w-full overflow-hidden bg-bg",children:[b&&(0,d.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 lg:hidden",onClick:()=>c(!1)}),(0,d.jsx)("div",{className:"hidden lg:flex",children:(0,d.jsx)(f.default,{collapsed:k,onToggleCollapse:()=>{let a=!k;l(a),localStorage.setItem("sidebar-collapsed",String(a))}})}),(0,d.jsx)("div",{className:`fixed inset-y-0 left-0 z-50 transform lg:hidden transition-transform duration-300 ease-in-out ${b?"translate-x-0":"-translate-x-full"}`,children:(0,d.jsx)(f.default,{onClose:()=>c(!1)})}),(0,d.jsxs)("main",{id:"main-content",className:"flex flex-col flex-1 h-full min-w-0 relative transition-colors duration-300",children:[(0,d.jsx)(g.default,{onMenuClick:()=>c(!0)}),(0,d.jsx)(j,{}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-6 lg:p-10",children:(0,d.jsxs)("div",{className:"max-w-7xl mx-auto",children:[(0,d.jsx)(h.default,{}),a]})})]}),(0,d.jsx)(i.default,{})]})}},50818:(a,b,c)=>{c.d(b,{default:()=>e});var d=c(48249);function e({columns:a=[],data:b=[],renderCell:c,renderHeader:e,onRowClick:f,selectedId:g,loading:h=!1,maxHeight:i="calc(100vh - 320px)",emptyIcon:j="\uD83D\uDCED",emptyMessage:k="No data found"}){return h?(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,d.jsx)("span",{style:{animation:"spin 1s linear infinite",marginRight:"8px"},children:"⏳"}),"Loading...",(0,d.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}):0===b.length?(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--text-secondary, #888)",fontSize:"14px"},children:[(0,d.jsx)("span",{style:{fontSize:"32px",marginBottom:"8px",opacity:.6},children:j}),k]}):(0,d.jsx)("div",{style:{overflow:"auto",maxHeight:i,borderRadius:"8px"},children:(0,d.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px",tableLayout:"auto"},children:[(0,d.jsx)("thead",{children:(0,d.jsx)("tr",{children:a.map(a=>(0,d.jsx)("th",{style:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"var(--text-secondary, #888)",borderBottom:"1px solid rgba(255,255,255,0.08)",position:"sticky",top:0,background:"var(--bg-table-header, rgba(15,15,25,0.95))",zIndex:1,whiteSpace:"nowrap",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px"},children:e?e(a):a.label},a.key))})}),(0,d.jsx)("tbody",{children:b.map((b,e)=>(0,d.jsx)("tr",{onClick:()=>f?.(b),style:{cursor:f?"pointer":"default",background:b.id===g?"rgba(99,102,241,0.1)":e%2==0?"transparent":"rgba(255,255,255,0.02)",transition:"background 0.15s"},onMouseEnter:a=>{b.id!==g&&(a.currentTarget.style.background="rgba(255,255,255,0.04)")},onMouseLeave:a=>{b.id!==g&&(a.currentTarget.style.background=e%2==0?"transparent":"rgba(255,255,255,0.02)")},children:a.map(a=>(0,d.jsx)("td",{style:{padding:"6px 10px",borderBottom:"1px solid rgba(255,255,255,0.04)",whiteSpace:"nowrap",maxWidth:a.maxWidth||"200px",overflow:"hidden",textOverflow:"ellipsis"},children:c(b,a)},a.key))},b.id||e))})]})})}},52198:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(67484);function f({columns:a=[],visible:b={},onToggle:c}){let[f,g]=(0,e.useState)(!1),h=(0,e.useRef)(null);return(0,d.jsxs)("div",{ref:h,style:{position:"relative"},children:[(0,d.jsxs)("button",{onClick:()=>g(!f),title:"Toggle columns",style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-secondary, #888)",fontSize:"13px",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[(0,d.jsx)("span",{style:{fontSize:"14px"},children:"⚙️"}),"Columns"]}),f&&(0,d.jsx)("div",{style:{position:"absolute",top:"100%",right:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"8px",zIndex:50,minWidth:"160px",backdropFilter:"blur(12px)"},children:a.map(a=>(0,d.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 8px",cursor:"pointer",fontSize:"12px",color:b[a.key]?"var(--text-primary, #e0e0e0)":"var(--text-secondary, #888)",borderRadius:"4px"},children:[(0,d.jsx)("input",{type:"checkbox",checked:b[a.key]??!0,onChange:()=>c(a.key),style:{accentColor:"#6366f1"}}),a.label]},a.key))})]})}},53140:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(29824),i=c(73295);function j({isOpen:a,provider:b,onSuccess:c,onClose:f}){let[g,j]=(0,e.useState)("loading"),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(null),{copied:s,copy:t}=(0,i.C)(),u=async()=>{try{let a;r(null);try{a=new URL(o)}catch(a){throw Error("Invalid callback URL format")}let d=a.searchParams.get("code");a.searchParams.get("state");let e=a.searchParams.get("error");if(e)throw Error(a.searchParams.get("error_description")||e);if(!d)throw Error("No authorization code found in URL");let f=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:d,codeVerifier:m.codeVerifier,provider:b})}),g=await f.json();if(!f.ok)throw Error(g.error);j("success"),c?.()}catch(a){r(a.message),j("error")}},v="google"===b?"Google":"GitHub";return(0,d.jsx)(h.aF,{isOpen:a,title:`Connect Kiro via ${v}`,onClose:f,size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,d.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",v," authentication"]})]}),"input"===g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.pd,{value:k,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,d.jsx)(h.$n,{variant:"secondary",icon:"auth_url"===s?"check":"content_copy",onClick:()=>t(k,"auth_url"),children:"Copy"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,d.jsx)(h.pd,{value:o,onChange:a=>p(a.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:u,fullWidth:!0,disabled:!o,children:"Connect"}),(0,d.jsx)(h.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,d.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",v," has been connected."]}),(0,d.jsx)(h.$n,{onClick:f,fullWidth:!0,children:"Done"})]}),"error"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,d.jsx)("p",{className:"text-sm text-red-600 mb-4",children:q}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:()=>j("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,d.jsx)(h.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}j.propTypes={isOpen:g().bool.isRequired,provider:g().oneOf(["google","github"]).isRequired,onSuccess:g().func,onClose:g().func.isRequired}},53156:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(31846);let f={primary:"bg-gradient-to-b from-primary to-primary-hover text-white shadow-sm",secondary:"bg-white dark:bg-white/10 border border-black/10 dark:border-white/10 text-text-main hover:bg-black/5 dark:hover:bg-white/5",outline:"border border-black/15 dark:border-white/15 text-text-main hover:bg-black/5",ghost:"text-text-muted hover:bg-black/5 dark:hover:bg-white/5 hover:text-text-main",danger:"bg-red-500 text-white hover:bg-red-600 shadow-sm"},g={sm:"h-7 px-3 text-xs rounded-md",md:"h-9 px-4 text-sm rounded-lg",lg:"h-11 px-6 text-sm rounded-lg"};function h({children:a,variant:b="primary",size:c="md",icon:h,iconRight:i,disabled:j=!1,loading:k=!1,fullWidth:l=!1,className:m,...n}){return(0,d.jsxs)("button",{type:"button",className:(0,e.cn)("inline-flex items-center justify-center gap-2 font-medium transition-all duration-200 cursor-pointer","active:scale-[0.99] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",f[b],g[c],l&&"w-full",m),disabled:j||k,"aria-busy":k||void 0,...n,children:[k?(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px] pointer-events-none","aria-hidden":"true",children:"progress_activity"}):h?(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] pointer-events-none","aria-hidden":"true",children:h}):null,a,i&&!k&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] pointer-events-none","aria-hidden":"true",children:i})]})}},56589:(a,b,c)=>{c.d(b,{default:()=>l});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(65953),i=c(53156);let j=[{value:"http",label:"HTTP"},{value:"https",label:"HTTPS"},{value:"socks5",label:"SOCKS5"}],k={global:"Global",provider:"Provider",combo:"Combo",key:"Key",direct:"Direct (none)"};function l({isOpen:a,onClose:b,level:c,levelId:f,levelLabel:g,onSaved:l}){let[m,n]=(0,e.useState)(j[0]?.value||"http"),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(""),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(null),[E,F]=(0,e.useState)(!0),[G,H]=(0,e.useState)(null),[I,J]=(0,e.useState)(!1),[K,L]=(0,e.useState)(null),M=a=>"socks5"===a?"1080":"https"===a?"443":"8080",N=async()=>{if(o.trim()){L(null),z(!0);try{let a={type:m,host:o.trim(),port:q.trim()||M(m),username:s.trim(),password:u.trim()},b=await fetch("/api/settings/proxy",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:c,id:f,proxy:a})}),d=await b.json().catch(()=>({}));if(!b.ok)return void L(d?.error?.message||"Failed to save proxy configuration");J(!0),l?.()}catch(a){console.error("Error saving proxy:",a),L(a.message||"Failed to save proxy configuration")}finally{z(!1)}}},O=async()=>{L(null),z(!0);try{let a=new URLSearchParams({level:c});f&&a.set("id",f);let b=await fetch(`/api/settings/proxy?${a}`,{method:"DELETE"}),d=await b.json().catch(()=>({}));if(!b.ok)return void L(d?.error?.message||"Failed to clear proxy configuration");n(j[0]?.value||"http"),p(""),r(""),t(""),v(""),x(!1),L(null),J(!1),D(null),l?.()}catch(a){console.error("Error clearing proxy:",a),L(a.message||"Failed to clear proxy configuration")}finally{z(!1)}},P=async()=>{if(o.trim()){L(null),B(!0),D(null);try{let a={type:m,host:o.trim(),port:q.trim()||M(m),username:s.trim(),password:u.trim()},b=await fetch("/api/settings/proxy/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxy:a})}),c=await b.json().catch(()=>({}));if(!b.ok){let a=c?.error?.message||"Connection failed";D({success:!1,error:a}),L(a);return}D(c)}catch(a){D({success:!1,error:a.message}),L(a.message||"Connection failed")}finally{B(!1)}}},Q="global"===c?"Global Proxy Configuration":`${k[c]} Proxy — ${g||f||""}`;return(0,d.jsx)(h.default,{isOpen:a,onClose:b,title:Q,maxWidth:"lg",children:E?(0,d.jsx)("div",{className:"py-8 text-center text-text-muted animate-pulse",children:"Loading proxy configuration..."}):(0,d.jsxs)("div",{className:"flex flex-col gap-5",children:["global"!==c&&!I&&G&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-blue-500/10 border border-blue-500/20 text-sm",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-blue-400 text-base",children:"subdirectory_arrow_right"}),(0,d.jsxs)("span",{className:"text-blue-300",children:["Inheriting from ",(0,d.jsx)("strong",{children:G.level}),": ",G.proxy?.type,"://",G.proxy?.host,":",G.proxy?.port]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Proxy Type"}),(0,d.jsx)("div",{className:"flex gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:j.map(a=>(0,d.jsx)("button",{onClick:()=>n(a.value),className:`flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all ${m===a.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,children:a.label},a.value))})]}),(0,d.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,d.jsxs)("div",{className:"col-span-2",children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Host"}),(0,d.jsx)("input",{type:"text",value:o,onChange:a=>p(a.target.value),placeholder:"1.2.3.4 or proxy.example.com",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Port"}),(0,d.jsx)("input",{type:"text",value:q,onChange:a=>r(a.target.value),placeholder:M(m),className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("button",{onClick:()=>x(!w),className:"flex items-center gap-2 text-sm text-text-muted hover:text-text-primary transition-colors",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-base",children:w?"expand_less":"expand_more"}),"Authentication (optional)"]}),w&&(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Username"}),(0,d.jsx)("input",{type:"text",value:s,onChange:a=>t(a.target.value),placeholder:"Username",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1.5 block uppercase tracking-wider font-medium",children:"Password"}),(0,d.jsx)("input",{type:"password",value:u,onChange:a=>v(a.target.value),placeholder:"Password",className:"w-full px-3 py-2.5 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted/50 focus:outline-none focus:border-primary transition-colors"})]})]})]}),K&&(0,d.jsx)("div",{className:"px-4 py-3 rounded-lg border border-red-500/30 bg-red-500/10 text-sm text-red-400",children:K}),C&&(0,d.jsxs)("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border ${C.success?"bg-emerald-500/10 border-emerald-500/30":"bg-red-500/10 border-red-500/30"}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-xl ${C.success?"text-emerald-400":"text-red-400"}`,children:C.success?"check_circle":"error"}),(0,d.jsx)("div",{className:"flex-1",children:C.success?(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"text-sm font-medium text-emerald-400",children:"Connected"}),(0,d.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["IP: ",(0,d.jsx)("span",{className:"font-mono text-emerald-300",children:C.publicIp}),C.latencyMs&&` \xb7 ${C.latencyMs}ms`]})]}):(0,d.jsxs)("div",{className:"text-sm text-red-400",children:[C.error||"Connection failed",C.latencyMs&&(0,d.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["(",C.latencyMs,"ms)"]})]})})]}),(0,d.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-border",children:[(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(i.default,{size:"sm",variant:"secondary",icon:"speed",onClick:P,loading:A,disabled:!o.trim(),children:"Test Connection"}),I&&(0,d.jsx)(i.default,{size:"sm",variant:"ghost",icon:"delete",onClick:O,disabled:y,className:"!text-red-400 hover:!bg-red-500/10",children:"Clear"})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(i.default,{size:"sm",variant:"secondary",onClick:b,children:"Cancel"}),(0,d.jsx)(i.default,{size:"sm",icon:"save",onClick:N,loading:y,disabled:!o.trim(),children:"Save"})]})]})]})})}l.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,level:g().oneOf(["global","provider","combo","key"]).isRequired,levelId:g().string,levelLabel:g().string,onSaved:g().func}},59256:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(67484),f=c(31846);function g({label:a,options:b=[],value:c,onChange:g,placeholder:h="Select an option",error:i,hint:j,disabled:k=!1,required:l=!1,className:m,selectClassName:n,id:o,...p}){let q=(0,e.useId)(),r=o||q,s=i?`${r}-error`:void 0,t=j&&!i?`${r}-hint`:void 0,u=[s,t].filter(Boolean).join(" ")||void 0;return(0,d.jsxs)("div",{className:(0,f.cn)("flex flex-col gap-1.5",m),children:[a&&(0,d.jsxs)("label",{htmlFor:r,className:"text-sm font-medium text-text-main",children:[a,l&&(0,d.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsxs)("select",{id:r,value:c,onChange:g,disabled:k,required:l,"aria-required":l||void 0,"aria-invalid":!!i||void 0,"aria-describedby":u,className:(0,f.cn)("w-full py-2 px-3 pr-10 text-sm text-text-main","bg-surface border border-black/10 dark:border-white/10 rounded-md appearance-none","focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none","transition-all disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",i?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",n),...p,children:[(0,d.jsx)("option",{value:"",disabled:!0,className:"bg-surface text-text-muted",children:h}),b.map(a=>(0,d.jsx)("option",{value:a.value,className:"bg-surface text-text-main",children:a.label},a.value))]}),(0,d.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-text-muted","aria-hidden":"true",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"expand_more"})})]}),i&&(0,d.jsxs)("p",{id:s,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),i]}),j&&!i&&(0,d.jsx)("p",{id:t,className:"text-xs text-text-muted",children:j})]})}},59869:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(89132),f=c(31846);function g({className:a,variant:b="default"}){let{theme:c,toggleTheme:g,isDark:h}=(0,e.D)(),i={default:(0,f.cn)("flex items-center justify-center size-10 rounded-full","text-text-muted","hover:bg-black/5","hover:text-text-main","transition-colors"),card:(0,f.cn)("flex items-center justify-center size-11 rounded-full","bg-surface/60","hover:bg-surface","border border-border","backdrop-blur-md shadow-sm hover:shadow-md","text-text-muted-light hover:text-primary","hover:text-primary","transition-all group")};return(0,d.jsx)("button",{onClick:g,className:(0,f.cn)(i[b],a),"aria-label":`Switch to ${h?"light":"dark"} mode`,title:`Switch to ${h?"light":"dark"} mode`,children:(0,d.jsx)("span",{className:(0,f.cn)("material-symbols-outlined text-[22px]","card"===b&&"transition-transform duration-300 group-hover:rotate-12"),children:h?"light_mode":"dark_mode"})})}},62688:(a,b,c)=>{c.d(b,{default:()=>L});var d=c(48249),e=c(67484),f=c(2490),g=c(22746),h=c(17908),i=c(37627),j=c(83673),k=c(37930),l=c(22393),m=c(54206),n=c(40369),o=c(37538),p=c(20525),q=c(51831),r=c(73855),s=c(93237),t=c(21621),u=c(75829);function v({active:a,payload:b,label:c,formatter:e}){return a&&b?.length?(0,d.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[c&&(0,d.jsx)("div",{className:"font-semibold text-text-main mb-1",children:c}),b.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:a.color}}),(0,d.jsxs)("span",{children:[a.name,":"]}),(0,d.jsx)("span",{className:"font-mono font-medium text-text-main",children:e?e(a.value):a.value})]},b))]}):null}function w({active:a,sortOrder:b}){return a?(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"asc"===b?"expand_less":"expand_more"}):(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-0 group-hover:opacity-30",children:"unfold_more"})}function x({icon:a,label:b,value:c,subValue:e,color:g="text-text-main"}){return(0,d.jsxs)(f.default,{className:"px-4 py-3 flex flex-col gap-1",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted text-xs uppercase font-semibold tracking-wider",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:a}),b]}),(0,d.jsx)("span",{className:`text-2xl font-bold ${g}`,children:c}),e&&(0,d.jsx)("span",{className:"text-xs text-text-muted",children:e})]})}function y({activityMap:a}){let b=(0,e.useMemo)(()=>{let b=new Date,c=[],d=0;for(let e=364;e>=0;e--){let f=new Date(b);f.setDate(f.getDate()-e);let g=`${f.getFullYear()}-${String(f.getMonth()+1).padStart(2,"0")}-${String(f.getDate()).padStart(2,"0")}`,h=a?.[g]||0;h>d&&(d=h),c.push({date:g,value:h,dayOfWeek:f.getDay()})}return{days:c,maxVal:d}},[a]),c=(0,e.useMemo)(()=>{let a=[],c=[],d=b.days[0]?.dayOfWeek||0;for(let a=0;a<d;a++)c.push(null);for(let d of b.days)c.push(d),7===c.length&&(a.push(c),c=[]);return c.length>0&&a.push(c),a},[b]),g=(0,e.useMemo)(()=>{let a=[],b=-1;return c.forEach((c,d)=>{let e=c.find(a=>null!==a);if(e){let c=new Date(e.date).getMonth();c!==b&&(a.push({weekIdx:d,label:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c]}),b=c)}}),a},[c]);return(0,d.jsxs)(f.default,{className:"p-4 h-full",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Activity"}),(0,d.jsxs)("span",{className:"text-xs text-text-muted",children:[Object.keys(a||{}).length," active days \xb7"," ",(0,h.VK)(Object.values(a||{}).reduce((a,b)=>a+b,0))," tokens \xb7 365 days"]})]}),(0,d.jsx)("div",{className:"flex gap-[3px] mb-1 ml-6",style:{fontSize:"10px"},children:g.map((a,b)=>(0,d.jsx)("span",{className:"text-text-muted",style:{position:"relative",left:`${13*a.weekIdx}px`,marginLeft:0===b?0:"-20px"},children:a.label},b))}),(0,d.jsxs)("div",{className:"flex gap-[3px] overflow-x-auto",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-[3px] shrink-0 text-[10px] text-text-muted pr-1",children:[(0,d.jsx)("span",{className:"h-[10px]"}),(0,d.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Mon"}),(0,d.jsx)("span",{className:"h-[10px]"}),(0,d.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Wed"}),(0,d.jsx)("span",{className:"h-[10px]"}),(0,d.jsx)("span",{className:"h-[10px] leading-[10px]",children:"Fri"}),(0,d.jsx)("span",{className:"h-[10px]"})]}),c.map((a,c)=>(0,d.jsx)("div",{className:"flex flex-col gap-[3px]",children:a.map((a,c)=>(0,d.jsx)("div",{title:a?`${a.date}: ${(0,h.xW)(a.value)} tokens`:"",className:`w-[10px] h-[10px] rounded-[2px] ${a?function(a){if(!a||0===a)return"bg-white/[0.04]";let c=Math.min(a/(b.maxVal||1),1);return c<.25?"bg-primary/20":c<.5?"bg-primary/40":c<.75?"bg-primary/60":"bg-primary/90"}(a.value):"bg-transparent"}`},c))},c))]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 mt-2 ml-6 text-[10px] text-text-muted",children:[(0,d.jsx)("span",{children:"Less"}),(0,d.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-white/[0.04]"}),(0,d.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/20"}),(0,d.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/40"}),(0,d.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/60"}),(0,d.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/90"}),(0,d.jsx)("span",{children:"More"})]})]})}function z({dailyTrend:a}){let b=(0,e.useMemo)(()=>(a||[]).map(a=>({date:a.date.slice(5),Input:a.promptTokens,Output:a.completionTokens,Cost:a.cost||0})),[a]),c=(0,e.useMemo)(()=>b.some(a=>a.Cost>0),[b]);return b.length?(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token & Cost Trend"}),(0,d.jsx)(j.u,{width:"100%",height:140,children:(0,d.jsxs)(k.X,{data:b,margin:{top:0,right:40*!!c,left:0,bottom:0},children:[(0,d.jsx)(l.W,{dataKey:"date",tick:{fontSize:9,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:Math.max(Math.floor(b.length/6),0)}),c&&(0,d.jsx)(m.h,{yAxisId:"cost",orientation:"right",tick:{fontSize:8,fill:"#f59e0b"},axisLine:!1,tickLine:!1,tickFormatter:a=>`$${a.toFixed(2)}`,width:36}),(0,d.jsx)(n.m,{content:(0,d.jsx)(A,{}),cursor:{fill:"rgba(255,255,255,0.04)"}}),(0,d.jsx)(o.yP,{dataKey:"Input",stackId:"a",fill:"var(--primary)",opacity:.7,radius:[0,0,0,0],animationDuration:600}),(0,d.jsx)(o.yP,{dataKey:"Output",stackId:"a",fill:"#10b981",opacity:.7,radius:[3,3,0,0],animationDuration:600}),c&&(0,d.jsx)(p.N1,{yAxisId:"cost",type:"monotone",dataKey:"Cost",stroke:"#f59e0b",strokeWidth:2,dot:!1,animationDuration:600})]})}),(0,d.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-text-muted",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-primary/70"})," Input"]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500/70"})," Output"]}),c&&(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500/70"})," Cost ($)"]})]})]}):(0,d.jsxs)(f.default,{className:"p-4",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Token Trend"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function A({active:a,payload:b,label:c}){return a&&b?.length?(0,d.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[c&&(0,d.jsx)("div",{className:"font-semibold text-text-main mb-1",children:c}),b.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:a.color}}),(0,d.jsxs)("span",{children:[a.name,":"]}),(0,d.jsx)("span",{className:"font-mono font-medium text-text-main",children:"Cost"===a.name?(0,h.F0)(a.value):(0,h.VK)(a.value)})]},b))]}):null}function B({byAccount:a}){let b=(0,e.useMemo)(()=>a||[],[a]),c=b.length>0,g=(0,e.useMemo)(()=>b.slice(0,8).map((a,b)=>({name:a.account,value:a.totalTokens,fill:(0,i.ng)(b)})),[b]);return c?(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,d.jsxs)("div",{className:"flex items-center gap-4",children:[(0,d.jsx)(j.u,{width:120,height:120,children:(0,d.jsxs)(q.r,{children:[(0,d.jsx)(r.Fq,{data:g,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:g.map((a,b)=>(0,d.jsx)(s.f,{fill:a.fill,stroke:"none"},b))}),(0,d.jsx)(n.m,{content:(0,d.jsx)(v,{formatter:h.VK})})]})}),(0,d.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:g.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:a.fill}}),(0,d.jsx)("span",{className:"truncate text-text-main",children:a.name})]}),(0,d.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,h.VK)(a.value)})]},b))})]})]}):(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By Account"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function C({byApiKey:a}){let b=(0,e.useMemo)(()=>a||[],[a]),c=b.length>0,g=(0,e.useMemo)(()=>b.slice(0,8).map((a,b)=>({name:(0,h.VO)(a.apiKeyName,a.apiKeyId),fullName:a.apiKeyName||a.apiKeyId||"unknown",value:a.totalTokens,fill:(0,i.ng)(b)})),[b]);return c?(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,d.jsxs)("div",{className:"flex items-center gap-4",children:[(0,d.jsx)(j.u,{width:120,height:120,children:(0,d.jsxs)(q.r,{children:[(0,d.jsx)(r.Fq,{data:g,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:g.map((a,b)=>(0,d.jsx)(s.f,{fill:a.fill,stroke:"none"},b))}),(0,d.jsx)(n.m,{content:(0,d.jsx)(v,{formatter:h.VK})})]})}),(0,d.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:g.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:a.fill}}),(0,d.jsx)("span",{className:"truncate text-text-main",title:a.fullName,children:a.name})]}),(0,d.jsx)("span",{className:"font-mono font-medium text-text-muted shrink-0",children:(0,h.VK)(a.value)})]},`${a.fullName}-${b}`))})]})]}):(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"By API Key"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function D({byApiKey:a}){let[b,c]=(0,e.useState)(""),[g,i]=(0,e.useState)("totalTokens"),[j,k]=(0,e.useState)("desc"),l=(0,e.useMemo)(()=>a||[],[a]),m=(0,e.useMemo)(()=>{let a=b.trim().toLowerCase();return a?l.filter(b=>(b.apiKeyName||"").toLowerCase().includes(a)||(b.apiKeyId||"").toLowerCase().includes(a)):l},[l,b]),n=(0,e.useMemo)(()=>{let a=[...m];return a.sort((a,b)=>{let c=a[g]??0,d=b[g]??0;return"string"==typeof c?"asc"===j?c.localeCompare(d):d.localeCompare(c):"asc"===j?c-d:d-c}),a},[m,g,j]),o=(0,e.useCallback)(a=>{g===a?k(a=>"asc"===a?"desc":"asc"):(i(a),k("desc"))},[g]);return l.length>0?(0,d.jsxs)(f.default,{className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between gap-3",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"API Key Breakdown"}),(0,d.jsx)("input",{type:"text",value:b,onChange:a=>c(a.target.value),placeholder:"Filter API key...",className:"w-full max-w-[220px] px-3 py-1.5 rounded-lg bg-bg-subtle border border-border text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,d.jsxs)("tr",{children:[(0,d.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>o("apiKeyName"),children:["API Key ",(0,d.jsx)(w,{active:"apiKeyName"===g,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>o("requests"),children:["Requests ",(0,d.jsx)(w,{active:"requests"===g,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>o("promptTokens"),children:["Input ",(0,d.jsx)(w,{active:"promptTokens"===g,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>o("completionTokens"),children:["Output"," ",(0,d.jsx)(w,{active:"completionTokens"===g,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>o("totalTokens"),children:["Total Tokens"," ",(0,d.jsx)(w,{active:"totalTokens"===g,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>o("cost"),children:["Cost ",(0,d.jsx)(w,{active:"cost"===g,sortOrder:j})]})]})}),(0,d.jsxs)("tbody",{className:"divide-y divide-border",children:[n.map((a,b)=>(0,d.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,d.jsx)("td",{className:"px-4 py-2.5",children:(0,d.jsx)("span",{className:"font-medium",title:a.apiKeyName||a.apiKeyId||"unknown",children:(0,h.VO)(a.apiKeyName,a.apiKeyId)})}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,h.xW)(a.requests)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,h.VK)(a.promptTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,h.VK)(a.completionTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,h.VK)(a.totalTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,h.F0)(a.cost)})]},`${a.apiKeyId||a.apiKeyName||"key"}-${b}`)),0===n.length&&(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:6,className:"px-4 py-8 text-center text-text-muted",children:"No API key matches this filter."})})]})]})})]}):(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"API Key Breakdown"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function E({activityMap:a}){let b=(0,e.useMemo)(()=>{if(!a)return null;let b=new Date,c=null,d=0;for(let e=0;e<7;e++){let f=new Date(b);f.setDate(f.getDate()-e);let g=`${f.getFullYear()}-${String(f.getMonth()+1).padStart(2,"0")}-${String(f.getDate()).padStart(2,"0")}`,h=a[g]||0;h>d&&(d=h,c=g)}if(!c||0===d)return null;let e=new Date(c+"T12:00:00");return{weekday:["domingo","segunda","ter\xe7a","quarta","quinta","sexta","s\xe1bado"][e.getDay()],label:`${e.getDate()} de ${["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"][e.getMonth()]}`,tokens:d}},[a]);return(0,d.jsxs)(f.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,d.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"Most Active Day"}),b?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-xl font-bold capitalize",style:{lineHeight:1.2},children:b.weekday}),(0,d.jsxs)("span",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:[b.label," \xb7 ",(0,h.VK)(b.tokens)," tokens"]})]}):(0,d.jsx)("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Sem dados nos \xfaltimos 7 dias"})]})}function F({activityMap:a}){let b=(0,e.useMemo)(()=>{if(!a)return[];let b=new Date,c=[],d=0;for(let e=6;e>=0;e--){let f=new Date(b);f.setDate(f.getDate()-e);let g=`${f.getFullYear()}-${String(f.getMonth()+1).padStart(2,"0")}-${String(f.getDate()).padStart(2,"0")}`,h=a[g]||0;h>d&&(d=h);let i=["DOM","SEG","TER","QUA","QUI","SEX","S\xc1B"];c.push({key:g,val:h,label:i[f.getDay()]})}return c.map(a=>({...a,intensity:d>0?a.val/d:0}))},[a]);return(0,d.jsxs)(f.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,d.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Weekly"}),(0,d.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,justifyContent:"center"},children:b.map((a,b)=>{var c;return(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[(0,d.jsx)("div",{title:`${a.key}: ${(0,h.xW)(a.val)} tokens`,style:{width:36,height:36,borderRadius:8,...0===(c=a.intensity)?{background:"rgba(255,255,255,0.04)"}:{background:`rgba(229, 77, 94, ${(.15+.75*c).toFixed(2)})`},transition:"all 0.2s",cursor:"default"}}),(0,d.jsx)("span",{style:{fontSize:9,fontWeight:600,color:"var(--text-muted)",letterSpacing:"0.03em"},children:a.label})]},b)})})]})}function G({byModel:a,summary:b}){let[c,g]=(0,e.useState)("totalTokens"),[j,k]=(0,e.useState)("desc"),l=(0,e.useCallback)(a=>{c===a?k(a=>"asc"===a?"desc":"asc"):(g(a),k("desc"))},[c]),m=(0,e.useMemo)(()=>{let b=[...a||[]];return b.sort((a,b)=>{let d=a[c]??0,e=b[c]??0;return"string"==typeof d?"asc"===j?d.localeCompare(e):e.localeCompare(d):"asc"===j?d-e:e-d}),b},[a,c,j]);return(0,d.jsxs)(f.default,{className:"overflow-hidden",children:[(0,d.jsx)("div",{className:"p-4 border-b border-border",children:(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Model Breakdown"})}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,d.jsxs)("tr",{children:[(0,d.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>l("model"),children:["Model ",(0,d.jsx)(w,{active:"model"===c,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("requests"),children:["Requests ",(0,d.jsx)(w,{active:"requests"===c,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("promptTokens"),children:["Input ",(0,d.jsx)(w,{active:"promptTokens"===c,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("completionTokens"),children:["Output"," ",(0,d.jsx)(w,{active:"completionTokens"===c,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("totalTokens"),children:["Total ",(0,d.jsx)(w,{active:"totalTokens"===c,sortOrder:j})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("cost"),children:["Cost ",(0,d.jsx)(w,{active:"cost"===c,sortOrder:j})]}),(0,d.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border",children:m.map((a,b)=>(0,d.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,d.jsx)("td",{className:"px-4 py-2.5",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,i.ng)(b)}}),(0,d.jsx)("span",{className:"font-medium",children:a.model})]})}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,h.xW)(a.requests)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,h.VK)(a.promptTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,h.VK)(a.completionTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,h.VK)(a.totalTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,h.F0)(a.cost)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,d.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,d.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${a.pct}%`,backgroundColor:(0,i.ng)(b)}})}),(0,d.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[a.pct,"%"]})]})})]},a.model))})]})})]})}let H=["#f59e0b","#ef4444","#8b5cf6","#10b981","#06b6d4","#ec4899","#f97316","#6366f1","#14b8a6","#a855f7"];function I({byProvider:a}){let b=(0,e.useMemo)(()=>a||[],[a]),c=b.length>0&&b.some(a=>a.cost>0),g=(0,e.useMemo)(()=>b.filter(a=>a.cost>0).sort((a,b)=>b.cost-a.cost).slice(0,8).map((a,b)=>({name:a.provider,value:a.cost,fill:H[b%H.length]})),[b]);return c?(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,d.jsxs)("div",{className:"flex items-center gap-4",children:[(0,d.jsx)(j.u,{width:120,height:120,children:(0,d.jsxs)(q.r,{children:[(0,d.jsx)(r.Fq,{data:g,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:g.map((a,b)=>(0,d.jsx)(s.f,{fill:a.fill,stroke:"none"},b))}),(0,d.jsx)(n.m,{content:(0,d.jsx)(v,{formatter:h.F0})})]})}),(0,d.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:g.map((a,b)=>(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:a.fill}}),(0,d.jsx)("span",{className:"truncate text-text-main capitalize",children:a.name})]}),(0,d.jsx)("span",{className:"font-mono font-medium text-amber-500 shrink-0",children:(0,h.F0)(a.value)})]},b))})]})]}):(0,d.jsxs)(f.default,{className:"p-4 flex-1",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Cost by Provider"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No cost data"})]})}function J({dailyByModel:a,modelNames:b}){let c=(0,e.useMemo)(()=>a||[],[a]),g=(0,e.useMemo)(()=>b||[],[b]),k=(0,e.useMemo)(()=>c.map(a=>{let b={...a};if(a.date){let c=a.date.split("-");b.dateLabel=`${c[1]}/${c[2]}`}return b}),[c]);return c.length&&g.length?(0,d.jsxs)(f.default,{className:"p-4",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,d.jsx)(j.u,{width:"100%",height:240,children:(0,d.jsxs)(t.Q,{data:k,margin:{top:4,right:4,left:0,bottom:0},children:[(0,d.jsx)(l.W,{dataKey:"dateLabel",tick:{fontSize:10,fill:"var(--text-muted)"},axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),(0,d.jsx)(m.h,{tick:{fontSize:10,fill:"var(--text-muted)"},tickFormatter:a=>(0,h.VK)(a),axisLine:!1,tickLine:!1,width:50}),(0,d.jsx)(n.m,{content:(0,d.jsx)(v,{formatter:h.VK})}),g.map((a,b)=>(0,d.jsx)(u.Gk,{type:"monotone",dataKey:a,stackId:"1",stroke:(0,i.ng)(b),fill:(0,i.ng)(b),fillOpacity:.4,strokeWidth:1.5,animationDuration:600},a))]})}),(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 text-[10px] text-text-muted",children:g.map((a,b)=>(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,i.ng)(b)}}),a]},a))})]}):(0,d.jsxs)(f.default,{className:"p-4",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Model Usage Over Time"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function K({byProvider:a}){let[b,c]=(0,e.useState)("totalTokens"),[g,i]=(0,e.useState)("desc"),j=(0,e.useMemo)(()=>a||[],[a]),k=(0,e.useMemo)(()=>j.reduce((a,b)=>a+b.totalTokens,0),[j]),l=(0,e.useCallback)(a=>{b===a?i(a=>"asc"===a?"desc":"asc"):(c(a),i("desc"))},[b]),m=(0,e.useMemo)(()=>{let a=[...j];return a.sort((a,c)=>{let d=a[b]??0,e=c[b]??0;return"string"==typeof d?"asc"===g?d.localeCompare(e):e.localeCompare(d):"asc"===g?d-e:e-d}),a},[j,b,g]);return j.length?(0,d.jsxs)(f.default,{className:"overflow-hidden",children:[(0,d.jsx)("div",{className:"p-4 border-b border-border",children:(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Provider Breakdown"})}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,d.jsxs)("tr",{children:[(0,d.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>l("provider"),children:["Provider ",(0,d.jsx)(w,{active:"provider"===b,sortOrder:g})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("requests"),children:["Requests ",(0,d.jsx)(w,{active:"requests"===b,sortOrder:g})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("promptTokens"),children:["Input ",(0,d.jsx)(w,{active:"promptTokens"===b,sortOrder:g})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("completionTokens"),children:["Output"," ",(0,d.jsx)(w,{active:"completionTokens"===b,sortOrder:g})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("totalTokens"),children:["Total ",(0,d.jsx)(w,{active:"totalTokens"===b,sortOrder:g})]}),(0,d.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>l("cost"),children:["Cost ",(0,d.jsx)(w,{active:"cost"===b,sortOrder:g})]}),(0,d.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:"Share"})]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border",children:m.map((a,b)=>{let c=k>0?(a.totalTokens/k*100).toFixed(1):"0";return(0,d.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,d.jsx)("td",{className:"px-4 py-2.5",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:H[b%H.length]}}),(0,d.jsx)("span",{className:"font-medium capitalize",children:a.provider})]})}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,h.xW)(a.requests)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,h.VK)(a.promptTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,h.VK)(a.completionTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,h.VK)(a.totalTokens)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,h.F0)(a.cost)}),(0,d.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,d.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,d.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${c}%`,backgroundColor:H[b%H.length]}})}),(0,d.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[c,"%"]})]})})]},a.provider)})})]})})]}):(0,d.jsxs)(f.default,{className:"p-4",children:[(0,d.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:"Provider Breakdown"}),(0,d.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No data"})]})}function L(){let[a,b]=(0,e.useState)("30d"),[c,i]=(0,e.useState)(null),[j,k]=(0,e.useState)(!0),[l,m]=(0,e.useState)(null);(0,e.useCallback)(async()=>{try{k(!0);let b=await fetch(`/api/usage/analytics?range=${a}`);if(!b.ok)throw Error("Failed to fetch");let c=await b.json();i(c),m(null)}catch(a){m(a.message)}finally{k(!1)}},[a]);let n=(0,e.useMemo)(()=>{let a=c?.byModel||[];return a.length>0?a[0].model:"—"},[c]),o=(0,e.useMemo)(()=>{let a=c?.byProvider||[];return a.length>0?a[0].provider:"—"},[c]),p=(0,e.useMemo)(()=>{let a=c?.weeklyPattern||[];if(!a.length)return"—";let b=a.reduce((a,b)=>a.avgTokens>b.avgTokens?a:b,a[0]);return b.avgTokens>0?b.day:"—"},[c]),q=(0,e.useMemo)(()=>(c?.byProvider||[]).length,[c]);if(j&&!c)return(0,d.jsx)(g.CardSkeleton,{});if(l)return(0,d.jsxs)(f.default,{className:"p-6 text-center text-red-500",children:["Error: ",l]});let r=c?.summary||{},s=r.totalRequests>0?Math.round(r.totalTokens/r.totalRequests):0,t=r.totalRequests>0?r.totalCost/r.totalRequests:0,u=r.completionTokens>0?(r.promptTokens/r.completionTokens).toFixed(1):"—";return(0,d.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-primary text-[22px]",children:"analytics"}),"Usage Analytics"]}),(0,d.jsx)("div",{className:"flex items-center gap-1 bg-black/[0.03] dark:bg-white/[0.03] rounded-lg p-1 border border-black/5 dark:border-white/5",children:[{value:"1d",label:"1D"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"90d",label:"90D"},{value:"ytd",label:"YTD"},{value:"all",label:"All"}].map(c=>(0,d.jsx)("button",{onClick:()=>b(c.value),className:`px-3 py-1 rounded-md text-xs font-semibold transition-all ${a===c.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:c.label},c.value))})]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-7 gap-3",children:[(0,d.jsx)(x,{icon:"generating_tokens",label:"Total Tokens",value:(0,h.VK)(r.totalTokens),subValue:`${(0,h.xW)(r.totalRequests)} requests`}),(0,d.jsx)(x,{icon:"input",label:"Input Tokens",value:(0,h.VK)(r.promptTokens),color:"text-primary"}),(0,d.jsx)(x,{icon:"output",label:"Output Tokens",value:(0,h.VK)(r.completionTokens),color:"text-emerald-500"}),(0,d.jsx)(x,{icon:"payments",label:"Est. Cost",value:(0,h.F0)(r.totalCost),color:"text-amber-500"}),(0,d.jsx)(x,{icon:"group",label:"Accounts",value:r.uniqueAccounts||0}),(0,d.jsx)(x,{icon:"vpn_key",label:"API Keys",value:r.uniqueApiKeys||0}),(0,d.jsx)(x,{icon:"model_training",label:"Models",value:r.uniqueModels||0})]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-7 gap-3",children:[(0,d.jsx)(x,{icon:"speed",label:"Avg Tokens/Req",value:(0,h.VK)(s),color:"text-cyan-500"}),(0,d.jsx)(x,{icon:"request_quote",label:"Cost/Request",value:(0,h.F0)(t),color:"text-orange-500"}),(0,d.jsx)(x,{icon:"compare_arrows",label:"I/O Ratio",value:`${u}x`,color:"text-violet-500"}),(0,d.jsx)(x,{icon:"star",label:"Top Model",value:n,color:"text-pink-500"}),(0,d.jsx)(x,{icon:"cloud",label:"Top Provider",value:o,color:"text-teal-500"}),(0,d.jsx)(x,{icon:"today",label:"Busiest Day",value:p,color:"text-rose-500"}),(0,d.jsx)(x,{icon:"dns",label:"Providers",value:q,color:"text-indigo-500"})]}),(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:16,alignItems:"stretch"},children:[(0,d.jsx)(y,{activityMap:c?.activityMap}),(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,d.jsx)(E,{activityMap:c?.activityMap}),(0,d.jsx)(F,{activityMap:c?.activityMap})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,d.jsx)(z,{dailyTrend:c?.dailyTrend}),(0,d.jsx)(I,{byProvider:c?.byProvider})]}),(0,d.jsx)(J,{dailyByModel:c?.dailyByModel,modelNames:c?.modelNames}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,d.jsx)(B,{byAccount:c?.byAccount}),(0,d.jsx)(C,{byApiKey:c?.byApiKey})]}),(0,d.jsx)(K,{byProvider:c?.byProvider}),(0,d.jsx)(D,{byApiKey:c?.byApiKey}),(0,d.jsx)(G,{byModel:c?.byModel,summary:r})]})}},65472:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(31846);function f({checked:a=!1,onChange:b,label:c,description:f,disabled:g=!1,size:h="md",className:i}){let j={sm:{track:"w-8 h-4",thumb:"size-3",translate:"translate-x-4"},md:{track:"w-11 h-6",thumb:"size-5",translate:"translate-x-5"},lg:{track:"w-14 h-7",thumb:"size-6",translate:"translate-x-7"}};return(0,d.jsxs)("div",{className:(0,e.cn)("flex items-center gap-3",g&&"opacity-50 cursor-not-allowed",i),children:[(0,d.jsx)("button",{type:"button",role:"switch","aria-checked":a,"aria-label":c?void 0:f||"Toggle",disabled:g,onClick:()=>{!g&&b&&b(!a)},className:(0,e.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-1 focus:ring-primary/30",a?"bg-primary":"bg-black/10 dark:bg-white/20",j[h].track,g&&"cursor-not-allowed"),children:(0,d.jsx)("span",{"aria-hidden":"true",className:(0,e.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",a?j[h].translate:"translate-x-0.5",j[h].thumb,"mt-0.5")})}),(c||f)&&(0,d.jsxs)("div",{className:"flex flex-col",children:[c&&(0,d.jsx)("span",{className:"text-sm font-medium text-text-main",children:c}),f&&(0,d.jsx)("span",{className:"text-xs text-text-muted",children:f})]})]})}},65892:(a,b,c)=>{c.d(b,{default:()=>w});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(2116),i=c.n(h),j=c(19099),k=c(31846),l=c(73959),m=c(75033),n=c(53156),o=c(65953);let p={connected:{icon:"cloud_done",color:"text-green-500",label:"Cloud"},syncing:{icon:"cloud_sync",color:"text-blue-400 animate-pulse",label:"Syncing..."},disconnected:{icon:"cloud_off",color:"text-amber-500",label:"Cloud Off"},error:{icon:"cloud_off",color:"text-red-400",label:"Cloud Error"},disabled:{icon:"cloud_off",color:"text-text-muted/50",label:"Disabled"}};function q({collapsed:a=!1}){let[b,c]=(0,e.useState)("disabled"),[f,g]=(0,e.useState)(null),h=(0,e.useRef)(!0),i=(0,j.useRouter)();if((0,e.useCallback)(async()=>{try{let a=await fetch("/api/sync/cloud");if(!h.current)return;if(!a.ok)return void c("disconnected");let b=await a.json();if(!h.current)return;b.enabled?b.syncing?c("syncing"):b.connected?(c("connected"),b.lastSync&&g(new Date(b.lastSync))):c("disconnected"):c("disabled")}catch{h.current&&c("disconnected")}},[]),"disabled"===b)return null;let k=p[b];return(0,d.jsxs)("button",{onClick:()=>i.push("/dashboard/endpoint"),className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg hover:bg-white/5 transition-colors cursor-pointer w-full",title:f?`Cloud ${"connected"===b?"connected":"disconnected"} — Last sync: ${f.toLocaleTimeString()}`:k.label,"aria-label":`Cloud sync status: ${k.label}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[16px] ${k.color}`,"aria-hidden":"true",children:k.icon}),!a&&(0,d.jsx)("span",{className:`truncate ${"connected"===b?"text-green-500":"text-text-muted"}`,children:k.label})]})}var r=c(77360);let s=[{href:"/dashboard",i18nKey:"home",icon:"home",exact:!0},{href:"/dashboard/endpoint",i18nKey:"endpoint",icon:"api"},{href:"/dashboard/api-manager",i18nKey:"apiManager",icon:"vpn_key"},{href:"/dashboard/providers",i18nKey:"providers",icon:"dns"},{href:"/dashboard/combos",i18nKey:"combos",icon:"layers"},{href:"/dashboard/logs",i18nKey:"logs",icon:"description"},{href:"/dashboard/costs",i18nKey:"costs",icon:"account_balance_wallet"},{href:"/dashboard/analytics",i18nKey:"analytics",icon:"analytics"},{href:"/dashboard/limits",i18nKey:"limits",icon:"tune"},{href:"/dashboard/health",i18nKey:"health",icon:"health_and_safety"},{href:"/dashboard/cli-tools",i18nKey:"cliTools",icon:"terminal"},{href:"/dashboard/media",i18nKey:"media",icon:"auto_awesome"}],t=[{href:"/dashboard/translator",i18nKey:"translator",icon:"translate"}],u=[{href:"/dashboard/settings",i18nKey:"settings",icon:"settings"}],v=[{href:"/docs",i18nKey:"docs",icon:"menu_book"},{href:"https://github.com/diegosouzapw/OmniRoute/issues",i18nKey:"issues",icon:"bug_report",external:!0}];function w({onClose:a,collapsed:b=!1,onToggleCollapse:c}){let f=(0,j.usePathname)(),g=(0,r.c)("sidebar"),h=(0,r.c)("common"),[p,w]=(0,e.useState)(!1),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)(!1),H=async()=>{A(!0);try{await fetch("/api/shutdown",{method:"POST"})}catch(a){}A(!1),w(!1),E(!0)},I=async()=>{C(!0);try{await fetch("/api/restart",{method:"POST"})}catch(a){}C(!1),y(!1),E(!0),setTimeout(()=>{globalThis.location.reload()},3e3)},J=a=>a.map(a=>({...a,label:g(a.i18nKey)})),K=J(s),L=J(t),M=J(u),N=J(v),O=c=>{var e;let g=!c.external&&(e=c.href,c.exact?f===e:f.startsWith(e)),h=(0,k.cn)("flex items-center gap-3 rounded-lg transition-all group",b?"justify-center px-2 py-2.5":"px-4 py-2",g?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),j=(0,k.cn)("material-symbols-outlined text-[18px]",g?"fill-1":"group-hover:text-primary transition-colors"),l=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:j,children:c.icon}),!b&&(0,d.jsx)("span",{className:"text-sm font-medium",children:c.label})]});return c.external?(0,d.jsx)("a",{href:c.href,target:"_blank",rel:"noopener noreferrer",onClick:a,title:b?c.label:void 0,className:h,children:l},c.href):(0,d.jsx)(i(),{href:c.href,onClick:a,title:b?c.label:void 0,className:h,children:l},c.href)};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("aside",{className:(0,k.cn)("flex flex-col border-r border-black/5 dark:border-white/5 bg-vibrancy backdrop-blur-xl transition-all duration-300 ease-in-out",b?"w-16":"w-72"),children:[(0,d.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:absolute focus:z-50 focus:p-3 focus:bg-primary focus:text-white focus:rounded-md focus:m-2",children:"Skip to content"}),(0,d.jsxs)("div",{className:(0,k.cn)("flex items-center gap-2 pt-5 pb-2",b?"px-3 justify-center":"px-6"),"aria-hidden":"true",children:[(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"}),!b&&(0,d.jsx)("div",{className:"flex-1"}),c&&(0,d.jsx)("button",{onClick:c,title:b?"Expand sidebar":"Collapse sidebar","aria-expanded":!b,"aria-label":b?"Expand sidebar":"Collapse sidebar",className:(0,k.cn)("p-1 rounded-md text-text-muted/50 hover:text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",b&&"mt-2"),children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:b?"chevron_right":"chevron_left"})})]}),(0,d.jsx)("div",{className:(0,k.cn)("py-4",b?"px-2":"px-6"),children:(0,d.jsxs)(i(),{href:"/dashboard",className:(0,k.cn)("flex items-center",b?"justify-center":"gap-3"),children:[(0,d.jsx)("div",{className:"flex items-center justify-center size-9 rounded bg-linear-to-br from-[#E54D5E] to-[#C93D4E] shrink-0",children:(0,d.jsx)(m.A,{size:20,className:"text-white"})}),!b&&(0,d.jsxs)("div",{className:"flex flex-col",children:[(0,d.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:l.vQ.name}),(0,d.jsxs)("span",{className:"text-xs text-text-muted",children:["v",l.vQ.version]})]})]})}),(0,d.jsxs)("nav",{"aria-label":"Main navigation",className:(0,k.cn)("flex-1 py-2 space-y-1 overflow-y-auto custom-scrollbar",b?"px-2":"px-4"),children:[K.map(O),F&&(0,d.jsxs)("div",{className:"pt-4 mt-2",children:[!b&&(0,d.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"Debug"}),b&&(0,d.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),L.map(O)]}),(0,d.jsxs)("div",{className:"pt-4 mt-2",children:[!b&&(0,d.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"System"}),b&&(0,d.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),M.map(O)]}),(0,d.jsxs)("div",{className:"pt-4 mt-2",children:[!b&&(0,d.jsx)("p",{className:"px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",children:"Help"}),b&&(0,d.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 mb-2"}),N.map(O)]})]}),(0,d.jsx)(q,{collapsed:b}),(0,d.jsxs)("div",{className:(0,k.cn)("border-t border-black/5 dark:border-white/5",b?"p-2 flex flex-col gap-1":"p-3 flex gap-2"),children:[(0,d.jsxs)("button",{onClick:()=>y(!0),title:g("restart"),className:(0,k.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-amber-500 hover:bg-amber-500/10 border border-amber-500/20 hover:border-amber-500/40",b?"p-2":"flex-1 px-3 py-2 text-sm"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"restart_alt"}),!b&&g("restart")]}),(0,d.jsxs)("button",{onClick:()=>w(!0),title:g("shutdown"),className:(0,k.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-red-500 hover:bg-red-500/10 border border-red-500/20 hover:border-red-500/40",b?"p-2":"flex-1 px-3 py-2 text-sm"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"power_settings_new"}),!b&&g("shutdown")]})]})]}),(0,d.jsx)(o.ConfirmModal,{isOpen:p,onClose:()=>w(!1),onConfirm:H,title:g("shutdown"),message:g("shutdownConfirm"),confirmText:g("shutdown"),cancelText:h("cancel"),variant:"danger",loading:z}),(0,d.jsx)(o.ConfirmModal,{isOpen:x,onClose:()=>y(!1),onConfirm:I,title:g("restart"),message:g("restartConfirm"),confirmText:g("restart"),cancelText:h("cancel"),variant:"warning",loading:B}),D&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,d.jsxs)("div",{className:"text-center p-8",children:[(0,d.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,d.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,d.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped or is restarting."}),(0,d.jsx)(n.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}w.propTypes={onClose:g().func,collapsed:g().bool,onToggleCollapse:g().func}},65953:(a,b,c)=>{c.d(b,{ConfirmModal:()=>i,default:()=>h});var d=c(48249),e=c(67484),f=c(31846),g=c(53156);function h({isOpen:a,onClose:b,title:c,children:g,footer:h,size:i="md",closeOnOverlay:j=!0,showCloseButton:k=!0,className:l}){let m=(0,e.useId)(),n=(0,e.useRef)(null);return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:j?b:void 0,"aria-hidden":"true"}),(0,d.jsxs)("div",{ref:n,role:"dialog","aria-modal":"true","aria-labelledby":c?m:void 0,className:(0,f.cn)("relative w-full bg-surface","border border-black/10 dark:border-white/10","rounded-xl shadow-2xl","animate-in fade-in zoom-in-95 duration-200",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[i],l),children:[(c||k)&&(0,d.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-black/5 dark:border-white/5",children:[(0,d.jsxs)("div",{className:"flex items-center",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mr-4","aria-hidden":"true",children:[(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),c&&(0,d.jsx)("h2",{id:m,className:"text-lg font-semibold text-text-main",children:c})]}),k&&(0,d.jsx)("button",{onClick:b,"aria-label":"Close",className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"close"})})]}),(0,d.jsx)("div",{className:"p-6 max-h-[calc(80vh-140px)] overflow-y-auto",children:g}),h&&(0,d.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-black/5 dark:border-white/5",children:h})]})]}):null}function i({isOpen:a,onClose:b,onConfirm:c,title:e="Confirm",message:f,confirmText:i="Confirm",cancelText:j="Cancel",variant:k="danger",loading:l=!1}){return(0,d.jsx)(h,{isOpen:a,onClose:b,title:e,size:"sm",footer:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.default,{variant:"ghost",onClick:b,disabled:l,children:j}),(0,d.jsx)(g.default,{variant:k,onClick:c,loading:l,children:i})]}),children:(0,d.jsx)("p",{className:"text-text-muted",children:f})})}},67083:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(67484);function f({searchValue:a="",onSearchChange:b,placeholder:c="Search...",filters:f=[],activeFilters:g={},onFilterChange:h,children:i}){let[j,k]=(0,e.useState)(null),l=(0,e.useCallback)(()=>{b(""),f.forEach(a=>h(a.key,"")),k(null)},[b,f,h]),m=a||Object.values(g).some(a=>a&&""!==a);return(0,d.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",padding:"8px 0"},children:[(0,d.jsxs)("div",{style:{position:"relative",flex:"1 1 200px",minWidth:"200px"},children:[(0,d.jsx)("input",{type:"text",value:a,onChange:a=>b(a.target.value),placeholder:c,style:{width:"100%",padding:"8px 12px 8px 32px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-primary, #e0e0e0)",fontSize:"13px",outline:"none"}}),(0,d.jsx)("span",{style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",opacity:.4,fontSize:"14px",pointerEvents:"none"},children:"\uD83D\uDD0D"})]}),f.map(a=>(0,d.jsxs)("div",{style:{position:"relative"},children:[(0,d.jsxs)("button",{onClick:()=>k(j===a.key?null:a.key),style:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${g[a.key]?"rgba(99,102,241,0.5)":"rgba(255,255,255,0.1)"}`,background:g[a.key]?"rgba(99,102,241,0.15)":"rgba(255,255,255,0.05)",color:g[a.key]?"#818cf8":"var(--text-secondary, #888)",fontSize:"12px",cursor:"pointer",whiteSpace:"nowrap"},children:[a.label,g[a.key]?` \xb7 ${g[a.key]}`:""]}),j===a.key&&(0,d.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"4px",zIndex:50,minWidth:"120px",backdropFilter:"blur(12px)"},children:[(0,d.jsx)("button",{onClick:()=>{h(a.key,""),k(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:"none",border:"none",color:"#888",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:"All"}),(a.options||[]).map(b=>(0,d.jsx)("button",{onClick:()=>{h(a.key,b),k(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:g[a.key]===b?"rgba(99,102,241,0.2)":"none",border:"none",color:g[a.key]===b?"#818cf8":"var(--text-primary, #e0e0e0)",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:b},b))]})]},a.key)),m&&(0,d.jsx)("button",{onClick:l,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid rgba(239,68,68,0.3)",background:"rgba(239,68,68,0.1)",color:"#ef4444",fontSize:"12px",cursor:"pointer"},children:"Clear"}),i]})}},73295:(a,b,c)=>{c.d(b,{C:()=>f});var d=c(67484);function e(a){let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.left="-9999px",b.style.top="-9999px",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select();try{document.execCommand("copy")}catch{}document.body.removeChild(b)}function f(a=2e3){let[b,c]=(0,d.useState)(null),g=(0,d.useRef)(null);return{copied:b,copy:(0,d.useCallback)(async(b,d="default")=>{try{navigator.clipboard&&window.isSecureContext?await navigator.clipboard.writeText(b):e(b)}catch{e(b)}c(d),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{c(null)},a)},[a])}}},73979:(a,b,c)=>{c.d(b,{default:()=>m});var d=c(48249),e=c(67484),f=c(2490),g=c(37627),h=c(17908);function i({log:a,onClose:b}){let c=(0,g.Yh)(a.status),e=g.Gp[a.proxy?.type]||{bg:"#6B7280",text:"#fff",label:a.proxy?.type||"-"},f=g.Ie[a.level]||g.Ie.direct,i=g.RY[a.provider]||{bg:"#374151",text:"#fff",label:(a.provider||"-").toUpperCase()};return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[5vh]",onClick:b,role:"dialog","aria-modal":"true","aria-label":"Proxy log detail",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,d.jsxs)("div",{className:"relative bg-bg-primary border border-border rounded-xl w-full max-w-[700px] max-h-[90vh] overflow-y-auto shadow-2xl",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-6 py-4 border-b border-border bg-bg-primary/95 backdrop-blur-sm rounded-t-xl",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-xs font-bold uppercase",style:{backgroundColor:c.bg,color:c.text},children:a.status}),(0,d.jsx)("span",{className:"font-bold text-lg",children:"Proxy Event"})]}),(0,d.jsx)("button",{onClick:b,className:"p-1.5 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors","aria-label":"Close proxy detail modal",children:(0,d.jsx)("span",{className:"material-symbols-outlined",children:"close"})})]}),(0,d.jsxs)("div",{className:"p-6 flex flex-col gap-6",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 p-4 bg-bg-subtle rounded-xl border border-border",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Time"}),(0,d.jsx)("div",{className:"text-sm font-medium",children:(a=>{try{let b=new Date(a);return b.toLocaleDateString("pt-BR")+", "+b.toLocaleTimeString("en-US",{hour12:!1})}catch{return a}})(a.timestamp)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Latency"}),(0,d.jsx)("div",{className:"text-sm font-medium",children:(0,h.a3)(a.latencyMs)})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Public IP"}),(0,d.jsx)("div",{className:"text-sm font-medium font-mono text-emerald-400",children:a.publicIp||"—"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Proxy"}),(0,d.jsx)("div",{className:"text-sm font-medium font-mono text-primary",children:a.proxy?`${a.proxy.type}://${a.proxy.host}:${a.proxy.port}`:"Direct"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Type"}),(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:e.bg,color:e.text},children:e.label})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Level"}),(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:f.bg,color:f.text},children:f.label})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Provider"}),a.provider?(0,d.jsx)("span",{className:"inline-block px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:i.bg,color:i.text},children:i.label}):(0,d.jsx)("div",{className:"text-sm text-text-muted",children:"—"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"TLS Fingerprint"}),a.tlsFingerprint?(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded text-[10px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},children:[(0,d.jsx)("span",{style:{fontSize:"12px"},children:"\uD83D\uDD12"})," Chrome 124"]}):(0,d.jsx)("div",{className:"text-sm text-text-muted",children:"Direct (native)"})]}),(0,d.jsxs)("div",{className:"col-span-2",children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-1",children:"Target URL"}),(0,d.jsx)("div",{className:"text-sm font-medium font-mono text-text-muted break-all",children:a.targetUrl||"—"})]})]}),a.error&&(0,d.jsxs)("div",{className:"p-4 rounded-xl bg-red-500/10 border border-red-500/30",children:[(0,d.jsx)("div",{className:"text-[10px] text-red-400 uppercase tracking-wider mb-1 font-bold",children:"Error"}),(0,d.jsx)("div",{className:"text-sm text-red-300 font-mono",children:a.error})]}),a.proxy&&(0,d.jsxs)("div",{className:"p-4 rounded-xl bg-bg-subtle border border-border",children:[(0,d.jsx)("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mb-2 font-bold",children:"Proxy Configuration"}),(0,d.jsx)("pre",{className:"text-xs font-mono text-text-primary bg-black/20 rounded-lg p-3 overflow-x-auto",children:JSON.stringify(a.proxy,null,2)})]})]})]})]})}let j=[{key:"all",label:"All"},{key:"error",label:"Errors",icon:"error"},{key:"ok",label:"Success",icon:"check_circle"},{key:"timeout",label:"Timeout",icon:"timer_off"}],k=[{key:"status",label:"Status"},{key:"proxy",label:"Proxy"},{key:"tls",label:"TLS"},{key:"type",label:"Type"},{key:"level",label:"Level"},{key:"provider",label:"Provider"},{key:"target",label:"Target"},{key:"latency",label:"Latency"},{key:"ip",label:"Public IP"},{key:"time",label:"Time"}],l=Object.fromEntries(k.map(a=>[a.key,!0]));function m(){let[a,b]=(0,e.useState)([]),[c,m]=(0,e.useState)(!0),[n,o]=(0,e.useState)(!0),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)("all"),[t,u]=(0,e.useState)(""),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)(""),[z,A]=(0,e.useState)("newest"),[B,C]=(0,e.useState)(null);(0,e.useRef)(null),(0,e.useRef)(!1);let[D,E]=(0,e.useState)(()=>l),F=(0,e.useCallback)(a=>{E(b=>{let c={...b,[a]:!b[a]};try{localStorage.setItem("proxyLoggerVisibleColumns",JSON.stringify(c))}catch{}return c})},[]),G=(0,e.useCallback)(async(a=!1)=>{a&&m(!0);try{let a=new URLSearchParams;p&&a.set("search",p),"error"===r&&a.set("status","error"),"ok"===r&&a.set("status","ok"),"timeout"===r&&a.set("status","timeout"),t&&a.set("type",t),v&&a.set("provider",v),x&&a.set("level",x),a.set("limit","300");let c=await fetch(`/api/usage/proxy-logs?${a}`);if(c.ok){let a=await c.json();b(a)}}catch(a){console.error("Failed to fetch proxy logs:",a)}finally{a&&m(!1)}},[p,r,t,v,x]),H=(0,e.useMemo)(()=>{let b=[...a];return b.sort((a,b)=>{switch(z){case"oldest":return new Date(a.timestamp).getTime()-new Date(b.timestamp).getTime();case"latency_desc":return(b.latencyMs||0)-(a.latencyMs||0);case"latency_asc":return(a.latencyMs||0)-(b.latencyMs||0);default:return new Date(b.timestamp).getTime()-new Date(a.timestamp).getTime()}}),b},[a,z]),I=[...new Set(a.map(a=>a.provider).filter(Boolean))].sort(),J=[...new Set(a.map(a=>a.proxy?.type).filter(Boolean))].sort(),K=[...new Set(a.map(a=>a.level).filter(Boolean))].sort(),L=a.length,M=a.filter(a=>"success"===a.status).length,N=a.filter(a=>"error"===a.status).length,O=a.filter(a=>"timeout"===a.status).length,P=a.filter(a=>"direct"===a.level).length,Q=a.filter(a=>a.tlsFingerprint).length;return(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,d.jsxs)("button",{onClick:()=>o(!n),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${n?"bg-red-500/10 border-red-500/30 text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,d.jsx)("span",{className:`w-2 h-2 rounded-full ${n?"bg-red-500 animate-pulse":"bg-text-muted"}`}),n?"Recording":"Paused"]}),(0,d.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,d.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,d.jsx)("input",{type:"text",placeholder:"Search host, provider, target, IP...",value:p,onChange:a=>q(a.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,d.jsxs)("select",{value:t,onChange:a=>u(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,d.jsx)("option",{value:"",children:"All Types"}),J.map(a=>(0,d.jsx)("option",{value:a,children:(g.Gp[a]?.label||a).toUpperCase()},a))]}),(0,d.jsxs)("select",{value:x,onChange:a=>y(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[120px]",children:[(0,d.jsx)("option",{value:"",children:"All Levels"}),K.map(a=>(0,d.jsx)("option",{value:a,children:g.Ie[a]?.label||a},a))]}),(0,d.jsxs)("select",{value:v,onChange:a=>w(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,d.jsx)("option",{value:"",children:"All Providers"}),I.map(a=>{let b=g.RY[a];return(0,d.jsx)("option",{value:a,children:b?.label||a.toUpperCase()},a)})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[L," total"]}),(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 font-mono",children:[M," OK"]}),N>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-400 font-mono",children:[N," ERR"]}),O>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-amber-500/10 text-amber-400 font-mono",children:[O," TMO"]}),P>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-gray-500/10 text-gray-400 font-mono",children:[P," direct"]}),Q>0&&(0,d.jsxs)("span",{className:"px-2 py-1 rounded bg-cyan-500/10 text-cyan-400 font-mono",children:["\uD83D\uDD12 ",Q," TLS"]})]}),(0,d.jsxs)("select",{value:z,onChange:a=>A(a.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,d.jsx)("option",{value:"newest",children:"Newest"}),(0,d.jsx)("option",{value:"oldest",children:"Oldest"}),(0,d.jsx)("option",{value:"latency_desc",children:"Latency ↓"}),(0,d.jsx)("option",{value:"latency_asc",children:"Latency ↑"})]}),(0,d.jsx)("button",{onClick:()=>G(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:"Refresh",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[j.map(a=>(0,d.jsxs)("button",{onClick:()=>s(r===a.key?"all":a.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${r===a.key?"error"===a.key?"bg-red-500/20 text-red-400 border-red-500/40":"ok"===a.key?"bg-emerald-500/20 text-emerald-400 border-emerald-500/40":"timeout"===a.key?"bg-amber-500/20 text-amber-400 border-amber-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[a.icon&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:a.icon}),a.label]},a.key)),I.length>0&&(0,d.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),I.map(a=>{let b=g.RY[a]||{bg:"#374151",text:"#fff",label:a.toUpperCase()},c=v===a;return(0,d.jsx)("button",{onClick:()=>w(c?"":a),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${c?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:c?b.bg:`${b.bg}33`,color:c?b.text:b.bg},children:b.label},a)})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,d.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:"Columns"}),k.map(a=>(0,d.jsx)("button",{onClick:()=>F(a.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${D[a.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:a.label},a.key))]}),(0,d.jsx)(f.default,{className:"overflow-hidden bg-black/5 dark:bg-black/20",children:(0,d.jsx)("div",{className:"p-0 overflow-x-auto max-h-[calc(100vh-320px)] overflow-y-auto",children:c&&0===a.length?(0,d.jsx)("div",{className:"p-8 text-center text-text-muted",children:"Loading proxy logs..."}):0===a.length?(0,d.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"vpn_lock"}),"No proxy logs yet. Configure proxies and make API calls to see them here."]}):0===H.length?(0,d.jsx)("div",{className:"p-8 text-center text-text-muted",children:"No logs match the current filters."}):(0,d.jsxs)("table",{className:"w-full text-left border-collapse text-xs",children:[(0,d.jsx)("thead",{className:"sticky top-0 z-10",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:(0,d.jsxs)("tr",{className:"border-b border-border",style:{backgroundColor:"var(--bg-primary, #0f1117)"},children:[D.status&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Status"}),D.proxy&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Proxy"}),D.tls&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"TLS"}),D.type&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Type"}),D.level&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Level"}),D.provider&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Provider"}),D.target&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Target"}),D.latency&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Latency"}),D.ip&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px]",children:"Public IP"}),D.time&&(0,d.jsx)("th",{className:"px-3 py-2.5 font-semibold text-text-muted uppercase tracking-wider text-[10px] text-right",children:"Time"})]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border/30",children:H.map(a=>{let b=(0,g.Yh)(a.status),c=g.Gp[a.proxy?.type]||{bg:"#6B7280",text:"#fff",label:a.proxy?.type||"-"},e=g.Ie[a.level]||g.Ie.direct,f=g.RY[a.provider]||{bg:"#374151",text:"#fff",label:(a.provider||"-").toUpperCase()},i="error"===a.status||"timeout"===a.status;return(0,d.jsxs)("tr",{onClick:()=>C(B?.id===a.id?null:a),className:`cursor-pointer hover:bg-primary/5 transition-colors ${i?"bg-red-500/5":""}`,children:[D.status&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[50px] text-center uppercase",style:{backgroundColor:b.bg,color:b.text},children:a.status})}),D.proxy&&(0,d.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-primary",children:a.proxy?`${a.proxy.host}:${a.proxy.port}`:"—"}),D.tls&&(0,d.jsx)("td",{className:"px-3 py-2",children:a.tlsFingerprint?(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:"rgba(6, 182, 212, 0.15)",color:"#22d3ee"},title:"Chrome 124 TLS Fingerprint",children:[(0,d.jsx)("span",{style:{fontSize:"10px"},children:"\uD83D\uDD12"})," TLS"]}):(0,d.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),D.type&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:c.bg,color:c.text},children:c.label})}),D.level&&(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:e.bg,color:e.text},children:e.label})}),D.provider&&(0,d.jsx)("td",{className:"px-3 py-2",children:a.provider?(0,d.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:f.bg,color:f.text},children:f.label}):(0,d.jsx)("span",{className:"text-text-muted text-[10px]",children:"—"})}),D.target&&(0,d.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[200px] font-mono text-[10px]",title:a.targetUrl,children:(0,h.Y1)(a.targetUrl)}),D.latency&&(0,d.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,h.a3)(a.latencyMs)}),D.ip&&(0,d.jsx)("td",{className:"px-3 py-2 font-mono text-[11px] text-emerald-400",children:a.publicIp||"—"}),D.time&&(0,d.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,h.fU)(a.timestamp)})]},a.id)})})]})})}),B&&(0,d.jsx)(i,{log:B,onClose:()=>C(null)})]})}},75033:(a,b,c)=>{c.d(b,{A:()=>g});var d=c(48249),e=c(49885),f=c.n(e);function g({size:a=20,className:b=""}){return(0,d.jsxs)("svg",{width:a,height:a,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:b,children:[(0,d.jsx)("circle",{cx:"16",cy:"16",r:"3",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"24",cy:"8",r:"2",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"8",cy:"24",r:"2",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"24",cy:"24",r:"2",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"16",cy:"5",r:"1.5",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"16",cy:"27",r:"1.5",fill:"currentColor"}),(0,d.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,d.jsx)("line",{x1:"16",y1:"13",x2:"24",y2:"8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,d.jsx)("line",{x1:"16",y1:"19",x2:"8",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,d.jsx)("line",{x1:"16",y1:"19",x2:"24",y2:"24",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,d.jsx)("line",{x1:"16",y1:"13",x2:"16",y2:"5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"}),(0,d.jsx)("line",{x1:"16",y1:"19",x2:"16",y2:"27",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]})}g.propTypes={size:f().number,className:f().string}},77088:(a,b,c)=>{c.d(b,{default:()=>i});var d=c(48249),e=c(19099),f=c(2116),g=c.n(f);let h={dashboard:"Dashboard",providers:"Providers",combos:"Combos",settings:"Settings",logs:"Logs","audit-log":"Audit Log",console:"Console",logger:"Logger",translator:"Translator",playground:"Playground",add:"Add",edit:"Edit",keys:"API Keys",models:"Models"};function i(){let a=(0,e.usePathname)();if(!a||"/dashboard"===a)return null;let b=a.split("/").filter(Boolean),c=b.map((a,c)=>({label:h[a]||a.charAt(0).toUpperCase()+a.slice(1),href:"/"+b.slice(0,c+1).join("/"),isLast:c===b.length-1}));return(0,d.jsx)("nav",{"aria-label":"Breadcrumb",style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:"var(--text-secondary, #888)",padding:"8px 0",marginBottom:"8px"},children:c.map((a,b)=>(0,d.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[b>0&&(0,d.jsx)("span",{style:{opacity:.4,fontSize:"11px"},"aria-hidden":"true",children:"›"}),a.isLast?(0,d.jsx)("span",{"aria-current":"page",style:{color:"var(--text-primary, #e0e0e0)",fontWeight:500},children:a.label}):(0,d.jsx)(g(),{href:a.href,style:{color:"var(--text-secondary, #888)",textDecoration:"none",transition:"color 0.15s"},onMouseEnter:a=>a.currentTarget.style.color="var(--accent, #818cf8)",onMouseLeave:a=>a.currentTarget.style.color="var(--text-secondary, #888)",children:a.label})]},a.href))})}},82054:(a,b,c)=>{c.d(b,{default:()=>p});var d=c(48249),e=c(77360),f=c(67484),g=c(49885),h=c.n(g),i=c(19099),j=c(2490),k=c(4355),l=c(22746),m=c(17908);function n({field:a,currentSort:b,currentOrder:c}){return b!==a?(0,d.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,d.jsx)("span",{className:"ml-1",children:"asc"===c?"↑":"↓"})}function o({data:a,colorClass:b="bg-primary"}){let c=Math.max(...a,1);return(0,d.jsx)("div",{className:"flex items-end gap-1 h-8 w-24",children:a.slice(-9).map((a,e)=>(0,d.jsx)("div",{className:`flex-1 rounded-t-sm transition-all duration-500 ${b}`,style:{height:`${Math.max(a/c*100,5)}%`},title:String(a)},`bar-${e}-${a}`))})}function p(){let a=(0,e.c)("stats"),b=(0,i.useRouter)(),c=(0,i.useSearchParams)(),g=c.get("sortBy")||"rawModel",h=c.get("sortOrder")||"asc",[p,q]=(0,f.useState)(null),[r,s]=(0,f.useState)(!0),[t,u]=(0,f.useState)(!0),[v,w]=(0,f.useState)("tokens"),[x,y]=(0,f.useState)(5e3),z=(0,f.useRef)(0),A=a=>{let d=new URLSearchParams(c.toString());g===a?d.set("sortOrder","asc"===h?"desc":"asc"):(d.set("sortBy",a),d.set("sortOrder","asc")),b.replace(`?${d.toString()}`,{scroll:!1})},B=(0,f.useCallback)((a,b={})=>Object.entries(a||{}).map(([a,c])=>{let d=(c.promptTokens||0)+(c.completionTokens||0),e=c.cost||0,f=d>0?(c.promptTokens||0)*(e/d):0,g=d>0?(c.completionTokens||0)*(e/d):0;return{...c,key:a,totalTokens:d,totalCost:e,inputCost:f,outputCost:g,pending:b[a]||0}}).sort((a,b)=>{let c=a[g],d=b[g];return("string"==typeof c&&(c=c.toLowerCase()),"string"==typeof d&&(d=d.toLowerCase()),c<d)?"asc"===h?-1:1:c>d?"asc"===h?1:-1:0}),[g,h]),C=(0,f.useMemo)(()=>B(p?.byModel,p?.pending?.byModel),[p?.byModel,p?.pending?.byModel,B]),D=(0,f.useMemo)(()=>{let a={};return p?.pending?.byAccount&&Object.entries(p.byAccount||{}).forEach(([b,c])=>{let d=p.pending.byAccount[c.connectionId];if(d){let e=c.provider?`${c.rawModel} (${c.provider})`:c.rawModel;a[b]=d[e]||0}}),B(p?.byAccount,a)},[p?.byAccount,p?.pending?.byAccount,B]);if((0,f.useCallback)(async(a=!0)=>{a&&s(!0);try{let a=await fetch("/api/usage/history");if(a.ok){let b=await a.json();q(b);let c=b.totalRequests||0;c>z.current?y(5e3):y(a=>Math.min(2*a,6e4)),z.current=c}}catch(a){console.error("Failed to fetch usage stats:",a)}finally{a&&s(!1)}},[]),r)return(0,d.jsx)(l.CardSkeleton,{});if(!p)return(0,d.jsx)("div",{className:"text-text-muted",children:a("failedToLoad")});let E=a=>(0,m.xW)(a),F=a=>{if(!a)return"Never";let b=new Date(a),c=Math.floor((new Date().getTime()-b.getTime())/6e4);return c<1?"Just now":c<60?`${c}m ago`:c<1440?`${Math.floor(c/60)}h ago`:b.toLocaleDateString()};return(0,d.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("h2",{className:"text-xl font-semibold",children:a("usageOverview")}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:[(0,d.jsx)("button",{onClick:()=>w("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"}),(0,d.jsx)("button",{onClick:()=>w("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===v?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"})]}),(0,d.jsxs)("div",{className:"text-sm font-medium text-text-muted flex items-center gap-2",children:[(0,d.jsxs)("span",{children:["Auto Refresh (",x/1e3,"s)"]}),(0,d.jsx)("button",{type:"button",onClick:()=>u(!t),role:"switch","aria-checked":t,"aria-label":"Toggle auto refresh",className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary/50 ${t?"bg-primary":"bg-bg-subtle border border-border"}`,children:(0,d.jsx)("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${t?"translate-x-5":"translate-x-1"}`})})]})]})]}),(p.activeRequests||[]).length>0&&(0,d.jsx)(j.default,{className:"p-3 border-primary/20 bg-primary/5",children:(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 text-primary font-semibold text-sm uppercase tracking-wider",children:[(0,d.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,d.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"}),(0,d.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-primary"})]}),"Active Requests"]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-3",children:p.activeRequests.map(a=>(0,d.jsxs)("div",{className:"px-3 py-1.5 rounded-md bg-bg-subtle border border-primary/20 text-xs font-mono shadow-sm",children:[(0,d.jsx)("span",{className:"text-primary font-bold",children:a.model}),(0,d.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,d.jsx)("span",{className:"text-text",children:a.provider}),(0,d.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,d.jsx)("span",{className:"text-text font-medium",children:a.account}),a.count>1&&(0,d.jsxs)("span",{className:"ml-2 px-1.5 py-0.5 rounded bg-primary text-white font-bold",children:["x",a.count]})]},`${a.model}-${a.provider}-${a.account}`))})]})}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,d.jsx)(j.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,d.jsxs)("div",{className:"flex justify-between items-start",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Requests"}),(0,d.jsx)("span",{className:"text-2xl font-bold",children:E(p.totalRequests)})]}),(0,d.jsx)(o,{data:(p.last10Minutes||[]).map(a=>a.requests),colorClass:"bg-text-muted/30"})]})}),(0,d.jsx)(j.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,d.jsxs)("div",{className:"flex justify-between items-start",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Input Tokens"}),(0,d.jsx)("span",{className:"text-2xl font-bold text-primary",children:E(p.totalPromptTokens)})]}),(0,d.jsx)(o,{data:(p.last10Minutes||[]).map(a=>a.promptTokens),colorClass:"bg-primary/50"})]})}),(0,d.jsx)(j.default,{className:"px-4 py-2 flex flex-col gap-1",children:(0,d.jsxs)("div",{className:"flex justify-between items-start gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:a("outputTokens")}),(0,d.jsx)("span",{className:"text-2xl font-bold text-success",children:E(p.totalCompletionTokens)})]}),(0,d.jsx)("div",{className:"w-px bg-border self-stretch mx-2"}),(0,d.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:a("totalCost")}),(0,d.jsx)("span",{className:"text-2xl font-bold text-warning",children:(0,m.F0)(p.totalCost)})]})]})})]}),(0,d.jsxs)(j.default,{className:"overflow-hidden",children:[(0,d.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,d.jsx)("h3",{className:"font-semibold",children:"Usage by Model"})}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,d.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,d.jsxs)("tr",{children:[(0,d.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("rawModel"),children:["Model ",(0,d.jsx)(n,{field:"rawModel",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("provider"),children:["Provider"," ",(0,d.jsx)(n,{field:"provider",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("requests"),children:["Requests"," ",(0,d.jsx)(n,{field:"requests",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("lastUsed"),children:["Last Used"," ",(0,d.jsx)(n,{field:"lastUsed",currentSort:g,currentOrder:h})]}),"tokens"===v?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("promptTokens"),children:["Input Tokens"," ",(0,d.jsx)(n,{field:"promptTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("completionTokens"),children:["Output Tokens"," ",(0,d.jsx)(n,{field:"completionTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("totalTokens"),children:["Total Tokens"," ",(0,d.jsx)(n,{field:"totalTokens",currentSort:g,currentOrder:h})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("promptTokens"),children:["Input Cost"," ",(0,d.jsx)(n,{field:"promptTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("completionTokens"),children:["Output Cost"," ",(0,d.jsx)(n,{field:"completionTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("cost"),children:["Total Cost"," ",(0,d.jsx)(n,{field:"cost",currentSort:g,currentOrder:h})]})]})]})}),(0,d.jsxs)("tbody",{className:"divide-y divide-border",children:[C.map(a=>(0,d.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,d.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(k.default,{variant:a.pending>0?"primary":"default",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:E(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:F(a.lastUsed)}),"tokens"===v?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(a.promptTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(a.completionTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:E(a.totalTokens)})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(a.inputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(a.outputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(a.totalCost)})]})]},a.key)),0===C.length&&(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:8,className:"px-6 py-8 text-center text-text-muted",children:"No usage recorded yet. Make some requests to see data here."})})]})]})})]}),(0,d.jsxs)(j.default,{className:"overflow-hidden",children:[(0,d.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,d.jsx)("h3",{className:"font-semibold",children:"Usage by Account"})}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,d.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,d.jsxs)("tr",{children:[(0,d.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("rawModel"),children:["Model ",(0,d.jsx)(n,{field:"rawModel",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("provider"),children:["Provider"," ",(0,d.jsx)(n,{field:"provider",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("accountName"),children:["Account"," ",(0,d.jsx)(n,{field:"accountName",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("requests"),children:["Requests"," ",(0,d.jsx)(n,{field:"requests",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("lastUsed"),children:["Last Used"," ",(0,d.jsx)(n,{field:"lastUsed",currentSort:g,currentOrder:h})]}),"tokens"===v?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("promptTokens"),children:["Input Tokens"," ",(0,d.jsx)(n,{field:"promptTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("completionTokens"),children:["Output Tokens"," ",(0,d.jsx)(n,{field:"completionTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("totalTokens"),children:["Total Tokens"," ",(0,d.jsx)(n,{field:"totalTokens",currentSort:g,currentOrder:h})]})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("promptTokens"),children:["Input Cost"," ",(0,d.jsx)(n,{field:"promptTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("completionTokens"),children:["Output Cost"," ",(0,d.jsx)(n,{field:"completionTokens",currentSort:g,currentOrder:h})]}),(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>A("cost"),children:["Total Cost"," ",(0,d.jsx)(n,{field:"cost",currentSort:g,currentOrder:h})]})]})]})}),(0,d.jsxs)("tbody",{className:"divide-y divide-border",children:[D.map(a=>(0,d.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,d.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(k.default,{variant:a.pending>0?"primary":"default",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)("span",{className:`font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.accountName||`Account ${a.connectionId?.slice(0,8)}...`})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:E(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:F(a.lastUsed)}),"tokens"===v?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(a.promptTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:E(a.completionTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:E(a.totalTokens)})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(a.inputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,m.F0)(a.outputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,m.F0)(a.totalCost)})]})]},a.key)),0===D.length&&(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:9,className:"px-6 py-8 text-center text-text-muted",children:"No account-specific usage recorded yet. Make requests using OAuth accounts to see data here."})})]})]})})]})]})}n.propTypes={field:h().string.isRequired,currentSort:h().string.isRequired,currentOrder:h().string.isRequired},o.propTypes={data:h().arrayOf(h().number).isRequired,colorClass:h().string}},85974:(a,b,c)=>{c.d(b,{default:()=>e});var d=c(48249);function e({icon:a="\uD83D\uDCED",title:b="Nothing here yet",description:c="",actionLabel:e="",onAction:f=null}){return(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",minHeight:"200px"},children:[(0,d.jsx)("div",{style:{fontSize:"48px",marginBottom:"16px",opacity:.8,animation:"emptyBounce 2s ease-in-out infinite"},role:"img","aria-hidden":"true",children:a}),(0,d.jsx)("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary, #e0e0e0)",marginBottom:"8px",margin:0},children:b}),c&&(0,d.jsx)("p",{style:{fontSize:"14px",color:"var(--text-secondary, #888)",maxWidth:"320px",lineHeight:1.5,marginTop:"8px"},children:c}),e&&f&&(0,d.jsx)("button",{onClick:f,style:{marginTop:"20px",padding:"10px 24px",borderRadius:"8px",border:"1px solid rgba(99, 102, 241, 0.4)",background:"rgba(99, 102, 241, 0.15)",color:"#818cf8",fontSize:"14px",fontWeight:500,cursor:"pointer",transition:"all 0.2s ease"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(99, 102, 241, 0.25)",a.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(99, 102, 241, 0.15)",a.currentTarget.style.transform="translateY(0)"},children:e}),(0,d.jsx)("style",{children:`
17
17
  @keyframes emptyBounce {
18
18
  0%, 100% { transform: translateY(0); }
19
19
  50% { transform: translateY(-8px); }