@synthever/jrouter 1.0.3 → 1.0.5

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 (597) hide show
  1. package/README.md +129 -158
  2. package/app/.next-cli-build/BUILD_ID +1 -1
  3. package/app/.next-cli-build/app-path-routes-manifest.json +24 -24
  4. package/app/.next-cli-build/build-manifest.json +2 -2
  5. package/app/.next-cli-build/prerender-manifest.json +19 -19
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/health/page.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/health/page.js.nft.json +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +2 -2
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  33. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +1 -1
  34. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
  35. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  36. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js +1 -1
  37. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
  38. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  39. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js +1 -1
  40. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
  41. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  42. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js +1 -1
  43. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  44. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  45. package/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page.js +1 -1
  46. package/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page.js.nft.json +1 -1
  47. package/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
  48. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js +1 -1
  49. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  50. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  51. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  52. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  53. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  54. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
  55. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  56. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  57. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js +1 -1
  58. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  59. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  60. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page.js +1 -1
  61. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page.js.nft.json +1 -1
  62. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  63. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js +1 -1
  64. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js.nft.json +1 -1
  65. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  66. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js +1 -1
  67. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
  68. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  69. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js +1 -1
  70. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js.nft.json +1 -1
  71. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  72. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js +1 -1
  73. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +1 -1
  74. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  75. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js +1 -1
  76. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
  77. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  78. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js +1 -1
  79. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
  80. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  81. package/app/.next-cli-build/server/app/_global-error/page.js.nft.json +1 -1
  82. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  83. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  84. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  85. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  86. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  87. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  88. package/app/.next-cli-build/server/app/_not-found/page.js +1 -1
  89. package/app/.next-cli-build/server/app/_not-found/page.js.nft.json +1 -1
  90. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  91. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  92. package/app/.next-cli-build/server/app/_not-found.rsc +5 -5
  93. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +5 -5
  94. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -5
  95. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  96. package/app/.next-cli-build/server/app/api/auth/login/route.js +1 -1
  97. package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
  98. package/app/.next-cli-build/server/app/api/auth/logout/route.js +1 -1
  99. package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
  100. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js +1 -1
  101. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js.nft.json +1 -1
  102. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js +1 -1
  103. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js.nft.json +1 -1
  104. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js +1 -1
  105. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js.nft.json +1 -1
  106. package/app/.next-cli-build/server/app/api/auth/reset-password/route.js +1 -1
  107. package/app/.next-cli-build/server/app/api/auth/reset-password/route.js.nft.json +1 -1
  108. package/app/.next-cli-build/server/app/api/auth/saml/acs/route.js +1 -1
  109. package/app/.next-cli-build/server/app/api/auth/saml/acs/route.js.nft.json +1 -1
  110. package/app/.next-cli-build/server/app/api/auth/saml/metadata/route.js +1 -1
  111. package/app/.next-cli-build/server/app/api/auth/saml/metadata/route.js.nft.json +1 -1
  112. package/app/.next-cli-build/server/app/api/auth/saml/start/route.js +1 -1
  113. package/app/.next-cli-build/server/app/api/auth/saml/start/route.js.nft.json +1 -1
  114. package/app/.next-cli-build/server/app/api/auth/saml/test/route.js +1 -1
  115. package/app/.next-cli-build/server/app/api/auth/saml/test/route.js.nft.json +1 -1
  116. package/app/.next-cli-build/server/app/api/auth/status/route.js +1 -1
  117. package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
  118. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +1 -1
  119. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  120. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
  121. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  122. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
  123. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  124. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
  125. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
  126. package/app/.next-cli-build/server/app/api/cli-tools/codewhale-settings/route.js +1 -1
  127. package/app/.next-cli-build/server/app/api/cli-tools/codewhale-settings/route.js.nft.json +1 -1
  128. package/app/.next-cli-build/server/app/api/cli-tools/codex-profiles/route.js.nft.json +1 -1
  129. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
  130. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js +1 -1
  131. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js.nft.json +1 -1
  132. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +1 -1
  133. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
  134. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
  135. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
  136. package/app/.next-cli-build/server/app/api/cli-tools/crush-settings/route.js +1 -1
  137. package/app/.next-cli-build/server/app/api/cli-tools/crush-settings/route.js.nft.json +1 -1
  138. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +1 -1
  139. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +1 -1
  140. package/app/.next-cli-build/server/app/api/cli-tools/devin-settings/route.js.nft.json +1 -1
  141. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
  142. package/app/.next-cli-build/server/app/api/cli-tools/forge-settings/route.js +1 -1
  143. package/app/.next-cli-build/server/app/api/cli-tools/forge-settings/route.js.nft.json +1 -1
  144. package/app/.next-cli-build/server/app/api/cli-tools/grok-build-settings/route.js +1 -1
  145. package/app/.next-cli-build/server/app/api/cli-tools/grok-build-settings/route.js.nft.json +1 -1
  146. package/app/.next-cli-build/server/app/api/cli-tools/hermes-profiles/route.js.nft.json +1 -1
  147. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js.nft.json +1 -1
  148. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js.nft.json +1 -1
  149. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
  150. package/app/.next-cli-build/server/app/api/cli-tools/omp-settings/route.js +1 -1
  151. package/app/.next-cli-build/server/app/api/cli-tools/omp-settings/route.js.nft.json +1 -1
  152. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
  153. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +1 -1
  154. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
  155. package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +1 -1
  156. package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js.nft.json +1 -1
  157. package/app/.next-cli-build/server/app/api/cli-tools/smelt-settings/route.js +1 -1
  158. package/app/.next-cli-build/server/app/api/cli-tools/smelt-settings/route.js.nft.json +1 -1
  159. package/app/.next-cli-build/server/app/api/combos/[id]/route.js +1 -1
  160. package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
  161. package/app/.next-cli-build/server/app/api/combos/presets/route.js +1 -1
  162. package/app/.next-cli-build/server/app/api/combos/presets/route.js.nft.json +1 -1
  163. package/app/.next-cli-build/server/app/api/combos/route.js +1 -1
  164. package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
  165. package/app/.next-cli-build/server/app/api/headroom/extras/route.js.nft.json +1 -1
  166. package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js +1 -1
  167. package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js.nft.json +1 -1
  168. package/app/.next-cli-build/server/app/api/headroom/restart/route.js +1 -1
  169. package/app/.next-cli-build/server/app/api/headroom/restart/route.js.nft.json +1 -1
  170. package/app/.next-cli-build/server/app/api/headroom/start/route.js +1 -1
  171. package/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +1 -1
  172. package/app/.next-cli-build/server/app/api/headroom/status/route.js +1 -1
  173. package/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +1 -1
  174. package/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +1 -1
  175. package/app/.next-cli-build/server/app/api/health/route.js.nft.json +1 -1
  176. package/app/.next-cli-build/server/app/api/init/route.js.nft.json +1 -1
  177. package/app/.next-cli-build/server/app/api/keys/[id]/route.js +1 -1
  178. package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
  179. package/app/.next-cli-build/server/app/api/keys/[id]/secret/route.js +1 -1
  180. package/app/.next-cli-build/server/app/api/keys/[id]/secret/route.js.nft.json +1 -1
  181. package/app/.next-cli-build/server/app/api/keys/route.js +1 -1
  182. package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
  183. package/app/.next-cli-build/server/app/api/locale/route.js.nft.json +1 -1
  184. package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
  185. package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
  186. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js +1 -1
  187. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
  188. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js +1 -1
  189. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
  190. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js +1 -1
  191. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
  192. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js +1 -1
  193. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
  194. package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js.nft.json +1 -1
  195. package/app/.next-cli-build/server/app/api/model-health/check/route.js +2 -2
  196. package/app/.next-cli-build/server/app/api/model-health/check/route.js.nft.json +1 -1
  197. package/app/.next-cli-build/server/app/api/model-health/check-all/route.js +2 -2
  198. package/app/.next-cli-build/server/app/api/model-health/check-all/route.js.nft.json +1 -1
  199. package/app/.next-cli-build/server/app/api/model-health/config/route.js +2 -2
  200. package/app/.next-cli-build/server/app/api/model-health/config/route.js.nft.json +1 -1
  201. package/app/.next-cli-build/server/app/api/model-health/history/route.js +2 -2
  202. package/app/.next-cli-build/server/app/api/model-health/history/route.js.nft.json +1 -1
  203. package/app/.next-cli-build/server/app/api/model-health/model/route.js +2 -2
  204. package/app/.next-cli-build/server/app/api/model-health/model/route.js.nft.json +1 -1
  205. package/app/.next-cli-build/server/app/api/model-health/models/route.js +2 -2
  206. package/app/.next-cli-build/server/app/api/model-health/models/route.js.nft.json +1 -1
  207. package/app/.next-cli-build/server/app/api/model-health/route.js +2 -2
  208. package/app/.next-cli-build/server/app/api/model-health/route.js.nft.json +1 -1
  209. package/app/.next-cli-build/server/app/api/model-health/run-scheduled/route.js +2 -2
  210. package/app/.next-cli-build/server/app/api/model-health/run-scheduled/route.js.nft.json +1 -1
  211. package/app/.next-cli-build/server/app/api/model-health/summary/route.js +2 -2
  212. package/app/.next-cli-build/server/app/api/model-health/summary/route.js.nft.json +1 -1
  213. package/app/.next-cli-build/server/app/api/models/alias/route.js +1 -1
  214. package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
  215. package/app/.next-cli-build/server/app/api/models/availability/route.js +1 -1
  216. package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
  217. package/app/.next-cli-build/server/app/api/models/catalog-sync/route.js +1 -1
  218. package/app/.next-cli-build/server/app/api/models/catalog-sync/route.js.nft.json +1 -1
  219. package/app/.next-cli-build/server/app/api/models/custom/route.js +1 -1
  220. package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
  221. package/app/.next-cli-build/server/app/api/models/disabled/route.js +1 -1
  222. package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
  223. package/app/.next-cli-build/server/app/api/models/limits/route.js +1 -1
  224. package/app/.next-cli-build/server/app/api/models/limits/route.js.nft.json +1 -1
  225. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  226. package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
  227. package/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
  228. package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
  229. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  230. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  231. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js +1 -1
  232. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
  233. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
  234. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
  235. package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
  236. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js +1 -1
  237. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  238. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js +1 -1
  239. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
  240. package/app/.next-cli-build/server/app/api/oauth/grok-cli/bulk-import/route.js +1 -1
  241. package/app/.next-cli-build/server/app/api/oauth/grok-cli/bulk-import/route.js.nft.json +1 -1
  242. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js +1 -1
  243. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  244. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js +1 -1
  245. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js.nft.json +1 -1
  246. package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
  247. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js +1 -1
  248. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  249. package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js +1 -1
  250. package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js.nft.json +1 -1
  251. package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
  252. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  253. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  254. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/api-key/route.js +1 -1
  255. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/api-key/route.js.nft.json +1 -1
  256. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/auto-import/route.js.nft.json +1 -1
  257. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/login/start/route.js.nft.json +1 -1
  258. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/login/status/route.js.nft.json +1 -1
  259. package/app/.next-cli-build/server/app/api/oauth/zed/auto-import/route.js.nft.json +1 -1
  260. package/app/.next-cli-build/server/app/api/oauth/zed/import/route.js +1 -1
  261. package/app/.next-cli-build/server/app/api/oauth/zed/import/route.js.nft.json +1 -1
  262. package/app/.next-cli-build/server/app/api/pricing/route.js +1 -1
  263. package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
  264. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js +1 -1
  265. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  266. package/app/.next-cli-build/server/app/api/provider-nodes/route.js +1 -1
  267. package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
  268. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js +1 -1
  269. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
  270. package/app/.next-cli-build/server/app/api/providers/[id]/connections/keys/route.js +1 -1
  271. package/app/.next-cli-build/server/app/api/providers/[id]/connections/keys/route.js.nft.json +1 -1
  272. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js +1 -1
  273. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  274. package/app/.next-cli-build/server/app/api/providers/[id]/overrides/route.js +1 -1
  275. package/app/.next-cli-build/server/app/api/providers/[id]/overrides/route.js.nft.json +1 -1
  276. package/app/.next-cli-build/server/app/api/providers/[id]/route.js +1 -1
  277. package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
  278. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js +1 -1
  279. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  280. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js +1 -1
  281. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  282. package/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
  283. package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
  284. package/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js.nft.json +1 -1
  285. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  286. package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
  287. package/app/.next-cli-build/server/app/api/providers/suggested-models/route.js.nft.json +1 -1
  288. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js +1 -1
  289. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  290. package/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
  291. package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
  292. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js +1 -1
  293. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js.nft.json +1 -1
  294. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js +1 -1
  295. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js.nft.json +1 -1
  296. package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js +2 -2
  297. package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js.nft.json +1 -1
  298. package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js +1 -1
  299. package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js.nft.json +1 -1
  300. package/app/.next-cli-build/server/app/api/proxy-pools/netlify-deploy/route.js +1 -1
  301. package/app/.next-cli-build/server/app/api/proxy-pools/netlify-deploy/route.js.nft.json +1 -1
  302. package/app/.next-cli-build/server/app/api/proxy-pools/route.js +1 -1
  303. package/app/.next-cli-build/server/app/api/proxy-pools/route.js.nft.json +1 -1
  304. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js +1 -1
  305. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js.nft.json +1 -1
  306. package/app/.next-cli-build/server/app/api/pxpipe/health/route.js.nft.json +1 -1
  307. package/app/.next-cli-build/server/app/api/pxpipe/install/route.js.nft.json +1 -1
  308. package/app/.next-cli-build/server/app/api/pxpipe/logs/route.js.nft.json +1 -1
  309. package/app/.next-cli-build/server/app/api/pxpipe/restart/route.js.nft.json +1 -1
  310. package/app/.next-cli-build/server/app/api/pxpipe/start/route.js +1 -1
  311. package/app/.next-cli-build/server/app/api/pxpipe/start/route.js.nft.json +1 -1
  312. package/app/.next-cli-build/server/app/api/pxpipe/stats/route.js.nft.json +1 -1
  313. package/app/.next-cli-build/server/app/api/pxpipe/status/route.js +1 -1
  314. package/app/.next-cli-build/server/app/api/pxpipe/status/route.js.nft.json +1 -1
  315. package/app/.next-cli-build/server/app/api/pxpipe/stop/route.js.nft.json +1 -1
  316. package/app/.next-cli-build/server/app/api/settings/database/route.js +1 -1
  317. package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
  318. package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
  319. package/app/.next-cli-build/server/app/api/settings/require-login/route.js +1 -1
  320. package/app/.next-cli-build/server/app/api/settings/require-login/route.js.nft.json +1 -1
  321. package/app/.next-cli-build/server/app/api/settings/route.js +1 -1
  322. package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
  323. package/app/.next-cli-build/server/app/api/shutdown/route.js.nft.json +1 -1
  324. package/app/.next-cli-build/server/app/api/tags/route.js.nft.json +1 -1
  325. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  326. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js.nft.json +1 -1
  327. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  328. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
  329. package/app/.next-cli-build/server/app/api/translator/load/route.js.nft.json +1 -1
  330. package/app/.next-cli-build/server/app/api/translator/save/route.js.nft.json +1 -1
  331. package/app/.next-cli-build/server/app/api/translator/send/route.js +1 -1
  332. package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
  333. package/app/.next-cli-build/server/app/api/translator/translate/route.js +1 -1
  334. package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
  335. package/app/.next-cli-build/server/app/api/tunnel/disable/route.js +1 -1
  336. package/app/.next-cli-build/server/app/api/tunnel/disable/route.js.nft.json +1 -1
  337. package/app/.next-cli-build/server/app/api/tunnel/enable/route.js +1 -1
  338. package/app/.next-cli-build/server/app/api/tunnel/enable/route.js.nft.json +1 -1
  339. package/app/.next-cli-build/server/app/api/tunnel/status/route.js +1 -1
  340. package/app/.next-cli-build/server/app/api/tunnel/status/route.js.nft.json +1 -1
  341. package/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js +1 -1
  342. package/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js.nft.json +1 -1
  343. package/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js +1 -1
  344. package/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js.nft.json +1 -1
  345. package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js +1 -1
  346. package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js.nft.json +1 -1
  347. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js +1 -1
  348. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js.nft.json +1 -1
  349. package/app/.next-cli-build/server/app/api/usage/[connectionId]/claude-reset/route.js +1 -1
  350. package/app/.next-cli-build/server/app/api/usage/[connectionId]/claude-reset/route.js.nft.json +1 -1
  351. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js +1 -1
  352. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js.nft.json +1 -1
  353. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js +1 -1
  354. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  355. package/app/.next-cli-build/server/app/api/usage/chart/route.js +1 -1
  356. package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
  357. package/app/.next-cli-build/server/app/api/usage/history/route.js +1 -1
  358. package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
  359. package/app/.next-cli-build/server/app/api/usage/logs/route.js +1 -1
  360. package/app/.next-cli-build/server/app/api/usage/logs/route.js.nft.json +1 -1
  361. package/app/.next-cli-build/server/app/api/usage/providers/route.js +1 -1
  362. package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
  363. package/app/.next-cli-build/server/app/api/usage/request-details/route.js +1 -1
  364. package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
  365. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js +1 -1
  366. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  367. package/app/.next-cli-build/server/app/api/usage/stats/route.js +1 -1
  368. package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
  369. package/app/.next-cli-build/server/app/api/usage/stream/route.js +1 -1
  370. package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
  371. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js +1 -1
  372. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  373. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js +1 -1
  374. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  375. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js +1 -1
  376. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  377. package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js +1 -1
  378. package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js.nft.json +1 -1
  379. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js +1 -1
  380. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  381. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js +1 -1
  382. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  383. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js +1 -1
  384. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  385. package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js +1 -1
  386. package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
  387. package/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
  388. package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
  389. package/app/.next-cli-build/server/app/api/v1/models/[...model]/route.js +1 -1
  390. package/app/.next-cli-build/server/app/api/v1/models/[...model]/route.js.nft.json +1 -1
  391. package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
  392. package/app/.next-cli-build/server/app/api/v1/models/info/route.js.nft.json +1 -1
  393. package/app/.next-cli-build/server/app/api/v1/models/route.js +1 -1
  394. package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
  395. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js +1 -1
  396. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  397. package/app/.next-cli-build/server/app/api/v1/responses/route.js +1 -1
  398. package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
  399. package/app/.next-cli-build/server/app/api/v1/route.js +1 -1
  400. package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
  401. package/app/.next-cli-build/server/app/api/v1/search/route.js +1 -1
  402. package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
  403. package/app/.next-cli-build/server/app/api/v1/systemone/route.js +1 -1
  404. package/app/.next-cli-build/server/app/api/v1/systemone/route.js.nft.json +1 -1
  405. package/app/.next-cli-build/server/app/api/v1/videos/[id]/route.js +1 -1
  406. package/app/.next-cli-build/server/app/api/v1/videos/[id]/route.js.nft.json +1 -1
  407. package/app/.next-cli-build/server/app/api/v1/videos/edits/route.js +1 -1
  408. package/app/.next-cli-build/server/app/api/v1/videos/edits/route.js.nft.json +1 -1
  409. package/app/.next-cli-build/server/app/api/v1/videos/extensions/route.js +1 -1
  410. package/app/.next-cli-build/server/app/api/v1/videos/extensions/route.js.nft.json +1 -1
  411. package/app/.next-cli-build/server/app/api/v1/videos/generations/route.js +1 -1
  412. package/app/.next-cli-build/server/app/api/v1/videos/generations/route.js.nft.json +1 -1
  413. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js +1 -1
  414. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  415. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js +1 -1
  416. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  417. package/app/.next-cli-build/server/app/api/v1beta/models/route.js +1 -1
  418. package/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +1 -1
  419. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  420. package/app/.next-cli-build/server/app/api/version/route.js.nft.json +1 -1
  421. package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
  422. package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
  423. package/app/.next-cli-build/server/app/callback/page.js +1 -1
  424. package/app/.next-cli-build/server/app/callback/page.js.nft.json +1 -1
  425. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  426. package/app/.next-cli-build/server/app/callback.html +1 -1
  427. package/app/.next-cli-build/server/app/callback.rsc +5 -5
  428. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +5 -5
  429. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +2 -2
  430. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +5 -5
  431. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  432. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +7 -7
  433. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +7 -7
  434. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +7 -7
  435. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +2 -2
  436. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  437. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +7 -7
  438. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +7 -7
  439. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +7 -7
  440. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
  441. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  442. package/app/.next-cli-build/server/app/dashboard/combos.rsc +7 -7
  443. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +7 -7
  444. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +7 -7
  445. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
  446. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  447. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +7 -7
  448. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +7 -7
  449. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +7 -7
  450. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
  451. package/app/.next-cli-build/server/app/dashboard/health.html +1 -1
  452. package/app/.next-cli-build/server/app/dashboard/health.rsc +6 -6
  453. package/app/.next-cli-build/server/app/dashboard/health.segments/!KGRhc2hib2FyZCk/dashboard/health/__PAGE__.segment.rsc +6 -6
  454. package/app/.next-cli-build/server/app/dashboard/health.segments/_full.segment.rsc +6 -6
  455. package/app/.next-cli-build/server/app/dashboard/health.segments/_tree.segment.rsc +2 -2
  456. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  457. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +7 -7
  458. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +7 -7
  459. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +7 -7
  460. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +2 -2
  461. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  462. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +7 -7
  463. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +7 -7
  464. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +7 -7
  465. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
  466. package/app/.next-cli-build/server/app/dashboard/playground.html +1 -1
  467. package/app/.next-cli-build/server/app/dashboard/playground.rsc +7 -7
  468. package/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground/__PAGE__.segment.rsc +7 -7
  469. package/app/.next-cli-build/server/app/dashboard/playground.segments/_full.segment.rsc +7 -7
  470. package/app/.next-cli-build/server/app/dashboard/playground.segments/_tree.segment.rsc +2 -2
  471. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  472. package/app/.next-cli-build/server/app/dashboard/profile.rsc +7 -7
  473. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +7 -7
  474. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +7 -7
  475. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
  476. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  477. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +7 -7
  478. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +7 -7
  479. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +7 -7
  480. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
  481. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  482. package/app/.next-cli-build/server/app/dashboard/providers.rsc +7 -7
  483. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +7 -7
  484. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +7 -7
  485. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
  486. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  487. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +7 -7
  488. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +7 -7
  489. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +7 -7
  490. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
  491. package/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
  492. package/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +7 -7
  493. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +7 -7
  494. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +7 -7
  495. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +2 -2
  496. package/app/.next-cli-build/server/app/dashboard/quota.html +1 -1
  497. package/app/.next-cli-build/server/app/dashboard/quota.rsc +8 -8
  498. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +8 -8
  499. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +8 -8
  500. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
  501. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js +1 -1
  502. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
  503. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  504. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  505. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +5 -5
  506. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +5 -5
  507. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  508. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +5 -5
  509. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  510. package/app/.next-cli-build/server/app/dashboard/skills.rsc +7 -7
  511. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +7 -7
  512. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +7 -7
  513. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +2 -2
  514. package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  515. package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +7 -7
  516. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +7 -7
  517. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +7 -7
  518. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +2 -2
  519. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  520. package/app/.next-cli-build/server/app/dashboard/translator.rsc +7 -7
  521. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +7 -7
  522. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +7 -7
  523. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
  524. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  525. package/app/.next-cli-build/server/app/dashboard/usage.rsc +7 -7
  526. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +7 -7
  527. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +7 -7
  528. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
  529. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  530. package/app/.next-cli-build/server/app/dashboard.rsc +6 -6
  531. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +6 -6
  532. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +6 -6
  533. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  534. package/app/.next-cli-build/server/app/index.html +1 -1
  535. package/app/.next-cli-build/server/app/index.rsc +5 -5
  536. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +5 -5
  537. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +5 -5
  538. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +2 -2
  539. package/app/.next-cli-build/server/app/landing/page.js +1 -1
  540. package/app/.next-cli-build/server/app/landing/page.js.nft.json +1 -1
  541. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  542. package/app/.next-cli-build/server/app/landing.html +1 -1
  543. package/app/.next-cli-build/server/app/landing.rsc +5 -5
  544. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +5 -5
  545. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +2 -2
  546. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +5 -5
  547. package/app/.next-cli-build/server/app/login/page.js +1 -1
  548. package/app/.next-cli-build/server/app/login/page.js.nft.json +1 -1
  549. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  550. package/app/.next-cli-build/server/app/login.html +1 -1
  551. package/app/.next-cli-build/server/app/login.rsc +6 -6
  552. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +6 -6
  553. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +2 -2
  554. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +6 -6
  555. package/app/.next-cli-build/server/app/manifest.webmanifest/route.js +1 -1
  556. package/app/.next-cli-build/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  557. package/app/.next-cli-build/server/app/manifest.webmanifest.body +1 -1
  558. package/app/.next-cli-build/server/app/page.js +1 -1
  559. package/app/.next-cli-build/server/app/page.js.nft.json +1 -1
  560. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  561. package/app/.next-cli-build/server/app-paths-manifest.json +24 -24
  562. package/app/.next-cli-build/server/chunks/2760.js +1 -17
  563. package/app/.next-cli-build/server/chunks/412.js +1 -1
  564. package/app/.next-cli-build/server/chunks/436.js +1 -1
  565. package/app/.next-cli-build/server/chunks/455.js +1 -1
  566. package/app/.next-cli-build/server/chunks/4746.js +1 -1
  567. package/app/.next-cli-build/server/chunks/4764.js +1 -1
  568. package/app/.next-cli-build/server/chunks/4827.js +1 -1
  569. package/app/.next-cli-build/server/chunks/4864.js +1 -1
  570. package/app/.next-cli-build/server/chunks/5298.js +17 -0
  571. package/app/.next-cli-build/server/chunks/5563.js +1 -1
  572. package/app/.next-cli-build/server/chunks/5665.js +27 -0
  573. package/app/.next-cli-build/server/chunks/6296.js +4 -4
  574. package/app/.next-cli-build/server/chunks/735.js +1 -1
  575. package/app/.next-cli-build/server/chunks/7716.js +1 -1
  576. package/app/.next-cli-build/server/chunks/8126.js +1 -1
  577. package/app/.next-cli-build/server/chunks/8306.js +1 -1
  578. package/app/.next-cli-build/server/chunks/8895.js +1 -1
  579. package/app/.next-cli-build/server/instrumentation.js +1 -1
  580. package/app/.next-cli-build/server/instrumentation.js.nft.json +1 -1
  581. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  582. package/app/.next-cli-build/server/middleware.js +9 -9
  583. package/app/.next-cli-build/server/middleware.js.nft.json +1 -1
  584. package/app/.next-cli-build/server/pages/404.html +1 -1
  585. package/app/.next-cli-build/server/pages/500.html +1 -1
  586. package/app/.next-cli-build/static/chunks/{1321-f3534bbafebb96c9.js → 1321-3c971fb492222955.js} +1 -1
  587. package/app/.next-cli-build/static/chunks/{5497-973a06c94a94aff7.js → 5497-f836574435383a9a.js} +1 -1
  588. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-0c2a1f2542917271.js → page-87ca193c32e4c066.js} +9 -9
  589. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-0a9dfeb5c4e2b097.js +27 -0
  590. package/app/.next-cli-build/static/css/{3b896d96bcd3ef7a.css → 56aa6e7907cd49f9.css} +1 -1
  591. package/app/package.json +1 -1
  592. package/package.json +1 -1
  593. package/app/.next-cli-build/server/chunks/3192.js +0 -27
  594. package/app/.next-cli-build/server/chunks/379.js +0 -1
  595. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-eb6a5a055eded9f8.js +0 -27
  596. /package/app/.next-cli-build/static/{rJzsAZX3-_OjA05HFqaR_ → oR8OFCXf8t5fTOWrh72mj}/_buildManifest.js +0 -0
  597. /package/app/.next-cli-build/static/{rJzsAZX3-_OjA05HFqaR_ → oR8OFCXf8t5fTOWrh72mj}/_ssgManifest.js +0 -0
package/app/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "9router-app",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "9Router web dashboard",
5
5
  "private": true,
6
6
  "scripts": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synthever/jrouter",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "JRouter CLI - Start and manage the JRouter server",
5
5
  "bin": {
6
6
  "jrouter": "./cli.js"
@@ -1,27 +0,0 @@
1
- "use strict";exports.id=3192,exports.ids=[615,3192],exports.modules={644:(a,b,c)=>{function d(a,b=null){if(null==a)return b;if("string"!=typeof a)return a;try{return JSON.parse(a)}catch{return b}}function e(a){return JSON.stringify(a??null)}c.d(b,{q:()=>d,s:()=>e})},1129:(a,b,c)=>{c.r(b),c.d(b,{createProviderNode:()=>l,deleteProviderNode:()=>n,getProviderNodeById:()=>k,getProviderNodes:()=>j,updateProviderNode:()=>m});var d=c(94755),e=c(36366),f=c(644),g=c(82455);function h(a){return a?{...(0,f.q)(a.data,{}),id:a.id,type:a.type,name:a.name,createdAt:a.createdAt,updatedAt:a.updatedAt}:null}function i(a,b){let c=function(a){let{id:b,type:c,name:d,createdAt:e,updatedAt:g,...h}=a;return{id:b,type:c??null,name:d??null,data:(0,f.s)(h),createdAt:e,updatedAt:g}}(b);a.run(`INSERT INTO providerNodes(id, type, name, data, createdAt, updatedAt)
2
- VALUES(?, ?, ?, ?, ?, ?)
3
- ON CONFLICT(id) DO UPDATE SET
4
- type=excluded.type, name=excluded.name, data=excluded.data, updatedAt=excluded.updatedAt`,[c.id,c.type,c.name,c.data,c.createdAt,c.updatedAt])}async function j(a={}){let b=await (0,e.c)(),c=[],d=[];a.type&&(c.push("type = ?"),d.push(a.type));let f=`SELECT * FROM providerNodes${c.length?` WHERE ${c.join(" AND ")}`:""}`;return b.all(f,d).map(h)}async function k(a){return h((await (0,e.c)()).get("SELECT * FROM providerNodes WHERE id = ?",[a]))}async function l(a){let b=await (0,e.c)(),c=new Date().toISOString(),f={id:a.id||(0,d.A)(),type:a.type,name:a.name,prefix:a.prefix,apiType:a.apiType,baseUrl:a.baseUrl,createdAt:c,updatedAt:c};return i(b,f),f}async function m(a,b){let c=await (0,e.c)(),d=null;return c.transaction(()=>{let e=c.get("SELECT * FROM providerNodes WHERE id = ?",[a]);if(!e)return;let f={...h(e),...b,updatedAt:new Date().toISOString()};i(c,f),d=f}),d}async function n(a){let b=await (0,e.c)(),c=null;return b.transaction(()=>{let d=b.get("SELECT * FROM providerNodes WHERE id = ?",[a]);d&&(c=h(d),b.run("DELETE FROM providerNodes WHERE id = ?",[a]),b.run("DELETE FROM kv WHERE scope = 'customModels' AND key LIKE ?",[`${a}|%`]),(0,g.cC)(b,a,c?.prefix))}),c}},1541:(a,b,c)=>{c.d(b,{CG:()=>n,Dj:()=>k,IL:()=>h,L:()=>j,Uv:()=>i,jd:()=>l,oG:()=>m});var d=c(94755),e=c(36366),f=c(644),g=c(50830);function h(a){return a?{id:a.id,name:a.name,kind:a.kind,models:(0,f.q)(a.models,[]),...(0,g.bX)(a),createdAt:a.createdAt,updatedAt:a.updatedAt}:null}async function i(){return(await (0,e.c)()).all("SELECT * FROM combos ORDER BY createdAt ASC").map(h)}async function j(a){return h((await (0,e.c)()).get("SELECT * FROM combos WHERE id = ?",[a]))}async function k(a){return h((await (0,e.c)()).get("SELECT * FROM combos WHERE name = ?",[a]))}async function l(a){let b=await (0,e.c)(),c=new Date().toISOString(),h={id:(0,d.A)(),name:a.name,kind:a.kind||null,models:a.models||[],...(0,g.bX)((0,g.is)(a)),createdAt:c,updatedAt:c};return b.run("INSERT INTO combos(id, name, kind, models, createdAt, updatedAt, promptInjectionEnabled, promptInjectionMode, systemPrompt, displayIdentity) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",[h.id,h.name,h.kind,(0,f.s)(h.models),h.createdAt,h.updatedAt,+!!h.promptInjectionEnabled,h.promptInjectionMode,h.systemPrompt,h.displayIdentity]),h}async function m(a,b){let c=(0,g.is)(b),d=await (0,e.c)(),i=null;return d.transaction(()=>{let e=d.get("SELECT * FROM combos WHERE id = ?",[a]);if(!e)return;let g={...h(e),...b,...c,updatedAt:new Date().toISOString()};d.run("UPDATE combos SET name = ?, kind = ?, models = ?, updatedAt = ?, promptInjectionEnabled = ?, promptInjectionMode = ?, systemPrompt = ?, displayIdentity = ? WHERE id = ?",[g.name,g.kind,(0,f.s)(g.models||[]),g.updatedAt,+!!g.promptInjectionEnabled,g.promptInjectionMode,g.systemPrompt,g.displayIdentity,a]),i=g}),i}async function n(a){let b=(await (0,e.c)()).run("DELETE FROM combos WHERE id = ?",[a]);return(b?.changes??0)>0}},2818:(a,b,c)=>{c.d(b,{Ln:()=>i,MH:()=>j,WF:()=>d,ZX:()=>e,nX:()=>f,sh:()=>h,yR:()=>g});let d=[{value:"chat",label:"Chat / Responses",hint:"Chat completions, Responses, Claude, Gemini and Ollama"},{value:"embeddings",label:"Embeddings",hint:"Text embeddings"},{value:"images",label:"Images",hint:"Image generation"},{value:"audio",label:"Audio",hint:"Speech, transcription and voices"},{value:"web",label:"Web / Search",hint:"Search and web fetch"},{value:"videos",label:"Videos",hint:"Generation, edits, extensions and job status"},{value:"systemone",label:"SystemOne",hint:"SystemOne browser automation"}],e=["lifetime","hourly","daily","weekly","monthly"],f={description:"",maxTokensQuota:null,maxCostUsd:null,quotaResetCycle:"lifetime",tokenMultiplier:1,maxOutputTokens:null,rateLimitRpm:null,rateLimitTpm:null,expiresAt:null,allowedModels:[],blockedModels:[],allowedEndpoints:null},g=18e5,h=6e4,i=4096;function j(a){let b=a.replace(/^\/api(?=\/v1)/,"");return b.includes("/audio/")?"audio":b.includes("/images/")?"images":b.includes("/videos/")?"videos":b.endsWith("/embeddings")?"embeddings":b.includes("/search")||b.includes("/web/")?"web":b.endsWith("/systemone")?"systemone":"chat"}},5781:(a,b,c)=>{c.r(b),c.d(b,{cleanupProviderConnections:()=>s,createProviderConnection:()=>n,deleteProviderConnection:()=>p,deleteProviderConnectionsByProvider:()=>q,getProviderConnectionById:()=>l,getProviderConnections:()=>k,reorderProviderConnections:()=>r,updateProviderConnection:()=>o});var d=c(94755),e=c(36366),f=c(644);let g=["displayName","email","globalPriority","defaultModel","accessToken","refreshToken","expiresAt","tokenType","scope","projectId","apiKey","testStatus","lastTested","lastError","lastErrorAt","rateLimitedUntil","expiresIn","errorCode","consecutiveUseCount","idToken","lastRefreshAt"];function h(a,b){if(b?.testStatus!=="active")return b;let c={...b,testStatus:"active",lastError:Object.hasOwn(b,"lastError")?b.lastError:null,lastErrorAt:Object.hasOwn(b,"lastErrorAt")?b.lastErrorAt:null,errorCode:null,rateLimitedUntil:null,backoffLevel:0};for(let b of Object.keys(a||{}))b.startsWith("modelLock_")&&(c[b]=null);return c}function i(a){return a?{...(0,f.q)(a.data,{}),id:a.id,provider:a.provider,authType:a.authType,name:a.name,email:a.email,priority:a.priority,isActive:1===a.isActive||!0===a.isActive,createdAt:a.createdAt,updatedAt:a.updatedAt}:null}function j(a,b){let c=function(a){let{id:b,provider:c,authType:d,name:e,email:g,priority:h,isActive:i,createdAt:j,updatedAt:k,...l}=a;return{id:b,provider:c,authType:d,name:e??null,email:g??null,priority:h??null,isActive:+(!1!==i),data:(0,f.s)(l),createdAt:j,updatedAt:k}}(b);a.run(`INSERT INTO providerConnections(id, provider, authType, name, email, priority, isActive, data, createdAt, updatedAt)
5
- VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
6
- ON CONFLICT(id) DO UPDATE SET
7
- provider=excluded.provider, authType=excluded.authType, name=excluded.name,
8
- email=excluded.email, priority=excluded.priority, isActive=excluded.isActive,
9
- data=excluded.data, updatedAt=excluded.updatedAt`,[c.id,c.provider,c.authType,c.name,c.email,c.priority,c.isActive,c.data,c.createdAt,c.updatedAt])}async function k(a={}){let b=await (0,e.c)(),c=[],d=[];a.provider&&(c.push("provider = ?"),d.push(a.provider)),void 0!==a.isActive&&(c.push("isActive = ?"),d.push(+!!a.isActive));let f=`SELECT * FROM providerConnections${c.length?` WHERE ${c.join(" AND ")}`:""}`,g=b.all(f,d).map(i);return g.sort((a,b)=>(a.priority||999)-(b.priority||999)),g}async function l(a){return i((await (0,e.c)()).get("SELECT * FROM providerConnections WHERE id = ?",[a]))}function m(a,b){let c=a.all("SELECT * FROM providerConnections WHERE provider = ?",[b]).map(i);c.sort((a,b)=>{let c=(a.priority||0)-(b.priority||0);return 0!==c?c:new Date(b.updatedAt||0)-new Date(a.updatedAt||0)}),c.forEach((b,c)=>{let d=c+1;(b.priority||0)!==d&&a.run("UPDATE providerConnections SET priority = ? WHERE id = ?",[d,b.id])})}async function n(a){let b,c=await (0,e.c)(),f=new Date().toISOString();return c.transaction(()=>{var e;let k="apikey"===a.authType&&!!a.name,l=k?c.all("SELECT * FROM providerConnections WHERE provider = ? AND authType = ? AND name = ?",[a.provider,"apikey",a.name]).map(i):c.all("SELECT * FROM providerConnections WHERE provider = ?",[a.provider]).map(i),m=k?c.get("SELECT COUNT(*) AS n FROM providerConnections WHERE provider = ?",[a.provider])?.n??l.length:l.length,n=null;if("oauth"===a.authType&&a.email){let b=a.providerSpecificData?.username,c=a.providerSpecificData?.chatgptAccountId;n=l.find(d=>{if("oauth"!==d.authType||d.email!==a.email)return!1;if("codex"===a.provider){let a=d.providerSpecificData?.chatgptAccountId;return!!c&&!!a&&c===a}let e=d.providerSpecificData?.chatgptAccountId;if(c&&e)return c===e;if(c&&!e||!c&&e)return!1;let f=d.providerSpecificData?.username;return b&&f?b===f:!b&&!f})}else"apikey"===a.authType&&a.name&&(n=l.find(b=>"apikey"===b.authType&&b.name===a.name));if(n){if(!1===a.allowOverwrite){let b=Error(`A connection named "${n.name}" already exists for provider "${a.provider}". Pass allowOverwrite: true to replace it.`);throw b.code="PROVIDER_NAME_CONFLICT",b.existingId=n.id,b.existingName=n.name,b}let d=h(n,a),e={...n,...d,updatedAt:f};j(c,e),b=e;return}let o=a.name||null;o||"oauth"!==a.authType&&"access_token"!==a.authType||(e=a.email||`Account ${m+1}`,o="github"===a.provider&&(a.providerSpecificData?.githubLogin||a.providerSpecificData?.githubEmail||a.email||a.providerSpecificData?.githubName)||e);let p=a.priority;if(!p){let b=c.get("SELECT MAX(priority) AS m FROM providerConnections WHERE provider = ?",[a.provider]);p=(b?.m||0)+1}let q={id:(0,d.A)(),provider:a.provider,authType:a.authType||"oauth",name:o,priority:p,isActive:void 0===a.isActive||a.isActive,createdAt:f,updatedAt:f};for(let b of g)void 0!==a[b]&&null!==a[b]&&(q[b]=a[b]);a.providerSpecificData&&Object.keys(a.providerSpecificData).length>0&&(q.providerSpecificData=a.providerSpecificData),void 0!==a.email&&(q.email=a.email),j(c,q),b=q}),b}async function o(a,b){let c,d=await (0,e.c)();return d.transaction(()=>{let e=d.get("SELECT * FROM providerConnections WHERE id = ?",[a]);if(!e){c=null;return}let f=i(e),g=h(f,b),k={...f,...g,updatedAt:new Date().toISOString()};j(d,k),void 0!==b.priority&&m(d,f.provider),c=k}),c}async function p(a){let b=await (0,e.c)(),c=!1;return b.transaction(()=>{let d=b.get("SELECT provider FROM providerConnections WHERE id = ?",[a]);d&&(b.run("DELETE FROM providerConnections WHERE id = ?",[a]),m(b,d.provider),c=!0)}),c}async function q(a){let b=await (0,e.c)(),c=b.get("SELECT COUNT(*) AS n FROM providerConnections WHERE provider = ?",[a]);return b.run("DELETE FROM providerConnections WHERE provider = ?",[a]),c?.n||0}async function r(a){let b=await (0,e.c)();b.transaction(()=>m(b,a))}async function s(){let a=await (0,e.c)(),b=["displayName","email","globalPriority","defaultModel","accessToken","refreshToken","expiresAt","tokenType","scope","projectId","apiKey","testStatus","lastTested","lastError","lastErrorAt","rateLimitedUntil","expiresIn","consecutiveUseCount"],c=0;return a.transaction(()=>{for(let d of a.all("SELECT * FROM providerConnections")){let e=i(d),f=!1;for(let a of b)(null===e[a]||void 0===e[a])&&a in e&&(delete e[a],c++,f=!0);e.providerSpecificData&&0===Object.keys(e.providerSpecificData).length&&(delete e.providerSpecificData,c++,f=!0),f&&j(a,e)}}),c}},9460:(a,b,c)=>{c.d(b,{L9:()=>r,OM:()=>j,S8:()=>o,fv:()=>l,getMitmAlias:()=>q,o5:()=>k,uL:()=>p,uv:()=>n});var d=c(36366),e=c(644),f=c(22846);let g=(0,f.U)("modelAliases"),h=(0,f.U)("customModels"),i=(0,f.U)("mitmAlias");async function j(){return await g.getAll()}async function k(a,b){await g.set(a,b)}async function l(a){await g.remove(a)}function m(a,b,c){return`${a}|${b}|${c}`}async function n(){return Object.values(await h.getAll())}async function o({providerAlias:a,id:b,type:c="llm",name:f,caps:g,transport:h}){let i=m(a,b,c),j=await (0,d.c)(),k=!1;return j.transaction(()=>{let d=j.get("SELECT value FROM kv WHERE scope = 'customModels' AND key = ?",[i]);if(d){let a={...(0,e.q)(d.value)||{},...f?{name:f}:{},...g?{caps:g}:{},...h?{transport:h}:{}};j.run("UPDATE kv SET value = ? WHERE scope = 'customModels' AND key = ?",[(0,e.s)(a),i]);return}let l=(0,e.s)({providerAlias:a,id:b,type:c,name:f||b,...g?{caps:g}:{},...h?{transport:h}:{}});j.run("INSERT INTO kv(scope, key, value) VALUES('customModels', ?, ?)",[i,l]),k=!0}),k}async function p({providerAlias:a,id:b,type:c="llm"}){await h.remove(m(a,b,c))}async function q(a){return a?await i.get(a)||{}:await i.getAll()}async function r(a,b){await i.set(a,b||{})}},19804:(a,b,c)=>{c.d(b,{Du:()=>f,R4:()=>e,m8:()=>g,x4:()=>d});let d={TEXT:"text",IMAGE_URL:"image_url",IMAGE:"image",INPUT_AUDIO:"input_audio",AUDIO_URL:"audio_url",FILE:"file",FUNCTION:"function"},e={TEXT:"text",IMAGE:"image",DOCUMENT:"document",TOOL_USE:"tool_use",TOOL_RESULT:"tool_result",CONTAINER_UPLOAD:"container_upload",THINKING:"thinking",REDACTED_THINKING:"redacted_thinking",SERVER_TOOL_USE:"server_tool_use",WEB_SEARCH_TOOL_RESULT:"web_search_tool_result"},f={MESSAGE:"message",FUNCTION_CALL:"function_call",FUNCTION_CALL_OUTPUT:"function_call_output",CUSTOM_TOOL_CALL:"custom_tool_call",CUSTOM_TOOL_CALL_OUTPUT:"custom_tool_call_output",ADDITIONAL_TOOLS:"additional_tools",REASONING:"reasoning",OUTPUT_TEXT:"output_text",INPUT_TEXT:"input_text",INPUT_IMAGE:"input_image",SUMMARY_TEXT:"summary_text"},g=[d.TEXT,d.IMAGE_URL,d.IMAGE,d.INPUT_AUDIO,d.AUDIO_URL,d.FILE];d.TEXT,d.IMAGE_URL,d.IMAGE,e.TOOL_RESULT},22846:(a,b,c)=>{c.d(b,{U:()=>f});var d=c(36366),e=c(644);function f(a){return{async get(b,c=null){let f=(await (0,d.c)()).get("SELECT value FROM kv WHERE scope = ? AND key = ?",[a,b]);return f?(0,e.q)(f.value,c):c},async getAll(){let b=(await (0,d.c)()).all("SELECT key, value FROM kv WHERE scope = ?",[a]),c={};for(let a of b)c[a.key]=(0,e.q)(a.value);return c},async set(b,c){(await (0,d.c)()).run("INSERT INTO kv(scope, key, value) VALUES(?, ?, ?) ON CONFLICT(scope, key) DO UPDATE SET value = excluded.value",[a,b,(0,e.s)(c)])},async setMany(b){let c=await (0,d.c)();c.transaction(()=>{for(let[d,f]of Object.entries(b))c.run("INSERT INTO kv(scope, key, value) VALUES(?, ?, ?) ON CONFLICT(scope, key) DO UPDATE SET value = excluded.value",[a,d,(0,e.s)(f)])})},async remove(b){(await (0,d.c)()).run("DELETE FROM kv WHERE scope = ? AND key = ?",[a,b])},async clear(){(await (0,d.c)()).run("DELETE FROM kv WHERE scope = ?",[a])}}}},33077:(a,b,c)=>{c.d(b,{R:()=>e,z:()=>d});let d={USER:"user",ASSISTANT:"assistant",TOOL:"tool",SYSTEM:"system",DEVELOPER:"developer"},e={USER:"user",MODEL:"model"}},33666:(a,b,c)=>{c.d(b,{M7:()=>h,aB:()=>g,xE:()=>f});var d=c(38606);function e(a){if(!Array.isArray(a))return[];let b=new Set,c=[];for(let d of a){if("string"!=typeof d)continue;let a=d.trim();if(!a)continue;let e=a.toLowerCase();b.has(e)||(b.add(e),c.push(a))}return c}function f(a,b){if(1!==a&&!0!==a)return{restricted:!1,allow:[]};let c=[];if("string"==typeof b&&b)try{c=JSON.parse(b)}catch{c=[]}return{restricted:!0,allow:e(c)}}function g(a){let b=a||d.M0;return{accessRestricted:+!!b.restricted,accessAllow:JSON.stringify(b.restricted?e(b.allow):[])}}function h(a){if(!a||"object"!=typeof a||Array.isArray(a))return{ok:!1,error:"access must be an object { restricted, allow }"};let b=Object.keys(a).filter(a=>"restricted"!==a&&"allow"!==a);if(b.length)return{ok:!1,error:`access: unexpected field(s) ${b.join(", ")}`};if("boolean"!=typeof a.restricted)return{ok:!1,error:"access.restricted must be a boolean"};let c=void 0===a.allow?[]:a.allow;return!Array.isArray(c)||c.some(a=>"string"!=typeof a)?{ok:!1,error:"access.allow must be an array of strings"}:c.length>d.lO?{ok:!1,error:`access.allow has more than ${d.lO} entries`}:c.some(a=>a.trim().length>d.AM)?{ok:!1,error:`access.allow entries must be at most ${d.AM} characters`}:{ok:!0,value:{restricted:a.restricted,allow:e(c)}}}},36366:(a,b,c)=>{c.d(b,{c:()=>k});var d=c(95658);global._dbAdapter||(global._dbAdapter={instance:null,initPromise:null,logged:!1});let e=global._dbAdapter;async function f(){if(!process.versions.bun)return null;try{let{createBunSqliteAdapter:a}=await c.e(4739).then(c.bind(c,24739));return await a(d.AL)}catch(a){return console.warn(`[DB] bun:sqlite unavailable: ${a.message}`),null}}async function g(){if(process.versions.bun)return null;let[a]=process.versions.node.split(".").map(Number);if(a>=24)return null;try{let{createBetterSqliteAdapter:a}=await c.e(5258).then(c.bind(c,25258));return a(d.AL)}catch(a){return console.warn(`[DB] better-sqlite3 unavailable: ${a.message}`),null}}async function h(){if(process.versions.bun)return null;let[a,b]=process.versions.node.split(".").map(Number);if(a<22||22===a&&b<5)return null;try{let{createNodeSqliteAdapter:a}=await c.e(8520).then(c.bind(c,88520));return await a(d.AL)}catch(a){return console.warn(`[DB] node:sqlite unavailable: ${a.message}`),null}}async function i(){try{let{createSqlJsAdapter:a}=await c.e(3593).then(c.bind(c,53593));return await a(d.AL)}catch(a){return console.warn(`[DB] sql.js unavailable: ${a.message}`),null}}async function j(){(0,d.Jh)();let a=await f();if(a||(a=await g()),a||(a=await h()),a||(a=await i()),!a)throw Error("[DB] No SQLite driver available (bun/better/node/sql.js all failed)");e.logged||(console.log(`[DB] Driver: ${a.driver} | file: ${d.AL}`),e.logged=!0);let{runMigrationOnce:b}=await c.e(7954).then(c.bind(c,37954));return await b(a),a}async function k(){return e.instance?e.instance:(e.initPromise||(e.initPromise=j().then(a=>(e.instance=a,a))),e.initPromise)}},38606:(a,b,c)=>{c.d(b,{AM:()=>e,Cq:()=>i,M0:()=>f,WR:()=>h,YR:()=>g,lO:()=>d});let d=200,e=256,f=Object.freeze({restricted:!1,allow:Object.freeze([])}),g=Object.freeze(["webSearch","webFetch"]),h="combo";function i(a){return`This API key is not allowed to use model "${a}"`}},40615:(a,b,c)=>{c.d(b,{AI_PROVIDERS:()=>s,js:()=>w,DI:()=>n,fg:()=>k,Pd:()=>o,IS:()=>h,nJ:()=>i,zN:()=>j,JH:()=>m,jO:()=>y,wb:()=>x,br:()=>l,wG:()=>v,zt:()=>t,gb:()=>q,gC:()=>r,mq:()=>p,rs:()=>u});var d=c(4406);let e="⚠️ Risk Notice: This provider uses a subscription/OAuth session not officially licensed for proxy/router use. Account may be restricted or banned. Use at your own risk.";Object.fromEntries(d.default.filter(a=>a.display).map(a=>{let b;return[a.id,"RISK_NOTICE"===(b=a.display).deprecationNotice?{...b,deprecationNotice:e}:b]}));let f=["serviceKinds","ttsConfig","sttConfig","embeddingConfig","imageConfig","imageToTextConfig","videoConfig","musicConfig","searchViaChat","searchConfig","fetchConfig","credentialFallback","systemoneConfig","modelsFetcher","mediaPriority","hiddenKinds"],g=a=>Object.fromEntries(d.default.filter(b=>b.category===a).map(a=>[a.id,function(a){let b={};for(let c of(a.media&&Object.assign(b,a.media),f))void 0!==a[c]&&(b[c]=a[c]);let c={...a.display||{}};return"RISK_NOTICE"===c.deprecationNotice&&(c.deprecationNotice=e),{...c,id:a.id,alias:a.uiAlias||a.alias,...a.hidden?{hidden:!0}:{},...b,...void 0!==a.priority?{priority:a.priority}:{},...a.hasFree?{hasFree:!0}:{},...a.thinkingConfig?{thinkingConfig:a.thinkingConfig}:{},...a.regions?{regions:a.regions,defaultRegion:a.defaultRegion}:{},...a.hasProviderSpecificData?{hasProviderSpecificData:!0}:{},...a.noAuth?{noAuth:!0}:{},...a.passthroughModels?{passthroughModels:!0}:{},...a.hasOAuth?{hasOAuth:!0}:{},...a.authModes?{authModes:a.authModes}:{},...a.authType?{authType:a.authType}:{},...a.authHint?{authHint:a.authHint}:{},...a.apiKeyOptionalWith?{apiKeyOptionalWith:a.apiKeyOptionalWith}:{},...a.credentialForm?{credentialForm:a.credentialForm}:{}}}(a)])),h=g("free"),i=g("freeTier"),j=g("oauth"),k=g("apikey"),l=g("webCookie"),m="openai-compatible-",n="anthropic-compatible-",o="custom-embedding-";function p(a){return"string"==typeof a&&a.startsWith(m)}function q(a){return"string"==typeof a&&a.startsWith(n)}function r(a){return"string"==typeof a&&a.startsWith(o)}let s={...h,...i,...j,...k,...l};function t(a){for(let b of Object.values(s))if(b.alias===a||b.id===a)return b;return null}function u(a){let b=t(a);return b?.id||a}function v(a){let b=s[a];return b?.alias||a}let w=Object.values(s).reduce((a,b)=>(a[b.alias]=b.id,a),{});Object.values(s).reduce((a,b)=>(a[b.id]=b.alias,a),{});let x=d.default.filter(a=>a.features?.usage).map(a=>a.id),y=d.default.filter(a=>a.features?.usageApikey).map(a=>a.id)},42655:(a,b,c)=>{c.d(b,{Xx:()=>j,exportSettings:()=>k,getSettings:()=>i});var d=c(36366),e=c(644);let f={cloudEnabled:!1,tunnelEnabled:!1,tunnelUrl:"",tunnelProvider:"cloudflare",tailscaleEnabled:!1,tailscaleUrl:"",stickyRoundRobinLimit:3,providerStrategies:{},quotaVisibility:{},comboStrategy:"fallback",comboStickyRoundRobinLimit:1,comboStrategies:{},capacityAdapter:{vision:{enabled:!0,roundRobin:!1,models:[]},pdf:{enabled:!1,roundRobin:!1,models:[]},audioInput:{enabled:!0,roundRobin:!1,models:[]},videoInput:{enabled:!1,roundRobin:!1,models:[]}},requireLogin:!0,requireApiKey:!0,tunnelDashboardAccess:!0,authMode:"password",ssoType:"oidc",oidcIssuerUrl:"",oidcClientId:"",oidcClientSecret:"",oidcScopes:"openid profile email",oidcLoginLabel:"Sign in with OIDC",samlEntryPoint:"",samlIssuer:"urn:jrouter:sp",samlCert:"",samlLoginLabel:"Sign in with SAML SSO",samlAttributeEmail:"email",samlAttributeName:"name",enableObservability:!1,observabilityMaxRecords:1e3,observabilityBatchSize:20,observabilityFlushIntervalMs:5e3,observabilityMaxJsonSize:5,outboundProxyEnabled:!1,outboundProxyUrl:"",outboundNoProxy:"",mitmRouterBaseUrl:"http://localhost:20128",dnsToolEnabled:{},rtkEnabled:!0,headroomEnabled:!1,headroomUrl:process.env.HEADROOM_URL||"http://localhost:8787",headroomCompressUserMessages:!1,headroomTimeoutMs:3e3,cavemanEnabled:!1,cavemanLevel:"full",ponytailEnabled:!1,ponytailLevel:"full",pxpipeEnabled:!1,pxpipeAutoInstall:!0,pxpipeMinChars:25e3,pxpipeTimeoutMs:15e3,providerOverrides:{}};async function g(){let a=(await (0,d.c)()).get("SELECT data FROM settings WHERE id = 1");return a?(0,e.q)(a.data,{}):{}}function h(a){let b={...f,...a||{}};for(let[a,c]of Object.entries(f))void 0===b[a]&&("outboundProxyEnabled"===a&&"string"==typeof b.outboundProxyUrl&&b.outboundProxyUrl.trim()?b[a]=!0:b[a]=c);if(b.capacityAdapter&&"object"==typeof b.capacityAdapter)for(let a of Object.keys(b.capacityAdapter)){let c=b.capacityAdapter[a];Array.isArray(c?.models)&&(c.models=c.models.map(a=>"oc/mimo-v2.5-free"===a?"oc/mimo-v2.6-flash-free":a))}return b}async function i(){return h(await g())}async function j(a){let b,c=await (0,d.c)();return c.transaction(function(){let d=c.get("SELECT data FROM settings WHERE id = 1");b={...d?(0,e.q)(d.data,{}):{},...a},c.run("INSERT INTO settings(id, data) VALUES(1, ?) ON CONFLICT(id) DO UPDATE SET data = excluded.data",[(0,e.s)(b)])}),h(b)}async function k(){return await g()}},43438:(a,b,c)=>{c.d(b,{NE:()=>i,ZP:()=>h,lx:()=>k,yl:()=>j});var d=c(16698),e=c(79494),f=c(40615);let g=Symbol.for("jrouter.apiKeyPolicyContext");globalThis[g]||(globalThis[g]=new d.AsyncLocalStorage);let h=globalThis[g],i=()=>h.getStore();function j(a,b={}){let c=[a,b.model];return b.provider&&c.push(`${b.provider}/${b.model}`,`${(0,f.wG)(b.provider)}/${b.model}`),c}function k(a,b={}){let c=i();if(c){try{(0,e.ox)(c.policy,[...j(a,b),...c.isCombo?[c.requestedModel]:[]]),c.modelPolicyError=null}catch(a){throw c.modelPolicyError=a,a}c.resolvedModel=b}}},43659:(a,b,c)=>{c.d(b,{A1:()=>h,lR:()=>j,wO:()=>i,xJ:()=>e,yj:()=>f,zL:()=>g});var d=c(3662);function e(a,b){let c=d.LY[a]||(a>=500?{type:"server_error",code:"internal_server_error"}:{type:"invalid_request_error",code:""});return{error:{message:b||d.O[a]||"An error occurred",type:c.type,code:c.code}}}function f(a,b,c=null){return new Response(JSON.stringify(e(a,b)),{status:a,headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*",...c}})}async function g(a,b=null){let c="";try{c=await a.text()}catch{c=""}if(b&&"function"==typeof b.parseError)try{let e=b.parseError(a,c);if(e&&"object"==typeof e){let b=e.message||d.O[a.status]||`Upstream error: ${a.status}`;return{statusCode:e.status||a.status,message:b,resetsAtMs:e.resetsAtMs}}}catch{}let e="";try{let a=JSON.parse(c);e=a.error?.message||a.message||a.error||c}catch{e=c}let f=("string"==typeof e?e:JSON.stringify(e))||d.O[a.status]||`Upstream error: ${a.status}`;return{statusCode:a.status,message:f}}function h(a,b,c,d=null){return{success:!1,status:a,error:b,resetsAtMs:c,response:f(a,b,d)}}function i(a,b,c,d,e=null){let f=Math.max(Math.ceil((new Date(c).getTime()-Date.now())/1e3),1);return new Response(JSON.stringify({error:{message:`${b} (${d})`}}),{status:a,headers:{...e,"Content-Type":"application/json","retry-after":String(f)}})}function j(a,b,c,d){let e=d||a.code||"FETCH_FAILED",f=a.message||"Unknown error",g=a.cause?.code,h=a.cause?.message,i=g||h?` (cause: ${[g,h].filter(Boolean).join(": ")})`:"";return`[${e}]: ${f}${i}`}},50830:(a,b,c)=>{c.d(b,{YK:()=>n,bX:()=>i,is:()=>j});var d=c(33077),e=c(19804),f=c(14170);let g=["prepend","append","replace"],h={promptInjectionEnabled:!1,promptInjectionMode:"prepend",systemPrompt:null,displayIdentity:null};function i(a={}){return{promptInjectionEnabled:!0===a.promptInjectionEnabled||1===a.promptInjectionEnabled,promptInjectionMode:g.includes(a.promptInjectionMode)?a.promptInjectionMode:h.promptInjectionMode,systemPrompt:"string"==typeof a.systemPrompt?a.systemPrompt:null,displayIdentity:"string"==typeof a.displayIdentity?a.displayIdentity:null}}function j(a){if(!a||"object"!=typeof a||Array.isArray(a))throw Error("Invalid combo settings");let b={};for(let c of Object.keys(h)){if(!Object.hasOwn(a,c))continue;let d=a[c];if("promptInjectionEnabled"===c&&"boolean"!=typeof d)throw Error("Prompt injection enabled must be a boolean");if("promptInjectionMode"===c&&!g.includes(d))throw Error("Injection strategy must be prepend, append or replace");if(("systemPrompt"===c||"displayIdentity"===c)&&null!==d&&"string"!=typeof d)throw Error(`${c} must be a string or null`);b[c]=d}return b}let k=a=>a?.role===d.z.SYSTEM||a?.role===d.z.DEVELOPER;function l(a,b,c){if("replace"===c)return[b,...a.filter(a=>!k(a))];if("prepend"===c)return[b,...a];let d=a.findLastIndex(k);return[...a.slice(0,d+1),b,...a.slice(d+1)]}function m(a,b,c){return"replace"===c?[b]:"append"===c?[...a,b]:[b,...a]}function n(a,b,{requestedModel:c,sourceFormat:g}={}){if(!b)return a;let h=i(b);if(!h.promptInjectionEnabled)return a;let j=function(a,b=a.name){let c={combo_name:a.name||"",display_name:a.displayIdentity?.trim()||a.name||"",requested_model:"string"==typeof b?b:""};return("string"==typeof a.systemPrompt?a.systemPrompt:"").replace(/\{\{\s*([a-z_]+)\s*\}\}/g,(a,b)=>Object.hasOwn(c,b)?c[b]:a)}({...b,...h},c??a.model);if(!j.trim())return a;let o=h.promptInjectionMode;if(Array.isArray(a.contents)||a.systemInstruction){let b=Array.isArray(a.systemInstruction?.parts)?a.systemInstruction.parts:[];return{...a,systemInstruction:{...a.systemInstruction,role:d.R.USER,parts:m(b,{text:j},o)}}}if(g===f.h.CLAUDE||Object.hasOwn(a,"system")){let b=Array.isArray(a.system)?a.system:"string"==typeof a.system&&a.system?[{type:e.R4.TEXT,text:a.system}]:[];return{...a,system:m(b,{type:e.R4.TEXT,text:j},o),...Array.isArray(a.messages)&&"replace"===o?{messages:a.messages.filter(a=>!k(a))}:{}}}if(Object.hasOwn(a,"input")||g===f.h.OPENAI_RESPONSES){let b=Array.isArray(a.input)?a.input:"string"==typeof a.input?[{role:d.z.USER,content:a.input}]:[],c="string"==typeof a.instructions&&a.instructions?[{role:d.z.SYSTEM,content:a.instructions},...b]:b,{instructions:e,...f}=a;return{...f,input:l(c,{role:d.z.SYSTEM,content:j},o)}}return Array.isArray(a.messages)?{...a,messages:l(a.messages,{role:d.z.SYSTEM,content:j},o)}:a}},57056:(a,b,c)=>{c.d(b,{$4:()=>f,Fw:()=>e,b5:()=>g});var d=c(2818);function e(a={}){return{...d.nX,...a}}function f(a){if(!a||"object"!=typeof a||Array.isArray(a))throw Error("Settings must be an object.");let b=new Set([...Object.keys(d.nX),"name","isActive"]),c={};for(let[e,f]of Object.entries(a)){if(!b.has(e))throw Error(`Unknown setting: ${e}`);if(["name","description"].includes(e)){if("string"!=typeof f||f.length>("name"===e?120:500)||"name"===e&&!f.trim())throw Error(`Invalid ${e}.`);c[e]=f.trim()}else if("isActive"===e){if("boolean"!=typeof f)throw Error("isActive must be a boolean.");c[e]=f}else if("quotaResetCycle"===e){if(!d.ZX.includes(f))throw Error("Invalid quota reset cycle.");c[e]=f}else if("expiresAt"===e){if(null!==f&&!function(a){if("string"!=typeof a)return!1;let b=a.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d{1,3})?(?:Z|[+-](\d{2}):(\d{2}))$/);return!!b&&!!Number.isFinite(Date.parse(a))&&new Date(`${b[1]}T00:00:00Z`).toISOString().slice(0,10)===b[1]&&24>Number(b[2])&&60>Number(b[3])&&60>Number(b[4])&&24>Number(b[5]||0)&&60>Number(b[6]||0)}(f))throw Error("Invalid expiration date. Use an ISO datetime with a timezone.");c[e]=null===f?null:new Date(f).toISOString()}else if(["allowedModels","blockedModels","allowedEndpoints"].includes(e)){if(null===f&&"allowedEndpoints"===e){c[e]=null;continue}if(!Array.isArray(f)||f.length>200||f.some(a=>"string"!=typeof a||!a.trim()||a.length>256||/[\s\x00-\x1f]|:\/\//.test(a)))throw Error(`Invalid ${e}.`);if("allowedEndpoints"===e&&f.some(a=>!d.WF.some(b=>b.value===a)))throw Error("Invalid endpoint permission.");c[e]=[...new Set(f)]}else{if(null===f&&"tokenMultiplier"!==e){c[e]=null;continue}let a=!["maxCostUsd","tokenMultiplier"].includes(e),b=5e-324*!["maxTokensQuota","maxCostUsd"].includes(e);if("number"!=typeof f||!Number.isFinite(f)||f<b||f>Number.MAX_SAFE_INTEGER||a&&!Number.isSafeInteger(f))throw Error(`Invalid ${e}. Enter ${a?"an integer":"a number"} ${0===b?"at least zero":"greater than zero"}, or leave empty for unlimited.`);c[e]=f}}return c}function g(a){if(!a)return null;let{key:b,machineId:c,...d}=a,e=b?b.length<=12?"••••••":`${b.slice(0,6)}••••••${b.slice(-4)}`:"";return{...d,isExpired:!!(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()),keyPrefix:e}}},62674:(a,b,c)=>{function d(a,b,c=null){let e=a.get("SELECT value FROM _meta WHERE key = ?",[b]);return e?e.value:c}function e(a,b,c){a.run("INSERT INTO _meta(key, value) VALUES(?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",[b,String(c)])}c.d(b,{dy:()=>d,np:()=>e}),c(36366)},66972:(a,b,c)=>{c.d(b,{Cu:()=>l,QE:()=>k,ft:()=>j});var d=c(77598),e=c(644),f=c(57056),g=c(79494),h=c(2818);function i(a,b,c,d){let e=(0,g.ck)(c.quotaResetCycle,new Date(d));return e!==b.quotaPeriodStartedAt&&(a.run("UPDATE apiKeys SET quotaPeriodStartedAt = ?, quotaTokens = ?, quotaCost = ? WHERE id = ?",[e,null===e?b.quotaTokens:0,null===e?b.quotaCost:0,b.id]),b.quotaPeriodStartedAt=e,null!==e&&(b.quotaTokens=0,b.quotaCost=0)),e}function j(a,b,c,m=Date.now()){a.exec("BEGIN IMMEDIATE");try{let j=a.get("SELECT * FROM apiKeys WHERE id = ?",[b]);if(!j||!j.isActive)throw new g.wY(401,"invalid_api_key","API key is invalid or inactive.");let p=(0,f.Fw)((0,e.q)(j.policy,{}));if(p.expiresAt&&Date.parse(p.expiresAt)<=m)throw new g.wY(401,"api_key_expired","API key has expired.");let q=i(a,j,p,m);for(let c of a.all("SELECT * FROM apiKeyRequests WHERE apiKeyId = ? AND isPending = 1 AND expiresAt <= ?",[b,m])){let b=Math.max(0,c.estimatedTokens-c.actualTokens),d=Math.max(0,c.estimatedCost-c.actualCost);k(a,c,b,d,m),l(a,c)}let r=a.get("SELECT * FROM apiKeys WHERE id = ?",[b]),s=a.get(`SELECT COALESCE(SUM(MAX(0, estimatedTokens - actualTokens) * multiplier),0) AS tokens,
10
- COALESCE(SUM(MAX(0, estimatedCost - actualCost) * multiplier),0) AS cost FROM apiKeyRequests
11
- WHERE apiKeyId = ? AND isPending = 1`,[b]);var n=s.tokens+c.tokens*p.tokenMultiplier,o=s.cost+c.cost*p.tokenMultiplier;if(null!=p.maxTokensQuota&&(r.quotaTokens>=p.maxTokensQuota||r.quotaTokens+n>p.maxTokensQuota))throw new g.wY(429,"quota_exceeded","API key token quota exceeded.");if(null!=p.maxCostUsd&&(r.quotaCost>=p.maxCostUsd||r.quotaCost+o>p.maxCostUsd))throw new g.wY(429,"cost_quota_exceeded","API key cost quota exceeded.");let t=a.get(`SELECT COUNT(*) AS requests, MIN(startedAt) AS oldest,
12
- COALESCE(SUM(CASE WHEN isPending = 1 THEN MAX(estimatedTokens,actualTokens) ELSE actualTokens END),0) AS tokens
13
- FROM apiKeyRequests WHERE apiKeyId = ? AND startedAt > ?`,[b,m-h.sh]),u=a.get(`SELECT COALESCE(SUM(CASE WHEN isPending = 1 THEN MAX(estimatedTokens,actualTokens) ELSE actualTokens END),0) AS tokens
14
- FROM apiKeyRequests WHERE apiKeyId = ? AND (isPending = 1 OR usageRecordedAt > ?)`,[b,m-h.sh]),v=Math.max(1,Math.ceil((t.oldest+h.sh-m)/1e3));if(null!=p.rateLimitRpm&&t.requests>=p.rateLimitRpm)throw new g.wY(429,"rate_limit_exceeded","API key requests per minute limit exceeded.",v);if(null!=p.rateLimitTpm&&u.tokens+c.tokens>p.rateLimitTpm)throw new g.wY(429,"token_rate_limit_exceeded","API key tokens per minute limit exceeded.",Number.isFinite(v)?v:60);a.run("DELETE FROM apiKeyRequests WHERE apiKeyId = ? AND isPending = 0 AND startedAt <= ? AND usageRecordedAt <= ?",[b,m-h.sh,m-h.sh]);let w={id:(0,d.randomUUID)(),apiKeyId:b,multiplier:p.tokenMultiplier,quotaPeriodStartedAt:q};return a.run(`INSERT INTO apiKeyRequests(id,apiKeyId,startedAt,expiresAt,quotaPeriodStartedAt,estimatedTokens,estimatedCost,multiplier)
15
- VALUES(?,?,?,?,?,?,?,?)`,[w.id,b,m,m+h.yR,q,c.tokens,c.cost,w.multiplier]),a.run("UPDATE apiKeys SET lastUsedAt = ? WHERE id = ?",[new Date(m).toISOString(),b]),a.exec("COMMIT"),w}catch(b){throw a.exec("ROLLBACK"),b}}function k(a,b,c,d,g=Date.now()){let h=a.get("SELECT * FROM apiKeys WHERE id = ?",[b.apiKeyId]);if(!h)return;i(a,h,(0,f.Fw)((0,e.q)(h.policy,{})),g);let j=Math.max(0,Number(c)||0),l=Math.max(0,Number(d)||0);a.run("UPDATE apiKeys SET quotaTokens = quotaTokens + ?, quotaCost = quotaCost + ? WHERE id = ?",[j*b.multiplier,l*b.multiplier,b.apiKeyId]),a.run("UPDATE apiKeyRequests SET actualTokens = actualTokens + ?, actualCost = actualCost + ?, usageRecordedAt = ? WHERE id = ?",[j,l,g,b.id])}function l(a,b){a.run("UPDATE apiKeyRequests SET isPending = 0 WHERE id = ?",[b.id])}},74452:(a,b,c)=>{c.r(b),c.d(b,{createApiKey:()=>n,deleteApiKey:()=>q,getApiKeyById:()=>l,getApiKeyByKey:()=>m,getApiKeyBySecret:()=>p,getApiKeys:()=>k,rowToKey:()=>j,updateApiKey:()=>o,validateApiKey:()=>r});var d=c(94755),e=c(36366),f=c(644),g=c(57056),h=c(33666),i=c(38606);function j(a){return a?{...(0,g.Fw)((0,f.q)(a.policy,{})),id:a.id,key:a.key,name:a.name,machineId:a.machineId,isActive:1===a.isActive||!0===a.isActive,createdAt:a.createdAt,updatedAt:a.updatedAt||a.createdAt,lastUsedAt:a.lastUsedAt||null,quotaPeriodStartedAt:a.quotaPeriodStartedAt||null,quotaTokens:a.quotaTokens||0,quotaCost:a.quotaCost||0,access:(0,h.xE)(a.accessRestricted,a.accessAllow)}:null}async function k(){return(await (0,e.c)()).all("SELECT * FROM apiKeys ORDER BY createdAt ASC").map(j)}async function l(a){return j((await (0,e.c)()).get("SELECT * FROM apiKeys WHERE id = ?",[a]))}async function m(a){return a?j((await (0,e.c)()).get("SELECT * FROM apiKeys WHERE key = ?",[a])):null}async function n(a,b){if(!b)throw Error("machineId is required");let f=await (0,e.c)(),{generateApiKeyWithMachine:g}=await c.e(6844).then(c.bind(c,86844)),j=g(b),k={id:(0,d.A)(),name:a,key:j.key,machineId:b,isActive:!0,createdAt:new Date().toISOString(),access:{restricted:!1,allow:[]}},l=(0,h.aB)(i.M0);return f.run("INSERT INTO apiKeys(id, key, name, machineId, isActive, createdAt, accessRestricted, accessAllow) VALUES(?, ?, ?, ?, ?, ?, ?, ?)",[k.id,k.key,k.name,k.machineId,1,k.createdAt,l.accessRestricted,l.accessAllow]),k}async function o(a,b){let c;(!b||"object"!=typeof b||Array.isArray(b))&&(0,g.$4)(b);let{access:d,...i}=b,k=(0,g.$4)(i);if(void 0!==d){let a=(0,h.M7)(d);if(!a.ok)throw Error(a.error);c=a.value}let l=await (0,e.c)(),m=null;return l.transaction(()=>{let b=l.get("SELECT * FROM apiKeys WHERE id = ?",[a]);if(!b)return;let{name:d,isActive:e,...g}=k,i={...(0,f.q)(b.policy,{}),...g},n=new Date().toISOString(),o=(0,h.aB)(c??j(b).access);l.run("UPDATE apiKeys SET name = ?, isActive = ?, policy = ?, updatedAt = ?, accessRestricted = ?, accessAllow = ? WHERE id = ?",[d??b.name,void 0===e?b.isActive:+!!e,(0,f.s)(i),n,o.accessRestricted,o.accessAllow,a]),m=j(l.get("SELECT * FROM apiKeys WHERE id = ?",[a]))}),m}async function p(a){return j((await (0,e.c)()).get("SELECT * FROM apiKeys WHERE key = ?",[a]))}async function q(a){let b=(await (0,e.c)()).run("DELETE FROM apiKeys WHERE id = ?",[a]);return(b?.changes??0)>0}async function r(a){let b=(await (0,e.c)()).get("SELECT isActive FROM apiKeys WHERE key = ?",[a]);return!!b&&(1===b.isActive||!0===b.isActive)}},79494:(a,b,c)=>{c.d(b,{ck:()=>f,ox:()=>h,pB:()=>i,wY:()=>e});var d=c(43659);class e extends Error{constructor(a,b,c,d=null){super(c),this.status=a,this.code=b,this.retryAfter=d}response(){let a=(0,d.xJ)(this.status,this.message);return a.error.code=this.code,Response.json(a,{status:this.status,headers:{"Access-Control-Allow-Origin":"*",...this.retryAfter?{"Retry-After":String(this.retryAfter)}:{}}})}}function f(a,b=new Date){if("lifetime"===a)return null;let c=new Date(b);return c.setUTCMinutes(0,0,0),"hourly"!==a&&c.setUTCHours(0),"weekly"===a&&c.setUTCDate(c.getUTCDate()-(c.getUTCDay()+6)%7),"monthly"===a&&c.setUTCDate(1),c.toISOString()}function g(a,b){let c=a.split("*").map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return RegExp(`^${c}$`).test(b)}function h(a,b){let c=b.filter(a=>"string"==typeof a&&a.length);if(a.blockedModels?.some(a=>c.some(b=>g(a,b)))||a.allowedModels?.length&&!a.allowedModels.some(a=>c.some(b=>g(a,b))))throw new e(403,"model_not_allowed","This model is not allowed for this API key.")}function i(a,b){if(null==b)return a;let c=[a.max_tokens,a.max_completion_tokens,a.max_output_tokens,a.generationConfig?.maxOutputTokens,a.options?.num_predict];if(c.some(a=>null!=a&&("number"!=typeof a||!Number.isSafeInteger(a)||a<0||a>b)))throw new e(400,"max_output_tokens_exceeded",`Maximum output tokens for this API key is ${b}.`);let d={...a};return a.generationConfig?d.generationConfig={...a.generationConfig,maxOutputTokens:a.generationConfig.maxOutputTokens??b}:a.options?d.options={...a.options,num_predict:a.options.num_predict??b}:c.slice(0,3).every(a=>null==a)&&(Object.hasOwn(a,"input")?d.max_output_tokens=b:d.max_tokens=b),d}},82455:(a,b,c)=>{c.d(b,{Os:()=>f,cC:()=>g});var d=c(644);let e=/^(?:openai-compatible-chat|anthropic-compatible|custom-embedding)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function f(a){let b=new Set(a.all("SELECT id FROM providerNodes").map(a=>a.id)),c=[...new Set(a.all("SELECT key, value FROM kv WHERE scope = 'customModels'").map(a=>((0,d.q)(a.value,{})||{}).providerAlias||a.key.split("|")[0]).filter(a=>e.test(a)&&!b.has(a)))],f=0;for(let b of c){let c=a.run("DELETE FROM kv WHERE scope = 'customModels' AND key LIKE ?",[`${b}|%`]);f+=c?.changes??0}return f}function g(a,b,c){let d=0;for(let e of[b,c].filter(Boolean))d+=a.all("SELECT COUNT(*) AS n FROM kv WHERE scope = 'customModels' AND key LIKE ?",[`${e}|%`])[0]?.n??0,a.run("DELETE FROM kv WHERE scope = 'customModels' AND key LIKE ?",[`${e}|%`]);return d}},83192:(a,b,c)=>{c.d(b,{S8:()=>w.S8,E5:()=>Z,bI:()=>l.cleanupProviderConnections,Iq:()=>v.createApiKey,jd:()=>f.jd,iE:()=>l.createProviderConnection,i0:()=>m.createProviderNode,ZO:()=>s,Lh:()=>v.deleteApiKey,CG:()=>f.CG,uL:()=>w.uL,fv:()=>w.fv,fK:()=>l.deleteProviderConnection,op:()=>l.deleteProviderConnectionsByProvider,Pc:()=>m.deleteProviderNode,Yd:()=>u,tm:()=>A,oF:()=>B,zP:()=>al,rg:()=>T,yg:()=>v.getApiKeyById,PX:()=>v.getApiKeys,j$:()=>Y,L:()=>f.L,Dj:()=>f.Dj,Uv:()=>f.Uv,getCustomModels:()=>w.uv,vF:()=>z,Lk:()=>aj,c:()=>w.getMitmAlias,OM:()=>w.OM,r4:()=>x.r4,Mc:()=>l.getProviderConnectionById,P:()=>l.getProviderConnections,Qu:()=>m.getProviderNodeById,getProviderNodes:()=>m.getProviderNodes,hr:()=>r,ui:()=>q,Zx:()=>$,SL:()=>ai,mt:()=>k.getSettings,BY:()=>X,K1:()=>am,VT:()=>x.VT,yF:()=>x.yF,ox:()=>ah,sZ:()=>U,L9:()=>w.L9,o5:()=>w.o5,_V:()=>M,uw:()=>S,XW:()=>v.updateApiKey,oG:()=>f.oG,KJ:()=>x.KJ,rj:()=>l.updateProviderConnection,ho:()=>m.updateProviderNode,Q_:()=>t,Xx:()=>k.Xx,ek:()=>v.validateApiKey});var d=c(36366),e=c(644),f=c(1541),g=c(50830),h=c(33666),i=c(38606),j=c(82455),k=c(42655),l=c(5781),m=c(1129),n=c(94755);function o(a){return a?{...(0,e.q)(a.data,{}),id:a.id,isActive:1===a.isActive||!0===a.isActive,testStatus:a.testStatus,createdAt:a.createdAt,updatedAt:a.updatedAt}:null}function p(a,b){let c=function(a){let{id:b,isActive:c,testStatus:d,createdAt:f,updatedAt:g,...h}=a;return{id:b,isActive:+(!1!==c),testStatus:d??null,data:(0,e.s)(h),createdAt:f,updatedAt:g}}(b);a.run(`INSERT INTO proxyPools(id, isActive, testStatus, data, createdAt, updatedAt)
16
- VALUES(?, ?, ?, ?, ?, ?)
17
- ON CONFLICT(id) DO UPDATE SET
18
- isActive=excluded.isActive, testStatus=excluded.testStatus,
19
- data=excluded.data, updatedAt=excluded.updatedAt`,[c.id,c.isActive,c.testStatus,c.data,c.createdAt,c.updatedAt])}async function q(a={}){let b=await (0,d.c)(),c=[],e=[];void 0!==a.isActive&&(c.push("isActive = ?"),e.push(+!!a.isActive)),a.testStatus&&(c.push("testStatus = ?"),e.push(a.testStatus));let f=`SELECT * FROM proxyPools${c.length?` WHERE ${c.join(" AND ")}`:""}`,g=b.all(f,e).map(o);return g.sort((a,b)=>new Date(b.updatedAt||0)-new Date(a.updatedAt||0)),g}async function r(a){return o((await (0,d.c)()).get("SELECT * FROM proxyPools WHERE id = ?",[a]))}async function s(a){let b=await (0,d.c)(),c=new Date().toISOString(),e={id:a.id||(0,n.A)(),name:a.name,proxyUrl:a.proxyUrl,noProxy:a.noProxy||"",type:a.type||"http",isActive:void 0===a.isActive||a.isActive,strictProxy:!0===a.strictProxy,testStatus:a.testStatus||"unknown",lastTestedAt:a.lastTestedAt||null,lastError:a.lastError||null,createdAt:c,updatedAt:c};return p(b,e),e}async function t(a,b){let c=await (0,d.c)(),e=null;return c.transaction(()=>{let d=c.get("SELECT * FROM proxyPools WHERE id = ?",[a]);if(!d)return;let f={...o(d),...b,updatedAt:new Date().toISOString()};p(c,f),e=f}),e}async function u(a){let b=await (0,d.c)(),c=null;return b.transaction(()=>{let d=b.get("SELECT * FROM proxyPools WHERE id = ?",[a]);d&&(c=o(d),b.run("DELETE FROM proxyPools WHERE id = ?",[a]))}),c}var v=c(74452),w=c(9460),x=c(97914);let y="disabledModels";async function z(){let a=(await (0,d.c)()).all("SELECT key, value FROM kv WHERE scope = ?",[y]),b={};for(let c of a)b[c.key]=(0,e.q)(c.value,[]);return b}async function A(a,b){if(!a||!Array.isArray(b))return;let c=await (0,d.c)();c.transaction(()=>{let d=c.get("SELECT value FROM kv WHERE scope = ? AND key = ?",[y,a]),f=[...new Set([...d&&(0,e.q)(d.value,[])||[],...b])];c.run("INSERT INTO kv(scope, key, value) VALUES(?, ?, ?) ON CONFLICT(scope, key) DO UPDATE SET value = excluded.value",[y,a,(0,e.s)(f)])})}async function B(a,b){if(!a)return;let c=await (0,d.c)();c.transaction(()=>{if(!Array.isArray(b)||0===b.length)return void c.run("DELETE FROM kv WHERE scope = ? AND key = ?",[y,a]);let d=c.get("SELECT value FROM kv WHERE scope = ? AND key = ?",[y,a]),f=d&&(0,e.q)(d.value,[])||[],g=new Set(b),h=f.filter(a=>!g.has(a));0===h.length?c.run("DELETE FROM kv WHERE scope = ? AND key = ?",[y,a]):c.run("INSERT INTO kv(scope, key, value) VALUES(?, ?, ?) ON CONFLICT(scope, key) DO UPDATE SET value = excluded.value",[y,a,(0,e.s)(h)])})}var C=c(94735);c(62674);var D=c(43438),E=c(66972);function F(a){if(!a||"string"!=typeof a)return null;let b=a.trim();return b.length<=12?b.charAt(0)+"***":b.slice(0,8)+"***"+b.slice(-4)}global._pendingRequests||(global._pendingRequests={byModel:{},byAccount:{}}),global._lastErrorProvider||(global._lastErrorProvider={provider:"",ts:0}),global._statsEmitter||(global._statsEmitter=new C.EventEmitter,global._statsEmitter.setMaxListeners(50)),global._pendingTimers||(global._pendingTimers={}),global._recentRing||(global._recentRing={items:[],initialized:!1}),global._connectionMapCache||(global._connectionMapCache={map:{},ts:0}),global._statsEmitTimers||(global._statsEmitTimers={pending:null,update:null});let G=global._pendingRequests,H=global._lastErrorProvider,I=global._pendingTimers,J=global._recentRing,K=global._connectionMapCache,L=global._statsEmitTimers,M=global._statsEmitter;function N(a,b=150){let c="update"===a?"update":"pending";L[c]||(L[c]=setTimeout(()=>{L[c]=null,M.emit(a)},b),L[c]?.unref?.())}function O(a,b,c){a[b]||(a[b]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0}),a[b].requests+=c.requests||1,a[b].promptTokens+=c.promptTokens||0,a[b].completionTokens+=c.completionTokens||0,a[b].cachedTokens+=c.cachedTokens||0,a[b].cost+=c.cost||0,c.meta&&Object.assign(a[b],c.meta)}async function P(){if(Date.now()-K.ts<3e4)return K.map;try{let{getProviderConnections:a}=await Promise.resolve().then(c.bind(c,5781)),b=await a(),d={};for(let a of b)d[a.id]=a.name||a.email||a.id;K.map=d,K.ts=Date.now()}catch{}return K.map}async function Q(){if(!J.initialized){J.initialized=!0;try{J.items=(await (0,d.c)()).all("SELECT timestamp, provider, model, connectionId, apiKey, endpoint, cost, status, tokens FROM usageHistory ORDER BY id DESC LIMIT ?",[50]).reverse().map(a=>({timestamp:a.timestamp,provider:a.provider,model:a.model,connectionId:a.connectionId,apiKey:a.apiKey,endpoint:a.endpoint,cost:a.cost,status:a.status,tokens:(0,e.q)(a.tokens,{})}))}catch{}}}async function R(a,b,d){if(!d||!a||!b)return 0;try{let{getPricingForModel:e}=await Promise.resolve().then(c.bind(c,97914)),f=await e(a,b);if(!f)return 0;let{calculateCostFromTokens:g}=await c.e(8920).then(c.bind(c,58920));return g(d,f)}catch(a){return console.error("Error calculating cost:",a),0}}function S(a,b,c,d,e=!1){let f=b?`${a} (${b})`:a,g=`${c}|${f}`;G.byModel[f]||(G.byModel[f]=0),G.byModel[f]=Math.max(0,G.byModel[f]+(d?1:-1)),0===G.byModel[f]&&delete G.byModel[f],c&&(G.byAccount[c]||(G.byAccount[c]={}),G.byAccount[c][f]||(G.byAccount[c][f]=0),G.byAccount[c][f]=Math.max(0,G.byAccount[c][f]+(d?1:-1)),0===G.byAccount[c][f]&&(delete G.byAccount[c][f],0===Object.keys(G.byAccount[c]).length&&delete G.byAccount[c])),d?(clearTimeout(I[g]),I[g]=setTimeout(()=>{delete I[g],G.byModel[f]>0&&(G.byModel[f]=0),c&&G.byAccount[c]?.[f]>0&&(G.byAccount[c][f]=0),N("pending")},6e4)):(clearTimeout(I[g]),delete I[g]),!d&&e&&b&&(H.provider=b.toLowerCase(),H.ts=Date.now()),N("pending")}async function T(){let a=[],b=await P();for(let[c,d]of Object.entries(G.byAccount))for(let[e,f]of Object.entries(d))if(f>0){let d=b[c]||`Account ${c.slice(0,8)}...`,g=e.match(/^(.*) \((.*)\)$/);a.push({model:g?g[1]:e,provider:g?g[2]:"unknown",account:d,count:f})}await Q();let c=new Set;return{activeRequests:a,recentRequests:[...J.items].sort((a,b)=>new Date(b.timestamp)-new Date(a.timestamp)).map(a=>{let b=a.tokens||{};return{timestamp:a.timestamp,model:a.model,provider:a.provider||"",promptTokens:b.prompt_tokens||b.input_tokens||0,completionTokens:b.completion_tokens||b.output_tokens||0,status:a.status||"ok"}}).filter(a=>{if(0===a.promptTokens&&0===a.completionTokens)return!1;let b=a.timestamp?a.timestamp.slice(0,16):"",d=`${a.model}|${a.provider}|${a.promptTokens}|${a.completionTokens}|${b}`;return!c.has(d)&&(c.add(d),!0)}).slice(0,20),errorProvider:Date.now()-H.ts<1e4?H.provider:""}}function U(a){let b=(0,D.NE)(),c=V({...a,...b?{apiKey:b.apiKeyId}:{}},b);return b&&(b.pending.add(c),c.then(()=>b.pending.delete(c),()=>b.pending.delete(c))),c}async function V(a,b){try{let c=await (0,d.c)();a.timestamp||(a.timestamp=new Date().toISOString()),a.cost=await R(a.provider,a.model,a.tokens);let f=a.tokens||{},g=f.prompt_tokens||f.input_tokens||0,h=f.completion_tokens||f.output_tokens||0,i=!1;(c.transaction(()=>{var d;let j,k,l,m,n,o,p,q,r,s,t,u,v=c.get(`SELECT id, endpoint FROM usageHistory
20
- WHERE timestamp = ?
21
- AND COALESCE(provider, '') = COALESCE(?, '')
22
- AND COALESCE(model, '') = COALESCE(?, '')
23
- AND COALESCE(connectionId, '') = COALESCE(?, '')
24
- AND COALESCE(apiKey, '') = COALESCE(?, '')
25
- AND promptTokens = ?
26
- AND completionTokens = ?
27
- ORDER BY id DESC LIMIT 1`,[a.timestamp,a.provider||null,a.model||null,a.connectionId||null,a.apiKey||null,g,h]);if(v){b&&!b.accounted&&((0,E.QE)(c,b,g+h,a.cost||0),b.accounted=!0),!v.endpoint&&a.endpoint&&c.run("UPDATE usageHistory SET endpoint = ? WHERE id = ?",[a.endpoint,v.id]);return}c.run("INSERT INTO usageHistory(timestamp, provider, model, connectionId, apiKey, endpoint, promptTokens, completionTokens, cost, status, tokens, meta) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",[a.timestamp,a.provider||null,a.model||null,a.connectionId||null,a.apiKey||null,a.endpoint||null,g,h,a.cost||0,a.status||"ok",(0,e.s)(f),(0,e.s)({latency:a.latency})]),b&&((0,E.QE)(c,b,g+h,a.cost||0),b.accounted=!0);let w=(j=(d=a.timestamp)?new Date(d):new Date,`${j.getFullYear()}-${String(j.getMonth()+1).padStart(2,"0")}-${String(j.getDate()).padStart(2,"0")}`),x=c.get("SELECT data FROM usageDaily WHERE dateKey = ?",[w]),y=x?(0,e.q)(x.data,{}):{requests:0,promptTokens:0,completionTokens:0,cost:0,byProvider:{},byModel:{},byAccount:{},byApiKey:{},byEndpoint:{}};k=a.tokens?.prompt_tokens||a.tokens?.input_tokens||0,l=a.tokens?.completion_tokens||a.tokens?.output_tokens||0,m=a.tokens?.cached_tokens||a.tokens?.cache_read_input_tokens||0,n=a.cost||0,o={promptTokens:k,completionTokens:l,cachedTokens:m,cost:n},y.requests=(y.requests||0)+1,y.promptTokens=(y.promptTokens||0)+k,y.completionTokens=(y.completionTokens||0)+l,y.cachedTokens=(y.cachedTokens||0)+m,y.cost=(y.cost||0)+n,p=a.latency?.total,Number.isFinite(p)&&p>=0&&(y.totalLatencyMs=(y.totalLatencyMs||0)+p,y.requestsWithLatency=(y.requestsWithLatency||0)+1),y.byProvider||={},y.byModel||={},y.byAccount||={},y.byApiKey||={},y.byEndpoint||={},a.provider&&O(y.byProvider,a.provider,o),q=a.provider?`${a.model}|${a.provider}`:a.model,O(y.byModel,q,{...o,meta:{rawModel:a.model,provider:a.provider}}),a.connectionId&&O(y.byAccount,a.connectionId,{...o,meta:{rawModel:a.model,provider:a.provider}}),r=a.apiKey&&"string"==typeof a.apiKey?a.apiKey:"local-no-key",s=`${r}|${a.model}|${a.provider||"unknown"}`,O(y.byApiKey,s,{...o,meta:{rawModel:a.model,provider:a.provider,apiKey:a.apiKey||null}}),t=a.endpoint||"Unknown",u=`${t}|${a.model}|${a.provider||"unknown"}`,O(y.byEndpoint,u,{...o,meta:{endpoint:t,rawModel:a.model,provider:a.provider}}),c.run("INSERT INTO usageDaily(dateKey, data) VALUES(?, ?) ON CONFLICT(dateKey) DO UPDATE SET data = excluded.data",[w,(0,e.s)(y)]);let z=c.get("SELECT value FROM _meta WHERE key = 'totalRequestsLifetime'"),A=(z?parseInt(z.value,10):0)+1;c.run("INSERT INTO _meta(key, value) VALUES('totalRequestsLifetime', ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",[String(A)]),i=!0}),i)&&(J.items.push(a),J.items.length>50&&(J.items=J.items.slice(-50)),N("update",250))}catch(a){console.error("Failed to save usage stats:",a)}}function W(a,b){if(null==b)return a.all("SELECT dateKey, data FROM usageDaily ORDER BY dateKey ASC");let c=new Date,d=new Date(c.getFullYear(),c.getMonth(),c.getDate()-b+1),e=`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`;return a.all("SELECT dateKey, data FROM usageDaily WHERE dateKey >= ? ORDER BY dateKey ASC",[e])}async function X(a="all"){let b=await (0,d.c)(),[{getProviderConnections:f},{getApiKeys:g},{getProviderNodes:h}]=await Promise.all([Promise.resolve().then(c.bind(c,5781)),Promise.resolve().then(c.bind(c,74452)),Promise.resolve().then(c.bind(c,1129))]),i=[];try{i=await f()}catch{}let j={};for(let a of i)j[a.id]=a.name||a.email||a.id;let k={};try{for(let a of(await h()))a.id&&a.name&&(k[a.id]=a.name)}catch{}let l=[];try{l=await g()}catch{}let m={};for(let a of l){let b={name:a.name,id:a.id,createdAt:a.createdAt};a.key&&(m[a.key.trim()]=b),m[a.id]=b}let n=b.all("SELECT timestamp, provider, model, tokens, status FROM usageHistory ORDER BY id DESC LIMIT 100"),o=new Set,p={totalRequests:0,totalPromptTokens:0,totalCompletionTokens:0,totalCachedTokens:0,totalCost:0,totalLatencyMs:0,latencySamples:0,periodStart:null,periodEnd:null,byProvider:{},byModel:{},byAccount:{},byApiKey:{},byEndpoint:{},last10Minutes:[],pending:G,activeRequests:[],recentRequests:n.map(a=>{let b=(0,e.q)(a.tokens,{})||{};return{timestamp:a.timestamp,model:a.model,provider:a.provider||"",promptTokens:b.prompt_tokens||b.input_tokens||0,completionTokens:b.completion_tokens||b.output_tokens||0,cachedTokens:b.cached_tokens||b.cache_read_input_tokens||0,status:a.status||"ok"}}).filter(a=>{if(0===a.promptTokens&&0===a.completionTokens)return!1;let b=a.timestamp?a.timestamp.slice(0,16):"",c=`${a.model}|${a.provider}|${a.promptTokens}|${a.completionTokens}|${b}`;return!o.has(c)&&(o.add(c),!0)}).slice(0,20),errorProvider:Date.now()-H.ts<1e4?H.provider:""};for(let[a,b]of Object.entries(G.byAccount))for(let[c,d]of Object.entries(b))if(d>0){let b=j[a]||`Account ${a.slice(0,8)}...`,e=c.match(/^(.*) \((.*)\)$/);p.activeRequests.push({model:e?e[1]:c,provider:e?e[2]:"unknown",account:b,count:d})}let q=new Date,r=new Date(6e4*Math.floor(q.getTime()/6e4)),s=new Date(r.getTime()-54e4),t={};for(let a=0;a<10;a++){let b=r.getTime()-(9-a)*6e4;t[b]={requests:0,promptTokens:0,completionTokens:0,cost:0},p.last10Minutes.push(t[b])}for(let a of b.all("SELECT timestamp, promptTokens, completionTokens, cost FROM usageHistory WHERE timestamp >= ? AND timestamp <= ?",[s.toISOString(),q.toISOString()])){let b=6e4*Math.floor(new Date(a.timestamp).getTime()/6e4);t[b]&&(t[b].requests++,t[b].promptTokens+=a.promptTokens||0,t[b].completionTokens+=a.completionTokens||0,t[b].cost+=a.cost||0)}if("24h"!==a&&"today"!==a){let c={"7d":7,"30d":30,"60d":60}[a]||null;for(let a of W(b,c)){let b=a.dateKey,c=(0,e.q)(a.data,{});for(let[b,d]of(p.totalPromptTokens+=c.promptTokens||0,p.totalCompletionTokens+=c.completionTokens||0,p.totalCachedTokens+=c.cachedTokens||0,p.totalCost+=c.cost||0,c.totalLatencyMs&&c.requestsWithLatency&&(p.totalLatencyMs+=c.totalLatencyMs,p.latencySamples+=c.requestsWithLatency),a.dateKey&&(!p.periodStart||a.dateKey<p.periodStart)&&(p.periodStart=a.dateKey),a.dateKey&&(!p.periodEnd||a.dateKey>p.periodEnd)&&(p.periodEnd=a.dateKey),Object.entries(c.byProvider||{})))p.byProvider[b]||(p.byProvider[b]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0}),p.byProvider[b].requests+=d.requests||0,p.byProvider[b].promptTokens+=d.promptTokens||0,p.byProvider[b].completionTokens+=d.completionTokens||0,p.byProvider[b].cachedTokens+=d.cachedTokens||0,p.byProvider[b].cost+=d.cost||0;for(let[a,d]of Object.entries(c.byModel||{})){let c=d.rawModel||a.split("|")[0],e=d.provider||a.split("|")[1]||"",f=e?`${c} (${e})`:c,g=k[e]||e;p.byModel[f]||(p.byModel[f]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0,rawModel:c,provider:g,lastUsed:b}),p.byModel[f].requests+=d.requests||0,p.byModel[f].promptTokens+=d.promptTokens||0,p.byModel[f].completionTokens+=d.completionTokens||0,p.byModel[f].cachedTokens+=d.cachedTokens||0,p.byModel[f].cost+=d.cost||0,b>(p.byModel[f].lastUsed||"")&&(p.byModel[f].lastUsed=b)}for(let[a,d]of Object.entries(c.byAccount||{})){let c=j[a]||`Account ${a.slice(0,8)}...`,e=d.rawModel||"",f=d.provider||"",g=k[f]||f,h=`${e} (${f} - ${c})`;p.byAccount[h]||(p.byAccount[h]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0,rawModel:e,provider:g,connectionId:a,accountName:c,lastUsed:b}),p.byAccount[h].requests+=d.requests||0,p.byAccount[h].promptTokens+=d.promptTokens||0,p.byAccount[h].completionTokens+=d.completionTokens||0,p.byAccount[h].cachedTokens+=d.cachedTokens||0,p.byAccount[h].cost+=d.cost||0,b>(p.byAccount[h].lastUsed||"")&&(p.byAccount[h].lastUsed=b)}for(let[a,d]of Object.entries(c.byApiKey||{})){let c=d.rawModel||"",e=d.provider||"",f=k[e]||e,g=d.apiKey?d.apiKey.trim():null,h=g?m[g]:null,i=F(g),j=h?.name||(g?i||g.slice(0,8)+"...":"Local (No API Key)"),l=i||"local-no-key";p.byApiKey[a]||(p.byApiKey[a]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0,rawModel:c,provider:f,apiKeyMasked:i,keyName:j,apiKeyKey:l,lastUsed:b}),p.byApiKey[a].requests+=d.requests||0,p.byApiKey[a].promptTokens+=d.promptTokens||0,p.byApiKey[a].completionTokens+=d.completionTokens||0,p.byApiKey[a].cachedTokens+=d.cachedTokens||0,p.byApiKey[a].cost+=d.cost||0,b>(p.byApiKey[a].lastUsed||"")&&(p.byApiKey[a].lastUsed=b)}for(let[a,d]of Object.entries(c.byEndpoint||{})){let c=d.endpoint||a.split("|")[0]||"Unknown",e=d.rawModel||"",f=d.provider||"",g=k[f]||f;p.byEndpoint[a]||(p.byEndpoint[a]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0,endpoint:c,rawModel:e,provider:g,lastUsed:b}),p.byEndpoint[a].requests+=d.requests||0,p.byEndpoint[a].promptTokens+=d.promptTokens||0,p.byEndpoint[a].completionTokens+=d.completionTokens||0,p.byEndpoint[a].cachedTokens+=d.cachedTokens||0,p.byEndpoint[a].cost+=d.cost||0,b>(p.byEndpoint[a].lastUsed||"")&&(p.byEndpoint[a].lastUsed=b)}}let d=Math.max(c?Date.now()-864e5*c:0,Date.now()-1728e5);for(let a of b.all("SELECT timestamp, provider, model, connectionId, apiKey, endpoint FROM usageHistory WHERE timestamp >= ?",[new Date(d).toISOString()])){let b=a.timestamp,c=a.provider?`${a.model} (${a.provider})`:a.model;if(p.byModel[c]&&new Date(b)>new Date(p.byModel[c].lastUsed)&&(p.byModel[c].lastUsed=b),a.connectionId){let c=j[a.connectionId]||`Account ${a.connectionId.slice(0,8)}...`,d=`${a.model} (${a.provider} - ${c})`;p.byAccount[d]&&new Date(b)>new Date(p.byAccount[d].lastUsed)&&(p.byAccount[d].lastUsed=b)}let d=a.apiKey&&"string"==typeof a.apiKey?`${a.apiKey}|${a.model}|${a.provider||"unknown"}`:"local-no-key";p.byApiKey[d]&&new Date(b)>new Date(p.byApiKey[d].lastUsed)&&(p.byApiKey[d].lastUsed=b);let e=a.endpoint||"Unknown",f=`${e}|${a.model}|${a.provider||"unknown"}`;p.byEndpoint[f]&&new Date(b)>new Date(p.byEndpoint[f].lastUsed)&&(p.byEndpoint[f].lastUsed=b)}}else{let c;if("today"===a){let a=new Date;a.setHours(0,0,0,0),c=a.toISOString()}else c=new Date(Date.now()-864e5).toISOString();for(let a of b.all("SELECT timestamp, provider, model, connectionId, apiKey, endpoint, promptTokens, completionTokens, cost, tokens, meta FROM usageHistory WHERE timestamp >= ?",[c])){let b=(0,e.q)(a.tokens,{})||{},c=b.prompt_tokens||b.input_tokens||a.promptTokens||0,d=b.completion_tokens||b.output_tokens||a.completionTokens||0,f=b.cached_tokens||b.cache_read_input_tokens||0,g=a.cost||0,h=k[a.provider]||a.provider;p.totalPromptTokens+=c,p.totalCompletionTokens+=d,p.totalCachedTokens+=f,p.totalCost+=g;let i=(0,e.q)(a.meta,{})?.latency;Number.isFinite(i?.total)&&i.total>=0&&(p.totalLatencyMs+=i.total,p.latencySamples+=1),a.timestamp&&(!p.periodStart||a.timestamp<p.periodStart)&&(p.periodStart=a.timestamp),a.timestamp&&(!p.periodEnd||a.timestamp>p.periodEnd)&&(p.periodEnd=a.timestamp),p.byProvider[a.provider]||(p.byProvider[a.provider]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0}),p.byProvider[a.provider].requests++,p.byProvider[a.provider].promptTokens+=c,p.byProvider[a.provider].completionTokens+=d,p.byProvider[a.provider].cachedTokens+=f,p.byProvider[a.provider].cost+=g;let l=a.provider?`${a.model} (${a.provider})`:a.model;if(p.byModel[l]||(p.byModel[l]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0,rawModel:a.model,provider:h,lastUsed:a.timestamp}),p.byModel[l].requests++,p.byModel[l].promptTokens+=c,p.byModel[l].completionTokens+=d,p.byModel[l].cachedTokens+=f,p.byModel[l].cost+=g,new Date(a.timestamp)>new Date(p.byModel[l].lastUsed)&&(p.byModel[l].lastUsed=a.timestamp),a.connectionId){let b=j[a.connectionId]||`Account ${a.connectionId.slice(0,8)}...`,e=`${a.model} (${a.provider} - ${b})`;p.byAccount[e]||(p.byAccount[e]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0,rawModel:a.model,provider:h,connectionId:a.connectionId,accountName:b,lastUsed:a.timestamp}),p.byAccount[e].requests++,p.byAccount[e].promptTokens+=c,p.byAccount[e].completionTokens+=d,p.byAccount[e].cachedTokens+=f,p.byAccount[e].cost+=g,new Date(a.timestamp)>new Date(p.byAccount[e].lastUsed)&&(p.byAccount[e].lastUsed=a.timestamp)}if(a.apiKey&&"string"==typeof a.apiKey){let b=a.apiKey.trim(),e=m[b],i=F(b),j=e?.name||i||a.apiKey.slice(0,8)+"...",k=`${a.apiKey}|${a.model}|${a.provider||"unknown"}`;p.byApiKey[k]||(p.byApiKey[k]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0,rawModel:a.model,provider:h,apiKeyMasked:i,keyName:j,apiKeyKey:i,lastUsed:a.timestamp});let l=p.byApiKey[k];l.requests++,l.promptTokens+=c,l.completionTokens+=d,l.cachedTokens+=f,l.cost+=g,new Date(a.timestamp)>new Date(l.lastUsed)&&(l.lastUsed=a.timestamp)}else{p.byApiKey["local-no-key"]||(p.byApiKey["local-no-key"]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0,rawModel:a.model,provider:h,apiKeyMasked:null,keyName:"Local (No API Key)",apiKeyKey:"local-no-key",lastUsed:a.timestamp});let b=p.byApiKey["local-no-key"];b.requests++,b.promptTokens+=c,b.completionTokens+=d,b.cachedTokens+=f,b.cost+=g,new Date(a.timestamp)>new Date(b.lastUsed)&&(b.lastUsed=a.timestamp)}let n=a.endpoint||"Unknown",o=`${n}|${a.model}|${a.provider||"unknown"}`;p.byEndpoint[o]||(p.byEndpoint[o]={requests:0,promptTokens:0,completionTokens:0,cachedTokens:0,cost:0,endpoint:n,rawModel:a.model,provider:h,lastUsed:a.timestamp});let q=p.byEndpoint[o];q.requests++,q.promptTokens+=c,q.completionTokens+=d,q.cachedTokens+=f,q.cost+=g,new Date(a.timestamp)>new Date(q.lastUsed)&&(q.lastUsed=a.timestamp)}}if(("today"===a||"24h"===a||"7d"===a)&&0===p.latencySamples){let c=new Date(Date.now()-3600*("7d"===a?168:24)*1e3).toISOString();for(let a of b.all("SELECT timestamp, meta FROM usageHistory WHERE timestamp >= ? AND meta LIKE '%\"latency\"%' ORDER BY id DESC LIMIT 4000",[c])){let b=(0,e.q)(a.meta,{})?.latency;Number.isFinite(b?.total)&&b.total>=0&&(p.totalLatencyMs+=b.total,p.latencySamples+=1),a.timestamp&&(!p.periodStart||a.timestamp<p.periodStart)&&(p.periodStart=a.timestamp),a.timestamp&&(!p.periodEnd||a.timestamp>p.periodEnd)&&(p.periodEnd=a.timestamp)}}return p.totalRequests=Object.values(p.byProvider).reduce((a,b)=>a+(b.requests||0),0),p}async function Y(a="7d"){let b=await (0,d.c)(),c=Date.now();if("today"===a){let a=new Date;a.setHours(0,0,0,0);let c=a.getTime(),d=c+864e5,e=Array.from({length:24},(a,b)=>({label:new Date(c+36e5*b).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}),tokens:0,cost:0,requests:0}));for(let a of b.all("SELECT timestamp, promptTokens, completionTokens, cost FROM usageHistory WHERE timestamp >= ?",[new Date(c).toISOString()])){let b=new Date(a.timestamp).getTime();if(b<c||b>=d)continue;let f=Math.floor((b-c)/36e5);f>=0&&f<24&&(e[f].tokens+=(a.promptTokens||0)+(a.completionTokens||0),e[f].cost+=a.cost||0,e[f].requests+=1)}return e}if("24h"===a){let a=c-864e5,d=Array.from({length:24},(b,c)=>({label:new Date(a+36e5*c).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}),tokens:0,cost:0,requests:0}));for(let e of b.all("SELECT timestamp, promptTokens, completionTokens, cost FROM usageHistory WHERE timestamp >= ?",[new Date(a).toISOString()])){let b=new Date(e.timestamp).getTime();if(b<a||b>c)continue;let f=Math.min(Math.floor((b-a)/36e5),23);d[f].tokens+=(e.promptTokens||0)+(e.completionTokens||0),d[f].cost+=e.cost||0,d[f].requests+=1}return d}let f=a=>a.toLocaleDateString("en-US",{month:"short",day:"numeric"});if("all"===a){let a=W(b,null);if(!a.length)return[];let c={};for(let b of a)c[b.dateKey]=(0,e.q)(b.data,{});let d=new Date(a[0].dateKey+"T00:00:00"),g=new Date;return g.setHours(0,0,0,0),Array.from({length:Math.max(1,Math.round((g-d)/864e5)+1)},(a,b)=>{let e=new Date(d);e.setDate(e.getDate()+b);let g=c[`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`];return{label:f(e),tokens:g?(g.promptTokens||0)+(g.completionTokens||0):0,cost:g&&g.cost||0,requests:g&&g.requests||0}})}let g="7d"===a?7:"30d"===a?30:60,h=new Date,i=W(b,g),j={};for(let a of i)j[a.dateKey]=(0,e.q)(a.data,{});return Array.from({length:g},(a,b)=>{let c=new Date(h);c.setDate(c.getDate()-(g-1-b));let d=j[`${c.getFullYear()}-${String(c.getMonth()+1).padStart(2,"0")}-${String(c.getDate()).padStart(2,"0")}`];return{label:f(c),tokens:d?(d.promptTokens||0)+(d.completionTokens||0):0,cost:d&&d.cost||0,requests:d&&d.requests||0}})}async function Z(){}async function $(a=200,{format:b="text"}={}){try{let f=(await (0,d.c)()).all("SELECT id, timestamp, provider, model, connectionId, promptTokens, completionTokens, status, tokens, meta FROM usageHistory ORDER BY id DESC LIMIT ?",[a]);if(!f.length)return[];if("json"===b)return f.map(a=>{let b=(0,e.q)(a.tokens,{})||{},c=(0,e.q)(a.meta,{})?.latency;return{id:a.id,timestamp:a.timestamp,model:a.model,provider:a.provider,status:a.status||"ok",promptTokens:a.promptTokens??b.prompt_tokens??b.input_tokens??0,completionTokens:a.completionTokens??b.completion_tokens??b.output_tokens??0,ttftMs:Number.isFinite(c?.ttft)&&c.ttft>=0?c.ttft:null,durationMs:Number.isFinite(c?.total)&&c.total>=0?c.total:null}});let g={};try{let{getProviderConnections:a}=await Promise.resolve().then(c.bind(c,5781));for(let b of(await a()))g[b.id]=b.name||b.email||""}catch{}return f.map(a=>{let b=function(a=new Date){let b=a=>String(a).padStart(2,"0");return`${b(a.getDate())}-${b(a.getMonth()+1)}-${a.getFullYear()} ${b(a.getHours())}:${b(a.getMinutes())}:${b(a.getSeconds())}`}(new Date(a.timestamp)),c=a.provider?.toUpperCase()||"-",d=a.model||"-",f=g[a.connectionId]||(a.connectionId?a.connectionId.slice(0,8):"-"),h=a.tokens?(0,e.q)(a.tokens,{}):{},i=a.promptTokens??h.prompt_tokens??"-",j=a.completionTokens??h.completion_tokens??"-";return`${b} | ${d} | ${c} | ${f} | ${i} | ${j} | ${a.status||"-"}`})}catch(a){return console.error("[usageRepo] getRecentLogs failed:",a.message),[]}}let _=null,aa=0;async function ab(){if(_&&Date.now()-aa<5e3)return _;try{let{getSettings:a}=await Promise.resolve().then(c.bind(c,42655)),b=await a(),d=process.env.ENABLE_REQUEST_LOGS;if(void 0!==d)return _={enabled:"true"===d.toLowerCase(),maxRecords:b.observabilityMaxRecords||parseInt(process.env.OBSERVABILITY_MAX_RECORDS||String(200),10),batchSize:b.observabilityBatchSize||parseInt(process.env.OBSERVABILITY_BATCH_SIZE||String(20),10),flushIntervalMs:b.observabilityFlushIntervalMs||parseInt(process.env.OBSERVABILITY_FLUSH_INTERVAL_MS||String(5e3),10),maxJsonSize:1024*(b.observabilityMaxJsonSize||parseInt(process.env.OBSERVABILITY_MAX_JSON_SIZE||"5",10))},aa=Date.now(),_;let e="false"!==process.env.OBSERVABILITY_ENABLED;_={enabled:"boolean"==typeof b.enableObservability?b.enableObservability:e,maxRecords:b.observabilityMaxRecords||parseInt(process.env.OBSERVABILITY_MAX_RECORDS||String(200),10),batchSize:b.observabilityBatchSize||parseInt(process.env.OBSERVABILITY_BATCH_SIZE||String(20),10),flushIntervalMs:b.observabilityFlushIntervalMs||parseInt(process.env.OBSERVABILITY_FLUSH_INTERVAL_MS||String(5e3),10),maxJsonSize:1024*(b.observabilityMaxJsonSize||parseInt(process.env.OBSERVABILITY_MAX_JSON_SIZE||"5",10))}}catch{_={enabled:!1,maxRecords:200,batchSize:20,flushIntervalMs:5e3,maxJsonSize:5120}}return aa=Date.now(),_}let ac=[],ad=null,ae=!1;function af(a,b){let c=JSON.stringify(a||{});return c.length>b?{_truncated:!0,_originalSize:c.length,_preview:c.substring(0,200)}:a||{}}async function ag(){if(!ae&&0!==ac.length){ae=!0;try{for(;ac.length>0;){let a=ac.splice(0,ac.length),b=await (0,d.c)(),c=await ab();b.transaction(()=>{for(let d of a){d.id||(d.id=function(a){let b=new Date().toISOString(),c=Math.random().toString(36).substring(2,8),d=a?a.replace(/[^a-zA-Z0-9-]/g,"-"):"unknown";return`${b}-${c}-${d}`}(d.model)),d.timestamp||(d.timestamp=new Date().toISOString()),d.request?.headers&&(d.request.headers=function(a){if(!a||"object"!=typeof a)return{};let b=["authorization","x-api-key","x-goog-api-key","cookie","token","api-key"],c={...a};for(let a of Object.keys(c))b.some(b=>a.toLowerCase().includes(b))&&delete c[a];return c}(d.request.headers));let a={id:d.id,provider:d.provider||null,model:d.model||null,connectionId:d.connectionId||null,timestamp:d.timestamp,status:d.status||null,latency:d.latency||{},tokens:d.tokens||{},request:af(d.request,c.maxJsonSize),providerRequest:af(d.providerRequest,c.maxJsonSize),providerResponse:af(d.providerResponse,c.maxJsonSize),response:af(d.response,c.maxJsonSize),pxpipe:d.pxpipe||void 0};b.run("INSERT INTO requestDetails(id, timestamp, provider, model, connectionId, status, data) VALUES(?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET timestamp = excluded.timestamp, provider = excluded.provider, model = excluded.model, connectionId = excluded.connectionId, status = excluded.status, data = excluded.data",[a.id,a.timestamp,a.provider,a.model,a.connectionId,a.status,(0,e.s)(a)])}let d=b.get("SELECT COUNT(*) as c FROM requestDetails");d&&d.c>c.maxRecords&&b.run("DELETE FROM requestDetails WHERE id IN (SELECT id FROM requestDetails ORDER BY timestamp ASC LIMIT ?)",[d.c-c.maxRecords])})}}catch(a){console.error("[requestDetailsRepo] Batch write failed:",a)}finally{ae=!1}}}async function ah(a){let b=await ab();b.enabled&&(ac.push(a),ac.length>=b.batchSize?(ad&&(clearTimeout(ad),ad=null),ag().catch(a=>console.error("[requestDetailsRepo] flush err:",a))):ad||(ad=setTimeout(()=>{ad=null,ag().catch(()=>{})},b.flushIntervalMs)))}async function ai(a={}){let b=await (0,d.c)(),c=[],f=[];a.provider&&(c.push("provider = ?"),f.push(a.provider)),a.model&&(c.push("model = ?"),f.push(a.model)),a.connectionId&&(c.push("connectionId = ?"),f.push(a.connectionId)),a.status&&(c.push("status = ?"),f.push(a.status)),a.startDate&&(c.push("timestamp >= ?"),f.push(new Date(a.startDate).toISOString())),a.endDate&&(c.push("timestamp <= ?"),f.push(new Date(a.endDate).toISOString()));let g=c.length?`WHERE ${c.join(" AND ")}`:"",h=b.get(`SELECT COUNT(*) as c FROM requestDetails ${g}`,f),i=h?h.c:0,j=a.page||1,k=a.pageSize||50,l=Math.ceil(i/k);return{details:b.all(`SELECT data FROM requestDetails ${g} ORDER BY timestamp DESC LIMIT ? OFFSET ?`,[...f,k,(j-1)*k]).map(a=>(0,e.q)(a.data,{})),pagination:{page:j,pageSize:k,totalItems:i,totalPages:l,hasNext:j<l,hasPrev:j>1}}}async function aj(){return(await (0,d.c)()).all("SELECT DISTINCT provider FROM requestDetails WHERE provider IS NOT NULL ORDER BY provider ASC").map(a=>a.provider)}let ak=async()=>{ad&&(clearTimeout(ad),ad=null),ac.length>0&&await ag()};async function al(){let a=await (0,d.c)(),{exportSettings:b}=await Promise.resolve().then(c.bind(c,42655)),g={settings:await b(),providerConnections:a.all("SELECT * FROM providerConnections").map(a=>({...(0,e.q)(a.data,{}),id:a.id,provider:a.provider,authType:a.authType,name:a.name,email:a.email,priority:a.priority,isActive:1===a.isActive,createdAt:a.createdAt,updatedAt:a.updatedAt})),providerNodes:a.all("SELECT * FROM providerNodes").map(a=>({...(0,e.q)(a.data,{}),id:a.id,type:a.type,name:a.name,createdAt:a.createdAt,updatedAt:a.updatedAt})),proxyPools:a.all("SELECT * FROM proxyPools").map(a=>({...(0,e.q)(a.data,{}),id:a.id,isActive:1===a.isActive,testStatus:a.testStatus,createdAt:a.createdAt,updatedAt:a.updatedAt})),apiKeys:a.all("SELECT * FROM apiKeys").map(a=>({...a,policy:(0,e.q)(a.policy,{}),isActive:1===a.isActive,access:(0,h.xE)(a.accessRestricted,a.accessAllow)})),combos:a.all("SELECT * FROM combos").map(f.IL),modelAliases:{},customModels:[],mitmAlias:{},pricing:{},disabledModels:{}};for(let b of a.all("SELECT key, value FROM kv WHERE scope = 'modelAliases'"))g.modelAliases[b.key]=(0,e.q)(b.value);for(let b of a.all("SELECT key, value FROM kv WHERE scope = 'customModels'"))g.customModels.push((0,e.q)(b.value));for(let b of a.all("SELECT key, value FROM kv WHERE scope = 'mitmAlias'"))g.mitmAlias[b.key]=(0,e.q)(b.value);for(let b of a.all("SELECT key, value FROM kv WHERE scope = 'pricing'"))g.pricing[b.key]=(0,e.q)(b.value);for(let b of a.all("SELECT key, value FROM kv WHERE scope = 'disabledModels'"))g.disabledModels[b.key]=(0,e.q)(b.value,[]);return g}async function am(a){if(!a||"object"!=typeof a||Array.isArray(a))throw Error("Invalid database payload");let b=await (0,d.c)();return b.transaction(()=>{for(let c of(b.run("DELETE FROM settings"),b.run("DELETE FROM providerConnections"),b.run("DELETE FROM providerNodes"),b.run("DELETE FROM proxyPools"),b.run("DELETE FROM apiKeys"),b.run("DELETE FROM combos"),b.run("DELETE FROM kv WHERE scope IN ('modelAliases', 'customModels', 'mitmAlias', 'pricing', 'disabledModels')"),a.settings&&b.run("INSERT INTO settings(id, data) VALUES(1, ?) ON CONFLICT(id) DO UPDATE SET data = excluded.data",[(0,e.s)(a.settings)]),a.providerConnections||[])){let{id:a,provider:d,authType:f,name:g,email:h,priority:i,isActive:j,createdAt:k,updatedAt:l,...m}=c;b.run("INSERT OR REPLACE INTO providerConnections(id, provider, authType, name, email, priority, isActive, data, createdAt, updatedAt) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",[a,d,f||"oauth",g||null,h||null,i||null,+(!1!==j),(0,e.s)(m),k||new Date().toISOString(),l||new Date().toISOString()])}for(let c of a.providerNodes||[]){let{id:a,type:d,name:f,createdAt:g,updatedAt:h,...i}=c;b.run("INSERT OR REPLACE INTO providerNodes(id, type, name, data, createdAt, updatedAt) VALUES(?, ?, ?, ?, ?, ?)",[a,d||null,f||null,(0,e.s)(i),g||new Date().toISOString(),h||new Date().toISOString()])}for(let c of a.proxyPools||[]){let{id:a,isActive:d,testStatus:f,createdAt:g,updatedAt:h,...i}=c;b.run("INSERT OR REPLACE INTO proxyPools(id, isActive, testStatus, data, createdAt, updatedAt) VALUES(?, ?, ?, ?, ?, ?)",[a,+(!1!==d),f||"unknown",(0,e.s)(i),g||new Date().toISOString(),h||new Date().toISOString()])}for(let c of a.apiKeys||[]){let a=i.M0;if(void 0!==c.access){let b=(0,h.M7)(c.access);if(!b.ok)throw Error(`apiKeys ${c.id}: ${b.error}`);a=b.value}let d=(0,h.aB)(a);b.run("INSERT OR REPLACE INTO apiKeys(id, key, name, machineId, isActive, createdAt, policy, quotaPeriodStartedAt, quotaTokens, quotaCost, lastUsedAt, updatedAt, accessRestricted, accessAllow) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",[c.id,c.key,c.name||null,c.machineId||null,+(!1!==c.isActive),c.createdAt||new Date().toISOString(),(0,e.s)(c.policy||{}),c.quotaPeriodStartedAt||null,c.quotaTokens||0,c.quotaCost||0,c.lastUsedAt||null,c.updatedAt||null,d.accessRestricted,d.accessAllow])}for(let c of a.combos||[]){let a=(0,g.bX)(c);b.run("INSERT OR REPLACE INTO combos(id, name, kind, models, createdAt, updatedAt, promptInjectionEnabled, promptInjectionMode, systemPrompt, displayIdentity) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",[c.id,c.name,c.kind||null,(0,e.s)(c.models||[]),c.createdAt||new Date().toISOString(),c.updatedAt||new Date().toISOString(),+!!a.promptInjectionEnabled,a.promptInjectionMode,a.systemPrompt,a.displayIdentity])}for(let[c,d]of Object.entries(a.modelAliases||{}))b.run("INSERT OR REPLACE INTO kv(scope, key, value) VALUES('modelAliases', ?, ?)",[c,(0,e.s)(d)]);for(let c of a.customModels||[]){let a=`${c.providerAlias}|${c.id}|${c.type||"llm"}`;b.run("INSERT OR REPLACE INTO kv(scope, key, value) VALUES('customModels', ?, ?)",[a,(0,e.s)(c)])}for(let[c,d]of Object.entries(a.mitmAlias||{}))b.run("INSERT OR REPLACE INTO kv(scope, key, value) VALUES('mitmAlias', ?, ?)",[c,(0,e.s)(d||{})]);for(let[c,d]of Object.entries(a.pricing||{}))b.run("INSERT OR REPLACE INTO kv(scope, key, value) VALUES('pricing', ?, ?)",[c,(0,e.s)(d||{})]);for(let[c,d]of Object.entries(a.disabledModels||{}))b.run("INSERT OR REPLACE INTO kv(scope, key, value) VALUES('disabledModels', ?, ?)",[c,(0,e.s)(d||[])]);(0,j.Os)(b)}),await al()}process.off("beforeExit",ak),process.off("SIGINT",ak),process.off("SIGTERM",ak),process.off("exit",ak),process.on("beforeExit",ak),process.on("SIGINT",ak),process.on("SIGTERM",ak),process.on("exit",ak)},95658:(a,b,c)=>{c.d(b,{AL:()=>j,HG:()=>i,Jh:()=>m,KQ:()=>k,Or:()=>l});var d=c(76760),e=c.n(d),f=c(73024),g=c.n(f),h=c(49120);let i=e().join(h.n,"db"),j=e().join(i,"data.sqlite"),k=e().join(i,"backups"),l={main:e().join(h.n,"db.json"),usage:e().join(h.n,"usage.json"),disabled:e().join(h.n,"disabledModels.json"),details:e().join(h.n,"request-details.json")};function m(){for(let a of[h.n,i,k])g().existsSync(a)||g().mkdirSync(a,{recursive:!0})}},97914:(a,b,c)=>{c.d(b,{KJ:()=>l,VT:()=>n,getPricingForModel:()=>k,r4:()=>j,yF:()=>m});var d=c(36366),e=c(644);let f=(0,c(22846).U)("pricing"),g={value:null,expiresAt:0};function h(){g={value:null,expiresAt:0}}async function i(){return await f.getAll()}async function j(){let a=Date.now();if(g.value&&g.expiresAt>a)return g.value;let b=await i(),{PROVIDER_PRICING:d}=await c.e(8920).then(c.bind(c,58920)),e={};for(let[a,c]of Object.entries(d))if(e[a]={...c},b[a])for(let[c,d]of Object.entries(b[a]))e[a][c]=e[a][c]?{...e[a][c],...d}:d;for(let[a,c]of Object.entries(b))if(e[a])for(let[b,d]of Object.entries(c))e[a][b]||(e[a][b]=d);else e[a]={...c};return g={value:e,expiresAt:a+5e3},e}async function k(a,b){if(!b)return null;let d=await i();if(a&&d[a]?.[b])return d[a][b];let{getPricingForModel:e}=await c.e(8920).then(c.bind(c,58920));return e(a,b)}async function l(a){let b=await (0,d.c)();return b.transaction(()=>{for(let[c,d]of Object.entries(a)){let a=b.get("SELECT value FROM kv WHERE scope = 'pricing' AND key = ?",[c]),f={...a&&(0,e.q)(a.value,{})||{}};for(let[a,b]of Object.entries(d))f[a]=b;b.run("INSERT INTO kv(scope, key, value) VALUES('pricing', ?, ?) ON CONFLICT(scope, key) DO UPDATE SET value = excluded.value",[c,(0,e.s)(f)])}}),h(),await i()}async function m(a,b){if(!a)return await i();let c=await (0,d.c)();return c.transaction(()=>{if(!b)return void c.run("DELETE FROM kv WHERE scope = 'pricing' AND key = ?",[a]);let d=c.get("SELECT value FROM kv WHERE scope = 'pricing' AND key = ?",[a]),f=d&&(0,e.q)(d.value,{})||{};delete f[b],0===Object.keys(f).length?c.run("DELETE FROM kv WHERE scope = 'pricing' AND key = ?",[a]):c.run("INSERT INTO kv(scope, key, value) VALUES('pricing', ?, ?) ON CONFLICT(scope, key) DO UPDATE SET value = excluded.value",[a,(0,e.s)(f)])}),h(),await i()}async function n(){return await f.clear(),h(),{}}}};
@@ -1 +0,0 @@
1
- exports.id=379,exports.ids=[379],exports.modules={2116:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0});var d={default:function(){return p},useLinkStatus:function(){return r}};for(var e in d)Object.defineProperty(b,e,{enumerable:!0,get:d[e]});let f=c(24814),g=c(48249),h=f._(c(67484)),i=c(79925),j=c(30836),k=c(57272),l=c(30167),m=c(75729);c(52204);let n=c(78756);c(52836);let o=c(10881);function p(a){var b;let c,d,e,[f,p]=(0,h.useOptimistic)(n.IDLE_LINK_STATUS),r=(0,h.useRef)(null),{href:s,as:t,children:u,prefetch:v=null,passHref:w,replace:x,shallow:y,scroll:z,onClick:A,onMouseEnter:B,onTouchStart:C,legacyBehavior:D=!1,onNavigate:E,transitionTypes:F,ref:G,unstable_dynamicOnHover:H,...I}=a;c=u,D&&("string"==typeof c||"number"==typeof c)&&(c=(0,g.jsx)("a",{children:c}));let J=h.default.useContext(j.AppRouterContext),K=!1!==v,L=!1===v?"none":!0===v?"full":"auto",M="none"!==L?"auto"===L?o.FetchStrategy.PPR:o.FetchStrategy.Full:o.FetchStrategy.PPR,N="string"==typeof(b=t||s)?b:(0,i.formatUrl)(b);if(D){if(c?.$$typeof===Symbol.for("react.lazy"))throw Object.defineProperty(Error("`<Link legacyBehavior>` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's `<a>` tag."),"__NEXT_ERROR_CODE",{value:"E863",enumerable:!1,configurable:!0});d=h.default.Children.only(c)}let O=D?d&&"object"==typeof d&&d.ref:G,P,Q=h.default.useCallback(a=>(null!==J&&(r.current=(0,n.mountLinkInstance)(a,N,J,M,K,p,P)),()=>{r.current&&((0,n.unmountLinkForCurrentNavigation)(r.current),r.current=null),(0,n.unmountPrefetchableInstance)(a)}),[K,N,J,M,p,P]),R={ref:(0,k.useMergedRef)(Q,O),onClick(a){D||"function"!=typeof A||A(a),D&&d.props&&"function"==typeof d.props.onClick&&d.props.onClick(a),!J||a.defaultPrevented||function(a="none"){}(L)},onMouseEnter(a){D||"function"!=typeof B||B(a),D&&d.props&&"function"==typeof d.props.onMouseEnter&&d.props.onMouseEnter(a),J&&K&&(0,n.onNavigationIntent)(a.currentTarget,!0===H)},onTouchStart:function(a){D||"function"!=typeof C||C(a),D&&d.props&&"function"==typeof d.props.onTouchStart&&d.props.onTouchStart(a),J&&K&&(0,n.onNavigationIntent)(a.currentTarget,!0===H)}};return(0,l.isAbsoluteUrl)(N)?R.href=N:D&&!w&&("a"!==d.type||"href"in d.props)||(R.href=(0,m.addBasePath)(N)),e=D?h.default.cloneElement(d,R):(0,g.jsx)("a",{...I,...R,children:c}),(0,g.jsx)(q.Provider,{value:f,children:e})}let q=(0,h.createContext)(n.IDLE_LINK_STATUS),r=()=>(0,h.useContext)(q);("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},14953:(a,b,c)=>{"use strict";var d=c(68662);function e(){}function f(){}f.resetWarningCache=e,a.exports=function(){function a(a,b,c,e,f,g){if(g!==d){var h=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}function b(){return a}a.isRequired=a;var c={array:a,bigint:a,bool:a,func:a,number:a,object:a,string:a,symbol:a,any:a,arrayOf:b,element:a,elementType:a,instanceOf:b,node:a,objectOf:b,oneOf:b,oneOfType:b,shape:b,exact:b,checkPropTypes:f,resetWarningCache:e};return c.PropTypes=c,c}},34956:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"normalizePathTrailingSlash",{enumerable:!0,get:function(){return f}});let d=c(62043),e=c(10571),f=a=>{if(47!==a.charCodeAt(0))return a;let{pathname:b,query:c,hash:f}=(0,e.parsePath)(a);return`${(0,d.removeTrailingSlash)(b)}${c}${f}`};("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},49885:(a,b,c)=>{a.exports=c(14953)()},52836:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"isLocalURL",{enumerable:!0,get:function(){return f}});let d=c(30167),e=c(71742);function f(a){if(!(0,d.isAbsoluteUrl)(a))return!0;try{let b=(0,d.getLocationOrigin)(),c=new URL(a,b);return c.origin===b&&(0,e.hasBasePath)(c.pathname)}catch(a){return!1}}},57272:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"useMergedRef",{enumerable:!0,get:function(){return e}});let d=c(67484);function e(a,b){let c=(0,d.useRef)(null),e=(0,d.useRef)(null);return(0,d.useCallback)(d=>{if(null===d){let a=c.current;a&&(c.current=null,a());let b=e.current;b&&(e.current=null,b())}else a&&(c.current=f(a,d)),b&&(e.current=f(b,d))},[a,b])}function f(a,b){if("function"!=typeof a)return a.current=b,()=>{a.current=null};{let c=a(b);return"function"==typeof c?c:()=>a(null)}}("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},62043:(a,b)=>{"use strict";function c(a){return 47===a.charCodeAt(a.length-1)&&a.length>1?a.slice(0,-1):a}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"removeTrailingSlash",{enumerable:!0,get:function(){return c}})},68662:a=>{"use strict";a.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},71e3:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"addPathPrefix",{enumerable:!0,get:function(){return e}});let d=c(10571);function e(a,b){if(!a.startsWith("/")||!b)return a;let{pathname:c,query:e,hash:f}=(0,d.parsePath)(a);return`${b}${c}${e}${f}`}},75729:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"addBasePath",{enumerable:!0,get:function(){return f}});let d=c(71e3),e=c(34956);function f(a,b){return(0,e.normalizePathTrailingSlash)((0,d.addPathPrefix)(a,""))}("function"==typeof b.default||"object"==typeof b.default&&null!==b.default)&&void 0===b.default.__esModule&&(Object.defineProperty(b.default,"__esModule",{value:!0}),Object.assign(b.default,b),a.exports=b.default)},79925:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0});var d={formatUrl:function(){return h},formatWithValidation:function(){return j},urlObjectKeys:function(){return i}};for(var e in d)Object.defineProperty(b,e,{enumerable:!0,get:d[e]});let f=c(24814)._(c(90485)),g=/https?|ftp|gopher|file/;function h(a){let{auth:b,hostname:c}=a,d=a.protocol||"",e=a.pathname||"",h=a.hash||"",i=a.query||"",j=!1;b=b?encodeURIComponent(b).replace(/%3A/i,":")+"@":"",a.host?j=b+a.host:c&&(j=b+(~c.indexOf(":")?`[${c}]`:c),a.port&&(j+=":"+a.port)),i&&"object"==typeof i&&(i=String(f.urlQueryToSearchParams(i)));let k=a.search||i&&`?${i}`||"";return d&&!d.endsWith(":")&&(d+=":"),a.slashes||(!d||g.test(d))&&!1!==j?(j="//"+(j||""),e&&"/"!==e[0]&&(e="/"+e)):j||(j=""),h&&"#"!==h[0]&&(h="#"+h),k&&"?"!==k[0]&&(k="?"+k),e=e.replace(/[?#]/g,encodeURIComponent),k=k.replace("#","%23"),`${d}${j}${e}${k}${h}`}let i=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function j(a){return h(a)}}};
@@ -1,27 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{34929:(e,t,s)=>{Promise.resolve().then(s.bind(s,43947))},43947:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>en});var i=s(95155),a=s(96439),r=s(12115),l=s(73321),n=s(98500),o=s.n(n),d=s(5772),c=s(8247),p=s(35497),m=s(88105),u=s(28777),h=s(67899),x=s(62630);s(67468);var f=s(13097);let g=["none","low","medium","high"],y=["none","thinking"],v=["none","low","medium","high","xhigh","max"],b={openai:["none","minimal","low","medium","high","xhigh"],"claude-adaptive":v,"claude-budget":v,"gemini-level":["minimal","low","medium","high"],"gemini-budget":g,zai:y,qwen:g,kimi:["none","low","medium","high","max"],deepseek:["none","high","max"],commandcode:["none","low","medium","high","xhigh","max"],river:["none","low","medium","high","xhigh","max"],minimax:y,hunyuan:g,step:g,nous:g},j=["none","minimal","low","medium","high","xhigh","max"],w=["none","low","medium","high","max"],k=[{pattern:"*gemini-4*",levels:["low","medium","high"]},{pattern:"*claude*4.6*",levels:w},{pattern:"*claude*4-6*",levels:w},{provider:"codex",pattern:"*gpt-6*",levels:j},{provider:"codex",pattern:"*gpt-5.6-sol*",levels:[...j,"ultra"]},{provider:"codex",pattern:"*gpt-5.6-terra*",levels:[...j,"ultra"]},{provider:"codex",pattern:"*gpt-5.6-luna*",levels:j},{pattern:"*codex*",levels:["low","medium","high","xhigh"]},{pattern:"*mimo*v2.6*",levels:["none","low","medium","high","xhigh"]},{pattern:"*mimo*v2.5-pro*",levels:["none","low","medium","high","xhigh"]},{provider:"codebuddy-cn",pattern:"deepseek-v4-pro",levels:["low","high","xhigh"]},{provider:"codebuddy-cn",pattern:"deepseek-v4.1-flash",levels:["low","high","max"]},{pattern:"*deepseek-v4.*",levels:["none","low","medium","high","xhigh","max"]},{provider:"codebuddy-cn",pattern:"glm-5.3",levels:["low","high","max"]},{provider:"codebuddy-cn",pattern:"glm-5.3-flash",levels:["low","high","max"]},{provider:"codebuddy-cn",pattern:"glm-5.2",levels:["high","xhigh"]},{provider:"codebuddy-cn",pattern:"kimi-k2.8-preview",levels:["low","medium","high"]},{provider:"codebuddy-cn",pattern:"hy3",levels:["low","high"]},{provider:"codebuddy-cn",pattern:"hy4-preview",levels:["high"]},{provider:"codebuddy-intl",pattern:"deepseek-v4*",levels:["low","high","xhigh"]},{provider:"minimax-code",pattern:"MiniMax-M3.1*",levels:["low","medium","high","xhigh","max"]},{provider:"minimax-code",pattern:"MiniMax-M3",levels:["none","high"]},{provider:"minimax-code-global",pattern:"MiniMax-M3.1*",levels:["low","medium","high","xhigh","max"]},{provider:"minimax-code-global",pattern:"MiniMax-M3",levels:["none","high"]}];function N(e,t){if("kiro"===e&&null===function(e){if("string"!=typeof e)return null;let t=e.toLowerCase().replace(/-/g,".");if(/(?:^|[/.])gpt[/.]5[/.]6(?:[/.]|$)/.test(t))return"reasoning";if(!t.includes("claude"))return null;let s=function(e){if("string"!=typeof e)return null;let t=e.toLowerCase().replace(/-/g,".").match(/(?:^|[/.])claude(?:[/.][a-z]+)*[/.](\d+)(?:[/.](\d+))?(?:[/.]|$)/);return t?{major:Number(t[1]),minor:void 0===t[2]?null:Number(t[2])}:null}(e);if(!s)return null;let{major:i,minor:a}=s;return i<4||4===i&&(null===a||a<=5||null!==a&&a>=1e3)?null:"output_config"}(t))return null;let s=(0,h.nl)(e,t);if(!s.reasoning)return null;let i=String(t||"").replace(/\([^()]+\)\s*$/,""),a="codex"===e?(0,f.SM)("cx").find(e=>e.id===i)?.thinkingLevels:null,r=k.find(s=>(!s.provider||s.provider===e)&&(0,x.gH)(s.pattern,t)),l=a||r?.levels||b[s.thinkingFormat]||g;return!1===s.thinkingCanDisable&&(l=l.filter(e=>"none"!==e)),l}var C=s(11059),S=s(929),$=s(73006);let A=new Map;async function T(e){if(!e?.url||!e?.type)return[];let t=A.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let i=(await s.json()).data??[];return A.set(e.url,{data:i,expiresAt:Date.now()+6e5}),i}catch{return[]}}function _({customModels:e=[],modelAliases:t={},providerAlias:s,builtInModels:i=[],type:a="llm",includeLegacyAliases:r=!0}){let l=new Set(i.map(e=>e.id)),n=new Set,o=[];for(let t of e){if(!t?.id||t.providerAlias!==s)continue;let e=t?.kind||t?.type||"llm";if(a&&e!==a||l.has(t.id))continue;let i=`${s}/${t.id}`;n.has(i)||(n.add(i),o.push({id:t.id,name:t.name||t.id,fullModel:i,source:"custom",type:e}))}if(!r)return o;let d=`${s}/`;for(let[e,s]of Object.entries(t||{})){if("string"!=typeof s||!s.startsWith(d))continue;let t=s.slice(d.length);!t||l.has(t)||n.has(s)||(n.add(s),o.push({id:t,alias:e,fullModel:s,source:"legacyAlias",type:a||"llm"}))}return o}var O=s(14051),P=s.n(O);function I({model:e,fullModel:t,alias:s,copied:r,onCopy:l,testStatus:n,isCustom:o,isFree:d,onDeleteAlias:c,onTest:m,isTesting:u,onDisable:h,caps:x,thinkingSuffix:f}){let g=f?`${t}(${f})`:t,y="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,i.jsx)("div",{className:`group w-full sm:w-auto min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,i.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(0,i.jsx)(a.default,{className:"shrink-0 text-base mt-0.5 sm:mt-0",style:y?{color:y}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,i.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,i.jsx)("code",{className:"w-fit max-w-full break-all rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px] sm:truncate",children:g}),(0,i.jsxs)("span",{className:"flex min-w-0 items-center text-[9px] gap-1 pl-1",children:[e.name&&(0,i.jsx)("span",{className:"break-all sm:truncate text-[9px] italic text-text-muted/70",children:e.name}),(0,i.jsx)(p.nh,{caps:x,colorOverride:"text-text-muted/70",size:12})]})]}),(0,i.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 sm:gap-1",children:[m&&(0,i.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,i.jsx)("button",{onClick:m,disabled:u,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${u?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,i.jsx)(a.default,{className:"text-sm",style:u?{animation:"spin 1s linear infinite"}:void 0,children:u?"progress_activity":"science"})}),(0,i.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:u?"Testing...":"Test"})]}),(0,i.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,i.jsx)("button",{onClick:()=>l(g,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,i.jsx)(a.default,{className:"text-sm",children:r===`model-${e.id}`?"check":"content_copy"})}),(0,i.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:r===`model-${e.id}`?"Copied!":"Copy"})]}),o?(0,i.jsx)("button",{onClick:c,className:"rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,i.jsx)(a.default,{className:"text-sm",children:"close"})}):h?(0,i.jsx)("button",{onClick:h,className:"rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,i.jsx)(a.default,{className:"text-sm",children:"close"})}):null]})]})})}I.propTypes={model:P().shape({id:P().string.isRequired}).isRequired,fullModel:P().string.isRequired,alias:P().string,copied:P().string,onCopy:P().func.isRequired,testStatus:P().oneOf(["ok","error"]),isCustom:P().bool,isFree:P().bool,onDeleteAlias:P().func,onTest:P().func,isTesting:P().bool,onDisable:P().func,caps:P().object,thinkingSuffix:P().string},P().string.isRequired,P().string.isRequired,P().string,P().func.isRequired,P().func.isRequired,P().func,P().oneOf(["ok","error"]),P().bool,P().string.isRequired,P().object.isRequired,P().arrayOf(P().object),P().string,P().func.isRequired,P().func.isRequired,P().func.isRequired,P().func.isRequired;var E=s(48187),D=s.n(E);function R({modelId:e,fullModel:t,copied:s,onCopy:r,onDeleteAlias:l,onTest:n,testStatus:o,isTesting:d}){let c="ok"===o?"var(--pos)":"error"===o?"var(--danger)":void 0;return(0,i.jsxs)("div",{className:D().modelRow,children:[(0,i.jsx)(a.default,{className:"text-base text-text-muted",style:c?{color:c}:void 0,children:"ok"===o?"check_circle":"error"===o?"cancel":"smart_toy"}),(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,i.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1 mt-1",children:[(0,i.jsx)("code",{className:"min-w-0 text-xs text-text-muted font-mono break-all",children:t}),(0,i.jsxs)("div",{className:"relative group/btn",children:[(0,i.jsx)("button",{onClick:()=>r(t,`model-${e}`),className:D().iconButton,"aria-label":`Copy ${t}`,title:`Copy ${t}`,children:(0,i.jsx)(a.default,{className:"text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,i.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),n&&(0,i.jsxs)("div",{className:"relative group/btn",children:[(0,i.jsx)("button",{onClick:n,disabled:d,className:D().iconButton,"aria-label":`Test ${e}`,title:`Test ${e}`,children:(0,i.jsx)(a.default,{className:"text-sm",style:d?{animation:"spin 1s linear infinite"}:void 0,children:d?"progress_activity":"science"})}),(0,i.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:d?"Testing...":"Test"})]})]})]}),(0,i.jsx)("button",{onClick:l,className:`${D().iconButton} ${D().error}`,"aria-label":`Remove ${e}`,title:"Remove model",children:(0,i.jsx)(a.default,{className:"text-sm",children:"delete"})})]})}function z({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:a,copied:l,onCopy:n,onDeleteAlias:o,onAddCustomModel:d,onDeleteCustomModel:c,connections:m,isAnthropic:u}){let[h,x]=(0,r.useState)(""),[f,g]=(0,r.useState)(!1),[y,v]=(0,r.useState)(!1),[b,j]=(0,r.useState)(null),[w,k]=(0,r.useState)({}),N=async t=>{if(!b){j(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),i=await s.json();k(e=>({...e,[t]:i.ok?"ok":"error"}))}catch{k(e=>({...e,[t]:"error"}))}finally{j(null)}}},C=_({customModels:a,modelAliases:s,providerAlias:e,type:"llm"}),S=async()=>{if(!h.trim()||f)return;let e=h.trim();if(C.some(t=>t.id===e))return void alert("Model already exists for this provider.");g(!0);try{await d(e),x("")}catch(e){console.log("Error adding model:",e)}finally{g(!1)}},$=async()=>{if(y)return;let e=m.find(e=>!1!==e.isActive);if(e){v(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||"Failed to import models");let i=s.models||[];if(0===i.length)return void alert("No models returned from /models.");let a=0;for(let e of i){let t=e.id||e.name||e.model;t&&(C.some(e=>e.id===t)||(await d(t),a+=1))}0===a&&alert("No new models were added.")}catch(e){console.log("Error importing models:",e)}finally{v(!1)}}},A=m.some(e=>!1!==e.isActive);return(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsxs)("p",{className:D().description,children:["Add ",u?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,i.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,i.jsx)(p.pd,{className:"flex-[1_1_200px] min-w-0",label:"Model ID",id:"new-compatible-model-input",type:"text",value:h,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&S(),placeholder:u?"claude-3-opus-20240229":"gpt-4o"}),(0,i.jsx)(p.$n,{size:"sm",variant:"contrast",icon:"add",onClick:S,disabled:!h.trim()||f,children:f?"Adding...":"Add"}),(0,i.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"download",onClick:$,disabled:!A||y,children:y?"Importing...":"Import from /models"})]}),!A&&(0,i.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),C.length>0&&(0,i.jsx)("div",{className:"flex min-w-0 flex-col",children:C.map(({id:s,alias:a,source:r})=>(0,i.jsx)(R,{modelId:s,fullModel:`${t}/${s}`,copied:l,onCopy:n,onDeleteAlias:()=>"custom"===r?c(s):o(a),onTest:m.length>0?()=>N(s):void 0,testStatus:w[s],isTesting:b===s},`${r}-${e}/${s}`))})]})}z.propTypes={providerStorageAlias:P().string.isRequired,providerDisplayAlias:P().string.isRequired,modelAliases:P().object.isRequired,customModels:P().arrayOf(P().object),copied:P().string,onCopy:P().func.isRequired,onDeleteAlias:P().func.isRequired,onAddCustomModel:P().func.isRequired,onDeleteCustomModel:P().func.isRequired,connections:P().arrayOf(P().shape({id:P().string,isActive:P().bool})).isRequired,isAnthropic:P().bool};var M=s(47650),q=s(70217);function U({until:e}){let[t,s]=(0,r.useState)("");return((0,r.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let i=Math.floor(t/1e3);if(i<60)s(`${i}s`);else if(i<3600)s(`${Math.floor(i/60)}m ${i%60}s`);else{let e=Math.floor(i/3600),t=Math.floor(i%3600/60);s(`${e}h ${t}m`)}};t();let i=setInterval(t,1e3);return()=>clearInterval(i)},[e]),t)?(0,i.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}U.propTypes={until:P().string.isRequired};var K=s(66119);function J({connection:e,proxyPools:t,isOAuth:s,isFirst:l,isLast:n,onMoveUp:o,onMoveDown:d,onToggleActive:c,onUpdateProxy:m,onEdit:u,onDelete:h,oneByOneStatus:x=null,autoPing:f=null}){let[g,y]=(0,r.useState)(!1),[v,b]=(0,r.useState)(!1),j=(0,r.useRef)(null),w=(0,r.useRef)(null),[k,N]=(0,r.useState)(null),C=new Map((t||[]).map(e=>[e.id,e])),S=e.providerSpecificData?.proxyPoolId||null,$=S?C.get(S):null,A=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,T=!!S||A,_=$?`Pool: ${$.name}`:S?`Pool: ${S} (inactive/missing)`:A?`Legacy: ${e.providerSpecificData?.connectionProxyUrl}`:"",O=(()=>{if(!f)return"";let e=[];return(f.reactiveOn&&e.push("On reset"),f.scheduleOn&&e.push(`Scheduled (${f.scheduleSummary||"active"})`),e.length>0)?`Auto-ping active: ${e.join(" + ")}. Click to configure.`:"codex"===f.provider?"Auto-starts the next 5h Codex window after reset or on schedule. Click to configure.":"Auto-starts a new window on quota reset or fixed schedule. Click to configure."})(),P="";if($?.proxyUrl||e.providerSpecificData?.connectionProxyUrl){let t=$?.proxyUrl||e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);P=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{P=t}}let I=$?.noProxy||e.providerSpecificData?.connectionNoProxy||"",E="default";$?.isActive===!0?E="success":(S||A)&&(E="error"),(0,r.useEffect)(()=>{if(!g)return;let e=e=>{j.current?.contains(e.target)||w.current?.contains(e.target)||y(!1)},t=()=>y(!1);return document.addEventListener("mousedown",e),window.addEventListener("resize",t),document.addEventListener("scroll",t,!0),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("resize",t),document.removeEventListener("scroll",t,!0)}},[g]);let R=async e=>{b(!0);try{await m("__none__"===e?null:e)}finally{b(!1),y(!1)}},z=e.authType||(s?"oauth":"apikey"),L="oauth"===z,F="cookie"===z,B=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(L?"OAuth Account":F?"Cookie Account":"API Key"),H=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,[W,G]=(0,r.useState)(!1),Z=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,r.useEffect)(()=>{let t=()=>{G(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=Z?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[Z]);let Q="unavailable"!==e.testStatus||W?e.testStatus:"active",V=()=>(0,q.g)(e.isActive,Q),X=()=>x?"success"===x.state?"success":"failed"===x.state?"error":"testing"===x.state?"primary":"default":"default",Y=()=>x?"queued"===x.state?"queued":"testing"===x.state?"testing":"success"===x.state?"success":"failed"===x.state?x.error?`failed: ${x.error}`:"failed":null:null;return(0,i.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,i.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,i.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,i.jsx)("button",{"aria-label":`Move ${B} up`,onClick:o,disabled:l,className:`p-0.5 rounded ${l?"text-text-muted/30 cursor-not-allowed":"hover:bg-surface-2 text-text-muted hover:text-text-main"}`,children:(0,i.jsx)(a.default,{className:"text-sm",children:"keyboard_arrow_up"})}),(0,i.jsx)("button",{"aria-label":`Move ${B} down`,onClick:d,disabled:n,className:`p-0.5 rounded ${n?"text-text-muted/30 cursor-not-allowed":"hover:bg-surface-2 text-text-muted hover:text-text-main"}`,children:(0,i.jsx)(a.default,{className:"text-sm",children:"keyboard_arrow_down"})})]}),(0,i.jsx)(a.default,{className:"shrink-0 text-base text-text-muted",children:F?"cookie":L?"lock":"key"}),(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)("p",{className:"text-sm font-medium truncate",children:B}),H&&(0,i.jsx)("p",{className:"text-xs text-text-muted truncate",children:H}),(0,i.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",children:[(0,i.jsx)(K.A,{variant:V(),className:"error"===V()?D().errorBadge:void 0,children:!1===e.isActive?"disabled":Q||"Unknown"}),(0,i.jsx)(K.A,{dot:!1,children:L?"OAuth":F?"Cookie":"API Key"}),T&&(0,i.jsx)(K.A,{variant:E,dot:!1,children:"Proxy"}),W&&!1!==e.isActive&&(0,i.jsx)(U,{until:Z}),e.lastError&&!1!==e.isActive&&(0,i.jsx)("span",{className:`max-w-full truncate text-xs sm:max-w-[300px] ${D().error}`,title:e.lastError,children:e.lastError}),(0,i.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,i.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),Y()&&(0,i.jsx)(K.A,{variant:"primary"===X()?"default":X(),dot:!1,children:Y()})]}),T&&(0,i.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,i.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:_,children:_}),P&&(0,i.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:P}),I&&(0,i.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:I,children:["no_proxy: ",I]})]})]})]}),(0,i.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,i.jsxs)("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[(t||[]).length>0&&(0,i.jsxs)("div",{children:[(0,i.jsxs)("button",{ref:w,onClick:()=>{if(g)return void y(!1);let e=w.current?.getBoundingClientRect();if(!e)return void y(!0);let s=((t?.length||0)+1)*34+8,i=window.innerHeight-e.bottom,a=i<s&&e.top>i;N({position:"fixed",right:window.innerWidth-e.right,...a?{bottom:window.innerHeight-e.top+4,maxHeight:Math.max(e.top-8,120)}:{top:e.bottom+4,maxHeight:Math.max(i-8,120)}}),y(!0)},className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-surface-2 ${T?"text-text-main":"text-text-muted hover:text-text-main"}`,disabled:v,children:[(0,i.jsx)(a.default,{className:"text-[18px]",children:v?"progress_activity":"lan"}),(0,i.jsx)("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),g&&(0,M.createPortal)((0,i.jsxs)("div",{ref:j,style:k,className:"z-50 max-w-[78vw] min-w-[160px] overflow-y-auto rounded-lg border border-border bg-bg py-1 shadow-lg",children:[(0,i.jsx)("button",{onClick:()=>R("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${!S?"text-primary font-medium":"text-text-main"}`,children:"None"}),(t||[]).map(e=>(0,i.jsx)("button",{onClick:()=>R(e.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${S===e.id?"text-primary font-medium":"text-text-main"}`,children:e.name},e.id))]}),document.body)]}),f&&(0,i.jsx)(p.m_,{text:O,children:(0,i.jsxs)("button",{onClick:f.onConfigure,className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-surface-2 ${f.isActive?"text-text-main":"text-text-muted hover:text-text-main"}`,children:[(0,i.jsx)(a.default,{className:"text-[18px]",children:"bolt"}),(0,i.jsx)("span",{className:"text-[10px] leading-tight",children:"Auto-ping"})]})}),(0,i.jsx)("button",{onClick:u,className:D().iconButton,"aria-label":`Edit ${B}`,title:`Edit ${B}`,children:(0,i.jsx)(a.default,{className:"text-[18px]",children:"edit"})}),(0,i.jsx)("button",{onClick:h,className:`${D().iconButton} ${D().error}`,"aria-label":`Delete ${B}`,title:`Delete ${B}`,children:(0,i.jsx)(a.default,{className:"text-[18px]",children:"delete"})})]}),(0,i.jsx)(p.lM,{size:"sm",checked:e.isActive??!0,"aria-label":`${!1===e.isActive?"Enable":"Disable"} ${B}`,onChange:c,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}function L(e,t,s={}){let{isCloudflareAi:i=!1}=s,a=new Set((Array.isArray(t)?t:[]).map(e=>"string"==typeof e?e.toLowerCase():"")),r=[];for(let t of e){let e,s="string"==typeof t?t.trim():"";if(!s)continue;let l=function(e,t={}){let{isCloudflareAi:s=!1}=t,i=e.split("|");if(s&&i.length>=3){let e=i[0].trim();return{baseName:e||"Key",apiKey:i.slice(1,-1).join("|").trim(),providerSpecificData:{accountId:i[i.length-1].trim()}}}return i.length>=2?{baseName:i[0].trim()||"Key",apiKey:i.slice(1).join("|").trim()}:{baseName:"Key",apiKey:i[0].trim()}}(s,{isCloudflareAi:i});if(!l||!l.apiKey)continue;let n=l.baseName,o=1;for(;e=`${n} ${o}`,a.has(e.toLowerCase());)o+=1;a.add(e.toLowerCase());let d={name:e,apiKey:l.apiKey,skipped:!1};l.providerSpecificData&&(d.providerSpecificData=l.providerSpecificData),r.push(d)}return r}J.propTypes={connection:P().shape({id:P().string,name:P().string,email:P().string,displayName:P().string,modelLockUntil:P().string,testStatus:P().string,isActive:P().bool,lastError:P().string,priority:P().number,globalPriority:P().number}).isRequired,proxyPools:P().arrayOf(P().shape({id:P().string,name:P().string,proxyUrl:P().string,noProxy:P().string,isActive:P().bool})),isOAuth:P().bool.isRequired,isFirst:P().bool.isRequired,isLast:P().bool.isRequired,onMoveUp:P().func.isRequired,onMoveDown:P().func.isRequired,onToggleActive:P().func.isRequired,onUpdateProxy:P().func,onEdit:P().func.isRequired,onDelete:P().func.isRequired,oneByOneStatus:P().shape({state:P().string,error:P().string}),autoPing:P().shape({isActive:P().bool,provider:P().string,reactiveOn:P().bool,scheduleOn:P().bool,scheduleSummary:P().string,onConfigure:P().func})};let F=`name1|sk-key1
2
- name2|sk-key2
3
- sk-key-only-auto-named`;function B({isOpen:e,provider:t,providerName:s,isCompatible:a,isAnthropic:l,authType:n,authHint:o,website:d,proxyPools:c,error:u,existingNames:h,onSave:x,onBulkDone:f,onClose:g}){let y="__none__",v="ollama-local"===t,b="cookie"===n,j="xai"===t&&!b,w=b?"Cookie Value":"qoder"===t||"qoder-cn"===t?"Personal Access Token (PAT)":"API Key",k="azure"===t,N="cloudflare-ai"===t,C=m.Q2?.[t]?.credentialForm==="aws",S=m.Q2?.[t]?.apiKeyOptionalWith||null,$=m.Q2?.[t]?.regions||null,A=m.Q2?.[t]?.defaultRegion||$?.[0]?.id||"",[T,_]=(0,r.useState)({name:"",apiKey:"",defaultModel:"",priority:1,proxyPoolId:y,ollamaHostUrl:""}),[O,P]=(0,r.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[I,E]=(0,r.useState)({accountId:""}),[R,z]=(0,r.useState)({profile:"",region:"",accessKeyId:"",sessionToken:""}),[M,q]=(0,r.useState)(A),[U,J]=(0,r.useState)(!1),[H,W]=(0,r.useState)(null),[G,Z]=(0,r.useState)(!1),Q=N?`name1|sk-key1|acc123456
4
- name2|sk-key2|def789012
5
- sk-key-only-auto-named`:"qoder"===t||"qoder-cn"===t?`name1|pt-xxxxx
6
- name2|pt-yyyyy
7
- pt-only-auto-named`:F,[V,X]=(0,r.useState)("single"),[Y,ee]=(0,r.useState)(""),[et,es]=(0,r.useState)(null),[ei,ea]=(0,r.useState)(""),[er,el]=(0,r.useState)(null),en=()=>{if(v&&T.ollamaHostUrl.trim())return{baseUrl:T.ollamaHostUrl.trim()};if(k)return{azureEndpoint:O.azureEndpoint,apiVersion:O.apiVersion,deployment:O.deployment,organization:O.organization};if(N)return{accountId:I.accountId};if(C){let e={};return R.profile.trim()&&(e.profile=R.profile.trim()),R.region.trim()&&(e.region=R.region.trim()),R.accessKeyId.trim()&&(e.accessKeyId=R.accessKeyId.trim()),R.sessionToken.trim()&&(e.sessionToken=R.sessionToken.trim()),Object.keys(e).length?e:void 0}if($&&M)return{region:M}},eo=()=>{let e=en();return!!(S&&e?.[S])||(C?!!T.apiKey&&!!e?.accessKeyId:!!T.apiKey)},ed=async()=>{J(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:T.apiKey,providerSpecificData:en()})}),s=await e.json();W(s.valid?"success":"failed")}catch{W("failed")}finally{J(!1)}},ec=async()=>{if(t&&(v||eo())&&(v||T.name)&&(!a||T.defaultModel.trim())){Z(!0);try{let e=!1;try{J(!0),W(null);let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:T.apiKey,providerSpecificData:en()})});e=!!(await s.json()).valid,W(e?"success":"failed")}catch{W("failed")}finally{J(!1)}await x({name:T.name||(v?"Ollama Local":""),apiKey:T.apiKey,defaultModel:a?T.defaultModel.trim():void 0,priority:T.priority,proxyPoolId:T.proxyPoolId===y?null:T.proxyPoolId,testStatus:e?"active":"unknown",providerSpecificData:en()})}finally{Z(!1)}}},ep=async()=>{let e=Y.split("\n");if(!e.length)return;let s=L(e,h,{isCloudflareAi:N});if(!s.length)return;Z(!0),es(null);let i=0,a=0;for(let e of s)try{let s=!1;try{let i=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e.apiKey})});s=!!(await i.json().catch(()=>({}))).valid}catch{s=!1}(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e.apiKey,name:e.name,priority:1,testStatus:s?"active":"unknown",...e.providerSpecificData?{providerSpecificData:e.providerSpecificData}:{}})})).ok?i++:a++}catch{a++}Z(!1),es({success:i,failed:a}),i>0&&f&&f()},em=async()=>{let e=function(e){let t,s=e=>({entries:[],provider:null,skipped:0,error:e});try{t=JSON.parse(e)}catch{return s("Invalid JSON.")}let i=Array.isArray(t)?t:t?.keys;if(!Array.isArray(i))return s('JSON must contain a "keys" array (or be an array of entries).');let a=[],r=0;for(let e of i){let t="string"==typeof e?.apiKey?e.apiKey.trim():"",s="string"==typeof e?.name?e.name.trim():"";if(!t||e?.isActive===!1){r+=1;continue}a.push({name:s,apiKey:t})}return!a.length&&r>0?s("No usable keys found (all entries empty or inactive)."):{entries:a,provider:"string"==typeof t?.provider?t.provider:null,skipped:r,error:null}}(ei);if(e.error)return void el({error:e.error});if(!e.entries.length)return;Z(!0),el(null);let s=L(e.entries.map(e=>e.name?`${e.name}|${e.apiKey}`:e.apiKey),h,{isCloudflareAi:N}),i=0,a=0,r=async e=>{try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e})});return!!(await s.json().catch(()=>({}))).valid}catch{return!1}};for(let e=0;e<s.length;e+=4){let l=s.slice(e,e+4),n=await Promise.all(l.map(e=>r(e.apiKey)));for(let e=0;e<l.length;e++){let s=l[e];try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:s.apiKey,name:s.name,priority:1,testStatus:n[e]?"active":"unknown",...s.providerSpecificData?{providerSpecificData:s.providerSpecificData}:{}})})).ok?i++:a++}catch{a++}}}Z(!1),el({success:i,failed:a,skipped:e.skipped}),i>0&&f&&f()};return t?(0,i.jsx)(p.aF,{isOpen:e,title:`Add ${s||t} ${w}`,onClose:g,className:D().dialog,children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[!C&&(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(p.$n,{size:"sm",variant:"single"===V?"contrast":"ghost","aria-pressed":"single"===V,onClick:()=>{X("single"),es(null),el(null)},children:"Single"}),(0,i.jsx)(p.$n,{size:"sm",variant:"bulk"===V?"contrast":"ghost","aria-pressed":"bulk"===V,onClick:()=>{X("bulk"),es(null),el(null)},children:"Bulk Add"}),(0,i.jsx)(p.$n,{size:"sm",variant:"json"===V?"contrast":"ghost","aria-pressed":"json"===V,onClick:()=>{X("json"),es(null),el(null)},children:"Import JSON"})]}),"json"===V&&(0,i.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,i.jsxs)("p",{className:"text-xs text-text-muted",children:["Paste the JSON produced by another provider's ",(0,i.jsx)("strong",{children:"Extract Keys"})," button (","{",'"keys": [',"apiKey","]","}","). Inactive and empty entries are skipped; names are kept, missing names are auto-numbered."]}),(0,i.jsx)("textarea",{className:"w-full font-mono resize-y min-h-[160px]","aria-label":"Extracted keys JSON",placeholder:'{\n "provider": "commandcode",\n "keys": [{ "name": "Key 1", "apiKey": "user_..." }]\n}',value:ei,onChange:e=>ea(e.target.value)}),er&&(0,i.jsx)("div",{className:`text-xs font-medium ${er.error||er.failed>0?"text-[var(--warn)]":D().success}`,role:"status",children:er.error?`✗ ${er.error}`:`✓ ${er.success} added${er.failed>0?`, ✗ ${er.failed} failed`:""}${er.skipped>0?`, ${er.skipped} skipped`:""}`}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(p.$n,{onClick:em,variant:"contrast",fullWidth:!0,disabled:G||!ei.trim(),children:G?"Importing...":"Import Keys"}),(0,i.jsx)(p.$n,{onClick:g,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"bulk"===V&&(0,i.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,i.jsx)("p",{className:"text-xs text-text-muted",children:N?(0,i.jsxs)(i.Fragment,{children:["One key per line. Format: ",(0,i.jsx)("code",{children:"name|apiKey|accountId"})," or just ",(0,i.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}):"qoder"===t||"qoder-cn"===t?(0,i.jsxs)(i.Fragment,{children:["One PAT per line. Format: ",(0,i.jsx)("code",{children:"name|pt-..."})," or just ",(0,i.jsx)("code",{children:"pt-..."})," (auto-named by index)."]}):(0,i.jsxs)(i.Fragment,{children:["One key per line. Format: ",(0,i.jsx)("code",{children:"name|apiKey"})," or just ",(0,i.jsx)("code",{children:"apiKey"})," (auto-named by index)."]})}),(0,i.jsx)("textarea",{className:"w-full font-mono resize-y min-h-[140px]","aria-label":"API keys to add in bulk",placeholder:Q,value:Y,onChange:e=>ee(e.target.value)}),et&&(0,i.jsxs)("div",{className:`text-xs font-medium ${et.failed>0?"text-[var(--warn)]":D().success}`,role:"status",children:["✓ ",et.success," added",et.failed>0?`, ✗ ${et.failed} failed`:""]}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(p.$n,{onClick:ep,variant:"contrast",fullWidth:!0,disabled:G||!Y.trim(),children:G?"Adding...":"Add All Keys"}),(0,i.jsx)(p.$n,{onClick:g,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===V&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(p.pd,{label:"Name",value:T.name,onChange:e=>_({...T,name:e.target.value}),placeholder:v?"Ollama Local":"Production Key"}),v&&(0,i.jsxs)("div",{className:D().fieldGroup,children:[(0,i.jsx)(p.pd,{label:"Ollama Host URL",value:T.ollamaHostUrl,onChange:e=>_({...T,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,i.jsx)("div",{className:"pt-6",children:(0,i.jsx)(p.$n,{onClick:ed,disabled:U||G,variant:"secondary",children:U?"Checking...":"Check"})})]}),!v&&(0,i.jsxs)("div",{className:D().fieldGroup,children:[(0,i.jsx)(p.pd,{label:w,type:b?"text":"password",value:T.apiKey,onChange:e=>_({...T,apiKey:e.target.value}),placeholder:b?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":j?"xai-...":"qoder"===t||"qoder-cn"===t?"pt-...":"",className:"flex-1"}),(0,i.jsx)("div",{className:"pt-6",children:(0,i.jsx)(p.$n,{onClick:ed,disabled:!eo()||U||G,variant:"secondary",children:U?"Checking...":"Check"})})]}),j&&(0,i.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),b&&o&&(0,i.jsxs)("p",{className:"text-xs text-text-muted",children:[o,d&&(0,i.jsxs)(i.Fragment,{children:[" ",(0,i.jsxs)("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",d.replace(/^https?:\/\//,"")]})]})]}),$&&(0,i.jsx)(p.l6,{label:"Region",value:M,onChange:e=>q(e.target.value),options:$.map(e=>({value:e.id,label:e.label}))}),a&&(0,i.jsx)(p.pd,{label:"Default Model",value:T.defaultModel,onChange:e=>_({...T,defaultModel:e.target.value}),placeholder:l?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),v&&(0,i.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,i.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,i.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),H&&(0,i.jsx)(K.A,{variant:"success"===H?"success":"error",className:"success"===H?void 0:D().errorBadge,children:"success"===H?"Valid":"Invalid"}),u&&(0,i.jsx)("p",{className:`text-xs break-words ${D().error}`,role:"alert",children:u}),a&&(0,i.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),N&&(0,i.jsxs)("div",{className:D().settingsGroup,children:[(0,i.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,i.jsx)(p.pd,{label:"Account ID",value:I.accountId,onChange:e=>E({...I,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,i.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,i.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),C&&(0,i.jsxs)("div",{className:D().settingsGroup,children:[(0,i.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"AWS Bedrock Credentials"}),(0,i.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,i.jsx)(p.pd,{label:"AWS Profile (SSO — recommended)",value:R.profile,onChange:e=>z({...R,profile:e.target.value}),placeholder:"my-sso-profile"}),(0,i.jsx)(p.pd,{label:"Region",value:R.region,onChange:e=>z({...R,region:e.target.value}),placeholder:"us-east-1"})]}),(0,i.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Set a profile from ",(0,i.jsx)("code",{children:"~/.aws/config"})," and leave the API key empty, then run"," ",(0,i.jsxs)("code",{children:["aws sso login --profile ",R.profile||"my-sso-profile"]}),". Credentials refresh automatically."]}),(0,i.jsxs)("div",{className:"flex flex-col gap-3 mt-4",children:[(0,i.jsx)(p.pd,{label:"Access Key ID (only for static keys)",value:R.accessKeyId,onChange:e=>z({...R,accessKeyId:e.target.value}),placeholder:"AKIA..."}),(0,i.jsx)(p.pd,{label:"Session Token (only for temporary ASIA… keys)",type:"password",value:R.sessionToken,onChange:e=>z({...R,sessionToken:e.target.value}),placeholder:"FwoGZXIvYXdz..."})]}),(0,i.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["For static keys instead: put the AWS ",(0,i.jsx)("strong",{children:"secret"})," access key in the API Key field above and the access key id here. A profile, if set, takes precedence."]})]}),k&&(0,i.jsxs)("div",{className:D().settingsGroup,children:[(0,i.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,i.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,i.jsx)(p.pd,{label:"Azure Endpoint",value:O.azureEndpoint,onChange:e=>P({...O,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,i.jsx)(p.pd,{label:"Deployment Name",value:O.deployment,onChange:e=>P({...O,deployment:e.target.value}),placeholder:"gpt-4"}),(0,i.jsx)(p.pd,{label:"API Version",value:O.apiVersion,onChange:e=>P({...O,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,i.jsx)(p.pd,{label:"Organization",value:O.organization,onChange:e=>P({...O,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,i.jsx)(p.pd,{label:"Priority",type:"number",value:T.priority,onChange:e=>_({...T,priority:Number.parseInt(e.target.value)||1})}),(0,i.jsx)(p.l6,{label:"Proxy Pool",value:T.proxyPoolId,onChange:e=>_({...T,proxyPoolId:e.target.value}),options:[{value:y,label:"None"},...(c||[]).map(e=>({value:e.id,label:e.name}))],placeholder:"None"}),0===(c||[]).length&&(0,i.jsx)("p",{className:"text-xs text-text-muted",children:"No active proxy pools available. Create one in Proxy Pools page first."}),(0,i.jsx)("p",{className:"text-xs text-text-muted",children:"Legacy manual proxy fields are still accepted by API for backward compatibility."}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(p.$n,{onClick:ec,variant:"contrast",fullWidth:!0,disabled:G||!v&&(!T.name||!eo())||a&&!T.defaultModel.trim()||k&&(!O.azureEndpoint||!O.deployment||!O.organization)||N&&!I.accountId,children:G?"Saving...":"Save"}),(0,i.jsx)(p.$n,{onClick:g,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function H({isOpen:e,node:t,onSave:s,onClose:a,isAnthropic:l}){let[n,o]=(0,r.useState)({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[d,c]=(0,r.useState)(!1),[m,u]=(0,r.useState)(""),[h,x]=(0,r.useState)(""),[f,g]=(0,r.useState)(!1),[y,v]=(0,r.useState)(null);(0,r.useEffect)(()=>{t&&o({name:t.name||"",prefix:t.prefix||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[t,l]);let b=async()=>{if(n.name.trim()&&n.prefix.trim()&&n.baseUrl.trim()){c(!0);try{let e={name:n.name,prefix:n.prefix,baseUrl:n.baseUrl};l||(e.apiType=n.apiType),await s(e)}finally{c(!1)}}},j=async()=>{g(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:m,type:l?"anthropic-compatible":"openai-compatible",modelId:h.trim()||void 0})}),t=await e.json();v(t.valid?"success":"failed")}catch{v("failed")}finally{g(!1)}};return t?(0,i.jsx)(p.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:a,className:D().dialog,children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsx)(p.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),(0,i.jsx)(p.pd,{label:"Prefix",value:n.prefix,onChange:e=>o({...n,prefix:e.target.value}),placeholder:l?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!l&&(0,i.jsx)(p.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,i.jsx)(p.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),(0,i.jsxs)("div",{className:D().fieldGroup,children:[(0,i.jsx)(p.pd,{label:"API Key (for Check)",type:"password",value:m,onChange:e=>u(e.target.value),className:"flex-1"}),(0,i.jsx)("div",{className:"pt-6",children:(0,i.jsx)(p.$n,{onClick:j,disabled:!m||f||!n.baseUrl.trim(),variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,i.jsx)(p.pd,{label:"Model ID (optional)",value:h,onChange:e=>x(e.target.value),placeholder:"e.g. my-model-id",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),y&&(0,i.jsx)(K.A,{variant:"success"===y?"success":"error",className:"success"===y?void 0:D().errorBadge,children:"success"===y?"Valid":"Invalid"}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(p.$n,{onClick:b,variant:"contrast",fullWidth:!0,disabled:!n.name.trim()||!n.prefix.trim()||!n.baseUrl.trim()||d,children:d?"Saving...":"Save"}),(0,i.jsx)(p.$n,{onClick:a,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}B.propTypes={isOpen:P().bool.isRequired,provider:P().string,providerName:P().string,isCompatible:P().bool,isAnthropic:P().bool,authType:P().string,authHint:P().string,website:P().string,proxyPools:P().arrayOf(P().shape({id:P().string,name:P().string})),error:P().string,existingNames:P().arrayOf(P().string),onSave:P().func.isRequired,onBulkDone:P().func,onClose:P().func.isRequired},H.propTypes={isOpen:P().bool.isRequired,node:P().shape({id:P().string,name:P().string,prefix:P().string,apiType:P().string,baseUrl:P().string}),onSave:P().func.isRequired,onClose:P().func.isRequired,isAnthropic:P().bool};let W=()=>Object.fromEntries(Object.keys(u.bs).map(e=>[e,!1]));function G({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:l,onClose:n}){let[o,d]=(0,r.useState)(""),[c,m]=(0,r.useState)(W),[h,x]=(0,r.useState)(null),[f,g]=(0,r.useState)(""),[y,v]=(0,r.useState)(!1),[b,j]=(0,r.useState)("");(0,r.useEffect)(()=>{e&&(d(""),m(W()),j(""),x(null),g(""))},[e]);let w=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},k=async()=>{let e=w(o.trim());if(e){x("testing"),g("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),i=await s.json();x(i.ok?"ok":"error"),g(i.error||"")}catch(e){x("error"),g(e.message)}}},N=async()=>{let e=w(o.trim());if(e&&!y){v(!0);try{await l(e,c,c.stt?b:null)}finally{v(!1)}}};return(0,i.jsx)(p.aF,{isOpen:e,onClose:n,title:"Add Custom Model",children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)("input",{type:"text",value:o,onChange:e=>{d(e.target.value),x(null),g("")},onKeyDown:e=>{"Enter"===e.key&&k()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,i.jsx)(p.$n,{variant:"secondary",icon:"science",loading:"testing"===h,onClick:k,disabled:!o.trim()||"testing"===h,children:"testing"===h?"Testing...":"Test"})]}),(0,i.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,i.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:w(o.trim())||"model-id"})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Capabilities"}),(0,i.jsx)("div",{className:"flex flex-wrap gap-4",children:Object.entries(u.bs).map(([e,t])=>(0,i.jsx)(p.lM,{checked:!!c[e],onChange:t=>m(s=>({...s,[e]:t})),label:t.label,description:t.desc,size:"sm"},e))})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)(p.lM,{checked:!!c.stt,onChange:e=>{m(t=>({...t,stt:e})),e||j("")},label:"Speech to text",description:"Transcribes audio via /v1/audio/transcriptions",size:"sm"}),c.stt&&(0,i.jsx)("div",{className:"mt-3",children:(0,i.jsx)(p.l6,{label:"Transport",value:b,onChange:e=>j(e.target.value),placeholder:"Provider default (REST)",options:u.vp.map(e=>({value:e,label:u.qw[e].label})),hint:"Realtime transport marker for the STT dispatcher. Empty keeps the provider's REST format."})})]}),"ok"===h&&(0,i.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,i.jsx)(a.default,{className:"text-base",children:"check_circle"}),"Model is reachable"]}),"error"===h&&(0,i.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,i.jsx)(a.default,{className:"text-base shrink-0",children:"cancel"}),(0,i.jsx)("span",{children:f||"Model not reachable"})]}),(0,i.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,i.jsx)(p.$n,{onClick:n,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,i.jsx)(p.$n,{onClick:N,fullWidth:!0,size:"sm",disabled:!o.trim()||y,children:y?"Adding...":"Add Model"})]})]})})}G.propTypes={isOpen:P().bool.isRequired,providerAlias:P().string.isRequired,providerDisplayAlias:P().string.isRequired,onSave:P().func.isRequired,onClose:P().func.isRequired};let Z=`[
8
- {
9
- "accessToken": "eyJhbGc...",
10
- "refreshToken": "rt_...",
11
- "idToken": "eyJhbGc...",
12
- "email": "user@example.com"
13
- }
14
- ]`;function Q({isOpen:e,onClose:t,onSuccess:s}){let[a,l]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(""),[m,u]=(0,r.useState)(null),h=()=>{n||(l(""),c(""),u(null),t())},x=async()=>{var e;let t;c(""),u(null);let i=a.trim();if(!i)return;try{t=JSON.parse(i)}catch(e){c(`${(0,$.Tl)("Invalid JSON")}: ${e.message}`);return}let r=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!r||0===r.length)return void c((0,$.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:r})}),t=await e.json();if(!e.ok)return void c(t?.error||`Request failed: ${e.status}`);u(t),t.success>0&&"function"==typeof s&&s()}catch(e){c(e.message||(0,$.Tl)("Request failed"))}finally{o(!1)}},f=m?.results?.filter(e=>!e.ok)||[];return(0,i.jsx)(p.aF,{isOpen:e,title:(0,$.Tl)("Bulk Add Codex Accounts"),onClose:h,children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsx)("p",{className:"text-xs text-text-muted",children:(0,$.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,i.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:Z,value:a,onChange:e=>l(e.target.value),disabled:n}),d&&(0,i.jsx)("p",{className:"text-xs text-red-500 break-words",children:d}),m&&(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,i.jsxs)("div",{className:`text-sm font-medium ${m.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",m.success," ",(0,$.Tl)("added"),m.failed>0?`, ✗ ${m.failed} ${(0,$.Tl)("failed")}`:""]}),f.length>0&&(0,i.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,i.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(p.$n,{onClick:x,fullWidth:!0,disabled:n||!a.trim(),children:n?(0,$.Tl)("Importing..."):(0,$.Tl)("Import All")}),(0,i.jsx)(p.$n,{onClick:h,variant:"ghost",fullWidth:!0,disabled:n,children:(0,$.Tl)("Close")})]})]})})}Q.propTypes={isOpen:P().bool.isRequired,onClose:P().func.isRequired,onSuccess:P().func};let V=`[
15
- {
16
- "access_token": "eyJ0eXAiOiJhdCtqd3Qi...",
17
- "refresh_token": "LZhriF9bf88pPykpXCuZ9...",
18
- "id_token": "eyJ0eXAiOiJKV1QiLCJhbGci...",
19
- "email": "account1@example.com"
20
- },
21
- {
22
- "access_token": "eyJ0eXAiOiJhdCtqd3Qi...",
23
- "refresh_token": "LZhriF9bf88pPykpXCuZ9...",
24
- "id_token": "eyJ0eXAiOiJKV1QiLCJhbGci...",
25
- "email": "account2@example.com"
26
- }
27
- ]`;function X(e){let t,s=e.trim();if(!s)return[];try{t=JSON.parse(s)}catch(e){try{let e=s;e.startsWith("[")||((e=e.replace(/\}\s*,\s*\{/g,"},{").replace(/\}\s*\{/g,"},{")).endsWith(",")&&(e=e.slice(0,-1)),e=`[${e}]`),t=JSON.parse(e)}catch{throw e}}if(Array.isArray(t))return t;if(t&&"object"==typeof t)return Array.isArray(t.accounts)?t.accounts:[t];throw Error("Input must be a JSON object or array of objects")}function Y({isOpen:e,onClose:t,onSuccess:s}){let[l,n]=(0,r.useState)(""),[o,d]=(0,r.useState)(!1),[c,m]=(0,r.useState)(""),[u,h]=(0,r.useState)(null),[x,f]=(0,r.useState)(!1),[g,y]=(0,r.useState)(null),v=(0,r.useRef)(null),b=()=>{o||(n(""),m(""),h(null),y(null),f(!1),t())},j=async e=>{if(!e||0===e.length)return;m("");let t=Array.from(e).filter(e=>e.name.endsWith(".json")||"application/json"===e.type||""===e.type);if(0===t.length)return void m((0,$.Tl)("Please select valid .json files"));try{let e=[];for(let s of t){let t=await s.text(),i=X(t);Array.isArray(i)?e.push(...i):i&&e.push(i)}if(0===e.length)return void m((0,$.Tl)("No accounts found in selected files"));n(JSON.stringify(e,null,2)),y({filesCount:t.length,accountsCount:e.length})}catch(e){m(`${(0,$.Tl)("Error reading files")}: ${e.message}`)}},w=async()=>{let e;m(""),h(null);try{e=X(l)}catch(e){m(`${(0,$.Tl)("Invalid JSON")}: ${e.message}`);return}if(!e||0===e.length)return void m((0,$.Tl)("No accounts found in input"));d(!0);try{let t=await fetch("/api/oauth/grok-cli/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:e})}),i=await t.json();if(!t.ok)return void m(i?.error||`Request failed: ${t.status}`);h(i),i.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,$.Tl)("Request failed"))}finally{d(!1)}},k=u?.results?.filter(e=>!e.ok)||[];return(0,i.jsx)(p.aF,{isOpen:e,title:(0,$.Tl)("Bulk Add Grok CLI Accounts"),onClose:b,children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,i.jsx)("p",{className:"text-xs text-text-muted",children:(0,$.Tl)("Upload multiple .json files or paste JSON array / object.")}),(0,i.jsx)("input",{ref:v,type:"file",accept:".json,application/json",multiple:!0,className:"hidden",onChange:e=>{j(e.target.files),e.target&&(e.target.value="")}}),(0,i.jsx)(p.$n,{type:"button",size:"sm",variant:"secondary",icon:"upload_file",onClick:()=>v.current?.click(),disabled:o,children:(0,$.Tl)("Upload JSON Files")})]}),(0,i.jsxs)("div",{onDragOver:e=>{e.preventDefault(),f(!0)},onDragLeave:e=>{e.preventDefault(),f(!1)},onDrop:e=>{e.preventDefault(),f(!1),e.dataTransfer?.files?.length>0&&j(e.dataTransfer.files)},className:`relative rounded border transition-colors ${x?"border-primary bg-primary/10 ring-2 ring-primary/30":"border-accent/30 bg-sidebar"}`,children:[(0,i.jsx)("textarea",{className:"w-full rounded bg-transparent p-2.5 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:V,value:l,onChange:e=>{n(e.target.value),y(null)},disabled:o}),x&&(0,i.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-sidebar/90 rounded pointer-events-none backdrop-blur-xs",children:[(0,i.jsx)(a.default,{className:"text-3xl text-primary mb-1",children:"upload_file"}),(0,i.jsx)("span",{className:"text-sm font-medium text-primary",children:(0,$.Tl)("Drop .json files here")})]})]}),g&&(0,i.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-green-400 font-medium bg-green-500/10 border border-green-500/20 px-2.5 py-1.5 rounded",children:[(0,i.jsx)(a.default,{className:"text-sm",children:"check_circle"}),(0,i.jsxs)("span",{children:[(0,$.Tl)("Loaded")," ",g.accountsCount," ",(0,$.Tl)("account(s) from")," ",g.filesCount," ",(0,$.Tl)("file(s)")]})]}),c&&(0,i.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),u&&u.failed>0&&(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,i.jsxs)("div",{className:"text-sm font-medium text-yellow-400",children:["✗ ",u.failed," ",(0,$.Tl)("failed")]}),k.length>0&&(0,i.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:k.map(e=>(0,i.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(p.$n,{onClick:w,fullWidth:!0,disabled:o||!l.trim(),children:o?(0,$.Tl)("Importing..."):(0,$.Tl)("Import All")}),(0,i.jsx)(p.$n,{onClick:b,variant:"ghost",fullWidth:!0,disabled:o,children:(0,$.Tl)("Close")})]})]})})}var ee=s(65921);let et=["host","content-length","content-type","connection","transfer-encoding","authorization","cookie"],es=/^[A-Za-z0-9-]+$/;function ei({providerId:e}){let t=(0,ee.i)(),[s,l]=(0,r.useState)(!1),[n,o]=(0,r.useState)([{name:"",value:""}]),[d,c]=(0,r.useState)({}),[m,u]=(0,r.useState)(!1),[h,x]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let t=!1;return fetch(`/api/providers/${e}/overrides`,{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>{if(t||!e)return;let s=e.builtinHeaders||{},i=Object.entries({...s,...e.headers||{}}).map(([e,t])=>({name:e,value:t}));c(s),o(i.length?i:[{name:"",value:""}]),u(Object.keys(e.headers||{}).length>0)}).catch(()=>{}),()=>{t=!0}},[e]);let f=(e,t,s)=>{o(i=>i.map((i,a)=>a===e?{...i,[t]:s}:i))},g=(0,r.useCallback)(async()=>{let s={};for(let e of n.filter(e=>e.name.trim())){let i=e.name.trim();if(!es.test(i))return void t.error(`Invalid header name: ${i}`);if(et.includes(i.toLowerCase()))return void t.error(`Header ${i} cannot be overridden`);if(i in s)return void t.error(`Duplicate header name: ${i}`);e.value!==d[i]&&(s[i]=e.value)}x(!0);try{let i=await fetch(`/api/providers/${e}/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({headers:s})});if(!i.ok){let e=await i.json().catch(()=>({}));t.error(e.error||"Failed to save");return}u(Object.keys(s).length>0),t.success("Custom headers saved")}finally{x(!1)}},[n,d,e,t]);return 0!==Object.keys(d).length||m?(0,i.jsxs)(p.Zp,{className:`ui-card ${D().panel}`,children:[(0,i.jsxs)("button",{type:"button",onClick:()=>l(e=>!e),"aria-expanded":s,className:"flex w-full items-center justify-between text-left",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsxs)("span",{className:"ui-eyebrow",children:[(0,i.jsx)(a.default,{className:"text-[16px]",children:"tune"}),"Custom Headers"]}),m&&(0,i.jsx)(K.A,{variant:"success",children:"Active"})]}),(0,i.jsx)(a.default,{className:"text-[16px] text-text-muted",children:s?"expand_less":"expand_more"})]}),s&&(0,i.jsxs)("div",{className:"mt-3 border-t border-border pt-3",children:[(0,i.jsx)("div",{className:"flex flex-col gap-2",children:n.map((e,t)=>{let s=e.name.trim()in d&&e.value!==d[e.name.trim()];return(0,i.jsxs)("div",{className:D().customHeaderRow,children:[(0,i.jsx)(p.pd,{"aria-label":`Header ${t+1} name`,value:e.name,onChange:e=>f(t,"name",e.target.value),placeholder:"Header-Name",spellCheck:!1,className:"min-w-0"}),(0,i.jsx)(p.pd,{"aria-label":`Header ${t+1} value`,value:e.value,onChange:e=>f(t,"value",e.target.value),placeholder:"Value",spellCheck:!1,title:s?"Overridden":e.name.trim()in d?"Registry default":"",className:"min-w-0",inputClassName:s?"border-[var(--warn)]":void 0}),(0,i.jsx)("button",{type:"button",title:"Remove header","aria-label":`Remove header ${t+1}`,onClick:()=>o(e=>e.length>1?e.filter((e,s)=>s!==t):[{name:"",value:""}]),className:`${D().iconButton} ${D().error}`,children:(0,i.jsx)(a.default,{className:"text-[16px]",children:"delete"})})]},t)})}),(0,i.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2",children:[(0,i.jsx)(p.$n,{size:"sm",variant:"ghost",icon:"add",onClick:()=>o(e=>[...e,{name:"",value:""}]),children:"Add header"}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(p.$n,{size:"sm",variant:"secondary",disabled:h,onClick:()=>{o(Object.entries(d).map(([e,t])=>({name:e,value:t})))},children:"Reset"}),(0,i.jsx)(p.$n,{size:"sm",variant:"contrast",disabled:h,onClick:g,children:h?"Saving...":"Save"})]})]})]})]}):null}ei.propTypes={providerId:P().string.isRequired};var ea=s(97132),er=s(93195);let el={claude:"claudeAutoPing",codex:"codexAutoPing"};function en(){let e,t,s,n,h,x=(0,l.useParams)(),f=(0,l.useRouter)(),g=x.id,{getCaps:y}=(0,S.y)(),[v,b]=(0,r.useState)([]),[j,w]=(0,r.useState)(!0),[k,A]=(0,r.useState)(null),[O,P]=(0,r.useState)([]),[E,R]=(0,r.useState)(!1),[M,q]=(0,r.useState)(!1),[U,K]=(0,r.useState)(!1),[L,F]=(0,r.useState)(!1),[W,Z]=(0,r.useState)(""),[V,X]=(0,r.useState)(!1),[ee,et]=(0,r.useState)(!1),[es,en]=(0,r.useState)(!1),[eo,ed]=(0,r.useState)(!1),[ec,ep]=(0,r.useState)(!1),[em,eu]=(0,r.useState)(null),[eh,ex]=(0,r.useState)({}),[ef,eg]=(0,r.useState)([]),[ey,ev]=(0,r.useState)(!1),[eb,ej]=(0,r.useState)({}),[ew,ek]=(0,r.useState)(""),[eN,eC]=(0,r.useState)(()=>new Set),[eS,e$]=(0,r.useState)(!1),[eA,eT]=(0,r.useState)([]),[e_,eO]=(0,r.useState)("__none__"),[eP,eI]=(0,r.useState)(!1),[eE,eD]=(0,r.useState)(null),[eR,ez]=(0,r.useState)(""),[eM,eq]=(0,r.useState)(null),[eU,eK]=(0,r.useState)("auto"),[eJ,eL]=(0,r.useState)({enabled:!1,connections:{},schedules:{}}),[eF,eB]=(0,r.useState)(null),[eH,eW]=(0,r.useState)([]),[eG,eZ]=(0,r.useState)([]),[eQ,eV]=(0,r.useState)(null),[eX,eY]=(0,r.useState)([]),[e0,e1]=(0,r.useState)([]),[e2,e5]=(0,r.useState)(null),[e3,e4]=(0,r.useState)(!1),[e6,e9]=(0,r.useState)(!1),[e7,e8]=(0,r.useState)(!1),[te,tt]=(0,r.useState)(null),[ts,ti]=(0,r.useState)({}),[ta,tr]=(0,r.useState)(null),tl=(0,r.useRef)(!1),[tn,to]=(0,r.useState)(!1),[td,tc]=(0,r.useState)(!1),{copied:tp,copy:tm}=(0,C.C)(),tu="ag_risk_confirmed",th=()=>{R(!0)},tx=()=>{"antigravity"===g&&"true"!==window.localStorage.getItem(tu)?e4(!0):"xiaomi-mimo"===g?q(!0):tb?th():(Z(""),F(!0))},tf=()=>{Z(""),F(!0)},tg=()=>{tb?tx():tf()},ty=k?{id:k.id,name:k.name||("anthropic-compatible"===k.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===k.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===k.type?"AC":"OC",apiType:k.apiType,baseUrl:k.baseUrl,type:k.type}:m.zN[g]||m.fg[g]||m.IS[g]||m.nJ[g]||m.br[g],tv=ty?.authModes||[],tb=!!m.zN[g]||!!m.IS[g]||tv.includes("oauth"),tj=!!m.fg[g]||tv.includes("apikey"),tw=!!m.IS[g]?.noAuth,tk=(0,u.KC)(g),tN=("cursor"===g||"zed"===g)&&eG.length>0?eG:tk,tC=(0,m.wG)(g),tS=(0,m.mq)(g),t$=(0,m.gb)(g),tA=tS||t$,tT=!tA&&tb&&tj,t_="xai"===g?"Grok Build OAuth":"grok-cli"===g?"Grok CLI Device Login":"kimi"===g?"Kimi Coding OAuth":"OAuth",tO="xai"===g?"xAI API Key":"kimi"===g?"Kimi API Key":"qoder"===g||"qoder-cn"===g?"PAT":"API Key",tP=e=>{if(!eU||"auto"===eU)return null;let t=N(g,e);return t&&t.includes(eU)?eU:null},tI=tA?g:tC,tE=(()=>{let e=new Set,t=new Set,s=s=>{if(!s||t.has(s))return;t.add(s);let i=N(g,s);i&&i.forEach(t=>{"none"!==t&&e.add(t)})};for(let e of tN)s(e.id);for(let e of eX)s(e.id);for(let e of ef)e.providerAlias===tI&&"llm"===(e.kind||e.type||"llm")&&s(e.id);return e.size?["auto",...e]:null})(),tD=tA?k?.prefix||g:tC,tR=(0,r.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tI)}`,{cache:"no-store"}),t=await e.json();e.ok&&e1(t.ids||[])}catch(e){console.log("Error fetching disabled models:",e)}},[tI]),tz=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tI,ids:[e]})})).ok&&await tR()}catch(e){console.log("Error disabling model:",e)}},tM=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tI)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tR()}catch(e){console.log("Error enabling model:",e)}},tq=async e=>{e.length&&e5({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{e5(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tI,ids:e})})).ok&&await tR()}catch(e){console.log("Error disabling all models:",e)}}})},tU=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tI)}`,{method:"DELETE"})).ok&&await tR()}catch(e){console.log("Error enabling all models:",e)}},tK=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&ex(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},[]),tJ=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&eg(t.models||[])}catch(e){console.log("Error fetching custom models:",e)}},[]);(0,r.useEffect)(()=>{"kilocode"===g&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eY(e.models)}).catch(()=>{})},[g]);let tL=(0,r.useCallback)(async()=>{try{let[e,t,s,i]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),a=await e.json(),r=await t.json(),l=await s.json(),n=i.ok?await i.json():{};if(e.ok){let e=(a.connections||[]).filter(e=>e.provider===g);b(e)}s.ok&&P(l.proxyPools||[]);let o=(n.providerStrategies||{})[g]||{};eD(o.fallbackStrategy||null),ez(null!=o.stickyRoundRobinLimit?String(o.stickyRoundRobinLimit):"1"),eq(!1!==o.demoteOnError&&null);let d=(n.providerThinking||{})[g]||{};eK(d.mode||"auto");let c=el[g],p=c&&n[c]||{};if(eL({enabled:!0===p.enabled,connections:p.connections||{},schedules:p.schedules||{}}),t.ok){let e=(r.nodes||[]).find(e=>e.id===g)||null;if(!e&&tA)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===g)||null))break}A(e)}}catch(e){console.log("Error fetching connections:",e)}finally{w(!1)}},[g,tA]),tF=async e=>{try{let t=await fetch(`/api/provider-nodes/${g}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(A(s.node),await tL(),ed(!1))}catch(e){console.log("Error updating provider node:",e)}},tB=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),i=(s.ok?await s.json():{}).providerStrategies||{},a={};e&&(a.fallbackStrategy=e),"round-robin"===e&&""!==t&&(a.stickyRoundRobinLimit=Number(t)||3);let r={...i};0===Object.keys(a).length?delete r[g]:r[g]=a,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:r})})}catch(e){console.log("Error saving provider strategy:",e)}},tH=async e=>{eq(!!e&&null);try{let t=await fetch("/api/settings",{cache:"no-store"}),s=(t.ok?await t.json():{}).providerStrategies||{},i={...s[g]||{}};e?delete i.demoteOnError:i.demoteOnError=!1;let a={...s};0===Object.keys(i).length?delete a[g]:a[g]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:a})})}catch(e){console.log("Error saving demoteOnError toggle:",e)}},tW=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[g]={mode:e}:delete s[g],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){console.log("Error saving thinking config:",e)}},tG=async e=>{let t=el[g];if(t){eL(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){console.log("Error saving auto-ping config:",e)}}};(0,r.useEffect)(()=>{tL(),tK(),tJ(),tR()},[tL,tK,tJ,tR]),(0,r.useEffect)(()=>{if("cursor"!==g&&"zed"!==g)return void eZ([]);let e=v.find(e=>!1!==e.isActive);if(!e?.id){eZ([]),"zed"===g&&eV(null);return}let t=!1;return"zed"===g&&eV(null),fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(async e=>({ok:e.ok,data:await e.json().catch(()=>null)})).then(({ok:e,data:s})=>{if(!t){if(e&&Array.isArray(s?.models)&&s.models.length>0){eZ(s.models),"zed"===g&&s?.warning&&eV(s.warning);return}"zed"===g&&(eZ([]),eV(s?.warning||s?.error||"Zed returned no live models."))}}).catch(()=>{t||"zed"!==g||(eZ([]),eV("Failed to reach the Zed model catalog."))}),()=>{t=!0}},[g,v]),(0,r.useEffect)(()=>{let e=(m.zN[g]||m.fg[g]||m.IS[g]||m.nJ[g])?.modelsFetcher;e&&T(e).then(eW)},[g]);let tZ=async(e,t,s=tC)=>{let i=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:i,alias:t})});if(e.ok)await tK();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},tQ=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tK()}catch(e){console.log("Error deleting alias:",e)}},tV=async(e,t="llm",s=tI,i,a)=>{try{let r=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t,...i?{caps:i}:{},...a?{transport:a}:{}})});if(r.ok)await tJ(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await r.json();alert(e.error||"Failed to add custom model")}}catch(e){console.log("Error adding custom model:",e)}},tX=async(e,t="llm",s=tI)=>{try{let i=new URLSearchParams({providerAlias:s,id:e,type:t});(await fetch(`/api/models/custom?${i}`,{method:"DELETE"})).ok&&(await tJ(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){console.log("Error deleting custom model:",e)}},tY=async()=>{if(tn)return;let e=v.find(e=>!1!==e.isActive);if(!e)return void alert((0,$.Tl)("Please add an active Qoder connection first"));to(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||(0,$.Tl)("Failed to fetch models"));let i=s.models||[];if(0===i.length)return void alert((0,$.Tl)("No models returned"));let a=0;for(let e of i){let t=e.id||e.name;if(!t)continue;let s=t.replace(/^(qoder-cn|qoder)\//,"");ef.some(e=>e.providerAlias===tI&&e.id===s&&"llm"===(e.kind||e.type||"llm"))||Object.values(eh).includes(`${tI}/${s}`)||(await tV(s,"llm",tI),a+=1)}0===a?alert((0,$.Tl)("All models already exist, no new models added")):alert((0,$.Tl)("Successfully added")+` ${a} `+(0,$.Tl)("models"))}catch(e){console.log("Error importing Qoder models:",e),alert((0,$.Tl)("Error fetching models")+": "+e.message)}finally{to(!1)}},t0=async()=>{if(td)return;let e=v.find(e=>!1!==e.isActive);if(!e)return void alert((0,$.Tl)("Please add an active Cline connection first"));tc(!0);try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json();if(!t.ok)return void alert(s.error||(0,$.Tl)("Failed to fetch models"));let i=s.models||[];if(0===i.length)return void alert((0,$.Tl)("No models returned"));let a=0;for(let e of i){let t=e.id||e.name;t&&(ef.some(e=>e.providerAlias===tI&&e.id===t&&"llm"===(e.kind||e.type||"llm"))||Object.values(eh).includes(`${tI}/${t}`)||(await tV(t,"llm",tI),a+=1))}0===a?alert((0,$.Tl)("All models already exist, no new models added")):alert((0,$.Tl)("Successfully added")+` ${a} `+(0,$.Tl)("models"))}catch(e){console.log("Error importing Cline models:",e),alert((0,$.Tl)("Error fetching models")+": "+e.message)}finally{tc(!1)}},t1=async()=>{if(e6||0===v.length)return;let e=Object.fromEntries(v.map(e=>[e.id,{state:"queued",error:null}]));tl.current=!1,e9(!0),e8(!1),tt(null),ti(e),tr({total:v.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<v.length;e+=1){if(tl.current){tr({total:v.length,completed:e,passed:t,failed:s,stopped:!0});break}let i=v[e];tt(i.id),ti(e=>({...e,[i.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${i.id}/test`,{method:"POST"}),a=await e.json(),r=!!a.valid;r?t+=1:s+=1,ti(e=>({...e,[i.id]:{state:r?"success":"failed",error:r?null:a.error||null}}))}catch(e){s+=1,ti(t=>({...t,[i.id]:{state:"failed",error:e.message||"Test failed"}}))}tr({total:v.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<v.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{tt(null),e9(!1),e8(!1),tl.current=!1}},t2=async e=>{e5({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{e5(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&b(t=>t.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}}})},t5=()=>{tL(),R(!1)},t3=async e=>{Z("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:g,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tL(),F(!1);return}Z(s?.error||"Failed to save connection")}catch(e){console.log("Error saving connection:",e),Z("Failed to save connection")}},t4=async e=>{try{(await fetch(`/api/providers/${em.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tL(),en(!1))}catch(e){console.log("Error updating connection:",e)}},t6=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&b(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error updating connection status:",e)}},t9=async(e,t)=>{let s=[...v];[s[e],s[t]]=[s[t],s[e]],b(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){console.log("Error swapping priority:",e),await tL()}},t7=v.filter(e=>eA.includes(e.id)),t8=v.length>0&&eA.length===v.length;(0,r.useEffect)(()=>{eT(e=>e.filter(e=>v.some(t=>t.id===e)))},[v]),(()=>{if(0===t7.length)return;let e=new Set(t7.map(e=>e.providerSpecificData?.proxyPoolId||"__none__"));if(1===e.size){let t=[...e][0];if("__none__"===t)return;let s=O.find(e=>e.id===t);return s?.name}})();let se=()=>{eP||ep(!1)},st=async e=>{eI(!0);try{let t=0;for(let{connectionId:s,proxyPoolId:i}of e)try{(await fetch(`/api/providers/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:i})})).ok||(t+=1)}catch(e){console.log("Error applying proxy for",s,e),t+=1}t>0&&alert(`Updated with ${t} failed request(s).`),await tL(),ep(!1)}finally{eI(!1)}},ss=e=>st(v.map(t=>({connectionId:t.id,proxyPoolId:e}))),[si,sa]=(0,r.useState)(!1),sr=async()=>{if(!si){sa(!0);try{let e=await fetch(`/api/providers/${encodeURIComponent(g)}/connections/keys`),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||"Failed to export connection keys");let s=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download=`keys-${g}.json`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}catch(e){useNotificationStore.getState().error(e.message)}finally{sa(!1)}}},sl=(0,i.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03] max-h-[500px] overflow-y-auto pr-1",children:v.map((e,t)=>{let s;return(0,i.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,i.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,i.jsx)("input",{type:"checkbox",checked:(s=e.id,eA.includes(s)),onChange:()=>{var t;return t=e.id,void eT(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,i.jsx)("div",{className:"flex-1 min-w-0",children:(0,i.jsx)(J,{connection:e,proxyPools:O,isOAuth:tb,isFirst:0===t,isLast:t===v.length-1,onMoveUp:()=>t9(t,t-1),onMoveDown:()=>t9(t,t+1),onToggleActive:t=>t6(e.id,t),autoPing:el[g]&&"oauth"===e.authType?{isActive:!0===eJ.connections[e.id]||eJ.schedules?.[e.id]?.enabled===!0,reactiveOn:!0===eJ.connections[e.id],provider:g,scheduleOn:eJ.schedules?.[e.id]?.enabled===!0,scheduleSummary:(0,er.JW)(eJ.schedules?.[e.id]).join(" / "),onConfigure:()=>eB(e)}:null,onUpdateProxy:async t=>{try{(await fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:t||null})})).ok&&b(s=>s.map(s=>s.id===e.id?{...s,providerSpecificData:{...s.providerSpecificData,proxyPoolId:t||null}}:s))}catch(e){console.log("Error updating proxy:",e)}},onEdit:()=>{eu(e),en(!0)},onDelete:()=>t2(e.id),oneByOneStatus:ts[e.id]||null})})]},e.id)})}),sn=O.filter(e=>!0===e.isActive),so=(0,i.jsx)(p.aF,{isOpen:ec,onClose:se,title:`Apply Proxy (${v.length} connections)`,children:(0,i.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,i.jsxs)("div",{className:"flex flex-col",children:[(0,i.jsxs)("button",{onClick:()=>{let e=O.filter(e=>!0===e.isActive);return 0===e.length?void alert("No active proxy pools available."):st(v.map((t,s)=>({connectionId:t.id,proxyPoolId:e[s%e.length].id})))},disabled:eP||0===sn.length,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,i.jsx)(a.default,{className:"text-text-muted text-[18px]",children:"sync_alt"}),(0,i.jsx)("span",{className:"text-sm text-text-main",children:"One-to-one (rotate)"})]}),(0,i.jsxs)("button",{onClick:()=>ss(null),disabled:eP,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,i.jsx)(a.default,{className:"text-text-muted text-[18px]",children:"link_off"}),(0,i.jsx)("span",{className:"text-sm text-text-main",children:"None (unbind all)"})]}),O.map(e=>(0,i.jsxs)("button",{onClick:()=>ss(e.id),disabled:eP||!0!==e.isActive,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,i.jsx)(a.default,{className:"text-text-muted text-[18px]",children:"lan"}),(0,i.jsx)("span",{className:"truncate text-sm text-text-main",children:e.name}),!0!==e.isActive&&(0,i.jsx)("span",{className:"text-[10px] text-text-muted",children:"(inactive)"})]},e.id))]}),eP&&(0,i.jsx)("p",{className:"text-xs text-text-muted",children:"Applying..."}),(0,i.jsx)(p.$n,{onClick:se,variant:"ghost",fullWidth:!0,disabled:eP,children:"Cancel"})]})}),sd=async e=>{if(!eN.has(e)){eC(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tI}/${e}`})}),s=await t.json();ej(t=>({...t,[e]:s.ok?"ok":"error"})),ek(s.ok?"":s.error||"Model not reachable")}catch{ej(t=>({...t,[e]:"error"})),ek("Network error")}finally{eC(t=>{let s=new Set(t);return s.delete(e),s})}}};if(j)return(0,i.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,i.jsx)(p.Qv,{}),(0,i.jsx)(p.Qv,{})]});if(!ty)return(0,i.jsxs)("div",{className:"text-center py-20",children:[(0,i.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,i.jsx)(o(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]});let sc=()=>tS&&ty.apiType?"responses"===ty.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":t$?"/providers/anthropic-m.png":(0,c.HY)(ty.id);return(0,i.jsxs)("div",{className:`dashboard-surface ${D().page}`,children:[(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)(o(),{href:"/dashboard/providers",className:D().detailLink,children:[(0,i.jsx)(a.default,{className:"text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,i.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,i.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${ty.color}15`},children:ey||!sc()?(0,i.jsx)("span",{className:"text-sm font-bold",style:{color:ty.color},children:ty.textIcon||ty.id.slice(0,2).toUpperCase()}):(0,i.jsx)(d.default,{src:sc(),alt:ty.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>{(0,c.Kw)(ty.id),ev(!0)},loading:"lazy",decoding:"async"})}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,i.jsx)("h1",{className:D().detailTitle,children:ty.name}),(ty.notice?.apiKeyUrl||ty.notice?.signupUrl||ty.website)&&(0,i.jsxs)("a",{href:ty.notice?.apiKeyUrl||ty.notice?.signupUrl||ty.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-text-muted hover:text-text-main hover:underline inline-flex items-center gap-1",children:[(0,i.jsx)(a.default,{className:"text-sm",children:"open_in_new"}),ty.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,i.jsxs)("p",{className:D().description,children:[v.length," connection",1===v.length?"":"s"]})]})]})]}),ty.deprecated&&(0,i.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,i.jsx)(a.default,{className:"text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,i.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:ty.deprecationNotice})]}),ty.notice?.text&&!ty.deprecated&&(0,i.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,i.jsx)(a.default,{className:"text-[16px] text-blue-500 shrink-0",children:"info"}),(0,i.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:ty.notice.text}),ty.notice.apiKeyUrl&&(0,i.jsx)("a",{href:ty.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),tA&&k&&(0,i.jsx)(p.Zp,{className:`ui-card ${D().panel}`,children:(0,i.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)("h2",{className:"ui-eyebrow",children:[(0,i.jsx)(a.default,{className:"text-[16px]",children:"api"}),t$?"Anthropic Compatible Details":"OpenAI Compatible Details"]}),(0,i.jsxs)("p",{className:`break-all mt-2 ${D().description}`,children:[t$?"Messages API":"responses"===k.apiType?"Responses API":"Chat Completions"," \xb7 ",(k.baseUrl||"").replace(/\/$/,""),"/",t$?"messages":"responses"===k.apiType?"responses":"chat/completions"]})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,i.jsx)(p.$n,{size:"sm",variant:"contrast",icon:"add",onClick:()=>{Z(""),F(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,i.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>ed(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,i.jsx)(p.$n,{size:"sm",variant:"ghost",icon:"delete",onClick:async()=>{e5({title:"Delete Compatible Node",message:`Delete this ${t$?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{e5(null);try{(await fetch(`/api/provider-nodes/${g}`,{method:"DELETE"})).ok&&f.push("/dashboard/providers")}catch(e){console.log("Error deleting provider node:",e)}}})},className:`w-full sm:w-auto ${D().error}`,children:"Delete"})]})]})}),tw?(0,i.jsx)(p.gw,{providerId:g}):(0,i.jsxs)(p.Zp,{className:`ui-card ${D().panel}`,children:[(0,i.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,i.jsxs)("h2",{className:"ui-eyebrow",children:[(0,i.jsx)(a.default,{className:"text-[16px]",children:"vpn_key"}),"Connections"]}),(0,i.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[v.some(e=>"apikey"===(e.authType||"apikey"))&&(0,i.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"download",onClick:sr,disabled:si,children:si?"Extracting...":"Extract Keys"}),v.length>0&&O.length>0&&(0,i.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>ep(!0),children:"Apply Proxy"}),v.length>0&&(0,i.jsxs)(i.Fragment,{children:[eA.length>0&&(0,i.jsxs)(p.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=eA.length;0!==e&&e5({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{e5(null);let e=0,t=[...eA];for(let s of t)try{(await fetch(`/api/providers/${s}`,{method:"DELETE"})).ok||(e+=1)}catch(t){console.log("Error deleting connection:",t),e+=1}b(e=>e.filter(e=>!t.includes(e.id))),eT([]),e>0&&alert(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",eA.length,")"]}),(0,i.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:t1,disabled:e6,children:e6?"Testing Connection One-by-One...":"Test Connection One-by-One"}),e6&&(0,i.jsx)(p.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{e6&&(tl.current=!0,e8(!0))},disabled:e7,children:e7?"Stopping...":"Stop"})]}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,i.jsx)(p.lM,{checked:"round-robin"===eE,onChange:e=>{let t=e?"round-robin":null,s=e?eR||"1":eR;e&&!eR&&ez("1"),eD(t),tB(t,s)}}),"round-robin"===eE&&(0,i.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,i.jsx)("span",{className:"text-xs text-text-muted",children:"Pool:"}),(0,i.jsx)("input",{type:"number",min:1,value:eR,onChange:e=>{var t;ez(t=e.target.value),tB("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Auto-demote on error"}),(0,i.jsx)(p.lM,{checked:null===eM||eM,onChange:tH})]})]})]}),0===v.length?(0,i.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 text-text-muted shrink-0",children:(0,i.jsx)(a.default,{className:"text-[18px]",children:tb?"lock":"key"})}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tT&&(0,i.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",t_," or ",tO,"."]})]})]}),(0,i.jsx)("div",{className:"flex gap-2",children:tT?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(p.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tx,children:t_}),(0,i.jsx)(p.$n,{size:"sm",variant:"contrast",icon:"key",onClick:tf,children:tO})]}):(0,i.jsxs)(i.Fragment,{children:[!tA&&"iflow"===g&&(0,i.jsx)(p.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>K(!0),children:"Cookie"}),"codex"===g&&(0,i.jsx)(p.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>X(!0),children:(0,$.Tl)("Bulk Add")}),"grok-cli"===g&&(0,i.jsx)(p.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>et(!0),children:(0,$.Tl)("Bulk Add")}),(0,i.jsx)(p.$n,{size:"sm",icon:"add",onClick:tg,children:tA?"Add API Key":"iflow"===g?"OAuth":"Add Connection"})]})})]}):(0,i.jsxs)(i.Fragment,{children:[ta&&(0,i.jsx)("div",{className:"mb-4 rounded-lg 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,i.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,i.jsxs)("span",{children:["Total: ",ta.total]}),(0,i.jsxs)("span",{children:["Completed: ",ta.completed]}),(0,i.jsxs)("span",{children:["Passed: ",ta.passed]}),(0,i.jsxs)("span",{children:["Failed: ",ta.failed]}),ta.stopped&&(0,i.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),e6&&te&&(0,i.jsxs)("span",{children:["Running: ",v.find(e=>e.id===te)?.name||te]})]})}),v.length>0&&(0,i.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,i.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,i.jsx)("input",{type:"checkbox",checked:t8,onChange:()=>{t8?eT([]):eT(v.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),sl,!tA&&(0,i.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===g&&(0,i.jsx)(p.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>K(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===g&&(0,i.jsx)(p.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>X(!0),title:(0,$.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,$.Tl)("Bulk Add")}),"grok-cli"===g&&(0,i.jsx)(p.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>et(!0),title:(0,$.Tl)("Bulk import Grok CLI accounts from JSON"),className:"w-full sm:w-auto",children:(0,$.Tl)("Bulk Add")}),tT?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(p.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tx,className:"w-full sm:w-auto",children:t_}),(0,i.jsx)(p.$n,{size:"sm",icon:"key",onClick:tf,className:"w-full sm:w-auto",children:tO})]}):(0,i.jsx)(p.$n,{size:"sm",icon:"add",onClick:tg,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,i.jsx)(ei,{providerId:g}),(0,i.jsxs)(p.Zp,{className:`ui-card ${D().panel}`,children:[(0,i.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsxs)("h2",{className:"ui-eyebrow",children:[(0,i.jsx)(a.default,{className:"text-[16px]",children:"smart_toy"}),"Available Models"]}),tE&&(0,i.jsx)("select",{value:eU,onChange:e=>{var t;eK(t=e.target.value),tW(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tE.map(e=>(0,i.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),!tA&&(e=[...tN,...eX.filter(e=>!tN.some(t=>t.id===e.id))].filter(e=>{let t=(0,u.CP)(e);return!t||"llm"===t}).map(e=>e.id).filter(e=>!e0.includes(e)),(0,i.jsxs)("div",{className:"flex gap-2",children:[e0.length>0&&(0,i.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tU,children:"Active All"}),e.length>0&&(0,i.jsx)(p.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tq(e),children:"Disable All"})]}))]}),!!ew&&(0,i.jsxs)("div",{className:"mb-3",children:[(0,i.jsx)("p",{className:"text-xs text-red-500 break-words",children:ew}),/RegionError|hosted in China|regionNotAllowed/i.test(ew)&&(s=(t="string"==typeof ew?ew:JSON.stringify(ew)).match(/https:\/\/opencode\.ai\/workspace\/[^\s"')]+/),n=t.match(/wrk_[0-9A-Za-z]+/),h=s?s[0].endsWith("/go")?s[0]:`${s[0]}/go`:n?`https://opencode.ai/workspace/${n[0]}/go`:"https://opencode.ai",(0,i.jsx)("div",{className:"mt-1.5",children:(0,i.jsxs)("a",{href:h,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-600 hover:bg-amber-500/20 dark:text-amber-400 transition-colors",children:[(0,i.jsx)("span",{children:"Allow China-hosted models"}),(0,i.jsx)(a.default,{className:"text-[13px]",children:"open_in_new"})]})}))]}),"zed"===g&&!!eQ&&(0,i.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:eQ}),(()=>{let e,t,s;if(tA)return(0,i.jsx)(z,{providerStorageAlias:tI,providerDisplayAlias:tD,modelAliases:eh,customModels:ef,copied:tp,onCopy:tm,onSetAlias:tZ,onDeleteAlias:tQ,onAddCustomModel:e=>tV(e,"llm",tI),onDeleteCustomModel:e=>tX(e,"llm",tI),connections:v,isAnthropic:t$});let r=[...tN,...eX.filter(e=>!tN.some(t=>t.id===e.id))].filter(e=>{let t=(0,u.CP)(e);return!t||"llm"===t}),l=new Set(e0),n=r.filter(e=>!l.has(e.id)),o=r.filter(e=>l.has(e.id)),d=_({customModels:ef,modelAliases:eh,providerAlias:tI,builtInModels:tN,type:"llm"});return(0,i.jsxs)("div",{className:"flex flex-wrap gap-3",children:[d.map(e=>(0,i.jsx)(I,{model:{id:e.id,name:e.name},fullModel:`${tD}/${e.id}`,alias:e.alias,copied:tp,onCopy:tm,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?tX(e.id,"llm",tI):tQ(e.alias)},testStatus:eb[e.id],onTest:v.length>0||tw?()=>sd(e.id):void 0,isTesting:eN.has(e.id),isCustom:!0,isFree:!1,caps:y(`${g}/${e.id}`),thinkingSuffix:tP(e.id)},`${e.source}-${e.fullModel}`)),n.map(e=>{let t=`${tI}/${e.id}`,s=`${g}/${e.id}`,a=Object.entries(eh).find(([,e])=>e===t||e===s)?.[0];return(0,i.jsx)(I,{model:e,fullModel:`${tD}/${e.id}`,alias:a,copied:tp,onCopy:tm,onSetAlias:t=>tZ(e.id,t,tI),onDeleteAlias:()=>tQ(a),testStatus:eb[e.id],onTest:v.length>0||tw?()=>sd(e.id):void 0,isTesting:eN.has(e.id),isFree:e.isFree,onDisable:()=>tz(e.id),caps:y(`${g}/${e.id}`),thinkingSuffix:tP(e.id)},e.id)}),(0,i.jsxs)("button",{onClick:()=>e$(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,i.jsx)(a.default,{className:"text-sm",children:"add"}),"Add Model"]}),("qoder"===g||"qoder-cn"===g)&&v.some(e=>!1!==e.isActive)&&(0,i.jsxs)("button",{onClick:tY,disabled:tn,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,i.jsx)(a.default,{className:"text-sm",style:tn?{animation:"spin 1s linear infinite"}:void 0,children:tn?"progress_activity":"download"}),tn?(0,$.Tl)("Fetching..."):(0,$.Tl)("Fetch Qoder Models")]}),("cline"===g||"clinepass"===g)&&v.some(e=>!1!==e.isActive)&&(0,i.jsxs)("button",{onClick:t0,disabled:td,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,i.jsx)(a.default,{className:"text-sm",style:td?{animation:"spin 1s linear infinite"}:void 0,children:td?"progress_activity":"download"}),td?(0,$.Tl)("Fetching..."):(0,$.Tl)("Import from /models")]}),eH.length>0&&(e=new Set([...Object.values(eh),...d.map(e=>e.fullModel)]),t=new Set(tN.map(e=>e.id)),0===(s=eH.filter(s=>!e.has(`${tI}/${s.id}`)&&!t.has(s.id))).length?null:(0,i.jsxs)("div",{className:"w-full mt-2",children:[(0,i.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,i.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,i.jsxs)("button",{onClick:async()=>{await tV(e.id,"llm",tI)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,i.jsx)(a.default,{className:"text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),o.length>0&&(0,i.jsxs)("div",{className:"w-full mt-2",children:[(0,i.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",o.length,"):"]}),(0,i.jsx)("div",{className:"flex flex-wrap gap-2",children:o.map(e=>(0,i.jsxs)("button",{onClick:()=>tM(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,i.jsx)(a.default,{className:"text-[13px]",children:"add"}),e.id]},e.id))})]})]})})()]}),so,"kiro"===g?(0,i.jsx)(p.Mh,{isOpen:E,providerInfo:ty,onSuccess:t5,onClose:()=>R(!1)}):"cursor"===g?(0,i.jsx)(p.G9,{isOpen:E,onSuccess:t5,onClose:()=>R(!1)}):"zed"===g?(0,i.jsx)(p.TE,{isOpen:E,providerInfo:ty,onSuccess:t5,onClose:()=>R(!1)}):"gitlab"===g?(0,i.jsx)(p.vj,{isOpen:E,providerInfo:ty,onSuccess:t5,onClose:()=>R(!1)}):(0,i.jsx)(p.LF,{isOpen:E,provider:g,providerInfo:ty,onSuccess:t5,onClose:()=>R(!1)}),(0,i.jsx)(p.LH,{isOpen:M,onSuccess:t5,onClose:()=>q(!1)}),"iflow"===g&&(0,i.jsx)(p.vE,{isOpen:U,onSuccess:()=>{tL(),K(!1)},onClose:()=>K(!1)}),(0,i.jsx)(B,{isOpen:L,provider:g,providerName:ty.name,isCompatible:tA,isAnthropic:t$,authType:ty?.authType,authHint:ty?.authHint,website:ty?.website,proxyPools:O,error:W,existingNames:v.map(e=>e.name).filter(Boolean),onSave:t3,onBulkDone:tL,onClose:()=>{Z(""),F(!1)}}),(0,i.jsx)(p.wI,{isOpen:es,connection:em,proxyPools:O,onSave:t4,onClose:()=>en(!1)}),tA&&(0,i.jsx)(H,{isOpen:eo,node:k,onSave:tF,onClose:()=>ed(!1),isAnthropic:t$}),!tA&&(0,i.jsx)(G,{isOpen:eS,providerAlias:tI,providerDisplayAlias:tD,onSave:async(e,t,s)=>{await tV(e,t?.stt?"stt":"llm",tI,t,s),e$(!1)},onClose:()=>e$(!1)}),"codex"===g&&(0,i.jsx)(Q,{isOpen:V,onClose:()=>X(!1),onSuccess:tL}),"grok-cli"===g&&(0,i.jsx)(Y,{isOpen:ee,onClose:()=>et(!1),onSuccess:tL}),eF&&(0,i.jsx)(ea.A,{isOpen:!!eF,onClose:()=>eB(null),connection:eF,reactive:!0===eJ.connections[eF.id],schedule:eJ.schedules?.[eF.id]||null,onSave:e=>((e,{reactive:t,schedule:s})=>{tG({...eJ,connections:{...eJ.connections,[e]:t},schedules:{...eJ.schedules,[e]:s}})})(eF.id,e)}),(0,i.jsx)(p.uo,{isOpen:e3,onClose:()=>e4(!1),onConfirm:()=>{(window.localStorage.setItem(tu,"true"),e4(!1),tb)?th():tf()},title:"Risk Notice",message:ty?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,i.jsx)(p.uo,{isOpen:!!e2,onClose:()=>e5(null),onConfirm:e2?.onConfirm,title:e2?.title||"Confirm",message:e2?.message,variant:"danger"})]})}},48187:e=>{e.exports={page:"providers_page__lNQhJ DashboardControls_formScope__ID02o",toolbar:"providers_toolbar__2pR_g",header:"providers_header__s_NP2",description:"providers_description__zL7w6",filter:"providers_filter__uXyjM",actions:"providers_actions__tZbB3",rowActions:"providers_rowActions__jo8WW",select:"providers_select__qT5m6",panel:"providers_panel__HhfEl",list:"providers_list__Xl0Bx",providerRow:"providers_providerRow__7w53x",modelRow:"providers_modelRow__BaZk7",providerLink:"providers_providerLink__p1_5n",providerIcon:"providers_providerIcon__4Smce",identity:"providers_identity__gc5tm",providerName:"providers_providerName__Q5P80",metadata:"providers_metadata__lljWr",providerAddress:"providers_providerAddress__S_6uZ",status:"providers_status__0o78C",iconButton:"providers_iconButton__wueX2 DashboardControls_iconButton__v_EJw",errorBadge:"providers_errorBadge__39MFD",dialog:"providers_dialog__P87TZ DashboardControls_dialog__YyPS4",success:"providers_success__dL3RB",error:"providers_error__yBcA8",empty:"providers_empty__cy1cY",emptyTitle:"providers_emptyTitle___2E_x",showMore:"providers_showMore__hmFpK",testRow:"providers_testRow__FX937",fieldGroup:"providers_fieldGroup__e_9HL",settingsGroup:"providers_settingsGroup__BKD1U",customHeaderRow:"providers_customHeaderRow__GyQ3r",detailTitle:"providers_detailTitle__uBT1b",detailLink:"providers_detailLink__0O8z2"}},70217:(e,t,s)=>{"use strict";function i(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}s.d(t,{g:()=>i})},93195:(e,t,s)=>{"use strict";function i(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}s.d(t,{JW:()=>o,Vm:()=>i,fB:()=>r,gy:()=>a,nz:()=>l});let a={anchor:"09:30",timezone:i(),windowHours:5,slotsPerDay:3};function r(e){let t=/^(\d{1,2}):(\d{2})$/.exec(String(e||"").trim());if(!t)return null;let s=Number(t[1]),i=Number(t[2]);return s>23||i>59?null:{hour:s,minute:i}}function l(e){return Math.max(1,Math.floor(24/e))}function n(e,t,s,i){let a="number"==typeof e?e:Number(e);return Number.isFinite(a)?Math.min(i,Math.max(s,a)):t}function o(e){let t=function(e){if(!e||!0!==e.enabled)return null;let t=r(e.anchor)||r(a.anchor),s=`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`,i=!function(e){if(!e||"string"!=typeof e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}(e.timezone)?a.timezone:e.timezone,o=n(e.windowHours,a.windowHours,.5,24),d=Math.round(n(e.slotsPerDay,a.slotsPerDay,1,l(o)));return{enabled:!0,anchor:s,timezone:i,windowHours:o,slotsPerDay:d}}(e);if(!t)return[];let{hour:s,minute:i}=r(t.anchor),o=60*s+i;return Array.from({length:t.slotsPerDay},(e,s)=>{let i=Math.round(o+s*t.windowHours*60)%1440;return`${String(Math.floor(i/60)).padStart(2,"0")}:${String(i%60).padStart(2,"0")}`})}},97132:(e,t,s)=>{"use strict";s.d(t,{A:()=>p});var i=s(95155),a=s(12115),r=s(14051),l=s.n(r),n=s(35497),o=s(31474),d=s(93195);let c=[{value:"off",label:"Off",icon:"block"},{value:"reset",label:"On reset",icon:"bolt"},{value:"schedule",label:"Schedule",icon:"schedule"}];function p({isOpen:e,onClose:t,onSave:s,connection:r,reactive:l=!1,schedule:m=null}){let[u,h]=(0,a.useState)(()=>({mode:m?.enabled===!0?"schedule":!0===l?"reset":"off",anchor:m?.anchor||d.gy.anchor,timezone:(0,d.Vm)(),windowHours:String(m?.windowHours??d.gy.windowHours),slotsPerDay:String(m?.slotsPerDay??d.gy.slotsPerDay)})),x=Number(u.windowHours),f=Number(u.slotsPerDay),g=!!(0,d.fB)(u.anchor),y=Number.isFinite(x)&&x>=.5&&x<=24,v=y?(0,d.nz)(x):24,b=Number.isInteger(f)&&f>=1&&f<=v,j=g&&y&&b,w="schedule"!==u.mode||j,k=j?(0,d.JW)({enabled:!0,...u,windowHours:x,slotsPerDay:f}):[],N=k.length&&y?(()=>{let{hour:e,minute:t}=(0,d.fB)(u.anchor),s=Math.round(60*e+t+f*x*60)%1440;return`${String(Math.floor(s/60)).padStart(2,"0")}:${String(s%60).padStart(2,"0")}`})():"",C=e=>h(t=>({...t,...e}));return(0,i.jsx)(n.aF,{isOpen:e,onClose:t,title:"Auto-ping settings",size:"lg",footer:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.$n,{variant:"secondary",onClick:t,children:"Cancel"}),(0,i.jsx)(n.$n,{onClick:()=>{w&&(s({reactive:"reset"===u.mode,schedule:"schedule"===u.mode?{enabled:!0,anchor:u.anchor,timezone:u.timezone,windowHours:x,slotsPerDay:f}:{enabled:!1}}),t())},disabled:!w,children:"Save"})]}),children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsxs)("p",{className:"text-sm text-text-muted",children:["Configure automated quota pings",r?.name?` for ${r.name}`:""," — pick one mode."]}),(0,i.jsx)("div",{className:"grid grid-cols-3 gap-1 rounded-[10px] bg-surface-2 p-1",children:c.map(e=>{let t=u.mode===e.value;return(0,i.jsxs)("button",{type:"button",onClick:()=>C({mode:e.value}),className:(0,o.cn)("flex h-9 items-center justify-center gap-1.5 rounded-[8px] px-3 text-sm font-medium transition-all",t?"bg-surface text-text-main shadow-sm":"text-text-muted hover:text-text-main"),children:[(0,i.jsx)("span",{className:"material-symbols-outlined text-[15px] leading-none",children:e.icon}),(0,i.jsx)("span",{children:e.label})]},e.value)})}),"reset"===u.mode&&(0,i.jsx)("p",{className:"text-xs text-text-muted",children:"Pings right after the 5h quota window resets, so a new window starts immediately."}),"schedule"===u.mode&&(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsx)("p",{className:"text-xs text-text-muted",children:"Pings at fixed local times so the 5h windows align with your workday."}),(0,i.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[(0,i.jsx)(n.pd,{label:"Anchor time",type:"time",value:u.anchor,onChange:e=>C({anchor:e.target.value}),error:g?"":"Use HH:MM",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"}),(0,i.jsx)(n.pd,{label:"Window (hours)",type:"number",min:"0.5",max:"24",step:"0.5",value:u.windowHours,onChange:e=>C({windowHours:e.target.value}),error:y?"":"0.5 – 24",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"}),(0,i.jsx)(n.pd,{label:"Pings per day",type:"number",min:"1",max:String(v),step:"1",value:u.slotsPerDay,onChange:e=>C({slotsPerDay:e.target.value}),error:b?"":`1 – ${v}`,hint:b?`Max ${v}`:"",inputClassName:"ring-1 ring-black/10 dark:ring-white/15"})]}),k.length>0&&(0,i.jsxs)("div",{className:"rounded-[10px] bg-surface-2 px-3 py-2.5",children:[(0,i.jsxs)("p",{className:"text-xs font-medium uppercase tracking-wide text-text-muted",children:["Daily slots (",u.timezone,")"]}),(0,i.jsx)("p",{className:"mt-1 text-sm font-medium text-text-main",children:k.join(" → ")}),(0,i.jsxs)("p",{className:"mt-1 text-xs text-text-muted",children:["Covers ",k[0]," – ",N,", then pauses until ",k[0]," next day."]})]})]})]})})}p.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onSave:l().func.isRequired,connection:l().object,reactive:l().bool,schedule:l().object}}},e=>{e.O(0,[3493,8679,1852,2904,6506,8500,3847,5772,1321,705,5497,8441,3794,7358],()=>e(e.s=34929)),_N_E=e.O()}]);