@jheavenknows/bluerouter 5.0.57 → 5.0.58

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 (450) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +8 -8
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/api-keys/page_client-reference-manifest.js +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/personalcloudprovider/page_client-reference-manifest.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/personalquota/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/prompt-logs/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/provider-health/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  33. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js +1 -1
  34. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  35. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  36. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  37. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  38. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  39. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  40. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  41. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  42. package/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  43. package/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  44. package/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  45. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  46. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  47. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  48. package/app/.next-cli-build/server/app/_not-found.rsc +5 -5
  49. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +5 -5
  50. package/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  51. package/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +5 -5
  52. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  53. package/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  54. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  55. package/app/.next-cli-build/server/app/api/auth/ldap/test/route.js.nft.json +1 -1
  56. package/app/.next-cli-build/server/app/api/auth/ldap/users/route.js.nft.json +1 -1
  57. package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
  58. package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
  59. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js.nft.json +1 -1
  60. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js.nft.json +1 -1
  61. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js.nft.json +1 -1
  62. package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
  63. package/app/.next-cli-build/server/app/api/branding/[asset]/route.js.nft.json +1 -1
  64. package/app/.next-cli-build/server/app/api/branding/route.js.nft.json +1 -1
  65. package/app/.next-cli-build/server/app/api/branding/upload/route.js.nft.json +1 -1
  66. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  67. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  68. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/autostart/route.js.nft.json +1 -1
  69. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/prompt-log-db/route.js.nft.json +1 -1
  70. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/root-ca/route.js.nft.json +1 -1
  71. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  72. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js.nft.json +1 -1
  73. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
  74. package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
  75. package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
  76. package/app/.next-cli-build/server/app/api/dashboard/analytics/route.js.nft.json +1 -1
  77. package/app/.next-cli-build/server/app/api/dashboard/combos/route.js.nft.json +1 -1
  78. package/app/.next-cli-build/server/app/api/dashboard/endpoint/route.js.nft.json +1 -1
  79. package/app/.next-cli-build/server/app/api/dashboard/prompt-logs/[id]/route.js.nft.json +1 -1
  80. package/app/.next-cli-build/server/app/api/dashboard/prompt-logs/options/route.js.nft.json +1 -1
  81. package/app/.next-cli-build/server/app/api/dashboard/prompt-logs/route.js.nft.json +1 -1
  82. package/app/.next-cli-build/server/app/api/dashboard/token-saver/route.js.nft.json +1 -1
  83. package/app/.next-cli-build/server/app/api/keys/[id]/rotate/route.js.nft.json +1 -1
  84. package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
  85. package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
  86. package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
  87. package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
  88. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
  89. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
  90. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
  91. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
  92. package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
  93. package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
  94. package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
  95. package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
  96. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  97. package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
  98. package/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
  99. package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
  100. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  101. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
  102. package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
  103. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  104. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
  105. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  106. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  107. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  108. package/app/.next-cli-build/server/app/api/personal-cloud-providers/[id]/api-key-models/route.js.nft.json +1 -1
  109. package/app/.next-cli-build/server/app/api/personal-cloud-providers/[id]/import-models/route.js.nft.json +1 -1
  110. package/app/.next-cli-build/server/app/api/personal-cloud-providers/[id]/models/[...routeModel]/route.js.nft.json +1 -1
  111. package/app/.next-cli-build/server/app/api/personal-cloud-providers/[id]/route.js.nft.json +1 -1
  112. package/app/.next-cli-build/server/app/api/personal-cloud-providers/[id]/usage/route.js.nft.json +1 -1
  113. package/app/.next-cli-build/server/app/api/personal-cloud-providers/client/route.js.nft.json +1 -1
  114. package/app/.next-cli-build/server/app/api/personal-cloud-providers/permissions/route.js.nft.json +1 -1
  115. package/app/.next-cli-build/server/app/api/personal-cloud-providers/route.js.nft.json +1 -1
  116. package/app/.next-cli-build/server/app/api/personal-cloud-providers/routing/route.js.nft.json +1 -1
  117. package/app/.next-cli-build/server/app/api/pricing/recalculate/route.js.nft.json +1 -1
  118. package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
  119. package/app/.next-cli-build/server/app/api/provider-health/route.js.nft.json +1 -1
  120. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  121. package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
  122. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  123. package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
  124. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  125. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js +1 -1
  126. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  127. package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
  128. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  129. package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
  130. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  131. package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
  132. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js.nft.json +1 -1
  133. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js.nft.json +1 -1
  134. package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js.nft.json +1 -1
  135. package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js.nft.json +1 -1
  136. package/app/.next-cli-build/server/app/api/proxy-pools/route.js.nft.json +1 -1
  137. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js.nft.json +1 -1
  138. package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
  139. package/app/.next-cli-build/server/app/api/settings/require-login/route.js.nft.json +1 -1
  140. package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
  141. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  142. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  143. package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
  144. package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
  145. package/app/.next-cli-build/server/app/api/tunnel/disable/route.js.nft.json +1 -1
  146. package/app/.next-cli-build/server/app/api/tunnel/enable/route.js.nft.json +1 -1
  147. package/app/.next-cli-build/server/app/api/tunnel/status/route.js.nft.json +1 -1
  148. package/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js.nft.json +1 -1
  149. package/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js.nft.json +1 -1
  150. package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js.nft.json +1 -1
  151. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js.nft.json +1 -1
  152. package/app/.next-cli-build/server/app/api/tunnel/tailscale-login/route.js.nft.json +1 -1
  153. package/app/.next-cli-build/server/app/api/tunnel/tailscale-start-daemon/route.js.nft.json +1 -1
  154. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  155. package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
  156. package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
  157. package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
  158. package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
  159. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  160. package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
  161. package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
  162. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  163. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  164. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  165. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  166. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  167. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  168. package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
  169. package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
  170. package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
  171. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  172. package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
  173. package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
  174. package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
  175. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  176. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  177. package/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +1 -1
  178. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  179. package/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
  180. package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
  181. package/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
  182. package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
  183. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  184. package/app/.next-cli-build/server/app/callback.html +1 -1
  185. package/app/.next-cli-build/server/app/callback.rsc +5 -5
  186. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +5 -5
  187. package/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
  188. package/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +5 -5
  189. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  190. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  191. package/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
  192. package/app/.next-cli-build/server/app/dashboard/analytics.html +1 -1
  193. package/app/.next-cli-build/server/app/dashboard/analytics.rsc +6 -6
  194. package/app/.next-cli-build/server/app/dashboard/analytics.segments/!KGRhc2hib2FyZCk/dashboard/analytics/__PAGE__.segment.rsc +1 -1
  195. package/app/.next-cli-build/server/app/dashboard/analytics.segments/!KGRhc2hib2FyZCk/dashboard/analytics.segment.rsc +1 -1
  196. package/app/.next-cli-build/server/app/dashboard/analytics.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  197. package/app/.next-cli-build/server/app/dashboard/analytics.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  198. package/app/.next-cli-build/server/app/dashboard/analytics.segments/_full.segment.rsc +6 -6
  199. package/app/.next-cli-build/server/app/dashboard/analytics.segments/_head.segment.rsc +1 -1
  200. package/app/.next-cli-build/server/app/dashboard/analytics.segments/_index.segment.rsc +5 -5
  201. package/app/.next-cli-build/server/app/dashboard/analytics.segments/_tree.segment.rsc +1 -1
  202. package/app/.next-cli-build/server/app/dashboard/api-keys.html +1 -1
  203. package/app/.next-cli-build/server/app/dashboard/api-keys.rsc +7 -7
  204. package/app/.next-cli-build/server/app/dashboard/api-keys.segments/!KGRhc2hib2FyZCk/dashboard/api-keys/__PAGE__.segment.rsc +2 -2
  205. package/app/.next-cli-build/server/app/dashboard/api-keys.segments/!KGRhc2hib2FyZCk/dashboard/api-keys.segment.rsc +1 -1
  206. package/app/.next-cli-build/server/app/dashboard/api-keys.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  207. package/app/.next-cli-build/server/app/dashboard/api-keys.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  208. package/app/.next-cli-build/server/app/dashboard/api-keys.segments/_full.segment.rsc +7 -7
  209. package/app/.next-cli-build/server/app/dashboard/api-keys.segments/_head.segment.rsc +1 -1
  210. package/app/.next-cli-build/server/app/dashboard/api-keys.segments/_index.segment.rsc +5 -5
  211. package/app/.next-cli-build/server/app/dashboard/api-keys.segments/_tree.segment.rsc +1 -1
  212. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  213. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +7 -7
  214. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  215. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  216. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  217. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  218. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +7 -7
  219. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  220. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +5 -5
  221. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
  222. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  223. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +7 -7
  224. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  225. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  226. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  227. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  228. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +7 -7
  229. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  230. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +5 -5
  231. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  232. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  233. package/app/.next-cli-build/server/app/dashboard/combos.rsc +7 -7
  234. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  235. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  236. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  237. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  238. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +7 -7
  239. package/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  240. package/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +5 -5
  241. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  242. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  243. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +7 -7
  244. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  245. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  246. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  247. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  248. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +7 -7
  249. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  250. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +5 -5
  251. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  252. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  253. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +7 -7
  254. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  255. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  256. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  257. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  258. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  259. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +7 -7
  260. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  261. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +5 -5
  262. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
  263. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  264. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +7 -7
  265. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  266. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  267. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  268. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  269. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +7 -7
  270. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  271. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +5 -5
  272. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  273. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  274. package/app/.next-cli-build/server/app/dashboard/profile.rsc +6 -6
  275. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +1 -1
  276. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  277. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  278. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  279. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
  280. package/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  281. package/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +5 -5
  282. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  283. package/app/.next-cli-build/server/app/dashboard/prompt-logs.html +1 -1
  284. package/app/.next-cli-build/server/app/dashboard/prompt-logs.rsc +6 -6
  285. package/app/.next-cli-build/server/app/dashboard/prompt-logs.segments/!KGRhc2hib2FyZCk/dashboard/prompt-logs/__PAGE__.segment.rsc +1 -1
  286. package/app/.next-cli-build/server/app/dashboard/prompt-logs.segments/!KGRhc2hib2FyZCk/dashboard/prompt-logs.segment.rsc +1 -1
  287. package/app/.next-cli-build/server/app/dashboard/prompt-logs.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  288. package/app/.next-cli-build/server/app/dashboard/prompt-logs.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  289. package/app/.next-cli-build/server/app/dashboard/prompt-logs.segments/_full.segment.rsc +6 -6
  290. package/app/.next-cli-build/server/app/dashboard/prompt-logs.segments/_head.segment.rsc +1 -1
  291. package/app/.next-cli-build/server/app/dashboard/prompt-logs.segments/_index.segment.rsc +5 -5
  292. package/app/.next-cli-build/server/app/dashboard/prompt-logs.segments/_tree.segment.rsc +1 -1
  293. package/app/.next-cli-build/server/app/dashboard/provider-health.html +1 -1
  294. package/app/.next-cli-build/server/app/dashboard/provider-health.rsc +6 -6
  295. package/app/.next-cli-build/server/app/dashboard/provider-health.segments/!KGRhc2hib2FyZCk/dashboard/provider-health/__PAGE__.segment.rsc +1 -1
  296. package/app/.next-cli-build/server/app/dashboard/provider-health.segments/!KGRhc2hib2FyZCk/dashboard/provider-health.segment.rsc +1 -1
  297. package/app/.next-cli-build/server/app/dashboard/provider-health.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  298. package/app/.next-cli-build/server/app/dashboard/provider-health.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  299. package/app/.next-cli-build/server/app/dashboard/provider-health.segments/_full.segment.rsc +6 -6
  300. package/app/.next-cli-build/server/app/dashboard/provider-health.segments/_head.segment.rsc +1 -1
  301. package/app/.next-cli-build/server/app/dashboard/provider-health.segments/_index.segment.rsc +5 -5
  302. package/app/.next-cli-build/server/app/dashboard/provider-health.segments/_tree.segment.rsc +1 -1
  303. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  304. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +7 -7
  305. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  306. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  307. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  308. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  309. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  310. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +7 -7
  311. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  312. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +5 -5
  313. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  314. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  315. package/app/.next-cli-build/server/app/dashboard/providers.rsc +7 -7
  316. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  317. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  318. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  319. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  320. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +7 -7
  321. package/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  322. package/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +5 -5
  323. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  324. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  325. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +7 -7
  326. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  327. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  328. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  329. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  330. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +7 -7
  331. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  332. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +5 -5
  333. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  334. package/app/.next-cli-build/server/app/dashboard/quota.html +1 -1
  335. package/app/.next-cli-build/server/app/dashboard/quota.rsc +8 -8
  336. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  337. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  338. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  339. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  340. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +8 -8
  341. package/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  342. package/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +5 -5
  343. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  344. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  345. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  346. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +5 -5
  347. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +5 -5
  348. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  349. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +5 -5
  350. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  351. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  352. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  353. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  354. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  355. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  356. package/app/.next-cli-build/server/app/dashboard/skills.rsc +7 -7
  357. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
  358. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills.segment.rsc +1 -1
  359. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  360. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  361. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +7 -7
  362. package/app/.next-cli-build/server/app/dashboard/skills.segments/_head.segment.rsc +1 -1
  363. package/app/.next-cli-build/server/app/dashboard/skills.segments/_index.segment.rsc +5 -5
  364. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
  365. package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  366. package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +7 -7
  367. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
  368. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
  369. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  370. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  371. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +7 -7
  372. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
  373. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +5 -5
  374. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
  375. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  376. package/app/.next-cli-build/server/app/dashboard/translator.rsc +7 -7
  377. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  378. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  379. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  380. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  381. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +7 -7
  382. package/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  383. package/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +5 -5
  384. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  385. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  386. package/app/.next-cli-build/server/app/dashboard/usage.rsc +7 -7
  387. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  388. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  389. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  390. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  391. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +7 -7
  392. package/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  393. package/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +5 -5
  394. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  395. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  396. package/app/.next-cli-build/server/app/dashboard.rsc +7 -7
  397. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  398. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  399. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  400. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +7 -7
  401. package/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
  402. package/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +5 -5
  403. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  404. package/app/.next-cli-build/server/app/index.html +1 -1
  405. package/app/.next-cli-build/server/app/index.rsc +5 -5
  406. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  407. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +5 -5
  408. package/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
  409. package/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +5 -5
  410. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  411. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  412. package/app/.next-cli-build/server/app/landing.html +1 -1
  413. package/app/.next-cli-build/server/app/landing.rsc +5 -5
  414. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +5 -5
  415. package/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  416. package/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +5 -5
  417. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  418. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  419. package/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  420. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  421. package/app/.next-cli-build/server/app/login.html +1 -1
  422. package/app/.next-cli-build/server/app/login.rsc +6 -6
  423. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +6 -6
  424. package/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  425. package/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +5 -5
  426. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  427. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  428. package/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  429. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  430. package/app/.next-cli-build/server/app-paths-manifest.json +8 -8
  431. package/app/.next-cli-build/server/chunks/2338.js +1 -1
  432. package/app/.next-cli-build/server/chunks/3110.js +1 -1
  433. package/app/.next-cli-build/server/chunks/4746.js +1 -1
  434. package/app/.next-cli-build/server/chunks/6328.js +1 -1
  435. package/app/.next-cli-build/server/chunks/700.js +1 -1
  436. package/app/.next-cli-build/server/chunks/9434.js +1 -1
  437. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  438. package/app/.next-cli-build/server/pages/404.html +1 -1
  439. package/app/.next-cli-build/server/pages/500.html +1 -1
  440. package/app/.next-cli-build/static/chunks/{5263-0ab1990ccdc396bb.js → 5263-65af42de22bcd175.js} +1 -1
  441. package/app/.next-cli-build/static/chunks/{5497-336d2f218c69deac.js → 5497-699167abfa5c7877.js} +1 -1
  442. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/token-saver/page-6cd8f0e0ce1dfbc9.js +1 -0
  443. package/app/cli/.build-home/AppData/Roaming/bluerouter/db/data.sqlite-shm +0 -0
  444. package/app/cli/.build-home/AppData/Roaming/bluerouter/db/data.sqlite-wal +0 -0
  445. package/app/package.json +1 -1
  446. package/package.json +1 -1
  447. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/token-saver/page-2d20542fb8e54b68.js +0 -1
  448. /package/app/.next-cli-build/static/{a4sfNmyQir_TloQgNMKz9 → v1bW62XYWO5YgqgjQesKg}/_buildManifest.js +0 -0
  449. /package/app/.next-cli-build/static/{a4sfNmyQir_TloQgNMKz9 → v1bW62XYWO5YgqgjQesKg}/_ssgManifest.js +0 -0
  450. /package/app/cli/.build-home/AppData/Roaming/bluerouter/db/backups/{upgrade-5.0.52-to-5.0.53-5.0.53-20260701-113007 → upgrade-5.0.56-to-5.0.57-5.0.57-20260701-134156}/data.sqlite +0 -0
@@ -7,4 +7,4 @@
7
7
  `,title:e.internalName&&e.internalName!==t?`Internal: ${e.internalName}`:t,children:[a&&(0,s.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),(0,s.jsx)("span",{children:r})]},`${e.pickerSource||"combo"}-${e.id||t}`)})})]}),Object.entries(D).map(([e,t])=>(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 z-10 bg-white py-1 dark:bg-zinc-950",children:[(0,s.jsx)(i.A,{src:(0,d.mq)(e)||(0,d.gb)(e)?null:`/providers/${e}.png`,alt:t.name,size:14,fallbackText:(t.name||e).slice(0,2).toUpperCase(),fallbackColor:t.color}),(0,s.jsx)("span",{className:"text-xs font-medium text-primary",children:t.name}),(0,s.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",t.models.length,")"]})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.models.map(e=>{let t=n===e.value,r=e.isPlaceholder;return(0,s.jsx)("button",{onClick:()=>F(e),title:r?"Select to pre-fill, then edit model ID in the input":void 0,className:`
8
8
  px-2 py-1 rounded-xl text-xs font-medium transition-all border hover:cursor-pointer
9
9
  ${r?"border-dashed border-border text-text-muted hover:border-primary/50 hover:text-primary bg-surface italic":t?"bg-primary text-white border-primary":f.includes(e.value)?"bg-primary border-primary text-white hover:bg-primary-hover":"bg-surface border-border text-text-main hover:border-primary/50 hover:bg-primary/5"}
10
- `,children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[f.includes(e.value)&&!r&&(0,s.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,s.jsxs)(s.Fragment,{children:[e.name,(0,s.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"})]}):e.name]})},e.value)})})]},e)),0===Object.keys(D).length&&0===U.length&&(0,s.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,s.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})]})}):null}u.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onSelect:n().func.isRequired,onDeselect:n().func,selectedModel:n().string,activeProviders:n().arrayOf(n().shape({provider:n().string.isRequired})),title:n().string,modelAliases:n().object,kindFilter:n().string,addedModelValues:n().arrayOf(n().string),closeOnSelect:n().bool,personalOnly:n().bool,extraModels:n().arrayOf(n().string)}},73006:(e,t,r)=>{r.d(t,{FE:()=>u,Tl:()=>d,wn:()=>x});var s=r(93308);let a={},l=s.Xn,n=[];function i(){if("u"<typeof document)return s.Xn;let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${s.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):s.Xn;return(0,s.QC)(t)}async function o(e){if("en"===e){a={};return}try{let t=await fetch(`/i18n/literals/${e}.json`);a=await t.json()}catch(e){console.error("Failed to load translations:",e),a={}}}function d(e){if(!e||"string"!=typeof e)return e;let t=e.trim();return t&&"en"!==l&&a[t]||e}function c(e){if(!e.nodeValue||!e.nodeValue.trim())return;let t=e.parentElement;if(!t)return;let r=t;for(;r;){if(r.hasAttribute&&r.hasAttribute("data-i18n-skip"))return;r=r.parentElement}if(["script","style","code","pre","colgroup","table","thead","tbody","tfoot","tr","select","datalist","optgroup"].includes(t.tagName?.toLowerCase()))return;e._originalText||(e._originalText=e.nodeValue);let s=d(e._originalText);s!==e.nodeValue&&(e.nodeValue=s)}function m(e){let t;if(!e)return;let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),s=[];for(;t=r.nextNode();)s.push(t);s.forEach(c)}async function u(){l=i(),await o(l),m(document.body),new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE?m(e):e.nodeType===Node.TEXT_NODE&&c(e)})})}).observe(document.body,{childList:!0,subtree:!0})}async function x(){l=i(),await o(l),n.forEach(e=>e()),m(document.body)}},73579:(e,t,r)=>{r.d(t,{default:()=>j});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(81127),o=r(11910),d=r(92542),c=r(56061),m=r(52679),u=r(90620),x=r(12494);let p=[0,1,2,3,4,5,6],h=[{value:1,label:"T2"},{value:2,label:"T3"},{value:3,label:"T4"},{value:4,label:"T5"},{value:5,label:"T6"},{value:6,label:"T7"},{value:0,label:"CN"}];function b(e,t){let r=String(e||"").trim();return/^([01]\d|2[0-3]):([0-5]\d)$/.test(r)?r:t}function f(e={}){let t=e&&"object"==typeof e?e:{},r=Array.isArray(t.weekdays)?t.weekdays.map(Number).filter(e=>e>=0&&e<=6):p;return{enabled:!1!==t.enabled,weekdays:[...new Set(r)].sort((e,t)=>e-t),fromTime:b(t.fromTime||t.from,"00:00"),toTime:b(t.toTime||t.to,"23:59")}}function g(e={}){var t;let r=e&&"object"==typeof e?e:{};return{enabled:!0===r.enabled,intervalSec:Math.max(10,Number.parseInt(r.intervalSec||60,10)||60),failureThreshold:Math.max(1,Number.parseInt(r.failureThreshold||3,10)||3),timeoutMs:Math.max(1e3,Number.parseInt(r.timeoutMs||15e3,10)||15e3),prompt:"string"==typeof r.prompt&&r.prompt.trim()?r.prompt.trim():"Say hi",disableThinking:!1!==r.disableThinking,model:"string"==typeof(t=r.model||r.healthModel||r.testModel)?t.trim():""}}function y(){return"text-xs font-medium text-text-muted"}function v(){return"mt-1 w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-text-main outline-none focus:border-primary disabled:cursor-not-allowed disabled:opacity-50"}function j({isOpen:e,connection:t,proxyPools:r,onSave:l,onClose:n}){let[b,N]=(0,a.useState)({name:"",priority:1,apiKey:""}),[w,k]=(0,a.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[C,S]=(0,a.useState)({accountId:""}),[T,A]=(0,a.useState)(!1),[_,I]=(0,a.useState)(null),[M,$]=(0,a.useState)(!1),[P,E]=(0,a.useState)(null),[R,O]=(0,a.useState)(!1),[L,z]=(0,a.useState)(f()),[q,U]=(0,a.useState)(g()),[D,F]=(0,a.useState)(!1),[W,K]=(0,a.useState)(!1),[B,V]=(0,a.useState)([]),[G,Q]=(0,a.useState)(!1),[J,H]=(0,a.useState)("");(0,a.useEffect)(()=>{t&&(N({name:t.name||"",priority:t.priority||1,apiKey:""}),"azure"===t.provider&&t.providerSpecificData?k({azureEndpoint:t.providerSpecificData.azureEndpoint||"",apiVersion:t.providerSpecificData.apiVersion||"2024-10-01-preview",deployment:t.providerSpecificData.deployment||"",organization:t.providerSpecificData.organization||""}):k({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),"cloudflare-ai"===t.provider&&t.providerSpecificData?S({accountId:t.providerSpecificData.accountId||""}):S({accountId:""}),z(f(t.schedule||{})),U(g(t.healthCheck||{})),F(!0===t.providerScheduleOverride),K(!0===t.providerHealthOverride),I(null),E(null))},[t]);let X=t?.authType==="oauth",Y=t?.provider==="azure",Z=t?.provider==="cloudflare-ai",ee=t?function(e=""){if((0,m.gb)(e))return"anthropic";if((0,m.mq)(e)||"cloudflare-ai"===e)return"openai";if("gemini"===e)return"gemini";if("github"===e)return"openai";let t=u.X3?.[e]||"";return t.includes("/messages")?"anthropic":t.includes("/chat/completions")||t.includes("/responses")?"openai":null}(t.provider):null,et=!!ee,er=(0,x.wB)(B,q.model);(0,a.useEffect)(()=>{if(!e||!t?.provider)return;let r=!1;return async function(){Q(!0),H("");try{let e=await (0,x.ns)({providerId:t.provider,connections:[t],currentModel:q.model||t.defaultModel||""});r||(V(e.models),H(e.warning||""))}catch(e){r||(V([]),H(e.message||"Kh\xf4ng tải được danh s\xe1ch Available Models cục bộ"))}finally{r||Q(!1)}}(),()=>{r=!0}},[e,t,q.model]);let es=async()=>{if(t?.provider){A(!0),I(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),r=await e.json();I(r.valid?"success":"failed")}catch{I("failed")}finally{A(!1)}}},ea=async()=>{if(t?.provider&&b.apiKey){$(!0),E(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:b.apiKey,...Y?{providerSpecificData:w}:{},...Z?{providerSpecificData:C}:{}})}),r=await e.json();E(r.valid?"success":"failed")}catch{E("failed")}finally{$(!1)}}},el=async()=>{if(t){O(!0);try{let e={name:b.name,priority:b.priority,schedule:f(L),healthCheck:g(q)};if(!X&&b.apiKey){e.apiKey=b.apiKey;let r="success"===P;if(!r)try{$(!0),E(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:b.apiKey,...Y?{providerSpecificData:w}:{},...Z?{providerSpecificData:C}:{}})});r=!!(await e.json()).valid,E(r?"success":"failed")}catch{E("failed")}finally{$(!1)}r&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}Y&&(e.providerSpecificData={azureEndpoint:w.azureEndpoint,apiVersion:w.apiVersion,deployment:w.deployment,organization:w.organization}),Z&&(e.providerSpecificData={accountId:C.accountId}),await l(e)}finally{O(!1)}}};return t?(0,s.jsx)(i.default,{isOpen:e,onClose:n,title:"Chỉnh sửa connection",size:"full",children:(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsx)(o.default,{label:"T\xean",value:b.name,onChange:e=>N({...b,name:e.target.value}),placeholder:X?"T\xean t\xe0i khoản":"Key production"}),(0,s.jsx)(o.default,{label:"Độ ưu ti\xean",type:"number",value:b.priority,onChange:e=>N({...b,priority:Number.parseInt(e.target.value,10)||1})})]}),X&&t.email&&(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-sidebar/40 px-3 py-2 text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"font-medium text-text-main",children:"Email:"})," ",t.email]}),!X&&(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.default,{label:"API Key",type:"password",value:b.apiKey,onChange:e=>N({...b,apiKey:e.target.value}),placeholder:"Nhập API key mới",hint:"Để trống nếu muốn giữ API key hiện tại.",className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(d.default,{onClick:ea,disabled:!b.apiKey||M||R,variant:"secondary",children:M?"Checking...":"Check"})}),P&&(0,s.jsx)("div",{className:"pt-7",children:(0,s.jsx)(c.default,{variant:"success"===P?"success":"error",children:"success"===P?"Valid":"Invalid"})})]}),Y&&(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-sidebar/40 p-4",children:[(0,s.jsx)("h3",{className:"mb-3 text-sm font-semibold text-text-main",children:"Cấu h\xecnh Azure OpenAI"}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsx)(o.default,{label:"Azure Endpoint",value:w.azureEndpoint,onChange:e=>k({...w,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,s.jsx)(o.default,{label:"T\xean deployment",value:w.deployment,onChange:e=>k({...w,deployment:e.target.value}),placeholder:"gpt-4"}),(0,s.jsx)(o.default,{label:"Phi\xean bản API",value:w.apiVersion,onChange:e=>k({...w,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,s.jsx)(o.default,{label:"Organization",value:w.organization,onChange:e=>k({...w,organization:e.target.value}),placeholder:"Organization ID"})]})]}),Z&&(0,s.jsx)(o.default,{label:"Cloudflare Account ID",value:C.accountId,onChange:e=>S({...C,accountId:e.target.value})}),(0,s.jsxs)("section",{className:"rounded-xl border border-border bg-sidebar/30 p-4",children:[(0,s.jsx)("h3",{className:"mb-3 text-sm font-semibold text-text-main",children:"Lịch hoạt động"}),D&&(0,s.jsx)("p",{className:"mb-3 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-xs text-yellow-500",children:"Provider đang bật ghi đ\xe8 lịch. Lịch ri\xeang của t\xe0i khoản n\xe0y sẽ bị kh\xf3a v\xe0 bị bỏ qua khi ghi đ\xe8 c\xf2n bật."}),(0,s.jsxs)("label",{className:"mb-3 flex items-center gap-2 text-sm text-text-main",children:[(0,s.jsx)("input",{type:"checkbox",checked:L.enabled,disabled:D,onChange:e=>z(t=>({...t,enabled:e.target.checked}))}),"Bật lịch cho t\xe0i khoản"]}),(0,s.jsx)("div",{className:"mb-3 flex flex-wrap gap-2",children:h.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-xs text-text-main",children:[(0,s.jsx)("input",{type:"checkbox",checked:L.weekdays.includes(e.value),disabled:D,onChange:()=>z(t=>{let r=new Set(Array.isArray(t.weekdays)?t.weekdays:p);return r.has(e.value)?r.delete(e.value):r.add(e.value),{...t,weekdays:[...r].sort((e,t)=>e-t)}})}),e.label]},e.value))}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("label",{className:y(),children:["Từ giờ",(0,s.jsx)("input",{type:"time",value:L.fromTime,disabled:D,onChange:e=>z(t=>({...t,fromTime:e.target.value})),className:v()})]}),(0,s.jsxs)("label",{className:y(),children:["Đến giờ",(0,s.jsx)("input",{type:"time",value:L.toTime,disabled:D,onChange:e=>z(t=>({...t,toTime:e.target.value})),className:v()})]})]})]}),(0,s.jsxs)("section",{className:"rounded-xl border border-border bg-sidebar/30 p-4",children:[(0,s.jsx)("h3",{className:"mb-3 text-sm font-semibold text-text-main",children:"Kiểm tra sức khỏe bằng ping"}),W&&(0,s.jsx)("p",{className:"mb-3 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-xs text-yellow-500",children:"Provider đang bật ghi đ\xe8 healthcheck. Ch\xednh s\xe1ch healthcheck ri\xeang của t\xe0i khoản n\xe0y sẽ bị kh\xf3a v\xe0 bị bỏ qua khi ghi đ\xe8 c\xf2n bật."}),(0,s.jsxs)("label",{className:"mb-3 flex items-center gap-2 text-sm text-text-main",children:[(0,s.jsx)("input",{type:"checkbox",checked:q.enabled,disabled:W,onChange:e=>U(t=>({...t,enabled:e.target.checked}))}),"Bật healthcheck định kỳ"]}),q.enabled&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("label",{className:y(),children:["Model d\xf9ng để healthcheck",(0,s.jsxs)("select",{value:q.model||"",onChange:e=>U(t=>({...t,model:e.target.value})),className:v(),disabled:W||G,children:[(0,s.jsx)("option",{value:"",children:"Chỉ kiểm tra connection/base URL — kh\xf4ng ping chat"}),er.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))]})]}),(0,s.jsxs)("label",{className:`${y()} mt-3 block`,children:["Nhập model healthcheck thủ c\xf4ng",(0,s.jsx)("input",{value:q.model||"",onChange:e=>U(t=>({...t,model:e.target.value})),placeholder:"anthropic"===ee?"t\xean model Claude từ endpoint n\xe0y":"gemini"===ee?"model Gemini, v\xed dụ gemini-2.5-flash":"t\xean model từ Available Models",className:v(),disabled:W||G})]}),G&&(0,s.jsx)("p",{className:"mt-2 text-xs text-text-muted",children:"Đang tải Available Models cục bộ..."}),J&&(0,s.jsxs)("p",{className:"mt-2 text-xs text-yellow-500",children:["Ghi ch\xfa danh s\xe1ch model: ",J]}),!G&&!J&&(0,s.jsx)("p",{className:"mt-2 text-xs text-text-muted",children:"Danh s\xe1ch model được lấy từ Available Models / DB cục bộ, kh\xf4ng gọi API /models của provider."}),"anthropic"===ee&&(0,s.jsxs)("p",{className:"mt-2 text-xs text-text-muted",children:["Healthcheck tương th\xedch Anthropic gửi ",(0,s.jsx)("code",{children:"Say hi"})," tới ",(0,s.jsx)("code",{children:"/v1/messages"})," chỉ khi đ\xe3 chọn model."]}),"gemini"===ee&&(0,s.jsxs)("p",{className:"mt-2 text-xs text-text-muted",children:["Healthcheck Gemini gửi ",(0,s.jsx)("code",{children:"Say hi"})," bằng API native ",(0,s.jsx)("code",{children:"generateContent"})," chỉ khi đ\xe3 chọn model."]}),"cloudflare-ai"===t.provider&&(0,s.jsxs)("p",{className:"mt-2 text-xs text-text-muted",children:["Healthcheck Cloudflare gửi ",(0,s.jsx)("code",{children:"Say hi"})," tới Workers AI OpenAI-style chat endpoint chỉ khi đ\xe3 chọn model."]}),!et&&(0,s.jsx)("p",{className:"mt-2 text-xs text-text-muted",children:"Provider n\xe0y vẫn c\xf3 thể hiển thị Available Models cục bộ. Auto healthcheck sẽ tiếp tục d\xf9ng kiểm tra connection/token/account gốc cho đến khi c\xf3 direct chat endpoint."})]}),q.enabled&&(!et||!q.model)&&(0,s.jsx)("p",{className:"mt-4 rounded-lg border border-border bg-background/60 px-3 py-2 text-xs text-text-muted",children:"Chưa bật model/endpoint direct chat healthcheck. Auto healthcheck sẽ kiểm tra connection/base URL/key/token/account v\xe0 kh\xf4ng gửi ping chat Say hi."}),(0,s.jsxs)("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[(0,s.jsxs)("label",{className:y(),children:["Chu kỳ (gi\xe2y)",(0,s.jsx)("input",{type:"number",min:"10",value:q.intervalSec,disabled:W,onChange:e=>U(t=>({...t,intervalSec:Math.max(10,Number.parseInt(e.target.value,10)||60)})),className:v()})]}),(0,s.jsxs)("label",{className:y(),children:["Ngưỡng lỗi",(0,s.jsx)("input",{type:"number",min:"1",value:q.failureThreshold,disabled:W,onChange:e=>U(t=>({...t,failureThreshold:Math.max(1,Number.parseInt(e.target.value,10)||3)})),className:v()})]}),(0,s.jsxs)("label",{className:y(),children:["Timeout (ms)",(0,s.jsx)("input",{type:"number",min:"1000",value:q.timeoutMs,disabled:W,onChange:e=>U(t=>({...t,timeoutMs:Math.max(1e3,Number.parseInt(e.target.value,10)||15e3)})),className:v()})]})]}),(0,s.jsxs)("label",{className:`${y()} mt-3 block`,children:["Lời nhắc",(0,s.jsx)("input",{value:q.prompt,disabled:W,onChange:e=>U(t=>({...t,prompt:e.target.value})),className:v()})]}),(0,s.jsxs)("label",{className:"mt-3 flex items-center gap-2 text-sm text-text-main",children:[(0,s.jsx)("input",{type:"checkbox",checked:q.disableThinking,disabled:W,onChange:e=>U(t=>({...t,disableThinking:e.target.checked}))}),"Ưu ti\xean payload kiểm tra nhẹ / tắt thinking nếu được hỗ trợ"]}),(0,s.jsxs)("div",{className:"mt-3 text-xs text-text-muted",children:["Trạng th\xe1i: ",(0,s.jsx)("span",{className:"font-medium text-text-main",children:t.healthStatus||"kh\xf4ng r\xf5"}),t.healthLastCheckedAt&&(0,s.jsxs)("span",{children:[" \xb7 lần kiểm tra cuối: ",function(e){if(!e)return"";try{return new Date(e).toLocaleString()}catch{return String(e)}}(t.healthLastCheckedAt)]}),t.healthLastError&&(0,s.jsx)("p",{className:"mt-1 break-words text-red-500",children:t.healthLastError})]})]}),!Y&&!Z&&(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(d.default,{onClick:es,disabled:T,variant:"secondary",children:T?"Đang kiểm tra...":"Kiểm tra connection"}),_&&(0,s.jsx)(c.default,{variant:"success"===_?"success":"error",children:"success"===_?"Hợp lệ":"Thất bại"})]}),(0,s.jsxs)("div",{className:"flex gap-2 border-t border-border pt-4",children:[(0,s.jsx)(d.default,{onClick:el,disabled:R||Y&&(!w.azureEndpoint||!w.deployment||!w.organization)||Z&&!C.accountId,fullWidth:!0,children:R?"Đang lưu...":"Lưu"}),(0,s.jsx)(d.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}j.propTypes={isOpen:n().bool.isRequired,connection:n().shape({id:n().string,name:n().string,email:n().string,priority:n().number,authType:n().string,provider:n().string,defaultModel:n().string,providerSpecificData:n().object,schedule:n().object,healthCheck:n().object,healthStatus:n().string,healthLastCheckedAt:n().string,healthLastError:n().string,providerScheduleOverride:n().bool,providerHealthOverride:n().bool}),proxyPools:n().arrayOf(n().shape({id:n().string,name:n().string})),onSave:n().func.isRequired,onClose:n().func.isRequired}},74891:(e,t,r)=>{r.d(t,{default:()=>f});var s=r(95155),a=r(12115),l=r(73321),n=r(98500),i=r.n(n),o=r(14051),d=r.n(o),c=r(80752),m=r(38587),u=r(94027),x=r(38003),p=r(90620),h=r(52679),b=r(73006);function f({onMenuClick:e,showMenuButton:t=!0}){let r=(0,l.usePathname)(),n=(0,l.useRouter)(),{displayName:o,loginMethod:d}=(0,u.s)(),{title:x,description:y,icon:v,breadcrumbs:j}=(0,a.useMemo)(()=>(e=>{if(!e)return{title:"",description:"",breadcrumbs:[]};let t=e.match(/\/media-providers\/([^/]+)\/([^/]+)$/);if(t){let e=t[1],r=t[2],s=h.rj.find(t=>t.id===e),a=h.Q2[r];return{title:a?.name||r,description:"",breadcrumbs:[{label:"Media Providers",href:`/dashboard/media-providers/${e}`},{label:s?.label||e,href:`/dashboard/media-providers/${e}`},{label:a?.name||r,image:`/providers/${r}.png`}]}}let r=e.match(/\/media-providers\/([^/]+)$/);if(r){let e=r[1],t=h.rj.find(t=>t.id===e);return{title:t?.label||e,description:`Manage your ${t?.label||e} providers`,icon:t?.icon||"perm_media",breadcrumbs:[]}}let s=e.match(/\/providers\/([^/]+)$/);if(s){let e=s[1],t=p.zN[e]||p.fg[e];if(t)return{title:t.name,description:"",breadcrumbs:[{label:"Providers",href:"/dashboard/providers"},{label:t.name,image:`/providers/${t.id}.png`}]}}return e.includes("/providers")&&!e.includes("/media-providers")?{title:"Providers",description:"Manage your AI provider connections",icon:"dns",breadcrumbs:[]}:e.includes("/combos")?{title:"Combos",description:"Model combos with fallback",icon:"layers",breadcrumbs:[]}:e.includes("/token-saver")?{title:"Token Saver Analytics",description:"Theo d\xf5i hiệu quả RTK token saving theo source tool, provider, model v\xe0 filter",icon:"compress",breadcrumbs:[]}:e.includes("/analytics")?{title:"Analytics",description:"Thống k\xea request, token, API key, Source IP, provider, model v\xe0 lỗi vận h\xe0nh",icon:"monitoring",breadcrumbs:[]}:e.includes("/usage")?{title:"Usage & Analytics",description:"Monitor your API usage, token consumption, and request logs",icon:"bar_chart",breadcrumbs:[]}:e.includes("/auth-files")?{title:"Auth Files",description:"Map provider credentials stored in the local database",icon:"vpn_key",breadcrumbs:[]}:e.includes("/quota")?{title:"Quota Tracker",description:"Track and manage your API quota limits",icon:"data_usage",breadcrumbs:[]}:e.includes("/mitm")?{title:"AI Traffic Proxy",description:"Intercept CLI tool traffic and route through this router gateway",icon:"security",breadcrumbs:[]}:e.includes("/prompt-logs")?{title:"Prompt Logs",description:"Search Copilot/MITM prompts across the prompt log database",icon:"manage_search",breadcrumbs:[]}:e.includes("/cli-tools")?{title:"CLI Tools",description:"Configure CLI tools",icon:"terminal",breadcrumbs:[]}:e.includes("/proxy-pools")?{title:"Proxy Pools",description:"Manage your proxy pool configurations",icon:"lan",breadcrumbs:[]}:e.includes("/skills")?{title:"Agent Skills",description:"Copy a link and paste to your AI to use this Router — no install needed",icon:"extension",breadcrumbs:[]}:e.includes("/endpoint")?{title:"Endpoint",description:"API endpoint configuration",icon:"api",breadcrumbs:[]}:e.includes("/api-keys")?{title:"API Keys",description:"Manage API keys and model access",icon:"vpn_key",breadcrumbs:[]}:e.includes("/profile")?{title:"Settings",description:"Manage your preferences",icon:"settings",breadcrumbs:[]}:e.includes("/translator")?{title:"Translator",description:"Debug translation flow between formats",icon:"translate",breadcrumbs:[]}:e.includes("/console-log")?{title:"Console Log",description:"Live server console output",icon:"monitor",breadcrumbs:[]}:"/dashboard"===e?{title:"Endpoint",description:"API endpoint configuration",icon:"api",breadcrumbs:[]}:{title:"",description:"",breadcrumbs:[]}})(r),[r]),N=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&(n.push("/login"),n.refresh())}catch(e){console.error("Failed to logout:",e)}};return(0,s.jsx)("header",{className:"sticky top-0 z-30 border-b border-border bg-background/80 backdrop-blur",children:(0,s.jsxs)("div",{className:"flex min-h-[72px] items-center justify-between gap-4 px-4 md:px-6",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[t?(0,s.jsx)("button",{type:"button",onClick:e,className:"rounded-xl border border-border p-2 text-text-muted hover:bg-surface hover:text-text-main lg:hidden","aria-label":"Open menu",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"menu"})}):null,(0,s.jsx)("div",{className:"min-w-0",children:j.length>0?(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-1 text-sm text-text-muted",children:j.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[t>0?(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_right"}):null,e.href?(0,s.jsx)(i(),{href:e.href,className:"hover:text-primary",children:(0,b.Tl)(e.label)}):(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[e.image?(0,s.jsx)("img",{src:e.image,alt:"",className:"h-5 w-5 rounded"}):null,(0,s.jsx)("h1",{className:"text-xl font-semibold text-text-main",children:(0,b.Tl)(e.label)})]})]},`${e.label}-${t}`))}):x?(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[v?(0,s.jsx)("span",{className:"material-symbols-outlined text-primary",children:v}):null,(0,s.jsx)("h1",{className:"truncate text-xl font-semibold text-text-main",children:(0,b.Tl)(x)})]}),y?(0,s.jsx)("p",{className:"mt-1 truncate text-sm text-text-muted",children:(0,b.Tl)(y)}):null]}):null})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)(g,{}),o&&"OIDC"===d?(0,s.jsxs)("div",{className:"hidden items-center gap-2 rounded-xl border border-border px-3 py-2 text-sm text-text-muted md:flex",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"person"}),(0,s.jsx)("span",{children:o}),(0,s.jsx)("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-xs text-primary",children:"OIDC"})]}):null,(0,s.jsx)(m.default,{}),(0,s.jsx)(c.default,{onLogout:N})]})]})})}function g(){let e=(0,x.C)(e=>e.visible),t=(0,x.C)(e=>e.query),r=(0,x.C)(e=>e.placeholder),a=(0,x.C)(e=>e.setQuery);return e?(0,s.jsxs)("div",{className:"relative hidden w-72 md:block",children:[(0,s.jsx)("span",{className:"material-symbols-outlined pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-[18px] text-text-muted",children:"search"}),(0,s.jsx)("input",{value:t,onChange:e=>a(e.target.value),placeholder:r,className:"h-9 w-full rounded-lg border border-border bg-surface/60 pl-8 pr-8 text-sm text-text-main outline-none transition-colors placeholder:text-text-muted focus:border-primary/50"}),t?(0,s.jsx)("button",{type:"button",onClick:()=>a(""),className:"absolute right-1 top-1/2 -translate-y-1/2 rounded p-0.5 text-text-muted hover:text-text-main","aria-label":"Clear search",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})}):null]}):null}f.propTypes={onMenuClick:d().func,showMenuButton:d().bool}},77907:(e,t,r)=>{r.d(t,{Fv:()=>s,SI:()=>a,VC:()=>i}),Object.freeze({ADMIN:"admin",MONITOR_ADMIN:"monitor_admin",AI_GATEWAYS_MONITOR:"ai_gateways_monitor",USER:"user",GUEST:"guest"});let s="/dashboard/endpoint",a=Object.freeze([{href:"/dashboard/endpoint",label:"Endpoint",icon:"api"},{href:"/dashboard/api-keys",label:"API Keys",icon:"vpn_key"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/analytics",label:"Analytics",icon:"monitoring"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"},{href:"/dashboard/prompt-logs",label:"Prompt Logs",icon:"manage_search"}]),l=Object.freeze(["/dashboard","/dashboard/endpoint","/dashboard/api-keys","/dashboard/usage","/dashboard/analytics","/dashboard/quota","/dashboard/prompt-logs"]);function n(e=""){return String(e||"").split("?")[0].replace(/\/+$/,"")||"/"}function i(e=""){let t=n(e);return"/dashboard"===t||l.filter(e=>"/dashboard"!==e).some(e=>{let r,s;return r=n(t),r===(s=n(e))||r.startsWith(`${s}/`)})}},80752:(e,t,r)=>{r.d(t,{default:()=>f});var s=r(95155),a=r(12115),l=r(47650),n=r(14051),i=r.n(n),o=r(93308),d=r(1620),c=r(94027),m=r(40197);r(14932);var u=r(21931),x=r(92542),p=r(81127);let h={en:{name:"English",flag:"\uD83C\uDDFA\uD83C\uDDF8"},vi:{name:"Tiếng Việt",flag:"\uD83C\uDDFB\uD83C\uDDF3"},"zh-CN":{name:"简体中文",flag:"\uD83C\uDDE8\uD83C\uDDF3"},"zh-TW":{name:"繁體中文",flag:"\uD83C\uDDF9\uD83C\uDDFC"},ja:{name:"日本語",flag:"\uD83C\uDDEF\uD83C\uDDF5"},"pt-BR":{name:"Portugu\xeas (BR)",flag:"\uD83C\uDDE7\uD83C\uDDF7"},"pt-PT":{name:"Portugu\xeas (PT)",flag:"\uD83C\uDDF5\uD83C\uDDF9"},ko:{name:"한국어",flag:"\uD83C\uDDF0\uD83C\uDDF7"},es:{name:"Espa\xf1ol",flag:"\uD83C\uDDEA\uD83C\uDDF8"},de:{name:"Deutsch",flag:"\uD83C\uDDE9\uD83C\uDDEA"},fr:{name:"Fran\xe7ais",flag:"\uD83C\uDDEB\uD83C\uDDF7"},he:{name:"עברית",flag:"\uD83C\uDDEE\uD83C\uDDF1"},ar:{name:"العربية",flag:"\uD83C\uDDF8\uD83C\uDDE6"},ru:{name:"Русский",flag:"\uD83C\uDDF7\uD83C\uDDFA"},pl:{name:"Polski",flag:"\uD83C\uDDF5\uD83C\uDDF1"},cs:{name:"Čeština",flag:"\uD83C\uDDE8\uD83C\uDDFF"},nl:{name:"Nederlands",flag:"\uD83C\uDDF3\uD83C\uDDF1"},tr:{name:"T\xfcrk\xe7e",flag:"\uD83C\uDDF9\uD83C\uDDF7"},uk:{name:"Українська",flag:"\uD83C\uDDFA\uD83C\uDDE6"},tl:{name:"Tagalog",flag:"\uD83C\uDDF5\uD83C\uDDED"},id:{name:"Indonesia",flag:"\uD83C\uDDEE\uD83C\uDDE9"},th:{name:"ไทย",flag:"\uD83C\uDDF9\uD83C\uDDED"},hi:{name:"हिन्दी",flag:"\uD83C\uDDEE\uD83C\uDDF3"},bn:{name:"বাংলা",flag:"\uD83C\uDDE7\uD83C\uDDE9"},ur:{name:"اردو",flag:"\uD83C\uDDF5\uD83C\uDDF0"},ro:{name:"Rom\xe2nă",flag:"\uD83C\uDDF7\uD83C\uDDF4"},sv:{name:"Svenska",flag:"\uD83C\uDDF8\uD83C\uDDEA"},it:{name:"Italiano",flag:"\uD83C\uDDEE\uD83C\uDDF9"},el:{name:"Ελληνικά",flag:"\uD83C\uDDEC\uD83C\uDDF7"},hu:{name:"Magyar",flag:"\uD83C\uDDED\uD83C\uDDFA"},fi:{name:"Suomi",flag:"\uD83C\uDDEB\uD83C\uDDEE"},da:{name:"Dansk",flag:"\uD83C\uDDE9\uD83C\uDDF0"},no:{name:"Norsk",flag:"\uD83C\uDDF3\uD83C\uDDF4"}};function b({icon:e,label:t,onClick:r,trailing:a,danger:l}){return(0,s.jsxs)("button",{onClick:r,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${l?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[20px] ${l?"":"text-text-muted"}`,children:e}),(0,s.jsx)("span",{className:"flex-1 text-left",children:t}),a&&(0,s.jsx)("span",{className:"text-base",children:a})]})}function f({onLogout:e}){let[t,r]=(0,a.useState)(!1),[n,i]=(0,a.useState)(!1),[g,y]=(0,a.useState)(!1),[v,j]=(0,a.useState)(!1),[N,w]=(0,a.useState)(""),[k,C]=(0,a.useState)(10),[S,T]=(0,a.useState)(!1),[A,_]=(0,a.useState)("en"),{toggleTheme:I,isDark:M}=(0,d.D)(),{isAdmin:$}=(0,c.s)(),P=(0,a.useRef)(null),E=(0,a.useRef)(null),R=(0,a.useRef)(null);(0,a.useEffect)(()=>{_(function(){if("u"<typeof document)return"en";let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${o.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):"en";return(0,o.QC)(t)}())},[S]),(0,a.useEffect)(()=>{let e=e=>{P.current&&!P.current.contains(e.target)&&r(!1)};if(t)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,a.useEffect)(()=>()=>{E.current&&clearTimeout(E.current),R.current&&clearInterval(R.current)},[]);let O=()=>{E.current&&(clearTimeout(E.current),E.current=null),R.current&&(clearInterval(R.current),R.current=null)},L=()=>{v||(y(!1),w(""),C(10))},z=async()=>{if($&&!v){j(!0),w("");try{let e=await fetch("/api/version/restart",{method:"POST"}),t=await e.json().catch(()=>({}));if(!e.ok||t?.success===!1)throw Error(t?.message||"Restart request failed");O(),C(10),R.current=setInterval(()=>{C(e=>Math.max(0,e-1))},1e3),E.current=setTimeout(()=>{window.location.reload()},1e4)}catch(e){O(),C(10),w(e?.message||"Restart request failed"),j(!1)}}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative",ref:P,children:[(0,s.jsx)("button",{onClick:()=>r(e=>!e),className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5 transition-all",title:"Menu",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),t&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[(0,s.jsx)(b,{icon:"history",label:"Change Log",onClick:()=>{r(!1),i(!0)}}),(0,s.jsx)(b,{icon:"language",label:h[A]?.name||A,trailing:h[A]?.flag||"\uD83C\uDF10",onClick:()=>{r(!1),T(!0)}}),(0,s.jsx)(b,{icon:M?"light_mode":"dark_mode",label:"Theme",onClick:()=>{I(),r(!1)}}),(0,s.jsx)(b,{icon:"logout",label:"Logout",danger:!0,onClick:()=>{r(!1),e()}}),$?(0,s.jsx)(b,{icon:"restart_alt",label:v?"Restarting...":"Restart",danger:!0,onClick:()=>{$&&!v&&(r(!1),w(""),y(!0))}}):null]})]}),g&&"u">typeof document?(0,l.createPortal)((0,s.jsx)(p.default,{isOpen:g,onClose:L,title:"Restart BlueRouter",size:"sm",closeOnOverlay:!v,className:"overflow-hidden",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.default,{variant:"ghost",onClick:L,disabled:v,children:"Cancel"}),(0,s.jsx)(x.default,{variant:"primary",icon:"restart_alt",loading:v,onClick:z,children:v?"Restarting":"Restart now"})]}),children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"rounded-2xl border border-primary/15 bg-primary/10 p-4",children:(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-primary/15 text-primary",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[24px]",children:"restart_alt"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-text-main",children:"Confirm service restart"}),(0,s.jsx)("p",{className:"mt-1 text-sm leading-6 text-text-muted",children:"The dashboard and API gateway may be unavailable for a few seconds while BlueRouter restarts."})]})]})}),N?(0,s.jsxs)("div",{className:"flex gap-2 rounded-xl border border-red-500/20 bg-red-500/10 p-3 text-sm text-red-600 dark:text-red-300",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"error"}),(0,s.jsx)("span",{children:N})]}):null,v?(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-xl border border-border bg-surface-2 px-3 py-2 text-xs font-medium text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px] text-primary",children:"progress_activity"}),"Restart command sent. This page will reload automatically in ",k,"s."]}):null]})}),document.body):null,(0,s.jsx)(m.default,{isOpen:n,onClose:()=>i(!1)}),(0,s.jsx)(u.default,{hideTrigger:!0,isOpen:S,onClose:e=>{T(!1),_(e)}})]})}b.propTypes={icon:i().string.isRequired,label:i().string.isRequired,onClick:i().func.isRequired,trailing:i().node,danger:i().bool},f.propTypes={onLogout:i().func.isRequired}},81127:(e,t,r)=>{r.d(t,{ConfirmModal:()=>d,default:()=>o});var s=r(95155),a=r(12115),l=r(31474),n=r(92542),i=r(97677);function o({isOpen:e,onClose:t,title:r,children:n,footer:d,size:c="md",closeOnOverlay:m=!0,showTrafficLights:u=!0,className:x}){return((0,a.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,a.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t]),e)?(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-[2px] fade-in",onClick:m?t:void 0}),(0,s.jsxs)("div",{className:(0,l.cn)("relative w-full bg-surface","border border-border-subtle","rounded-[14px] shadow-[var(--shadow-elev)]","fade-in",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[c],x),children:[(r||u)&&(0,s.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[u&&(0,s.jsxs)("div",{className:"hidden md:flex items-center gap-2 mr-4 ml-2",children:[(0,s.jsx)(i.default,{text:"Close",position:"top",color:"#FF5F56",children:(0,s.jsx)("button",{onClick:t,"aria-label":"Close",title:"Close",className:"w-4 h-4 rounded-full bg-[#FF5F56] hover:brightness-90 transition-all cursor-pointer flex items-center justify-center group/dot",children:(0,s.jsx)("span",{className:"text-[9px] font-bold text-white opacity-0 group-hover/dot:opacity-100 transition-opacity leading-none",children:"✕"})})}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"})]}),r&&(0,s.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:r})]}),(0,s.jsx)("button",{onClick:t,"aria-label":"Close",className:"md:hidden p-1.5 rounded-[10px] text-text-muted hover:bg-surface-2 hover:text-text-main transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,s.jsx)("div",{className:"p-6 max-h-[calc(85vh-100px)] overflow-y-auto custom-scrollbar",children:n}),d&&(0,s.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-subtle",children:d})]})]}):null}function d({isOpen:e,onClose:t,onConfirm:r,title:a="Confirm",message:l,confirmText:i="Confirm",cancelText:c="Cancel",variant:m="danger",loading:u=!1}){return(0,s.jsx)(o,{isOpen:e,onClose:t,title:a,size:"sm",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.default,{variant:"ghost",onClick:t,disabled:u,children:c}),(0,s.jsx)(n.default,{variant:m,onClick:r,loading:u,children:i})]}),children:(0,s.jsx)("p",{className:"text-text-muted",children:l})})}},84588:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(31474);function l({children:e,title:t,subtitle:r,icon:n,action:i,padding:o="md",hover:d=!1,elev:c=!1,className:m,...u}){return(0,s.jsxs)("div",{className:(0,a.cn)("bg-surface border border-border-subtle",c?"rounded-[14px] shadow-[var(--shadow-elev)]":"rounded-[14px] shadow-[var(--shadow-soft)]",d&&"hover:shadow-[var(--shadow-warm)] hover:border-brand-500/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[o],m),...u,children:[(t||i)&&(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[n&&(0,s.jsx)("div",{className:"p-2 rounded-[10px] bg-bg text-text-muted",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:n})}),(0,s.jsxs)("div",{children:[t&&(0,s.jsx)("h3",{className:"text-text-main font-semibold",children:t}),r&&(0,s.jsx)("p",{className:"text-sm text-text-muted",children:r})]})]}),i]}),e]})}l.Section=function({children:e,className:t,...r}){return(0,s.jsx)("div",{className:(0,a.cn)("p-4 rounded-[10px]","bg-bg border border-border-subtle",t),...r,children:e})},l.Row=function({children:e,className:t,...r}){return(0,s.jsx)("div",{className:(0,a.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50",t),...r,children:e})},l.ListItem=function({children:e,actions:t,className:r,...l}){return(0,s.jsxs)("div",{className:(0,a.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50 transition-colors",r),...l,children:[(0,s.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,s.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:t})]})}},86671:(e,t,r)=>{r.d(t,{default:()=>x});var s=r(95155),a=r(12115),l=r(73321),n=r(65921),i=r(94027),o=r(92622),d=r(74891),c=r(77907);let m=["/dashboard/api-keys","/dashboard/personalcloudprovider","/dashboard/personalquota","/dashboard/analytics","/dashboard/token-saver"];function u({children:e}){let t=(0,l.usePathname)(),r=(0,l.useRouter)(),{isAdmin:n,isMonitorAdmin:o,loading:d}=(0,i.s)(),[x,p]=(0,a.useState)(!1),h=function({pathname:e,isAdmin:t,isMonitorAdmin:r}){return!!t||(r?(0,c.VC)(e):m.some(t=>e===t||e.startsWith(`${t}/`)))}({pathname:t,isAdmin:n,isMonitorAdmin:o});return((0,a.useEffect)(()=>{if(!d){if(!h){p(!0),r.replace(function({isMonitorAdmin:e}){return e?c.Fv:"/dashboard/api-keys"}({isMonitorAdmin:o}));return}p(!1)}},[h,o,d,r]),d)?(0,s.jsxs)("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined mr-2 animate-spin",children:"progress_activity"}),"Đang tải dashboard..."]}):x||!h?(0,s.jsx)("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-text-muted",children:"Đang chuyển hướng..."}):e}function x({children:e}){let[t,r]=(0,a.useState)(!1),c=(0,n.i)(e=>e.notifications),m=(0,n.i)(e=>e.removeNotification),p=(0,l.usePathname)();return(0,s.jsx)(i.Y,{children:(0,s.jsx)(u,{children:(0,s.jsxs)("div",{className:"min-h-screen bg-surface text-text-main",children:[(0,s.jsx)("div",{className:"fixed right-4 top-4 z-[100] w-[min(420px,calc(100vw-2rem))] space-y-2",children:c.map(e=>{var t;let r="success"===(t=e.type)?{wrapper:"border-green-500/30 bg-green-500/10 text-green-600 dark:text-green-400",icon:"check_circle"}:"error"===t?{wrapper:"border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-400",icon:"error"}:"warning"===t?{wrapper:"border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400",icon:"warning"}:{wrapper:"border-blue-500/30 bg-blue-500/10 text-blue-600 dark:text-blue-400",icon:"info"};return(0,s.jsx)("div",{className:`rounded-2xl border px-4 py-3 shadow-lg backdrop-blur ${r.wrapper}`,children:(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:r.icon}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[e.title?(0,s.jsx)("div",{className:"font-semibold",children:e.title}):null,(0,s.jsx)("div",{className:"text-sm opacity-90",children:e.message})]}),e.dismissible?(0,s.jsx)("button",{type:"button",onClick:()=>m(e.id),className:"text-current/70 hover:text-current","aria-label":"Dismiss notification",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})}):null]})},e.id)})}),t?(0,s.jsx)("div",{className:"fixed inset-0 z-40 bg-black/40 lg:hidden",onClick:()=>r(!1)}):null,(0,s.jsxs)("div",{className:"flex min-h-screen",children:[(0,s.jsx)("div",{className:"hidden lg:block",children:(0,s.jsx)(o.default,{})}),(0,s.jsx)("div",{className:`fixed inset-y-0 left-0 z-50 transform transition-transform lg:hidden ${t?"translate-x-0":"-translate-x-full"}`,children:(0,s.jsx)(o.default,{onClose:()=>r(!1)})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)(d.default,{onMenuClick:()=>r(!0)},p),(0,s.jsx)("main",{className:"mx-auto w-full max-w-[1600px] px-4 py-6 md:px-6 lg:px-8",children:e})]})]})]})})})}},90085:(e,t,r)=>{r.d(t,{A:()=>i});var s=r(1934),a=r(31692),l=r(90620);function n(e){let t=document.documentElement,r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";"dark"===("system"===e?r:e)?t.classList.add("dark"):t.classList.remove("dark")}let i=(0,s.v)((0,a.Zr)((e,t)=>({theme:l.B2.defaultTheme,setTheme:t=>{e({theme:t}),n(t)},toggleTheme:()=>{let r="dark"===t().theme?"light":"dark";e({theme:r}),n(r)},initTheme:()=>{n(t().theme)}}),{name:l.B2.storageKey}))},90882:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497),o=r(11059);function d({isOpen:e,provider:t,providerInfo:r,onSuccess:l,onClose:n,oauthMeta:c,idcConfig:m,connectionScope:u="system"}){let[x,p]=(0,a.useState)("waiting"),[h,b]=(0,a.useState)(null),[f,g]=(0,a.useState)(""),[y,v]=(0,a.useState)(null),[j,N]=(0,a.useState)(!1),[w,k]=(0,a.useState)(null),[C,S]=(0,a.useState)(!1),T=(0,a.useRef)(null),A=(0,a.useRef)(!1),{copied:_,copy:I}=(0,o.C)(),[M,$]=(0,a.useState)(!1),[P,E]=(0,a.useState)("/callback?code=..."),R=(0,a.useRef)(!1);(0,a.useEffect)(()=>{$("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),E(`${window.location.origin}/callback?code=...`)},[]);let O=(0,a.useCallback)(async(e,r)=>{if(h)try{let s=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:h.redirectUri,codeVerifier:h.codeVerifier,state:r,...c?{meta:c}:{},..."personal"===u?{connectionScope:"personal"}:{}})}),a=await s.json();if(!s.ok)throw Error(a.error);p("success"),l?.()}catch(e){v(e.message),p("error")}},[h,t,l,c,u]),L=(0,a.useCallback)(async e=>{if(h?.state)try{let t=await fetch("/api/oauth/xai/manual-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,state:h.state})}),r=await t.json();if(!t.ok)throw Error(r.error);p("success"),l?.()}catch(e){v(e.message),p("error")}},[h,l]),z=(0,a.useCallback)(async(e,r,s,a)=>{A.current=!1,S(!0);for(let n=0;n<60;n++){if(A.current){console.log("[OAuthModal] Polling aborted"),S(!1);return}if(await new Promise(e=>setTimeout(e,1e3*s)),A.current){console.log("[OAuthModal] Polling aborted after sleep"),S(!1);return}try{let n=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:r,extraData:a,..."personal"===u?{connectionScope:"personal"}:{}})}),i=await n.json();if(i.success){A.current=!0,p("success"),S(!1),l?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(s=Math.min(s+5,30))}catch(e){v(e.message),p("error"),S(!1);return}}v("Authorization timeout"),p("error"),S(!1)},[t,l,u]),q=(0,a.useCallback)(async()=>{if(t)try{let e;if(v(null),["github","qwen","kiro","kimi-coding","kilocode","codebuddy"].includes(t)){N(!0),p("waiting");let e=new URL(`/api/oauth/${t}/device-code`,window.location.origin);"personal"===u&&e.searchParams.set("connection_scope","personal"),"kiro"===t&&m?.startUrl&&(e.searchParams.set("start_url",m.startUrl),m.region&&e.searchParams.set("region",m.region),e.searchParams.set("auth_method","idc"));let r=await fetch(e.toString()),s=await r.json();if(!r.ok)throw Error(s.error);k(s);let a=s.verification_uri_complete||s.verification_uri;a&&window.open(a,"_blank","noopener,noreferrer");let l="kiro"===t?{_clientId:s._clientId,_clientSecret:s._clientSecret,_region:s._region,_authMethod:s._authMethod,_startUrl:s._startUrl}:null;z(s.device_code,s.codeVerifier,s.interval||5,l);return}let r=window.location.port||("https:"===window.location.protocol?"443":"80");e="codex"===t?"http://localhost:1455/auth/callback":"xai"===t?"http://127.0.0.1:56121/callback":M?`${window.location.origin}/callback`:"http://localhost:54545/callback";let s=new URL(`/api/oauth/${t}/authorize`,window.location.origin);s.searchParams.set("redirect_uri",e),"personal"===u&&s.searchParams.set("connection_scope","personal"),c&&Object.entries(c).forEach(([e,t])=>{t&&s.searchParams.set(e,t)});let a=await fetch(s.toString()),l=await a.json();if(!a.ok)throw Error(l.error);let n=!1,i=!1;if("codex"===t)try{let t=new URL("/api/oauth/codex/start-proxy",window.location.origin);t.searchParams.set("app_port",r),t.searchParams.set("state",l.state),t.searchParams.set("code_verifier",l.codeVerifier),t.searchParams.set("redirect_uri",e),"personal"===u&&t.searchParams.set("connection_scope","personal");let s=await fetch(t.toString()),a=await s.json();n=a.success,i=!!a.serverSide}catch{n=!1}let o=!1,d=!1;if("xai"===t)try{let t=new URL("/api/oauth/xai/start-proxy",window.location.origin);t.searchParams.set("app_port",r),t.searchParams.set("state",l.state),t.searchParams.set("code_verifier",l.codeVerifier),t.searchParams.set("redirect_uri",e);let s=await fetch(t.toString()),a=await s.json();if(o=a.success,d=!!a.serverSide,!o&&"port_busy"===a.reason)throw Error("Port 56121 in use; close the conflicting process and retry")}catch(e){if(e?.message)throw e;o=!1}b({...l,redirectUri:e,codexServerSide:i,xaiServerSide:d}),"codex"===t&&n||"xai"===t&&o||M&&"codex"!==t&&"xai"!==t?(p("waiting"),T.current=window.open(l.authUrl,"oauth_popup","width=600,height=700"),T.current||p("input")):(p("input"),window.open(l.authUrl,"_blank"))}catch(e){v(e.message),p("error")}},[t,M,z,c,m,u]);(0,a.useEffect)(()=>{e&&t?(b(null),g(""),v(null),N(!1),k(null),S(!1),A.current=!1,q()):e||(A.current=!0,"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}))},[e,t,q]),(0,a.useEffect)(()=>{let e=h?.codexServerSide?"codex":h?.xaiServerSide?"xai":null;if(!e||!h?.state||R.current)return;let t=!1,r=0,s=async()=>{if(!t&&!R.current){r+=1;try{let r=await fetch(`/api/oauth/${e}/poll-status?state=${encodeURIComponent(h.state)}`),s=await r.json();if(t||R.current)return;if("done"===s.status){R.current=!0,p("success"),l?.();return}if("error"===s.status){R.current=!0,v(s.error||"Authentication failed"),p("error");return}}catch{}if(r>=200){R.current=!0,v("Authentication timeout"),p("error");return}setTimeout(s,1500)}};return setTimeout(s,1500),()=>{t=!0}},[h,l]),(0,a.useEffect)(()=>{let e;if(!h)return;R.current=!1;let t=async e=>{if(R.current)return;let{code:t,state:r,error:s,errorDescription:a}=e;if(s){R.current=!0,v(a||s),p("error");return}t&&(R.current=!0,await O(t,r))},r=e=>{let r=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),s=e.origin===window.location.origin;(r||s)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",r);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let s=e=>{if("oauth_callback"===e.key&&e.newValue)try{let r=JSON.parse(e.newValue);t(r),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",s);try{let e=localStorage.getItem("oauth_callback");if(e){let r=JSON.parse(e);r.timestamp&&Date.now()-r.timestamp<3e4&&t(r),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",r),window.removeEventListener("storage",s),e&&e.close()}},[h,O]);let U=async()=>{try{v(null);let e=f.trim();if(e.startsWith("eyJ")&&e.includes("."))return void await O(e,null);if("xai"===t&&e&&!e.includes("://")&&!e.includes("?")&&!e.includes("code="))return void await L(e);let r=new URL(e),s=r.searchParams.get("code"),a=r.searchParams.get("state"),l=r.searchParams.get("error");if(l)throw Error(r.searchParams.get("error_description")||l);if(!s)throw Error("xai"===t?"Paste the callback URL or copied xAI code":"No authorization code found in URL");await O(s,a)}catch(e){v(e.message),p("error")}},D=(0,a.useCallback)(()=>{"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}),n()},[n,t]);if(!t||!r)return null;let F="xai"===t,W=w?.verification_uri_complete||w?.verification_uri||"",K=F?"Connect Grok Build OAuth":`Connect ${r.name}`;return(0,s.jsx)(i.aF,{isOpen:e,title:K,onClose:D,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[("waiting"===x||"input"===x)&&!j&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-lg bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,s.jsx)("span",{className:"text-sm",children:F?"Waiting for Grok Build OAuth…":"Waiting for popup authorization…"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 my-1",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Or paste callback URL manually"}),(0,s.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 1: Open this ",F?"Grok Build OAuth URL":"URL"," in your browser"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.pd,{value:h?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===_?"check":"content_copy",onClick:()=>I(h?.authUrl,"auth_url"),disabled:!h?.authUrl,children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 2: Paste the ","xai"===t?"callback URL or copied code":"callback URL"," here"]}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"xai"===t?"If xAI shows a code instead of redirecting, paste that code here.":"After authorization, copy the full URL from your browser."}),(0,s.jsx)(i.pd,{value:f,onChange:e=>g(e.target.value),placeholder:F?"http://127.0.0.1:56121/callback?code=... or copied code":P,className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:U,fullWidth:!0,disabled:!f,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"waiting"===x&&j&&w&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"text-center py-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,s.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("code",{className:"flex-1 text-sm break-all",children:W}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"login_url"===_?"check":"content_copy",onClick:()=>I(W,"login_url"),disabled:!W}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(W,"_blank","noopener,noreferrer"),disabled:!W,children:"Open"})]})]}),(0,s.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,s.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:w.user_code}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"user_code"===_?"check":"content_copy",onClick:()=>I(w.user_code,"user_code")})]})]})]}),C&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"success"===x&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",r.name," account has been connected."]}),(0,s.jsx)(i.$n,{onClick:D,fullWidth:!0,children:"Done"})]}),"error"===x&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:y}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:q,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().string,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired,oauthMeta:n().object,idcConfig:n().shape({startUrl:n().string,region:n().string}),connectionScope:n().oneOf(["system","personal"])}},91450:(e,t,r)=>{r.d(t,{default:()=>i});var s=r(95155),a=r(14051),l=r.n(a),n=r(38587);function i({children:e}){return(0,s.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,s.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,s.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,s.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,s.jsx)(n.default,{variant:"card"})}),(0,s.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}i.propTypes={children:l().node.isRequired}},92173:(e,t,r)=>{r.d(t,{default:()=>c});var s=r(95155),a=r(98500),l=r.n(a),n=r(90620);let i=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,s.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,s.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,s.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,s.jsx)("div",{className:"size-6 text-primary",children:(0,s.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,s.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,s.jsx)("span",{className:"text-xl font-bold text-text-main",children:n.vQ.name})]}),(0,s.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,s.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",n.vQ.name," Inc. All rights reserved."]}),(0,s.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,s.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,s.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,r)=>{r.d(t,{default:()=>i});var s=r(95155),a=r(31474);let l={primary:"bg-brand-500 hover:bg-brand-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",secondary:"bg-surface-2 hover:bg-surface-3 text-text-main border border-border disabled:opacity-50",outline:"border border-border text-text-main hover:bg-surface-2 hover:border-brand-500/40",ghost:"text-text-muted hover:bg-surface-2 hover:text-text-main",danger:"bg-red-500 hover:bg-red-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",success:"bg-green-600 hover:bg-green-700 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted"},n={sm:"h-7 px-3 text-xs rounded-[8px]",md:"h-9 px-4 text-sm rounded-[10px]",lg:"h-11 px-6 text-sm rounded-[10px]"};function i({children:e,variant:t="primary",size:r="md",icon:o,iconRight:d,disabled:c=!1,loading:m=!1,fullWidth:u=!1,className:x,...p}){return(0,s.jsxs)("button",{className:(0,a.cn)("inline-flex items-center justify-center gap-2 font-semibold transition-all duration-150 ease-out cursor-pointer","active:scale-[0.97] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",l[t],n[r],u&&"w-full",x),disabled:c||m,...p,children:[m?(0,s.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}):o?(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:o}):null,e,d&&!m&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:d})]})}},92622:(e,t,r)=>{r.d(t,{default:()=>N});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(98500),o=r.n(i),d=r(73321),c=r(90620),m=r(92542),u=r(81127),x=r(77907),p=r(94027),h=r(44656),b=r(31474);let f=[{href:"/dashboard/endpoint",label:"Endpoint",icon:"api"},{href:"/dashboard/api-keys",label:"API Keys",icon:"vpn_key"},{href:"/dashboard/providers",label:"Providers",icon:"dns"},{href:"/dashboard/personalcloudprovider",label:"Personal OAuth",icon:"cloud_sync"},{href:"/dashboard/personalquota",label:"Personal Quota",icon:"data_usage"},{href:"/dashboard/combos",label:"Combos",icon:"layers"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/analytics",label:"Analytics",icon:"monitoring"},{href:"/dashboard/token-saver",label:"Token Saver",icon:"compress"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"},{href:"/dashboard/media-providers/web",label:"Media / Web",icon:"perm_media",advanced:!0},{href:"/dashboard/mitm",label:"AI Traffic Gateway",icon:"security",advanced:!0},{href:"/dashboard/prompt-logs",label:"Prompt Logs",icon:"manage_search"},{href:"/dashboard/cli-tools",label:"CLI Tools",icon:"terminal",advanced:!0},{href:"/dashboard/proxy-pools",label:"Proxy Pools",icon:"lan",advanced:!0},{href:"/dashboard/skills",label:"Skills",icon:"extension",advanced:!0},{href:"/dashboard/profile",label:"Settings",icon:"settings"},{href:"/dashboard/console-log",label:"Console Log",icon:"terminal"},{href:"/dashboard/translator",label:"Translator",icon:"translate",advanced:!0}],g=[...x.SI],y=[{href:"/dashboard/api-keys",label:"API Keys",icon:"vpn_key"},{href:"/dashboard/personalcloudprovider",label:"Personal OAuth",icon:"cloud_sync"},{href:"/dashboard/personalquota",label:"Personal Quota",icon:"data_usage"},{href:"/dashboard/analytics",label:"Analytics",icon:"monitoring"},{href:"/dashboard/token-saver",label:"Token Saver",icon:"compress"}],v=c.h0?.installCmdLatest||"npm install -g @jheavenknows/bluerouter@latest";function j({href:e,label:t,icon:r,active:a,onClick:l}){return(0,s.jsxs)(o(),{href:e,onClick:l,className:(0,b.cn)("flex items-center gap-3 rounded-xl px-3 py-2.5 text-sm font-medium transition-colors",a?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface hover:text-text-main"),children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:r}),(0,s.jsx)("span",{className:"truncate",children:t})]})}function N({onClose:e}){let t=(0,d.usePathname)(),r=(0,d.useRouter)(),{displayName:l,loginMethod:n,isAdmin:i,isMonitorAdmin:o,isAiGatewaysMonitor:x}=(0,p.s)(),{logoUrl:b,siteShortName:w,siteTitle:k}=(0,h.useBranding)(),C=w||k||"Blue Router",[S,T]=(0,a.useState)(null),[A,_]=(0,a.useState)(!1),[I,M]=(0,a.useState)(!1),[$,P]=(0,a.useState)(!1),[E,R]=(0,a.useState)(""),[O,L]=(0,a.useState)(!0),z=()=>e?.();(0,a.useEffect)(()=>{if(!i)return void T(null);let e=!1;return fetch("/api/version",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>{!e&&t?.hasUpdate&&T(t)}).catch(()=>{}),()=>{e=!0}},[i]),(0,a.useEffect)(()=>{if(!i)return;let e=!1,t=e=>{L(e?.detail?.visible!==!1)};return fetch("/api/settings",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&L(!1!==t.sidebarAdvancedToolsVisible)}).catch(()=>{}),window.addEventListener("bluerouter:sidebar-advanced-tools",t),()=>{e=!0,window.removeEventListener("bluerouter:sidebar-advanced-tools",t)}},[i]),(0,a.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>M(!1),2e3);return()=>clearTimeout(e)},[I]);let q=async()=>{R("");try{return await navigator.clipboard.writeText(S?.installCommand||v),M(!0),!0}catch(e){return R(e?.message||"Could not copy update command. Please copy it manually."),!1}},U=async()=>{if(!$&&await q()){P(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch{}}},D=async()=>{try{await fetch("/api/auth/logout",{method:"POST"})}catch{}r.push("/login"),r.refresh()},F=(i?f:o?g:y).filter(e=>!e.advanced||O),W=i?"Admin":o?"Monitor Admin":x?"AI Gateways Monitor":"User";return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("aside",{className:"flex h-full w-64 flex-col border-r border-border bg-background p-3",children:[(0,s.jsxs)("div",{className:"mb-4 rounded-2xl bg-primary/10 p-4 text-primary",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[b?(0,s.jsx)("img",{src:b,alt:C,className:"h-8 w-8 rounded-md object-contain"}):(0,s.jsx)("span",{className:"material-symbols-outlined text-[28px]",children:"hub"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate font-bold text-text-main",children:C}),(0,s.jsxs)("div",{className:"text-xs text-text-muted",children:["v",c.vQ?.version||"local"]})]})]}),i&&S?(0,s.jsxs)("button",{type:"button",onClick:()=>{R(""),M(!1),_(!0)},className:"mt-3 flex w-full items-center justify-between gap-2 rounded-xl border border-amber-400/40 bg-amber-500/10 px-3 py-2 text-left text-xs font-semibold text-amber-700 transition hover:bg-amber-500/15 dark:text-amber-300",title:`New BlueRouter version available: v${S.latestVersion}`,children:[(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"system_update_alt"}),(0,s.jsxs)("span",{className:"truncate",children:["New v",S.latestVersion]})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_right"})]}):null,l?(0,s.jsxs)("div",{className:"mt-4 flex items-start gap-2 text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"person"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate text-sm font-semibold text-text-main",children:l}),(0,s.jsxs)("div",{className:"text-xs",children:[W,n?` \xb7 ${n}`:""]})]})]}):null]}),(0,s.jsx)("div",{className:"mb-4 grid gap-2 border-b border-border pb-4",children:(0,s.jsxs)("button",{type:"button",onClick:D,className:"flex w-full items-center justify-between gap-3 rounded-2xl border border-border bg-surface/70 px-3 py-2.5 text-left text-sm font-semibold text-text-muted transition hover:border-border-subtle hover:bg-surface hover:text-text-main",children:[(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"logout"}),(0,s.jsx)("span",{className:"truncate",children:"Logout"})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px] opacity-60",children:"chevron_right"})]})}),(0,s.jsx)("nav",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto pr-1",children:F.map(e=>{var r;return(0,s.jsx)(j,{href:e.href,label:e.label,icon:e.icon,active:"/dashboard/endpoint"===(r=e.href)?"/dashboard"===t||t.startsWith("/dashboard/endpoint"):t===r||t.startsWith(`${r}/`),onClick:z},e.href)})})]}),(0,s.jsx)(u.default,{isOpen:A,onClose:()=>{$||_(!1)},title:"Update BlueRouter",size:"md",closeOnOverlay:!$,footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.default,{type:"button",variant:"ghost",onClick:()=>_(!1),disabled:$,children:"Cancel"}),(0,s.jsx)(m.default,{type:"button",variant:"secondary",onClick:q,disabled:$,children:I?"Copied":"Copy command"}),(0,s.jsx)(m.default,{type:"button",variant:"primary",onClick:U,loading:$,children:"Copy & shutdown"})]}),children:(0,s.jsxs)("div",{className:"space-y-4 text-sm text-text-muted",children:[(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-surface p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{children:"Current version"}),(0,s.jsxs)("span",{className:"font-mono font-semibold text-text-main",children:["v",S?.currentVersion||c.vQ?.version||"local"]})]}),(0,s.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{children:"Latest npm version"}),(0,s.jsxs)("span",{className:"font-mono font-semibold text-primary",children:["v",S?.latestVersion||"unknown"]})]}),(0,s.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{children:"NPM package"}),(0,s.jsx)("span",{className:"truncate font-mono text-xs text-text-main",children:S?.packageName||c.h0?.npmPackageName||"@jheavenknows/bluerouter"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"mb-2 font-medium text-text-main",children:"Install command"}),(0,s.jsx)("pre",{className:"overflow-x-auto rounded-xl border border-border bg-bg-subtle px-3 py-2 font-mono text-xs text-text-main",children:S?.installCommand||v})]}),(0,s.jsxs)("ol",{className:"list-decimal space-y-1 pl-5",children:[(0,s.jsxs)("li",{children:["Click ",(0,s.jsx)("span",{className:"font-semibold text-text-main",children:"Copy & shutdown"}),"."]}),(0,s.jsx)("li",{children:"Paste the command into the server terminal and run it."}),(0,s.jsx)("li",{children:"Start BlueRouter again after npm finishes installing."})]}),E?(0,s.jsx)("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 px-3 py-2 text-red-600 dark:text-red-300",children:E}):null,$?(0,s.jsx)("div",{className:"rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300",children:"Command copied. BlueRouter is shutting down so you can run the npm update command safely."}):null]})})]})}j.propTypes={href:n().string.isRequired,label:n().string.isRequired,icon:n().string.isRequired,active:n().bool,onClick:n().func},N.propTypes={onClose:n().func}},93308:(e,t,r)=>{r.d(t,{CL:()=>l,QC:()=>n,Xn:()=>a,YZ:()=>s});let s=["en","vi","zh-CN","zh-TW","ja","pt-BR","pt-PT","ko","es","de","fr","he","ar","ru","pl","cs","nl","tr","uk","tl","id","th","hi","bn","ur","ro","sv","it","el","hu","fi","da","no"],a="en",l="locale";function n(e){return"zh"===e||"zh-CN"===e?"zh-CN":"en"===e?"en":"vi"===e?"vi":"zh-TW"===e?"zh-TW":"ja"===e?"ja":"pt-BR"===e?"pt-BR":"pt-PT"===e?"pt-PT":"ko"===e?"ko":"es"===e?"es":"de"===e?"de":"fr"===e?"fr":"he"===e?"he":"ar"===e?"ar":"ru"===e?"ru":"pl"===e?"pl":"cs"===e?"cs":"nl"===e?"nl":"tr"===e?"tr":"uk"===e?"uk":"tl"===e?"tl":"id"===e?"id":"th"===e?"th":"hi"===e?"hi":"bn"===e?"bn":"ur"===e?"ur":"ro"===e?"ro":"sv"===e?"sv":"it"===e?"it":"el"===e?"el":"hu"===e?"hu":"fi"===e?"fi":"da"===e?"da":"no"===e?"no":a}},94027:(e,t,r)=>{r.d(t,{Y:()=>o,s:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l);let i=(0,a.createContext)(null);function o({children:e}){let[t,r]=(0,a.useState)(null),[l,n]=(0,a.useState)(!0),[d,c]=(0,a.useState)(""),m=(0,a.useCallback)(async()=>{n(!0),c("");try{let e=await fetch("/api/auth/status",{cache:"no-store"}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t?.error||"Kh\xf4ng tải được trạng th\xe1i đăng nhập");return r(t||{}),t||{}}catch(e){return c(e?.message||"Kh\xf4ng tải được trạng th\xe1i đăng nhập"),r({}),{}}finally{n(!1)}},[]);(0,a.useEffect)(()=>{let e=!1;return(async()=>{n(!0),c("");try{let t=await fetch("/api/auth/status",{cache:"no-store"}),s=await t.json().catch(()=>({}));if(e)return;if(!t.ok)throw Error(s?.error||"Kh\xf4ng tải được trạng th\xe1i đăng nhập");r(s||{})}catch(t){e||(c(t?.message||"Kh\xf4ng tải được trạng th\xe1i đăng nhập"),r({}))}finally{e||n(!1)}})(),()=>{e=!0}},[]);let u=(0,a.useMemo)(()=>{let e,r,s,a,l;return r=(e=t&&"object"==typeof t?t:{}).displayName||e.oidcName||e.oidcEmail||e.userId||"",s=!0===e.isAdmin,a=!0===e.isMonitorAdmin,l=!0===e.isAiGatewaysMonitor,{status:e,displayName:r,userId:e.userId||"",loginMethod:e.loginMethod||"",role:e.role||"guest",isAdmin:s,isMonitorAdmin:a,isAiGatewaysMonitor:l,canManageApiKeys:!0===e.canManageApiKeys||s||a,canUseMonitorAdminTabs:!0===e.canUseMonitorAdminTabs||s||a,canViewAllAnalytics:!0===e.canViewAllAnalytics||s||a||l}},[t]),x=(0,a.useMemo)(()=>({...u,loading:l,error:d,reload:m}),[u,l,d,m]);return(0,s.jsx)(i.Provider,{value:x,children:e})}function d(){let e=(0,a.useContext)(i);return e||{status:{},displayName:"",userId:"",loginMethod:"",role:"admin",isAdmin:!0,isMonitorAdmin:!1,isAiGatewaysMonitor:!1,canManageApiKeys:!0,canUseMonitorAdminTabs:!0,canViewAllAnalytics:!0,loading:!1,error:"",reload:async()=>({})}}o.propTypes={children:n().node}},94230:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497),o=r(11059);function d({isOpen:e,provider:t,onSuccess:r,onClose:l}){let[n,c]=(0,a.useState)("loading"),[m,u]=(0,a.useState)(""),[x,p]=(0,a.useState)(null),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)(null),{copied:y,copy:v}=(0,o.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{g(null),c("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),r=await e.json();if(!e.ok)throw Error(r.error);p(r),u(r.authUrl),c("input"),window.open(r.authUrl,"_blank")}catch(e){g(e.message),c("error")}})()},[e,t]);let j=async()=>{try{let e;g(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let s=e.searchParams.get("code");e.searchParams.get("state");let a=e.searchParams.get("error");if(a)throw Error(e.searchParams.get("error_description")||a);if(!s)throw Error("No authorization code found in URL");let l=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:s,codeVerifier:x.codeVerifier,provider:t})}),n=await l.json();if(!l.ok)throw Error(n.error);c("success"),r?.()}catch(e){g(e.message),c("error")}},N="google"===t?"Google":"GitHub";return(0,s.jsx)(i.aF,{isOpen:e,title:`Connect Kiro via ${N}`,onClose:l,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",N," authentication"]})]}),"input"===n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.pd,{value:m,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===y?"check":"content_copy",onClick:()=>v(m,"auth_url"),children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,s.jsx)(i.pd,{value:h,onChange:e=>b(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:j,fullWidth:!0,disabled:!h,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",N," has been connected."]}),(0,s.jsx)(i.$n,{onClick:l,fullWidth:!0,children:"Done"})]}),"error"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:f}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:()=>c("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().oneOf(["google","github"]).isRequired,onSuccess:n().func,onClose:n().func.isRequired}},95088:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497);let o="https://gitlab.com";function d({isOpen:e,providerInfo:t,onSuccess:r,onClose:l}){let n,[c,m]=(0,a.useState)(null),[u,x]=(0,a.useState)(o),[p,h]=(0,a.useState)(""),[b,f]=(0,a.useState)(""),[g,y]=(0,a.useState)(""),[v,j]=(0,a.useState)(!1),[N,w]=(0,a.useState)(null),[k,C]=(0,a.useState)(!1),[S,T]=(0,a.useState)(null),A=()=>{m(null),x(o),h(""),f(""),y(""),w(null),j(!1),C(!1),T(null),l()},_=async()=>{if(!g.trim())return void w("Personal Access Token is required");j(!0),w(null);try{let e=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:g.trim(),baseUrl:u.trim()||o})}),t=await e.json();if(!e.ok)throw Error(t.error||"Authentication failed");r?.(),A()}catch(e){w(e.message)}finally{j(!1)}};return e?k&&S?(0,s.jsx)(i.LF,{isOpen:!0,provider:"gitlab",providerInfo:t,oauthMeta:S,onSuccess:()=>{r?.(),A()},onClose:()=>{C(!1),T(null)}}):(0,s.jsx)(i.aF,{isOpen:e,title:"Connect GitLab Duo",onClose:A,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[!c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("button",{onClick:()=>m("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,s.jsxs)("button",{onClick:()=>m("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:(n=window.location.port||("https:"===window.location.protocol?"443":"80"),`http://localhost:${n}/callback`)})]}),(0,s.jsx)(i.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(i.pd,{label:"Client ID",value:p,onChange:e=>h(e.target.value),placeholder:"Your OAuth application client ID"}),(0,s.jsx)(i.pd,{label:"Client Secret (optional for PKCE)",value:b,onChange:e=>f(e.target.value),placeholder:"Leave empty for public PKCE app"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:()=>{p.trim()?(w(null),T({baseUrl:u.trim()||o,clientId:p.trim(),clientSecret:b.trim()}),C(!0)):w("Client ID is required")},fullWidth:!0,disabled:!p.trim(),children:"Authorize"}),(0,s.jsx)(i.$n,{onClick:()=>{m(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,s.jsx)(i.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(i.pd,{label:"Personal Access Token",value:g,onChange:e=>y(e.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:_,fullWidth:!0,disabled:!g.trim()||v,loading:v,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:()=>{m(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}d.propTypes={isOpen:n().bool.isRequired,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired}},96748:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497);let o="https://api.openai.com/v1";function d({isOpen:e,onClose:t,onCreated:r,onSaved:l,node:n}){let c=!!n,[m,u]=(0,a.useState)({name:"",prefix:"",baseUrl:o}),[x,p]=(0,a.useState)(!1),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)(""),[y,v]=(0,a.useState)(!1),[j,N]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(N(null),b(""),g(""),c?u({name:n.name||"",prefix:n.prefix||"",baseUrl:n.baseUrl||o}):u({name:"",prefix:"",baseUrl:o}))},[e,c,n]);let w=async()=>{if(m.name.trim()&&m.prefix.trim()&&m.baseUrl.trim()){p(!0);try{let e=c?`/api/provider-nodes/${n.id}`:"/api/provider-nodes",t=c?"PUT":"POST",s={name:m.name,prefix:m.prefix,baseUrl:m.baseUrl};c||(s.type="custom-embedding");let a=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),i=await a.json();a.ok&&(c?l?.(i.node):r?.(i.node))}catch(e){console.log("Error saving custom embedding node:",e)}finally{p(!1)}}},k=async()=>{v(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:m.baseUrl,apiKey:h,type:"custom-embedding",modelId:f.trim()||void 0})}),t=await e.json();N(t)}catch{N({valid:!1,error:"Network error"})}finally{v(!1)}};return(0,s.jsx)(i.aF,{isOpen:e,title:c?"Edit Custom Embedding":"Add Custom Embedding",onClose:t,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(i.pd,{label:"Name",value:m.name,onChange:e=>u({...m,name:e.target.value}),placeholder:"Voyage AI",hint:"Required. A friendly label for this embedding provider."}),(0,s.jsx)(i.pd,{label:"Prefix",value:m.prefix,onChange:e=>u({...m,prefix:e.target.value}),placeholder:"voyage",hint:"Required. Used as the provider prefix for model IDs (e.g. voyage/voyage-3)."}),(0,s.jsx)(i.pd,{label:"Base URL",value:m.baseUrl,onChange:e=>u({...m,baseUrl:e.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"Most embedding APIs are OpenAI-compatible: Voyage, Cohere, Jina, Mistral, Together..."}),(0,s.jsx)(i.pd,{label:"API Key (for Check)",type:"password",value:h,onChange:e=>b(e.target.value)}),(0,s.jsx)(i.pd,{label:"Model ID (for Check)",value:f,onChange:e=>g(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",hint:"Required for validation. Will send a test embeddings request."}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(i.$n,{onClick:k,disabled:!h||!f.trim()||y||!m.baseUrl.trim(),variant:"secondary",children:y?"Checking...":"Check"}),(()=>{if(!j)return null;let{valid:e,error:t,dimensions:r}=j;return e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Ex,{variant:"success",children:"Valid"}),r&&(0,s.jsxs)("span",{className:"text-sm text-text-muted",children:[r," dims"]})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)(i.Ex,{variant:"error",children:"Invalid"}),t&&(0,s.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:w,fullWidth:!0,disabled:!m.name.trim()||!m.prefix.trim()||!m.baseUrl.trim()||x,children:x?c?"Saving...":"Creating...":c?"Save":"Create"}),(0,s.jsx)(i.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}d.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func,onSaved:n().func,node:n().shape({id:n().string,name:n().string,prefix:n().string,baseUrl:n().string})}},97677:(e,t,r)=>{r.d(t,{default:()=>a});var s=r(95155);function a({text:e,children:t,position:r="top",color:l}){let n=l?"":"bg-gray-900";return(0,s.jsxs)("div",{className:"relative inline-flex group",children:[t,(0,s.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[r]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${n} text-white opacity-0 group-hover:opacity-100 transition-opacity duration-150 whitespace-normal`,style:l?{backgroundColor:l}:{},children:e})]})}},98542:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(31474);function l({checked:e=!1,onChange:t,label:r,description:n,disabled:i=!1,size:o="md",className:d}){let c={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,s.jsxs)("div",{className:(0,a.cn)("flex items-center gap-3",i&&"opacity-50 cursor-not-allowed",d),children:[(0,s.jsx)("button",{type:"button",role:"switch","aria-checked":e,disabled:i,onClick:()=>{!i&&t&&t(!e)},className:(0,a.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-2 focus:ring-brand-500/30",e?"bg-brand-500":"bg-surface-3",c[o].track,i&&"cursor-not-allowed"),children:(0,s.jsx)("span",{className:(0,a.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",e?c[o].translate:"translate-x-0.5",c[o].thumb,"mt-0.5")})}),(r||n)&&(0,s.jsxs)("div",{className:"flex flex-col",children:[r&&(0,s.jsx)("span",{className:"text-sm font-medium text-text-main",children:r}),n&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:n})]})]})}}}]);
10
+ `,children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[f.includes(e.value)&&!r&&(0,s.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,s.jsxs)(s.Fragment,{children:[e.name,(0,s.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"})]}):e.name]})},e.value)})})]},e)),0===Object.keys(D).length&&0===U.length&&(0,s.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,s.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})]})}):null}u.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onSelect:n().func.isRequired,onDeselect:n().func,selectedModel:n().string,activeProviders:n().arrayOf(n().shape({provider:n().string.isRequired})),title:n().string,modelAliases:n().object,kindFilter:n().string,addedModelValues:n().arrayOf(n().string),closeOnSelect:n().bool,personalOnly:n().bool,extraModels:n().arrayOf(n().string)}},73006:(e,t,r)=>{r.d(t,{FE:()=>u,Tl:()=>d,wn:()=>x});var s=r(93308);let a={},l=s.Xn,n=[];function i(){if("u"<typeof document)return s.Xn;let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${s.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):s.Xn;return(0,s.QC)(t)}async function o(e){if("en"===e){a={};return}try{let t=await fetch(`/i18n/literals/${e}.json`);a=await t.json()}catch(e){console.error("Failed to load translations:",e),a={}}}function d(e){if(!e||"string"!=typeof e)return e;let t=e.trim();return t&&"en"!==l&&a[t]||e}function c(e){if(!e.nodeValue||!e.nodeValue.trim())return;let t=e.parentElement;if(!t)return;let r=t;for(;r;){if(r.hasAttribute&&r.hasAttribute("data-i18n-skip"))return;r=r.parentElement}if(["script","style","code","pre","colgroup","table","thead","tbody","tfoot","tr","select","datalist","optgroup"].includes(t.tagName?.toLowerCase()))return;e._originalText||(e._originalText=e.nodeValue);let s=d(e._originalText);s!==e.nodeValue&&(e.nodeValue=s)}function m(e){let t;if(!e)return;let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),s=[];for(;t=r.nextNode();)s.push(t);s.forEach(c)}async function u(){l=i(),await o(l),m(document.body),new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE?m(e):e.nodeType===Node.TEXT_NODE&&c(e)})})}).observe(document.body,{childList:!0,subtree:!0})}async function x(){l=i(),await o(l),n.forEach(e=>e()),m(document.body)}},73579:(e,t,r)=>{r.d(t,{default:()=>j});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(81127),o=r(11910),d=r(92542),c=r(56061),m=r(52679),u=r(90620),x=r(12494);let p=[0,1,2,3,4,5,6],h=[{value:1,label:"T2"},{value:2,label:"T3"},{value:3,label:"T4"},{value:4,label:"T5"},{value:5,label:"T6"},{value:6,label:"T7"},{value:0,label:"CN"}];function b(e,t){let r=String(e||"").trim();return/^([01]\d|2[0-3]):([0-5]\d)$/.test(r)?r:t}function f(e={}){let t=e&&"object"==typeof e?e:{},r=Array.isArray(t.weekdays)?t.weekdays.map(Number).filter(e=>e>=0&&e<=6):p;return{enabled:!1!==t.enabled,weekdays:[...new Set(r)].sort((e,t)=>e-t),fromTime:b(t.fromTime||t.from,"00:00"),toTime:b(t.toTime||t.to,"23:59")}}function g(e={}){var t;let r=e&&"object"==typeof e?e:{};return{enabled:!0===r.enabled,intervalSec:Math.max(10,Number.parseInt(r.intervalSec||60,10)||60),failureThreshold:Math.max(1,Number.parseInt(r.failureThreshold||3,10)||3),timeoutMs:Math.max(1e3,Number.parseInt(r.timeoutMs||15e3,10)||15e3),prompt:"string"==typeof r.prompt&&r.prompt.trim()?r.prompt.trim():"Say hi",disableThinking:!1!==r.disableThinking,model:"string"==typeof(t=r.model||r.healthModel||r.testModel)?t.trim():""}}function y(){return"text-xs font-medium text-text-muted"}function v(){return"mt-1 w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-text-main outline-none focus:border-primary disabled:cursor-not-allowed disabled:opacity-50"}function j({isOpen:e,connection:t,proxyPools:r,onSave:l,onClose:n}){let[b,N]=(0,a.useState)({name:"",priority:1,apiKey:""}),[w,k]=(0,a.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[C,S]=(0,a.useState)({accountId:""}),[T,A]=(0,a.useState)(!1),[_,I]=(0,a.useState)(null),[M,$]=(0,a.useState)(!1),[P,E]=(0,a.useState)(null),[R,O]=(0,a.useState)(!1),[L,z]=(0,a.useState)(f()),[q,U]=(0,a.useState)(g()),[D,F]=(0,a.useState)(!1),[W,K]=(0,a.useState)(!1),[B,V]=(0,a.useState)([]),[G,Q]=(0,a.useState)(!1),[J,H]=(0,a.useState)("");(0,a.useEffect)(()=>{t&&(N({name:t.name||"",priority:t.priority||1,apiKey:""}),"azure"===t.provider&&t.providerSpecificData?k({azureEndpoint:t.providerSpecificData.azureEndpoint||"",apiVersion:t.providerSpecificData.apiVersion||"2024-10-01-preview",deployment:t.providerSpecificData.deployment||"",organization:t.providerSpecificData.organization||""}):k({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),"cloudflare-ai"===t.provider&&t.providerSpecificData?S({accountId:t.providerSpecificData.accountId||""}):S({accountId:""}),z(f(t.schedule||{})),U(g(t.healthCheck||{})),F(!0===t.providerScheduleOverride),K(!0===t.providerHealthOverride),I(null),E(null))},[t]);let X=t?.authType==="oauth",Y=t?.provider==="azure",Z=t?.provider==="cloudflare-ai",ee=t?function(e=""){if((0,m.gb)(e))return"anthropic";if((0,m.mq)(e)||"cloudflare-ai"===e)return"openai";if("gemini"===e)return"gemini";if("github"===e)return"openai";let t=u.X3?.[e]||"";return t.includes("/messages")?"anthropic":t.includes("/chat/completions")||t.includes("/responses")?"openai":null}(t.provider):null,et=!!ee,er=(0,x.wB)(B,q.model);(0,a.useEffect)(()=>{if(!e||!t?.provider)return;let r=!1;return async function(){Q(!0),H("");try{let e=await (0,x.ns)({providerId:t.provider,connections:[t],currentModel:q.model||t.defaultModel||""});r||(V(e.models),H(e.warning||""))}catch(e){r||(V([]),H(e.message||"Kh\xf4ng tải được danh s\xe1ch Available Models cục bộ"))}finally{r||Q(!1)}}(),()=>{r=!0}},[e,t,q.model]);let es=async()=>{if(t?.provider){A(!0),I(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),r=await e.json();I(r.valid?"success":"failed")}catch{I("failed")}finally{A(!1)}}},ea=async()=>{if(t?.provider&&b.apiKey){$(!0),E(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:b.apiKey,...Y?{providerSpecificData:w}:{},...Z?{providerSpecificData:C}:{}})}),r=await e.json();E(r.valid?"success":"failed")}catch{E("failed")}finally{$(!1)}}},el=async()=>{if(t){O(!0);try{let e={name:b.name,priority:b.priority,schedule:f(L),healthCheck:g(q)};if(!X&&b.apiKey){e.apiKey=b.apiKey;let r="success"===P;if(!r)try{$(!0),E(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:b.apiKey,...Y?{providerSpecificData:w}:{},...Z?{providerSpecificData:C}:{}})});r=!!(await e.json()).valid,E(r?"success":"failed")}catch{E("failed")}finally{$(!1)}r&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}Y&&(e.providerSpecificData={azureEndpoint:w.azureEndpoint,apiVersion:w.apiVersion,deployment:w.deployment,organization:w.organization}),Z&&(e.providerSpecificData={accountId:C.accountId}),await l(e)}finally{O(!1)}}};return t?(0,s.jsx)(i.default,{isOpen:e,onClose:n,title:"Chỉnh sửa connection",size:"full",children:(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsx)(o.default,{label:"T\xean",value:b.name,onChange:e=>N({...b,name:e.target.value}),placeholder:X?"T\xean t\xe0i khoản":"Key production"}),(0,s.jsx)(o.default,{label:"Độ ưu ti\xean",type:"number",value:b.priority,onChange:e=>N({...b,priority:Number.parseInt(e.target.value,10)||1})})]}),X&&t.email&&(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-sidebar/40 px-3 py-2 text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"font-medium text-text-main",children:"Email:"})," ",t.email]}),!X&&(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.default,{label:"API Key",type:"password",value:b.apiKey,onChange:e=>N({...b,apiKey:e.target.value}),placeholder:"Nhập API key mới",hint:"Để trống nếu muốn giữ API key hiện tại.",className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(d.default,{onClick:ea,disabled:!b.apiKey||M||R,variant:"secondary",children:M?"Checking...":"Check"})}),P&&(0,s.jsx)("div",{className:"pt-7",children:(0,s.jsx)(c.default,{variant:"success"===P?"success":"error",children:"success"===P?"Valid":"Invalid"})})]}),Y&&(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-sidebar/40 p-4",children:[(0,s.jsx)("h3",{className:"mb-3 text-sm font-semibold text-text-main",children:"Cấu h\xecnh Azure OpenAI"}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsx)(o.default,{label:"Azure Endpoint",value:w.azureEndpoint,onChange:e=>k({...w,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,s.jsx)(o.default,{label:"T\xean deployment",value:w.deployment,onChange:e=>k({...w,deployment:e.target.value}),placeholder:"gpt-4"}),(0,s.jsx)(o.default,{label:"Phi\xean bản API",value:w.apiVersion,onChange:e=>k({...w,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,s.jsx)(o.default,{label:"Organization",value:w.organization,onChange:e=>k({...w,organization:e.target.value}),placeholder:"Organization ID"})]})]}),Z&&(0,s.jsx)(o.default,{label:"Cloudflare Account ID",value:C.accountId,onChange:e=>S({...C,accountId:e.target.value})}),(0,s.jsxs)("section",{className:"rounded-xl border border-border bg-sidebar/30 p-4",children:[(0,s.jsx)("h3",{className:"mb-3 text-sm font-semibold text-text-main",children:"Lịch hoạt động"}),D&&(0,s.jsx)("p",{className:"mb-3 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-xs text-yellow-500",children:"Provider đang bật ghi đ\xe8 lịch. Lịch ri\xeang của t\xe0i khoản n\xe0y sẽ bị kh\xf3a v\xe0 bị bỏ qua khi ghi đ\xe8 c\xf2n bật."}),(0,s.jsxs)("label",{className:"mb-3 flex items-center gap-2 text-sm text-text-main",children:[(0,s.jsx)("input",{type:"checkbox",checked:L.enabled,disabled:D,onChange:e=>z(t=>({...t,enabled:e.target.checked}))}),"Bật lịch cho t\xe0i khoản"]}),(0,s.jsx)("div",{className:"mb-3 flex flex-wrap gap-2",children:h.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-xs text-text-main",children:[(0,s.jsx)("input",{type:"checkbox",checked:L.weekdays.includes(e.value),disabled:D,onChange:()=>z(t=>{let r=new Set(Array.isArray(t.weekdays)?t.weekdays:p);return r.has(e.value)?r.delete(e.value):r.add(e.value),{...t,weekdays:[...r].sort((e,t)=>e-t)}})}),e.label]},e.value))}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("label",{className:y(),children:["Từ giờ",(0,s.jsx)("input",{type:"time",value:L.fromTime,disabled:D,onChange:e=>z(t=>({...t,fromTime:e.target.value})),className:v()})]}),(0,s.jsxs)("label",{className:y(),children:["Đến giờ",(0,s.jsx)("input",{type:"time",value:L.toTime,disabled:D,onChange:e=>z(t=>({...t,toTime:e.target.value})),className:v()})]})]})]}),(0,s.jsxs)("section",{className:"rounded-xl border border-border bg-sidebar/30 p-4",children:[(0,s.jsx)("h3",{className:"mb-3 text-sm font-semibold text-text-main",children:"Kiểm tra sức khỏe bằng ping"}),W&&(0,s.jsx)("p",{className:"mb-3 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-xs text-yellow-500",children:"Provider đang bật ghi đ\xe8 healthcheck. Ch\xednh s\xe1ch healthcheck ri\xeang của t\xe0i khoản n\xe0y sẽ bị kh\xf3a v\xe0 bị bỏ qua khi ghi đ\xe8 c\xf2n bật."}),(0,s.jsxs)("label",{className:"mb-3 flex items-center gap-2 text-sm text-text-main",children:[(0,s.jsx)("input",{type:"checkbox",checked:q.enabled,disabled:W,onChange:e=>U(t=>({...t,enabled:e.target.checked}))}),"Bật healthcheck định kỳ"]}),q.enabled&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("label",{className:y(),children:["Model d\xf9ng để healthcheck",(0,s.jsxs)("select",{value:q.model||"",onChange:e=>U(t=>({...t,model:e.target.value})),className:v(),disabled:W||G,children:[(0,s.jsx)("option",{value:"",children:"Chỉ kiểm tra connection/base URL — kh\xf4ng ping chat"}),er.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))]})]}),(0,s.jsxs)("label",{className:`${y()} mt-3 block`,children:["Nhập model healthcheck thủ c\xf4ng",(0,s.jsx)("input",{value:q.model||"",onChange:e=>U(t=>({...t,model:e.target.value})),placeholder:"anthropic"===ee?"t\xean model Claude từ endpoint n\xe0y":"gemini"===ee?"model Gemini, v\xed dụ gemini-2.5-flash":"t\xean model từ Available Models",className:v(),disabled:W||G})]}),G&&(0,s.jsx)("p",{className:"mt-2 text-xs text-text-muted",children:"Đang tải Available Models cục bộ..."}),J&&(0,s.jsxs)("p",{className:"mt-2 text-xs text-yellow-500",children:["Ghi ch\xfa danh s\xe1ch model: ",J]}),!G&&!J&&(0,s.jsx)("p",{className:"mt-2 text-xs text-text-muted",children:"Danh s\xe1ch model được lấy từ Available Models / DB cục bộ, kh\xf4ng gọi API /models của provider."}),"anthropic"===ee&&(0,s.jsxs)("p",{className:"mt-2 text-xs text-text-muted",children:["Healthcheck tương th\xedch Anthropic gửi ",(0,s.jsx)("code",{children:"Say hi"})," tới ",(0,s.jsx)("code",{children:"/v1/messages"})," chỉ khi đ\xe3 chọn model."]}),"gemini"===ee&&(0,s.jsxs)("p",{className:"mt-2 text-xs text-text-muted",children:["Healthcheck Gemini gửi ",(0,s.jsx)("code",{children:"Say hi"})," bằng API native ",(0,s.jsx)("code",{children:"generateContent"})," chỉ khi đ\xe3 chọn model."]}),"cloudflare-ai"===t.provider&&(0,s.jsxs)("p",{className:"mt-2 text-xs text-text-muted",children:["Healthcheck Cloudflare gửi ",(0,s.jsx)("code",{children:"Say hi"})," tới Workers AI OpenAI-style chat endpoint chỉ khi đ\xe3 chọn model."]}),!et&&(0,s.jsx)("p",{className:"mt-2 text-xs text-text-muted",children:"Provider n\xe0y vẫn c\xf3 thể hiển thị Available Models cục bộ. Auto healthcheck sẽ tiếp tục d\xf9ng kiểm tra connection/token/account gốc cho đến khi c\xf3 direct chat endpoint."})]}),q.enabled&&(!et||!q.model)&&(0,s.jsx)("p",{className:"mt-4 rounded-lg border border-border bg-background/60 px-3 py-2 text-xs text-text-muted",children:"Chưa bật model/endpoint direct chat healthcheck. Auto healthcheck sẽ kiểm tra connection/base URL/key/token/account v\xe0 kh\xf4ng gửi ping chat Say hi."}),(0,s.jsxs)("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[(0,s.jsxs)("label",{className:y(),children:["Chu kỳ (gi\xe2y)",(0,s.jsx)("input",{type:"number",min:"10",value:q.intervalSec,disabled:W,onChange:e=>U(t=>({...t,intervalSec:Math.max(10,Number.parseInt(e.target.value,10)||60)})),className:v()})]}),(0,s.jsxs)("label",{className:y(),children:["Ngưỡng lỗi",(0,s.jsx)("input",{type:"number",min:"1",value:q.failureThreshold,disabled:W,onChange:e=>U(t=>({...t,failureThreshold:Math.max(1,Number.parseInt(e.target.value,10)||3)})),className:v()})]}),(0,s.jsxs)("label",{className:y(),children:["Timeout (ms)",(0,s.jsx)("input",{type:"number",min:"1000",value:q.timeoutMs,disabled:W,onChange:e=>U(t=>({...t,timeoutMs:Math.max(1e3,Number.parseInt(e.target.value,10)||15e3)})),className:v()})]})]}),(0,s.jsxs)("label",{className:`${y()} mt-3 block`,children:["Lời nhắc",(0,s.jsx)("input",{value:q.prompt,disabled:W,onChange:e=>U(t=>({...t,prompt:e.target.value})),className:v()})]}),(0,s.jsxs)("label",{className:"mt-3 flex items-center gap-2 text-sm text-text-main",children:[(0,s.jsx)("input",{type:"checkbox",checked:q.disableThinking,disabled:W,onChange:e=>U(t=>({...t,disableThinking:e.target.checked}))}),"Ưu ti\xean payload kiểm tra nhẹ / tắt thinking nếu được hỗ trợ"]}),(0,s.jsxs)("div",{className:"mt-3 text-xs text-text-muted",children:["Trạng th\xe1i: ",(0,s.jsx)("span",{className:"font-medium text-text-main",children:t.healthStatus||"kh\xf4ng r\xf5"}),t.healthLastCheckedAt&&(0,s.jsxs)("span",{children:[" \xb7 lần kiểm tra cuối: ",function(e){if(!e)return"";try{return new Date(e).toLocaleString()}catch{return String(e)}}(t.healthLastCheckedAt)]}),t.healthLastError&&(0,s.jsx)("p",{className:"mt-1 break-words text-red-500",children:t.healthLastError})]})]}),!Y&&!Z&&(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(d.default,{onClick:es,disabled:T,variant:"secondary",children:T?"Đang kiểm tra...":"Kiểm tra connection"}),_&&(0,s.jsx)(c.default,{variant:"success"===_?"success":"error",children:"success"===_?"Hợp lệ":"Thất bại"})]}),(0,s.jsxs)("div",{className:"flex gap-2 border-t border-border pt-4",children:[(0,s.jsx)(d.default,{onClick:el,disabled:R||Y&&(!w.azureEndpoint||!w.deployment||!w.organization)||Z&&!C.accountId,fullWidth:!0,children:R?"Đang lưu...":"Lưu"}),(0,s.jsx)(d.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}j.propTypes={isOpen:n().bool.isRequired,connection:n().shape({id:n().string,name:n().string,email:n().string,priority:n().number,authType:n().string,provider:n().string,defaultModel:n().string,providerSpecificData:n().object,schedule:n().object,healthCheck:n().object,healthStatus:n().string,healthLastCheckedAt:n().string,healthLastError:n().string,providerScheduleOverride:n().bool,providerHealthOverride:n().bool}),proxyPools:n().arrayOf(n().shape({id:n().string,name:n().string})),onSave:n().func.isRequired,onClose:n().func.isRequired}},74891:(e,t,r)=>{r.d(t,{default:()=>f});var s=r(95155),a=r(12115),l=r(73321),n=r(98500),i=r.n(n),o=r(14051),d=r.n(o),c=r(80752),m=r(38587),u=r(94027),x=r(38003),p=r(90620),h=r(52679),b=r(73006);function f({onMenuClick:e,showMenuButton:t=!0}){let r=(0,l.usePathname)(),n=(0,l.useRouter)(),{displayName:o,loginMethod:d}=(0,u.s)(),{title:x,description:y,icon:v,breadcrumbs:j}=(0,a.useMemo)(()=>(e=>{if(!e)return{title:"",description:"",breadcrumbs:[]};let t=e.match(/\/media-providers\/([^/]+)\/([^/]+)$/);if(t){let e=t[1],r=t[2],s=h.rj.find(t=>t.id===e),a=h.Q2[r];return{title:a?.name||r,description:"",breadcrumbs:[{label:"Media Providers",href:`/dashboard/media-providers/${e}`},{label:s?.label||e,href:`/dashboard/media-providers/${e}`},{label:a?.name||r,image:`/providers/${r}.png`}]}}let r=e.match(/\/media-providers\/([^/]+)$/);if(r){let e=r[1],t=h.rj.find(t=>t.id===e);return{title:t?.label||e,description:`Manage your ${t?.label||e} providers`,icon:t?.icon||"perm_media",breadcrumbs:[]}}let s=e.match(/\/providers\/([^/]+)$/);if(s){let e=s[1],t=p.zN[e]||p.fg[e];if(t)return{title:t.name,description:"",breadcrumbs:[{label:"Providers",href:"/dashboard/providers"},{label:t.name,image:`/providers/${t.id}.png`}]}}return e.includes("/providers")&&!e.includes("/media-providers")?{title:"Providers",description:"Manage your AI provider connections",icon:"dns",breadcrumbs:[]}:e.includes("/combos")?{title:"Combos",description:"Model combos with fallback",icon:"layers",breadcrumbs:[]}:e.includes("/token-saver")?{title:"Token Saver Analytics",description:"Theo d\xf5i hiệu quả RTK token saving theo source tool, provider, model v\xe0 filter",icon:"compress",breadcrumbs:[]}:e.includes("/analytics")?{title:"Analytics",description:"Thống k\xea request, token, API key, Source IP, provider, model v\xe0 lỗi vận h\xe0nh",icon:"monitoring",breadcrumbs:[]}:e.includes("/usage")?{title:"Usage & Analytics",description:"Monitor your API usage, token consumption, and request logs",icon:"bar_chart",breadcrumbs:[]}:e.includes("/auth-files")?{title:"Auth Files",description:"Map provider credentials stored in the local database",icon:"vpn_key",breadcrumbs:[]}:e.includes("/quota")?{title:"Quota Tracker",description:"Track and manage your API quota limits",icon:"data_usage",breadcrumbs:[]}:e.includes("/mitm")?{title:"AI Traffic Proxy",description:"Intercept CLI tool traffic and route through this router gateway",icon:"security",breadcrumbs:[]}:e.includes("/prompt-logs")?{title:"Prompt Logs",description:"Search Copilot/MITM prompts across the prompt log database",icon:"manage_search",breadcrumbs:[]}:e.includes("/cli-tools")?{title:"CLI Tools",description:"Configure CLI tools",icon:"terminal",breadcrumbs:[]}:e.includes("/proxy-pools")?{title:"Proxy Pools",description:"Manage your proxy pool configurations",icon:"lan",breadcrumbs:[]}:e.includes("/skills")?{title:"Agent Skills",description:"Copy a link and paste to your AI to use this Router — no install needed",icon:"extension",breadcrumbs:[]}:e.includes("/endpoint")?{title:"Endpoint",description:"API endpoint configuration",icon:"api",breadcrumbs:[]}:e.includes("/api-keys")?{title:"API Keys",description:"Manage API keys and model access",icon:"vpn_key",breadcrumbs:[]}:e.includes("/profile")?{title:"Settings",description:"Manage your preferences",icon:"settings",breadcrumbs:[]}:e.includes("/translator")?{title:"Translator",description:"Debug translation flow between formats",icon:"translate",breadcrumbs:[]}:e.includes("/console-log")?{title:"Console Log",description:"Live server console output",icon:"monitor",breadcrumbs:[]}:"/dashboard"===e?{title:"Endpoint",description:"API endpoint configuration",icon:"api",breadcrumbs:[]}:{title:"",description:"",breadcrumbs:[]}})(r),[r]),N=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&(n.push("/login"),n.refresh())}catch(e){console.error("Failed to logout:",e)}};return(0,s.jsx)("header",{className:"sticky top-0 z-30 border-b border-border bg-background/80 backdrop-blur",children:(0,s.jsxs)("div",{className:"flex min-h-[72px] items-center justify-between gap-4 px-4 md:px-6",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[t?(0,s.jsx)("button",{type:"button",onClick:e,className:"rounded-xl border border-border p-2 text-text-muted hover:bg-surface hover:text-text-main lg:hidden","aria-label":"Open menu",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"menu"})}):null,(0,s.jsx)("div",{className:"min-w-0",children:j.length>0?(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-1 text-sm text-text-muted",children:j.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[t>0?(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_right"}):null,e.href?(0,s.jsx)(i(),{href:e.href,className:"hover:text-primary",children:(0,b.Tl)(e.label)}):(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[e.image?(0,s.jsx)("img",{src:e.image,alt:"",className:"h-5 w-5 rounded"}):null,(0,s.jsx)("h1",{className:"text-xl font-semibold text-text-main",children:(0,b.Tl)(e.label)})]})]},`${e.label}-${t}`))}):x?(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[v?(0,s.jsx)("span",{className:"material-symbols-outlined text-primary",children:v}):null,(0,s.jsx)("h1",{className:"truncate text-xl font-semibold text-text-main",children:(0,b.Tl)(x)})]}),y?(0,s.jsx)("p",{className:"mt-1 truncate text-sm text-text-muted",children:(0,b.Tl)(y)}):null]}):null})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)(g,{}),o&&"OIDC"===d?(0,s.jsxs)("div",{className:"hidden items-center gap-2 rounded-xl border border-border px-3 py-2 text-sm text-text-muted md:flex",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"person"}),(0,s.jsx)("span",{children:o}),(0,s.jsx)("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-xs text-primary",children:"OIDC"})]}):null,(0,s.jsx)(m.default,{}),(0,s.jsx)(c.default,{onLogout:N})]})]})})}function g(){let e=(0,x.C)(e=>e.visible),t=(0,x.C)(e=>e.query),r=(0,x.C)(e=>e.placeholder),a=(0,x.C)(e=>e.setQuery);return e?(0,s.jsxs)("div",{className:"relative hidden w-72 md:block",children:[(0,s.jsx)("span",{className:"material-symbols-outlined pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-[18px] text-text-muted",children:"search"}),(0,s.jsx)("input",{value:t,onChange:e=>a(e.target.value),placeholder:r,className:"h-9 w-full rounded-lg border border-border bg-surface/60 pl-8 pr-8 text-sm text-text-main outline-none transition-colors placeholder:text-text-muted focus:border-primary/50"}),t?(0,s.jsx)("button",{type:"button",onClick:()=>a(""),className:"absolute right-1 top-1/2 -translate-y-1/2 rounded p-0.5 text-text-muted hover:text-text-main","aria-label":"Clear search",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})}):null]}):null}f.propTypes={onMenuClick:d().func,showMenuButton:d().bool}},77907:(e,t,r)=>{r.d(t,{Fv:()=>s,SI:()=>a,VC:()=>i}),Object.freeze({ADMIN:"admin",MONITOR_ADMIN:"monitor_admin",AI_GATEWAYS_MONITOR:"ai_gateways_monitor",USER:"user",GUEST:"guest"});let s="/dashboard/endpoint",a=Object.freeze([{href:"/dashboard/endpoint",label:"Endpoint",icon:"api"},{href:"/dashboard/api-keys",label:"API Keys",icon:"vpn_key"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/analytics",label:"Analytics",icon:"monitoring"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"},{href:"/dashboard/prompt-logs",label:"Prompt Logs",icon:"manage_search"}]),l=Object.freeze(["/dashboard","/dashboard/endpoint","/dashboard/api-keys","/dashboard/usage","/dashboard/analytics","/dashboard/quota","/dashboard/prompt-logs"]);function n(e=""){return String(e||"").split("?")[0].replace(/\/+$/,"")||"/"}function i(e=""){let t=n(e);return"/dashboard"===t||l.filter(e=>"/dashboard"!==e).some(e=>{let r,s;return r=n(t),r===(s=n(e))||r.startsWith(`${s}/`)})}},80752:(e,t,r)=>{r.d(t,{default:()=>f});var s=r(95155),a=r(12115),l=r(47650),n=r(14051),i=r.n(n),o=r(93308),d=r(1620),c=r(94027),m=r(40197);r(14932);var u=r(21931),x=r(92542),p=r(81127);let h={en:{name:"English",flag:"\uD83C\uDDFA\uD83C\uDDF8"},vi:{name:"Tiếng Việt",flag:"\uD83C\uDDFB\uD83C\uDDF3"},"zh-CN":{name:"简体中文",flag:"\uD83C\uDDE8\uD83C\uDDF3"},"zh-TW":{name:"繁體中文",flag:"\uD83C\uDDF9\uD83C\uDDFC"},ja:{name:"日本語",flag:"\uD83C\uDDEF\uD83C\uDDF5"},"pt-BR":{name:"Portugu\xeas (BR)",flag:"\uD83C\uDDE7\uD83C\uDDF7"},"pt-PT":{name:"Portugu\xeas (PT)",flag:"\uD83C\uDDF5\uD83C\uDDF9"},ko:{name:"한국어",flag:"\uD83C\uDDF0\uD83C\uDDF7"},es:{name:"Espa\xf1ol",flag:"\uD83C\uDDEA\uD83C\uDDF8"},de:{name:"Deutsch",flag:"\uD83C\uDDE9\uD83C\uDDEA"},fr:{name:"Fran\xe7ais",flag:"\uD83C\uDDEB\uD83C\uDDF7"},he:{name:"עברית",flag:"\uD83C\uDDEE\uD83C\uDDF1"},ar:{name:"العربية",flag:"\uD83C\uDDF8\uD83C\uDDE6"},ru:{name:"Русский",flag:"\uD83C\uDDF7\uD83C\uDDFA"},pl:{name:"Polski",flag:"\uD83C\uDDF5\uD83C\uDDF1"},cs:{name:"Čeština",flag:"\uD83C\uDDE8\uD83C\uDDFF"},nl:{name:"Nederlands",flag:"\uD83C\uDDF3\uD83C\uDDF1"},tr:{name:"T\xfcrk\xe7e",flag:"\uD83C\uDDF9\uD83C\uDDF7"},uk:{name:"Українська",flag:"\uD83C\uDDFA\uD83C\uDDE6"},tl:{name:"Tagalog",flag:"\uD83C\uDDF5\uD83C\uDDED"},id:{name:"Indonesia",flag:"\uD83C\uDDEE\uD83C\uDDE9"},th:{name:"ไทย",flag:"\uD83C\uDDF9\uD83C\uDDED"},hi:{name:"हिन्दी",flag:"\uD83C\uDDEE\uD83C\uDDF3"},bn:{name:"বাংলা",flag:"\uD83C\uDDE7\uD83C\uDDE9"},ur:{name:"اردو",flag:"\uD83C\uDDF5\uD83C\uDDF0"},ro:{name:"Rom\xe2nă",flag:"\uD83C\uDDF7\uD83C\uDDF4"},sv:{name:"Svenska",flag:"\uD83C\uDDF8\uD83C\uDDEA"},it:{name:"Italiano",flag:"\uD83C\uDDEE\uD83C\uDDF9"},el:{name:"Ελληνικά",flag:"\uD83C\uDDEC\uD83C\uDDF7"},hu:{name:"Magyar",flag:"\uD83C\uDDED\uD83C\uDDFA"},fi:{name:"Suomi",flag:"\uD83C\uDDEB\uD83C\uDDEE"},da:{name:"Dansk",flag:"\uD83C\uDDE9\uD83C\uDDF0"},no:{name:"Norsk",flag:"\uD83C\uDDF3\uD83C\uDDF4"}};function b({icon:e,label:t,onClick:r,trailing:a,danger:l}){return(0,s.jsxs)("button",{onClick:r,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${l?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[20px] ${l?"":"text-text-muted"}`,children:e}),(0,s.jsx)("span",{className:"flex-1 text-left",children:t}),a&&(0,s.jsx)("span",{className:"text-base",children:a})]})}function f({onLogout:e}){let[t,r]=(0,a.useState)(!1),[n,i]=(0,a.useState)(!1),[g,y]=(0,a.useState)(!1),[v,j]=(0,a.useState)(!1),[N,w]=(0,a.useState)(""),[k,C]=(0,a.useState)(10),[S,T]=(0,a.useState)(!1),[A,_]=(0,a.useState)("en"),{toggleTheme:I,isDark:M}=(0,d.D)(),{isAdmin:$}=(0,c.s)(),P=(0,a.useRef)(null),E=(0,a.useRef)(null),R=(0,a.useRef)(null);(0,a.useEffect)(()=>{_(function(){if("u"<typeof document)return"en";let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${o.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):"en";return(0,o.QC)(t)}())},[S]),(0,a.useEffect)(()=>{let e=e=>{P.current&&!P.current.contains(e.target)&&r(!1)};if(t)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,a.useEffect)(()=>()=>{E.current&&clearTimeout(E.current),R.current&&clearInterval(R.current)},[]);let O=()=>{E.current&&(clearTimeout(E.current),E.current=null),R.current&&(clearInterval(R.current),R.current=null)},L=()=>{v||(y(!1),w(""),C(10))},z=async()=>{if($&&!v){j(!0),w("");try{let e=await fetch("/api/version/restart",{method:"POST"}),t=await e.json().catch(()=>({}));if(!e.ok||t?.success===!1)throw Error(t?.message||"Restart request failed");O(),C(10),R.current=setInterval(()=>{C(e=>Math.max(0,e-1))},1e3),E.current=setTimeout(()=>{window.location.reload()},1e4)}catch(e){O(),C(10),w(e?.message||"Restart request failed"),j(!1)}}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative",ref:P,children:[(0,s.jsx)("button",{onClick:()=>r(e=>!e),className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5 transition-all",title:"Menu",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),t&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[(0,s.jsx)(b,{icon:"history",label:"Change Log",onClick:()=>{r(!1),i(!0)}}),(0,s.jsx)(b,{icon:"language",label:h[A]?.name||A,trailing:h[A]?.flag||"\uD83C\uDF10",onClick:()=>{r(!1),T(!0)}}),(0,s.jsx)(b,{icon:M?"light_mode":"dark_mode",label:"Theme",onClick:()=>{I(),r(!1)}}),(0,s.jsx)(b,{icon:"logout",label:"Logout",danger:!0,onClick:()=>{r(!1),e()}}),$?(0,s.jsx)(b,{icon:"restart_alt",label:v?"Restarting...":"Restart",danger:!0,onClick:()=>{$&&!v&&(r(!1),w(""),y(!0))}}):null]})]}),g&&"u">typeof document?(0,l.createPortal)((0,s.jsx)(p.default,{isOpen:g,onClose:L,title:"Restart BlueRouter",size:"sm",closeOnOverlay:!v,className:"overflow-hidden",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.default,{variant:"ghost",onClick:L,disabled:v,children:"Cancel"}),(0,s.jsx)(x.default,{variant:"primary",icon:"restart_alt",loading:v,onClick:z,children:v?"Restarting":"Restart now"})]}),children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"rounded-2xl border border-primary/15 bg-primary/10 p-4",children:(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-primary/15 text-primary",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[24px]",children:"restart_alt"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-text-main",children:"Confirm service restart"}),(0,s.jsx)("p",{className:"mt-1 text-sm leading-6 text-text-muted",children:"The dashboard and API gateway may be unavailable for a few seconds while BlueRouter restarts."})]})]})}),N?(0,s.jsxs)("div",{className:"flex gap-2 rounded-xl border border-red-500/20 bg-red-500/10 p-3 text-sm text-red-600 dark:text-red-300",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"error"}),(0,s.jsx)("span",{children:N})]}):null,v?(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-xl border border-border bg-surface-2 px-3 py-2 text-xs font-medium text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px] text-primary",children:"progress_activity"}),"Restart command sent. This page will reload automatically in ",k,"s."]}):null]})}),document.body):null,(0,s.jsx)(m.default,{isOpen:n,onClose:()=>i(!1)}),(0,s.jsx)(u.default,{hideTrigger:!0,isOpen:S,onClose:e=>{T(!1),_(e)}})]})}b.propTypes={icon:i().string.isRequired,label:i().string.isRequired,onClick:i().func.isRequired,trailing:i().node,danger:i().bool},f.propTypes={onLogout:i().func.isRequired}},81127:(e,t,r)=>{r.d(t,{ConfirmModal:()=>d,default:()=>o});var s=r(95155),a=r(12115),l=r(31474),n=r(92542),i=r(97677);function o({isOpen:e,onClose:t,title:r,children:n,footer:d,size:c="md",closeOnOverlay:m=!0,showTrafficLights:u=!0,className:x}){return((0,a.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,a.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t]),e)?(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-[2px] fade-in",onClick:m?t:void 0}),(0,s.jsxs)("div",{className:(0,l.cn)("relative w-full bg-surface","border border-border-subtle","rounded-[14px] shadow-[var(--shadow-elev)]","fade-in",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[c],x),children:[(r||u)&&(0,s.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[u&&(0,s.jsxs)("div",{className:"hidden md:flex items-center gap-2 mr-4 ml-2",children:[(0,s.jsx)(i.default,{text:"Close",position:"top",color:"#FF5F56",children:(0,s.jsx)("button",{onClick:t,"aria-label":"Close",title:"Close",className:"w-4 h-4 rounded-full bg-[#FF5F56] hover:brightness-90 transition-all cursor-pointer flex items-center justify-center group/dot",children:(0,s.jsx)("span",{className:"text-[9px] font-bold text-white opacity-0 group-hover/dot:opacity-100 transition-opacity leading-none",children:"✕"})})}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"})]}),r&&(0,s.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:r})]}),(0,s.jsx)("button",{onClick:t,"aria-label":"Close",className:"md:hidden p-1.5 rounded-[10px] text-text-muted hover:bg-surface-2 hover:text-text-main transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,s.jsx)("div",{className:"p-6 max-h-[calc(85vh-100px)] overflow-y-auto custom-scrollbar",children:n}),d&&(0,s.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-subtle",children:d})]})]}):null}function d({isOpen:e,onClose:t,onConfirm:r,title:a="Confirm",message:l,confirmText:i="Confirm",cancelText:c="Cancel",variant:m="danger",loading:u=!1}){return(0,s.jsx)(o,{isOpen:e,onClose:t,title:a,size:"sm",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.default,{variant:"ghost",onClick:t,disabled:u,children:c}),(0,s.jsx)(n.default,{variant:m,onClick:r,loading:u,children:i})]}),children:(0,s.jsx)("p",{className:"text-text-muted",children:l})})}},84588:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(31474);function l({children:e,title:t,subtitle:r,icon:n,action:i,padding:o="md",hover:d=!1,elev:c=!1,className:m,...u}){return(0,s.jsxs)("div",{className:(0,a.cn)("bg-surface border border-border-subtle",c?"rounded-[14px] shadow-[var(--shadow-elev)]":"rounded-[14px] shadow-[var(--shadow-soft)]",d&&"hover:shadow-[var(--shadow-warm)] hover:border-brand-500/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[o],m),...u,children:[(t||i)&&(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[n&&(0,s.jsx)("div",{className:"p-2 rounded-[10px] bg-bg text-text-muted",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:n})}),(0,s.jsxs)("div",{children:[t&&(0,s.jsx)("h3",{className:"text-text-main font-semibold",children:t}),r&&(0,s.jsx)("p",{className:"text-sm text-text-muted",children:r})]})]}),i]}),e]})}l.Section=function({children:e,className:t,...r}){return(0,s.jsx)("div",{className:(0,a.cn)("p-4 rounded-[10px]","bg-bg border border-border-subtle",t),...r,children:e})},l.Row=function({children:e,className:t,...r}){return(0,s.jsx)("div",{className:(0,a.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50",t),...r,children:e})},l.ListItem=function({children:e,actions:t,className:r,...l}){return(0,s.jsxs)("div",{className:(0,a.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50 transition-colors",r),...l,children:[(0,s.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,s.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:t})]})}},86671:(e,t,r)=>{r.d(t,{default:()=>x});var s=r(95155),a=r(12115),l=r(73321),n=r(65921),i=r(94027),o=r(92622),d=r(74891),c=r(77907);let m=["/dashboard/api-keys","/dashboard/personalcloudprovider","/dashboard/personalquota","/dashboard/analytics","/dashboard/token-saver"];function u({children:e}){let t=(0,l.usePathname)(),r=(0,l.useRouter)(),{isAdmin:n,isMonitorAdmin:o,loading:d}=(0,i.s)(),[x,p]=(0,a.useState)(!1),h=function({pathname:e,isAdmin:t,isMonitorAdmin:r}){return!!t||(r?(0,c.VC)(e):m.some(t=>e===t||e.startsWith(`${t}/`)))}({pathname:t,isAdmin:n,isMonitorAdmin:o});return((0,a.useEffect)(()=>{if(!d){if(!h){p(!0),r.replace(function({isMonitorAdmin:e}){return e?c.Fv:"/dashboard/api-keys"}({isMonitorAdmin:o}));return}p(!1)}},[h,o,d,r]),d)?(0,s.jsxs)("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined mr-2 animate-spin",children:"progress_activity"}),"Đang tải dashboard..."]}):x||!h?(0,s.jsx)("div",{className:"flex min-h-screen items-center justify-center bg-background text-sm text-text-muted",children:"Đang chuyển hướng..."}):e}function x({children:e}){let[t,r]=(0,a.useState)(!1),c=(0,n.i)(e=>e.notifications),m=(0,n.i)(e=>e.removeNotification),p=(0,l.usePathname)();return(0,s.jsx)(i.Y,{children:(0,s.jsx)(u,{children:(0,s.jsxs)("div",{className:"min-h-screen bg-surface text-text-main",children:[(0,s.jsx)("div",{className:"fixed right-4 top-4 z-[100] w-[min(420px,calc(100vw-2rem))] space-y-2",children:c.map(e=>{var t;let r="success"===(t=e.type)?{wrapper:"border-green-500/30 bg-green-500/10 text-green-600 dark:text-green-400",icon:"check_circle"}:"error"===t?{wrapper:"border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-400",icon:"error"}:"warning"===t?{wrapper:"border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400",icon:"warning"}:{wrapper:"border-blue-500/30 bg-blue-500/10 text-blue-600 dark:text-blue-400",icon:"info"};return(0,s.jsx)("div",{className:`rounded-2xl border px-4 py-3 shadow-lg backdrop-blur ${r.wrapper}`,children:(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:r.icon}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[e.title?(0,s.jsx)("div",{className:"font-semibold",children:e.title}):null,(0,s.jsx)("div",{className:"text-sm opacity-90",children:e.message})]}),e.dismissible?(0,s.jsx)("button",{type:"button",onClick:()=>m(e.id),className:"text-current/70 hover:text-current","aria-label":"Dismiss notification",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})}):null]})},e.id)})}),t?(0,s.jsx)("div",{className:"fixed inset-0 z-40 bg-black/40 lg:hidden",onClick:()=>r(!1)}):null,(0,s.jsxs)("div",{className:"flex min-h-screen",children:[(0,s.jsx)("div",{className:"hidden lg:block",children:(0,s.jsx)(o.default,{})}),(0,s.jsx)("div",{className:`fixed inset-y-0 left-0 z-50 transform transition-transform lg:hidden ${t?"translate-x-0":"-translate-x-full"}`,children:(0,s.jsx)(o.default,{onClose:()=>r(!1)})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)(d.default,{onMenuClick:()=>r(!0)},p),(0,s.jsx)("main",{className:"mx-auto w-full max-w-[1600px] px-4 py-6 md:px-6 lg:px-8",children:e})]})]})]})})})}},90085:(e,t,r)=>{r.d(t,{A:()=>i});var s=r(1934),a=r(31692),l=r(90620);function n(e){let t=document.documentElement,r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";"dark"===("system"===e?r:e)?t.classList.add("dark"):t.classList.remove("dark")}let i=(0,s.v)((0,a.Zr)((e,t)=>({theme:l.B2.defaultTheme,setTheme:t=>{e({theme:t}),n(t)},toggleTheme:()=>{let r="dark"===t().theme?"light":"dark";e({theme:r}),n(r)},initTheme:()=>{n(t().theme)}}),{name:l.B2.storageKey}))},90882:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497),o=r(11059);function d({isOpen:e,provider:t,providerInfo:r,onSuccess:l,onClose:n,oauthMeta:c,idcConfig:m,connectionScope:u="system"}){let[x,p]=(0,a.useState)("waiting"),[h,b]=(0,a.useState)(null),[f,g]=(0,a.useState)(""),[y,v]=(0,a.useState)(null),[j,N]=(0,a.useState)(!1),[w,k]=(0,a.useState)(null),[C,S]=(0,a.useState)(!1),T=(0,a.useRef)(null),A=(0,a.useRef)(!1),{copied:_,copy:I}=(0,o.C)(),[M,$]=(0,a.useState)(!1),[P,E]=(0,a.useState)("/callback?code=..."),R=(0,a.useRef)(!1);(0,a.useEffect)(()=>{$("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),E(`${window.location.origin}/callback?code=...`)},[]);let O=(0,a.useCallback)(async(e,r)=>{if(h)try{let s=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:h.redirectUri,codeVerifier:h.codeVerifier,state:r,...c?{meta:c}:{},..."personal"===u?{connectionScope:"personal"}:{}})}),a=await s.json();if(!s.ok)throw Error(a.error);p("success"),l?.()}catch(e){v(e.message),p("error")}},[h,t,l,c,u]),L=(0,a.useCallback)(async e=>{if(h?.state)try{let t=await fetch("/api/oauth/xai/manual-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,state:h.state})}),r=await t.json();if(!t.ok)throw Error(r.error);p("success"),l?.()}catch(e){v(e.message),p("error")}},[h,l]),z=(0,a.useCallback)(async(e,r,s,a)=>{A.current=!1,S(!0);for(let n=0;n<60;n++){if(A.current){console.log("[OAuthModal] Polling aborted"),S(!1);return}if(await new Promise(e=>setTimeout(e,1e3*s)),A.current){console.log("[OAuthModal] Polling aborted after sleep"),S(!1);return}try{let n=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:r,extraData:a,..."personal"===u?{connectionScope:"personal"}:{}})}),i=await n.json();if(i.success){A.current=!0,p("success"),S(!1),l?.();return}if("expired_token"===i.error||"access_denied"===i.error)throw Error(i.errorDescription||i.error);"slow_down"===i.error&&(s=Math.min(s+5,30))}catch(e){v(e.message),p("error"),S(!1);return}}v("Authorization timeout"),p("error"),S(!1)},[t,l,u]),q=(0,a.useCallback)(async()=>{if(t)try{let e;if(v(null),["github","qwen","kiro","kimi-coding","kilocode","codebuddy"].includes(t)){N(!0),p("waiting");let e=new URL(`/api/oauth/${t}/device-code`,window.location.origin);"personal"===u&&e.searchParams.set("connection_scope","personal"),"kiro"===t&&m?.startUrl&&(e.searchParams.set("start_url",m.startUrl),m.region&&e.searchParams.set("region",m.region),e.searchParams.set("auth_method","idc"));let r=await fetch(e.toString()),s=await r.json();if(!r.ok)throw Error(s.error);k(s);let a=s.verification_uri_complete||s.verification_uri;a&&window.open(a,"_blank","noopener,noreferrer");let l="kiro"===t?{_clientId:s._clientId,_clientSecret:s._clientSecret,_region:s._region,_authMethod:s._authMethod,_startUrl:s._startUrl}:null;z(s.device_code,s.codeVerifier,s.interval||5,l);return}let r=window.location.port||("https:"===window.location.protocol?"443":"80");e="codex"===t?"http://localhost:1455/auth/callback":"xai"===t?"http://127.0.0.1:56121/callback":M?`${window.location.origin}/callback`:"http://localhost:54545/callback";let s=new URL(`/api/oauth/${t}/authorize`,window.location.origin);s.searchParams.set("redirect_uri",e),"personal"===u&&s.searchParams.set("connection_scope","personal"),c&&Object.entries(c).forEach(([e,t])=>{t&&s.searchParams.set(e,t)});let a=await fetch(s.toString()),l=await a.json();if(!a.ok)throw Error(l.error);let n=!1,i=!1;if("codex"===t)try{let t=new URL("/api/oauth/codex/start-proxy",window.location.origin);t.searchParams.set("app_port",r),t.searchParams.set("state",l.state),t.searchParams.set("code_verifier",l.codeVerifier),t.searchParams.set("redirect_uri",e),"personal"===u&&t.searchParams.set("connection_scope","personal");let s=await fetch(t.toString()),a=await s.json();n=a.success,i=!!a.serverSide}catch{n=!1}let o=!1,d=!1;if("xai"===t)try{let t=new URL("/api/oauth/xai/start-proxy",window.location.origin);t.searchParams.set("app_port",r),t.searchParams.set("state",l.state),t.searchParams.set("code_verifier",l.codeVerifier),t.searchParams.set("redirect_uri",e);let s=await fetch(t.toString()),a=await s.json();if(o=a.success,d=!!a.serverSide,!o&&"port_busy"===a.reason)throw Error("Port 56121 in use; close the conflicting process and retry")}catch(e){if(e?.message)throw e;o=!1}b({...l,redirectUri:e,codexServerSide:i,xaiServerSide:d}),"codex"===t&&n||"xai"===t&&o||M&&"codex"!==t&&"xai"!==t?(p("waiting"),T.current=window.open(l.authUrl,"oauth_popup","width=600,height=700"),T.current||p("input")):(p("input"),window.open(l.authUrl,"_blank"))}catch(e){v(e.message),p("error")}},[t,M,z,c,m,u]);(0,a.useEffect)(()=>{e&&t?(b(null),g(""),v(null),N(!1),k(null),S(!1),A.current=!1,q()):e||(A.current=!0,"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}))},[e,t,q]),(0,a.useEffect)(()=>{let e=h?.codexServerSide?"codex":h?.xaiServerSide?"xai":null;if(!e||!h?.state||R.current)return;let t=!1,r=0,s=async()=>{if(!t&&!R.current){r+=1;try{let r=await fetch(`/api/oauth/${e}/poll-status?state=${encodeURIComponent(h.state)}`),s=await r.json();if(t||R.current)return;if("done"===s.status){R.current=!0,p("success"),l?.();return}if("error"===s.status){R.current=!0,v(s.error||"Authentication failed"),p("error");return}}catch{}if(r>=200){R.current=!0,v("Authentication timeout"),p("error");return}setTimeout(s,1500)}};return setTimeout(s,1500),()=>{t=!0}},[h,l]),(0,a.useEffect)(()=>{let e;if(!h)return;R.current=!1;let t=async e=>{if(R.current)return;let{code:t,state:r,error:s,errorDescription:a}=e;if(s){R.current=!0,v(a||s),p("error");return}t&&(R.current=!0,await O(t,r))},r=e=>{let r=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),s=e.origin===window.location.origin;(r||s)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",r);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let s=e=>{if("oauth_callback"===e.key&&e.newValue)try{let r=JSON.parse(e.newValue);t(r),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",s);try{let e=localStorage.getItem("oauth_callback");if(e){let r=JSON.parse(e);r.timestamp&&Date.now()-r.timestamp<3e4&&t(r),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",r),window.removeEventListener("storage",s),e&&e.close()}},[h,O]);let U=async()=>{try{v(null);let e=f.trim();if(e.startsWith("eyJ")&&e.includes("."))return void await O(e,null);if("xai"===t&&e&&!e.includes("://")&&!e.includes("?")&&!e.includes("code="))return void await L(e);let r=new URL(e),s=r.searchParams.get("code"),a=r.searchParams.get("state"),l=r.searchParams.get("error");if(l)throw Error(r.searchParams.get("error_description")||l);if(!s)throw Error("xai"===t?"Paste the callback URL or copied xAI code":"No authorization code found in URL");await O(s,a)}catch(e){v(e.message),p("error")}},D=(0,a.useCallback)(()=>{"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}),n()},[n,t]);if(!t||!r)return null;let F="xai"===t,W=w?.verification_uri_complete||w?.verification_uri||"",K=F?"Connect Grok Build OAuth":`Connect ${r.name}`;return(0,s.jsx)(i.aF,{isOpen:e,title:K,onClose:D,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[("waiting"===x||"input"===x)&&!j&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-lg bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,s.jsx)("span",{className:"text-sm",children:F?"Waiting for Grok Build OAuth…":"Waiting for popup authorization…"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 my-1",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Or paste callback URL manually"}),(0,s.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 1: Open this ",F?"Grok Build OAuth URL":"URL"," in your browser"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.pd,{value:h?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===_?"check":"content_copy",onClick:()=>I(h?.authUrl,"auth_url"),disabled:!h?.authUrl,children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 2: Paste the ","xai"===t?"callback URL or copied code":"callback URL"," here"]}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"xai"===t?"If xAI shows a code instead of redirecting, paste that code here.":"After authorization, copy the full URL from your browser."}),(0,s.jsx)(i.pd,{value:f,onChange:e=>g(e.target.value),placeholder:F?"http://127.0.0.1:56121/callback?code=... or copied code":P,className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:U,fullWidth:!0,disabled:!f,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"waiting"===x&&j&&w&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"text-center py-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,s.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("code",{className:"flex-1 text-sm break-all",children:W}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"login_url"===_?"check":"content_copy",onClick:()=>I(W,"login_url"),disabled:!W}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(W,"_blank","noopener,noreferrer"),disabled:!W,children:"Open"})]})]}),(0,s.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,s.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:w.user_code}),(0,s.jsx)(i.$n,{size:"sm",variant:"ghost",icon:"user_code"===_?"check":"content_copy",onClick:()=>I(w.user_code,"user_code")})]})]})]}),C&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"success"===x&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",r.name," account has been connected."]}),(0,s.jsx)(i.$n,{onClick:D,fullWidth:!0,children:"Done"})]}),"error"===x&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:y}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:q,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(i.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().string,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired,oauthMeta:n().object,idcConfig:n().shape({startUrl:n().string,region:n().string}),connectionScope:n().oneOf(["system","personal"])}},91450:(e,t,r)=>{r.d(t,{default:()=>i});var s=r(95155),a=r(14051),l=r.n(a),n=r(38587);function i({children:e}){return(0,s.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,s.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,s.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,s.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,s.jsx)(n.default,{variant:"card"})}),(0,s.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}i.propTypes={children:l().node.isRequired}},92173:(e,t,r)=>{r.d(t,{default:()=>c});var s=r(95155),a=r(98500),l=r.n(a),n=r(90620);let i=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,s.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,s.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,s.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,s.jsx)("div",{className:"size-6 text-primary",children:(0,s.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,s.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,s.jsx)("span",{className:"text-xl font-bold text-text-main",children:n.vQ.name})]}),(0,s.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(l(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,s.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",n.vQ.name," Inc. All rights reserved."]}),(0,s.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,s.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,s.jsx)(l(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,r)=>{r.d(t,{default:()=>i});var s=r(95155),a=r(31474);let l={primary:"bg-brand-500 hover:bg-brand-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",secondary:"bg-surface-2 hover:bg-surface-3 text-text-main border border-border disabled:opacity-50",outline:"border border-border text-text-main hover:bg-surface-2 hover:border-brand-500/40",ghost:"text-text-muted hover:bg-surface-2 hover:text-text-main",danger:"bg-red-500 hover:bg-red-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",success:"bg-green-600 hover:bg-green-700 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted"},n={sm:"h-7 px-3 text-xs rounded-[8px]",md:"h-9 px-4 text-sm rounded-[10px]",lg:"h-11 px-6 text-sm rounded-[10px]"};function i({children:e,variant:t="primary",size:r="md",icon:o,iconRight:d,disabled:c=!1,loading:m=!1,fullWidth:u=!1,className:x,...p}){return(0,s.jsxs)("button",{className:(0,a.cn)("inline-flex items-center justify-center gap-2 font-semibold transition-all duration-150 ease-out cursor-pointer","active:scale-[0.97] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",l[t],n[r],u&&"w-full",x),disabled:c||m,...p,children:[m?(0,s.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}):o?(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:o}):null,e,d&&!m&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:d})]})}},92622:(e,t,r)=>{r.d(t,{default:()=>N});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(98500),o=r.n(i),d=r(73321),c=r(90620),m=r(92542),u=r(81127),x=r(77907),p=r(94027),h=r(44656),b=r(31474);let f=[{href:"/dashboard/endpoint",label:"Endpoint",icon:"api"},{href:"/dashboard/api-keys",label:"API Keys",icon:"vpn_key"},{href:"/dashboard/providers",label:"Providers",icon:"dns"},{href:"/dashboard/personalcloudprovider",label:"Personal OAuth",icon:"cloud_sync"},{href:"/dashboard/personalquota",label:"Personal Quota",icon:"data_usage"},{href:"/dashboard/combos",label:"Combos",icon:"layers"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/analytics",label:"Analytics",icon:"monitoring"},{href:"/dashboard/token-saver",label:"Token Saver",icon:"compress"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"},{href:"/dashboard/media-providers/web",label:"Media / Web",icon:"perm_media",advanced:!0},{href:"/dashboard/mitm",label:"AI Traffic Gateway",icon:"security",advanced:!0},{href:"/dashboard/prompt-logs",label:"Prompt Logs",icon:"manage_search"},{href:"/dashboard/cli-tools",label:"CLI Tools",icon:"terminal",advanced:!0},{href:"/dashboard/proxy-pools",label:"Proxy Pools",icon:"lan",advanced:!0},{href:"/dashboard/skills",label:"Skills",icon:"extension",advanced:!0},{href:"/dashboard/console-log",label:"Console Log",icon:"terminal"},{href:"/dashboard/translator",label:"Translator",icon:"translate",advanced:!0},{href:"/dashboard/profile",label:"Settings",icon:"settings"}],g=[...x.SI],y=[{href:"/dashboard/api-keys",label:"API Keys",icon:"vpn_key"},{href:"/dashboard/personalcloudprovider",label:"Personal OAuth",icon:"cloud_sync"},{href:"/dashboard/personalquota",label:"Personal Quota",icon:"data_usage"},{href:"/dashboard/analytics",label:"Analytics",icon:"monitoring"},{href:"/dashboard/token-saver",label:"Token Saver",icon:"compress"}],v=c.h0?.installCmdLatest||"npm install -g @jheavenknows/bluerouter@latest";function j({href:e,label:t,icon:r,active:a,onClick:l}){return(0,s.jsxs)(o(),{href:e,onClick:l,className:(0,b.cn)("flex items-center gap-3 rounded-xl px-3 py-2.5 text-sm font-medium transition-colors",a?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface hover:text-text-main"),children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:r}),(0,s.jsx)("span",{className:"truncate",children:t})]})}function N({onClose:e}){let t=(0,d.usePathname)(),r=(0,d.useRouter)(),{displayName:l,loginMethod:n,isAdmin:i,isMonitorAdmin:o,isAiGatewaysMonitor:x}=(0,p.s)(),{logoUrl:b,siteShortName:w,siteTitle:k}=(0,h.useBranding)(),C=w||k||"Blue Router",[S,T]=(0,a.useState)(null),[A,_]=(0,a.useState)(!1),[I,M]=(0,a.useState)(!1),[$,P]=(0,a.useState)(!1),[E,R]=(0,a.useState)(""),[O,L]=(0,a.useState)(!0),z=()=>e?.();(0,a.useEffect)(()=>{if(!i)return void T(null);let e=!1;return fetch("/api/version",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>{!e&&t?.hasUpdate&&T(t)}).catch(()=>{}),()=>{e=!0}},[i]),(0,a.useEffect)(()=>{if(!i)return;let e=!1,t=e=>{L(e?.detail?.visible!==!1)};return fetch("/api/settings",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&L(!1!==t.sidebarAdvancedToolsVisible)}).catch(()=>{}),window.addEventListener("bluerouter:sidebar-advanced-tools",t),()=>{e=!0,window.removeEventListener("bluerouter:sidebar-advanced-tools",t)}},[i]),(0,a.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>M(!1),2e3);return()=>clearTimeout(e)},[I]);let q=async()=>{R("");try{return await navigator.clipboard.writeText(S?.installCommand||v),M(!0),!0}catch(e){return R(e?.message||"Could not copy update command. Please copy it manually."),!1}},U=async()=>{if(!$&&await q()){P(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch{}}},D=async()=>{try{await fetch("/api/auth/logout",{method:"POST"})}catch{}r.push("/login"),r.refresh()},F=(i?f:o?g:y).filter(e=>!e.advanced||O),W=i?"Admin":o?"Monitor Admin":x?"AI Gateways Monitor":"User";return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("aside",{className:"flex h-full w-64 flex-col border-r border-border bg-background p-3",children:[(0,s.jsxs)("div",{className:"mb-4 rounded-2xl bg-primary/10 p-4 text-primary",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[b?(0,s.jsx)("img",{src:b,alt:C,className:"h-8 w-8 rounded-md object-contain"}):(0,s.jsx)("span",{className:"material-symbols-outlined text-[28px]",children:"hub"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate font-bold text-text-main",children:C}),(0,s.jsxs)("div",{className:"text-xs text-text-muted",children:["v",c.vQ?.version||"local"]})]})]}),i&&S?(0,s.jsxs)("button",{type:"button",onClick:()=>{R(""),M(!1),_(!0)},className:"mt-3 flex w-full items-center justify-between gap-2 rounded-xl border border-amber-400/40 bg-amber-500/10 px-3 py-2 text-left text-xs font-semibold text-amber-700 transition hover:bg-amber-500/15 dark:text-amber-300",title:`New BlueRouter version available: v${S.latestVersion}`,children:[(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"system_update_alt"}),(0,s.jsxs)("span",{className:"truncate",children:["New v",S.latestVersion]})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"chevron_right"})]}):null,l?(0,s.jsxs)("div",{className:"mt-4 flex items-start gap-2 text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"person"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate text-sm font-semibold text-text-main",children:l}),(0,s.jsxs)("div",{className:"text-xs",children:[W,n?` \xb7 ${n}`:""]})]})]}):null]}),(0,s.jsx)("div",{className:"mb-4 grid gap-2 border-b border-border pb-4",children:(0,s.jsxs)("button",{type:"button",onClick:D,className:"flex w-full items-center justify-between gap-3 rounded-2xl border border-border bg-surface/70 px-3 py-2.5 text-left text-sm font-semibold text-text-muted transition hover:border-border-subtle hover:bg-surface hover:text-text-main",children:[(0,s.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"logout"}),(0,s.jsx)("span",{className:"truncate",children:"Logout"})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px] opacity-60",children:"chevron_right"})]})}),(0,s.jsx)("nav",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto pr-1",children:F.map(e=>{var r;return(0,s.jsx)(j,{href:e.href,label:e.label,icon:e.icon,active:"/dashboard/endpoint"===(r=e.href)?"/dashboard"===t||t.startsWith("/dashboard/endpoint"):t===r||t.startsWith(`${r}/`),onClick:z},e.href)})})]}),(0,s.jsx)(u.default,{isOpen:A,onClose:()=>{$||_(!1)},title:"Update BlueRouter",size:"md",closeOnOverlay:!$,footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.default,{type:"button",variant:"ghost",onClick:()=>_(!1),disabled:$,children:"Cancel"}),(0,s.jsx)(m.default,{type:"button",variant:"secondary",onClick:q,disabled:$,children:I?"Copied":"Copy command"}),(0,s.jsx)(m.default,{type:"button",variant:"primary",onClick:U,loading:$,children:"Copy & shutdown"})]}),children:(0,s.jsxs)("div",{className:"space-y-4 text-sm text-text-muted",children:[(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-surface p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{children:"Current version"}),(0,s.jsxs)("span",{className:"font-mono font-semibold text-text-main",children:["v",S?.currentVersion||c.vQ?.version||"local"]})]}),(0,s.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{children:"Latest npm version"}),(0,s.jsxs)("span",{className:"font-mono font-semibold text-primary",children:["v",S?.latestVersion||"unknown"]})]}),(0,s.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{children:"NPM package"}),(0,s.jsx)("span",{className:"truncate font-mono text-xs text-text-main",children:S?.packageName||c.h0?.npmPackageName||"@jheavenknows/bluerouter"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"mb-2 font-medium text-text-main",children:"Install command"}),(0,s.jsx)("pre",{className:"overflow-x-auto rounded-xl border border-border bg-bg-subtle px-3 py-2 font-mono text-xs text-text-main",children:S?.installCommand||v})]}),(0,s.jsxs)("ol",{className:"list-decimal space-y-1 pl-5",children:[(0,s.jsxs)("li",{children:["Click ",(0,s.jsx)("span",{className:"font-semibold text-text-main",children:"Copy & shutdown"}),"."]}),(0,s.jsx)("li",{children:"Paste the command into the server terminal and run it."}),(0,s.jsx)("li",{children:"Start BlueRouter again after npm finishes installing."})]}),E?(0,s.jsx)("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 px-3 py-2 text-red-600 dark:text-red-300",children:E}):null,$?(0,s.jsx)("div",{className:"rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300",children:"Command copied. BlueRouter is shutting down so you can run the npm update command safely."}):null]})})]})}j.propTypes={href:n().string.isRequired,label:n().string.isRequired,icon:n().string.isRequired,active:n().bool,onClick:n().func},N.propTypes={onClose:n().func}},93308:(e,t,r)=>{r.d(t,{CL:()=>l,QC:()=>n,Xn:()=>a,YZ:()=>s});let s=["en","vi","zh-CN","zh-TW","ja","pt-BR","pt-PT","ko","es","de","fr","he","ar","ru","pl","cs","nl","tr","uk","tl","id","th","hi","bn","ur","ro","sv","it","el","hu","fi","da","no"],a="en",l="locale";function n(e){return"zh"===e||"zh-CN"===e?"zh-CN":"en"===e?"en":"vi"===e?"vi":"zh-TW"===e?"zh-TW":"ja"===e?"ja":"pt-BR"===e?"pt-BR":"pt-PT"===e?"pt-PT":"ko"===e?"ko":"es"===e?"es":"de"===e?"de":"fr"===e?"fr":"he"===e?"he":"ar"===e?"ar":"ru"===e?"ru":"pl"===e?"pl":"cs"===e?"cs":"nl"===e?"nl":"tr"===e?"tr":"uk"===e?"uk":"tl"===e?"tl":"id"===e?"id":"th"===e?"th":"hi"===e?"hi":"bn"===e?"bn":"ur"===e?"ur":"ro"===e?"ro":"sv"===e?"sv":"it"===e?"it":"el"===e?"el":"hu"===e?"hu":"fi"===e?"fi":"da"===e?"da":"no"===e?"no":a}},94027:(e,t,r)=>{r.d(t,{Y:()=>o,s:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l);let i=(0,a.createContext)(null);function o({children:e}){let[t,r]=(0,a.useState)(null),[l,n]=(0,a.useState)(!0),[d,c]=(0,a.useState)(""),m=(0,a.useCallback)(async()=>{n(!0),c("");try{let e=await fetch("/api/auth/status",{cache:"no-store"}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t?.error||"Kh\xf4ng tải được trạng th\xe1i đăng nhập");return r(t||{}),t||{}}catch(e){return c(e?.message||"Kh\xf4ng tải được trạng th\xe1i đăng nhập"),r({}),{}}finally{n(!1)}},[]);(0,a.useEffect)(()=>{let e=!1;return(async()=>{n(!0),c("");try{let t=await fetch("/api/auth/status",{cache:"no-store"}),s=await t.json().catch(()=>({}));if(e)return;if(!t.ok)throw Error(s?.error||"Kh\xf4ng tải được trạng th\xe1i đăng nhập");r(s||{})}catch(t){e||(c(t?.message||"Kh\xf4ng tải được trạng th\xe1i đăng nhập"),r({}))}finally{e||n(!1)}})(),()=>{e=!0}},[]);let u=(0,a.useMemo)(()=>{let e,r,s,a,l;return r=(e=t&&"object"==typeof t?t:{}).displayName||e.oidcName||e.oidcEmail||e.userId||"",s=!0===e.isAdmin,a=!0===e.isMonitorAdmin,l=!0===e.isAiGatewaysMonitor,{status:e,displayName:r,userId:e.userId||"",loginMethod:e.loginMethod||"",role:e.role||"guest",isAdmin:s,isMonitorAdmin:a,isAiGatewaysMonitor:l,canManageApiKeys:!0===e.canManageApiKeys||s||a,canUseMonitorAdminTabs:!0===e.canUseMonitorAdminTabs||s||a,canViewAllAnalytics:!0===e.canViewAllAnalytics||s||a||l}},[t]),x=(0,a.useMemo)(()=>({...u,loading:l,error:d,reload:m}),[u,l,d,m]);return(0,s.jsx)(i.Provider,{value:x,children:e})}function d(){let e=(0,a.useContext)(i);return e||{status:{},displayName:"",userId:"",loginMethod:"",role:"admin",isAdmin:!0,isMonitorAdmin:!1,isAiGatewaysMonitor:!1,canManageApiKeys:!0,canUseMonitorAdminTabs:!0,canViewAllAnalytics:!0,loading:!1,error:"",reload:async()=>({})}}o.propTypes={children:n().node}},94230:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497),o=r(11059);function d({isOpen:e,provider:t,onSuccess:r,onClose:l}){let[n,c]=(0,a.useState)("loading"),[m,u]=(0,a.useState)(""),[x,p]=(0,a.useState)(null),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)(null),{copied:y,copy:v}=(0,o.C)();(0,a.useEffect)(()=>{e&&t&&(async()=>{try{g(null),c("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),r=await e.json();if(!e.ok)throw Error(r.error);p(r),u(r.authUrl),c("input"),window.open(r.authUrl,"_blank")}catch(e){g(e.message),c("error")}})()},[e,t]);let j=async()=>{try{let e;g(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let s=e.searchParams.get("code");e.searchParams.get("state");let a=e.searchParams.get("error");if(a)throw Error(e.searchParams.get("error_description")||a);if(!s)throw Error("No authorization code found in URL");let l=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:s,codeVerifier:x.codeVerifier,provider:t})}),n=await l.json();if(!l.ok)throw Error(n.error);c("success"),r?.()}catch(e){g(e.message),c("error")}},N="google"===t?"Google":"GitHub";return(0,s.jsx)(i.aF,{isOpen:e,title:`Connect Kiro via ${N}`,onClose:l,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",N," authentication"]})]}),"input"===n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.pd,{value:m,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.$n,{variant:"secondary",icon:"auth_url"===y?"check":"content_copy",onClick:()=>v(m,"auth_url"),children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,s.jsx)(i.pd,{value:h,onChange:e=>b(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:j,fullWidth:!0,disabled:!h,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",N," has been connected."]}),(0,s.jsx)(i.$n,{onClick:l,fullWidth:!0,children:"Done"})]}),"error"===n&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:f}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:()=>c("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(i.$n,{onClick:l,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:n().bool.isRequired,provider:n().oneOf(["google","github"]).isRequired,onSuccess:n().func,onClose:n().func.isRequired}},95088:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497);let o="https://gitlab.com";function d({isOpen:e,providerInfo:t,onSuccess:r,onClose:l}){let n,[c,m]=(0,a.useState)(null),[u,x]=(0,a.useState)(o),[p,h]=(0,a.useState)(""),[b,f]=(0,a.useState)(""),[g,y]=(0,a.useState)(""),[v,j]=(0,a.useState)(!1),[N,w]=(0,a.useState)(null),[k,C]=(0,a.useState)(!1),[S,T]=(0,a.useState)(null),A=()=>{m(null),x(o),h(""),f(""),y(""),w(null),j(!1),C(!1),T(null),l()},_=async()=>{if(!g.trim())return void w("Personal Access Token is required");j(!0),w(null);try{let e=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:g.trim(),baseUrl:u.trim()||o})}),t=await e.json();if(!e.ok)throw Error(t.error||"Authentication failed");r?.(),A()}catch(e){w(e.message)}finally{j(!1)}};return e?k&&S?(0,s.jsx)(i.LF,{isOpen:!0,provider:"gitlab",providerInfo:t,oauthMeta:S,onSuccess:()=>{r?.(),A()},onClose:()=>{C(!1),T(null)}}):(0,s.jsx)(i.aF,{isOpen:e,title:"Connect GitLab Duo",onClose:A,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[!c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("button",{onClick:()=>m("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,s.jsxs)("button",{onClick:()=>m("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:(n=window.location.port||("https:"===window.location.protocol?"443":"80"),`http://localhost:${n}/callback`)})]}),(0,s.jsx)(i.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(i.pd,{label:"Client ID",value:p,onChange:e=>h(e.target.value),placeholder:"Your OAuth application client ID"}),(0,s.jsx)(i.pd,{label:"Client Secret (optional for PKCE)",value:b,onChange:e=>f(e.target.value),placeholder:"Leave empty for public PKCE app"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:()=>{p.trim()?(w(null),T({baseUrl:u.trim()||o,clientId:p.trim(),clientSecret:b.trim()}),C(!0)):w("Client ID is required")},fullWidth:!0,disabled:!p.trim(),children:"Authorize"}),(0,s.jsx)(i.$n,{onClick:()=>{m(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,s.jsx)(i.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(i.pd,{label:"Personal Access Token",value:g,onChange:e=>y(e.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:_,fullWidth:!0,disabled:!g.trim()||v,loading:v,children:"Connect"}),(0,s.jsx)(i.$n,{onClick:()=>{m(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}d.propTypes={isOpen:n().bool.isRequired,providerInfo:n().shape({name:n().string}),onSuccess:n().func,onClose:n().func.isRequired}},96748:(e,t,r)=>{r.d(t,{default:()=>d});var s=r(95155),a=r(12115),l=r(14051),n=r.n(l),i=r(35497);let o="https://api.openai.com/v1";function d({isOpen:e,onClose:t,onCreated:r,onSaved:l,node:n}){let c=!!n,[m,u]=(0,a.useState)({name:"",prefix:"",baseUrl:o}),[x,p]=(0,a.useState)(!1),[h,b]=(0,a.useState)(""),[f,g]=(0,a.useState)(""),[y,v]=(0,a.useState)(!1),[j,N]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(N(null),b(""),g(""),c?u({name:n.name||"",prefix:n.prefix||"",baseUrl:n.baseUrl||o}):u({name:"",prefix:"",baseUrl:o}))},[e,c,n]);let w=async()=>{if(m.name.trim()&&m.prefix.trim()&&m.baseUrl.trim()){p(!0);try{let e=c?`/api/provider-nodes/${n.id}`:"/api/provider-nodes",t=c?"PUT":"POST",s={name:m.name,prefix:m.prefix,baseUrl:m.baseUrl};c||(s.type="custom-embedding");let a=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),i=await a.json();a.ok&&(c?l?.(i.node):r?.(i.node))}catch(e){console.log("Error saving custom embedding node:",e)}finally{p(!1)}}},k=async()=>{v(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:m.baseUrl,apiKey:h,type:"custom-embedding",modelId:f.trim()||void 0})}),t=await e.json();N(t)}catch{N({valid:!1,error:"Network error"})}finally{v(!1)}};return(0,s.jsx)(i.aF,{isOpen:e,title:c?"Edit Custom Embedding":"Add Custom Embedding",onClose:t,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(i.pd,{label:"Name",value:m.name,onChange:e=>u({...m,name:e.target.value}),placeholder:"Voyage AI",hint:"Required. A friendly label for this embedding provider."}),(0,s.jsx)(i.pd,{label:"Prefix",value:m.prefix,onChange:e=>u({...m,prefix:e.target.value}),placeholder:"voyage",hint:"Required. Used as the provider prefix for model IDs (e.g. voyage/voyage-3)."}),(0,s.jsx)(i.pd,{label:"Base URL",value:m.baseUrl,onChange:e=>u({...m,baseUrl:e.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"Most embedding APIs are OpenAI-compatible: Voyage, Cohere, Jina, Mistral, Together..."}),(0,s.jsx)(i.pd,{label:"API Key (for Check)",type:"password",value:h,onChange:e=>b(e.target.value)}),(0,s.jsx)(i.pd,{label:"Model ID (for Check)",value:f,onChange:e=>g(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",hint:"Required for validation. Will send a test embeddings request."}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(i.$n,{onClick:k,disabled:!h||!f.trim()||y||!m.baseUrl.trim(),variant:"secondary",children:y?"Checking...":"Check"}),(()=>{if(!j)return null;let{valid:e,error:t,dimensions:r}=j;return e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Ex,{variant:"success",children:"Valid"}),r&&(0,s.jsxs)("span",{className:"text-sm text-text-muted",children:[r," dims"]})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)(i.Ex,{variant:"error",children:"Invalid"}),t&&(0,s.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.$n,{onClick:w,fullWidth:!0,disabled:!m.name.trim()||!m.prefix.trim()||!m.baseUrl.trim()||x,children:x?c?"Saving...":"Creating...":c?"Save":"Create"}),(0,s.jsx)(i.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}d.propTypes={isOpen:n().bool.isRequired,onClose:n().func.isRequired,onCreated:n().func,onSaved:n().func,node:n().shape({id:n().string,name:n().string,prefix:n().string,baseUrl:n().string})}},97677:(e,t,r)=>{r.d(t,{default:()=>a});var s=r(95155);function a({text:e,children:t,position:r="top",color:l}){let n=l?"":"bg-gray-900";return(0,s.jsxs)("div",{className:"relative inline-flex group",children:[t,(0,s.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[r]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${n} text-white opacity-0 group-hover:opacity-100 transition-opacity duration-150 whitespace-normal`,style:l?{backgroundColor:l}:{},children:e})]})}},98542:(e,t,r)=>{r.d(t,{default:()=>l});var s=r(95155),a=r(31474);function l({checked:e=!1,onChange:t,label:r,description:n,disabled:i=!1,size:o="md",className:d}){let c={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,s.jsxs)("div",{className:(0,a.cn)("flex items-center gap-3",i&&"opacity-50 cursor-not-allowed",d),children:[(0,s.jsx)("button",{type:"button",role:"switch","aria-checked":e,disabled:i,onClick:()=>{!i&&t&&t(!e)},className:(0,a.cn)("relative inline-flex shrink-0 cursor-pointer rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus:ring-2 focus:ring-brand-500/30",e?"bg-brand-500":"bg-surface-3",c[o].track,i&&"cursor-not-allowed"),children:(0,s.jsx)("span",{className:(0,a.cn)("pointer-events-none inline-block rounded-full bg-white shadow-sm","transform transition duration-200 ease-in-out",e?c[o].translate:"translate-x-0.5",c[o].thumb,"mt-0.5")})}),(r||n)&&(0,s.jsxs)("div",{className:"flex flex-col",children:[r&&(0,s.jsx)("span",{className:"text-sm font-medium text-text-main",children:r}),n&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:n})]})]})}}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9839],{93413:(e,t,s)=>{Promise.resolve().then(s.bind(s,96180))},96180:(e,t,s)=>{"use strict";s.d(t,{default:()=>f});var r=s(95155),a=s(12115);s(97677);let l=[{value:"24h",label:"24h"},{value:"7d",label:"7 ng\xe0y"},{value:"30d",label:"30 ng\xe0y"},{value:"all",label:"Tất cả"}];function i(e){return new Intl.NumberFormat("en-US").format(Number(e||0))}function d(e){let t=Number(e||0);if(t<1024)return`${i(t)} B`;let s=["KB","MB","GB","TB"],r=t/1024,a=0;for(;r>=1024&&a<s.length-1;)r/=1024,a+=1;return`${r>=100?r.toFixed(0):r>=10?r.toFixed(1):r.toFixed(2)} ${s[a]}`}function n(e){let t=Number(e||0);return`${t.toFixed(t>=10?1:2)}%`}function c(e){let t=String(e||"");return t.length<=18?t||"-":`${t.slice(0,10)}…${t.slice(-6)}`}function x({icon:e,label:t,value:s,hint:a,tone:l="default"}){return(0,r.jsxs)("div",{className:`rounded-2xl border p-5 shadow-sm ${"success"===l?"border-emerald-500/20 bg-emerald-500/5 text-emerald-700 dark:text-emerald-300":"warning"===l?"border-amber-500/20 bg-amber-500/5 text-amber-700 dark:text-amber-300":"border-border bg-background text-text-main"}`,children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted",children:t}),(0,r.jsx)("div",{className:"mt-2 text-2xl font-bold text-text-main",children:s})]}),(0,r.jsx)("span",{className:"material-symbols-outlined rounded-xl bg-surface px-2.5 py-2 text-[22px] text-primary",children:e})]}),a?(0,r.jsx)("div",{className:"mt-3 text-xs text-text-muted",children:a}):null]})}function o({value:e}){let t=Math.max(0,Math.min(100,Number(e||0)));return(0,r.jsx)("div",{className:"h-2 w-full overflow-hidden rounded-full bg-surface",children:(0,r.jsx)("div",{className:"h-full rounded-full bg-primary",style:{width:`${t}%`}})})}function m(){return(0,r.jsx)("span",{className:"ml-1 rounded-full border border-amber-500/30 bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700 dark:text-amber-300",title:"Số request c\xf3 hit < 5 — con số hiệu quả c\xf3 thể chưa đại diện",children:"low sample"})}function h({title:e,icon:t,rows:s,columns:a="default",showEmpty:l=!0}){let c=l?s:(s||[]).filter(e=>Number(e.hitCount||0)>0);return(0,r.jsxs)("section",{className:"rounded-2xl border border-border bg-background p-5 shadow-sm",children:[(0,r.jsx)("div",{className:"mb-4 flex items-center justify-between gap-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary",children:t}),(0,r.jsx)("h2",{className:"text-base font-bold text-text-main",children:e})]})}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-left text-xs uppercase tracking-wide text-text-muted",children:(0,r.jsxs)("tr",{className:"border-b border-border",children:[(0,r.jsx)("th",{className:"pb-2 pr-4 font-semibold",children:"T\xean"}),(0,r.jsx)("th",{className:"pb-2 pr-4 text-right font-semibold",children:"Requests"}),(0,r.jsx)("th",{className:"pb-2 pr-4 text-right font-semibold",children:"Hits"}),(0,r.jsx)("th",{className:"pb-2 pr-4 text-right font-semibold",children:"Saved"}),(0,r.jsx)("th",{className:"pb-2 pr-4 text-right font-semibold",title:"filter"===a?"Phần trăm đ\xf3ng g\xf3p v\xe0o tổng saved":"bytesSaved / bytesBefore tr\xean to\xe0n bộ text đ\xe3 scan (kể cả kh\xf4ng match filter)",children:"filter"===a?"Share":"Saved / scanned"}),"filter"===a?null:(0,r.jsx)("th",{className:"pb-2 text-right font-semibold",title:"bytesSaved / bytesBefore CHỈ t\xednh tr\xean request c\xf3 hit (applied=true) — hiệu quả n\xe9n thực sự của RTK",children:"Saved / applied"})]})}),(0,r.jsx)("tbody",{children:c?.length?c.map(e=>{let t=Number(e.appliedRequests||0),s=Number(e.hitCount||0);return(0,r.jsxs)("tr",{className:"border-b border-border/60 last:border-0",children:[(0,r.jsxs)("td",{className:"max-w-[280px] py-3 pr-4 font-medium text-text-main",children:[(0,r.jsx)("div",{className:"truncate",title:e.key,children:e.key}),"filter"===a?(0,r.jsxs)("div",{className:"text-xs text-text-muted",children:[i(e.hitCount)," hit \xb7 ~",i(e.estimatedTokensSaved)," token"]}):null]}),(0,r.jsx)("td",{className:"py-3 pr-4 text-right text-text-muted",children:i(e.requests||e.appliedRequests)}),(0,r.jsx)("td",{className:"py-3 pr-4 text-right text-text-muted",children:i(e.hitCount)}),(0,r.jsx)("td",{className:"py-3 pr-4 text-right font-semibold text-emerald-600 dark:text-emerald-300",children:d(e.bytesSaved)}),(0,r.jsx)("td",{className:"py-3 pr-4 text-right text-text-muted",children:n(e.savedPct)}),"filter"===a?null:(0,r.jsx)("td",{className:"py-3 text-right font-semibold text-primary",children:s>0?(0,r.jsxs)(r.Fragment,{children:[n(e.appliedSavedPct),s>0&&t>0&&t<5?(0,r.jsx)(m,{}):null]}):"—"})]},e.key)}):(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:"filter"===a?5:6,className:"py-6 text-center text-text-muted",children:l?"Chưa c\xf3 dữ liệu RTK trong khoảng thời gian n\xe0y.":"Kh\xf4ng c\xf3 row n\xe0o c\xf3 hit trong khoảng thời gian n\xe0y."})})})]})})]})}function u({rows:e}){let t=Math.max(1,...(e||[]).map(e=>Number(e.bytesSaved||0))),s=(e||[]).slice(-30);return(0,r.jsxs)("section",{className:"rounded-2xl border border-border bg-background p-5 shadow-sm",children:[(0,r.jsxs)("div",{className:"mb-4 flex items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary",children:"stacked_bar_chart"}),(0,r.jsx)("h2",{className:"text-base font-bold text-text-main",children:"Savings trend"})]}),(0,r.jsx)("div",{className:"text-xs text-text-muted",children:"Theo bucket thời gian (local)"})]}),s.length?(0,r.jsx)("div",{className:"flex h-56 items-end gap-2 rounded-2xl bg-surface/60 px-4 py-4",children:s.map(e=>{let s=Math.max(4,Math.round(Number(e.bytesSaved||0)/t*100)),a=function(e){if(!e)return{full:"-",short:"-"};let t=String(e);if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(t)){let e=new Date(`${t}:00Z`);return Number.isNaN(e.getTime())?{full:t,short:t.slice(-5)}:{full:e.toLocaleString("vi-VN",{hour12:!1}),short:e.toLocaleTimeString("vi-VN",{hour12:!1,hour:"2-digit",minute:"2-digit"})}}if(/^\d{4}-\d{2}-\d{2}$/.test(t)){let e=new Date(`${t}T00:00:00Z`);return Number.isNaN(e.getTime())?{full:t,short:t.slice(5)}:{full:e.toLocaleDateString("vi-VN"),short:e.toLocaleDateString("vi-VN",{day:"2-digit",month:"2-digit"})}}return{full:t,short:t.slice(-5)}}(e.key);return(0,r.jsxs)("div",{className:"flex h-full min-w-0 flex-1 flex-col items-center gap-2",children:[(0,r.jsxs)("div",{className:"group relative flex min-h-0 w-full flex-1 items-end justify-center",children:[(0,r.jsx)("div",{className:"w-full rounded-t-lg bg-primary/80 transition hover:bg-primary",style:{height:`${s}%`,minHeight:4}}),(0,r.jsxs)("div",{className:"pointer-events-none absolute bottom-full z-10 mb-2 hidden min-w-max rounded-xl border border-border bg-background px-3 py-2 text-xs shadow-lg group-hover:block",children:[(0,r.jsx)("div",{className:"font-semibold text-text-main",children:a.full}),(0,r.jsxs)("div",{className:"text-text-muted",children:["Saved: ",d(e.bytesSaved)]}),(0,r.jsxs)("div",{className:"text-text-muted",children:["Requests: ",i(e.requests)]})]})]}),(0,r.jsx)("div",{className:"w-full truncate text-center text-[10px] text-text-muted",title:a.full,children:a.short})]},e.key)})}):(0,r.jsx)("div",{className:"rounded-2xl bg-surface/60 py-12 text-center text-sm text-text-muted",children:"Chưa c\xf3 trend data."})]})}function b({rows:e}){return(0,r.jsxs)("section",{className:"rounded-2xl border border-border bg-background p-5 shadow-sm",children:[(0,r.jsxs)("div",{className:"mb-4 flex items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary",children:"history"}),(0,r.jsx)("h2",{className:"text-base font-bold text-text-main",children:"Recent RTK hits"})]}),(0,r.jsx)("div",{className:"text-xs text-text-muted",children:"Kh\xf4ng hiển thị nội dung prompt/tool output"})]}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-left text-xs uppercase tracking-wide text-text-muted",children:(0,r.jsxs)("tr",{className:"border-b border-border",children:[(0,r.jsx)("th",{className:"pb-2 pr-4 font-semibold",children:"Time"}),(0,r.jsx)("th",{className:"pb-2 pr-4 font-semibold",children:"Source"}),(0,r.jsx)("th",{className:"pb-2 pr-4 font-semibold",children:"Provider / Model"}),(0,r.jsx)("th",{className:"pb-2 pr-4 font-semibold",children:"API key"}),(0,r.jsx)("th",{className:"pb-2 pr-4 font-semibold",children:"Filters"}),(0,r.jsx)("th",{className:"pb-2 pr-4 text-right font-semibold",children:"Saved"}),(0,r.jsx)("th",{className:"pb-2 text-right font-semibold",children:"Request"})]})}),(0,r.jsx)("tbody",{children:e?.length?e.map((e,t)=>(0,r.jsxs)("tr",{className:"border-b border-border/60 last:border-0",children:[(0,r.jsx)("td",{className:"whitespace-nowrap py-3 pr-4 text-text-muted",children:function(e){if(!e)return"-";let t=new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString("vi-VN",{hour12:!1})}(e.timestamp)}),(0,r.jsx)("td",{className:"py-3 pr-4 text-text-muted",children:e.sourceTool||"unknown"}),(0,r.jsxs)("td",{className:"max-w-[260px] py-3 pr-4",children:[(0,r.jsx)("div",{className:"font-medium text-text-main",children:e.provider}),(0,r.jsx)("div",{className:"truncate text-xs text-text-muted",title:e.model,children:e.model})]}),(0,r.jsxs)("td",{className:"max-w-[200px] py-3 pr-4",children:[(0,r.jsx)("div",{className:"truncate font-medium text-text-main",title:e.apiKeyName||e.apiKeyId||"-",children:e.apiKeyName||e.apiKeyId||"-"}),e.apiKeyOwner?(0,r.jsx)("div",{className:"truncate text-xs text-text-muted",title:e.apiKeyOwner,children:e.apiKeyOwner}):null]}),(0,r.jsx)("td",{className:"py-3 pr-4",children:(0,r.jsx)("div",{className:"flex max-w-[320px] flex-wrap gap-1.5",children:(e.filters||[]).slice(0,4).map(e=>(0,r.jsx)("span",{className:"rounded-full border border-border bg-surface px-2 py-0.5 text-xs text-text-muted",children:e},e))})}),(0,r.jsxs)("td",{className:"py-3 pr-4 text-right font-semibold text-emerald-600 dark:text-emerald-300",children:[d(e.bytesSaved),(0,r.jsx)("div",{className:"text-xs font-normal text-text-muted",children:n(e.savedPct)})]}),(0,r.jsx)("td",{className:"py-3 text-right font-mono text-xs text-text-muted",title:e.requestId,children:c(e.requestId)})]},`${e.requestId||t}-${e.timestamp}`)):(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:7,className:"py-6 text-center text-text-muted",children:"Chưa c\xf3 request n\xe0o được RTK n\xe9n th\xe0nh c\xf4ng."})})})]})})]})}function p({rows:e,showEmpty:t=!0}){let s=t?e:(e||[]).filter(e=>Number(e.hitCount||0)>0);return(0,r.jsxs)("section",{className:"rounded-2xl border border-border bg-background p-5 shadow-sm",children:[(0,r.jsx)("div",{className:"mb-4 flex items-center justify-between gap-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-primary",children:"vpn_key"}),(0,r.jsx)("h2",{className:"text-base font-bold text-text-main",children:"Top API keys"})]})}),(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"min-w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-left text-xs uppercase tracking-wide text-text-muted",children:(0,r.jsxs)("tr",{className:"border-b border-border",children:[(0,r.jsx)("th",{className:"pb-2 pr-4 font-semibold",children:"API key"}),(0,r.jsx)("th",{className:"pb-2 pr-4 font-semibold",children:"Owner"}),(0,r.jsx)("th",{className:"pb-2 pr-4 text-right font-semibold",children:"Requests"}),(0,r.jsx)("th",{className:"pb-2 pr-4 text-right font-semibold",children:"Hits"}),(0,r.jsx)("th",{className:"pb-2 pr-4 text-right font-semibold",children:"Saved"}),(0,r.jsx)("th",{className:"pb-2 pr-4 text-right font-semibold",title:"bytesSaved / bytesBefore tr\xean to\xe0n bộ text đ\xe3 scan (kể cả kh\xf4ng match filter)",children:"Saved / scanned"}),(0,r.jsx)("th",{className:"pb-2 text-right font-semibold",title:"bytesSaved / bytesBefore CHỈ t\xednh tr\xean request c\xf3 hit (applied=true) — hiệu quả n\xe9n thực sự của RTK",children:"Saved / applied"})]})}),(0,r.jsx)("tbody",{children:s?.length?s.map(e=>{let t=Number(e.appliedRequests||0),s=Number(e.hitCount||0);return(0,r.jsxs)("tr",{className:"border-b border-border/60 last:border-0",children:[(0,r.jsxs)("td",{className:"max-w-[260px] py-3 pr-4 font-medium text-text-main",children:[(0,r.jsx)("div",{className:"truncate",title:e.apiKeyName||e.apiKeyId||e.key,children:e.apiKeyName||e.apiKeyId||e.key}),e.apiKeyId?(0,r.jsx)("div",{className:"truncate font-mono text-xs text-text-muted",title:e.apiKeyId,children:c(e.apiKeyId)}):null]}),(0,r.jsx)("td",{className:"max-w-[200px] py-3 pr-4 text-text-muted",children:(0,r.jsx)("div",{className:"truncate",title:e.apiKeyOwner||"-",children:e.apiKeyOwner||"-"})}),(0,r.jsx)("td",{className:"py-3 pr-4 text-right text-text-muted",children:i(e.requests||e.appliedRequests)}),(0,r.jsx)("td",{className:"py-3 pr-4 text-right text-text-muted",children:i(e.hitCount)}),(0,r.jsx)("td",{className:"py-3 pr-4 text-right font-semibold text-emerald-600 dark:text-emerald-300",children:d(e.bytesSaved)}),(0,r.jsx)("td",{className:"py-3 pr-4 text-right text-text-muted",children:n(e.savedPct)}),(0,r.jsx)("td",{className:"py-3 text-right font-semibold text-primary",children:s>0?(0,r.jsxs)(r.Fragment,{children:[n(e.appliedSavedPct),s>0&&t>0&&t<5?(0,r.jsx)(m,{}):null]}):"—"})]},e.key)}):(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:7,className:"py-6 text-center text-text-muted",children:t?"Chưa c\xf3 API key n\xe0o c\xf3 RTK stats.":"Kh\xf4ng c\xf3 API key n\xe0o c\xf3 hit trong khoảng thời gian n\xe0y."})})})]})})]})}function f(){let[e,t]=(0,a.useState)("24h"),[s,c]=(0,a.useState)(null),[m,f]=(0,a.useState)(!0),[g,j]=(0,a.useState)(""),[N,y]=(0,a.useState)(!1),v=(0,a.useMemo)(()=>{let t=new URLSearchParams;return t.set("period",e),t.toString()},[e]),w=(0,a.useCallback)(async()=>{f(!0),j("");try{let e=await fetch(`/api/dashboard/token-saver?${v}`,{cache:"no-store"}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t?.error||`HTTP ${e.status}`);c(t)}catch(e){j(e?.message||"Kh\xf4ng tải được Token Saver Analytics"),c(null)}finally{f(!1)}},[v]);(0,a.useEffect)(()=>{w()},[w]);let k=s?.summary||{},S=k.measuredRequests>0;return(0,r.jsx)("main",{className:"space-y-6 p-6",children:(0,r.jsxs)("section",{className:"overflow-hidden rounded-3xl border border-border bg-background shadow-sm",children:[(0,r.jsx)("div",{className:"border-b border-border bg-gradient-to-r from-primary/10 via-background to-background p-6",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"rounded-full border border-emerald-500/20 bg-emerald-500/10 px-3 py-1 text-xs font-semibold text-emerald-700 dark:text-emerald-300",children:"Read-only"}),s?.viewerScope==="own"?(0,r.jsx)("span",{className:"rounded-full border border-amber-500/20 bg-amber-500/10 px-3 py-1 text-xs font-semibold text-amber-700 dark:text-amber-300",children:"Chỉ hiển thị API key của bạn"}):(0,r.jsx)("span",{className:"rounded-full border border-border bg-surface px-3 py-1 text-xs font-semibold text-text-muted",children:"To\xe0n hệ thống"}),(0,r.jsx)("span",{className:"rounded-full border border-border bg-surface px-3 py-1 text-xs font-semibold text-text-muted",children:"No routing change"})]}),(0,r.jsx)("h1",{className:"text-2xl font-bold text-text-main",children:"Token Saver Analytics"}),(0,r.jsx)("p",{className:"mt-1 max-w-3xl text-sm text-text-muted",children:"Theo d\xf5i hiệu quả RTK Token Saver tr\xean request thật: byte tiết kiệm, filter n\xe0o hoạt động, source tool/provider/model n\xe0o tiết kiệm nhiều nhất."})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("div",{className:"flex rounded-2xl border border-border bg-surface p-1",children:l.map(s=>(0,r.jsx)("button",{type:"button",onClick:()=>t(s.value),className:`rounded-xl px-3 py-2 text-sm font-semibold transition ${e===s.value?"bg-primary text-white":"text-text-muted hover:bg-background hover:text-text-main"}`,children:s.label},s.value))}),(0,r.jsxs)("button",{type:"button",onClick:()=>y(e=>!e),className:`inline-flex items-center gap-2 rounded-2xl border px-4 py-2 text-sm font-semibold transition ${N?"border-primary/40 bg-primary/10 text-primary":"border-border bg-background text-text-muted hover:bg-surface"}`,title:"Bật để hiển thị cả những provider/model/api-key/source-tool kh\xf4ng c\xf3 hit RTK n\xe0o",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:N?"visibility":"visibility_off"}),N?"Ẩn 0-hit":"Hiện 0-hit"]}),(0,r.jsxs)("button",{type:"button",onClick:w,disabled:m,className:"inline-flex items-center gap-2 rounded-2xl border border-border bg-background px-4 py-2 text-sm font-semibold text-text-main transition hover:bg-surface disabled:opacity-50",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[18px] ${m?"animate-spin":""}`,children:"refresh"}),"Refresh"]})]})]})}),g?(0,r.jsx)("div",{className:"m-6 rounded-2xl border border-red-500/20 bg-red-500/10 p-4 text-sm text-red-700 dark:text-red-300",children:"Authentication required"===g?"Vui l\xf2ng đăng nhập lại để xem Token Saver Analytics.":g}):null,m&&!s?(0,r.jsxs)("div",{className:"flex min-h-[320px] items-center justify-center text-sm text-text-muted",children:[(0,r.jsx)("span",{className:"material-symbols-outlined mr-2 animate-spin",children:"progress_activity"}),"Đang tải Token Saver Analytics..."]}):(0,r.jsxs)("div",{className:"space-y-6 p-6",children:[s?.unavailable?(0,r.jsx)("div",{className:"rounded-2xl border border-amber-500/20 bg-amber-500/10 p-4 text-sm text-amber-700 dark:text-amber-300",children:"MySQL observability chưa sẵn s\xe0ng, kh\xf4ng đọc được dữ liệu Token Saver."}):null,s?.summary?.truncated?(0,r.jsxs)("div",{className:"rounded-2xl border border-amber-500/20 bg-amber-500/10 p-4 text-sm text-amber-700 dark:text-amber-300",children:["Đang hiển thị mẫu ",i(k.sampledRows)," / ",i(k.totalRows)," rows. Tăng TOKEN_SAVER_ANALYTICS_MAX_ROWS nếu cần thống k\xea chi tiết hơn."]}):null,(0,r.jsxs)("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:[(0,r.jsx)(x,{icon:"compress",label:"Measured requests",value:i(k.measuredRequests),hint:`${i(k.enabledRequests)} request c\xf3 RTK enabled`}),(0,r.jsx)(x,{icon:"savings",label:"Estimated tokens saved",value:`~${i(k.estimatedTokensSaved)}`,hint:`${d(k.bytesSaved)} saved / ${d(k.bytesBefore)} scanned`,tone:"success"}),(0,r.jsx)(x,{icon:"bolt",label:"Hit rate",value:n(k.hitRate),hint:`${i(k.appliedRequests)} request c\xf3 n\xe9n th\xe0nh c\xf4ng`}),(0,r.jsx)(x,{icon:"speed",label:"Avg saved / hit",value:d(k.avgBytesSavedPerAppliedRequest),hint:`${i(k.hitCount)} total filter hits`})]}),(0,r.jsxs)("section",{className:"rounded-2xl border border-border bg-background p-5 shadow-sm",children:[(0,r.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"font-bold text-text-main",children:"RTK efficiency"}),(0,r.jsx)("p",{className:"text-sm text-text-muted",children:"Tỷ lệ byte giảm sau khi RTK n\xe9n tool output."})]}),(0,r.jsxs)("div",{className:"flex items-center gap-6 text-right",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-2xl font-bold text-text-main",children:n(k.savedPct)}),(0,r.jsx)("div",{className:"text-xs text-text-muted",title:"bytesSaved / bytesBefore tr\xean to\xe0n bộ text đ\xe3 scan (kể cả kh\xf4ng match filter)",children:"Saved / scanned"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-2xl font-bold text-primary",children:n(k.appliedSavedPct)}),(0,r.jsx)("div",{className:"text-xs text-text-muted",title:"bytesSaved / bytesBefore CHỈ t\xednh tr\xean request thực sự c\xf3 hit — hiệu quả n\xe9n thật của RTK",children:"Saved / applied"})]})]})]}),(0,r.jsx)(o,{value:k.savedPct})]}),S?null:(0,r.jsxs)("div",{className:"rounded-2xl border border-border bg-surface/60 p-8 text-center",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-4xl text-text-muted",children:"compress"}),(0,r.jsx)("div",{className:"mt-3 font-semibold text-text-main",children:"Chưa c\xf3 rtkStats"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-text-muted",children:"Dữ liệu sẽ xuất hiện sau khi c\xf3 request đi qua RTK-enabled route v\xe0 được ghi v\xe0o usage_events/request_details."})]}),(0,r.jsx)(u,{rows:s?.timeSeries||[]}),(0,r.jsxs)("div",{className:"grid gap-6 xl:grid-cols-2",children:[(0,r.jsx)(h,{title:"Top RTK filters",icon:"filter_alt",rows:s?.byFilter||[],columns:"filter",showEmpty:N}),(0,r.jsx)(h,{title:"Top source tools",icon:"terminal",rows:s?.bySourceTool||[],showEmpty:N})]}),(0,r.jsxs)("div",{className:"grid gap-6 xl:grid-cols-2",children:[(0,r.jsx)(h,{title:"Top providers",icon:"dns",rows:s?.byProvider||[],showEmpty:N}),(0,r.jsx)(h,{title:"Top models",icon:"memory",rows:s?.byModel||[],showEmpty:N})]}),(0,r.jsx)(p,{rows:s?.byApiKey||[],showEmpty:N}),(0,r.jsx)(b,{rows:s?.recentHits||[]})]})]})})}},97677:(e,t,s)=>{"use strict";s.d(t,{default:()=>a});var r=s(95155);function a({text:e,children:t,position:s="top",color:l}){let i=l?"":"bg-gray-900";return(0,r.jsxs)("div",{className:"relative inline-flex group",children:[t,(0,r.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[s]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${i} text-white opacity-0 group-hover:opacity-100 transition-opacity duration-150 whitespace-normal`,style:l?{backgroundColor:l}:{},children:e})]})}}},e=>{e.O(0,[8441,3794,7358],()=>e(e.s=93413)),_N_E=e.O()}]);