9router 0.5.65 → 0.5.69

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 (237) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +10 -10
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/prerender-manifest.json +1 -1
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +2 -2
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  33. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  34. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  35. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  36. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  37. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  38. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  39. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  40. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  41. package/app/.next-cli-build/server/app/_not-found.rsc +4 -4
  42. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +4 -4
  43. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -4
  44. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  45. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +3 -3
  46. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  47. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +2 -2
  48. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
  49. package/app/.next-cli-build/server/app/api/models/custom/route.js +1 -1
  50. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  51. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js +1 -1
  52. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
  53. package/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
  54. package/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
  55. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js +1 -1
  56. package/app/.next-cli-build/server/app/api/translator/send/route.js +1 -1
  57. package/app/.next-cli-build/server/app/api/translator/translate/route.js +1 -1
  58. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js +1 -1
  59. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js +1 -1
  60. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js +1 -1
  61. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js +1 -1
  62. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js +1 -1
  63. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js +1 -1
  64. package/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
  65. package/app/.next-cli-build/server/app/api/v1/models/[...model]/route.js +1 -1
  66. package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
  67. package/app/.next-cli-build/server/app/api/v1/models/route.js +1 -1
  68. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js +1 -1
  69. package/app/.next-cli-build/server/app/api/v1/responses/route.js +1 -1
  70. package/app/.next-cli-build/server/app/api/v1/route.js +1 -1
  71. package/app/.next-cli-build/server/app/api/v1/search/route.js +1 -1
  72. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js +1 -1
  73. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js +1 -1
  74. package/app/.next-cli-build/server/app/api/v1beta/models/route.js +1 -1
  75. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  76. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  77. package/app/.next-cli-build/server/app/callback.html +1 -1
  78. package/app/.next-cli-build/server/app/callback.rsc +4 -4
  79. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +4 -4
  80. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  81. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +4 -4
  82. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  83. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +6 -6
  84. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +6 -6
  85. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +6 -6
  86. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
  87. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  88. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +6 -6
  89. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +6 -6
  90. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +6 -6
  91. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  92. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  93. package/app/.next-cli-build/server/app/dashboard/combos.rsc +6 -6
  94. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +6 -6
  95. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +6 -6
  96. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  97. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  98. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +6 -6
  99. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +6 -6
  100. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +6 -6
  101. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  102. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  103. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +6 -6
  104. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +6 -6
  105. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +6 -6
  106. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
  107. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  108. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +6 -6
  109. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +6 -6
  110. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +6 -6
  111. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  112. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  113. package/app/.next-cli-build/server/app/dashboard/profile.rsc +6 -6
  114. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +6 -6
  115. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +6 -6
  116. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  117. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  118. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +6 -6
  119. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +6 -6
  120. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +6 -6
  121. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  122. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  123. package/app/.next-cli-build/server/app/dashboard/providers.rsc +6 -6
  124. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +6 -6
  125. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +6 -6
  126. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  127. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  128. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +6 -6
  129. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +6 -6
  130. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +6 -6
  131. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  132. package/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
  133. package/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +6 -6
  134. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +6 -6
  135. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +6 -6
  136. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
  137. package/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  138. package/app/.next-cli-build/server/app/dashboard/quota.rsc +7 -7
  139. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +7 -7
  140. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +7 -7
  141. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  142. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  143. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  144. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +4 -4
  145. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
  146. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  147. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +4 -4
  148. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  149. package/app/.next-cli-build/server/app/dashboard/skills.rsc +6 -6
  150. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +6 -6
  151. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +6 -6
  152. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
  153. package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  154. package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +6 -6
  155. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +6 -6
  156. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +6 -6
  157. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
  158. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  159. package/app/.next-cli-build/server/app/dashboard/translator.rsc +6 -6
  160. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +6 -6
  161. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +6 -6
  162. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  163. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  164. package/app/.next-cli-build/server/app/dashboard/usage.rsc +6 -6
  165. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +6 -6
  166. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +6 -6
  167. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  168. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  169. package/app/.next-cli-build/server/app/dashboard.rsc +6 -6
  170. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +6 -6
  171. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +6 -6
  172. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  173. package/app/.next-cli-build/server/app/index.html +1 -1
  174. package/app/.next-cli-build/server/app/index.rsc +4 -4
  175. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +4 -4
  176. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +4 -4
  177. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  178. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  179. package/app/.next-cli-build/server/app/landing.html +1 -1
  180. package/app/.next-cli-build/server/app/landing.rsc +4 -4
  181. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +4 -4
  182. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  183. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +4 -4
  184. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  185. package/app/.next-cli-build/server/app/login.html +1 -1
  186. package/app/.next-cli-build/server/app/login.rsc +5 -5
  187. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +5 -5
  188. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  189. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +5 -5
  190. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  191. package/app/.next-cli-build/server/app-paths-manifest.json +10 -10
  192. package/app/.next-cli-build/server/chunks/24.js +1 -1
  193. package/app/.next-cli-build/server/chunks/318.js +7 -7
  194. package/app/.next-cli-build/server/chunks/3193.js +7 -7
  195. package/app/.next-cli-build/server/chunks/3753.js +1 -1
  196. package/app/.next-cli-build/server/chunks/4037.js +1 -1
  197. package/app/.next-cli-build/server/chunks/4049.js +1 -1
  198. package/app/.next-cli-build/server/chunks/412.js +1 -1
  199. package/app/.next-cli-build/server/chunks/4123.js +1 -1
  200. package/app/.next-cli-build/server/chunks/4572.js +1 -1
  201. package/app/.next-cli-build/server/chunks/6763.js +1 -1
  202. package/app/.next-cli-build/server/chunks/7011.js +1 -1
  203. package/app/.next-cli-build/server/chunks/7211.js +1 -1
  204. package/app/.next-cli-build/server/chunks/7247.js +1 -1
  205. package/app/.next-cli-build/server/chunks/7828.js +1 -1
  206. package/app/.next-cli-build/server/chunks/8236.js +1 -1
  207. package/app/.next-cli-build/server/chunks/827.js +1 -1
  208. package/app/.next-cli-build/server/chunks/8402.js +1 -1
  209. package/app/.next-cli-build/server/chunks/8499.js +6 -6
  210. package/app/.next-cli-build/server/chunks/8635.js +1 -1
  211. package/app/.next-cli-build/server/chunks/869.js +1 -1
  212. package/app/.next-cli-build/server/chunks/8895.js +8 -8
  213. package/app/.next-cli-build/server/chunks/8920.js +1 -1
  214. package/app/.next-cli-build/server/chunks/9381.js +1 -1
  215. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  216. package/app/.next-cli-build/server/pages/404.html +1 -1
  217. package/app/.next-cli-build/server/pages/500.html +1 -1
  218. package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
  219. package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
  220. package/app/.next-cli-build/static/chunks/1321-cb0ab4daf4a3ef56.js +1 -0
  221. package/app/.next-cli-build/static/chunks/{5497-253ae93a75bfffb8.js → 5497-f014d674ae071743.js} +2 -2
  222. package/app/.next-cli-build/static/chunks/{6639-8569c9817c53576b.js → 6639-6558955a29787152.js} +9 -9
  223. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/{page-b380c1d957d1d06a.js → page-7293b5299c891da8.js} +1 -1
  224. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/page-c2368ce674af4465.js +1 -0
  225. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/profile/page-bd6d6ab3b23ed132.js +1 -0
  226. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-922031ba8d4c63d8.js → page-ff6932f680f13961.js} +1 -1
  227. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-abfc8e5e87ff975b.js +1 -0
  228. package/app/cli/.build-home/.9router/db/data.sqlite +0 -0
  229. package/app/package.json +1 -1
  230. package/app/src/sse/services/backgroundTokenRefresh.js +35 -46
  231. package/package.json +2 -2
  232. package/app/.next-cli-build/static/chunks/1321-2982c0d4c34582c9.js +0 -1
  233. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/page-10b1a756ede84964.js +0 -1
  234. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/profile/page-f001b60b30612565.js +0 -1
  235. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-1bf0db77f6172314.js +0 -1
  236. /package/app/.next-cli-build/static/{uvoMMoxsBxbnj7UjWpCwD → fKNEeW0xW0FqZn_GGs3Oo}/_buildManifest.js +0 -0
  237. /package/app/.next-cli-build/static/{uvoMMoxsBxbnj7UjWpCwD → fKNEeW0xW0FqZn_GGs3Oo}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3471],{35675:(e,t,s)=>{Promise.resolve().then(s.bind(s,64561))},64561:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>p});var a=s(95155),r=s(12115),l=s(35497),i=s(81127),o=s(21931),n=s(1620),d=s(31474),c=s(90620),m=s(93308),x=s(38202);function p(){let{theme:e,setTheme:t,isDark:s}=(0,n.D)(),[p,u]=(0,r.useState)(()=>(function(){if("u"<typeof document)return"en";let e=document.cookie.split(";").find(e=>e.trim().startsWith(`${m.CL}=`)),t=e?decodeURIComponent(e.split("=")[1]):"en";return(0,m.QC)(t)})()),[h,b]=(0,r.useState)(!1),[g,f]=(0,r.useState)(!1),[y,j]=(0,r.useState)(!1),[N,w]=(0,r.useState)({fallbackStrategy:"fill-first"}),[v,S]=(0,r.useState)(!0),[C,k]=(0,r.useState)({current:"",new:"",confirm:""}),[L,I]=(0,r.useState)({type:"",message:""}),[A,P]=(0,r.useState)(!1),[O,M]=(0,r.useState)(!1),[E,R]=(0,r.useState)({type:"",message:""}),[D,T]=(0,r.useState)({open:!1,mode:"",password:""}),U=(0,r.useRef)(null),[$,F]=(0,r.useState)({authMode:"password",oidcIssuerUrl:"",oidcClientId:"",oidcScopes:"openid profile email",oidcLoginLabel:"Sign in with OIDC"}),[q,_]=(0,r.useState)(""),[J,X]=(0,r.useState)({type:"",message:""}),[H,z]=(0,r.useState)(!1),[B,K]=(0,r.useState)(!1),[W,Z]=(0,r.useState)({type:"",message:""}),[Q,G]=(0,r.useState)(!1),V=window.location.origin,Y=V?`${V}/api/auth/oidc/callback`:"/api/auth/oidc/callback",ee=V?`${V}/api/auth/saml/acs`:"/api/auth/saml/acs",et=V?`${V}/api/auth/saml/metadata`:"/api/auth/saml/metadata",[es,ea]=(0,r.useState)("saml"),[er,el]=(0,r.useState)({samlEntryPoint:"",samlIssuer:"urn:9router:sp",samlCert:"",samlLoginLabel:"Sign in with SAML SSO",samlAttributeEmail:"email",samlAttributeName:"name"}),[ei,eo]=(0,r.useState)({type:"",message:""}),[en,ed]=(0,r.useState)(!1),[ec,em]=(0,r.useState)(!1),[ex,ep]=(0,r.useState)({type:"",message:""}),[eu,eh]=(0,r.useState)(!1),eb=(0,r.useRef)(null),eg=(0,r.useRef)(null),ef=(0,r.useRef)(null),[ey,ej]=(0,r.useState)({outboundProxyEnabled:!1,outboundProxyUrl:"",outboundNoProxy:""}),[eN,ew]=(0,r.useState)({type:"",message:""}),[ev,eS]=(0,r.useState)(!1),[eC,ek]=(0,r.useState)(!1);(0,r.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{w(e),F({authMode:e?.authMode||"password",oidcIssuerUrl:e?.oidcIssuerUrl||"",oidcClientId:e?.oidcClientId||"",oidcScopes:e?.oidcScopes||"openid profile email",oidcLoginLabel:e?.oidcLoginLabel||"Sign in with OIDC"}),_(""),ea(e?.ssoType||"saml"),el({samlEntryPoint:e?.samlEntryPoint||"",samlIssuer:e?.samlIssuer||"urn:9router:sp",samlCert:e?.samlCert||"",samlLoginLabel:e?.samlLoginLabel||"Sign in with SAML SSO",samlAttributeEmail:e?.samlAttributeEmail||"email",samlAttributeName:e?.samlAttributeName||"name"}),(e?.authMode==="sso"||e?.authMode==="saml"||e?.authMode==="oidc"||e?.authMode==="both")&&G(!0),ej({outboundProxyEnabled:e?.outboundProxyEnabled===!0,outboundProxyUrl:e?.outboundProxyUrl||"",outboundNoProxy:e?.outboundNoProxy||""}),S(!1)}).catch(e=>{console.error("Failed to fetch settings:",e),S(!1)})},[]);let eL=async e=>{if(e.preventDefault(),!0===N.outboundProxyEnabled){eS(!0),ew({type:"",message:""});try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyUrl:ey.outboundProxyUrl,outboundNoProxy:ey.outboundNoProxy})}),t=await e.json();e.ok?(w(e=>({...e,...t})),ew({type:"success",message:"Proxy settings applied"})):ew({type:"error",message:t.error||"Failed to update proxy settings"})}catch(e){ew({type:"error",message:"An error occurred"})}finally{eS(!1)}}},eI=async()=>{if(!0!==N.outboundProxyEnabled)return;let e=(ey.outboundProxyUrl||"").trim();if(!e)return void ew({type:"error",message:"Please enter a Proxy URL to test"});ek(!0),ew({type:"",message:""});try{let t=await fetch("/api/settings/proxy-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyUrl:e})}),s=await t.json();t.ok&&s?.ok?ew({type:"success",message:`Proxy test OK (${s.status}) in ${s.elapsedMs}ms`}):ew({type:"error",message:s?.error||"Proxy test failed"})}catch(e){ew({type:"error",message:"An error occurred"})}finally{ek(!1)}},eA=async e=>{eS(!0),ew({type:"",message:""});try{let t=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyEnabled:e})}),s=await t.json();t.ok?(w(e=>({...e,...s})),ej(e=>({...e,outboundProxyEnabled:s?.outboundProxyEnabled===!0})),ew({type:"success",message:e?"Proxy enabled":"Proxy disabled"})):ew({type:"error",message:s.error||"Failed to update proxy settings"})}catch(e){ew({type:"error",message:"An error occurred"})}finally{eS(!1)}},eP=async e=>{if(e.preventDefault(),C.new!==C.confirm)return void I({type:"error",message:"Passwords do not match"});P(!0),I({type:"",message:""});try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:C.current,newPassword:C.new})}),t=await e.json();e.ok?(I({type:"success",message:"Password updated successfully"}),k({current:"",new:"",confirm:""})):I({type:"error",message:t.error||"Failed to update password"})}catch(e){I({type:"error",message:"An error occurred"})}finally{P(!1)}},eO=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fallbackStrategy:e})})).ok&&w(t=>({...t,fallbackStrategy:e}))}catch(e){console.error("Failed to update settings:",e)}},eM=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategy:e})})).ok&&w(t=>({...t,comboStrategy:e}))}catch(e){console.error("Failed to update combo strategy:",e)}},eE=async e=>{let t=parseInt(e);if(!isNaN(t)&&!(t<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({stickyRoundRobinLimit:t})})).ok&&w(e=>({...e,stickyRoundRobinLimit:t}))}catch(e){console.error("Failed to update sticky limit:",e)}},eR=async e=>{let t=parseInt(e);if(!isNaN(t)&&!(t<1))try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStickyRoundRobinLimit:t})})).ok&&w(e=>({...e,comboStickyRoundRobinLimit:t}))}catch(e){console.error("Failed to update combo sticky limit:",e)}},eD=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireLogin:e})})).ok&&w(t=>({...t,requireLogin:e}))}catch(e){console.error("Failed to update require login:",e)}},eT=(e,t)=>{F(s=>({...s,[e]:t}))},eU=async(e=$.authMode||"password")=>{let t=$.oidcIssuerUrl.trim(),s=$.oidcClientId.trim(),a=$.oidcScopes.trim(),r=$.oidcLoginLabel.trim(),l=q.trim();if("password"!==e&&(!t||!s||!l)&&!N.oidcConfigured)return void X({type:"error",message:"Issuer URL, client ID, and client secret are required to enable OIDC."});z(!0),X({type:"",message:""}),Z({type:"",message:""});try{let i={authMode:e,ssoType:"oidc",oidcIssuerUrl:t,oidcClientId:s,oidcScopes:a||"openid profile email",oidcLoginLabel:r||"Sign in with OIDC"};l&&(i.oidcClientSecret=l);let o=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),n=await o.json();o.ok?(w(e=>({...e,...n})),F({authMode:n?.authMode||e,oidcIssuerUrl:n?.oidcIssuerUrl||t,oidcClientId:n?.oidcClientId||s,oidcScopes:n?.oidcScopes||a||"openid profile email",oidcLoginLabel:n?.oidcLoginLabel||r||"Sign in with OIDC"}),_(""),X({type:"success",message:"oidc"===e?"OIDC login enabled":"both"===e?"Password and OIDC login enabled":"OIDC settings saved"})):X({type:"error",message:n.error||"Failed to save OIDC settings"})}catch(e){X({type:"error",message:"An error occurred"})}finally{z(!1)}},e$=async()=>{let e=$.oidcIssuerUrl.trim(),t=$.oidcClientId.trim(),s=$.oidcScopes.trim(),a=q.trim();if(!e||!t)return void Z({type:"error",message:"Issuer URL and client ID are required to test the connection."});K(!0),X({type:"",message:""}),Z({type:"",message:""});try{let r=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({authMode:$.authMode||N.authMode||"password",oidcIssuerUrl:e,oidcClientId:t,oidcScopes:s||"openid profile email",oidcLoginLabel:$.oidcLoginLabel.trim()||"Sign in with OIDC",...a?{oidcClientSecret:a}:{}})}),l=await r.json().catch(()=>({}));if(!r.ok)return void Z({type:"error",message:l.error||"Failed to save OIDC settings before testing"});let i=await fetch("/api/auth/oidc/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({issuerUrl:l.oidcIssuerUrl||e,clientId:l.oidcClientId||t,scopes:l.oidcScopes||s||"openid profile email"})}),o=await i.json().catch(()=>({}));if(i.ok&&o?.ok){let e=o.clientSecretTested?!0===o.clientSecretValid?`Connection OK. Discovery loaded from ${o.issuerUrl}. Client secret validated too.`:`Connection OK. Discovery loaded from ${o.issuerUrl}. Client secret was not checked.`:`Connection OK. Discovery loaded from ${o.issuerUrl}.`;Z({type:"success",message:e})}else Z({type:"error",message:o.error||"OIDC connection test failed"})}catch(e){Z({type:"error",message:"An error occurred"})}finally{K(!1)}},eF=(e,t)=>{el(s=>({...s,[e]:t}))},eq=async(e=$.authMode||"password")=>{ed(!0),eo({type:"",message:""}),ep({type:"",message:""});try{let t={authMode:e,ssoType:"saml",samlEntryPoint:er.samlEntryPoint.trim(),samlIssuer:er.samlIssuer.trim()||"urn:9router:sp",samlCert:er.samlCert.trim(),samlLoginLabel:er.samlLoginLabel.trim()||"Sign in with SAML SSO",samlAttributeEmail:er.samlAttributeEmail.trim()||"email",samlAttributeName:er.samlAttributeName.trim()||"name"},s=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),a=await s.json();s.ok?(w(e=>({...e,...a})),el({samlEntryPoint:a?.samlEntryPoint||t.samlEntryPoint,samlIssuer:a?.samlIssuer||t.samlIssuer,samlCert:a?.samlCert||t.samlCert,samlLoginLabel:a?.samlLoginLabel||t.samlLoginLabel,samlAttributeEmail:a?.samlAttributeEmail||t.samlAttributeEmail,samlAttributeName:a?.samlAttributeName||t.samlAttributeName}),eo({type:"success",message:"sso"===e||"saml"===e?"SAML SSO login enabled":"both"===e?"Password and SAML SSO login enabled":"SAML 2.0 settings saved"})):eo({type:"error",message:a.error||"Failed to save SAML settings"})}catch{eo({type:"error",message:"An error occurred while saving SAML settings"})}finally{ed(!1)}},e_=async()=>{em(!0),eo({type:"",message:""}),ep({type:"",message:""});try{let e=await fetch("/api/auth/saml/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({samlEntryPoint:er.samlEntryPoint.trim(),samlIssuer:er.samlIssuer.trim(),samlCert:er.samlCert.trim()})}),t=await e.json();e.ok&&t.ok?ep({type:"success",message:t.message||"SAML configuration verified!"}):ep({type:"error",message:t.error||"SAML configuration test failed"})}catch{ep({type:"error",message:"An error occurred while testing SAML configuration"})}finally{em(!1)}},eJ=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enableObservability:e})})).ok&&w(t=>({...t,enableObservability:e}))}catch(e){console.error("Failed to update enableObservability:",e)}},eX=async()=>{try{let e=await fetch("/api/settings");if(!e.ok)return;let t=await e.json();w(t)}catch(e){console.error("Failed to reload settings:",e)}},eH=async e=>{M(!0),R({type:"",message:""});try{let t=await fetch("/api/settings/database",{headers:{"x-9r-password":e}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||"Failed to export database")}let s=await t.json(),a=JSON.stringify(s,null,2),r=new Blob([a],{type:"application/json"}),l=URL.createObjectURL(r),i=document.createElement("a"),o=new Date().toISOString().replace(/[.:]/g,"-");i.href=l,i.download=`9router-backup-${o}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(l),R({type:"success",message:"Database backup downloaded"})}catch(e){R({type:"error",message:e.message||"Failed to export database"})}finally{M(!1)}},ez=async e=>{let t=U.current;if(t){M(!0);try{let s=await t.text(),a=JSON.parse(s),r=await fetch("/api/settings/database",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,password:e})}),l=await r.json().catch(()=>({}));if(!r.ok)throw Error(l.error||"Failed to import database");await eX(),R({type:"success",message:"Database imported successfully"})}catch(e){R({type:"error",message:e.message||"Invalid backup file"})}finally{U.current=null,M(!1)}}},eB=async()=>{let{mode:e,password:t}=D;T({open:!1,mode:"",password:""}),"export"===e?await eH(t):"import"===e&&await ez(t)},eK=!0===N.enableObservability,eW=async()=>{j(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(e){}j(!1),f(!1)},eZ=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&window.location.assign("/login")}catch(e){console.error("Failed to logout:",e)}};return(0,a.jsxs)("div",{className:"max-w-2xl mx-auto px-4 sm:px-0",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)(l.Zp,{children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"size-10 sm:size-12 rounded-lg bg-green-500/10 text-green-500 flex items-center justify-center shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-xl sm:text-2xl",children:"computer"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-lg sm:text-xl font-semibold",children:"Local Mode"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Running on your machine"})]})]}),(0,a.jsx)("div",{className:"inline-flex p-1 rounded-lg bg-black/5 dark:bg-white/5 w-full sm:w-auto",children:["light","dark","system"].map(s=>(0,a.jsxs)("button",{type:"button",onClick:()=>t(s),className:(0,d.cn)("flex items-center justify-center gap-1 sm:gap-1.5 px-2 sm:px-3 py-1.5 rounded-md font-medium transition-all flex-1 sm:flex-initial",e===s?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"light"===s?"light_mode":"dark"===s?"dark_mode":"contrast"}),(0,a.jsx)("span",{className:"capitalize text-xs sm:text-sm",children:s})]},s))})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 pt-4 border-t border-border",children:[(0,a.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-3 rounded-lg bg-bg border border-border gap-2",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Database Location"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted font-mono break-all",children:"~/.9router/db/data.sqlite"})]})}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2",children:[(0,a.jsx)(l.$n,{variant:"secondary",icon:"download",onClick:()=>T({open:!0,mode:"export",password:""}),loading:O,className:"w-full sm:w-auto",children:"Download Backup"}),(0,a.jsx)(l.$n,{variant:"outline",icon:"upload",onClick:()=>ef.current?.click(),disabled:O,className:"w-full sm:w-auto",children:"Import Backup"}),(0,a.jsx)("input",{ref:ef,type:"file",accept:"application/json,.json",className:"hidden",onChange:e=>{let t=e.target.files?.[0];ef.current&&(ef.current.value=""),t&&(U.current=t,R({type:"",message:""}),T({open:!0,mode:"import",password:""}))}})]}),E.message&&(0,a.jsx)("p",{className:`text-sm ${"error"===E.type?"text-red-500":"text-green-600 dark:text-green-400"}`,children:E.message})]})]}),(0,a.jsxs)(l.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"size-10 rounded-lg bg-blue-500/10 text-blue-500 flex items-center justify-center shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"language"})}),(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold",children:"Language"})]}),(0,a.jsxs)("button",{onClick:()=>b(!0),className:"flex items-center justify-between w-full p-3 rounded-lg bg-bg border border-border hover:border-primary/50 transition-colors","data-i18n-skip":"true",children:[(0,a.jsx)("span",{className:"text-sm text-text-muted",children:"Display language"}),(0,a.jsx)("span",{className:"text-2xl",children:x.h[p]||"\uD83C\uDF10"})]})]}),(0,a.jsxs)(l.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"shield"})}),(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold",children:"Security"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Require login"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"When ON, dashboard requires password. When OFF, access without login."})]}),(0,a.jsx)(l.lM,{checked:!0===N.requireLogin,onChange:()=>eD(!N.requireLogin),disabled:v})]}),!0===N.requireLogin&&(0,a.jsxs)("form",{onSubmit:eP,className:"flex flex-col gap-4 pt-4 border-t border-border/50",children:[N.hasPassword&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"text-xs sm:text-sm font-medium",children:"Current Password"}),(0,a.jsx)(l.pd,{type:"password",placeholder:"Enter current password",value:C.current,onChange:e=>k({...C,current:e.target.value}),required:!0})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"text-xs sm:text-sm font-medium",children:"New Password"}),(0,a.jsx)(l.pd,{type:"password",placeholder:"Enter new password",value:C.new,onChange:e=>k({...C,new:e.target.value}),required:!0})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"text-xs sm:text-sm font-medium",children:"Confirm New Password"}),(0,a.jsx)(l.pd,{type:"password",placeholder:"Confirm new password",value:C.confirm,onChange:e=>k({...C,confirm:e.target.value}),required:!0})]})]}),L.message&&(0,a.jsx)("p",{className:`text-xs sm:text-sm ${"error"===L.type?"text-red-500":"text-green-500"}`,children:L.message}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(l.$n,{type:"submit",variant:"primary",loading:A,className:"w-full sm:w-auto",children:N.hasPassword?"Update Password":"Set Password"})})]})]})]}),(0,a.jsxs)(l.Zp,{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>G(e=>!e),className:"w-full flex items-center gap-3 text-left",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-indigo-500/10 text-indigo-500 shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"lock_open"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold",children:"Single Sign-On (SSO)"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"sso"===N.authMode||"oidc"===N.authMode||"saml"===N.authMode?`${"saml"===N.ssoType?"SAML 2.0":"OIDC"} SSO active`:"both"===N.authMode?`Password + ${"saml"===N.ssoType?"SAML 2.0":"OIDC"} active`:"Optional SSO via Okta, Entra ID, Keycloak, or OIDC"})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted shrink-0",children:Q?"expand_less":"expand_more"})]}),Q&&(0,a.jsxs)("div",{className:"flex flex-col gap-4 mt-4",children:[(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Configure enterprise Single Sign-On (SSO) for dashboard access using SAML 2.0 or OIDC."}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"SSO Protocol"}),(0,a.jsxs)("div",{className:"flex p-1 rounded-lg bg-black/5 dark:bg-white/5 border border-border",children:[(0,a.jsx)("button",{type:"button",onClick:()=>ea("saml"),className:(0,d.cn)("flex-1 py-1.5 px-3 rounded-md font-medium text-xs sm:text-sm transition-all text-center","saml"===es?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:"SAML 2.0"}),(0,a.jsx)("button",{type:"button",onClick:()=>ea("oidc"),className:(0,d.cn)("flex-1 py-1.5 px-3 rounded-md font-medium text-xs sm:text-sm transition-all text-center","oidc"===es?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:"OIDC"})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Auth Mode"}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[{value:"password",title:"Password only",desc:"Keep legacy password login."},{value:"sso",title:`${"saml"===es?"SAML":"OIDC"} only`,desc:"Require SSO for dashboard access."},{value:"both",title:"Both",desc:"Allow password or SSO login."}].map(e=>{let t=$.authMode,s="password"===e.value?"password"===t:"sso"===e.value?"sso"===t||"saml"===t||"oidc"===t:"both"===t;return(0,a.jsxs)("button",{type:"button",onClick:()=>eT("authMode",e.value),className:(0,d.cn)("text-left rounded-lg border p-3 transition-colors",s?"border-primary bg-primary/5":"border-border bg-bg hover:bg-black/5 dark:hover:bg-white/5"),disabled:v||H||en,children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:e.title}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted mt-1",children:e.desc})]},e.value)})})]}),"saml"===es?(0,a.jsxs)("div",{className:"flex flex-col gap-4 pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-bg/80 overflow-hidden",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>eh(e=>!e),className:"w-full p-3 flex items-center justify-between gap-2 text-left hover:bg-surface/50 transition-colors",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-lg",children:"menu_book"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-semibold text-xs sm:text-sm text-text-main",children:"IdP Setup Guidelines & Provider Configuration Instructions"}),(0,a.jsx)("p",{className:"text-[11px] text-text-muted",children:"Click to view setup steps for AWS IAM Identity Center, Okta, Entra ID, Keycloak, & Authentik"})]})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted transition-transform text-lg",style:{transform:eu?"rotate(180deg)":"none"},children:"expand_more"})]}),eu&&(0,a.jsxs)("div",{className:"p-4 border-t border-border bg-surface/30 text-xs text-text-main flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"p-2.5 rounded border border-primary/20 bg-primary/5 text-primary text-xs",children:[(0,a.jsx)("p",{className:"font-semibold mb-1",children:"\uD83D\uDD11 Required Service Provider (SP) Values for your IdP Setup:"}),(0,a.jsxs)("ul",{className:"list-disc pl-4 space-y-1 font-mono text-[11px]",children:[(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Assertion Consumer Service (ACS) URL:"})," ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded break-all",children:ee})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"SP Entity ID / Audience URI:"})," ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded break-all",children:er.samlIssuer||"urn:9router:sp"})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"NameID Format:"})," ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded",children:"EmailAddress"})," or ",(0,a.jsx)("code",{className:"bg-bg px-1 py-0.5 rounded",children:"Unspecified"})]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 pt-1",children:[(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsxs)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:[(0,a.jsx)("span",{children:"☁️"})," AWS IAM Identity Center"]}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Applications → ",(0,a.jsx)("b",{children:"Add application"})," → Select ",(0,a.jsx)("b",{children:"Add custom SAML 2.0 application"}),"."]}),(0,a.jsxs)("li",{children:["Set ",(0,a.jsx)("b",{children:"Application ACS URL"})," to ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ee}),"."]}),(0,a.jsxs)("li",{children:["Set ",(0,a.jsx)("b",{children:"Application SAML audience"})," to ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er.samlIssuer||"urn:9router:sp"}),"."]}),(0,a.jsxs)("li",{children:["Under ",(0,a.jsx)("i",{children:"Attribute mappings"}),", map ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:"Subject"})," or ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:"email"})," to ",(0,a.jsxs)("code",{className:"text-text-main font-mono",children:["$","{user:email}"]}),"."]}),(0,a.jsxs)("li",{children:["Download ",(0,a.jsx)("b",{children:"IAM Identity Center SAML metadata XML"})," file and use 1-Click Import below!"]})]})]}),(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsxs)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:[(0,a.jsx)("span",{children:"\uD83D\uDD37"})," Microsoft Entra ID (Azure AD)"]}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Enterprise Applications → ",(0,a.jsx)("b",{children:"New application"})," → ",(0,a.jsx)("b",{children:"Create your own application"}),"."]}),(0,a.jsxs)("li",{children:["Select ",(0,a.jsx)("b",{children:"Single sign-on"})," → ",(0,a.jsx)("b",{children:"SAML"}),"."]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Identifier (Entity ID):"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er.samlIssuer||"urn:9router:sp"})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Reply URL (ACS):"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ee})]}),(0,a.jsxs)("li",{children:["Download ",(0,a.jsx)("b",{children:"Federation Metadata XML"})," and import or copy X.509 Certificate."]})]})]}),(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsxs)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:[(0,a.jsx)("span",{children:"\uD83D\uDFE2"})," Okta / Auth0"]}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Applications → ",(0,a.jsx)("b",{children:"Create App Integration"})," → Select ",(0,a.jsx)("b",{children:"SAML 2.0"}),"."]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Single Sign-On URL:"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ee})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Audience URI (SP Entity ID):"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er.samlIssuer||"urn:9router:sp"})]}),(0,a.jsxs)("li",{children:["Name ID format: ",(0,a.jsx)("i",{children:"EmailAddress"}),"."]}),(0,a.jsx)("li",{children:"Download Identity Provider metadata XML or copy the X.509 cert."})]})]}),(0,a.jsxs)("div",{className:"p-3 rounded border border-border bg-bg/50 flex flex-col gap-1.5",children:[(0,a.jsxs)("p",{className:"font-semibold text-text-main flex items-center gap-1.5",children:[(0,a.jsx)("span",{children:"\uD83D\uDEE1️"})," Keycloak / Authentik"]}),(0,a.jsxs)("ol",{className:"list-decimal pl-4 text-text-muted space-y-1",children:[(0,a.jsxs)("li",{children:["Clients → ",(0,a.jsx)("b",{children:"Create client"})," → Select ",(0,a.jsx)("b",{children:"SAML"}),"."]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Client ID:"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:er.samlIssuer||"urn:9router:sp"})]}),(0,a.jsxs)("li",{children:[(0,a.jsx)("b",{children:"Master SAML Processing URL:"})," ",(0,a.jsx)("code",{className:"text-text-main font-mono",children:ee})]}),(0,a.jsx)("li",{children:"Export SAML Descriptor XML or copy IDP Certificate PEM."})]})]})]})]})]}),(0,a.jsxs)("div",{className:"p-3 rounded-lg border border-dashed border-primary/40 bg-primary/5 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-sm text-text-main",children:"1-Click IdP Metadata XML Import"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Auto-fill SSO URL, Issuer & Cert from XML metadata"})]}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",size:"sm",icon:"upload_file",onClick:()=>eb.current?.click(),children:"Upload Metadata XML"}),(0,a.jsx)("input",{ref:eb,type:"file",accept:".xml,application/xml,text/xml",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(eb.current&&(eb.current.value=""),!t)return;let s=new FileReader;s.onload=e=>{try{let t=e.target?.result||"",s=new DOMParser().parseFromString(t,"text/xml");if(s.querySelector("parsererror"))return void eo({type:"error",message:"Unable to parse valid SAML IdP metadata from XML file"});let a=s.documentElement.getAttribute("entityID")||"",r=Array.from(s.querySelectorAll("SingleSignOnService, *|SingleSignOnService")),l="";for(let e of r){let t=e.getAttribute("Binding")||"",s=e.getAttribute("Location")||"";if(s&&(l=s,t.includes("HTTP-Redirect")))break}let i=Array.from(s.querySelectorAll("X509Certificate, *|X509Certificate")),o="";i.length>0&&(o=i[0].textContent.trim()),el(e=>({...e,samlEntryPoint:l||e.samlEntryPoint,samlIssuer:e.samlIssuer||"urn:9router:sp",samlCert:o||e.samlCert})),eo({type:"success",message:`IdP Metadata imported! (SSO URL: ${l?"found":"not found"}, EntityID: ${a?"found":"not found"}, Cert: ${o?"found":"not found"})`})}catch(e){eo({type:"error",message:"Error reading IdP Metadata XML file"})}},s.readAsText(t)}})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Single Sign-On Service URL (samlEntryPoint)"}),(0,a.jsx)(l.pd,{placeholder:"https://idp.example.com/app/saml/sso/...",value:er.samlEntryPoint,onChange:e=>eF("samlEntryPoint",e.target.value),disabled:v||en})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"SP Entity ID / Audience (samlIssuer)"}),(0,a.jsx)(l.pd,{placeholder:"urn:9router:sp",value:er.samlIssuer,onChange:e=>eF("samlIssuer",e.target.value),disabled:v||en})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"IdP X.509 Certificate (samlCert)"}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",size:"sm",icon:"file_upload",onClick:()=>eg.current?.click(),children:"Upload Certificate"}),(0,a.jsx)("input",{ref:eg,type:"file",accept:".crt,.pem,.cer,text/plain",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(eg.current&&(eg.current.value=""),!t)return;let s=new FileReader;s.onload=e=>{let t=e.target?.result||"";el(e=>({...e,samlCert:t.trim()})),eo({type:"success",message:"Certificate file loaded into configuration."})},s.readAsText(t)}})]}),(0,a.jsx)("textarea",{rows:4,placeholder:"-----BEGIN CERTIFICATE-----\nMIIC...\n-----END CERTIFICATE-----",value:er.samlCert,onChange:e=>eF("samlCert",e.target.value),className:"w-full p-2.5 rounded-lg border border-border bg-bg text-xs font-mono text-text-main focus:outline-none focus:border-primary",disabled:v||en}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Paste raw Base64 certificate or PEM block."})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Login Button Label"}),(0,a.jsx)(l.pd,{placeholder:"Sign in with SAML SSO",value:er.samlLoginLabel,onChange:e=>eF("samlLoginLabel",e.target.value),disabled:v||en})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Email Claim Attribute"}),(0,a.jsx)(l.pd,{placeholder:"email",value:er.samlAttributeEmail,onChange:e=>eF("samlAttributeEmail",e.target.value),disabled:v||en})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Display Name Claim"}),(0,a.jsx)(l.pd,{placeholder:"name",value:er.samlAttributeName,onChange:e=>eF("samlAttributeName",e.target.value),disabled:v||en})]})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 p-3 rounded-lg border border-border bg-bg text-xs sm:text-sm text-text-muted",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-text-main",children:"ACS Callback URL"}),(0,a.jsx)("code",{className:"block break-all font-mono text-xs",children:ee})]}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",size:"sm",icon:"content_copy",onClick:()=>{navigator.clipboard.writeText(ee),eo({type:"success",message:"ACS URL copied to clipboard!"})},children:"Copy"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-text-main",children:"SP XML Metadata"}),(0,a.jsx)("code",{className:"block break-all font-mono text-xs",children:et})]}),(0,a.jsxs)("a",{href:et,target:"_blank",rel:"noopener noreferrer",download:"9router-sp-metadata.xml",className:"inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"download"}),"Download XML"]})]})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 pt-2 border-t border-border/50",children:[(0,a.jsx)(l.$n,{type:"button",variant:"primary",loading:en,onClick:()=>eq($.authMode),className:"w-full sm:w-auto",children:"Save SAML settings"}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",loading:ec,onClick:e_,className:"w-full sm:w-auto",children:"Test SAML settings"})]}),ex.message&&(0,a.jsx)("p",{className:`text-xs sm:text-sm ${"error"===ex.type?"text-red-500":"text-green-500"}`,children:ex.message}),ei.message&&(0,a.jsx)("p",{className:`text-xs sm:text-sm ${"error"===ei.type?"text-red-500":"text-green-500"}`,children:ei.message})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-4 pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Issuer URL"}),(0,a.jsx)(l.pd,{placeholder:"https://auth.example.com/application/o/9router/",value:$.oidcIssuerUrl,onChange:e=>eT("oidcIssuerUrl",e.target.value),disabled:v||H})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Client ID"}),(0,a.jsx)(l.pd,{placeholder:"9router-dashboard",value:$.oidcClientId,onChange:e=>eT("oidcClientId",e.target.value),disabled:v||H})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Client Secret"}),(0,a.jsx)(l.pd,{type:"password",placeholder:"Leave blank to keep existing secret",value:q,onChange:e=>_(e.target.value),disabled:v||H}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"This value is write-only after saving."})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Scopes"}),(0,a.jsx)(l.pd,{placeholder:"openid profile email",value:$.oidcScopes,onChange:e=>eT("oidcScopes",e.target.value),disabled:v||H})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Login Button Label"}),(0,a.jsx)(l.pd,{placeholder:"Sign in with OIDC",value:$.oidcLoginLabel,onChange:e=>eT("oidcLoginLabel",e.target.value),disabled:v||H})]})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border bg-bg p-3 text-xs sm:text-sm text-text-muted",children:[(0,a.jsx)("p",{className:"font-medium text-text-main mb-1",children:"Redirect URI"}),(0,a.jsx)("code",{className:"block break-all font-mono",children:Y})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 pt-2 border-t border-border/50",children:[(0,a.jsx)(l.$n,{type:"button",variant:"primary",loading:H,onClick:()=>eU(),className:"w-full sm:w-auto",children:"Save OIDC settings"}),(0,a.jsx)(l.$n,{type:"button",variant:"outline",loading:B,onClick:e$,className:"w-full sm:w-auto",children:"Test connection"})]}),W.message&&(0,a.jsx)("p",{className:`text-xs sm:text-sm ${"error"===W.type?"text-red-500":"text-green-500"}`,children:W.message}),J.message&&(0,a.jsx)("p",{className:`text-xs sm:text-sm ${"error"===J.type?"text-red-500":"text-green-500"}`,children:J.message})]}),"oidc"===N.authMode||"saml"===N.authMode||"sso"===N.authMode?(0,a.jsxs)("p",{className:"text-xs sm:text-sm text-amber-600 dark:text-amber-400",children:["SSO login (","saml"===N.ssoType?"SAML 2.0":"OIDC",") is currently active. Password login is disabled until you switch back."]}):null,"both"===N.authMode&&(0,a.jsxs)("p",{className:"text-xs sm:text-sm text-amber-600 dark:text-amber-400",children:["Password and SSO login (","saml"===N.ssoType?"SAML 2.0":"OIDC",") are both active."]})]})]}),(0,a.jsxs)(l.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-500 shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"route"})}),(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold",children:"Routing Strategy"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Round Robin"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through accounts to distribute load"})]}),(0,a.jsx)(l.lM,{checked:"round-robin"===N.fallbackStrategy,onChange:()=>eO("round-robin"===N.fallbackStrategy?"fill-first":"round-robin"),disabled:v})]}),"round-robin"===N.fallbackStrategy&&(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Sticky Limit"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Calls per account before switching"})]}),(0,a.jsx)(l.pd,{type:"number",min:"1",max:"10",value:N.stickyRoundRobinLimit||3,onChange:e=>eE(e.target.value),disabled:v,className:"w-16 sm:w-20 text-center shrink-0"})]}),(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4 pt-4 border-t border-border/50",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Combo Round Robin"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Cycle through providers in combos instead of always starting with first"})]}),(0,a.jsx)(l.lM,{checked:"round-robin"===N.comboStrategy,onChange:()=>eM("round-robin"===N.comboStrategy?"fallback":"round-robin"),disabled:v})]}),"round-robin"===N.comboStrategy&&(0,a.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:"Combo Sticky Limit"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Calls per combo model before switching"})]}),(0,a.jsx)(l.pd,{type:"number",min:"1",max:"100",value:N.comboStickyRoundRobinLimit||1,onChange:e=>eR(e.target.value),disabled:v,className:"w-20 text-center"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted italic pt-2 border-t border-border/50",children:["round-robin"===N.fallbackStrategy?`Currently distributing requests across all available accounts with ${N.stickyRoundRobinLimit||3} calls per account.`:"Currently using accounts in priority order (Fill First).","round-robin"===N.comboStrategy?` Combos rotate after ${N.comboStickyRoundRobinLimit||1} call${1===(N.comboStickyRoundRobinLimit||1)?"":"s"} per model.`:" Combos always start with their first model."]})]})]}),(0,a.jsxs)(l.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-purple-500/10 text-purple-500 shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"wifi"})}),(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold",children:"Network"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Outbound Proxy"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Enable proxy for OAuth + provider outbound requests."})]}),(0,a.jsx)(l.lM,{checked:!0===N.outboundProxyEnabled,onChange:()=>eA(!0!==N.outboundProxyEnabled),disabled:v||ev})]}),!0===N.outboundProxyEnabled&&(0,a.jsxs)("form",{onSubmit:eL,className:"flex flex-col gap-4 pt-2 border-t border-border/50",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"Proxy URL"}),(0,a.jsx)(l.pd,{placeholder:"http://127.0.0.1:7897",value:ey.outboundProxyUrl,onChange:e=>ej(t=>({...t,outboundProxyUrl:e.target.value})),disabled:v||ev}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Leave empty to inherit existing env proxy (if any)."})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 pt-2 border-t border-border/50",children:[(0,a.jsx)("label",{className:"font-medium text-sm sm:text-base",children:"No Proxy"}),(0,a.jsx)(l.pd,{placeholder:"localhost,127.0.0.1",value:ey.outboundNoProxy,onChange:e=>ej(t=>({...t,outboundNoProxy:e.target.value})),disabled:v||ev}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Comma-separated hostnames/domains to bypass the proxy."})]}),(0,a.jsxs)("div",{className:"pt-2 border-t border-border/50 flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[(0,a.jsx)(l.$n,{type:"button",variant:"secondary",loading:eC,disabled:v||ev,onClick:eI,className:"w-full sm:w-auto",children:"Test proxy URL"}),(0,a.jsx)(l.$n,{type:"submit",variant:"primary",loading:ev,className:"w-full sm:w-auto",children:"Apply"})]})]}),eN.message&&(0,a.jsx)("p",{className:`text-xs sm:text-sm ${"error"===eN.type?"text-red-500":"text-green-500"} pt-2 border-t border-border/50`,children:eN.message})]})]}),(0,a.jsxs)(l.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-orange-500/10 text-orange-500 shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"monitoring"})}),(0,a.jsx)("h3",{className:"text-base sm:text-lg font-semibold",children:"Observability"})]}),(0,a.jsxs)("div",{className:"flex items-start sm:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-sm sm:text-base",children:"Enable Observability"}),(0,a.jsx)("p",{className:"text-xs sm:text-sm text-text-muted",children:"Record request details for inspection in the logs view"})]}),(0,a.jsx)(l.lM,{checked:eK,onChange:eJ,disabled:v})]})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2",children:[(0,a.jsx)(l.$n,{variant:"outline",fullWidth:!0,icon:"power_settings_new",onClick:()=>f(!0),className:"text-red-500 border-red-200 hover:bg-red-50 hover:border-red-300",children:"Shutdown"}),(0,a.jsx)(l.$n,{variant:"outline",fullWidth:!0,icon:"logout",onClick:eZ,children:"Logout"})]}),(0,a.jsxs)("div",{className:"text-center text-xs sm:text-sm text-text-muted py-4",children:[(0,a.jsxs)("p",{children:[c.vQ.name," v",c.vQ.version]}),(0,a.jsx)("p",{className:"mt-1",children:"Local Mode - All data stored on your machine"})]})]}),(0,a.jsx)(o.default,{hideTrigger:!0,isOpen:h,onClose:e=>{b(!1),u(e)}}),(0,a.jsx)(i.ConfirmModal,{isOpen:g,onClose:()=>f(!1),onConfirm:eW,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:y}),(0,a.jsxs)(i.default,{isOpen:D.open,onClose:()=>T({open:!1,mode:"",password:""}),title:"Confirm Password",size:"sm",footer:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.$n,{variant:"ghost",onClick:()=>T({open:!1,mode:"",password:""}),disabled:O,children:"Cancel"}),(0,a.jsx)(l.$n,{variant:"primary",onClick:eB,loading:O,disabled:!D.password,children:"Confirm"})]}),children:[(0,a.jsxs)("p",{className:"text-text-muted mb-3 text-sm",children:["Enter your current password to ","export"===D.mode?"export":"import"," the database."]}),(0,a.jsx)(l.pd,{type:"password",value:D.password,onChange:e=>T(t=>({...t,password:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&D.password&&eB()},placeholder:"Current password",autoFocus:!0})]})]})}}},e=>{e.O(0,[4614,1321,705,5497,8441,3794,7358],()=>e(e.s=35675)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3826],{75095:(e,t,r)=>{"use strict";r.d(t,{default:()=>O});var a=r(95155),i=r(12115),s=r(57250),n=r(2378);let l="quotaCacheData",o="quotaAutoRefresh",d=[10,20,50,100],c=[{value:"all",label:"All accounts"},{value:"active",label:"Active"},{value:"inactive",label:"Turned off"}],u=[{value:"default",label:"Default quota order"},{value:"remaining-asc",label:"% quota: low to high"},{value:"remaining-desc",label:"% quota: high to low"}];function x(e){return e.name?.trim()||e.email?.trim()||e.displayName?.trim()||null}function m(e,t){let r=t[e.id]?.quotas?.[0];return r&&"number"==typeof r.remaining?r.remaining:1/0}function h(e){let t={};return e.forEach(e=>{t[e.id]=!0}),t}function p(e,t){let r=new Set(t.map(e=>e.id));return Object.fromEntries(Object.entries(e).filter(([e])=>r.has(e)))}async function b(e,t){return await e(t)}function g(){try{let e=window.localStorage.getItem(l);return e?JSON.parse(e):{}}catch(e){return console.error("Error reading quota cache:",e),{}}}function f(e,t){try{let r=g();r[e]={...t,cachedAt:new Date().toISOString()},window.localStorage.setItem(l,JSON.stringify(r))}catch(e){console.error("Error writing quota cache:",e)}}function y(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function v(e){return e&&"object"==typeof e?String(e.modelKey||e.name||"").trim():""}function k(e,t){let r=t?.[e]?.hidden;return new Set(Array.isArray(r)?r.map(String):[])}function w({quotas:e=[],compact:t=!1,sortMode:r="default",showSortLabel:s=!1,onHideQuota:n=null}){let[l,o]=(0,i.useState)(1),d=(0,i.useMemo)(()=>e.map((e,t)=>({...e,index:t,remaining:e?.remaining!==void 0?Math.max(0,Math.round(e.remaining)):e?.remainingPercentage!==void 0?Math.round(e.remainingPercentage):y(e?.used,e?.total)})),[e]),c=(0,i.useMemo)(()=>"remaining-asc"===r?[...d].sort((e,t)=>e.remaining-t.remaining||e.name.localeCompare(t.name)):"remaining-desc"===r?[...d].sort((e,t)=>t.remaining-e.remaining||e.name.localeCompare(t.name)):d,[d,r]),u=Math.max(1,Math.ceil(c.length/10));if((0,i.useEffect)(()=>{o(1)},[r,e]),(0,i.useEffect)(()=>{o(e=>Math.min(e,u))},[u]),!e||0===e.length)return null;let x=c.slice((l-1)*10,10*l),m=0===c.length?0:(l-1)*10+1,h=Math.min(10*l,c.length),p=t?"py-1 px-1.5":"py-2 px-3",b=t?"text-[11px]":"text-sm",g=t?"text-[11px]":"text-sm",f=t?"text-[10px] leading-tight":"text-xs",v="function"==typeof n;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"text-[10px] text-text-muted",children:[c.length," quota",c.length>1?"s":""]}),s&&(0,a.jsx)("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1 text-[10px] text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:"Sorted by account remaining"})]}),(0,a.jsx)("div",{className:"space-y-px",children:x.map(e=>{var r;let i=!0===e.unlimited,s=(r=e.remaining)>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"\uD83D\uDFE2"}:r>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"\uD83D\uDFE1"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"\uD83D\uDD34"},l=function(e){if(!e)return"-";try{let t="string"==typeof e?new Date(e):e,r=new Date,a=t-r;if(a<=0)return"-";let i=Math.ceil(a/6e4);if(i<60)return`${i}m`;let s=Math.floor(i/60),n=i%60;if(s<24)return`${s}h ${n}m`;let l=Math.floor(s/24);return`${l}d ${s%24}h ${n}m`}catch(e){return"-"}}(e.resetAt),o=function(e){if(!e)return null;try{let t=new Date(e),r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),i=new Date(a);i.setDate(i.getDate()+1);let s="";s=t>=a&&t<i?"Today":t>=i&&t<new Date(i.getTime()+864e5)?"Tomorrow":t.toLocaleDateString("en-US",{month:"short",day:"numeric"});let n=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${s}, ${n}`}catch{return null}}(e.resetAt),d=!1!==e.recurring?`in ${l}`:`expires in ${l}`;return(0,a.jsxs)("div",{className:`flex items-center gap-2 border-b border-black/5 dark:border-white/5 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors ${p}`,children:[(0,a.jsxs)("div",{className:"flex w-36 min-w-0 items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-[10px] shrink-0",children:s.emoji}),(0,a.jsx)("span",{className:`${b} font-medium text-text-primary truncate`,children:e.name})]}),(0,a.jsxs)("div",{className:`min-w-0 flex-1 ${t?"space-y-1":"space-y-1.5"}`,children:[!i&&(0,a.jsx)("div",{className:`${t?"h-1":"h-1.5"} rounded-full overflow-hidden border ${s.bgLight} ${0===e.remaining?"border-black/10 dark:border-white/10":"border-transparent"}`,children:(0,a.jsx)("div",{className:`h-full transition-all duration-300 ${s.bg}`,style:{width:`${Math.min(e.remaining,100)}%`}})}),(0,a.jsxs)("div",{className:`flex items-center justify-between gap-1 min-w-0 ${t?"text-[10px]":"text-xs"}`,children:[(0,a.jsx)("span",{className:"text-text-muted truncate",title:i?`${e.used.toLocaleString()} used \xb7 Unlimited`:`${e.used.toLocaleString()} / ${e.total>0?e.total.toLocaleString():"∞"}`,children:i?`${e.used.toLocaleString()} used \xb7 Unlimited`:`${e.used.toLocaleString()} / ${e.total>0?e.total.toLocaleString():"∞"}`}),(0,a.jsx)("span",{className:`font-medium ${i?"text-green-600 dark:text-green-400":s.text} shrink-0`,children:i?"Unlimited":`${e.remaining}%`})]})]}),(0,a.jsx)("div",{className:"min-w-0 shrink",children:"-"!==l||o?t?(0,a.jsx)("div",{className:`${g} text-text-primary font-medium truncate`,title:o||"",children:"-"!==l?d:o}):(0,a.jsxs)("div",{className:"min-w-0 space-y-0.5",children:["-"!==l&&(0,a.jsx)("div",{className:`${g} text-text-primary font-medium truncate`,children:d}),o&&(0,a.jsx)("div",{className:`${f} text-text-muted truncate`,children:o})]}):(0,a.jsx)("div",{className:`${g} text-text-muted italic`,children:"N/A"})}),v&&(0,a.jsx)("button",{type:"button",onClick:()=>n(e),className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-text-muted transition-colors hover:bg-black/5 hover:text-text-primary dark:hover:bg-white/5",title:"Hide this quota row","aria-label":`Hide quota ${e.name}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px]",children:"visibility_off"})})]},`${e.name}-${e.index}`)})}),u>1&&(0,a.jsxs)("div",{className:"rounded-md border border-black/10 bg-black/[0.02] px-2 py-1.5 dark:border-white/10 dark:bg-white/[0.03]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 text-[10px] text-text-muted",children:[(0,a.jsxs)("span",{children:["Showing ",m,"-",h," of ",c.length]}),(0,a.jsxs)("span",{children:["Page ",l," / ",u]})]}),(0,a.jsxs)("div",{className:"mt-1.5 flex items-center justify-end gap-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>o(e=>Math.max(1,e-1)),disabled:1===l,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Prev"}),(0,a.jsx)("button",{type:"button",onClick:()=>o(e=>Math.min(u,e+1)),disabled:l===u,className:"flex h-6 items-center rounded-md border border-black/10 px-2 text-[10px] text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Next"})]})]})]})}var j=r(98542),N=r(97677),C=r(84588),S=r(35497),A=r(88105),$=r(11059);let q={"builder-id":"AWS Builder ID",idc:"IAM Identity Center",google:"Google",github:"GitHub",imported:"Imported Token",api_key:"API Key"},P={claude:"claudeAutoPing",codex:"codexAutoPing"},E={claude:"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",codex:"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota."};function D(e){return e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null}function T(e){let t=e.providerSpecificData?.region;if(t)return t;let r=e.providerSpecificData?.profileArn;return("string"==typeof r?r.split(":")[3]:"")||""}function M(e){if(!e)return"N/A";let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}):"N/A"}function O(){let{copied:e,copy:t}=(0,$.C)(),[r,O]=(0,i.useState)([]),[_,I]=(0,i.useState)({}),[F,L]=(0,i.useState)({}),[z,R]=(0,i.useState)({}),[U,H]=(0,i.useState)(!0),[J,K]=(0,i.useState)({claude:{},codex:{}}),[W,G]=(0,i.useState)(null),[V,B]=(0,i.useState)(!1),[Q,Y]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(60),[ee,et]=(0,i.useState)(!0),[er,ea]=(0,i.useState)(null),[ei,es]=(0,i.useState)(null),[en,el]=(0,i.useState)(null),[eo,ed]=(0,i.useState)(null),[ec,eu]=(0,i.useState)(null),[ex,em]=(0,i.useState)(!1),[eh,ep]=(0,i.useState)(null),[eb,eg]=(0,i.useState)([]),[ef,ey]=(0,i.useState)("all"),[ev,ek]=(0,i.useState)([]),[ew,ej]=(0,i.useState)("all"),[eN,eC]=(0,i.useState)("default"),[eS,eA]=(0,i.useState)({}),[e$,eq]=(0,i.useState)(!1),[eP,eE]=(0,i.useState)(!1),[eD,eT]=(0,i.useState)(!1),[eM,eO]=(0,i.useState)(1),[e_,eI]=(0,i.useState)(20),[eF,eL]=(0,i.useState)(String(20)),[ez,eR]=(0,i.useState)({page:1,pageSize:20,total:0,totalPages:1}),[eU,eH]=(0,i.useState)({eligibleConnections:0,providerFilteredConnections:0}),eJ=(0,i.useRef)(null),eK=(0,i.useRef)(null),eW=(0,i.useRef)(0),eG=(0,i.useCallback)(async(e=eM)=>{try{var t,r;let a=new URLSearchParams({page:String(e),pageSize:String(e_),accountStatus:ew,sort:"priority"});"all"!==ef&&a.set("provider",ef);let i=await fetch(`/api/providers/client?${a.toString()}`);if(!i.ok)throw Error("Failed to fetch connections");let s=await i.json(),n=s.connections||[],l=(t=s.pagination,t||{page:1,pageSize:e_,total:0,totalPages:1}),o=function(e,t=0){return e||{eligibleConnections:t,providerFilteredConnections:t}}(s.totals,n.length);return O(n),ek(s.providerOptions||[]),eR(l),eH(o),eO((r=s.pagination,r?.page||e)),n}catch(e){return console.error("Error fetching connections:",e),O([]),ek([]),eR({page:1,pageSize:e_,total:0,totalPages:1}),eH({eligibleConnections:0,providerFilteredConnections:0}),[]}},[ew,e$,eM,e_,ef]),eV=(0,i.useCallback)(async(e,t,{force:r=!1}={})=>{L(t=>({...t,[e]:!0})),R(t=>({...t,[e]:null}));try{console.log(`[ProviderLimits] Fetching quota for ${t} (${e})`);let a=`/api/usage/${e}${r?"?force=1":""}`,i=await fetch(a);if(!i.ok){let r=(await i.json().catch(()=>({}))).error||i.statusText;if(404===i.status)return void console.warn(`[ProviderLimits] Connection not found for ${t}, skipping`);if(401===i.status){console.warn(`[ProviderLimits] Auth error for ${t}:`,r);let a={quotas:[],message:r};I(t=>({...t,[e]:a})),f(e,a);return}throw Error(`HTTP ${i.status}: ${r}`)}let s=await i.json();console.log(`[ProviderLimits] Got quota for ${t}:`,s);let l={quotas:function(e,t){if(!t||"object"!=typeof t)return[];let r=[];try{switch(e.toLowerCase()){case"github":default:t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"antigravity":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:t.displayName||e,modelKey:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codex":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{let a=e;"spark_session"===e?a="Spark (5h)":"spark_weekly"===e?a="Spark (Weekly)":"session"===e?a="5h":"weekly"===e?a="Weekly":"review_session"===e?a="Review (5h)":"review_weekly"===e&&(a="Review (Weekly)"),r.push({name:a,quotaType:e,used:t.used||0,total:t.total||0,remaining:t.remaining,resetAt:t.resetAt||null})});break;case"kiro":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"qoder":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{("organization"!==e||t&&0!==(Number(t.total)||0))&&r.push({name:"user"===e?"Personal":"organization"===e?"Organization":e,used:t.used||0,total:t.total||0,unit:t.unit,resetAt:t.resetAt||null})});break;case"claude":t.message?r.push({name:"error",used:0,total:0,resetAt:null,message:t.message}):t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"vercel-ai-gateway":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codebuddy-cn":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,recurring:!1!==t.recurring})});break;case"grok-cli":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"kimi":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"deepseek":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"groq":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"ollama":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"zed":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage,unlimited:t.unlimited})})}}catch(t){return console.error(`Error parsing quota data for ${e}:`,t),[]}let a=(0,n.KC)(e);if(a.length>0){let e=new Map(a.map((e,t)=>[e.id,t]));r.sort((t,r)=>{let a=t.modelKey||t.name,i=r.modelKey||r.name;return(e.get(a)??999)-(e.get(i)??999)})}return r}(t,s),plan:s.plan||null,message:s.message||null,raw:s};I(t=>({...t,[e]:l})),f(e,l)}catch(r){console.error(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,r),R(t=>({...t,[e]:r.message||"Failed to fetch quota"}))}finally{L(t=>({...t,[e]:!1}))}},[]),eB=(0,i.useCallback)(async(e,t)=>{await eV(e,t,{force:!0}),G(new Date)},[eV]),eQ=(0,i.useCallback)(async(e,t)=>{if("codex"===t&&!en){el(e),R(t=>({...t,[e]:null}));try{let r=await fetch(`/api/usage/${e}/codex-reset-credits`,{method:"POST"}),a=await r.json().catch(()=>({}));if(!r.ok)throw Error(a.message||a.error||a.code||"Failed to reset Codex limit");await eV(e,t),G(new Date)}catch(t){R(r=>({...r,[e]:t.message||"Failed to reset Codex limit"}))}finally{el(null)}}},[eV,en]),eY=(0,i.useCallback)(async e=>{eu({connection:e,loading:!0,error:null,data:null});try{let t=await fetch(`/api/usage/${e.id}/codex-reset-credits`,{cache:"no-store"}),r=await t.json().catch(()=>({}));if(!t.ok)throw Error(r.error||r.message||"Failed to load Codex reset credits");let a=Array.isArray(r.credits)?[...r.credits]:[];a.sort((e,t)=>{let r=e.expiresAt?new Date(e.expiresAt).getTime():1/0,a=t.expiresAt?new Date(t.expiresAt).getTime():1/0;return r-a}),eu({connection:e,loading:!1,error:null,data:{...r,credits:a}})}catch(t){eu({connection:e,loading:!1,error:t.message||"Failed to load Codex reset credits",data:null})}},[]),eX=(0,i.useCallback)(async e=>{if(confirm("Delete this connection?")){ea(e);try{if((await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok){I(t=>{let r={...t};return delete r[e],r}),L(t=>{let r={...t};return delete r[e],r}),R(t=>{let r={...t};return delete r[e],r});try{let t=g();t[e]&&(delete t[e],window.localStorage.setItem(l,JSON.stringify(t)))}catch(e){console.error("Error deleting cache entry:",e)}await b(eG,eM)}}catch(e){console.error("Error deleting connection:",e)}finally{ea(null)}}},[eG,eM]),eZ=(0,i.useCallback)(async(e,t)=>{es(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&(I(e=>({...e})),await b(eG,eM))}catch(e){console.error("Error updating connection status:",e)}finally{es(null)}},[eG,eM]),e0=(0,i.useCallback)(async e=>{if(!eh?.id)return;let t=eh.id,r=eh.provider;try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await eG(),em(!1),ep(null),A.wb.includes(r)&&await eV(t,r))}catch(e){console.error("Error saving connection:",e)}},[eh,eG,eV]);(0,i.useEffect)(()=>{let e=!1;return fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}).then(e=>e.json()).then(t=>{!e&&t?.proxyPools&&eg(t.proxyPools)}).catch(()=>{}),()=>{e=!0}},[]);let e1=(0,i.useCallback)(async(e=!1)=>{if(Q)return;Y(!0),Z(60);let t=eW.current+=1,r=Math.round(10);try{let a=await eG(eM);L(h(a)),R(e=>p(e,a)),I(e=>p(e,a)),await Promise.all(a.filter(a=>e||"claude"!==a.provider||t%r==0).map(e=>eV(e.id,e.provider))),G(new Date)}catch(e){console.error("Error refreshing all providers:",e)}finally{Y(!1)}},[Q,eG,eV,eM]);(0,i.useEffect)(()=>{(async()=>{et(!0);let e=await eG(eM);et(!1),L(h(e)),R(t=>p(t,e)),I(t=>p(t,e)),await Promise.all(e.map(e=>eV(e.id,e.provider))),G(new Date)})()},[eG,eV,eM]),(0,i.useEffect)(()=>{let e=window.localStorage.getItem(o);H(null===e||"true"===e),B(!0)},[]),(0,i.useEffect)(()=>{V&&window.localStorage.setItem(o,String(U))},[U,V]),(0,i.useEffect)(()=>{fetch("/api/settings",{cache:"no-store"}).then(e=>e.ok?e.json():{}).then(e=>{K({claude:e?.claudeAutoPing?.connections||{},codex:e?.codexAutoPing?.connections||{}}),eA(e?.quotaVisibility||{})}).catch(()=>{})},[]);let e5=(0,i.useCallback)(async(e,t,r)=>{let a=P[t];if(!a)return;let i={...J[t]||{},[e]:r};K({...J,[t]:i});try{let e=await fetch("/api/settings",{cache:"no-store"}),t={...(e.ok?await e.json():{})[a]||{},connections:i};await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:t})})}catch{K(J)}},[J]),e2=(0,i.useCallback)(async(e,t)=>{eA(e);try{if(!(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({quotaVisibility:e})})).ok)throw Error("Failed to update quota visibility")}catch(e){console.error("Error updating quota visibility:",e),eA(t)}},[]),e3=(0,i.useCallback)((e,t)=>{let r=v(t);if(!e||!r)return;let a=eS[e]||{},i=new Set(a.hidden||[]);i.add(r),e2({...eS,[e]:{...a,hidden:[...i]}},eS)},[eS,e2]),e4=(0,i.useCallback)((e,t)=>{let r=v(t);if(!e||!r)return;let a=eS[e]||{},i=new Set(a.hidden||[]);i.delete(r),e2({...eS,[e]:{...a,hidden:[...i]}},eS)},[eS,e2]);(0,i.useEffect)(()=>{if(!V||!U){eJ.current&&(clearInterval(eJ.current),eJ.current=null),eK.current&&(clearInterval(eK.current),eK.current=null);return}return eJ.current=setInterval(()=>{e1()},6e4),eK.current=setInterval(()=>{Z(e=>e<=1?60:e-1)},1e3),()=>{eJ.current&&clearInterval(eJ.current),eK.current&&clearInterval(eK.current)}},[U,e1,V]),(0,i.useEffect)(()=>{let e=()=>{document.hidden?(eJ.current&&(clearInterval(eJ.current),eJ.current=null),eK.current&&(clearInterval(eK.current),eK.current=null)):U&&V&&(eJ.current=setInterval(()=>e1(),6e4),eK.current=setInterval(()=>{Z(e=>e<=1?60:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[U,e1,V]);let e8=(0,i.useMemo)(()=>(function(e,t,r,a,i){if("codex"===a&&"default"!==i)return[...e].sort((e,r)=>{let a=m(e,t),s=m(r,t),n="remaining-asc"===i?a-s:s-a;return 0!==n?n:(x(e)||"").localeCompare(x(r)||"")});if(!r){let t=new Map;for(let r of e){let e=r.provider||"";t.has(e)||t.set(e,[]),t.get(e).push(r)}return Array.from(t.values()).flat()}let s=e=>{let r=(t[e.id]?.quotas||[]).map(e=>e.resetAt?new Date(e.resetAt).getTime():1/0).filter(e=>Number.isFinite(e));return r.length>0?Math.min(...r):1/0};return[...e].sort((e,t)=>{let r=s(e)-s(t);return 0!==r?r:(e.provider||"").localeCompare(t.provider||"")||(x(e)||"").localeCompare(x(t)||"")})})(r,_,e$,ef,eN),[r,_,e$,ef,eN]),e6=e=>{let t=_[e.id]?.quotas;return!!t?.length&&t.some(e=>!!e.total&&!(e.total<=0)&&5>=y(e.used,e.total))},e9=(0,i.useCallback)(async(e,t)=>{if(e.length&&!eD){eT(!0);try{await Promise.all(e.map(e=>fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})}))),await b(eG,eM)}catch(e){console.error("Error bulk toggling connections:",e)}finally{eT(!1)}}},[eD,eG,eM]),e7="all"===ef?"All providers":ef,te=eU.eligibleConnections>0,tt=e8.length>0,tr=eU.eligibleConnections?eU.providerFilteredConnections?{icon:"filter_alt_off",title:"No Accounts On This Page",description:"Try moving to another page or refreshing the current filters."}:{icon:"filter_alt_off",title:"No Accounts Match Current Filters",description:"all"===ef?"Try changing the account status filter to see more quota trackers.":`No ${"inactive"===ew?"turned off":"active"===ew?"active":"matching"} accounts found for ${ef}.`}:{icon:"cloud_off",title:"No Providers Connected",description:"Connect to providers with OAuth to track your API quota limits and usage."},ta=function(e){var t;let{start:r,end:a}=(t=e).total?{start:(t.page-1)*t.pageSize+1,end:Math.min(t.page*t.pageSize,t.total)}:{start:0,end:0};return`Showing ${r}-${a} of ${e.total}`}(ez),ti=!d.includes(e_);return ee||te?ee||tt?(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-end",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>eE(e=>!e),className:"flex h-8 items-center justify-between gap-1 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-haspopup":"menu","aria-expanded":eP,title:"Filter quota providers",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:["all"===ef?(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"apps"}):(0,a.jsx)(s.A,{src:`/providers/${ef}.png`,alt:ef,size:18,className:"size-[18px] rounded object-contain",fallbackText:ef.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"truncate capitalize hidden lg:inline",children:e7})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"expand_more"})]}),eP&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"fixed inset-0 z-30 bg-transparent","aria-label":"Close provider filter",onClick:()=>eE(!1)}),(0,a.jsxs)("div",{className:"absolute left-0 z-40 mt-2 w-64 overflow-hidden rounded-2xl border border-black/10 bg-surface/95 p-1.5 shadow-xl shadow-black/10 backdrop-blur dark:border-white/10 dark:bg-surface/95 sm:w-72",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{"all"!==ef&&eO(1),ey("all"),eE(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${"all"===ef?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[22px]",children:"apps"}),(0,a.jsx)("span",{className:"font-medium",children:"All providers"}),"all"===ef&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]}),(0,a.jsx)("div",{className:"my-1 h-px bg-black/10 dark:bg-white/10"}),(0,a.jsx)("div",{className:"max-h-72 overflow-y-auto pr-1",children:ev.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{ef!==e&&eO(1),ey(e),eE(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${ef===e?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)(s.A,{src:`/providers/${e}.png`,alt:e,size:24,className:"size-6 rounded-md object-contain",fallbackText:e.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"font-medium capitalize",children:e}),ef===e&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]},e))})]})]})]}),(0,a.jsx)("select",{value:ew,onChange:e=>{let t=e.target.value;ew!==t&&eO(1),ej(t)},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Filter accounts by status",children:c.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),"codex"===ef&&(0,a.jsx)("select",{value:eN,onChange:e=>eC(e.target.value),className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Sort Codex quotas by remaining",children:u.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,a.jsxs)("button",{type:"button",onClick:()=>eq(e=>!e),"aria-pressed":e$,className:`flex h-8 shrink-0 items-center gap-1 rounded-lg border px-2 text-xs transition-colors ${e$?"border-amber-500/40 bg-amber-500/10 text-amber-500":"border-black/10 text-text-primary hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5"}`,title:"Sort accounts by earliest quota reset time",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"hourglass_top"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Expiring first"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{e9(e8.filter(e=>(e.isActive??!0)&&e6(e)).map(e=>e.id),!1)},disabled:eD,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50",title:"Disable connections with depleted quota on the current page",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"block"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn off Empty"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{e9(e8.filter(e=>!(e.isActive??!0)&&!e6(e)).map(e=>e.id),!0)},disabled:eD,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs text-emerald-500 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",title:"Enable connections that still have quota on the current page",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn on Available"})]}),(0,a.jsxs)("button",{onClick:()=>H(e=>!e),className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5",title:U?"Disable auto-refresh":"Enable auto-refresh",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${U?"text-primary":"text-text-muted"}`,children:U?"toggle_on":"toggle_off"}),(0,a.jsx)("span",{className:"hidden text-text-primary sm:inline",children:"Auto-refresh"}),U&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",X,"s)"]})]}),(0,a.jsx)("button",{type:"button",onClick:()=>e1(!0),disabled:Q,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5 disabled:opacity-50",title:"Refresh all",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${Q?"animate-spin":""}`,children:"refresh"})})]})}),e$&&(0,a.jsx)("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300",children:"Expiring-first currently reorders accounts inside the current page. Cross-page ordering still follows backend pagination."}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:e8.map(r=>{let i,n,l,o=_[r.id],d=F[r.id],c=z[r.id],u=!1===r.isActive,m="codex"===r.provider,h=Number.isFinite(n="number"==typeof(i=o?.raw?.resetCredits?.availableCount)?i:Number(i))?Math.max(0,n):0,p=en===r.id,b=er===r.id||ei===r.id||p,g=o?.quotas||[],f=function(e,t=[],r={}){if(!Array.isArray(t)||0===t.length)return[];let a=k(e,r);return 0===a.size?t:t.filter(e=>!a.has(v(e)))}(r.provider,g,eS),y=function(e,t=[],r={}){if(!Array.isArray(t)||0===t.length)return[];let a=k(e,r);return 0===a.size?[]:t.filter(e=>a.has(v(e)))}(r.provider,g,eS);return(0,a.jsxs)(C.default,{padding:"none",className:`min-w-0 ${u?"opacity-60":""}`,children:[(0,a.jsx)("div",{className:"px-3 py-2 border-b border-black/10 dark:border-white/10",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:(0,a.jsx)(s.A,{src:`/providers/${r.provider}.png`,alt:r.provider,size:32,className:"object-contain",fallbackText:r.provider?.slice(0,2).toUpperCase()||"PR"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:r.provider}),x(r)?(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:x(r)}):null,D(r)?(0,a.jsx)("p",{className:"text-[11px] text-text-muted/80 truncate",children:D(r)}):null,"kiro"===r.provider&&(0,a.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[(0,a.jsx)("span",{className:"rounded-full bg-brand-500/10 px-2 py-0.5 text-[10px] font-semibold text-brand-600 dark:text-brand-300",children:(l=r.providerSpecificData?.authMethod)&&q[l]?q[l]:"api_key"===r.authType?"API Key":"OAuth"}),T(r)&&(0,a.jsx)("span",{className:"rounded-full bg-blue-500/10 px-2 py-0.5 text-[10px] font-semibold text-blue-600 dark:text-blue-400",children:T(r)}),(0,a.jsx)("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-semibold ${u?"bg-surface-2 text-text-muted":"active"===r.testStatus||"success"===r.testStatus?"bg-green-500/10 text-green-600 dark:text-green-400":"error"===r.testStatus||"expired"===r.testStatus||"unavailable"===r.testStatus?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-surface-2 text-text-muted"}`,children:u?"disabled":r.testStatus||"unknown"}),r.providerSpecificData?.profileArn&&(0,a.jsxs)("button",{type:"button",onClick:()=>t(r.providerSpecificData.profileArn,r.id),title:r.providerSpecificData.profileArn,className:"inline-flex max-w-full items-center gap-1 rounded-full border border-border-subtle px-2 py-0.5 text-[10px] text-text-muted transition-colors hover:text-primary",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:e===r.id?"check":"content_copy"}),(0,a.jsx)("code",{className:"truncate font-mono",children:r.providerSpecificData.profileArn})]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[m&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N.default,{text:h>0?`Use one Codex reset credit. Available: ${h}`:"No Codex reset credits available",children:(0,a.jsxs)("button",{type:"button",onClick:()=>ed({connection:r,resetCreditCount:h}),disabled:h<=0||d||b,"aria-label":h>0?`Use one Codex reset credit. ${h} available.`:"No Codex reset credits available",className:`flex h-8 min-w-10 items-center justify-center gap-1 rounded-lg border px-2 text-[11px] font-medium tabular-nums transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary/60 disabled:cursor-not-allowed disabled:opacity-60 ${h>0?"border-primary/30 bg-primary/5 text-primary hover:bg-primary/10":"border-black/10 bg-black/[0.02] text-text-muted dark:border-white/10 dark:bg-white/[0.03]"}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[15px] ${p?"animate-spin":""}`,children:p?"progress_activity":"restart_alt"}),(0,a.jsx)("span",{children:h})]})}),(0,a.jsx)(N.default,{text:"View Codex reset credit expiry",children:(0,a.jsx)("button",{type:"button",onClick:()=>eY(r),disabled:d||b,"aria-label":"View Codex reset credit expiry",className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-muted transition-colors hover:bg-black/5 hover:text-primary disabled:cursor-not-allowed disabled:opacity-50 dark:border-white/10 dark:hover:bg-white/5",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[17px]",children:"schedule"})})})]}),P[r.provider]&&"oauth"===r.authType&&(0,a.jsx)(N.default,{text:E[r.provider],children:(0,a.jsx)("button",{type:"button",onClick:()=>e5(r.id,r.provider,J[r.provider]?.[r.id]!==!0),"aria-label":"Toggle auto-ping",className:`flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${J[r.provider]?.[r.id]===!0?"text-primary":"text-text-muted"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"})})}),(0,a.jsx)(N.default,{text:"Refresh quota",children:(0,a.jsx)("button",{type:"button",onClick:()=>eB(r.id,r.provider),disabled:d||b,"aria-label":"Refresh quota",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${d?"animate-spin":""}`,children:"refresh"})})}),(0,a.jsx)(N.default,{text:"Edit connection",children:(0,a.jsx)("button",{type:"button",onClick:()=>{ep(r),em(!0)},disabled:b,"aria-label":"Edit connection",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})})}),(0,a.jsx)(N.default,{text:"Delete connection",children:(0,a.jsx)("button",{type:"button",onClick:()=>eX(r.id),disabled:b,"aria-label":"Delete connection",className:"flex h-8 w-8 items-center justify-center rounded-lg hover:bg-red-500/10 text-red-500 transition-colors disabled:opacity-50",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${er===r.id?"animate-pulse":""}`,children:"delete"})})}),(0,a.jsx)("div",{className:"inline-flex items-center pl-0.5",title:r.isActive??!0?"Disable connection":"Enable connection",children:(0,a.jsx)(j.default,{size:"sm",checked:r.isActive??!0,disabled:b,onChange:e=>eZ(r.id,e)})})]})]})}),(0,a.jsxs)("div",{className:"px-2 py-1.5",children:[d?(0,a.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):c?(0,a.jsxs)("div",{className:"text-center py-5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),(0,a.jsx)("p",{className:"mt-1.5 text-xs text-text-muted",children:c})]}):o?.message?(0,a.jsx)("div",{className:"text-center py-5",children:(0,a.jsx)("p",{className:"text-xs text-text-muted",children:o.message})}):(0,a.jsx)(w,{quotas:f,compact:!0,sortMode:"default",showSortLabel:"codex"===r.provider&&"default"!==eN,onHideQuota:e=>e3(r.provider,e)}),o?.message&&!c&&!d&&(0,a.jsx)("p",{className:"mt-2 px-1 text-[10px] leading-relaxed text-text-muted",children:o.message}),y.length>0&&(0,a.jsxs)("div",{className:"mt-2 flex min-w-0 items-center gap-1 border-t border-black/5 pt-2 text-[10px] text-text-muted dark:border-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[14px]",children:"visibility_off"}),(0,a.jsx)("span",{className:"shrink-0",children:"Hidden:"}),(0,a.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto whitespace-nowrap pb-2",children:y.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>e4(r.provider,e),className:"shrink-0 rounded-md border border-black/10 px-1.5 py-0.5 transition-colors hover:bg-black/5 hover:text-text-primary dark:border-white/10 dark:hover:bg-white/5",title:"Show this quota row",children:e.name},v(e)))})]})]})]},r.id)})}),(0,a.jsx)("div",{className:"rounded-xl border border-black/10 bg-black/[0.02] px-3 py-2 dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:ta}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)("select",{value:ti?"custom":String(e_),onChange:e=>{let t=e.target.value;if("custom"===t)return;let r=Number.parseInt(t,10);Number.isFinite(r)&&(eO(1),eI(r),eL(String(r)))},className:"h-8 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Accounts per page",children:[d.map(e=>(0,a.jsxs)("option",{value:String(e),children:[e," / page"]},e)),(0,a.jsx)("option",{value:"custom",children:"Custom"})]}),(0,a.jsx)("input",{type:"number",min:"1",max:String(500),inputMode:"numeric",value:eF,onChange:e=>eL(e.target.value),onBlur:()=>{let e=Number.parseInt(eF,10);if(!Number.isFinite(e))return void eL(String(e_));let t=Math.min(500,Math.max(1,e));eO(1),eI(t),eL(String(t))},onKeyDown:e=>{if("Enter"!==e.key)return;let t=Number.parseInt(eF,10);if(!Number.isFinite(t))return void eL(String(e_));let r=Math.min(500,Math.max(1,t));eO(1),eI(r),eL(String(r))},className:"h-8 w-20 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary outline-none transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-label":"Custom accounts per page",placeholder:"Custom"}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Page ",ez.page," / ",ez.totalPages]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("button",{type:"button",onClick:()=>eO(1),disabled:ez.page<=1||ee||Q,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"First Page"}),(0,a.jsx)("button",{type:"button",onClick:()=>eO(e=>Math.max(1,e-1)),disabled:ez.page<=1||ee||Q,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Previous accounts page",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_left"})}),(0,a.jsx)("button",{type:"button",onClick:()=>eO(e=>Math.min(ez.totalPages,e+1)),disabled:ez.page>=ez.totalPages||ee||Q,className:"flex h-8 w-8 items-center justify-center rounded-lg border border-black/10 text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5","aria-label":"Next accounts page",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"chevron_right"})}),(0,a.jsx)("button",{type:"button",onClick:()=>eO(ez.totalPages),disabled:ez.page>=ez.totalPages||ee||Q,className:"flex h-8 items-center rounded-lg border border-black/10 px-3 text-xs text-text-primary transition-colors hover:bg-black/5 disabled:cursor-not-allowed disabled:opacity-40 dark:border-white/10 dark:hover:bg-white/5",children:"Last Page"})]})]})}),(0,a.jsx)(S.uo,{isOpen:!!eo,onClose:()=>{en||ed(null)},onConfirm:async()=>{let e=eo?.connection;e&&(await eQ(e.id,e.provider),ed(null))},title:"Reset Codex limit?",message:`Use 1 Codex reset credit for ${x(eo?.connection||{})||"this account"}. This cannot be undone. Remaining credits: ${eo?.resetCreditCount??0}.`,confirmText:"Reset limit",cancelText:"Cancel",variant:"danger",loading:!!en}),ec&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 px-4 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"w-full max-w-2xl overflow-hidden rounded-2xl border border-black/15 bg-white shadow-2xl ring-1 ring-black/10 dark:border-white/15 dark:bg-neutral-950 dark:ring-white/10",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b border-black/10 bg-black/[0.03] px-4 py-3 dark:border-white/10 dark:bg-white/[0.04]",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-base font-semibold text-text-primary",children:"Codex Reset Credit Expiry"}),(0,a.jsx)("p",{className:"mt-0.5 truncate text-xs text-text-muted",children:x(ec.connection)||"Codex account"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>eu(null),className:"flex h-8 w-8 items-center justify-center rounded-lg text-text-muted transition-colors hover:bg-black/5 hover:text-text-primary dark:hover:bg-white/5","aria-label":"Close reset credit expiry modal",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsx)("div",{className:"max-h-[70vh] overflow-auto bg-white p-4 dark:bg-neutral-950",children:ec.loading?(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin text-[20px]",children:"progress_activity"}),"Loading reset credits..."]}):ec.error?(0,a.jsx)("div",{className:"rounded-xl border border-red-500/20 bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-300",children:ec.error}):ec.data?.credits?.length?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between rounded-xl border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:[(0,a.jsxs)("span",{children:[ec.data.credits.length," reset credit",1===ec.data.credits.length?"":"s"]}),(0,a.jsxs)("span",{children:[ec.data.availableCount??0," available"]})]}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-xl border border-black/10 dark:border-white/10",children:(0,a.jsxs)("table",{className:"w-full min-w-[560px] text-left text-sm",children:[(0,a.jsx)("thead",{className:"bg-black/[0.03] text-xs uppercase tracking-wide text-text-muted dark:bg-white/[0.04]",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-3 py-2 font-medium",children:"Status"}),(0,a.jsx)("th",{className:"px-3 py-2 font-medium",children:"Granted At"}),(0,a.jsx)("th",{className:"px-3 py-2 font-medium",children:"Expires At"}),(0,a.jsx)("th",{className:"px-3 py-2 font-medium",children:"Remaining"})]})}),(0,a.jsx)("tbody",{children:ec.data.credits.map((e,t)=>(0,a.jsxs)("tr",{className:"border-t border-black/5 dark:border-white/5",children:[(0,a.jsx)("td",{className:"px-3 py-2",children:(0,a.jsx)("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary",children:e.status||"unknown"})}),(0,a.jsx)("td",{className:"px-3 py-2 text-text-muted",children:M(e.grantedAt)}),(0,a.jsx)("td",{className:"px-3 py-2 text-text-primary",children:M(e.expiresAt)}),(0,a.jsx)("td",{className:"px-3 py-2 font-medium text-text-primary",children:function(e){if(!e)return"N/A";let t=new Date(e).getTime()-Date.now();if(!Number.isFinite(t))return"N/A";if(t<=0)return"Expired";let r=Math.ceil(t/36e5),a=Math.floor(r/24),i=r%24;return a>0?`${a}d ${i}h`:`${i}h`}(e.expiresAt)})]},`${e.status}-${e.expiresAt||t}`))})]})})]}):(0,a.jsx)("div",{className:"rounded-xl border border-black/10 bg-black/[0.02] px-3 py-8 text-center text-sm text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:"No reset credit details returned for this account."})})]})}),(0,a.jsx)(S.wI,{isOpen:ex,connection:eh,proxyPools:eb,onSave:e0,onClose:()=>{em(!1),ep(null)}})]}):(0,a.jsx)(C.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:tr.icon}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:tr.title}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:tr.description})]})}):(0,a.jsx)(C.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:"Connect to providers with OAuth to track your API quota limits and usage."})]})})}},96002:(e,t,r)=>{Promise.resolve().then(r.bind(r,75095)),Promise.resolve().then(r.bind(r,25086))}},e=>{e.O(0,[4614,1321,705,5497,8441,3794,7358],()=>e(e.s=96002)),_N_E=e.O()}]);