tokenhop 1.0.0 → 1.0.3

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 (622) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +4 -4
  3. package/app/.next-cli-build/build-manifest.json +3 -3
  4. package/app/.next-cli-build/prerender-manifest.json +3 -3
  5. package/app/.next-cli-build/react-loadable-manifest.json +43 -43
  6. package/app/.next-cli-build/required-server-files.json +1 -0
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/[...missing]/page.js +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/[...missing]/page.js.nft.json +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/[...missing]/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +1 -1
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
  33. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  34. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +1 -1
  35. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
  36. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  37. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page.js +1 -1
  38. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page.js.nft.json +1 -1
  39. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page_client-reference-manifest.js +1 -1
  40. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js +1 -1
  41. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
  42. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  43. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js +1 -1
  44. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
  45. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  46. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js +1 -1
  47. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  48. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  49. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js +1 -1
  50. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  51. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  52. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  53. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  54. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  55. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
  56. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  57. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  58. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js +1 -1
  59. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  60. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  61. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page.js +1 -1
  62. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page.js.nft.json +1 -1
  63. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  64. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js +1 -1
  65. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js.nft.json +1 -1
  66. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  67. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js +1 -1
  68. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
  69. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  70. package/app/.next-cli-build/server/app/(dashboard)/dashboard/settings/page.js +1 -1
  71. package/app/.next-cli-build/server/app/(dashboard)/dashboard/settings/page.js.nft.json +1 -1
  72. package/app/.next-cli-build/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
  73. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js +1 -1
  74. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js.nft.json +1 -1
  75. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  76. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js +1 -1
  77. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +1 -1
  78. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  79. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js +1 -1
  80. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
  81. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  82. package/app/.next-cli-build/server/app/(dashboard)/dashboard/ui-kit/page.js +1 -1
  83. package/app/.next-cli-build/server/app/(dashboard)/dashboard/ui-kit/page.js.nft.json +1 -1
  84. package/app/.next-cli-build/server/app/(dashboard)/dashboard/ui-kit/page_client-reference-manifest.js +1 -1
  85. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js +1 -1
  86. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
  87. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  88. package/app/.next-cli-build/server/app/_global-error/page.js.nft.json +1 -1
  89. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  90. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  91. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  92. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  93. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  94. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  95. package/app/.next-cli-build/server/app/_not-found/page.js +1 -1
  96. package/app/.next-cli-build/server/app/_not-found/page.js.nft.json +1 -1
  97. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  98. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  99. package/app/.next-cli-build/server/app/_not-found.rsc +5 -5
  100. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +5 -5
  101. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -5
  102. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  103. package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
  104. package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
  105. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js.nft.json +1 -1
  106. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js.nft.json +1 -1
  107. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js.nft.json +1 -1
  108. package/app/.next-cli-build/server/app/api/auth/reset-password/route.js.nft.json +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.nft.json +1 -1
  111. package/app/.next-cli-build/server/app/api/auth/saml/start/route.js.nft.json +1 -1
  112. package/app/.next-cli-build/server/app/api/auth/saml/test/route.js.nft.json +1 -1
  113. package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
  114. package/app/.next-cli-build/server/app/api/cli-tool-settings/[toolId]/route.js.nft.json +1 -1
  115. package/app/.next-cli-build/server/app/api/cli-tool-settings/route.js.nft.json +1 -1
  116. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +4 -4
  117. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  118. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  119. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  120. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  121. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +2 -2
  122. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
  123. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +2 -2
  124. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
  125. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +3 -3
  126. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
  127. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js +2 -2
  128. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js.nft.json +1 -1
  129. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
  130. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +1 -1
  131. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +2 -2
  132. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
  133. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
  134. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
  135. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +3 -3
  136. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +1 -1
  137. package/app/.next-cli-build/server/app/api/cli-tools/devin-settings/route.js +2 -2
  138. package/app/.next-cli-build/server/app/api/cli-tools/devin-settings/route.js.nft.json +1 -1
  139. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
  140. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
  141. package/app/.next-cli-build/server/app/api/cli-tools/grok-build-settings/route.js +2 -2
  142. package/app/.next-cli-build/server/app/api/cli-tools/grok-build-settings/route.js.nft.json +1 -1
  143. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +3 -3
  144. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js.nft.json +1 -1
  145. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +3 -3
  146. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js.nft.json +1 -1
  147. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
  148. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
  149. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
  150. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
  151. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +2 -2
  152. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
  153. package/app/.next-cli-build/server/app/api/combos/[id]/headroom/route.js +1 -1
  154. package/app/.next-cli-build/server/app/api/combos/[id]/headroom/route.js.nft.json +1 -1
  155. package/app/.next-cli-build/server/app/api/combos/[id]/route.js +1 -1
  156. package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
  157. package/app/.next-cli-build/server/app/api/combos/[id]/test/route.js +1 -1
  158. package/app/.next-cli-build/server/app/api/combos/[id]/test/route.js.nft.json +1 -1
  159. package/app/.next-cli-build/server/app/api/combos/route.js +1 -1
  160. package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
  161. package/app/.next-cli-build/server/app/api/gateway/status/route.js.nft.json +1 -1
  162. package/app/.next-cli-build/server/app/api/headroom/extras/route.js.nft.json +1 -1
  163. package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js.nft.json +1 -1
  164. package/app/.next-cli-build/server/app/api/headroom/restart/route.js.nft.json +1 -1
  165. package/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +1 -1
  166. package/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +1 -1
  167. package/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +1 -1
  168. package/app/.next-cli-build/server/app/api/health/route.js.nft.json +1 -1
  169. package/app/.next-cli-build/server/app/api/home/live-routes/route.js.nft.json +1 -1
  170. package/app/.next-cli-build/server/app/api/home/quota/route.js +1 -1
  171. package/app/.next-cli-build/server/app/api/home/quota/route.js.nft.json +1 -1
  172. package/app/.next-cli-build/server/app/api/home/summary/route.js.nft.json +1 -1
  173. package/app/.next-cli-build/server/app/api/init/route.js.nft.json +1 -1
  174. package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
  175. package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
  176. package/app/.next-cli-build/server/app/api/locale/route.js.nft.json +1 -1
  177. package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
  178. package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
  179. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
  180. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js +1 -1
  181. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
  182. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
  183. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
  184. package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js +1 -1
  185. package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js.nft.json +1 -1
  186. package/app/.next-cli-build/server/app/api/models/alias/route.js +1 -1
  187. package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
  188. package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
  189. package/app/.next-cli-build/server/app/api/models/catalog-sync/route.js +1 -1
  190. package/app/.next-cli-build/server/app/api/models/catalog-sync/route.js.nft.json +1 -1
  191. package/app/.next-cli-build/server/app/api/models/custom/route.js +1 -1
  192. package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
  193. package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
  194. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  195. package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
  196. package/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
  197. package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
  198. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  199. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  200. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js +1 -1
  201. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
  202. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
  203. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
  204. package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
  205. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js +1 -1
  206. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  207. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
  208. package/app/.next-cli-build/server/app/api/oauth/grok-cli/bulk-import/route.js.nft.json +1 -1
  209. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  210. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js +1 -1
  211. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js.nft.json +1 -1
  212. package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
  213. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js +1 -1
  214. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  215. package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js.nft.json +1 -1
  216. package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
  217. package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
  218. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  219. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  220. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/api-key/route.js.nft.json +1 -1
  221. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/auto-import/route.js +1 -1
  222. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/auto-import/route.js.nft.json +1 -1
  223. package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
  224. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  225. package/app/.next-cli-build/server/app/api/provider-nodes/route.js +1 -1
  226. package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
  227. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js +1 -1
  228. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
  229. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js +1 -1
  230. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  231. package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
  232. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js +1 -1
  233. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  234. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js +1 -1
  235. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  236. package/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
  237. package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
  238. package/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js.nft.json +1 -1
  239. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  240. package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
  241. package/app/.next-cli-build/server/app/api/providers/suggested-models/route.js.nft.json +1 -1
  242. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js +1 -1
  243. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  244. package/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
  245. package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
  246. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js.nft.json +1 -1
  247. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js.nft.json +1 -1
  248. package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js.nft.json +1 -1
  249. package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js.nft.json +1 -1
  250. package/app/.next-cli-build/server/app/api/proxy-pools/route.js.nft.json +1 -1
  251. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js.nft.json +1 -1
  252. package/app/.next-cli-build/server/app/api/pxpipe/health/route.js.nft.json +1 -1
  253. package/app/.next-cli-build/server/app/api/pxpipe/install/route.js.nft.json +1 -1
  254. package/app/.next-cli-build/server/app/api/pxpipe/logs/route.js.nft.json +1 -1
  255. package/app/.next-cli-build/server/app/api/pxpipe/restart/route.js.nft.json +1 -1
  256. package/app/.next-cli-build/server/app/api/pxpipe/start/route.js.nft.json +1 -1
  257. package/app/.next-cli-build/server/app/api/pxpipe/stats/route.js.nft.json +1 -1
  258. package/app/.next-cli-build/server/app/api/pxpipe/status/route.js.nft.json +1 -1
  259. package/app/.next-cli-build/server/app/api/pxpipe/stop/route.js.nft.json +1 -1
  260. package/app/.next-cli-build/server/app/api/settings/config/export/route.js.nft.json +1 -1
  261. package/app/.next-cli-build/server/app/api/settings/config/import/route.js +1 -1
  262. package/app/.next-cli-build/server/app/api/settings/config/import/route.js.nft.json +1 -1
  263. package/app/.next-cli-build/server/app/api/settings/database/route.js +1 -1
  264. package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
  265. package/app/.next-cli-build/server/app/api/settings/environment/route.js.nft.json +1 -1
  266. package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
  267. package/app/.next-cli-build/server/app/api/settings/require-login/route.js.nft.json +1 -1
  268. package/app/.next-cli-build/server/app/api/settings/route.js +1 -1
  269. package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
  270. package/app/.next-cli-build/server/app/api/shell/savings-milestone/route.js.nft.json +1 -1
  271. package/app/.next-cli-build/server/app/api/shell/summary/route.js +1 -1
  272. package/app/.next-cli-build/server/app/api/shell/summary/route.js.nft.json +1 -1
  273. package/app/.next-cli-build/server/app/api/shutdown/route.js.nft.json +1 -1
  274. package/app/.next-cli-build/server/app/api/tags/route.js.nft.json +1 -1
  275. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  276. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js.nft.json +1 -1
  277. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  278. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
  279. package/app/.next-cli-build/server/app/api/translator/load/route.js.nft.json +1 -1
  280. package/app/.next-cli-build/server/app/api/translator/save/route.js.nft.json +1 -1
  281. package/app/.next-cli-build/server/app/api/translator/send/route.js +9 -1
  282. package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
  283. package/app/.next-cli-build/server/app/api/translator/translate/route.js +9 -1
  284. package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
  285. package/app/.next-cli-build/server/app/api/tunnel/disable/route.js.nft.json +1 -1
  286. package/app/.next-cli-build/server/app/api/tunnel/enable/route.js.nft.json +1 -1
  287. package/app/.next-cli-build/server/app/api/tunnel/status/route.js.nft.json +1 -1
  288. package/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js.nft.json +1 -1
  289. package/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js.nft.json +1 -1
  290. package/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js.nft.json +1 -1
  291. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js +2 -2
  292. package/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js.nft.json +1 -1
  293. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js +9 -1
  294. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js.nft.json +1 -1
  295. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js +9 -1
  296. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  297. package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
  298. package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
  299. package/app/.next-cli-build/server/app/api/usage/last-activity/route.js.nft.json +1 -1
  300. package/app/.next-cli-build/server/app/api/usage/logs/route.js.nft.json +1 -1
  301. package/app/.next-cli-build/server/app/api/usage/providers/route.js +1 -1
  302. package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
  303. package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
  304. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  305. package/app/.next-cli-build/server/app/api/usage/savings/route.js.nft.json +1 -1
  306. package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
  307. package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
  308. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js +1 -1
  309. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  310. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js +1 -1
  311. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  312. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js +1 -1
  313. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  314. package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js +1 -1
  315. package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js.nft.json +1 -1
  316. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js +1 -1
  317. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  318. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js +9 -1
  319. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  320. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js +2 -2
  321. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  322. package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js +1 -1
  323. package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
  324. package/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
  325. package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
  326. package/app/.next-cli-build/server/app/api/v1/models/[...model]/route.js +1 -1
  327. package/app/.next-cli-build/server/app/api/v1/models/[...model]/route.js.nft.json +1 -1
  328. package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
  329. package/app/.next-cli-build/server/app/api/v1/models/info/route.js.nft.json +1 -1
  330. package/app/.next-cli-build/server/app/api/v1/models/route.js +1 -1
  331. package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
  332. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js +1 -1
  333. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  334. package/app/.next-cli-build/server/app/api/v1/responses/route.js +1 -1
  335. package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
  336. package/app/.next-cli-build/server/app/api/v1/route.js +1 -1
  337. package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
  338. package/app/.next-cli-build/server/app/api/v1/search/route.js +2 -2
  339. package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
  340. package/app/.next-cli-build/server/app/api/v1/videos/[id]/route.js +1 -1
  341. package/app/.next-cli-build/server/app/api/v1/videos/[id]/route.js.nft.json +1 -1
  342. package/app/.next-cli-build/server/app/api/v1/videos/edits/route.js +1 -1
  343. package/app/.next-cli-build/server/app/api/v1/videos/edits/route.js.nft.json +1 -1
  344. package/app/.next-cli-build/server/app/api/v1/videos/extensions/route.js +1 -1
  345. package/app/.next-cli-build/server/app/api/v1/videos/extensions/route.js.nft.json +1 -1
  346. package/app/.next-cli-build/server/app/api/v1/videos/generations/route.js +1 -1
  347. package/app/.next-cli-build/server/app/api/v1/videos/generations/route.js.nft.json +1 -1
  348. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js +1 -1
  349. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  350. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js +1 -1
  351. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  352. package/app/.next-cli-build/server/app/api/v1beta/models/route.js +1 -1
  353. package/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +1 -1
  354. package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
  355. package/app/.next-cli-build/server/app/callback/page.js +1 -1
  356. package/app/.next-cli-build/server/app/callback/page.js.nft.json +1 -1
  357. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  358. package/app/.next-cli-build/server/app/callback.html +1 -1
  359. package/app/.next-cli-build/server/app/callback.rsc +5 -5
  360. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +5 -5
  361. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +2 -2
  362. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +5 -5
  363. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +2 -2
  364. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +11 -11
  365. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +11 -11
  366. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +11 -11
  367. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +2 -2
  368. package/app/.next-cli-build/server/app/dashboard/combos.html +2 -2
  369. package/app/.next-cli-build/server/app/dashboard/combos.rsc +11 -11
  370. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +11 -11
  371. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +11 -11
  372. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
  373. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  374. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +9 -9
  375. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +8 -8
  376. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +9 -9
  377. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
  378. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +2 -2
  379. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +11 -11
  380. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +11 -11
  381. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +11 -11
  382. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +2 -2
  383. package/app/.next-cli-build/server/app/dashboard/media-providers.html +1 -1
  384. package/app/.next-cli-build/server/app/dashboard/media-providers.rsc +10 -10
  385. package/app/.next-cli-build/server/app/dashboard/media-providers.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/__PAGE__.segment.rsc +10 -10
  386. package/app/.next-cli-build/server/app/dashboard/media-providers.segments/_full.segment.rsc +10 -10
  387. package/app/.next-cli-build/server/app/dashboard/media-providers.segments/_tree.segment.rsc +2 -2
  388. package/app/.next-cli-build/server/app/dashboard/mitm.html +2 -2
  389. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +11 -11
  390. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +11 -11
  391. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +11 -11
  392. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
  393. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  394. package/app/.next-cli-build/server/app/dashboard/profile.rsc +10 -10
  395. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +10 -10
  396. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +10 -10
  397. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
  398. package/app/.next-cli-build/server/app/dashboard/providers/new.html +2 -2
  399. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +11 -11
  400. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +11 -11
  401. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +11 -11
  402. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
  403. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +2 -2
  404. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +10 -10
  405. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +10 -10
  406. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +10 -10
  407. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
  408. package/app/.next-cli-build/server/app/dashboard/pxpipe.html +2 -2
  409. package/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +10 -10
  410. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +10 -10
  411. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +10 -10
  412. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +2 -2
  413. package/app/.next-cli-build/server/app/dashboard/quota.html +1 -1
  414. package/app/.next-cli-build/server/app/dashboard/quota.rsc +11 -11
  415. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +11 -11
  416. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +11 -11
  417. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
  418. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js +1 -1
  419. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
  420. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  421. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  422. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +5 -5
  423. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +5 -5
  424. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  425. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +5 -5
  426. package/app/.next-cli-build/server/app/dashboard/settings.html +2 -2
  427. package/app/.next-cli-build/server/app/dashboard/settings.rsc +11 -11
  428. package/app/.next-cli-build/server/app/dashboard/settings.segments/!KGRhc2hib2FyZCk/dashboard/settings/__PAGE__.segment.rsc +11 -11
  429. package/app/.next-cli-build/server/app/dashboard/settings.segments/_full.segment.rsc +11 -11
  430. package/app/.next-cli-build/server/app/dashboard/settings.segments/_tree.segment.rsc +2 -2
  431. package/app/.next-cli-build/server/app/dashboard/skills.html +2 -2
  432. package/app/.next-cli-build/server/app/dashboard/skills.rsc +8 -8
  433. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +8 -8
  434. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +8 -8
  435. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +2 -2
  436. package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  437. package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +11 -11
  438. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +11 -11
  439. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +11 -11
  440. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +2 -2
  441. package/app/.next-cli-build/server/app/dashboard/translator.html +2 -2
  442. package/app/.next-cli-build/server/app/dashboard/translator.rsc +11 -11
  443. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +11 -11
  444. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +11 -11
  445. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
  446. package/app/.next-cli-build/server/app/dashboard/ui-kit.html +1 -1
  447. package/app/.next-cli-build/server/app/dashboard/ui-kit.rsc +10 -10
  448. package/app/.next-cli-build/server/app/dashboard/ui-kit.segments/!KGRhc2hib2FyZCk/dashboard/ui-kit/__PAGE__.segment.rsc +10 -10
  449. package/app/.next-cli-build/server/app/dashboard/ui-kit.segments/_full.segment.rsc +10 -10
  450. package/app/.next-cli-build/server/app/dashboard/ui-kit.segments/_tree.segment.rsc +2 -2
  451. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  452. package/app/.next-cli-build/server/app/dashboard/usage.rsc +11 -11
  453. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +11 -11
  454. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +11 -11
  455. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
  456. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  457. package/app/.next-cli-build/server/app/dashboard.rsc +11 -11
  458. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +11 -11
  459. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +11 -11
  460. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  461. package/app/.next-cli-build/server/app/index.html +1 -1
  462. package/app/.next-cli-build/server/app/index.rsc +5 -5
  463. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +5 -5
  464. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +5 -5
  465. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +2 -2
  466. package/app/.next-cli-build/server/app/landing/page.js +1 -1
  467. package/app/.next-cli-build/server/app/landing/page.js.nft.json +1 -1
  468. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  469. package/app/.next-cli-build/server/app/landing.html +1 -1
  470. package/app/.next-cli-build/server/app/landing.rsc +6 -6
  471. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +6 -6
  472. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +2 -2
  473. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +6 -6
  474. package/app/.next-cli-build/server/app/login/page.js +1 -1
  475. package/app/.next-cli-build/server/app/login/page.js.nft.json +1 -1
  476. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  477. package/app/.next-cli-build/server/app/login.html +1 -1
  478. package/app/.next-cli-build/server/app/login.rsc +5 -5
  479. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +5 -5
  480. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +2 -2
  481. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +5 -5
  482. package/app/.next-cli-build/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  483. package/app/.next-cli-build/server/app/page.js +1 -1
  484. package/app/.next-cli-build/server/app/page.js.nft.json +1 -1
  485. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  486. package/app/.next-cli-build/server/app/skills/[...slug]/route.js.nft.json +1 -1
  487. package/app/.next-cli-build/server/app-paths-manifest.json +4 -4
  488. package/app/.next-cli-build/server/chunks/1004.js +1 -0
  489. package/app/.next-cli-build/server/chunks/1152.js +1 -1
  490. package/app/.next-cli-build/server/chunks/1215.js +1 -0
  491. package/app/.next-cli-build/server/chunks/1336.js +1 -1
  492. package/app/.next-cli-build/server/chunks/1432.js +1 -1
  493. package/app/.next-cli-build/server/chunks/1533.js +1 -1
  494. package/app/.next-cli-build/server/chunks/2217.js +1 -1
  495. package/app/.next-cli-build/server/chunks/2380.js +7 -7
  496. package/app/.next-cli-build/server/chunks/24.js +1 -1
  497. package/app/.next-cli-build/server/chunks/2460.js +1 -1
  498. package/app/.next-cli-build/server/chunks/257.js +10 -0
  499. package/app/.next-cli-build/server/chunks/2592.js +1 -1
  500. package/app/.next-cli-build/server/chunks/2705.js +9 -0
  501. package/app/.next-cli-build/server/chunks/318.js +9 -16
  502. package/app/.next-cli-build/server/chunks/3593.js +1 -1
  503. package/app/.next-cli-build/server/chunks/3919.js +1 -1
  504. package/app/.next-cli-build/server/chunks/3943.js +1 -1
  505. package/app/.next-cli-build/server/chunks/4123.js +1 -1
  506. package/app/.next-cli-build/server/chunks/4125.js +1 -1
  507. package/app/.next-cli-build/server/chunks/4334.js +1 -1
  508. package/app/.next-cli-build/server/chunks/4406.js +2 -2
  509. package/app/.next-cli-build/server/chunks/4521.js +1 -1
  510. package/app/.next-cli-build/server/chunks/4730.js +1 -1
  511. package/app/.next-cli-build/server/chunks/4780.js +1 -1
  512. package/app/.next-cli-build/server/chunks/5055.js +1 -0
  513. package/app/.next-cli-build/server/chunks/5230.js +1 -0
  514. package/app/.next-cli-build/server/chunks/{1026.js → 5260.js} +1 -1
  515. package/app/.next-cli-build/server/chunks/5335.js +1 -0
  516. package/app/.next-cli-build/server/chunks/5559.js +9 -0
  517. package/app/.next-cli-build/server/chunks/5615.js +1 -1
  518. package/app/.next-cli-build/server/chunks/5649.js +1 -0
  519. package/app/.next-cli-build/server/chunks/5765.js +1 -0
  520. package/app/.next-cli-build/server/chunks/5827.js +1 -0
  521. package/app/.next-cli-build/server/chunks/5869.js +9 -0
  522. package/app/.next-cli-build/server/chunks/5908.js +1 -0
  523. package/app/.next-cli-build/server/chunks/620.js +1 -0
  524. package/app/.next-cli-build/server/chunks/6252.js +1 -1
  525. package/app/.next-cli-build/server/chunks/6328.js +1 -0
  526. package/app/.next-cli-build/server/chunks/6355.js +1 -0
  527. package/app/.next-cli-build/server/chunks/6493.js +1 -0
  528. package/app/.next-cli-build/server/chunks/6496.js +1 -1
  529. package/app/.next-cli-build/server/chunks/7211.js +1 -1
  530. package/app/.next-cli-build/server/chunks/7485.js +9 -0
  531. package/app/.next-cli-build/server/chunks/7616.js +1 -1
  532. package/app/.next-cli-build/server/chunks/7695.js +1 -0
  533. package/app/.next-cli-build/server/chunks/7716.js +1 -1
  534. package/app/.next-cli-build/server/chunks/7819.js +1 -1
  535. package/app/.next-cli-build/server/chunks/7828.js +1 -1
  536. package/app/.next-cli-build/server/chunks/8171.js +1 -1
  537. package/app/.next-cli-build/server/chunks/8255.js +1 -1
  538. package/app/.next-cli-build/server/chunks/8261.js +1 -0
  539. package/app/.next-cli-build/server/chunks/8416.js +1 -1
  540. package/app/.next-cli-build/server/chunks/878.js +1 -0
  541. package/app/.next-cli-build/server/chunks/8895.js +13 -13
  542. package/app/.next-cli-build/server/chunks/8954.js +1 -0
  543. package/app/.next-cli-build/server/chunks/8988.js +1 -0
  544. package/app/.next-cli-build/server/chunks/9016.js +9 -0
  545. package/app/.next-cli-build/server/chunks/9243.js +1 -0
  546. package/app/.next-cli-build/server/chunks/9326.js +1 -0
  547. package/app/.next-cli-build/server/chunks/9343.js +1 -1
  548. package/app/.next-cli-build/server/chunks/9421.js +1 -1
  549. package/app/.next-cli-build/server/chunks/9489.js +3 -0
  550. package/app/.next-cli-build/server/chunks/9578.js +1 -1
  551. package/app/.next-cli-build/server/chunks/9594.js +1 -0
  552. package/app/.next-cli-build/server/chunks/965.js +1 -1
  553. package/app/.next-cli-build/server/chunks/9899.js +1 -1
  554. package/app/.next-cli-build/server/instrumentation.js +1 -1
  555. package/app/.next-cli-build/server/instrumentation.js.nft.json +1 -1
  556. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  557. package/app/.next-cli-build/server/middleware-react-loadable-manifest.js +1 -1
  558. package/app/.next-cli-build/server/middleware.js.nft.json +1 -1
  559. package/app/.next-cli-build/server/pages/404.html +1 -1
  560. package/app/.next-cli-build/server/pages/500.html +1 -1
  561. package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
  562. package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
  563. package/app/.next-cli-build/static/chunks/{198-145d0ed2ec3c54f5.js → 198-7c5bbea89ef8bc14.js} +1 -1
  564. package/app/.next-cli-build/static/chunks/{3670-e7a22341025498f8.js → 3670-d6dc44bc181c9b8a.js} +1 -1
  565. package/app/.next-cli-build/static/chunks/5014-a5d960f4c6bc6297.js +1 -0
  566. package/app/.next-cli-build/static/chunks/{6174.18e2c57e892d721a.js → 6174.a18fedfa3d765b1e.js} +1 -1
  567. package/app/.next-cli-build/static/chunks/6448-71a8c2ac8d9ecc09.js +1 -0
  568. package/app/.next-cli-build/static/chunks/7899-a12f962af02edf7f.js +1 -0
  569. package/app/.next-cli-build/static/chunks/8105-71d1aea9708976db.js +1 -0
  570. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/{page-8147ae8fa9c04381.js → page-42bfc760fbea3b96.js} +1 -1
  571. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/console-log/{page-9cbf62f78701882a.js → page-1df6ad7d9adfc2a7.js} +1 -1
  572. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-5f91e148400a241b.js → page-59ee0b412f972940.js} +3 -3
  573. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/new/{page-dac4ab98fc595054.js → page-25d06b77bd1a5edb.js} +1 -1
  574. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-463f9fa33be9426a.js +1 -0
  575. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/{page-06f4e52ee3b63f82.js → page-5bb99ecaf48bde39.js} +1 -1
  576. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/ui-kit/{page-6c982cc50b6af101.js → page-1bc393f267badc04.js} +1 -1
  577. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/page-923f864ec0be0fc8.js +1 -0
  578. package/app/.next-cli-build/static/chunks/app/(dashboard)/{layout-dd9d1e49b2f69197.js → layout-a94f45e334f1841b.js} +1 -1
  579. package/app/.next-cli-build/static/chunks/app/landing/{page-02b7bfebd65c41f1.js → page-98f05847e3372b16.js} +1 -1
  580. package/app/.next-cli-build/static/chunks/app/{layout-c266f1acedfb4651.js → layout-29d74e164758a126.js} +1 -1
  581. package/app/.next-cli-build/static/chunks/webpack-1e19a4b05298b49d.js +1 -0
  582. package/app/.next-cli-build/static/css/{9f0b95a0d0bc5e51.css → ffa1d9c3cbb4e959.css} +1 -1
  583. package/app/custom-server.js +0 -37
  584. package/app/package.json +4 -5
  585. package/app/server.js +1 -1
  586. package/app/src/lib/db/adapters/sqljsAdapter.js +39 -4
  587. package/app/src/lib/oauth/services/xai.js +19 -12
  588. package/app/src/shared/services/quotaAutoPing.js +43 -8
  589. package/app/src/shared/services/quotaSnapshotPoller.js +2 -1
  590. package/app/src/sse/services/backgroundTokenRefresh.js +13 -1
  591. package/package.json +1 -1
  592. package/src/cli/menus/combos.js +3 -1
  593. package/app/.next-cli-build/server/chunks/1764.js +0 -1
  594. package/app/.next-cli-build/server/chunks/2384.js +0 -1
  595. package/app/.next-cli-build/server/chunks/3093.js +0 -1
  596. package/app/.next-cli-build/server/chunks/3306.js +0 -1
  597. package/app/.next-cli-build/server/chunks/331.js +0 -1
  598. package/app/.next-cli-build/server/chunks/3414.js +0 -1
  599. package/app/.next-cli-build/server/chunks/3558.js +0 -1
  600. package/app/.next-cli-build/server/chunks/3586.js +0 -1
  601. package/app/.next-cli-build/server/chunks/3676.js +0 -1
  602. package/app/.next-cli-build/server/chunks/4037.js +0 -1
  603. package/app/.next-cli-build/server/chunks/4199.js +0 -2
  604. package/app/.next-cli-build/server/chunks/4278.js +0 -1
  605. package/app/.next-cli-build/server/chunks/6158.js +0 -1
  606. package/app/.next-cli-build/server/chunks/6354.js +0 -1
  607. package/app/.next-cli-build/server/chunks/6734.js +0 -1
  608. package/app/.next-cli-build/server/chunks/6769.js +0 -1
  609. package/app/.next-cli-build/server/chunks/7261.js +0 -1
  610. package/app/.next-cli-build/server/chunks/7901.js +0 -1
  611. package/app/.next-cli-build/server/chunks/8372.js +0 -1
  612. package/app/.next-cli-build/server/chunks/8635.js +0 -3
  613. package/app/.next-cli-build/server/chunks/994.js +0 -1
  614. package/app/.next-cli-build/static/chunks/5014-a441cde708542153.js +0 -1
  615. package/app/.next-cli-build/static/chunks/6448-4eabf683083596e6.js +0 -1
  616. package/app/.next-cli-build/static/chunks/7899-e6a70cb9d3684f7f.js +0 -1
  617. package/app/.next-cli-build/static/chunks/8105-5c7e7c73b4bd532d.js +0 -1
  618. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-9fadf2c38665c20c.js +0 -1
  619. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/page-7571538830147099.js +0 -1
  620. package/app/.next-cli-build/static/chunks/webpack-187fa25c98ba99f3.js +0 -1
  621. /package/app/.next-cli-build/static/{3Qm_WgU2xvFJ9U_G7SKhT → gdVYVwJMM6JES9Y1KPQyw}/_buildManifest.js +0 -0
  622. /package/app/.next-cli-build/static/{3Qm_WgU2xvFJ9U_G7SKhT → gdVYVwJMM6JES9Y1KPQyw}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (()=>{var a={};a.id=2791,a.ids=[2791],a.modules={267:(a,b,c)=>{"use strict";c.d(b,{default:()=>m});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(51126),i=c(99258),j=c(95145);let k={en:"English",vi:"Tiếng Việt","zh-CN":"简体中文","zh-TW":"繁體中文",ja:"日本語","pt-BR":"Portugu\xeas (Brasil)","pt-PT":"Portugu\xeas (Portugal)",ko:"한국어",es:"Espa\xf1ol",de:"Deutsch",fr:"Fran\xe7ais",he:"עברית",ar:"العربية",ru:"Русский",pl:"Polski",cs:"Čeština",nl:"Nederlands",tr:"T\xfcrk\xe7e",uk:"Українська",tl:"Tagalog",id:"Indonesia",th:"ไทย",km:"ខ្មែរ",hi:"हिन्दी",bn:"বাংলা",ur:"اردو",ro:"Rom\xe2nă",sv:"Svenska",it:"Italiano",el:"Ελληνικά",hu:"Magyar",fi:"Suomi",da:"Dansk",no:"Norsk",fa:"فارسی"},l=a=>k[a]||a;function m({className:a="",isOpen:b,onClose:c,hideTrigger:f=!1}){let[g,k]=(0,e.useState)("en"),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),r="boolean"==typeof b,s=(a=g)=>{r?c?.(a):q(!1)},t=async a=>{if(a!==g&&!n){o(!0);try{await fetch("/api/locale",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locale:a})}),await (0,i.wn)();let b=document.documentElement,c=(0,i.kk)();b.lang=c,b.dir=h.rB.includes(c)?"rtl":"ltr",k(a),s(a)}catch(a){console.error("Failed to set locale:",a)}finally{o(!1)}}};return(0,d.jsxs)("div",{className:a,children:[!f&&(0,d.jsxs)("button",{type:"button",onClick:()=>q(!p),disabled:n,className:"flex h-11 items-center gap-2 rounded-lg px-3 text-muted transition-colors hover:bg-raised hover:text-text",title:"Language",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"language"}),(0,d.jsx)("span",{className:"text-sm font-medium",children:l(g)})]}),(0,d.jsx)(j.default,{isOpen:r?b:p,onClose:()=>s(),title:"Select language",size:"full",className:"max-w-2xl",children:(0,d.jsx)("div",{"data-i18n-skip":"true",className:"grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2",children:h.YZ.map(a=>{let b=g===a;return(0,d.jsxs)("button",{type:"button",onClick:()=>t(a),disabled:n,"aria-current":b||void 0,title:l(a),className:`flex w-full flex-col items-center justify-start gap-1 rounded-lg px-2 py-3 text-xs font-medium transition-colors ${b?"bg-coral-bg text-coral shadow-focus":"text-text hover:bg-raised"} ${n?"cursor-wait opacity-70":""}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[26px]","aria-hidden":"true",children:b?"language":"translate"}),(0,d.jsx)("span",{className:"flex h-8 items-center overflow-hidden text-center leading-tight [display:-webkit-box] [-webkit-box-orient:vertical] [-webkit-line-clamp:2]",children:l(a)}),b&&(0,d.jsx)("span",{className:"material-symbols-outlined text-sm","aria-hidden":"true",children:"check"})]},a)})})})]})}m.propTypes={className:g().string,isOpen:g().bool,onClose:g().func,hideTrigger:g().bool}},643:a=>{"use strict";a.exports=require("node:perf_hooks")},1582:(a,b,c)=>{"use strict";c.d(b,{default:()=>g});var d=c(48249),e=c(49885),f=c.n(e);function g({label:a,description:b,settingKey:c,control:e,className:f}){return(0,d.jsxs)("div",{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-3 py-4${f?` ${f}`:""}`,children:[(0,d.jsxs)("div",{className:"min-w-52 flex-1",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:a}),b&&(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:b}),c&&(0,d.jsx)("p",{className:"mt-0.5 font-mono text-[11px] text-subtle",children:c})]}),(0,d.jsx)("div",{className:"shrink-0",children:e})]})}g.propTypes={label:f().node.isRequired,description:f().node,settingKey:f().string,control:f().node.isRequired,className:f().string}},1708:a=>{"use strict";a.exports=require("node:process")},1932:a=>{"use strict";a.exports=require("url")},2362:(a,b,c)=>{"use strict";function d(a,b){let c=null,d=(...d)=>{clearTimeout(c),c=setTimeout(()=>a(...d),b)};return d.cancel=()=>clearTimeout(c),d}c.d(b,{s:()=>d})},3090:(a,b,c)=>{"use strict";c.d(b,{default:()=>i});var d=c(48249),e=c(49885),f=c.n(e),g=c(71404),h=c(27444);function i({label:a,value:b,onChange:c,unit:e,type:f="number",error:j,hint:k,disabled:l=!1,required:m=!1,className:n,id:o,...p}){return(0,d.jsx)(h.default,{id:o,label:a,hint:k,error:j,required:m,className:n,children:({inputId:a,describedBy:h,invalid:i})=>{let j=`${a}-unit`,k=[e?j:null,h].filter(Boolean).join(" ")||void 0;return(0,d.jsxs)("div",{className:(0,g.cn)("flex h-11 items-center rounded-lg border border-line bg-raised transition-colors","focus-within:border-coral focus-within:shadow-focus",i&&"border-err focus-within:border-err",l&&"opacity-50"),children:[(0,d.jsx)("input",{...p,id:a,type:f,inputMode:"number"===f?"decimal":void 0,value:b,onChange:c,disabled:l,"aria-describedby":k,"aria-invalid":i||void 0,className:"w-full min-w-0 bg-transparent px-3 py-2.5 text-sm text-text placeholder:text-subtle focus:outline-none text-[16px] sm:text-sm [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),e&&(0,d.jsx)("span",{id:j,className:"shrink-0 pe-3 text-sm text-subtle",children:e})]})}})}i.propTypes={label:f().node,value:f().oneOfType([f().string,f().number]),onChange:f().func,type:f().string,unit:f().node,error:f().node,hint:f().node,disabled:f().bool,required:f().bool,className:f().string,id:f().string}},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},7066:a=>{"use strict";a.exports=require("node:tty")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10117:(a,b)=>{"use strict";function c(a){return a.split("/").map(a=>encodeURIComponent(a)).join("/")}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"encodeURIPath",{enumerable:!0,get:function(){return c}})},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},14985:a=>{"use strict";a.exports=require("dns")},16698:a=>{"use strict";a.exports=require("node:async_hooks")},19099:(a,b,c)=>{"use strict";var d=c(54839);c.o(d,"notFound")&&c.d(b,{notFound:function(){return d.notFound}}),c.o(d,"useParams")&&c.d(b,{useParams:function(){return d.useParams}}),c.o(d,"usePathname")&&c.d(b,{usePathname:function(){return d.usePathname}}),c.o(d,"useRouter")&&c.d(b,{useRouter:function(){return d.useRouter}}),c.o(d,"useSearchParams")&&c.d(b,{useSearchParams:function(){return d.useSearchParams}})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{"use strict";a.exports=require("os")},27558:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>bk});var d=c(48249),e=c(67484),f=c(9123),g=c(26584),h=c(33597),i=c(74812),j=c(99070),k=c(49885),l=c.n(k),m=c(89025),n=c(75171),o=c(216),p=c(83552),q=c(95145);let r={changed:"warn",added:"info",unchanged:"neutral"},s=[["settings","Settings"],["combos","Combos"],["pricing","Pricing overrides"]],t="Configuration only: settings, combos and pricing overrides. Passwords, secrets and provider accounts are never included. URL credentials are redacted; masked URL settings keep their current values on import. For a full backup, use Data & backup.";async function u(a){let b=await fetch("/api/settings/config/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>({}));if(!b.ok){let a=(c.errors??[]).slice(1);throw Error([c.error||"Import failed",...a].join(" \xb7 "))}return c}function v({label:a,section:b}){let[c,f]=(0,e.useState)(!1);return b&&0!==b.entries.length?(0,d.jsxs)("div",{className:"rounded-xl border border-line",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>f(a=>!a),"aria-expanded":c,className:"flex min-h-11 w-full flex-wrap items-center gap-2 rounded-xl px-3 py-2 text-start text-sm outline-none focus-visible:shadow-focus",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] text-muted rtl:-scale-x-100","aria-hidden":"true",children:c?"expand_more":"chevron_right"}),(0,d.jsx)("span",{className:"font-semibold text-text",children:a}),(0,d.jsx)("span",{className:"ms-auto flex flex-wrap gap-1",children:["changed","added","unchanged"].map(a=>b[a]>0?(0,d.jsx)(n.default,{variant:r[a],children:`${b[a]} ${a}`},a):null)})]}),c&&(0,d.jsx)("ul",{className:"max-h-56 space-y-1.5 overflow-y-auto border-t border-line px-3 py-2",children:b.entries.map(a=>(0,d.jsxs)("li",{className:"flex flex-wrap items-center gap-2 text-[13px]",children:[(0,d.jsx)(n.default,{variant:r[a.status],children:a.status}),(0,d.jsx)("code",{className:"break-all font-mono text-text",children:a.key}),a.restart&&(0,d.jsx)(n.default,{variant:"neutral",children:"restart"})]},a.key))})]}):null}function w({onSettingsChange:a}){let[b,c]=(0,e.useState)({type:"",message:""}),[f,g]=(0,e.useState)(!1),[h,i]=(0,e.useState)({open:!1,mode:"",password:""}),[k,l]=(0,e.useState)(null),n=(0,e.useRef)(null),r=(0,e.useRef)(""),x=(0,e.useRef)(null),y=()=>i({open:!1,mode:"",password:""}),z=()=>{n.current=null,r.current="",l(null)},A=async a=>{g(!0);try{let b,d,e=await fetch("/api/settings/config/export",{headers:{"x-9r-password":a}}),f=await e.json().catch(()=>({}));if(!e.ok)throw Error(f.error||"Export failed");b=URL.createObjectURL(new Blob([JSON.stringify(f,null,2)],{type:"application/json"})),(d=document.createElement("a")).href=b,d.download=`${m.Hc.slug}-config-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(b),c({type:"ok",message:"Configuration exported"})}catch(a){c({type:"err",message:a.message||"Export failed"})}finally{g(!1)}},B=async a=>{g(!0);try{let b=await u({doc:n.current,mode:"preview",password:a});r.current=a,l(b)}catch(a){n.current=null,c({type:"err",message:a.message})}finally{g(!1)}},C=async()=>{g(!0);try{let b=await u({doc:n.current,mode:"apply",password:r.current});z(),a?.(),c({type:"ok",message:b.restartRequired?"Configuration imported. Some changes apply after a restart.":"Configuration imported"})}catch(a){l(b=>b?{...b,applyError:a.message}:b)}finally{g(!1)}},D=async a=>{let b=a.target.files?.[0];if(x.current&&(x.current.value=""),b){if(c({type:"",message:""}),b.size>1048576)return void c({type:"err",message:"That file is too large (max 1 MB)"});try{n.current=JSON.parse(await b.text())}catch{n.current=null,c({type:"err",message:"That file isn't valid JSON"});return}i({open:!0,mode:"import",password:""})}},E=()=>{let{mode:a,password:b}=h;y(),"export"===a?A(b):B(b)},F=k&&s.some(([a])=>k.diff[a].changed+k.diff[a].added>0);return(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(j.default,{variant:"secondary",icon:"download",loading:f&&"export"===h.mode,disabled:f,onClick:()=>{c({type:"",message:""}),i({open:!0,mode:"export",password:""})},children:"Export config"}),(0,d.jsx)(j.default,{variant:"secondary",icon:"upload",disabled:f,onClick:()=>x.current?.click(),children:"Import"}),(0,d.jsx)("input",{ref:x,type:"file",accept:"application/json,.json",onChange:D,className:"hidden",tabIndex:-1,"aria-hidden":"true"})]}),(0,d.jsx)("div",{"aria-live":"polite","aria-atomic":"true",children:b.message&&(0,d.jsx)(o.default,{variant:"ok"===b.type?"ok":"err",title:b.message})}),(0,d.jsxs)(q.default,{isOpen:h.open,onClose:y,title:"Confirm password",size:"sm",footer:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.default,{variant:"ghost",onClick:y,children:"Cancel"}),(0,d.jsx)(j.default,{onClick:E,disabled:!h.password,children:"Confirm"})]}),children:[(0,d.jsx)("p",{className:"mb-3 text-sm text-muted",children:"export"===h.mode?"Enter your current password to export the configuration.":"Enter your current password to check this configuration file."}),(0,d.jsx)(p.default,{type:"password",autoComplete:"current-password","aria-label":"Current password",value:h.password,onChange:a=>i(b=>({...b,password:a.target.value})),onKeyDown:a=>{"Enter"===a.key&&h.password&&E()},placeholder:"Current password"}),(0,d.jsx)("p",{className:"mt-3 text-[13px] text-muted",children:t})]}),(0,d.jsx)(q.default,{isOpen:!!k,onClose:z,title:"Import configuration",size:"lg",footer:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.default,{variant:"ghost",onClick:z,disabled:f,children:"Cancel"}),(0,d.jsx)(j.default,{onClick:C,loading:f,disabled:!F,children:"Apply import"})]}),children:k&&(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("p",{className:"text-sm text-muted",children:t}),k.redactedSettings?.length>0&&(0,d.jsx)(o.default,{variant:"info",title:"URLs with credentials were masked on export",children:(0,d.jsxs)("p",{children:[k.redactedSettings.join(", "),": these keep their current values unless you re-enter the full URL before applying."]})}),k.warnings?.length>0&&(0,d.jsx)(o.default,{variant:"warn",title:"Some entries will be skipped",children:(0,d.jsx)("ul",{className:"list-disc ps-5",children:k.warnings.map(a=>(0,d.jsx)("li",{children:a},a))})}),k.restartRequired&&(0,d.jsx)(o.default,{variant:"info",title:"Some changes apply after a restart"}),!F&&(0,d.jsx)(o.default,{variant:"ok",title:"Nothing to change: this matches your current setup"}),s.map(([a,b])=>(0,d.jsx)(v,{label:b,section:k.diff[a]},a)),(0,d.jsx)("p",{className:"text-[13px] text-muted",children:"Import adds and updates entries. Nothing is removed. All changes apply together or not at all."}),k.applyError&&(0,d.jsx)("div",{role:"alert",children:(0,d.jsx)(o.default,{variant:"err",title:k.applyError})})]})})]})}v.propTypes={label:l().string.isRequired,section:l().shape({changed:l().number,added:l().number,unchanged:l().number,entries:l().arrayOf(l().shape({key:l().string.isRequired,status:l().oneOf(["changed","added","unchanged"]).isRequired,restart:l().bool}))})},w.propTypes={onSettingsChange:l().func};var x=c(42118),y=c(78197),z=c(1582),A=c(91099),B=c(31023),C=c(267),D=c(51126),E=c(81725);function F(a,b){switch(b.type){case"optimistic":return{...a,value:b.value,status:"saving",error:""};case"saved":return{value:b.value,savedValue:b.value,status:"saved",error:""};case"failed":return{...a,value:a.savedValue,status:"error",error:b.error};case"sync":if("saving"===a.status)return a;return{...a,value:b.value,savedValue:b.value,error:""};case"clear-error":return{...a,status:"idle",error:""};default:return a}}function G(a){return{value:a,savedValue:a,status:"idle",error:""}}async function H(a,b){let c=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:b})}),d=await c.json().catch(()=>({}));if(!c.ok)throw Error(d.error||"Failed to save setting");return d}function I(a,b,c={}){let{debounced:d=!1,onSaved:f,restartRequired:g=!1}=c,[h,i]=(0,e.useReducer)(F,b,G),j=(0,e.useRef)(f);j.current=f;let k=(0,e.useCallback)(async b=>{try{let c=await H(a,b),d=Object.hasOwn(c,a)?c[a]:b;i({type:"saved",value:d}),j.current?.(d,{restartRequired:g})}catch(a){i({type:"failed",error:a.message})}},[a,g]),l=(0,e.useRef)(null),m=(0,e.useCallback)(a=>{i({type:"optimistic",value:a}),d?l.current?.(a):k(a)},[d,k]),n=(0,e.useCallback)(()=>i({type:"clear-error"}),[]);return{value:h.value,saving:"saving"===h.status,error:h.error,set:m,clearError:n}}c(2362);let J={"/dashboard":"Home","/dashboard/providers":"Providers","/dashboard/combos":"Combos","/dashboard/endpoint":"Endpoint & keys","/dashboard/usage":"Usage","/dashboard/quota":"Quota","/dashboard/console-log":"Console log","/dashboard/token-saver":"Token saver","/dashboard/cli-tools":"CLI tools","/dashboard/media-providers":"Media providers","/dashboard/proxy-pools":"Proxy pools","/dashboard/skills":"Skills","/dashboard/settings":"Settings","/dashboard/translator":"Translator"},K=["/dashboard","/dashboard/providers","/dashboard/combos","/dashboard/endpoint","/dashboard/usage","/dashboard/quota","/dashboard/console-log","/dashboard/token-saver","/dashboard/cli-tools","/dashboard/media-providers","/dashboard/proxy-pools","/dashboard/skills","/dashboard/settings","/dashboard/translator"].map(a=>({value:a,label:J[a]||a})),L=[{value:"light",label:"Light",icon:"light_mode"},{value:"dark",label:"Dark",icon:"dark_mode"},{value:"system",label:"System",icon:"contrast"}],M=[{value:"comfortable",label:"Comfortable"},{value:"compact",label:"Compact"}];function N({settings:a,locale:b="en",onLocaleChange:c,onSettingsChange:f}){let{theme:g,setTheme:h}=(0,x.D)(),[i,k]=(0,e.useState)(!1),l=I("startPage",a.startPage||"/dashboard",{onSaved:a=>f?.({startPage:a})}),m=I("uiDensity",a.uiDensity||"comfortable",{onSaved:a=>{(0,E.pW)(a),f?.({uiDensity:a})}});return(0,d.jsxs)("div",{id:"general",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"tune",title:"General",subtitle:"Look, language and where you land."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Theme",description:"Dark, light, or follow your system.",settingKey:"theme",control:(0,d.jsx)(A.default,{options:L,value:g,onChange:h,"aria-label":"Theme preference"})}),(0,d.jsx)(z.default,{label:"Language",description:"Dashboard language.",settingKey:"language",control:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(j.default,{variant:"secondary",icon:"language",onClick:()=>k(!0),children:D.kf[b]||b}),(0,d.jsx)(C.default,{hideTrigger:!0,isOpen:i,onClose:a=>{k(!1),a&&c?.(a)}})]})}),(0,d.jsx)(z.default,{label:"Start page",description:"Where you land after login and on `/`.",settingKey:"startPage",control:(0,d.jsxs)("div",{className:"w-56",children:[(0,d.jsx)(B.default,{"aria-label":"Start page",options:K,value:l.value,onChange:a=>l.set(a.target.value),disabled:l.saving}),l.error&&(0,d.jsx)("p",{className:"mt-1 text-xs text-err",role:"alert",children:l.error})]})}),(0,d.jsx)(z.default,{label:"Density",description:"Compact tightens spacing and row heights.",settingKey:"uiDensity",control:(0,d.jsxs)("div",{children:[(0,d.jsx)(A.default,{options:M,value:m.value,onChange:m.set,"aria-label":"Density preference"}),m.error&&(0,d.jsx)("p",{className:"mt-1 text-xs text-err",role:"alert",children:m.error})]})})]})]})}N.propTypes={settings:l().object.isRequired,locale:l().string,onLocaleChange:l().func,onSettingsChange:l().func};var O=c(95514),P=c(67635);function Q({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),f=I("requireLogin",!1!==a.requireLogin,{onSaved:c("requireLogin")}),g=I("requireApiKey",!1!==a.requireApiKey,{onSaved:c("requireApiKey")}),h=I("tunnelDashboardAccess",!1!==a.tunnelDashboardAccess,{onSaved:c("tunnelDashboardAccess")}),[k,l]=(0,e.useState)(null),[m,n]=(0,e.useState)(!1),[q,r]=(0,e.useState)({current:"",next:"",confirm:""}),[s,t]=(0,e.useState)({type:"",message:""}),[u,v]=(0,e.useState)(!1),w=async a=>{if(a.preventDefault(),q.next!==q.confirm)return void t({type:"err",message:"Passwords do not match"});if(!q.next)return void t({type:"err",message:"New password cannot be empty"});v(!0),t({type:"",message:""});try{let a=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:q.current,newPassword:q.next})}),c=await a.json().catch(()=>({}));a.ok?(t({type:"ok",message:"Password updated successfully"}),r({current:"",next:"",confirm:""}),b?.({hasPassword:!0})):t({type:"err",message:c.error||"Failed to update password"})}catch{t({type:"err",message:"An error occurred while updating password"})}finally{v(!1)}};return(0,d.jsxs)("div",{id:"security",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"shield",title:"Security & access",subtitle:"Who can reach the dashboard and the API.",status:"ok",statusLabel:"Protected"}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Require login",description:"Ask for the dashboard password first.",settingKey:"requireLogin",control:(0,d.jsx)(O.default,{checked:f.value,onChange:a=>f.set(a),disabled:f.saving,"aria-label":"Require login"})}),f.error&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:f.error}),(0,d.jsxs)("div",{className:"py-4 space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Password"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Change the dashboard password. Replace the default before exposing anything."})]}),(0,d.jsxs)("form",{onSubmit:w,className:"space-y-3 max-w-xl",children:[a.hasPassword&&(0,d.jsx)(p.default,{label:"Current password",type:"password",autoComplete:"current-password",value:q.current,onChange:a=>r(b=>({...b,current:a.target.value})),required:!0,disabled:u,placeholder:"Current password"}),(0,d.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,d.jsx)(p.default,{label:"New password",type:"password",autoComplete:"new-password",value:q.next,onChange:a=>r(b=>({...b,next:a.target.value})),required:!0,disabled:u,placeholder:"New password"}),(0,d.jsx)(p.default,{label:"Confirm new password",type:"password",autoComplete:"new-password",value:q.confirm,onChange:a=>r(b=>({...b,confirm:a.target.value})),required:!0,disabled:u,placeholder:"Confirm password"})]}),s.message&&(0,d.jsx)(o.default,{variant:"ok"===s.type?"ok":"err",title:s.message}),(0,d.jsx)(j.default,{type:"submit",loading:u,disabled:u||void 0===a.hasPassword,children:a.hasPassword?"Update password":"Set password"})]})]}),(0,d.jsx)(z.default,{label:"Require API key",description:"Requests without a valid key get a 401. Needed for the tunnel.",settingKey:"requireApiKey",control:(0,d.jsx)(O.default,{checked:g.value,onChange:a=>g.set(a),disabled:g.saving,"aria-label":"Require API key"})}),g.error&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:g.error}),(0,d.jsx)(z.default,{label:"Dashboard over tunnel",description:"Serve this dashboard on the public tunnel URL too.",settingKey:"tunnelDashboardAccess",control:(0,d.jsx)(O.default,{checked:h.value,onChange:a=>h.set(a),disabled:h.saving,"aria-label":"Dashboard over tunnel"})}),h.error&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:h.error}),(0,d.jsx)(z.default,{label:"Secure session cookie",description:"HTTPS-only cookie for the login session.",settingKey:"AUTH_COOKIE_SECURE",control:(0,d.jsx)("div",{className:"w-full sm:min-w-72 sm:max-w-sm",children:k?(0,d.jsx)(P.default,{value:k,label:"Copy secure cookie state"}):m?(0,d.jsx)("p",{className:"text-sm text-err",role:"alert",children:"Could not load cookie state"}):(0,d.jsx)("div",{role:"status","aria-label":"Loading cookie state",children:(0,d.jsx)(i.Skeleton,{className:"h-11 w-full"})})})})]})]})}async function R(a){return T("/api/settings","PATCH",a)}async function S(a,b){let c=await T(a,"POST",b);if(!c?.ok)throw Error(c?.error||"Request failed");return c}async function T(a,b,c){let d=await fetch(a,{method:b,headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),e=await d.json().catch(()=>({}));if(!d.ok)throw Error(e.error||`Request failed (${d.status})`);return e}Q.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var U=c(89322);let V="openid profile email",W="Sign in with OIDC";function X({settings:a,authMode:b,redirectUri:c,onSaved:f}){let[g,h]=(0,e.useState)({oidcIssuerUrl:a.oidcIssuerUrl||"",oidcClientId:a.oidcClientId||"",oidcScopes:a.oidcScopes||V,oidcLoginLabel:a.oidcLoginLabel||W}),[i,k]=(0,e.useState)(""),[l,n]=(0,e.useState)(""),[q,r]=(0,e.useState)({type:"",message:""}),s=a=>b=>h(c=>({...c,[a]:b.target.value})),t=()=>{let a={authMode:b,ssoType:"oidc",oidcIssuerUrl:g.oidcIssuerUrl.trim(),oidcClientId:g.oidcClientId.trim(),oidcScopes:g.oidcScopes.trim()||V,oidcLoginLabel:g.oidcLoginLabel.trim()||W};return i.trim()&&(a.oidcClientSecret=i.trim()),a},u=async()=>{let a=await R(t());return k(""),f(a),a},v=async c=>{c.preventDefault();let d=t();if("password"!==b&&(!d.oidcIssuerUrl||!d.oidcClientId||!d.oidcClientSecret)&&!a.oidcConfigured)return void r({type:"err",message:"Issuer URL, client ID, and client secret are required to enable OIDC."});n("save"),r({type:"",message:""});try{await u(),r({type:"ok",message:"sso"===b?"OIDC login enabled":"both"===b?"Password and OIDC login enabled":"OIDC settings saved"})}catch(a){r({type:"err",message:a.message||"Failed to save OIDC settings"})}finally{n("")}},w=async()=>{if(!g.oidcIssuerUrl.trim()||!g.oidcClientId.trim())return void r({type:"err",message:"Issuer URL and client ID are required to test the connection."});n("test"),r({type:"",message:""});try{let a,b,c;try{a=await u()}catch(a){throw Error(a.message||"Failed to save OIDC settings before testing")}let d=await S("/api/auth/oidc/test",{issuerUrl:a.oidcIssuerUrl,clientId:a.oidcClientId,scopes:a.oidcScopes||V});r({type:"ok",message:(b=`Connection OK. Discovery loaded from ${d.issuerUrl}.`,c=d.clientSecretTested?!0===d.clientSecretValid?`${b} Client secret validated too.`:`${b} Client secret was not checked.`:b,Array.isArray(d.signingAlgs)&&d.signingAlgs.length>0&&(c+=` Signing: ${d.signingAlgs.join(", ")}.`),Array.isArray(d.warnings)&&d.warnings.length>0&&(c+=` ${d.warnings.join(" ")}`),c)})}catch(a){r({type:"err",message:a.message||"OIDC connection test failed"})}finally{n("")}},x=""!==l;return(0,d.jsxs)("form",{onSubmit:v,className:"flex flex-col gap-4",children:[(0,d.jsx)(p.default,{label:"Issuer URL",value:g.oidcIssuerUrl,onChange:s("oidcIssuerUrl"),placeholder:`https://auth.example.com/application/o/${m.Hc.slug}/`,disabled:x}),(0,d.jsx)(p.default,{label:"Client ID",value:g.oidcClientId,onChange:s("oidcClientId"),placeholder:`${m.Hc.slug}-dashboard`,disabled:x}),(0,d.jsx)(p.default,{label:"Client secret",type:"password",autoComplete:"new-password",value:i,onChange:a=>k(a.target.value),placeholder:"Leave blank to keep existing secret",hint:"This value is write-only after saving.",disabled:x}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,d.jsx)(p.default,{label:"Scopes",value:g.oidcScopes,onChange:s("oidcScopes"),placeholder:V,disabled:x}),(0,d.jsx)(p.default,{label:"Button label",value:g.oidcLoginLabel,onChange:s("oidcLoginLabel"),placeholder:W,disabled:x})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-text",children:"Redirect URI \xb7 give this to your IdP"}),(0,d.jsx)(P.default,{value:c,label:"Copy redirect URI"})]}),(0,d.jsx)("div",{"aria-live":"polite",children:q.message&&(0,d.jsx)(o.default,{variant:"ok"===q.type?"ok":"err",title:q.message})}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(j.default,{type:"submit",loading:"save"===l,disabled:x,children:"Save OIDC settings"}),(0,d.jsx)(j.default,{type:"button",variant:"secondary",onClick:w,loading:"test"===l,disabled:x,children:"Test sign-in"})]})]})}X.propTypes={settings:l().object.isRequired,authMode:l().oneOf(["password","sso","both"]).isRequired,redirectUri:l().string.isRequired,onSaved:l().func.isRequired};var Y=c(44928);function Z({children:a}){return(0,d.jsx)("code",{className:"break-all font-mono text-text",children:a})}function $({title:a,steps:b}){return(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 rounded-lg border border-line bg-panel p-3",children:[(0,d.jsx)("p",{className:"font-semibold text-text",children:a}),(0,d.jsx)("ol",{className:"list-decimal space-y-1 ps-4 text-muted",children:b.map((a,b)=>(0,d.jsx)("li",{children:a},b))})]})}function _({acsUrl:a,entityId:b}){return(0,d.jsxs)("div",{className:"flex flex-col gap-3 text-xs",children:[(0,d.jsxs)("div",{className:"rounded-lg bg-sky-bg p-3 text-text",children:[(0,d.jsx)("p",{className:"mb-1 font-semibold",children:"Required service provider (SP) values for your IdP"}),(0,d.jsxs)("ul",{className:"list-disc space-y-1 ps-4",children:[(0,d.jsxs)("li",{children:["Assertion Consumer Service (ACS) URL: ",(0,d.jsx)(Z,{children:a})]}),(0,d.jsxs)("li",{children:["SP entity ID / audience URI: ",(0,d.jsx)(Z,{children:b})]}),(0,d.jsxs)("li",{children:["NameID format: ",(0,d.jsx)(Z,{children:"EmailAddress"})," or ",(0,d.jsx)(Z,{children:"Unspecified"})]})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[(0,d.jsx)($,{title:"AWS IAM Identity Center",steps:["Applications → Add application → Add custom SAML 2.0 application.",(0,d.jsxs)(d.Fragment,{children:["Set application ACS URL to ",(0,d.jsx)(Z,{children:a}),"."]}),(0,d.jsxs)(d.Fragment,{children:["Set application SAML audience to ",(0,d.jsx)(Z,{children:b}),"."]}),(0,d.jsxs)(d.Fragment,{children:["Under Attribute mappings, map ",(0,d.jsx)(Z,{children:"Subject"})," or ",(0,d.jsx)(Z,{children:"email"})," to"," ",(0,d.jsx)(Z,{children:"${user:email}"}),"."]}),"Download the IAM Identity Center SAML metadata XML and import it below."]}),(0,d.jsx)($,{title:"Microsoft Entra ID (Azure AD)",steps:["Enterprise Applications → New application → Create your own application.","Select Single sign-on → SAML.",(0,d.jsxs)(d.Fragment,{children:["Identifier (Entity ID): ",(0,d.jsx)(Z,{children:b})]}),(0,d.jsxs)(d.Fragment,{children:["Reply URL (ACS): ",(0,d.jsx)(Z,{children:a})]}),"Download Federation Metadata XML and import it, or copy the X.509 certificate."]}),(0,d.jsx)($,{title:"Okta / Auth0",steps:["Applications → Create App Integration → SAML 2.0.",(0,d.jsxs)(d.Fragment,{children:["Single Sign-On URL: ",(0,d.jsx)(Z,{children:a})]}),(0,d.jsxs)(d.Fragment,{children:["Audience URI (SP Entity ID): ",(0,d.jsx)(Z,{children:b})]}),"Name ID format: EmailAddress.","Download the Identity Provider metadata XML or copy the X.509 certificate."]}),(0,d.jsx)($,{title:"Keycloak / Authentik",steps:["Clients → Create client → SAML.",(0,d.jsxs)(d.Fragment,{children:["Client ID: ",(0,d.jsx)(Z,{children:b})]}),(0,d.jsxs)(d.Fragment,{children:["Master SAML Processing URL: ",(0,d.jsx)(Z,{children:a})]}),"Export the SAML descriptor XML or copy the IdP certificate PEM."]})]})]})}Z.propTypes={children:l().node},$.propTypes={title:l().string.isRequired,steps:l().arrayOf(l().node)},_.propTypes={acsUrl:l().string.isRequired,entityId:l().string.isRequired};let aa=m.Hc.samlIssuerDefault,ab="Sign in with SAML SSO";function ac({settings:a,authMode:b,acsUrl:c,metadataUrl:f,onSaved:g}){let[h,i]=(0,e.useState)({samlEntryPoint:a.samlEntryPoint||"",samlIssuer:a.samlIssuer||aa,samlCert:a.samlCert||"",samlLoginLabel:a.samlLoginLabel||ab,samlAttributeEmail:a.samlAttributeEmail||"email",samlAttributeName:a.samlAttributeName||"name"}),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)({type:"",message:""}),[q,r]=(0,e.useState)(!1),s=(0,e.useRef)(null),t=(0,e.useRef)(null),u=a=>b=>i(c=>({...c,[a]:b.target.value})),v=async a=>{a.preventDefault(),l("save"),n({type:"",message:""});try{let a=await R({authMode:b,ssoType:"saml",samlEntryPoint:h.samlEntryPoint.trim(),samlIssuer:h.samlIssuer.trim()||aa,samlCert:h.samlCert.trim(),samlLoginLabel:h.samlLoginLabel.trim()||ab,samlAttributeEmail:h.samlAttributeEmail.trim()||"email",samlAttributeName:h.samlAttributeName.trim()||"name"});g(a),n({type:"ok",message:"sso"===b?"SAML SSO login enabled":"both"===b?"Password and SAML SSO login enabled":"SAML 2.0 settings saved"})}catch(a){n({type:"err",message:a.message||"Failed to save SAML settings"})}finally{l("")}},w=async()=>{l("test"),n({type:"",message:""});try{let a=await S("/api/auth/saml/test",{samlEntryPoint:h.samlEntryPoint.trim(),samlIssuer:h.samlIssuer.trim()||aa,samlCert:h.samlCert.trim()});n({type:"ok",message:a.message||"SAML configuration verified!"})}catch(a){n({type:"err",message:a.message||"SAML configuration test failed"})}finally{l("")}},x=""!==k;return(0,d.jsxs)("form",{onSubmit:v,className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"rounded-xl border border-line bg-raised p-3",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>r(a=>!a),"aria-expanded":q,className:"flex w-full items-center justify-between text-start text-xs font-semibold text-text",children:[(0,d.jsxs)("span",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] text-coral","aria-hidden":"true",children:"menu_book"}),"IdP setup guidelines & provider instructions"]}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:q?"expand_less":"expand_more"})]}),q&&(0,d.jsx)("div",{className:"mt-3 border-t border-line pt-3",children:(0,d.jsx)(_,{acsUrl:c,entityId:h.samlIssuer||aa})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 rounded-xl border border-dashed border-coral/40 bg-coral-bg p-3",children:[(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("p",{className:"text-sm font-semibold text-text",children:"1-click IdP metadata XML import"}),(0,d.jsx)("p",{className:"text-xs text-muted",children:"Auto-fill SSO URL, entity ID and cert from the IdP XML."})]}),(0,d.jsx)(j.default,{type:"button",variant:"secondary",size:"sm",icon:"upload_file",onClick:()=>t.current?.click(),disabled:x,children:"Upload metadata XML"}),(0,d.jsx)("input",{ref:t,type:"file",accept:".xml,application/xml,text/xml",onChange:a=>{let b=a.target.files?.[0];if(t.current&&(t.current.value=""),!b)return;let c=new FileReader;c.onload=a=>{let b=function(a){let b=new DOMParser().parseFromString(a,"text/xml");if(b.querySelector("parsererror"))return null;let c="";for(let a of b.querySelectorAll("SingleSignOnService, *|SingleSignOnService")){let b=a.getAttribute("Location")||"";if(b&&(c=b,(a.getAttribute("Binding")||"").includes("HTTP-Redirect")))break}let d=b.querySelector("X509Certificate, *|X509Certificate");return{entityId:b.documentElement.getAttribute("entityID")||"",ssoUrl:c,cert:d?.textContent.trim()||""}}(a.target?.result||"");b?(i(a=>({...a,samlEntryPoint:b.ssoUrl||a.samlEntryPoint,samlCert:b.cert||a.samlCert})),n({type:"ok",message:`IdP metadata imported (SSO URL: ${b.ssoUrl?"found":"not found"}, cert: ${b.cert?"found":"not found"}).`})):n({type:"err",message:"Unable to parse valid SAML IdP metadata"})},c.onerror=()=>n({type:"err",message:"Error reading metadata file"}),c.readAsText(b)},className:"hidden"})]}),(0,d.jsx)(p.default,{label:"Single sign-on service URL (samlEntryPoint)",value:h.samlEntryPoint,onChange:u("samlEntryPoint"),placeholder:"https://idp.example.com/app/saml/sso/...",disabled:x}),(0,d.jsx)(p.default,{label:"SP entity ID / audience (samlIssuer)",value:h.samlIssuer,onChange:u("samlIssuer"),placeholder:aa,disabled:x}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-text",children:"IdP X.509 certificate (samlCert)"}),(0,d.jsx)(j.default,{type:"button",variant:"ghost",size:"sm",icon:"file_upload",onClick:()=>s.current?.click(),disabled:x,children:"Upload cert"}),(0,d.jsx)("input",{ref:s,type:"file",accept:".crt,.pem,.cer,text/plain",onChange:a=>{let b=a.target.files?.[0];if(s.current&&(s.current.value=""),!b)return;let c=new FileReader;c.onload=a=>{i(b=>({...b,samlCert:String(a.target?.result||"").trim()})),n({type:"ok",message:"Certificate file loaded into configuration."})},c.onerror=()=>n({type:"err",message:"Error reading certificate file"}),c.readAsText(b)},className:"hidden"})]}),(0,d.jsx)(Y.default,{"aria-label":"IdP X.509 certificate (samlCert)",value:h.samlCert,onChange:u("samlCert"),placeholder:"Paste raw Base64 certificate or PEM block",rows:4,disabled:x,textareaClassName:"font-mono text-xs"}),(0,d.jsx)("p",{className:"text-xs text-muted",children:"Paste raw Base64 certificate or PEM block."})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,d.jsx)(p.default,{label:"Login button label",value:h.samlLoginLabel,onChange:u("samlLoginLabel"),placeholder:ab,disabled:x}),(0,d.jsx)(p.default,{label:"Email claim attribute",value:h.samlAttributeEmail,onChange:u("samlAttributeEmail"),placeholder:"email",disabled:x}),(0,d.jsx)(p.default,{label:"Display name claim",value:h.samlAttributeName,onChange:u("samlAttributeName"),placeholder:"name",disabled:x})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-text",children:"ACS callback URL"}),(0,d.jsx)(P.default,{value:c,label:"Copy ACS URL"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-text",children:"SP XML metadata"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"min-w-0 flex-1",children:(0,d.jsx)(P.default,{value:f,label:"Copy metadata URL"})}),(0,d.jsx)(j.default,{type:"button",variant:"secondary",icon:"download",href:f,children:"Download XML"})]})]}),(0,d.jsx)("div",{"aria-live":"polite",children:m.message&&(0,d.jsx)(o.default,{variant:"ok"===m.type?"ok":"err",title:m.message})}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(j.default,{type:"submit",loading:"save"===k,disabled:x,children:"Save SAML settings"}),(0,d.jsx)(j.default,{type:"button",variant:"secondary",onClick:w,loading:"test"===k,disabled:x,children:"Test sign-in"})]})]})}ac.propTypes={settings:l().object.isRequired,authMode:l().oneOf(["password","sso","both"]).isRequired,acsUrl:l().string.isRequired,metadataUrl:l().string.isRequired,onSaved:l().func.isRequired};let ad=[{value:"password",label:"Password only"},{value:"sso",label:"SSO only"},{value:"both",label:"Both"}],ae=[{value:"oidc",label:"OIDC"},{value:"saml",label:"SAML 2.0"}];function af(a){return"saml"===a?"SAML 2.0":"OIDC"}function ag({settings:a,onSettingsChange:b}){var c;let[f,g]=(0,e.useState)("saml"===(c=a.authMode)||"oidc"===c?"sso":"both"===c||"sso"===c?c:"password"),[h,i]=(0,e.useState)("saml"===a.ssoType?"saml":"oidc"),[j,k]=(0,e.useState)(""),l=(0,e.useRef)(0),m=async(a,c,d)=>{let e=++l.current;k("");try{let d=await R({[a]:c});if(l.current!==e)return;b?.(d)}catch(a){if(l.current!==e)return;d(),k(a.message||"Failed to save sign-in method")}},n=a.authMode,p=(0,U.b)({authMode:n,ssoType:a.ssoType}).ssoOnly;return(0,d.jsxs)("div",{id:"sso",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"lock_open",title:"Single sign-on",subtitle:"Sign in with your identity provider."}),(0,d.jsxs)("div",{className:"divide-y divide-line rounded-2xl border border-line bg-panel p-5 shadow-card",children:[(0,d.jsx)(z.default,{label:"Sign-in method",description:"Password only, SSO only, or both.",settingKey:"authMode",control:(0,d.jsx)(A.default,{options:ad,value:f,onChange:a=>{g(a),m("authMode",a,()=>g(f))},"aria-label":"Sign-in method"})}),(0,d.jsx)(z.default,{label:"Protocol",description:"OIDC or SAML 2.0.",settingKey:"ssoType",control:(0,d.jsx)(A.default,{options:ae,value:h,onChange:a=>{i(a),m("ssoType",a,()=>i(h))},"aria-label":"SSO protocol"})}),j&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:j}),(0,d.jsx)("div",{className:"py-4",children:"saml"===h?(0,d.jsx)(ac,{settings:a,authMode:f,acsUrl:"/api/auth/saml/acs",metadataUrl:"/api/auth/saml/metadata",onSaved:a=>b?.(a)},`saml:${a.samlEntryPoint??""}:${a.samlIssuer??""}:${a.samlCert??""}`):(0,d.jsx)(X,{settings:a,authMode:f,redirectUri:"/api/auth/oidc/callback",onSaved:a=>b?.(a)},`oidc:${a.oidcIssuerUrl??""}:${a.oidcClientId??""}:${a.oidcConfigured??""}`)}),p&&(0,d.jsx)(o.default,{variant:"warn",title:`SSO login (${af(a.ssoType)}) is currently active.`,children:"Password login is disabled until you switch back."}),"both"===n&&(0,d.jsx)(o.default,{variant:"warn",title:`Password and SSO login (${af(a.ssoType)}) are both active.`})]})]})}ag.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var ah=c(79735),ai=c.n(ah),aj=c(69814),ak=c(24279),al=c(83035);function am(a={},b,c={}){let d={...a||{}},e={...a?.[b]||{}},{fallbackStrategy:f,stickyRoundRobinLimit:g}=c||{};f?e.fallbackStrategy=f:delete e.fallbackStrategy;let h=""===g||null==g?null:Number(g);return null!=h&&Number.isInteger(h)?e.stickyRoundRobinLimit=h:delete e.stickyRoundRobinLimit,0===Object.keys(e).length?delete d[b]:d[b]=e,d}let an=[{value:"fill-first",label:"Fill first"},{value:"round-robin",label:"Round robin"},{value:"weighted",label:"Weighted"}];function ao(a){if(!a||"object"!=typeof a)return"";let b="string"==typeof a.name?a.name.trim():"";return b&&b!==a.id?b:"string"==typeof a.displayName&&a.displayName.trim()?a.displayName.trim():a.id||""}function ap({overrides:a,onOverridesChange:b}){let[c,f]=(0,e.useState)([]),[g,h]=(0,e.useState)(""),[i,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(!1),[p,r]=(0,e.useState)(""),[s,t]=(0,e.useState)("round-robin"),[u,v]=(0,e.useState)(1),[w,x]=(0,e.useState)(""),y=(0,e.useMemo)(()=>{let b=c.map(a=>({value:a.id,label:ao(a)===a.id?a.id:`${ao(a)} (${a.id})`})),d=new Set(b.map(a=>a.value));for(let c of Object.keys(a))d.has(c)||b.push({value:c,label:c});return b.sort((a,b)=>a.value.localeCompare(b.value))},[c,a]),z=async c=>{k(!0),m("");try{let a=await fetch("/api/settings",{cache:"no-store"});if(!a.ok)throw Error("Could not load current overrides.");let d=await a.json(),e=d.providerStrategies&&"object"==typeof d.providerStrategies?d.providerStrategies:{},f=c(e);b?.(f);let g=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:f})}),h=await g.json().catch(()=>({}));if(!g.ok)throw Error(h.error||"Could not save overrides.");b?.(h.providerStrategies??f)}catch(c){b?.(a),m(c instanceof Error?c.message:"Could not save overrides.")}finally{k(!1)}},A=(b,c,d)=>{let e=a[b]||{};z(a=>am(a,b,"strategy"===c?{fallbackStrategy:d||"",stickyRoundRobinLimit:e.stickyRoundRobinLimit??""}:{fallbackStrategy:e.fallbackStrategy||"",stickyRoundRobinLimit:""===d?"":Number(d)}))};return(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-x-6 gap-y-3",children:[(0,d.jsxs)("div",{className:"min-w-52 flex-1",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Per-provider overrides"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Beat the global strategy for one provider."}),(0,d.jsx)("p",{className:"mt-0.5 font-mono text-[11px] text-subtle",children:"providerStrategies"})]}),(0,d.jsx)(j.default,{variant:"secondary",size:"sm",icon:"add",onClick:()=>{r(""),t("round-robin"),v(1),x(""),o(!0)},children:"Add"})]}),g&&(0,d.jsx)("p",{className:"pt-2 text-xs text-err",role:"alert",children:g}),l&&(0,d.jsx)("p",{className:"pt-2 text-xs text-err",role:"alert",children:l}),(0,d.jsx)("div",{className:"pt-3",children:0===Object.keys(a).length?(0,d.jsx)("p",{className:"text-sm text-muted",children:"No overrides yet. Every provider follows the global strategy above."}):(0,d.jsx)("ul",{className:"divide-y divide-line overflow-hidden rounded-xl border border-line",children:Object.keys(a).sort().map(b=>{let c=a[b]||{},e=y.find(a=>a.value===b)?.label||b;return(0,d.jsxs)("li",{className:"flex flex-wrap items-center gap-3 p-3",children:[(0,d.jsx)(al.default,{providerId:b,size:"md"}),(0,d.jsxs)("div",{className:"min-w-40 flex-1",children:[(0,d.jsx)("p",{className:"text-sm font-semibold text-text",children:e}),(0,d.jsx)("p",{className:"font-mono text-[11px] text-subtle",children:b})]}),(0,d.jsx)(B.default,{label:"Override strategy",value:c.fallbackStrategy||"",onChange:a=>A(b,"strategy",a.target.value),options:an,placeholder:"Inherit global",disabled:i,className:"w-44"}),(0,d.jsx)(aj.default,{label:"Override sticky",value:c.stickyRoundRobinLimit??"",onChange:a=>A(b,"sticky",a),min:1,max:100,disabled:i,"aria-label":`Sticky limit for ${b}`,className:"w-40"}),(0,d.jsx)(j.default,{variant:"ghost",size:"sm",icon:"delete",onClick:()=>{z(a=>(function(a={},b){let c={...a||{}},d={...a?.[b]||{}};return delete d.fallbackStrategy,delete d.stickyRoundRobinLimit,0===Object.keys(d).length?delete c[b]:c[b]=d,c})(a,b))},disabled:i,"aria-label":`Remove override for ${b}`,children:"Remove"})]},b)})})}),(0,d.jsx)(q.default,{isOpen:n,onClose:()=>o(!1),title:"Add provider override",description:"Beat the global strategy for one provider.",footer:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.default,{variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),(0,d.jsx)(j.default,{onClick:()=>{p?Object.hasOwn(a,p)?x("That provider already has an override — edit it instead."):(o(!1),z(a=>am(a,p,{fallbackStrategy:s,stickyRoundRobinLimit:u}))):x("Pick a provider.")},disabled:!p||i,children:"Add override"})]}),children:(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)(B.default,{label:"Provider",value:p,onChange:a=>r(a.target.value),options:y.filter(b=>!Object.hasOwn(a,b.value)),placeholder:0===c.length?"No providers found":"Pick a provider",error:w}),(0,d.jsx)(B.default,{label:"Strategy",value:s,onChange:a=>t(a.target.value),options:an}),(0,d.jsx)(aj.default,{label:"Sticky limit",value:u,onChange:a=>v(Number(a)||1),min:1,max:100,hint:"Calls per account before rotating."})]})})]})}ap.propTypes={overrides:l().object.isRequired,onOverridesChange:l().func};let aq=[{value:"fill-first",label:"Fill first"},{value:"round-robin",label:"Round robin"},{value:"weighted",label:"Weighted"}],ar=new Set(["fallback","round-robin","fusion","weighted"]);function as({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),e=I("fallbackStrategy",a.fallbackStrategy??"fill-first",{onSaved:c("fallbackStrategy")}),f=I("stickyRoundRobinLimit",a.stickyRoundRobinLimit??3,{onSaved:c("stickyRoundRobinLimit")}),g=I("comboStrategy",a.comboStrategy??"fallback",{onSaved:c("comboStrategy")}),h=I("comboStickyRoundRobinLimit",a.comboStickyRoundRobinLimit??1,{onSaved:c("comboStickyRoundRobinLimit")}),i=a.providerStrategies&&"object"==typeof a.providerStrategies?a.providerStrategies:{},j=ar.has(g.value),k="round-robin"===g.value,l="round-robin"===e.value||"weighted"===e.value,m="weighted"===e.value&&1===Number(f.value),n=a.capacityAdapter&&"object"==typeof a.capacityAdapter?a.capacityAdapter:{},p=["vision","pdf","audioInput","videoInput"].map(a=>{let b=n[a];return{cap:a,label:"vision"===a?"Vision":"audioInput"===a?"Audio":"pdf"===a?"PDF":"Video",enabled:b&&"object"==typeof b?!1!==b.enabled:!!b}}),q=function(a={}){let b,c,d=a?.fallbackStrategy??"fill-first",e=a?.stickyRoundRobinLimit??3,f=a?.comboStrategy??"fallback",g=a?.comboStickyRoundRobinLimit??1,h=a?.providerStrategies??{},i=h&&"object"==typeof h?Object.keys(h).length:0;b="round-robin"===d?`Each provider rotates through its accounts in turn, staying ${e} request(s) on one account before moving on.`:"weighted"===d?`Each provider sends requests to accounts with the most remaining quota, staying ${e} request(s) on one account before reconsidering.`:"Right now: each provider uses its accounts in priority order and moves on only when one fails or runs dry.",c="round-robin"===f?`Combos rotate through their models, staying ${g} request(s) per model.`:"fusion"===f?"Combos fuse answers from several models (managed per combo on the Combos page).":"weighted"===f?"Combos weight models by quota (managed per combo on the Combos page).":"Combos try models in order.";let j=0===i?"":1===i?" 1 provider override beats the global strategy.":` ${i} provider overrides beat the global strategy.`;return`${b} ${c}${j}`}({fallbackStrategy:e.value,stickyRoundRobinLimit:f.value,comboStrategy:g.value,comboStickyRoundRobinLimit:h.value,providerStrategies:i});return(0,d.jsxs)("div",{id:"routing",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"route",title:"Routing",subtitle:"How accounts and combos take turns."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsxs)("div",{className:"py-4 first:pt-0",children:[(0,d.jsx)(z.default,{label:"Account strategy",description:"Picks between accounts of the same provider.",settingKey:"fallbackStrategy",control:(0,d.jsx)(A.default,{options:aq,value:e.value,onChange:a=>e.set(a),"aria-label":"Account strategy"})}),e.error&&(0,d.jsx)("p",{className:"py-1 text-xs text-err",role:"alert",children:e.error})]}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)(z.default,{label:"Sticky limit",description:"Calls per account before rotating. Round robin and weighted only.",settingKey:"stickyRoundRobinLimit",control:(0,d.jsx)(aj.default,{value:f.value??3,onChange:a=>f.set(a),min:1,max:100,disabled:!l||f.saving,error:f.error,"aria-label":"Sticky limit"})}),m&&(0,d.jsx)(o.default,{variant:"warn",title:"Sticky 1 with weighted routing",children:"Every request may land on a different subscription account, which can trip anti-abuse flags. Prefer 3 or higher."})]}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)(z.default,{label:"Combo round robin",description:j?"Rotate inside combos by default instead of falling back in order.":`This combo strategy is managed per combo: “${g.value}” is not one of the global options, so the toggle is shown off without changing it.`,settingKey:"comboStrategy",control:(0,d.jsx)(O.default,{checked:k,onChange:a=>g.set(a?"round-robin":"fallback"),"aria-label":"Combo round robin"})}),g.error&&(0,d.jsx)("p",{className:"py-1 text-xs text-err",role:"alert",children:g.error})]}),(0,d.jsx)("div",{className:"py-4",children:(0,d.jsx)(z.default,{label:"Combo sticky limit",description:"Calls per combo model before rotating.",settingKey:"comboStickyRoundRobinLimit",control:(0,d.jsx)(aj.default,{value:h.value??1,onChange:a=>h.set(a),min:1,max:100,disabled:!k||h.saving,error:h.error,"aria-label":"Combo sticky limit"})})}),(0,d.jsx)("div",{className:"py-4",children:(0,d.jsx)(o.default,{variant:"info",children:q})}),(0,d.jsx)("div",{className:"py-4",children:(0,d.jsx)(ap,{overrides:i,onOverridesChange:a=>b?.({providerStrategies:a})})}),(0,d.jsx)("div",{className:"py-4 last:pb-0",children:(0,d.jsx)(z.default,{label:"Capability adapter",description:(0,d.jsxs)("span",{children:["Images or audio go to a capable model when the chosen one can’t read them."," ",(0,d.jsx)(ai(),{href:"/dashboard/combos",className:"underline",children:"Edit in Combos"})]}),settingKey:"capacityAdapter",control:(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:p.map(({cap:a,label:b,enabled:c})=>(0,d.jsxs)(ak.default,{variant:c?"ok":"neutral",size:"sm",dot:!0,children:[b," ",c?"on":"off"]},a))})})})]})]})}as.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var at=c(3090);let au={retryPolicy:{502:{tries:3,delayMs:3e3},503:{tries:3,delayMs:2e3},504:{tries:2,delayMs:3e3}},cooldowns:{rateLimitCapMs:18e5,longMs:12e4,shortMs:5e3,transientMs:3e4},backoff:{startMs:2e3,maxMs:3e5,levels:15},streamTimeouts:{firstChunkMs:2e5,stallMs:36e4,connectMs:6e4}},av=[{status:"502",label:"bad gateway"},{status:"503",label:"unavailable"},{status:"504",label:"timeout"}],aw=["retryPolicy","cooldowns","backoff","streamTimeouts"],ax=[{key:"rateLimitCapMs",label:"Rate-limit cap"},{key:"transientMs",label:"Transient error"},{key:"longMs",label:"Long"},{key:"shortMs",label:"Short"}],ay=[{key:"firstChunkMs",label:"First chunk",envVar:"STREAM_FIRST_CHUNK_TIMEOUT_MS"},{key:"stallMs",label:"Stall",envVar:"STREAM_STALL_TIMEOUT_MS"},{key:"connectMs",label:"Connect",envVar:"FETCH_CONNECT_TIMEOUT_MS"}];function az(a){if(!Number.isFinite(a))return"—";if(a<1e3)return`${a}ms`;let b=a/1e3;if(b<60)return`${b}s`;let c=b/60;if(c<60)return`${Number.isInteger(c)?c:c.toFixed(1)}min`;let d=c/60;return`${Number.isInteger(d)?d:d.toFixed(1)}h`}async function aA(){let a={};for(let b of aw)a[b]=au[b];let b=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>({}));if(!b.ok)throw Error(c.error||"Failed to save setting");return c}function aB({error:a}){return a?(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:a}):null}aB.propTypes={error:l().string};let aC=a=>{if(""===a)return;let b=Number(a);return Number.isFinite(b)?b:void 0};function aD({title:a,description:b,children:c,error:e}){return(0,d.jsxs)("div",{className:"py-4 first:pt-0",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:a}),b&&(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:b}),(0,d.jsx)("div",{className:"mt-3",children:c}),(0,d.jsx)(aB,{error:e})]})}function aE({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),f=I("retryPolicy",a.retryPolicy??au.retryPolicy,{debounced:!0,onSaved:c("retryPolicy")}),g=I("cooldowns",a.cooldowns??au.cooldowns,{debounced:!0,onSaved:c("cooldowns")}),h=I("backoff",a.backoff??au.backoff,{debounced:!0,onSaved:c("backoff")}),i=I("streamTimeouts",a.streamTimeouts??au.streamTimeouts,{debounced:!0,onSaved:c("streamTimeouts")}),k=a.streamEnvOverrides??{},[l,m]=(0,e.useState)(!1),o=(a,b,c)=>{void 0!==c&&a.set(function(a,b,c){let d={...a&&"object"==typeof a?a:{}},e=d;for(let a=0;a<b.length-1;a+=1){let c=b[a];e[c]={...e[c]&&"object"==typeof e[c]?e[c]:{}},e=e[c]}return e[b[b.length-1]]=c,d}(a.value,b,c))},[p,r]=(0,e.useState)(""),s=async()=>{r("");try{let a=await aA();for(let c of aw)b?.({[c]:a[c]??au[c]});m(!1)}catch(a){throw r(a.message),a}};return(0,d.jsxs)("div",{id:"reliability",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"restart_alt",title:(0,d.jsxs)("span",{className:"inline-flex items-center gap-2",children:["Reliability",(0,d.jsx)(n.default,{variant:"live",size:"sm",children:"New"})]}),subtitle:"Retries, cooldowns and timeouts. Changes apply to the next request, no restart."}),(0,d.jsxs)("div",{className:"divide-y divide-line rounded-2xl border border-line bg-panel p-5 shadow-card",children:[(0,d.jsx)(aD,{title:"Retries on upstream errors",description:"429s never retry. They cool the account down and fall back.",error:f.error,children:(0,d.jsxs)("div",{className:"overflow-hidden rounded-xl border border-line text-[13px]",children:[(0,d.jsxs)("div",{"aria-hidden":"true",className:"hidden grid-cols-[minmax(0,1.4fr)_minmax(11rem,1fr)_minmax(0,1fr)] gap-2 bg-raised px-3 py-2 text-xs font-semibold text-muted min-[420px]:grid",children:[(0,d.jsx)("span",{children:"Status"}),(0,d.jsx)("span",{children:"Tries"}),(0,d.jsx)("span",{children:"Delay"})]}),av.map(({status:a,label:b})=>(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 border-t border-line px-3 py-3 first:border-t-0 min-[420px]:grid-cols-[minmax(0,1.4fr)_minmax(11rem,1fr)_minmax(0,1fr)] min-[420px]:items-center min-[420px]:gap-2 min-[420px]:py-2",children:[(0,d.jsxs)("p",{className:"font-normal",children:[(0,d.jsx)("span",{className:"font-mono",children:a})," ",(0,d.jsx)("span",{className:"text-muted",children:b})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-12 text-xs font-semibold text-muted min-[420px]:hidden",children:"Tries"}),(0,d.jsx)(aj.default,{value:f.value?.[a]?.tries??au.retryPolicy[a].tries,onChange:b=>o(f,[a,"tries"],b),min:0,max:10,"aria-label":`${a} tries`})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-12 text-xs font-semibold text-muted min-[420px]:hidden",children:"Delay"}),(0,d.jsx)("div",{className:"min-w-0 flex-1",children:(0,d.jsx)(at.default,{value:f.value?.[a]?.delayMs??au.retryPolicy[a].delayMs,onChange:b=>o(f,[a,"delayMs"],aC(b.target.value)),unit:"ms",min:0,max:6e4,"aria-label":`${a} delay in milliseconds`})})]})]},a))]})}),(0,d.jsx)(aD,{title:"Cooldowns",description:"How long an account sits out after it fails.",error:g.error,children:(0,d.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:ax.map(({key:a,label:b})=>(0,d.jsx)(at.default,{label:b,value:g.value?.[a]??au.cooldowns[a],onChange:b=>o(g,[a],aC(b.target.value)),unit:"ms",hint:`Default ${az(au.cooldowns[a])}`},a))})}),(0,d.jsx)(aD,{title:"Backoff",description:"Grows with each repeated failure.",error:h.error,children:(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,d.jsx)(at.default,{label:"Start",value:h.value?.startMs??au.backoff.startMs,onChange:a=>o(h,["startMs"],aC(a.target.value)),unit:"ms",hint:`Default ${az(au.backoff.startMs)}`}),(0,d.jsx)(at.default,{label:"Max",value:h.value?.maxMs??au.backoff.maxMs,onChange:a=>o(h,["maxMs"],aC(a.target.value)),unit:"ms",hint:`Default ${az(au.backoff.maxMs)}`}),(0,d.jsx)(aj.default,{label:"Levels",value:h.value?.levels??au.backoff.levels,onChange:a=>o(h,["levels"],a),min:1,max:30,hint:`Default ${au.backoff.levels}`})]})}),(0,d.jsx)(aD,{title:"Stream timeouts",description:"When to give up on a slow or stalled upstream. Env vars win over this setting.",error:i.error,children:(0,d.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:ay.map(({key:a,label:b,envVar:c})=>{let e=!0===k[a];return(0,d.jsx)(at.default,{label:(0,d.jsxs)("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[b,e&&(0,d.jsx)(n.default,{variant:"neutral",size:"sm",children:".env overrides"})]}),value:i.value?.[a]??au.streamTimeouts[a],onChange:b=>o(i,[a],aC(b.target.value)),unit:"ms",disabled:e,hint:e?`Set by ${c} in .env. Read-only here.`:`Default ${az(au.streamTimeouts[a])}`},a)})})}),(0,d.jsx)("div",{className:"pt-4",children:(0,d.jsx)(j.default,{variant:"secondary",icon:"restart_alt",onClick:()=>m(!0),children:"Restore defaults"})})]}),(0,d.jsx)(q.ConfirmDialog,{isOpen:l,onClose:()=>{m(!1),r("")},onConfirm:s,title:"Restore reliability defaults?",message:"Retries, cooldowns, backoff and stream timeouts go back to the built-in values.",confirmText:"Restore defaults",error:p||void 0,variant:"primary"})]})}function aF(a){return a?a.enabled?{label:"Connected",variant:"ok"}:a.settingsEnabled?{label:"Starting",variant:"warn"}:{label:"Off",variant:"neutral"}:{label:"Checking",variant:"neutral"}}async function aG(){let a=await fetch("/api/tunnel/status",{cache:"no-store"});if(!a.ok)throw Error(`HTTP ${a.status}`);let b=await a.json();return{tunnel:b.tunnel??null,tailscale:b.tailscale??null}}function aH({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),f=I("outboundProxyEnabled",!0===a.outboundProxyEnabled,{onSaved:c("outboundProxyEnabled")}),g=I("outboundProxyUrl",a.outboundProxyUrl??"",{debounced:!0,onSaved:c("outboundProxyUrl")}),h=I("outboundNoProxy",a.outboundNoProxy??"",{debounced:!0,onSaved:c("outboundNoProxy")}),[i,k]=(0,e.useState)({type:"",message:""}),[l,n]=(0,e.useState)(!1),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)({tunnel:null,tailscale:null}),[u,v]=(0,e.useState)(!0),[w,x]=(0,e.useState)(""),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(null),[G,H]=(0,e.useState)(null),[J,K]=(0,e.useState)(""),L=(0,e.useCallback)(async()=>{v(!0),x("");try{t(await aG())}catch{x("Could not load tunnel status")}finally{v(!1)}},[]),M=async()=>{n(!0),k({type:"",message:""});try{let a=await fetch("/api/settings/proxy-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyUrl:g.value})}),b=await a.json().catch(()=>({}));if(a.ok&&!1!==b.ok){let a="number"==typeof b.elapsedMs?` \xb7 ${b.elapsedMs}ms`:"";k({type:"ok",message:`Reachable${a}`})}else k({type:"err",message:b.error||"Proxy test failed"})}catch{k({type:"err",message:"Proxy test failed"})}finally{n(!1)}},N=async()=>{r(!0),k({type:"",message:""});try{let a=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyEnabled:f.value,outboundProxyUrl:g.value,outboundNoProxy:h.value})}),c=await a.json().catch(()=>({}));if(!a.ok)throw Error(c.error||"Failed to apply proxy settings");b?.({outboundProxyEnabled:c.outboundProxyEnabled,outboundProxyUrl:c.outboundProxyUrl,outboundNoProxy:c.outboundNoProxy}),k({type:"ok",message:"Proxy settings applied"})}catch(a){k({type:"err",message:a.message||"Failed to apply proxy settings"})}finally{r(!1)}},P=async a=>{K(""),B(!0),F(a);try{let c=await fetch(a?"/api/tunnel/enable":"/api/tunnel/disable",{method:"POST"}),d=await c.json().catch(()=>({}));if(!c.ok)throw Error(d.error||"Failed to update tunnel");b?.({tunnelEnabled:a}),await L()}catch(a){K(a.message||"Failed to update tunnel")}finally{B(!1),F(null)}},Q=async a=>{K(""),D(!0),H(a);try{let c=await fetch(a?"/api/tunnel/tailscale-enable":"/api/tunnel/tailscale-disable",{method:"POST"}),d=await c.json().catch(()=>({}));if(!c.ok)throw Error(d.error||"Failed to update Tailscale");b?.({tailscaleEnabled:a}),await L()}catch(a){K(a.message||"Failed to update Tailscale")}finally{D(!1),H(null)}},R=aF(s.tunnel),S=aF(s.tailscale),T=E??s.tunnel?.settingsEnabled===!0,U=G??s.tailscale?.settingsEnabled===!0,V=function({requireLogin:a,hasPassword:b,requireApiKey:c}){return a?b?c?"":'Enable "Require API key" before activating the tunnel.':"Change the default dashboard password before activating the tunnel.":'Enable "Require login" and set a custom password before activating the tunnel.'}({requireLogin:!1!==a.requireLogin,hasPassword:!0===a.hasPassword,requireApiKey:!0===a.requireApiKey}),W=function({requireLogin:a,hasPassword:b}){return a?b?"":"Change the default dashboard password before activating Tailscale.":'Enable "Require login" and set a custom password before activating Tailscale.'}({requireLogin:!1!==a.requireLogin,hasPassword:!0===a.hasPassword}),X=g.error||h.error||f.error;return(0,d.jsxs)("div",{id:"network",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"public",title:"Network",subtitle:`How ${m.Hc.slug} reaches providers, and how you reach it.`}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Outbound proxy",description:"Send OAuth and provider calls through a proxy. Applies without restart.",settingKey:"outboundProxyEnabled",control:(0,d.jsx)(O.default,{checked:f.value,onChange:a=>f.set(a),disabled:f.saving,"aria-label":"Outbound proxy"})}),(0,d.jsxs)("div",{className:"py-4 space-y-3",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,d.jsx)(p.default,{label:"Proxy URL",value:g.value??"",onChange:a=>g.set(a.target.value),placeholder:"http://127.0.0.1:7897",inputClassName:"font-mono"}),(0,d.jsx)(p.default,{label:"Skip for",value:h.value??"",onChange:a=>h.set(a.target.value),placeholder:"localhost, .internal",inputClassName:"font-mono"})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)(j.default,{variant:"secondary",size:"sm",onClick:M,loading:l,disabled:!g.value?.trim?.(),children:"Test proxy"}),(0,d.jsx)(j.default,{size:"sm",onClick:N,loading:q,children:"Apply"}),i.message&&(0,d.jsx)(ak.default,{variant:"ok"===i.type?"ok":"err",size:"sm",dot:!0,children:i.message})]}),X&&(0,d.jsx)("p",{className:"text-xs text-err",role:"alert",children:X}),(0,d.jsx)("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:i.message||X})]}),(0,d.jsx)(z.default,{label:"Cloudflare tunnel",description:u?"Checking status…":s.tunnel?.publicUrl||s.tunnel?.tunnelUrl?`Public HTTPS URL: ${s.tunnel.publicUrl||s.tunnel.tunnelUrl}`:"Public HTTPS URL. Needs Require API key.",settingKey:"tunnelEnabled",control:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[!u&&!w&&(0,d.jsx)(ak.default,{variant:A?"info":R.variant,size:"sm",dot:!0,children:A?E?"Starting…":"Stopping…":R.label}),(0,d.jsx)(O.default,{checked:T,onChange:P,disabled:A||u||!!(V&&!T),title:V&&!T?V:void 0,"aria-label":"Cloudflare tunnel"})]})}),V&&!T&&(0,d.jsx)("p",{className:"py-2 text-xs text-muted",children:V}),(0,d.jsx)(z.default,{label:"Tailscale",description:u?"Checking status…":s.tailscale?.tunnelUrl||"Private mesh access.",settingKey:"tailscaleEnabled",control:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[!u&&!w&&(0,d.jsx)(ak.default,{variant:C?"info":S.variant,size:"sm",dot:!0,children:C?G?"Starting…":"Stopping…":S.label}),(0,d.jsx)(O.default,{checked:U,onChange:Q,disabled:C||u||!!(W&&!U),title:W&&!U?W:void 0,"aria-label":"Tailscale"})]})}),W&&!U&&(0,d.jsx)("p",{className:"py-2 text-xs text-muted",children:W}),(w||J)&&(0,d.jsx)(o.default,{variant:"err",title:J||w,children:!J&&(0,d.jsx)(j.default,{variant:"ghost",size:"sm",onClick:L,children:"Retry"})}),(0,d.jsx)(z.default,{label:"Tunnel provider",description:"Active tunnel backend.",settingKey:"tunnelProvider",control:(0,d.jsx)("span",{className:"font-mono text-[13px] text-muted",children:"string"==typeof a.tunnelProvider&&a.tunnelProvider?a.tunnelProvider:"cloudflare"})}),(0,d.jsx)(z.default,{label:"Web search backend",description:"SearXNG instance used by web search. Set SEARXNG_URL in .env and restart to change.",settingKey:"SEARXNG_URL",control:(0,d.jsx)("span",{className:"font-mono text-[13px] text-muted",children:"string"==typeof a.searxngUrl&&a.searxngUrl?a.searxngUrl:"not set (default http://localhost:8888/search)"})}),(0,d.jsx)("div",{className:"pt-4",children:(0,d.jsx)(j.default,{variant:"ghost",size:"sm",href:"/dashboard/proxy-pools",iconRight:"arrow_forward",children:"Per-connection proxies and relays live in Proxy pools"})})]})]})}aD.propTypes={title:l().node.isRequired,description:l().node,children:l().node,error:l().string},aE.propTypes={settings:l().object.isRequired,onSettingsChange:l().func},aH.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var aI=c(67960),aJ=c(99258);let aK=Object.freeze({rtkEnabled:!0,headroomEnabled:!1,headroomUrl:"http://localhost:8787",headroomTimeoutMs:3e3,headroomCompressUserMessages:!1,cavemanEnabled:!1,cavemanLevel:"full",ponytailEnabled:!1,ponytailLevel:"full",pxpipeEnabled:!1,pxpipeMinChars:25e3,pxpipeTimeoutMs:15e3,pxpipeAutoInstall:!0});function aL(a){return aI.hT.includes(a)}function aM(a,b){let c=aI.ev.find(a=>a.id===b);return c?c.wenyan&&!aL(a)?"ultra":b:aK.cavemanLevel}function aN(a){return aI.Nv.some(b=>b.id===a)?a:aK.ponytailLevel}function aO({error:a}){return a?(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:a}):null}function aP({settings:a,onSettingsChange:b}){var c;let f=a=>c=>b?.({[a]:c}),g=I("rtkEnabled",a.rtkEnabled??!0,{onSaved:f("rtkEnabled")}),h=I("headroomEnabled",a.headroomEnabled??!1,{onSaved:f("headroomEnabled")}),i=I("headroomUrl",a.headroomUrl??aK.headroomUrl,{debounced:!0,onSaved:f("headroomUrl")}),j=I("headroomTimeoutMs",a.headroomTimeoutMs??aK.headroomTimeoutMs,{onSaved:f("headroomTimeoutMs")}),k=I("headroomCompressUserMessages",a.headroomCompressUserMessages??!1,{onSaved:f("headroomCompressUserMessages")}),l=I("cavemanEnabled",a.cavemanEnabled??!1,{onSaved:f("cavemanEnabled")}),m=I("cavemanLevel",aM((0,aJ.kk)(),a.cavemanLevel??"full"),{onSaved:f("cavemanLevel")}),o=I("ponytailEnabled",a.ponytailEnabled??!1,{onSaved:f("ponytailEnabled")}),q=I("ponytailLevel",aN(a.ponytailLevel??"full"),{onSaved:f("ponytailLevel")}),r=I("pxpipeEnabled",a.pxpipeEnabled??!1,{onSaved:f("pxpipeEnabled")}),s=I("pxpipeMinChars",a.pxpipeMinChars??aK.pxpipeMinChars,{onSaved:f("pxpipeMinChars")}),t=I("pxpipeTimeoutMs",a.pxpipeTimeoutMs??aK.pxpipeTimeoutMs,{onSaved:f("pxpipeTimeoutMs")}),u=I("pxpipeAutoInstall",a.pxpipeAutoInstall??!0,{onSaved:f("pxpipeAutoInstall")}),[v,w]=(0,e.useState)("en"),x=aL(v)?aI.ev:aI.ev.filter(a=>!a.wenyan),B=aM(v,m.value??"full"),C=!h.value,D=!l.value,E=!o.value,F=!r.value,G=a?.headroomUrlFromEnv===!0;return(0,d.jsxs)("div",{id:"token-saver",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"bolt",title:"Token saver",subtitle:"Compress tool output, context and replies. Same store as the Token saver page."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Compress tool output",description:"git/grep/ls/tree/logs → 60-90% fewer input tokens (RTK).",settingKey:"rtkEnabled",control:(0,d.jsx)(O.default,{checked:!0===g.value,onChange:a=>g.set(a),disabled:g.saving,"aria-label":"Compress tool output"})}),(0,d.jsx)(aO,{error:g.error}),(0,d.jsx)(z.default,{label:"Compress context",description:"Compress prompts via Headroom before routing to the model.",settingKey:"headroomEnabled",control:(0,d.jsx)(O.default,{checked:!0===h.value,onChange:a=>h.set(a),disabled:h.saving,"aria-label":"Compress context"})}),(0,d.jsx)(aO,{error:h.error}),(0,d.jsx)(z.default,{label:"Headroom URL",description:G?(0,d.jsxs)(d.Fragment,{children:["Set by ",(0,d.jsx)("code",{className:"font-mono",children:"HEADROOM_URL"})," in .env — the env wins, this field is read-only."]}):"Local proxy for Start/Stop, or an external sidecar.",settingKey:"headroomUrl",control:(0,d.jsxs)("div",{className:"w-full sm:min-w-72 sm:max-w-sm",children:[(0,d.jsx)(p.default,{value:i.value??"",onChange:a=>i.set(a.target.value),disabled:C||i.saving||G,placeholder:"http://localhost:8787",inputClassName:"font-mono","aria-label":"Headroom URL"}),G&&(0,d.jsx)("div",{className:"mt-1.5",children:(0,d.jsx)(n.default,{variant:"info",size:"sm",icon:"lock",children:".env"})})]})}),(0,d.jsx)(aO,{error:i.error}),(0,d.jsx)(z.default,{label:"Headroom timeout",description:"Request timeout, in milliseconds.",settingKey:"headroomTimeoutMs",control:(0,d.jsx)("div",{className:"w-48",children:(0,d.jsx)(aj.default,{label:"Headroom timeout",value:j.value,onChange:a=>j.set(a),min:1,disabled:C||j.saving})})}),(0,d.jsx)(aO,{error:j.error}),(0,d.jsx)(z.default,{label:"Compress user messages",description:"Also compress user turns, not just tool output.",settingKey:"headroomCompressUserMessages",control:(0,d.jsx)(O.default,{checked:!0===k.value,onChange:a=>k.set(a),disabled:C||k.saving,"aria-label":"Compress user messages"})}),(0,d.jsx)(aO,{error:k.error}),(0,d.jsx)(z.default,{label:"Compress LLM output",description:"Terse-style system prompt → ~65% fewer output tokens (Caveman).",settingKey:"cavemanEnabled",control:(0,d.jsx)(O.default,{checked:!0===l.value,onChange:a=>l.set(a),disabled:l.saving,"aria-label":"Compress LLM output"})}),(0,d.jsx)(aO,{error:l.error}),(0,d.jsx)(z.default,{label:"Caveman level",description:aI.ev.find(a=>a.id===B)?.desc??"",settingKey:"cavemanLevel",control:(0,d.jsx)("fieldset",{disabled:D||m.saving,children:(0,d.jsx)(A.default,{options:x.map(a=>({value:a.id,label:a.label})),value:B,onChange:a=>m.set(a),"aria-label":"Caveman level"})})}),(0,d.jsx)(aO,{error:m.error}),(0,d.jsx)(z.default,{label:"Lazy senior dev",description:"Bias the model toward minimal code: YAGNI, reuse stdlib (Ponytail).",settingKey:"ponytailEnabled",control:(0,d.jsx)(O.default,{checked:!0===o.value,onChange:a=>o.set(a),disabled:o.saving,"aria-label":"Lazy senior dev"})}),(0,d.jsx)(aO,{error:o.error}),(0,d.jsx)(z.default,{label:"Ponytail level",description:(c=q.value,aI.Nv.find(a=>a.id===c)?.desc??""),settingKey:"ponytailLevel",control:(0,d.jsx)("fieldset",{disabled:E||q.saving,children:(0,d.jsx)(A.default,{options:aI.Nv.map(a=>({value:a.id,label:a.label})),value:aN(q.value),onChange:a=>q.set(a),"aria-label":"Ponytail level"})})}),(0,d.jsx)(aO,{error:q.error}),(0,d.jsx)(z.default,{label:(0,d.jsxs)("span",{className:"inline-flex items-center gap-2",children:["Prompts as images",(0,d.jsx)(n.default,{variant:"info",size:"sm",icon:"science",children:"Experimental"})]}),description:"Large context becomes optimized images before the LLM (PXPIPE).",settingKey:"pxpipeEnabled",control:(0,d.jsx)(O.default,{checked:!0===r.value,onChange:a=>r.set(a),disabled:r.saving,"aria-label":"Prompts as images"})}),(0,d.jsx)(aO,{error:r.error}),(0,d.jsx)(z.default,{label:"Minimum prompt size",description:"Requests smaller than this bypass PXPIPE as-is (chars).",settingKey:"pxpipeMinChars",control:(0,d.jsx)("div",{className:"w-48",children:(0,d.jsx)(aj.default,{label:"Minimum prompt size",value:s.value,onChange:a=>s.set(a),min:0,disabled:F||s.saving})})}),(0,d.jsx)(aO,{error:s.error}),(0,d.jsx)(z.default,{label:"PXPIPE timeout",description:"Request timeout, in milliseconds.",settingKey:"pxpipeTimeoutMs",control:(0,d.jsx)("div",{className:"w-48",children:(0,d.jsx)(aj.default,{label:"PXPIPE timeout",value:t.value,onChange:a=>t.set(a),min:1,disabled:F||t.saving})})}),(0,d.jsx)(aO,{error:t.error}),(0,d.jsx)(z.default,{label:"Auto-install PXPIPE",description:"Install the proxy package on first use when missing.",settingKey:"pxpipeAutoInstall",control:(0,d.jsx)(O.default,{checked:!0===u.value,onChange:a=>u.set(a),disabled:F||u.saving,"aria-label":"Auto-install PXPIPE"})}),(0,d.jsx)(aO,{error:u.error})]})]})}aO.propTypes={error:l().string},aP.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var aQ=c(91431),aR=c(83919);function aS(a={},b,c,d){let e=String(c||"").trim();if(!b||!e)throw Error("Provider and quota key are required");if(e.length>256)throw Error("Quota key too long");let f={...a?.[b]??{}},g=new Set(f.hidden??[]);if(d){if(g.add(e),g.size>1e3)throw Error("Too many hidden quota keys")}else g.delete(e);let h={...a||{}};return 0===g.size&&Object.keys(f).length<=1?delete h[b]:h[b]={...f,hidden:[...g]},h}function aT(a){let b=a?.connections;return!b||"object"!=typeof b||Array.isArray(b)?{}:Object.fromEntries(Object.entries(b).filter(([,a])=>"boolean"==typeof a))}function aU({providerId:a,label:b,settingKey:c,settings:f,onSettingsChange:g}){let[h,i]=(0,e.useState)(null),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)({}),o=(0,e.useCallback)(async()=>{l("");try{let b=await fetch("/api/providers",{cache:"no-store"});if(!b.ok)throw Error(`HTTP ${b.status}`);let c=await b.json();i((c.connections||[]).filter(b=>b.provider===a))}catch{l("Could not load connections"),i([])}},[a]),p=aT(f[c]),q=(0,e.useCallback)(async(a,b)=>{n(b=>({...b,[a]:!0}));try{let d=await fetch("/api/settings",{cache:"no-store"}),e=d.ok?await d.json():{},f=aT(e[c]),h={...e[c]||{},connections:{...f,[a]:b}},i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[c]:h})}),j=await i.json().catch(()=>({}));if(!i.ok)throw Error(j.error||"Failed to save");g?.({[c]:j[c]??h})}catch{l("Could not save auto-ping")}finally{n(b=>({...b,[a]:!1}))}},[g,c]);return(0,d.jsxs)("div",{className:"mt-3 rounded-xl border border-line bg-raised p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)(al.default,{providerId:a,size:"md"}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("p",{className:"text-sm font-semibold text-text",children:["Auto-ping \xb7 ",b]}),(0,d.jsx)("p",{className:"font-mono text-[11px] text-subtle",children:c})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)(ai(),{href:`/dashboard/providers/${a}`,className:"text-[13px] font-semibold text-coral-ink hover:text-coral",children:["Open ",b," ",(0,d.jsx)("span",{"aria-hidden":"true",className:"inline-block rtl:-scale-x-100",children:"→"})]}),(0,d.jsx)(j.default,{variant:"ghost",size:"sm",onClick:o,children:"Load connections"})]})]}),k&&(0,d.jsx)("p",{className:"pt-2 text-xs text-err",role:"alert",children:k}),null===h?(0,d.jsx)("p",{className:"pt-2 text-[13px] text-muted",children:"Per-connection switches live on the provider page too. Load the list to edit them here."}):0===h.length?(0,d.jsxs)("p",{className:"pt-2 text-[13px] text-muted",children:["No ",b," connections yet."," ",(0,d.jsx)(ai(),{href:`/dashboard/providers/${a}`,className:"font-semibold text-coral-ink hover:text-coral",children:"Add one on the Providers page"}),"."]}):(0,d.jsx)("ul",{className:"mt-2 divide-y divide-line",children:h.map(a=>(0,d.jsxs)("li",{className:"flex items-center justify-between gap-3 py-2",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-text",children:a.name||a.id}),(0,d.jsx)(O.default,{checked:!0===p[a.id],onChange:b=>q(a.id,b),disabled:!0===m[a.id],"aria-label":`Auto-ping ${a.name||a.id}`})]},a.id))})]})}aU.propTypes={providerId:l().string.isRequired,label:l().string.isRequired,settingKey:l().string.isRequired,settings:l().object.isRequired,onSettingsChange:l().func};let aV="http://localhost:20128",aW=["claude","codex","gemini-cli","antigravity","kiro","cursor"],aX=[{id:"claude",label:"Claude Code",settingKey:"claudeAutoPing"},{id:"codex",label:"OpenAI Codex",settingKey:"codexAutoPing"}],aY=[{key:"CLAUDE_CLI_VERSION",label:"Claude CLI"},{key:"CODEX_CLI_VERSION",label:"Codex CLI"},{key:"GROK_CLI_VERSION",label:"Grok CLI"},{key:"ZED_CLIENT_VERSION",label:"Zed client"}];function aZ({error:a}){return a?(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:a}):null}function a$(a){try{return((0,aQ.KC)(a)||[]).map(a=>a.id)}catch{return[]}}function a_({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),f=a.providerThinking||{},g=function(a=[],b,c){return a.filter(a=>(b(a)||[]).some(b=>{let d=c(a,b);return Array.isArray(d)&&d.some(a=>"none"!==a)}))}(aW,a$,aR.k),h=I("ccFilterNaming",!0===a.ccFilterNaming,{onSaved:c("ccFilterNaming")}),i=I("mitmRouterBaseUrl",a.mitmRouterBaseUrl??aV,{debounced:!0,onSaved:c("mitmRouterBaseUrl")}),[k,l]=(0,e.useState)({}),[m,n]=(0,e.useState)({}),[o,q]=(0,e.useState)({}),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(!1),v=(0,e.useCallback)(async(a,b)=>{let c=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:b})}),d=await c.json().catch(()=>({}));if(!c.ok)throw Error(d.error||"Failed to save setting");return Object.hasOwn(d,a)?d[a]:b},[]),w=(0,e.useCallback)(async(a,c)=>{l(b=>({...b,[a]:!0})),n(b=>({...b,[a]:""}));try{let d=await fetch("/api/settings",{cache:"no-store"}),e=d.ok?await d.json():{},f=function(a={},b,c){let d={...a||{}};return c&&"auto"!==c?d[b]={mode:c}:delete d[b],d}(e.providerThinking||{},a,c),g=await v("providerThinking",f);b?.({providerThinking:g})}catch(b){n(c=>({...c,[a]:b instanceof Error?b.message:"Failed to save"}))}finally{l(b=>({...b,[a]:!1}))}},[b,v]),x=(0,e.useCallback)(async a=>{u(!0),s("");try{let c=await fetch("/api/settings",{cache:"no-store"}),d={...(c.ok?await c.json():{}).quotaVisibility||{},...a};for(let b of Object.keys(d)){let c=d[b];c&&"object"==typeof c&&Array.isArray(c.hidden)&&0===c.hidden.length&&1===Object.keys(c).length&&Object.hasOwn(a,b)&&delete d[b]}let e=await v("quotaVisibility",d);b?.({quotaVisibility:e})}catch(a){s(a instanceof Error?a.message:"Failed to save")}finally{u(!1)}},[b,v]),A=a.quotaVisibility||{},C=function(a={}){return a&&"object"==typeof a?Object.keys(a):[]}(A);return(0,d.jsxs)("div",{id:"providers",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"dns",title:"Providers & models",subtitle:"Defaults that apply across providers."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Default thinking level"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Used when a request does not ask for one. Only providers with thinking levels are listed."}),(0,d.jsx)("p",{className:"mt-0.5 font-mono text-[11px] text-subtle",children:"providerThinking"}),0===g.length?(0,d.jsx)("p",{className:"mt-2 text-sm text-muted",children:"No provider with thinking levels found."}):(0,d.jsx)("div",{className:"mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:g.map(a=>{let b=function(a,b=[],c){let d=new Set,e=new Set;for(let f of b){if(!f||e.has(f))continue;e.add(f);let b=c(a,f);if(b)for(let a of b)"none"!==a&&d.add(a)}return 0===d.size?null:["auto",...[...d].sort()]}(a,a$(a),aR.k),c=f[a]?.mode||"auto";return(0,d.jsx)("div",{children:(0,d.jsx)(B.default,{label:(0,d.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,d.jsx)(al.default,{providerId:a,size:"sm"}),a]}),value:c,onChange:b=>w(a,b.target.value),disabled:!0===k[a],options:(b||["auto"]).map(a=>({value:a,label:"auto"===a?"Auto":a})),error:m[a]||void 0})},a)})})]}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Auto-ping quota windows"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"A tiny request keeps quota windows warm. Per connection only — there is no global switch."}),aX.map(({id:c,label:e,settingKey:f})=>(0,d.jsx)(aU,{providerId:c,label:e,settingKey:f,settings:a,onSettingsChange:b},c))]}),(0,d.jsx)(z.default,{label:"Filter naming requests",description:"Drop Claude Code title-naming calls to save quota.",settingKey:"ccFilterNaming",control:(0,d.jsx)(O.default,{checked:!0===h.value,onChange:a=>h.set(a),disabled:h.saving,"aria-label":"Filter naming requests"})}),(0,d.jsx)(aZ,{error:h.error}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-52 flex-1",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Quota rows shown"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Pick which limits appear on the Quota page. Same store as Usage → Limits."}),(0,d.jsx)("p",{className:"mt-0.5 font-mono text-[11px] text-subtle",children:"quotaVisibility"})]}),(0,d.jsx)(j.default,{variant:"secondary",size:"sm",icon:"tune",href:"/dashboard/quota",children:"Choose on Quota page"})]}),r&&(0,d.jsx)("p",{className:"pt-2 text-xs text-err",role:"alert",children:r}),0===C.length?(0,d.jsx)("p",{className:"pt-2 text-sm text-muted",children:"All quota rows are shown. Hide a row below by provider and key."}):(0,d.jsx)("ul",{className:"mt-3 space-y-2",children:C.map(a=>(0,d.jsxs)("li",{className:"rounded-lg border border-line bg-raised p-3 text-sm",children:[(0,d.jsxs)("p",{className:"flex items-center gap-2 font-mono text-xs text-text",children:[(0,d.jsx)(al.default,{providerId:a,size:"sm"}),a]}),(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:(function(a={},b){let c=a?.[b]?.hidden;return Array.isArray(c)?c.filter(a=>"string"==typeof a):[]})(A,a).map(b=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-line px-2 py-0.5 font-mono text-xs text-muted",children:[b,(0,d.jsx)("button",{type:"button","aria-label":`Show ${b}`,disabled:t,onClick:()=>x(aS(A,a,b,!1)),className:"text-coral-ink hover:text-coral disabled:opacity-50",children:"\xd7"})]},b))})]},a))}),(0,d.jsxs)("div",{className:"mt-3 flex flex-col gap-2 sm:flex-row sm:items-end",children:[(0,d.jsxs)("div",{className:"grid flex-1 grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,d.jsx)(p.default,{label:"Provider",value:o.provider??"",onChange:a=>q(b=>({...b,provider:a.target.value})),placeholder:"claude",inputClassName:"font-mono","aria-label":"Quota provider"}),(0,d.jsx)(p.default,{label:"Quota key",value:o.key??"",onChange:a=>q(b=>({...b,key:a.target.value})),placeholder:"weekly-5h",inputClassName:"font-mono","aria-label":"Quota key"})]}),(0,d.jsx)(j.default,{variant:"secondary",size:"sm",loading:t,disabled:t,onClick:()=>{try{let a=String(o.provider||"").trim(),b=String(o.key||"").trim(),c=aS(A,a,b,!0);q({}),x(c)}catch(a){s(a instanceof Error?a.message:"Invalid quota key")}},children:"Hide row"})]})]}),(0,d.jsx)(z.default,{label:"Intercept (MITM) router URL",description:"Base URL the MITM server routes through. Same behavior as the MITM card.",settingKey:"mitmRouterBaseUrl",control:(0,d.jsx)("div",{className:"w-full sm:min-w-72 sm:max-w-sm",children:(0,d.jsx)(p.default,{value:i.value??"",onChange:a=>i.set(a.target.value),disabled:i.saving,placeholder:aV,inputClassName:"font-mono","aria-label":"Intercept router URL"})})}),(0,d.jsx)(aZ,{error:i.error}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Client version pins"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Read from .env at startup. Read-only here."}),(0,d.jsx)("div",{className:"mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4",children:aY.map(({key:b,label:c})=>(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"mb-1 text-[13px] font-semibold text-text",children:c}),(0,d.jsx)("p",{className:"mb-1 font-mono text-[11px] text-subtle",children:b}),(0,d.jsx)(P.default,{value:a[b]?String(a[b]):"not set"})]},b))})]})]})]})}function a0({error:a}){return a?(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:a}):null}function a1({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),e=I("enableObservability",!0===a.enableObservability,{onSaved:c("enableObservability")}),g=!0===a.requestLogsOverridden||!0===a.requestLogEnvOverride,h=!0===a.translatorOverridden,i=I("observabilityMaxRecords",a.observabilityMaxRecords??1e3,{debounced:!0,onSaved:c("observabilityMaxRecords")}),j=I("observabilityBatchSize",a.observabilityBatchSize??20,{debounced:!0,onSaved:c("observabilityBatchSize")}),k=I("observabilityFlushIntervalMs",a.observabilityFlushIntervalMs??5e3,{debounced:!0,onSaved:c("observabilityFlushIntervalMs")}),l=I("observabilityMaxJsonSize",a.observabilityMaxJsonSize??5,{debounced:!0,onSaved:c("observabilityMaxJsonSize")}),m=I("requestLogsEnabled",!0===a.requestLogsEnabled,{onSaved:c("requestLogsEnabled")}),n=I("translatorEnabled",!0===a.translatorEnabled,{onSaved:a=>{c("translatorEnabled")(a),(0,f.q0)()}}),p=!e.value,q=g?!0===a.enableRequestLogs:m.value,r=h?!0===a.enableTranslator:n.value;return(0,d.jsxs)("div",{id:"logs",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"monitoring",title:"Observability & logs",subtitle:"What gets recorded, and for how long."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Record request details",description:g?(0,d.jsxs)(d.Fragment,{children:["Set by ",(0,d.jsx)("code",{className:"font-mono",children:"ENABLE_REQUEST_LOGS"})," in .env — the env wins, this toggle is read-only."]}):"Full payloads in Usage → Request log.",settingKey:"enableObservability",control:(0,d.jsx)(O.default,{checked:!0===e.value,onChange:a=>e.set(a),disabled:e.saving||g,"aria-label":"Record request details"})}),(0,d.jsx)(a0,{error:e.error}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Storage limits"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"New in UI. Applies within ~5 seconds — no restart required."}),(0,d.jsxs)("div",{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2${p?" opacity-50":""}`,children:[(0,d.jsx)(aj.default,{label:"Max records",value:i.value,onChange:a=>i.set(a),min:1,disabled:p||i.saving,error:i.error||void 0}),(0,d.jsx)(aj.default,{label:"Batch size",value:j.value,onChange:a=>j.set(a),min:1,disabled:p||j.saving,error:j.error||void 0}),(0,d.jsx)(at.default,{label:"Flush every",value:k.value??"",onChange:a=>k.set(Number(a.target.value)),unit:"ms",disabled:p||k.saving,error:k.error?String(k.error):void 0}),(0,d.jsx)(at.default,{label:"Max payload size",value:l.value??"",onChange:a=>l.set(Number(a.target.value)),unit:"KB",hint:"Kilobytes per payload (code multiplies by 1024).",disabled:p||l.saving,error:l.error?String(l.error):void 0})]}),(0,d.jsx)("div",{className:"mt-3",children:(0,d.jsx)(o.default,{variant:"info",title:"No restart needed",children:"Changes take effect within ~5 seconds via the runtime config cache."})})]}),(0,d.jsx)(z.default,{label:"Log every request to console",description:g?"Controlled by ENABLE_REQUEST_LOGS in .env — change it there and restart.":"Writes request/response logs under logs/ for debugging.",settingKey:"ENABLE_REQUEST_LOGS",control:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[g&&(0,d.jsx)("span",{className:"rounded-full bg-raised px-2 py-0.5 font-mono text-[11px] text-muted",children:".env overrides"}),(0,d.jsx)(O.default,{checked:q,onChange:a=>m.set(a),disabled:g||m.saving,"aria-label":"Log every request to console"})]})}),m.error&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:m.error}),(0,d.jsx)(z.default,{label:"Show Translator page",description:h?"Controlled by ENABLE_TRANSLATOR in .env — change it there and restart.":"Debug tool for format translation.",settingKey:"ENABLE_TRANSLATOR",control:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[h&&(0,d.jsx)("span",{className:"rounded-full bg-raised px-2 py-0.5 font-mono text-[11px] text-muted",children:".env overrides"}),(0,d.jsx)(O.default,{checked:r,onChange:a=>n.set(a),disabled:h||n.saving,"aria-label":"Show Translator page"})]})}),n.error&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:n.error})]})]})}aZ.propTypes={error:l().string},a_.propTypes={settings:l().object.isRequired,onSettingsChange:l().func},a0.propTypes={error:l().string},a1.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var a2=c(47392),a3=c(18982),a4=c(73655),a5=c(58460);let a6=["input","output","cached","reasoning","cache_creation"],a7={input:"Input",output:"Output",cached:"Cached",reasoning:"Reasoning",cache_creation:"Cache creation"};function a8({isOpen:a,onClose:b,onSave:c}){let[f,g]=(0,e.useState)({}),[h,i]=(0,e.useState)(!0),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(!1),r=(a,b,c,d)=>{let e=Number.parseFloat(d);Number.isNaN(e)||e<0||g(d=>({...d,[a]:{...d[a],[b]:{...d[a]?.[b],[c]:e}}}))},s=async()=>{l(!0),n("");try{let a=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(a.ok)c?.(),b();else{let b=await a.json().catch(()=>({}));n(`Failed to save pricing: ${b.error||a.status}`)}}catch(a){console.error("Failed to save pricing:",a),n("Failed to save pricing")}finally{l(!1)}},t=async()=>{if(!(await fetch("/api/pricing",{method:"DELETE"})).ok)throw Error("Failed to reset pricing");g((0,a3.ad)()),p(!1)},u=Object.keys(f).sort();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(q.default,{isOpen:a,onClose:b,title:"Pricing configuration",size:"full",className:"max-w-6xl",closeOnOverlay:!k,closeOnEscape:!k&&!o,footer:(0,d.jsxs)("div",{className:"flex w-full flex-wrap items-center justify-between gap-2",children:[(0,d.jsx)(j.default,{variant:"danger",onClick:()=>p(!0),disabled:k,children:"Reset to defaults"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(j.default,{variant:"ghost",onClick:b,disabled:k,children:"Cancel"}),(0,d.jsx)(j.default,{onClick:s,loading:k,disabled:h,children:k?"Saving...":"Save Changes"})]})]}),children:[(0,d.jsx)("div",{"aria-live":"polite",children:m&&(0,d.jsx)("p",{role:"alert",className:"mb-4 rounded-lg bg-err-bg px-3 py-2 text-sm text-err",children:m})}),h?(0,d.jsx)(a4.LoadingState,{label:"Loading pricing",lines:4}):(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsxs)("div",{className:"rounded-lg border border-line bg-raised p-3 text-sm",children:[(0,d.jsx)("p",{className:"mb-1 font-medium text-text",children:"Pricing rates format"}),(0,d.jsxs)("p",{className:"text-muted",children:["All rates are in ",(0,d.jsx)("strong",{children:"dollars per million tokens"})," ($/1M tokens). Example: Input rate of 2.50 means $2.50 per 1,000,000 input tokens."]})]}),u.map(a=>(0,d.jsx)(a9,{provider:a,models:f[a],onChange:r},a)),0===u.length&&(0,d.jsx)("div",{className:"py-8 text-center text-muted",children:"No pricing data available"})]})]}),(0,d.jsx)(q.ConfirmDialog,{isOpen:o,onClose:()=>p(!1),onConfirm:t,title:"Reset pricing",message:"Reset all pricing to defaults? This cannot be undone.",confirmText:"Reset to defaults"})]})}function a9({provider:a,models:b,onChange:c}){return(0,d.jsxs)("div",{className:"overflow-hidden rounded-lg border border-line",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 bg-raised px-4 py-2 text-sm font-semibold text-text",children:[(0,d.jsx)(al.default,{providerId:a,size:"sm"}),a.toUpperCase()]}),(0,d.jsx)("section",{className:"overflow-x-auto focus-visible:shadow-focus","aria-label":"Pricing table",tabIndex:0,children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:a5.pi,children:[(0,d.jsx)("th",{scope:"col",className:`${a5.PK} px-3 py-2 text-start`,children:"Model"}),a6.map(a=>(0,d.jsx)("th",{scope:"col",className:`${a5.PK} px-3 py-2 text-end`,children:a7[a]},a))]})}),(0,d.jsx)("tbody",{className:"divide-y divide-line",children:Object.keys(b).sort().map(e=>(0,d.jsxs)("tr",{className:"hover:bg-raised/60",children:[(0,d.jsx)("td",{className:"px-3 py-2 font-medium text-text",children:e}),a6.map(f=>(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("input",{type:"number",step:"0.01",min:"0","aria-label":`${e} ${a7[f]}`,value:b[e][f]||0,onChange:b=>c(a,e,f,b.target.value),className:"w-20 rounded border border-line bg-raised px-2 py-1 text-end text-text focus:border-coral focus:shadow-focus focus:outline-none"})},f))]},e))})]})})]})}function ba({modalOpen:a,onModalChange:b}){let[c,f]=(0,e.useState)(null),[h,k]=(0,e.useState)(!0),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(!1),p=b||o,q=(0,e.useRef)(null),r=async()=>{q.current?.abort();let a=new AbortController;q.current=a,k(!0),m("");try{let b=await fetch("/api/pricing",{signal:a.signal});if(!b.ok)throw Error(`HTTP ${b.status}`);let c=await b.json();f(c)}catch(a){if(a?.name==="AbortError")return;m("Failed to load pricing data")}finally{q.current===a&&k(!1)}},s=c?Object.keys(c).sort():[],t=s.reduce((a,b)=>a+Object.keys(c[b]||{}).length,0),u=s.reduce((a,b)=>a+Object.values(c[b]||{}).filter(a=>a&&!0===a.custom).length,0);return(0,d.jsxs)("div",{id:"pricing",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"savings",title:"Pricing",subtitle:"What cost estimates use, in $ per 1M tokens."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card space-y-4",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[(0,d.jsx)(a2.default,{eyebrow:"Models",value:h?"…":String(t)}),(0,d.jsx)(a2.default,{eyebrow:"Providers",value:h?"…":String(s.length)}),(0,d.jsx)(a2.default,{eyebrow:"Custom",value:h?"…":String(u)})]}),h?(0,d.jsx)(i.Skeleton,{}):l?(0,d.jsx)(g.default,{icon:"error",title:"Could not load pricing",body:l,action:(0,d.jsx)(j.default,{variant:"secondary",onClick:r,children:"Retry"})}):(0,d.jsxs)("div",{className:"overflow-x-auto rounded-xl border border-line",children:[(0,d.jsxs)("table",{className:"w-full min-w-[42rem] text-sm",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:"text-start text-xs text-muted",children:[(0,d.jsx)("th",{className:"px-3 py-2 text-start font-semibold",children:"Model"}),(0,d.jsx)("th",{className:"px-3 py-2 text-end font-semibold",children:"Input"}),(0,d.jsx)("th",{className:"px-3 py-2 text-end font-semibold",children:"Output"}),(0,d.jsx)("th",{className:"px-3 py-2 text-end font-semibold",children:"Cached"})]})}),(0,d.jsx)("tbody",{children:s.slice(0,5).flatMap(a=>Object.keys(c[a]||{}).slice(0,10).map(b=>{let e=c[a][b]||{};return(0,d.jsxs)("tr",{className:"border-t border-line",children:[(0,d.jsxs)("td",{className:"px-3 py-2 font-mono text-xs text-text",children:[(0,d.jsx)(al.default,{providerId:a,size:"sm",className:"me-2 align-middle"}),a,"/",b,!0===e.custom&&(0,d.jsx)("span",{className:"ms-1.5 rounded-full bg-coral-bg px-1.5 py-0.5 text-[10px] font-semibold text-coral-ink",children:"Custom"})]}),(0,d.jsx)("td",{className:"px-3 py-2 text-end tabular-nums text-text",children:e.input??"—"}),(0,d.jsx)("td",{className:"px-3 py-2 text-end tabular-nums text-text",children:e.output??"—"}),(0,d.jsx)("td",{className:"px-3 py-2 text-end tabular-nums text-text",children:e.cached??"—"})]},`${a}/${b}`)}))})]}),s.length>5&&(0,d.jsxs)("p",{className:"border-t border-line px-3 py-2 text-xs text-muted",children:["+ ",s.length-5," more providers — open Edit pricing for full details."]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(j.default,{variant:"secondary",icon:"edit",onClick:()=>p(!0),children:"Edit pricing"}),(0,d.jsx)(j.default,{variant:"ghost",icon:"restart_alt",onClick:()=>p(!0),children:"Reset to defaults…"})]})]}),(0,d.jsx)(a8,{isOpen:void 0!==a?a:n,onClose:()=>p(!1),onSave:()=>r()})]})}a8.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onSave:l().func},a9.propTypes={provider:l().string.isRequired,models:l().object.isRequired,onChange:l().func.isRequired},ba.propTypes={modalOpen:l().bool,onModalChange:l().func};let bb=`~/.${m.Hc.dataDirName}/db/data.sqlite`;function bc({onSettingsChange:a}){let[b,c]=(0,e.useState)({type:"",message:""}),[f,g]=(0,e.useState)(!1),[h,i]=(0,e.useState)({open:!1,mode:"",password:""}),k=(0,e.useRef)(null),l=(0,e.useRef)(null),[n,r]=(0,e.useState)(bb),s=async a=>{g(!0),c({type:"",message:""});try{let b=await fetch("/api/settings/database",{headers:{"x-9r-password":a}});if(!b.ok){let a=await b.json().catch(()=>({}));throw Error(a.error||"Failed to export database")}let d=await b.json(),e=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),f=URL.createObjectURL(e),g=document.createElement("a"),h=new Date().toISOString().replace(/[.:]/g,"-");g.href=f,g.download=`${m.Hc.backupFilePrefix}${h}.json`,document.body.appendChild(g),g.click(),document.body.removeChild(g),URL.revokeObjectURL(f),c({type:"ok",message:"Database backup downloaded"})}catch(a){c({type:"err",message:a.message||"Failed to export database"})}finally{g(!1)}},t=async b=>{let d=k.current;if(d){g(!0);try{let e=await d.text(),f=JSON.parse(e),g=await fetch("/api/settings/database",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...f,password:b})}),h=await g.json().catch(()=>({}));if(!g.ok)throw Error(h.error||"Failed to import database");a?.(),c({type:"ok",message:"Database imported successfully"})}catch(a){c({type:"err",message:a.message||"Invalid backup file"})}finally{k.current=null,g(!1)}}},u=async()=>{let{mode:a,password:b}=h;i({open:!1,mode:"",password:""}),"export"===a?await s(b):"import"===a&&await t(b)};return(0,d.jsxs)("div",{id:"data",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"database",title:"Data & backup",subtitle:"Everything lives in one SQLite file."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Database",description:"SQLite file location.",settingKey:"DATA_DIR",control:(0,d.jsx)("div",{className:"w-full sm:min-w-72 sm:max-w-sm",children:(0,d.jsx)(P.default,{value:n})})}),(0,d.jsxs)("div",{className:"py-4 space-y-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Backup"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Both ask for your password."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(j.default,{variant:"secondary",icon:"download",loading:f,onClick:()=>i({open:!0,mode:"export",password:""}),children:"Download"}),(0,d.jsx)(j.default,{variant:"secondary",icon:"upload",disabled:f,onClick:()=>l.current?.click(),children:"Import"}),(0,d.jsx)("input",{ref:l,type:"file",accept:"application/json,.json",onChange:a=>{let b=a.target.files?.[0];l.current&&(l.current.value=""),b&&(k.current=b,c({type:"",message:""}),i({open:!0,mode:"import",password:""}))},className:"hidden"})]}),b.message&&(0,d.jsx)(o.default,{variant:"ok"===b.type?"ok":"err",title:b.message})]}),(0,d.jsx)(z.default,{label:"Cloud sync",description:"Keep settings and connections in sync across machines.",settingKey:"cloudEnabled",control:(0,d.jsx)(O.default,{checked:!1,onChange:()=>{},disabled:!0,"aria-label":"Cloud sync (unavailable)"})}),(0,d.jsx)("div",{className:"py-3",children:(0,d.jsx)(o.default,{variant:"info",title:"Cloud sync is not available in this build",children:"No sync worker ships with this repo, so the toggle stays off. Your data stays local; use Download/Import backup to move it between machines."})})]}),(0,d.jsxs)(q.default,{isOpen:h.open,onClose:()=>i({open:!1,mode:"",password:""}),title:"Confirm password",size:"sm",footer:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.default,{variant:"ghost",onClick:()=>i({open:!1,mode:"",password:""}),disabled:f,children:"Cancel"}),(0,d.jsx)(j.default,{onClick:u,loading:f,disabled:!h.password,children:"Confirm"})]}),children:[(0,d.jsxs)("p",{className:"mb-3 text-sm text-muted",children:["Enter your current password to ","export"===h.mode?"export":"import"," the database."]}),(0,d.jsx)(p.default,{type:"password",autoComplete:"current-password",value:h.password,onChange:a=>i(b=>({...b,password:a.target.value})),onKeyDown:a=>{"Enter"===a.key&&h.password&&u()},placeholder:"Current password"})]})]})}bc.propTypes={onSettingsChange:l().func};let bd=`${m.qt.npmPackage} data migrate`;function be(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(null),[g,h]=(0,e.useState)(null),[j,k]=(0,e.useState)(""),l=a?Object.entries(a):[];return(0,d.jsxs)("div",{id:"environment",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"terminal",title:"Environment",subtitle:"Read from .env at startup. Edit the file and restart."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card space-y-4",children:[(0,d.jsx)(o.default,{variant:"info",title:".env \xb7 restart",children:`Values come from the server environment. Change them in .env and restart ${m.Hc.slug}.`}),c&&(0,d.jsxs)(o.default,{variant:"warn",title:"Data directory",children:[(0,d.jsx)("p",{children:"Your data is in the old folder. Stop the server, then run this command to move it."}),(0,d.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,d.jsx)(P.default,{value:c,label:"Data directory"}),(0,d.jsx)(P.default,{value:bd,label:"Copy code"})]})]}),g&&(0,d.jsxs)(o.default,{variant:"warn",title:"Data directory",children:[(0,d.jsx)("p",{children:"An old data folder also exists and is not used. If your data is missing, check it before deleting anything."}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(P.default,{value:g,label:"Data directory"})})]}),j?(0,d.jsx)("p",{className:"text-sm text-err",role:"alert",children:j}):a?0===l.length?(0,d.jsx)("p",{className:"text-sm text-muted",children:"No environment values set."}):(0,d.jsx)("dl",{className:"grid grid-cols-1 gap-x-6 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.3fr)]",children:l.map(([a,b])=>(0,d.jsxs)("div",{className:"contents sm:[&>dd]:border-t-0 sm:[&>dt]:border-t-0 [&>*]:border-t [&>*]:border-line [&>*]:py-2",children:[(0,d.jsx)("dt",{className:"font-mono text-[13px] text-text",children:a}),(0,d.jsx)("dd",{className:"min-w-0",children:(0,d.jsx)(P.default,{value:String(b),label:`Copy ${a}`})})]},a))}):(0,d.jsx)(i.Skeleton,{})]})]})}function bf(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)(""),g=async()=>{f("");try{if(!(await fetch("/api/auth/logout",{method:"POST"})).ok)throw Error("Failed to log out");window.location.assign("/login")}catch(a){f(a.message||"Failed to log out")}},h=async()=>{try{await fetch("/api/version/shutdown",{method:"POST"})}catch{}b(!1)};return(0,d.jsxs)("div",{id:"danger",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"warning",title:"Danger zone",subtitle:"End sessions and stop the server."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-err/40 bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Log out",description:"End this dashboard session.",control:(0,d.jsx)(j.default,{variant:"secondary",icon:"logout",onClick:g,children:"Log out"})}),c&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:c}),(0,d.jsx)(z.default,{label:`Shut down ${m.Hc.slug}`,description:"Your tools lose their endpoint until you start it again.",control:(0,d.jsx)(j.default,{variant:"danger",icon:"power_settings_new",onClick:()=>b(!0),children:"Shut down"})})]}),(0,d.jsx)(q.ConfirmDialog,{isOpen:a,onClose:()=>b(!1),onConfirm:h,title:`Shut down ${m.Hc.slug}`,message:"Your tools lose their endpoint until you start it again.",confirmText:"Shut down",variant:"danger"})]})}var bg=c(71404);let bh={new:"bg-coral-bg text-coral",experimental:"bg-raised text-muted"};function bi({groups:a,sections:b,activeId:c,onSelect:e}){let f=Object.fromEntries(b.map(a=>[a.id,a])),g=a.find(a=>a.sections.includes(c))??a[0];return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("nav",{"aria-label":"Settings groups",className:"grid grid-cols-2 gap-2 md:grid-cols-4 lg:col-span-2",children:a.map(a=>{let b=a.id===g.id;return(0,d.jsxs)("button",{type:"button","aria-pressed":b,onClick:()=>e(a.sections[0]),className:(0,bg.cn)("group flex items-center gap-3 rounded-xl border px-4 py-3 text-left transition-all outline-none focus-visible:shadow-focus",b?"border-coral/40 bg-coral-bg shadow-card":"border-line bg-panel hover:-translate-y-0.5 hover:bg-raised"),children:[(0,d.jsx)("span",{"aria-hidden":"true",className:(0,bg.cn)("material-symbols-outlined flex size-9 shrink-0 items-center justify-center rounded-lg text-[20px]",b?"bg-coral text-on-coral":"bg-raised text-muted group-hover:text-text"),children:a.icon}),(0,d.jsxs)("span",{className:"min-w-0",children:[(0,d.jsx)("span",{className:(0,bg.cn)("block text-sm font-semibold",b?"text-coral":"text-text"),children:a.title}),(0,d.jsx)("span",{className:"block truncate text-xs text-muted",children:a.sections.map(a=>f[a]?.title).join(" \xb7 ")})]})]},a.id)})}),(0,d.jsx)("nav",{"aria-label":`${g.title} sections`,className:"lg:sticky lg:top-0 lg:self-start",children:(0,d.jsx)("ul",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2 lg:flex lg:flex-col",children:g.sections.map(a=>{let b=f[a];if(!b)return null;let g=a===c,h="danger"===a;return(0,d.jsx)("li",{className:"min-w-0",children:(0,d.jsxs)("a",{href:`#${a}`,onClick:b=>{b.preventDefault(),e(a)},"aria-current":g?"page":void 0,className:(0,bg.cn)("relative flex items-start gap-3 rounded-lg px-3 py-2.5 transition-colors outline-none focus-visible:shadow-focus",g?"bg-panel shadow-card":"hover:bg-raised",g&&"lg:before:absolute lg:before:inset-y-2 lg:before:left-0 lg:before:w-0.5 lg:before:rounded-full lg:before:bg-coral"),children:[(0,d.jsx)("span",{"aria-hidden":"true",className:(0,bg.cn)("material-symbols-outlined mt-0.5 text-[18px]",h?"text-err":g?"text-coral":"text-muted"),children:b.icon}),(0,d.jsxs)("span",{className:"min-w-0",children:[(0,d.jsxs)("span",{className:"flex items-center gap-2 text-sm font-semibold whitespace-nowrap text-text",children:[b.title,[...new Set(b.rows.flatMap(a=>a.tags??[]))].filter(a=>bh[a]).map(a=>(0,d.jsx)("span",{className:(0,bg.cn)("rounded px-1.5 py-px text-[10px] uppercase tracking-wide",bh[a]),children:a},a))]}),(0,d.jsx)("span",{className:"hidden text-xs text-muted lg:block",children:b.subtitle})]})]})},a)})})})]})}bi.propTypes={groups:l().arrayOf(l().shape({id:l().string.isRequired,title:l().string.isRequired,icon:l().string.isRequired,sections:l().arrayOf(l().string).isRequired})).isRequired,sections:l().arrayOf(l().object).isRequired,activeId:l().string.isRequired,onSelect:l().func.isRequired};var bj=c(85699);function bk(){let[a,b]=(0,e.useState)({requireLogin:!0}),[c,k]=(0,e.useState)(!0),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)("en"),[r,s]=(0,e.useState)(0),[t,u]=(0,e.useState)(0),[v,x]=(0,e.useState)("general"),y=(0,e.useCallback)(async()=>{k(!0),m("");try{let a=await fetch("/api/settings",{cache:"no-store"});if(!a.ok)throw Error(`HTTP ${a.status}`);let c=await a.json();b(c)}catch{m("Failed to load settings")}finally{k(!1)}},[]),z=(0,e.useCallback)(a=>{x(a),window.history.replaceState(null,"",`#${a}`),document.querySelector("main .custom-scrollbar")?.scrollTo({top:0,behavior:"smooth"})},[]),A=(0,e.useCallback)(a=>{if(!a){y(),u(a=>a+1),(0,f.q0)();return}b(b=>({...b,...a})),s(a=>a+1)},[y]),B=(0,bj.Ee)(n),C=new Set(n?B.map(a=>a.id):[v]),D=bj.HX.find(a=>a.id===v),[E,F]=(0,e.useState)(!1),G=(0,e.useCallback)(a=>{if(F(a),!a){let a=new URL(window.location.href);a.searchParams.delete("editPricing"),window.history.replaceState(null,"",`${a.pathname}${a.search}${a.hash}`)}},[]);return(0,d.jsxs)("div",{className:"mx-auto max-w-6xl space-y-6",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsx)("div",{children:(0,d.jsxs)("p",{className:"text-sm text-muted",children:["Changes save instantly."," ",(0,d.jsx)("span",{"aria-live":"polite","aria-atomic":"true",className:"font-medium text-ok",children:r>0?`All changes saved (${r})`:" "})]})}),(0,d.jsx)(w,{onSettingsChange:A})]}),(0,d.jsx)(h.default,{id:"settings-search",value:n,onChange:a=>o(a.target.value),placeholder:"Search settings",ariaLabel:"Search settings"})]}),(0,d.jsxs)("div",{className:"grid gap-6 lg:grid-cols-[15rem_minmax(0,1fr)]",children:[n?(0,d.jsxs)("p",{className:"text-sm text-muted lg:col-span-2","aria-live":"polite",children:[B.reduce((a,b)=>a+b.rows.length,0)," matching settings in"," ",B.length," sections"]}):(0,d.jsx)(bi,{groups:bj.lY,sections:bj.HX,activeId:v,onSelect:z}),(0,d.jsxs)("div",{className:(0,bg.cn)("min-w-0",n&&"lg:col-span-2"),children:[!n&&D&&(0,d.jsxs)("p",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-muted",children:[bj.lY.find(a=>a.sections.includes(v))?.title," /"," ",(0,d.jsx)("span",{className:"text-text",children:D.title})]}),c?(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)(i.Skeleton,{}),(0,d.jsx)(i.Skeleton,{})]}):l?(0,d.jsx)(g.default,{icon:"error",title:"Could not load settings",body:l,action:(0,d.jsx)(j.default,{onClick:y,children:"Retry"})}):0===B.length?(0,d.jsx)(g.default,{icon:"search",title:"No settings match",body:`Nothing matches “${n}”. Try a different search.`,action:(0,d.jsx)(j.default,{variant:"ghost",onClick:()=>o(""),children:"Clear search"})}):(0,d.jsxs)("div",{className:"space-y-6",children:[C.has("general")&&(0,d.jsx)(N,{settings:a,locale:p,onLocaleChange:q,onSettingsChange:A}),C.has("security")&&(0,d.jsx)(Q,{settings:a,onSettingsChange:A}),C.has("sso")&&(0,d.jsx)(ag,{settings:a,onSettingsChange:A}),C.has("routing")&&(0,d.jsx)(as,{settings:a,onSettingsChange:A}),C.has("reliability")&&(0,d.jsx)(aE,{settings:a,onSettingsChange:A}),C.has("network")&&(0,d.jsx)(aH,{settings:a,onSettingsChange:A}),C.has("token-saver")&&(0,d.jsx)(aP,{settings:a,onSettingsChange:A}),C.has("providers")&&(0,d.jsx)(a_,{settings:a,onSettingsChange:A}),C.has("logs")&&(0,d.jsx)(a1,{settings:a,onSettingsChange:A}),C.has("pricing")&&(0,d.jsx)(ba,{modalOpen:E,onModalChange:G},`pricing-${t}`),C.has("data")&&(0,d.jsx)(bc,{onSettingsChange:A}),C.has("environment")&&(0,d.jsx)(be,{}),C.has("danger")&&(0,d.jsx)(bf,{})]})]})]})]})}},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},30766:(a,b,c)=>{Promise.resolve().then(c.bind(c,27558))},31421:a=>{"use strict";a.exports=require("node:child_process")},32467:a=>{"use strict";a.exports=require("node:http2")},33597:(a,b,c)=>{"use strict";c.d(b,{default:()=>k});var d=c(48249),e=c(49885),f=c.n(e),g=c(67484),h=c(83552),i=c(21951),j=c(71404);function k({value:a,onChange:b,ariaLabel:c,placeholder:e,id:f,className:l,inputClassName:m}){let n=(0,g.useRef)(null);return(0,d.jsxs)("div",{className:(0,j.cn)("relative",l),children:[(0,d.jsx)(h.default,{ref:n,id:f,type:"search",icon:"search",value:a,onChange:b,placeholder:e,"aria-label":c,inputClassName:(0,j.cn)("min-h-10 sm:pe-10",m)}),!a&&(0,d.jsx)("span",{className:"pointer-events-none absolute inset-y-0 end-3 hidden items-center sm:flex","aria-hidden":"true",children:(0,d.jsx)(i.default,{children:"/"})})]})}c(77637),k.propTypes={value:f().string.isRequired,onChange:f().func.isRequired,ariaLabel:f().string.isRequired,placeholder:f().string,id:f().string,className:f().string,inputClassName:f().string}},33873:a=>{"use strict";a.exports=require("path")},34589:a=>{"use strict";a.exports=require("node:assert")},37067:a=>{"use strict";a.exports=require("node:http")},37540:a=>{"use strict";a.exports=require("node:console")},38522:a=>{"use strict";a.exports=require("node:zlib")},39973:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"default",{enumerable:!0,get:function(){return e}});let d=c(40399)._(c(80061));function e(a,b){let c={};"function"==typeof a&&(c.loader=a);let e={...c,...b};return(0,d.default)({...e,modules:e.loadableGenerated?.modules})}("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)},40610:a=>{"use strict";a.exports=require("node:dns")},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},41692:a=>{"use strict";a.exports=require("node:tls")},41792:a=>{"use strict";a.exports=require("node:querystring")},44928:(a,b,c)=>{"use strict";c.d(b,{default:()=>i});var d=c(48249),e=c(49885),f=c.n(e),g=c(71404),h=c(27444);function i({label:a,placeholder:b,value:c,onChange:e,error:f,hint:j,disabled:k=!1,required:l=!1,rows:m=3,className:n,textareaClassName:o,id:p,...q}){return(0,d.jsx)(h.default,{id:p,label:a,hint:j,error:f,required:l,className:n,children:({inputId:a,describedBy:f,invalid:h})=>(0,d.jsx)("textarea",{...q,id:a,placeholder:b,value:c,onChange:e,disabled:k,rows:m,"aria-describedby":f,"aria-invalid":h||void 0,className:(0,g.cn)("w-full px-3 py-2.5 text-sm text-text bg-raised rounded-lg","border border-line placeholder:text-subtle resize-y","focus:outline-none focus:border-coral focus:shadow-focus","transition-colors duration-150 disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",h&&"border-err focus:border-err",o)})})}i.propTypes={label:f().node,placeholder:f().string,value:f().oneOfType([f().string,f().number]),onChange:f().func,error:f().node,hint:f().node,disabled:f().bool,required:f().bool,rows:f().number,className:f().string,textareaClassName:f().string,id:f().string,"aria-label":f().string}},46060:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external.js")},46193:a=>{"use strict";a.exports=require("node:string_decoder")},46293:a=>{"use strict";a.exports=require("sql.js")},47392:(a,b,c)=>{"use strict";c.d(b,{default:()=>h});var d=c(48249),e=c(49885),f=c.n(e);function g(a,b){return(0,d.jsx)("span",{className:`text-sm ${a?"":"text-muted"}`,children:b})}function h({eyebrow:a,value:b,delta:c,trend:e,sparkline:f,hero:i=!1,className:j}){let k,l;return(0,d.jsxs)("div",{className:`flex flex-col gap-1 rounded-2xl border p-5 shadow-card ${i?"border-transparent bg-lime text-on-lime":"border-line bg-panel text-text"}${j?` ${j}`:""}`,children:[(0,d.jsx)("span",{className:`text-xs font-semibold uppercase tracking-[0.08em] ${i?"":"text-muted"}`,children:a}),(0,d.jsx)("span",{className:"min-w-0 font-display text-4xl font-bold tabular-nums [word-break:break-word]",children:b}),c&&g(i,c),e&&g(i,e),f&&f.length>1&&(0,d.jsx)("svg",{viewBox:"0 0 100 24",className:"mt-1 h-6 w-full","aria-hidden":"true",preserveAspectRatio:"none",children:(0,d.jsx)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round",strokeLinecap:"round",points:(l=Math.max(...f)-(k=Math.min(...f))||1,f.map((a,b)=>{let c=b/(f.length-1)*100;return`${c},${22-(a-k)/l*20}`}).join(" "))})})]})}h.propTypes={eyebrow:f().string.isRequired,value:f().node.isRequired,delta:f().node,trend:f().node,sparkline:f().arrayOf(f().number),hero:f().bool,className:f().string}},48161:a=>{"use strict";a.exports=require("node:os")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},53053:a=>{"use strict";a.exports=require("node:diagnostics_channel")},55511:a=>{"use strict";a.exports=require("crypto")},55591:a=>{"use strict";a.exports=require("https")},57075:a=>{"use strict";a.exports=require("node:stream")},57975:a=>{"use strict";a.exports=require("node:util")},61030:(a,b,c)=>{Promise.resolve().then(c.bind(c,74669))},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},66958:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"BailoutToCSR",{enumerable:!0,get:function(){return e}});let d=c(49306);function e({reason:a,children:b}){throw Object.defineProperty(new d.BailoutToCSRError(a),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0})}},67635:(a,b,c)=>{"use strict";c.d(b,{default:()=>j});var d=c(48249),e=c(49885),f=c.n(e),g=c(67484),h=c(71404),i=c(31290);function j({value:a,copyValue:b,label:c="Copy to clipboard",showCopyButton:e=!0,className:f,...k}){let[l,m]=(0,g.useState)(null),n=(0,g.useRef)(null),o=a=>{m(a),clearTimeout(n.current),n.current=setTimeout(()=>m(null),2e3)},p=async()=>{try{await (0,i.eM)(b??a),o("copied")}catch{o("error")}};return(0,d.jsxs)("div",{className:(0,h.cn)("flex h-11 items-center gap-2 rounded-lg border border-line bg-raised ps-3 pe-1.5 transition-colors","focus-within:border-coral focus-within:shadow-focus",f),...k,children:[(0,d.jsx)("code",{title:String(b??a),className:"min-w-0 flex-1 truncate font-mono text-sm text-text",children:a}),e?(0,d.jsx)("button",{type:"button","aria-label":c,onClick:p,className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted transition-colors hover:bg-line/60 hover:text-text focus-visible:shadow-focus",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:"copied"===l?"check":"error"===l?"error":"content_copy"})}):null,e?(0,d.jsx)("span",{"aria-live":"polite",className:"sr-only",children:"copied"===l?"Copied":"error"===l?"Copy failed":""}):null]})}j.propTypes={value:f().oneOfType([f().string,f().number]).isRequired,copyValue:f().string,label:f().string,showCopyButton:f().bool,className:f().string}},67960:(a,b,c)=>{"use strict";c.d(b,{Cp:()=>g,Hx:()=>f,Iv:()=>k,Nv:()=>m,RL:()=>j,ev:()=>l,fl:()=>h,hT:()=>d,oX:()=>e,t6:()=>i});let d=["zh-CN","zh-TW"],e=[{icon:"public",title:"Access anywhere",desc:"Use your API from any network"},{icon:"group",title:"Share endpoint",desc:"Share URL with team members"},{icon:"code",title:"Use in Cursor/Cline",desc:"Connect AI tools remotely"},{icon:"lock",title:"Encrypted",desc:"End-to-end TLS via Cloudflare"}],f=2e3,g=3e5,h=5e3,i=5,j=1e4,k=5e3,l=[{id:"lite",label:"Lite",desc:"Drop filler, keep grammar"},{id:"full",label:"Full",desc:"Drop articles, fragments OK"},{id:"ultra",label:"Ultra",desc:"Telegraphic, max compression"},{id:"wenyan-lite",label:"文 Lite",desc:"Classical Chinese, light compression",wenyan:!0},{id:"wenyan",label:"文 Full",desc:"Maximum 文言文, 80-90% reduction",wenyan:!0},{id:"wenyan-ultra",label:"文 Ultra",desc:"Extreme classical compression",wenyan:!0}],m=[{id:"lite",label:"Lite",desc:"Build asked, name lazier option"},{id:"full",label:"Full",desc:"Ladder enforced: stdlib/native first"},{id:"ultra",label:"Ultra",desc:"YAGNI extremist, deletion first"}]},69814:(a,b,c)=>{"use strict";c.d(b,{default:()=>k});var d=c(48249),e=c(49885),f=c.n(e),g=c(67484),h=c(71404),i=c(31290),j=c(27444);function k({label:a,value:b,onChange:c,min:e,max:f,step:l=1,error:m,hint:n,disabled:o=!1,required:p=!1,className:q,id:r,...s}){let[t,u]=(0,g.useState)(null),v=t??b??"",w=a=>{let d=(0,i.N)(a,{min:e,max:f});u(null),("string"!=typeof d||""===d)&&d!==b&&c?.(d)},x=a=>{let d=t??b,g=(0,i.CD)(""===d?void 0:d,{min:e,max:f,step:l,direction:a});u(null),c?.(g)},y="inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-line bg-raised text-muted transition-colors hover:text-text focus-visible:shadow-focus disabled:cursor-not-allowed disabled:opacity-50";return(0,d.jsx)(j.default,{id:r,label:a,hint:n,error:m,required:p,className:q,children:({inputId:a,describedBy:b,invalid:c})=>(0,d.jsxs)("div",{className:"flex items-stretch gap-2",children:[(0,d.jsx)("button",{type:"button","aria-label":"Decrease value","aria-controls":a,disabled:o,onClick:()=>x(-1),className:y,children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"remove"})}),(0,d.jsx)("input",{...s,id:a,type:"number",inputMode:"decimal",value:v,min:e,max:f,step:l,disabled:o,"aria-describedby":b,"aria-invalid":c||void 0,onChange:a=>u(a.target.value),onBlur:a=>w(a.target.value),onKeyDown:a=>{"Enter"===a.key?w(a.currentTarget.value):"ArrowUp"===a.key?(a.preventDefault(),x(1)):"ArrowDown"===a.key&&(a.preventDefault(),x(-1))},className:(0,h.cn)("w-full h-11 px-3 text-center text-sm text-text bg-raised rounded-lg","border border-line focus:outline-none focus:border-coral focus:shadow-focus","transition-colors duration-150 disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",c&&"border-err focus:border-err")}),(0,d.jsx)("button",{type:"button","aria-label":"Increase value","aria-controls":a,disabled:o,onClick:()=>x(1),className:y,children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"add"})})]})})}k.propTypes={label:f().node,value:f().oneOfType([f().string,f().number]),onChange:f().func,min:f().number,max:f().number,step:f().number,error:f().node,hint:f().node,disabled:f().bool,required:f().bool,className:f().string,id:f().string}},71553:a=>{"use strict";a.exports=require("node:dns/promises")},71622:a=>{"use strict";a.exports=import("open")},73024:a=>{"use strict";a.exports=require("node:fs")},73136:a=>{"use strict";a.exports=require("node:url")},73429:a=>{"use strict";a.exports=require("node:util/types")},73496:a=>{"use strict";a.exports=require("http2")},74075:a=>{"use strict";a.exports=require("zlib")},74669:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/settings/page.js\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/settings/page.js","default")},75919:a=>{"use strict";a.exports=require("node:worker_threads")},76760:a=>{"use strict";a.exports=require("node:path")},77030:a=>{"use strict";a.exports=require("node:net")},77598:a=>{"use strict";a.exports=require("node:crypto")},78197:(a,b,c)=>{"use strict";c.d(b,{default:()=>h});var d=c(48249),e=c(49885),f=c.n(e),g=c(24279);function h({icon:a,title:b,subtitle:c,status:e,statusLabel:f,className:i}){return(0,d.jsxs)("div",{className:`flex items-center gap-4 rounded-2xl border border-line bg-panel p-5 shadow-card${i?` ${i}`:""}`,children:[(0,d.jsx)("span",{className:"flex size-12 shrink-0 items-center justify-center rounded-xl bg-coral-bg text-coral-ink",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:a})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("h2",{className:"font-display text-2xl font-bold text-text",children:b}),c&&(0,d.jsx)("p",{className:"text-sm text-muted",children:c})]}),e&&(0,d.jsx)(g.default,{variant:e,size:"sm",dot:!0,children:f??e})]})}h.propTypes={icon:f().string.isRequired,title:f().node.isRequired,subtitle:f().node,status:f().string,statusLabel:f().string,className:f().string}},78474:a=>{"use strict";a.exports=require("node:events")},79646:a=>{"use strict";a.exports=require("child_process")},80061:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"default",{enumerable:!0,get:function(){return j}});let d=c(48249),e=c(67484),f=c(66958),g=c(85264);function h(a){return{default:a&&"default"in a?a.default:a}}let i={loader:()=>Promise.resolve(h(()=>null)),loading:null,ssr:!0},j=function(a){let b={...i,...a},c=(0,e.lazy)(()=>b.loader().then(h)),j=b.loading;function k(a){let h=j?(0,d.jsx)(j,{isLoading:!0,pastDelay:!0,error:null}):null,i=!b.ssr||!!b.loading,k=i?e.Suspense:e.Fragment,l=b.ssr?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.PreloadChunks,{moduleIds:b.modules}),(0,d.jsx)(c,{...a})]}):(0,d.jsx)(f.BailoutToCSR,{reason:"next/dynamic",children:(0,d.jsx)(c,{...a})});return(0,d.jsx)(k,{...i?{fallback:h}:{},children:l})}return k.displayName="LoadableComponent",k}},80099:a=>{"use strict";a.exports=require("node:sqlite")},81630:a=>{"use strict";a.exports=require("http")},81787:a=>{"use strict";a.exports=require("bun:sqlite")},85264:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"PreloadChunks",{enumerable:!0,get:function(){return i}});let d=c(48249),e=c(74429),f=c(29294),g=c(10117),h=c(44217);function i({moduleIds:a}){let b=f.workAsyncStorage.getStore();if(void 0===b)return null;let c=[];if(b.reactLoadableManifest&&a){let d=b.reactLoadableManifest;for(let b of a){if(!d[b])continue;let a=d[b].files;c.push(...a)}}if(0===c.length)return null;let j=(0,h.getAssetTokenQuery)();return(0,d.jsx)(d.Fragment,{children:c.map(a=>{let c=`${b.assetPrefix}/_next/${(0,g.encodeURIPath)(a)}${j}`;return a.endsWith(".css")?(0,d.jsx)("link",{precedence:"dynamic",href:c,rel:"stylesheet",as:"style",nonce:b.nonce},a):((0,e.preload)(c,{as:"script",fetchPriority:"low",nonce:b.nonce}),null)})})}},87550:a=>{"use strict";a.exports=require("better-sqlite3")},87997:a=>{"use strict";a.exports=require("node:timers")},88453:(a,b,c)=>{"use strict";c.r(b),c.d(b,{__next_app__:()=>z,handler:()=>B,routeModule:()=>A});var d=c(21635),e=c(86315),f=c(1020),g=c(61287),h={};for(let a in g)0>["default","__next_app__","routeModule","handler"].indexOf(a)&&(h[a]=()=>g[a]);c.d(b,h);let i=(0,d.p)(()=>Promise.resolve().then(c.bind(c,57529))),j=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,95547,23))),k=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,55091,23))),l=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,45270,23))),m=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,28193,23))),n=(0,d.p)(()=>Promise.resolve().then(c.bind(c,79409))),o=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,95547,23))),p=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,55091,23))),q=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,45270,23))),r=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,28193,23))),s=(0,d.p)(()=>Promise.resolve().then(c.bind(c,79346))),t=(0,d.p)(()=>Promise.resolve().then(c.bind(c,70160))),u=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,95547,23))),v=(0,d.p)(()=>Promise.resolve().then(c.bind(c,55880))),w=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,95547,23))),x={children:["",{children:["(dashboard)",{children:["dashboard",{children:["settings",{children:["__PAGE__",{},{page:[(0,d.p)(()=>Promise.resolve().then(c.bind(c,74669))),"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/settings/page.js"]}]},{"global-error":[w,"next/dist/client/components/builtin/global-error.js"]},[]]},{error:[s,"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/error.js"],loading:[t,"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/loading.js"],"global-error":[u,"next/dist/client/components/builtin/global-error.js"],"not-found":[v,"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/not-found.js"]},[]]},{layout:[n,"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/layout.js"],"global-error":[o,"next/dist/client/components/builtin/global-error.js"],"not-found":[p,"next/dist/client/components/builtin/not-found.js"],forbidden:[q,"next/dist/client/components/builtin/forbidden.js"],unauthorized:[r,"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}},[]]},{layout:[i,"/home/runner/work/tokenhop/tokenhop/src/app/layout.js"],"global-error":[j,"next/dist/client/components/builtin/global-error.js"],"not-found":[k,"next/dist/client/components/builtin/not-found.js"],forbidden:[l,"next/dist/client/components/builtin/forbidden.js"],unauthorized:[m,"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}},[]]}.children,y=(0,e.H)({tree:x,page:"/(dashboard)/dashboard/settings/page",pathname:"/dashboard/settings",require:c,loadChunk:()=>Promise.resolve(),interopDefault:f.T}),z=y.__next_app__,A=y.routeModule,B=y.handler},89322:(a,b,c)=>{"use strict";function d({authMode:a,ssoType:b}={}){let c="sso"===a||"oidc"===a||"saml"===a,e=c||"both"===a,f="oidc"===a||"saml"===a?a:"saml"===b?"saml":"oidc";return{password:!c,oidc:e&&"oidc"===f,saml:e&&"saml"===f,protocol:f,ssoOnly:c}}c.d(b,{b:()=>d})},90314:(a,b,c)=>{"use strict";c.d(b,{default:()=>e.a});var d=c(39973),e=c.n(d)},91431:(a,b,c)=>{"use strict";c.d(b,{CP:()=>e,KC:()=>d.KC,Xg:()=>d.Xg,bs:()=>f});var d=c(66427);Object.entries(c(92592).Q2).filter(([,a])=>a.passthroughModels).map(([a])=>a),Object.entries(d.vq).flatMap(([a,b])=>b.map(b=>({provider:a,model:b.id,name:b.name})));let e=(a,b=null)=>a?.kind||a?.type||b,f={vision:{icon:"visibility",label:"Vision",desc:"Supports image input",color:"text-blue-500"},reasoning:{icon:"neurology",label:"Reasoning",desc:"Supports reasoning / thinking",color:"text-amber-500"}}},91645:a=>{"use strict";a.exports=require("net")},94735:a=>{"use strict";a.exports=require("events")},95514:(a,b,c)=>{"use strict";c.d(b,{default:()=>j});var d=c(48249),e=c(49885),f=c.n(e),g=c(67484),h=c(71404);let i={sm:"h-[26px] w-11",md:"h-[26px] w-11",lg:"h-7 w-12"};function j({checked:a=!1,onChange:b,label:c,description:e,disabled:f=!1,size:k="md",className:l,id:m,...n}){let o=(0,g.useId)(),p=m||o,q=`${p}-label`,r=`${p}-description`;if(!i[k])throw Error(`Toggle: unknown size "${k}"`);return(0,d.jsxs)("div",{className:(0,h.cn)("flex items-center gap-3",f&&"opacity-50",l),children:[(0,d.jsx)("button",{...n,id:p,type:"button",role:"switch","aria-checked":a,"aria-labelledby":c?q:n["aria-labelledby"],"aria-describedby":e?r:n["aria-describedby"],"aria-label":c?void 0:n["aria-label"]||n.title,disabled:f,onClick:()=>b?.(!a),className:(0,h.cn)("relative inline-flex shrink-0 rounded-full border border-line transition-colors duration-200","focus-visible:outline-none focus-visible:shadow-focus disabled:cursor-not-allowed","motion-reduce:transition-none",a?"bg-toggle-on":"bg-line",i[k]),children:(0,d.jsx)("span",{"aria-hidden":"true",className:(0,h.cn)("pointer-events-none absolute top-0.5 size-5 rounded-full shadow-sm transition-transform duration-200 motion-reduce:transition-none",a?"bg-toggle-knob-on translate-x-5 rtl:-translate-x-5":"bg-muted translate-x-0.5 rtl:-translate-x-0.5","start-0")})}),(c||e)&&(0,d.jsxs)("div",{className:"flex flex-col",children:[c&&(0,d.jsx)("label",{id:q,htmlFor:p,className:"text-sm font-medium text-text cursor-pointer",children:c}),e&&(0,d.jsx)("span",{id:r,className:"text-xs text-muted",children:e})]})]})}j.propTypes={checked:f().bool,onChange:f().func,label:f().node,description:f().node,disabled:f().bool,size:f().oneOf(Object.keys(i)),className:f().string,id:f().string,title:f().string,"aria-label":f().string}}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,8666,2430,2217,2116,6561,9421,7819,6070,1152,915,7642,4123,7261,1533,6244,6849,1320,8171,2592,6427,3919,5699],()=>b(b.s=88453));module.exports=c})();
1
+ (()=>{var a={};a.id=2791,a.ids=[2791],a.modules={267:(a,b,c)=>{"use strict";c.d(b,{default:()=>m});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(51126),i=c(99258),j=c(95145);let k={en:"English",vi:"Tiếng Việt","zh-CN":"简体中文","zh-TW":"繁體中文",ja:"日本語","pt-BR":"Portugu\xeas (Brasil)","pt-PT":"Portugu\xeas (Portugal)",ko:"한국어",es:"Espa\xf1ol",de:"Deutsch",fr:"Fran\xe7ais",he:"עברית",ar:"العربية",ru:"Русский",pl:"Polski",cs:"Čeština",nl:"Nederlands",tr:"T\xfcrk\xe7e",uk:"Українська",tl:"Tagalog",id:"Indonesia",th:"ไทย",km:"ខ្មែរ",hi:"हिन्दी",bn:"বাংলা",ur:"اردو",ro:"Rom\xe2nă",sv:"Svenska",it:"Italiano",el:"Ελληνικά",hu:"Magyar",fi:"Suomi",da:"Dansk",no:"Norsk",fa:"فارسی"},l=a=>k[a]||a;function m({className:a="",isOpen:b,onClose:c,hideTrigger:f=!1}){let[g,k]=(0,e.useState)("en"),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),r="boolean"==typeof b,s=(a=g)=>{r?c?.(a):q(!1)},t=async a=>{if(a!==g&&!n){o(!0);try{await fetch("/api/locale",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locale:a})}),await (0,i.wn)();let b=document.documentElement,c=(0,i.kk)();b.lang=c,b.dir=h.rB.includes(c)?"rtl":"ltr",k(a),s(a)}catch(a){console.error("Failed to set locale:",a)}finally{o(!1)}}};return(0,d.jsxs)("div",{className:a,children:[!f&&(0,d.jsxs)("button",{type:"button",onClick:()=>q(!p),disabled:n,className:"flex h-11 items-center gap-2 rounded-lg px-3 text-muted transition-colors hover:bg-raised hover:text-text",title:"Language",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"language"}),(0,d.jsx)("span",{className:"text-sm font-medium",children:l(g)})]}),(0,d.jsx)(j.default,{isOpen:r?b:p,onClose:()=>s(),title:"Select language",size:"full",className:"max-w-2xl",children:(0,d.jsx)("div",{"data-i18n-skip":"true",className:"grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2",children:h.YZ.map(a=>{let b=g===a;return(0,d.jsxs)("button",{type:"button",onClick:()=>t(a),disabled:n,"aria-current":b||void 0,title:l(a),className:`flex w-full flex-col items-center justify-start gap-1 rounded-lg px-2 py-3 text-xs font-medium transition-colors ${b?"bg-coral-bg text-coral shadow-focus":"text-text hover:bg-raised"} ${n?"cursor-wait opacity-70":""}`,children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[26px]","aria-hidden":"true",children:b?"language":"translate"}),(0,d.jsx)("span",{className:"flex h-8 items-center overflow-hidden text-center leading-tight [display:-webkit-box] [-webkit-box-orient:vertical] [-webkit-line-clamp:2]",children:l(a)}),b&&(0,d.jsx)("span",{className:"material-symbols-outlined text-sm","aria-hidden":"true",children:"check"})]},a)})})})]})}m.propTypes={className:g().string,isOpen:g().bool,onClose:g().func,hideTrigger:g().bool}},643:a=>{"use strict";a.exports=require("node:perf_hooks")},1582:(a,b,c)=>{"use strict";c.d(b,{default:()=>g});var d=c(48249),e=c(49885),f=c.n(e);function g({label:a,description:b,settingKey:c,control:e,className:f}){return(0,d.jsxs)("div",{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-3 py-4${f?` ${f}`:""}`,children:[(0,d.jsxs)("div",{className:"min-w-52 flex-1",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:a}),b&&(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:b}),c&&(0,d.jsx)("p",{className:"mt-0.5 font-mono text-[11px] text-subtle",children:c})]}),(0,d.jsx)("div",{className:"shrink-0",children:e})]})}g.propTypes={label:f().node.isRequired,description:f().node,settingKey:f().string,control:f().node.isRequired,className:f().string}},1708:a=>{"use strict";a.exports=require("node:process")},1932:a=>{"use strict";a.exports=require("url")},2362:(a,b,c)=>{"use strict";function d(a,b){let c=null,d=(...d)=>{clearTimeout(c),c=setTimeout(()=>a(...d),b)};return d.cancel=()=>clearTimeout(c),d}c.d(b,{s:()=>d})},3090:(a,b,c)=>{"use strict";c.d(b,{default:()=>i});var d=c(48249),e=c(49885),f=c.n(e),g=c(71404),h=c(27444);function i({label:a,value:b,onChange:c,unit:e,type:f="number",error:j,hint:k,disabled:l=!1,required:m=!1,className:n,id:o,...p}){return(0,d.jsx)(h.default,{id:o,label:a,hint:k,error:j,required:m,className:n,children:({inputId:a,describedBy:h,invalid:i})=>{let j=`${a}-unit`,k=[e?j:null,h].filter(Boolean).join(" ")||void 0;return(0,d.jsxs)("div",{className:(0,g.cn)("flex h-11 items-center rounded-lg border border-line bg-raised transition-colors","focus-within:border-coral focus-within:shadow-focus",i&&"border-err focus-within:border-err",l&&"opacity-50"),children:[(0,d.jsx)("input",{...p,id:a,type:f,inputMode:"number"===f?"decimal":void 0,value:b,onChange:c,disabled:l,"aria-describedby":k,"aria-invalid":i||void 0,className:"w-full min-w-0 bg-transparent px-3 py-2.5 text-sm text-text placeholder:text-subtle focus:outline-none text-[16px] sm:text-sm [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),e&&(0,d.jsx)("span",{id:j,className:"shrink-0 pe-3 text-sm text-subtle",children:e})]})}})}i.propTypes={label:f().node,value:f().oneOfType([f().string,f().number]),onChange:f().func,type:f().string,unit:f().node,error:f().node,hint:f().node,disabled:f().bool,required:f().bool,className:f().string,id:f().string}},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},7066:a=>{"use strict";a.exports=require("node:tty")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10117:(a,b)=>{"use strict";function c(a){return a.split("/").map(a=>encodeURIComponent(a)).join("/")}Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"encodeURIPath",{enumerable:!0,get:function(){return c}})},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},14985:a=>{"use strict";a.exports=require("dns")},16698:a=>{"use strict";a.exports=require("node:async_hooks")},19099:(a,b,c)=>{"use strict";var d=c(54839);c.o(d,"notFound")&&c.d(b,{notFound:function(){return d.notFound}}),c.o(d,"useParams")&&c.d(b,{useParams:function(){return d.useParams}}),c.o(d,"usePathname")&&c.d(b,{usePathname:function(){return d.usePathname}}),c.o(d,"useRouter")&&c.d(b,{useRouter:function(){return d.useRouter}}),c.o(d,"useSearchParams")&&c.d(b,{useSearchParams:function(){return d.useSearchParams}})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{"use strict";a.exports=require("os")},27558:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>bk});var d=c(48249),e=c(67484),f=c(9123),g=c(26584),h=c(33597),i=c(74812),j=c(99070),k=c(49885),l=c.n(k),m=c(89025),n=c(75171),o=c(216),p=c(83552),q=c(95145);let r={changed:"warn",added:"info",unchanged:"neutral"},s=[["settings","Settings"],["combos","Combos"],["pricing","Pricing overrides"]],t="Configuration only: settings, combos and pricing overrides. Passwords, secrets and provider accounts are never included. URL credentials are redacted; masked URL settings keep their current values on import. For a full backup, use Data & backup.";async function u(a){let b=await fetch("/api/settings/config/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>({}));if(!b.ok){let a=(c.errors??[]).slice(1);throw Error([c.error||"Import failed",...a].join(" \xb7 "))}return c}function v({label:a,section:b}){let[c,f]=(0,e.useState)(!1);return b&&0!==b.entries.length?(0,d.jsxs)("div",{className:"rounded-xl border border-line",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>f(a=>!a),"aria-expanded":c,className:"flex min-h-11 w-full flex-wrap items-center gap-2 rounded-xl px-3 py-2 text-start text-sm outline-none focus-visible:shadow-focus",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] text-muted rtl:-scale-x-100","aria-hidden":"true",children:c?"expand_more":"chevron_right"}),(0,d.jsx)("span",{className:"font-semibold text-text",children:a}),(0,d.jsx)("span",{className:"ms-auto flex flex-wrap gap-1",children:["changed","added","unchanged"].map(a=>b[a]>0?(0,d.jsx)(n.default,{variant:r[a],children:`${b[a]} ${a}`},a):null)})]}),c&&(0,d.jsx)("ul",{className:"max-h-56 space-y-1.5 overflow-y-auto border-t border-line px-3 py-2",children:b.entries.map(a=>(0,d.jsxs)("li",{className:"flex flex-wrap items-center gap-2 text-[13px]",children:[(0,d.jsx)(n.default,{variant:r[a.status],children:a.status}),(0,d.jsx)("code",{className:"break-all font-mono text-text",children:a.key}),a.restart&&(0,d.jsx)(n.default,{variant:"neutral",children:"restart"})]},a.key))})]}):null}function w({onSettingsChange:a}){let[b,c]=(0,e.useState)({type:"",message:""}),[f,g]=(0,e.useState)(!1),[h,i]=(0,e.useState)({open:!1,mode:"",password:""}),[k,l]=(0,e.useState)(null),n=(0,e.useRef)(null),r=(0,e.useRef)(""),x=(0,e.useRef)(null),y=()=>i({open:!1,mode:"",password:""}),z=()=>{n.current=null,r.current="",l(null)},A=async a=>{g(!0);try{let b,d,e=await fetch("/api/settings/config/export",{headers:{"x-9r-password":a}}),f=await e.json().catch(()=>({}));if(!e.ok)throw Error(f.error||"Export failed");b=URL.createObjectURL(new Blob([JSON.stringify(f,null,2)],{type:"application/json"})),(d=document.createElement("a")).href=b,d.download=`${m.Hc.slug}-config-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(b),c({type:"ok",message:"Configuration exported"})}catch(a){c({type:"err",message:a.message||"Export failed"})}finally{g(!1)}},B=async a=>{g(!0);try{let b=await u({doc:n.current,mode:"preview",password:a});r.current=a,l(b)}catch(a){n.current=null,c({type:"err",message:a.message})}finally{g(!1)}},C=async()=>{g(!0);try{let b=await u({doc:n.current,mode:"apply",password:r.current});z(),a?.(),c({type:"ok",message:b.restartRequired?"Configuration imported. Some changes apply after a restart.":"Configuration imported"})}catch(a){l(b=>b?{...b,applyError:a.message}:b)}finally{g(!1)}},D=async a=>{let b=a.target.files?.[0];if(x.current&&(x.current.value=""),b){if(c({type:"",message:""}),b.size>1048576)return void c({type:"err",message:"That file is too large (max 1 MB)"});try{n.current=JSON.parse(await b.text())}catch{n.current=null,c({type:"err",message:"That file isn't valid JSON"});return}i({open:!0,mode:"import",password:""})}},E=()=>{let{mode:a,password:b}=h;y(),"export"===a?A(b):B(b)},F=k&&s.some(([a])=>k.diff[a].changed+k.diff[a].added>0);return(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(j.default,{variant:"secondary",icon:"download",loading:f&&"export"===h.mode,disabled:f,onClick:()=>{c({type:"",message:""}),i({open:!0,mode:"export",password:""})},children:"Export config"}),(0,d.jsx)(j.default,{variant:"secondary",icon:"upload",disabled:f,onClick:()=>x.current?.click(),children:"Import"}),(0,d.jsx)("input",{ref:x,type:"file",accept:"application/json,.json",onChange:D,className:"hidden",tabIndex:-1,"aria-hidden":"true"})]}),(0,d.jsx)("div",{"aria-live":"polite","aria-atomic":"true",children:b.message&&(0,d.jsx)(o.default,{variant:"ok"===b.type?"ok":"err",title:b.message})}),(0,d.jsxs)(q.default,{isOpen:h.open,onClose:y,title:"Confirm password",size:"sm",footer:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.default,{variant:"ghost",onClick:y,children:"Cancel"}),(0,d.jsx)(j.default,{onClick:E,disabled:!h.password,children:"Confirm"})]}),children:[(0,d.jsx)("p",{className:"mb-3 text-sm text-muted",children:"export"===h.mode?"Enter your current password to export the configuration.":"Enter your current password to check this configuration file."}),(0,d.jsx)(p.default,{type:"password",autoComplete:"current-password","aria-label":"Current password",value:h.password,onChange:a=>i(b=>({...b,password:a.target.value})),onKeyDown:a=>{"Enter"===a.key&&h.password&&E()},placeholder:"Current password"}),(0,d.jsx)("p",{className:"mt-3 text-[13px] text-muted",children:t})]}),(0,d.jsx)(q.default,{isOpen:!!k,onClose:z,title:"Import configuration",size:"lg",footer:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.default,{variant:"ghost",onClick:z,disabled:f,children:"Cancel"}),(0,d.jsx)(j.default,{onClick:C,loading:f,disabled:!F,children:"Apply import"})]}),children:k&&(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("p",{className:"text-sm text-muted",children:t}),k.redactedSettings?.length>0&&(0,d.jsx)(o.default,{variant:"info",title:"URLs with credentials were masked on export",children:(0,d.jsxs)("p",{children:[k.redactedSettings.join(", "),": these keep their current values unless you re-enter the full URL before applying."]})}),k.warnings?.length>0&&(0,d.jsx)(o.default,{variant:"warn",title:"Some entries will be skipped",children:(0,d.jsx)("ul",{className:"list-disc ps-5",children:k.warnings.map(a=>(0,d.jsx)("li",{children:a},a))})}),k.restartRequired&&(0,d.jsx)(o.default,{variant:"info",title:"Some changes apply after a restart"}),!F&&(0,d.jsx)(o.default,{variant:"ok",title:"Nothing to change: this matches your current setup"}),s.map(([a,b])=>(0,d.jsx)(v,{label:b,section:k.diff[a]},a)),(0,d.jsx)("p",{className:"text-[13px] text-muted",children:"Import adds and updates entries. Nothing is removed. All changes apply together or not at all."}),k.applyError&&(0,d.jsx)("div",{role:"alert",children:(0,d.jsx)(o.default,{variant:"err",title:k.applyError})})]})})]})}v.propTypes={label:l().string.isRequired,section:l().shape({changed:l().number,added:l().number,unchanged:l().number,entries:l().arrayOf(l().shape({key:l().string.isRequired,status:l().oneOf(["changed","added","unchanged"]).isRequired,restart:l().bool}))})},w.propTypes={onSettingsChange:l().func};var x=c(42118),y=c(78197),z=c(1582),A=c(91099),B=c(31023),C=c(267),D=c(51126),E=c(81725);function F(a,b){switch(b.type){case"optimistic":return{...a,value:b.value,status:"saving",error:""};case"saved":return{value:b.value,savedValue:b.value,status:"saved",error:""};case"failed":return{...a,value:a.savedValue,status:"error",error:b.error};case"sync":if("saving"===a.status)return a;return{...a,value:b.value,savedValue:b.value,error:""};case"clear-error":return{...a,status:"idle",error:""};default:return a}}function G(a){return{value:a,savedValue:a,status:"idle",error:""}}async function H(a,b){let c=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:b})}),d=await c.json().catch(()=>({}));if(!c.ok)throw Error(d.error||"Failed to save setting");return d}function I(a,b,c={}){let{debounced:d=!1,onSaved:f,restartRequired:g=!1}=c,[h,i]=(0,e.useReducer)(F,b,G),j=(0,e.useRef)(f);j.current=f;let k=(0,e.useCallback)(async b=>{try{let c=await H(a,b),d=Object.hasOwn(c,a)?c[a]:b;i({type:"saved",value:d}),j.current?.(d,{restartRequired:g})}catch(a){i({type:"failed",error:a.message})}},[a,g]),l=(0,e.useRef)(null),m=(0,e.useCallback)(a=>{i({type:"optimistic",value:a}),d?l.current?.(a):k(a)},[d,k]),n=(0,e.useCallback)(()=>i({type:"clear-error"}),[]);return{value:h.value,saving:"saving"===h.status,error:h.error,set:m,clearError:n}}c(2362);let J={"/dashboard":"Home","/dashboard/providers":"Providers","/dashboard/combos":"Combos","/dashboard/endpoint":"Endpoint & keys","/dashboard/usage":"Usage","/dashboard/quota":"Quota","/dashboard/console-log":"Console log","/dashboard/token-saver":"Token saver","/dashboard/cli-tools":"CLI tools","/dashboard/media-providers":"Media providers","/dashboard/proxy-pools":"Proxy pools","/dashboard/skills":"Skills","/dashboard/settings":"Settings","/dashboard/translator":"Translator"},K=["/dashboard","/dashboard/providers","/dashboard/combos","/dashboard/endpoint","/dashboard/usage","/dashboard/quota","/dashboard/console-log","/dashboard/token-saver","/dashboard/cli-tools","/dashboard/media-providers","/dashboard/proxy-pools","/dashboard/skills","/dashboard/settings","/dashboard/translator"].map(a=>({value:a,label:J[a]||a})),L=[{value:"light",label:"Light",icon:"light_mode"},{value:"dark",label:"Dark",icon:"dark_mode"},{value:"system",label:"System",icon:"contrast"}],M=[{value:"comfortable",label:"Comfortable"},{value:"compact",label:"Compact"}];function N({settings:a,locale:b="en",onLocaleChange:c,onSettingsChange:f}){let{theme:g,setTheme:h}=(0,x.D)(),[i,k]=(0,e.useState)(!1),l=I("startPage",a.startPage||"/dashboard",{onSaved:a=>f?.({startPage:a})}),m=I("uiDensity",a.uiDensity||"comfortable",{onSaved:a=>{(0,E.pW)(a),f?.({uiDensity:a})}});return(0,d.jsxs)("div",{id:"general",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"tune",title:"General",subtitle:"Look, language and where you land."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Theme",description:"Dark, light, or follow your system.",settingKey:"theme",control:(0,d.jsx)(A.default,{options:L,value:g,onChange:h,"aria-label":"Theme preference"})}),(0,d.jsx)(z.default,{label:"Language",description:"Dashboard language.",settingKey:"language",control:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(j.default,{variant:"secondary",icon:"language",onClick:()=>k(!0),children:D.kf[b]||b}),(0,d.jsx)(C.default,{hideTrigger:!0,isOpen:i,onClose:a=>{k(!1),a&&c?.(a)}})]})}),(0,d.jsx)(z.default,{label:"Start page",description:"Where you land after login and on `/`.",settingKey:"startPage",control:(0,d.jsxs)("div",{className:"w-56",children:[(0,d.jsx)(B.default,{"aria-label":"Start page",options:K,value:l.value,onChange:a=>l.set(a.target.value),disabled:l.saving}),l.error&&(0,d.jsx)("p",{className:"mt-1 text-xs text-err",role:"alert",children:l.error})]})}),(0,d.jsx)(z.default,{label:"Density",description:"Compact tightens spacing and row heights.",settingKey:"uiDensity",control:(0,d.jsxs)("div",{children:[(0,d.jsx)(A.default,{options:M,value:m.value,onChange:m.set,"aria-label":"Density preference"}),m.error&&(0,d.jsx)("p",{className:"mt-1 text-xs text-err",role:"alert",children:m.error})]})})]})]})}N.propTypes={settings:l().object.isRequired,locale:l().string,onLocaleChange:l().func,onSettingsChange:l().func};var O=c(95514),P=c(67635);function Q({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),f=I("requireLogin",!1!==a.requireLogin,{onSaved:c("requireLogin")}),g=I("requireApiKey",!1!==a.requireApiKey,{onSaved:c("requireApiKey")}),h=I("tunnelDashboardAccess",!1!==a.tunnelDashboardAccess,{onSaved:c("tunnelDashboardAccess")}),[k,l]=(0,e.useState)(null),[m,n]=(0,e.useState)(!1),[q,r]=(0,e.useState)({current:"",next:"",confirm:""}),[s,t]=(0,e.useState)({type:"",message:""}),[u,v]=(0,e.useState)(!1),w=async a=>{if(a.preventDefault(),q.next!==q.confirm)return void t({type:"err",message:"Passwords do not match"});if(!q.next)return void t({type:"err",message:"New password cannot be empty"});v(!0),t({type:"",message:""});try{let a=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:q.current,newPassword:q.next})}),c=await a.json().catch(()=>({}));a.ok?(t({type:"ok",message:"Password updated successfully"}),r({current:"",next:"",confirm:""}),b?.({hasPassword:!0})):t({type:"err",message:c.error||"Failed to update password"})}catch{t({type:"err",message:"An error occurred while updating password"})}finally{v(!1)}};return(0,d.jsxs)("div",{id:"security",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"shield",title:"Security & access",subtitle:"Who can reach the dashboard and the API.",status:"ok",statusLabel:"Protected"}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Require login",description:"Ask for the dashboard password first.",settingKey:"requireLogin",control:(0,d.jsx)(O.default,{checked:f.value,onChange:a=>f.set(a),disabled:f.saving,"aria-label":"Require login"})}),f.error&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:f.error}),(0,d.jsxs)("div",{className:"py-4 space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Password"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Change the dashboard password. Replace the default before exposing anything."})]}),(0,d.jsxs)("form",{onSubmit:w,className:"space-y-3 max-w-xl",children:[a.hasPassword&&(0,d.jsx)(p.default,{label:"Current password",type:"password",autoComplete:"current-password",value:q.current,onChange:a=>r(b=>({...b,current:a.target.value})),required:!0,disabled:u,placeholder:"Current password"}),(0,d.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,d.jsx)(p.default,{label:"New password",type:"password",autoComplete:"new-password",value:q.next,onChange:a=>r(b=>({...b,next:a.target.value})),required:!0,disabled:u,placeholder:"New password"}),(0,d.jsx)(p.default,{label:"Confirm new password",type:"password",autoComplete:"new-password",value:q.confirm,onChange:a=>r(b=>({...b,confirm:a.target.value})),required:!0,disabled:u,placeholder:"Confirm password"})]}),s.message&&(0,d.jsx)(o.default,{variant:"ok"===s.type?"ok":"err",title:s.message}),(0,d.jsx)(j.default,{type:"submit",loading:u,disabled:u||void 0===a.hasPassword,children:a.hasPassword?"Update password":"Set password"})]})]}),(0,d.jsx)(z.default,{label:"Require API key",description:"Requests without a valid key get a 401. Needed for the tunnel.",settingKey:"requireApiKey",control:(0,d.jsx)(O.default,{checked:g.value,onChange:a=>g.set(a),disabled:g.saving,"aria-label":"Require API key"})}),g.error&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:g.error}),(0,d.jsx)(z.default,{label:"Dashboard over tunnel",description:"Serve this dashboard on the public tunnel URL too.",settingKey:"tunnelDashboardAccess",control:(0,d.jsx)(O.default,{checked:h.value,onChange:a=>h.set(a),disabled:h.saving,"aria-label":"Dashboard over tunnel"})}),h.error&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:h.error}),(0,d.jsx)(z.default,{label:"Secure session cookie",description:"HTTPS-only cookie for the login session.",settingKey:"AUTH_COOKIE_SECURE",control:(0,d.jsx)("div",{className:"w-full sm:min-w-72 sm:max-w-sm",children:k?(0,d.jsx)(P.default,{value:k,label:"Copy secure cookie state"}):m?(0,d.jsx)("p",{className:"text-sm text-err",role:"alert",children:"Could not load cookie state"}):(0,d.jsx)("div",{role:"status","aria-label":"Loading cookie state",children:(0,d.jsx)(i.Skeleton,{className:"h-11 w-full"})})})})]})]})}async function R(a){return T("/api/settings","PATCH",a)}async function S(a,b){let c=await T(a,"POST",b);if(!c?.ok)throw Error(c?.error||"Request failed");return c}async function T(a,b,c){let d=await fetch(a,{method:b,headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),e=await d.json().catch(()=>({}));if(!d.ok)throw Error(e.error||`Request failed (${d.status})`);return e}Q.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var U=c(89322);let V="openid profile email",W="Sign in with OIDC";function X({settings:a,authMode:b,redirectUri:c,onSaved:f}){let[g,h]=(0,e.useState)({oidcIssuerUrl:a.oidcIssuerUrl||"",oidcClientId:a.oidcClientId||"",oidcScopes:a.oidcScopes||V,oidcLoginLabel:a.oidcLoginLabel||W}),[i,k]=(0,e.useState)(""),[l,n]=(0,e.useState)(""),[q,r]=(0,e.useState)({type:"",message:""}),s=a=>b=>h(c=>({...c,[a]:b.target.value})),t=()=>{let a={authMode:b,ssoType:"oidc",oidcIssuerUrl:g.oidcIssuerUrl.trim(),oidcClientId:g.oidcClientId.trim(),oidcScopes:g.oidcScopes.trim()||V,oidcLoginLabel:g.oidcLoginLabel.trim()||W};return i.trim()&&(a.oidcClientSecret=i.trim()),a},u=async()=>{let a=await R(t());return k(""),f(a),a},v=async c=>{c.preventDefault();let d=t();if("password"!==b&&(!d.oidcIssuerUrl||!d.oidcClientId||!d.oidcClientSecret)&&!a.oidcConfigured)return void r({type:"err",message:"Issuer URL, client ID, and client secret are required to enable OIDC."});n("save"),r({type:"",message:""});try{await u(),r({type:"ok",message:"sso"===b?"OIDC login enabled":"both"===b?"Password and OIDC login enabled":"OIDC settings saved"})}catch(a){r({type:"err",message:a.message||"Failed to save OIDC settings"})}finally{n("")}},w=async()=>{if(!g.oidcIssuerUrl.trim()||!g.oidcClientId.trim())return void r({type:"err",message:"Issuer URL and client ID are required to test the connection."});n("test"),r({type:"",message:""});try{let a,b,c;try{a=await u()}catch(a){throw Error(a.message||"Failed to save OIDC settings before testing")}let d=await S("/api/auth/oidc/test",{issuerUrl:a.oidcIssuerUrl,clientId:a.oidcClientId,scopes:a.oidcScopes||V});r({type:"ok",message:(b=`Connection OK. Discovery loaded from ${d.issuerUrl}.`,c=d.clientSecretTested?!0===d.clientSecretValid?`${b} Client secret validated too.`:`${b} Client secret was not checked.`:b,Array.isArray(d.signingAlgs)&&d.signingAlgs.length>0&&(c+=` Signing: ${d.signingAlgs.join(", ")}.`),Array.isArray(d.warnings)&&d.warnings.length>0&&(c+=` ${d.warnings.join(" ")}`),c)})}catch(a){r({type:"err",message:a.message||"OIDC connection test failed"})}finally{n("")}},x=""!==l;return(0,d.jsxs)("form",{onSubmit:v,className:"flex flex-col gap-4",children:[(0,d.jsx)(p.default,{label:"Issuer URL",value:g.oidcIssuerUrl,onChange:s("oidcIssuerUrl"),placeholder:`https://auth.example.com/application/o/${m.Hc.slug}/`,disabled:x}),(0,d.jsx)(p.default,{label:"Client ID",value:g.oidcClientId,onChange:s("oidcClientId"),placeholder:`${m.Hc.slug}-dashboard`,disabled:x}),(0,d.jsx)(p.default,{label:"Client secret",type:"password",autoComplete:"new-password",value:i,onChange:a=>k(a.target.value),placeholder:"Leave blank to keep existing secret",hint:"This value is write-only after saving.",disabled:x}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,d.jsx)(p.default,{label:"Scopes",value:g.oidcScopes,onChange:s("oidcScopes"),placeholder:V,disabled:x}),(0,d.jsx)(p.default,{label:"Button label",value:g.oidcLoginLabel,onChange:s("oidcLoginLabel"),placeholder:W,disabled:x})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-text",children:"Redirect URI \xb7 give this to your IdP"}),(0,d.jsx)(P.default,{value:c,label:"Copy redirect URI"})]}),(0,d.jsx)("div",{"aria-live":"polite",children:q.message&&(0,d.jsx)(o.default,{variant:"ok"===q.type?"ok":"err",title:q.message})}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(j.default,{type:"submit",loading:"save"===l,disabled:x,children:"Save OIDC settings"}),(0,d.jsx)(j.default,{type:"button",variant:"secondary",onClick:w,loading:"test"===l,disabled:x,children:"Test sign-in"})]})]})}X.propTypes={settings:l().object.isRequired,authMode:l().oneOf(["password","sso","both"]).isRequired,redirectUri:l().string.isRequired,onSaved:l().func.isRequired};var Y=c(44928);function Z({children:a}){return(0,d.jsx)("code",{className:"break-all font-mono text-text",children:a})}function $({title:a,steps:b}){return(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 rounded-lg border border-line bg-panel p-3",children:[(0,d.jsx)("p",{className:"font-semibold text-text",children:a}),(0,d.jsx)("ol",{className:"list-decimal space-y-1 ps-4 text-muted",children:b.map((a,b)=>(0,d.jsx)("li",{children:a},b))})]})}function _({acsUrl:a,entityId:b}){return(0,d.jsxs)("div",{className:"flex flex-col gap-3 text-xs",children:[(0,d.jsxs)("div",{className:"rounded-lg bg-sky-bg p-3 text-text",children:[(0,d.jsx)("p",{className:"mb-1 font-semibold",children:"Required service provider (SP) values for your IdP"}),(0,d.jsxs)("ul",{className:"list-disc space-y-1 ps-4",children:[(0,d.jsxs)("li",{children:["Assertion Consumer Service (ACS) URL: ",(0,d.jsx)(Z,{children:a})]}),(0,d.jsxs)("li",{children:["SP entity ID / audience URI: ",(0,d.jsx)(Z,{children:b})]}),(0,d.jsxs)("li",{children:["NameID format: ",(0,d.jsx)(Z,{children:"EmailAddress"})," or ",(0,d.jsx)(Z,{children:"Unspecified"})]})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[(0,d.jsx)($,{title:"AWS IAM Identity Center",steps:["Applications → Add application → Add custom SAML 2.0 application.",(0,d.jsxs)(d.Fragment,{children:["Set application ACS URL to ",(0,d.jsx)(Z,{children:a}),"."]}),(0,d.jsxs)(d.Fragment,{children:["Set application SAML audience to ",(0,d.jsx)(Z,{children:b}),"."]}),(0,d.jsxs)(d.Fragment,{children:["Under Attribute mappings, map ",(0,d.jsx)(Z,{children:"Subject"})," or ",(0,d.jsx)(Z,{children:"email"})," to"," ",(0,d.jsx)(Z,{children:"${user:email}"}),"."]}),"Download the IAM Identity Center SAML metadata XML and import it below."]}),(0,d.jsx)($,{title:"Microsoft Entra ID (Azure AD)",steps:["Enterprise Applications → New application → Create your own application.","Select Single sign-on → SAML.",(0,d.jsxs)(d.Fragment,{children:["Identifier (Entity ID): ",(0,d.jsx)(Z,{children:b})]}),(0,d.jsxs)(d.Fragment,{children:["Reply URL (ACS): ",(0,d.jsx)(Z,{children:a})]}),"Download Federation Metadata XML and import it, or copy the X.509 certificate."]}),(0,d.jsx)($,{title:"Okta / Auth0",steps:["Applications → Create App Integration → SAML 2.0.",(0,d.jsxs)(d.Fragment,{children:["Single Sign-On URL: ",(0,d.jsx)(Z,{children:a})]}),(0,d.jsxs)(d.Fragment,{children:["Audience URI (SP Entity ID): ",(0,d.jsx)(Z,{children:b})]}),"Name ID format: EmailAddress.","Download the Identity Provider metadata XML or copy the X.509 certificate."]}),(0,d.jsx)($,{title:"Keycloak / Authentik",steps:["Clients → Create client → SAML.",(0,d.jsxs)(d.Fragment,{children:["Client ID: ",(0,d.jsx)(Z,{children:b})]}),(0,d.jsxs)(d.Fragment,{children:["Master SAML Processing URL: ",(0,d.jsx)(Z,{children:a})]}),"Export the SAML descriptor XML or copy the IdP certificate PEM."]})]})]})}Z.propTypes={children:l().node},$.propTypes={title:l().string.isRequired,steps:l().arrayOf(l().node)},_.propTypes={acsUrl:l().string.isRequired,entityId:l().string.isRequired};let aa=m.Hc.samlIssuerDefault,ab="Sign in with SAML SSO";function ac({settings:a,authMode:b,acsUrl:c,metadataUrl:f,onSaved:g}){let[h,i]=(0,e.useState)({samlEntryPoint:a.samlEntryPoint||"",samlIssuer:a.samlIssuer||aa,samlCert:a.samlCert||"",samlLoginLabel:a.samlLoginLabel||ab,samlAttributeEmail:a.samlAttributeEmail||"email",samlAttributeName:a.samlAttributeName||"name"}),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)({type:"",message:""}),[q,r]=(0,e.useState)(!1),s=(0,e.useRef)(null),t=(0,e.useRef)(null),u=a=>b=>i(c=>({...c,[a]:b.target.value})),v=async a=>{a.preventDefault(),l("save"),n({type:"",message:""});try{let a=await R({authMode:b,ssoType:"saml",samlEntryPoint:h.samlEntryPoint.trim(),samlIssuer:h.samlIssuer.trim()||aa,samlCert:h.samlCert.trim(),samlLoginLabel:h.samlLoginLabel.trim()||ab,samlAttributeEmail:h.samlAttributeEmail.trim()||"email",samlAttributeName:h.samlAttributeName.trim()||"name"});g(a),n({type:"ok",message:"sso"===b?"SAML SSO login enabled":"both"===b?"Password and SAML SSO login enabled":"SAML 2.0 settings saved"})}catch(a){n({type:"err",message:a.message||"Failed to save SAML settings"})}finally{l("")}},w=async()=>{l("test"),n({type:"",message:""});try{let a=await S("/api/auth/saml/test",{samlEntryPoint:h.samlEntryPoint.trim(),samlIssuer:h.samlIssuer.trim()||aa,samlCert:h.samlCert.trim()});n({type:"ok",message:a.message||"SAML configuration verified!"})}catch(a){n({type:"err",message:a.message||"SAML configuration test failed"})}finally{l("")}},x=""!==k;return(0,d.jsxs)("form",{onSubmit:v,className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"rounded-xl border border-line bg-raised p-3",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>r(a=>!a),"aria-expanded":q,className:"flex w-full items-center justify-between text-start text-xs font-semibold text-text",children:[(0,d.jsxs)("span",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] text-coral","aria-hidden":"true",children:"menu_book"}),"IdP setup guidelines & provider instructions"]}),(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:q?"expand_less":"expand_more"})]}),q&&(0,d.jsx)("div",{className:"mt-3 border-t border-line pt-3",children:(0,d.jsx)(_,{acsUrl:c,entityId:h.samlIssuer||aa})})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 rounded-xl border border-dashed border-coral/40 bg-coral-bg p-3",children:[(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("p",{className:"text-sm font-semibold text-text",children:"1-click IdP metadata XML import"}),(0,d.jsx)("p",{className:"text-xs text-muted",children:"Auto-fill SSO URL, entity ID and cert from the IdP XML."})]}),(0,d.jsx)(j.default,{type:"button",variant:"secondary",size:"sm",icon:"upload_file",onClick:()=>t.current?.click(),disabled:x,children:"Upload metadata XML"}),(0,d.jsx)("input",{ref:t,type:"file",accept:".xml,application/xml,text/xml",onChange:a=>{let b=a.target.files?.[0];if(t.current&&(t.current.value=""),!b)return;let c=new FileReader;c.onload=a=>{let b=function(a){let b=new DOMParser().parseFromString(a,"text/xml");if(b.querySelector("parsererror"))return null;let c="";for(let a of b.querySelectorAll("SingleSignOnService, *|SingleSignOnService")){let b=a.getAttribute("Location")||"";if(b&&(c=b,(a.getAttribute("Binding")||"").includes("HTTP-Redirect")))break}let d=b.querySelector("X509Certificate, *|X509Certificate");return{entityId:b.documentElement.getAttribute("entityID")||"",ssoUrl:c,cert:d?.textContent.trim()||""}}(a.target?.result||"");b?(i(a=>({...a,samlEntryPoint:b.ssoUrl||a.samlEntryPoint,samlCert:b.cert||a.samlCert})),n({type:"ok",message:`IdP metadata imported (SSO URL: ${b.ssoUrl?"found":"not found"}, cert: ${b.cert?"found":"not found"}).`})):n({type:"err",message:"Unable to parse valid SAML IdP metadata"})},c.onerror=()=>n({type:"err",message:"Error reading metadata file"}),c.readAsText(b)},className:"hidden"})]}),(0,d.jsx)(p.default,{label:"Single sign-on service URL (samlEntryPoint)",value:h.samlEntryPoint,onChange:u("samlEntryPoint"),placeholder:"https://idp.example.com/app/saml/sso/...",disabled:x}),(0,d.jsx)(p.default,{label:"SP entity ID / audience (samlIssuer)",value:h.samlIssuer,onChange:u("samlIssuer"),placeholder:aa,disabled:x}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-text",children:"IdP X.509 certificate (samlCert)"}),(0,d.jsx)(j.default,{type:"button",variant:"ghost",size:"sm",icon:"file_upload",onClick:()=>s.current?.click(),disabled:x,children:"Upload cert"}),(0,d.jsx)("input",{ref:s,type:"file",accept:".crt,.pem,.cer,text/plain",onChange:a=>{let b=a.target.files?.[0];if(s.current&&(s.current.value=""),!b)return;let c=new FileReader;c.onload=a=>{i(b=>({...b,samlCert:String(a.target?.result||"").trim()})),n({type:"ok",message:"Certificate file loaded into configuration."})},c.onerror=()=>n({type:"err",message:"Error reading certificate file"}),c.readAsText(b)},className:"hidden"})]}),(0,d.jsx)(Y.default,{"aria-label":"IdP X.509 certificate (samlCert)",value:h.samlCert,onChange:u("samlCert"),placeholder:"Paste raw Base64 certificate or PEM block",rows:4,disabled:x,textareaClassName:"font-mono text-xs"}),(0,d.jsx)("p",{className:"text-xs text-muted",children:"Paste raw Base64 certificate or PEM block."})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,d.jsx)(p.default,{label:"Login button label",value:h.samlLoginLabel,onChange:u("samlLoginLabel"),placeholder:ab,disabled:x}),(0,d.jsx)(p.default,{label:"Email claim attribute",value:h.samlAttributeEmail,onChange:u("samlAttributeEmail"),placeholder:"email",disabled:x}),(0,d.jsx)(p.default,{label:"Display name claim",value:h.samlAttributeName,onChange:u("samlAttributeName"),placeholder:"name",disabled:x})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-text",children:"ACS callback URL"}),(0,d.jsx)(P.default,{value:c,label:"Copy ACS URL"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-text",children:"SP XML metadata"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"min-w-0 flex-1",children:(0,d.jsx)(P.default,{value:f,label:"Copy metadata URL"})}),(0,d.jsx)(j.default,{type:"button",variant:"secondary",icon:"download",href:f,children:"Download XML"})]})]}),(0,d.jsx)("div",{"aria-live":"polite",children:m.message&&(0,d.jsx)(o.default,{variant:"ok"===m.type?"ok":"err",title:m.message})}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(j.default,{type:"submit",loading:"save"===k,disabled:x,children:"Save SAML settings"}),(0,d.jsx)(j.default,{type:"button",variant:"secondary",onClick:w,loading:"test"===k,disabled:x,children:"Test sign-in"})]})]})}ac.propTypes={settings:l().object.isRequired,authMode:l().oneOf(["password","sso","both"]).isRequired,acsUrl:l().string.isRequired,metadataUrl:l().string.isRequired,onSaved:l().func.isRequired};let ad=[{value:"password",label:"Password only"},{value:"sso",label:"SSO only"},{value:"both",label:"Both"}],ae=[{value:"oidc",label:"OIDC"},{value:"saml",label:"SAML 2.0"}];function af(a){return"saml"===a?"SAML 2.0":"OIDC"}function ag({settings:a,onSettingsChange:b}){var c;let[f,g]=(0,e.useState)("saml"===(c=a.authMode)||"oidc"===c?"sso":"both"===c||"sso"===c?c:"password"),[h,i]=(0,e.useState)("saml"===a.ssoType?"saml":"oidc"),[j,k]=(0,e.useState)(""),l=(0,e.useRef)(0),m=async(a,c,d)=>{let e=++l.current;k("");try{let d=await R({[a]:c});if(l.current!==e)return;b?.(d)}catch(a){if(l.current!==e)return;d(),k(a.message||"Failed to save sign-in method")}},n=a.authMode,p=(0,U.b)({authMode:n,ssoType:a.ssoType}).ssoOnly;return(0,d.jsxs)("div",{id:"sso",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"lock_open",title:"Single sign-on",subtitle:"Sign in with your identity provider."}),(0,d.jsxs)("div",{className:"divide-y divide-line rounded-2xl border border-line bg-panel p-5 shadow-card",children:[(0,d.jsx)(z.default,{label:"Sign-in method",description:"Password only, SSO only, or both.",settingKey:"authMode",control:(0,d.jsx)(A.default,{options:ad,value:f,onChange:a=>{g(a),m("authMode",a,()=>g(f))},"aria-label":"Sign-in method"})}),(0,d.jsx)(z.default,{label:"Protocol",description:"OIDC or SAML 2.0.",settingKey:"ssoType",control:(0,d.jsx)(A.default,{options:ae,value:h,onChange:a=>{i(a),m("ssoType",a,()=>i(h))},"aria-label":"SSO protocol"})}),j&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:j}),(0,d.jsx)("div",{className:"py-4",children:"saml"===h?(0,d.jsx)(ac,{settings:a,authMode:f,acsUrl:"/api/auth/saml/acs",metadataUrl:"/api/auth/saml/metadata",onSaved:a=>b?.(a)},`saml:${a.samlEntryPoint??""}:${a.samlIssuer??""}:${a.samlCert??""}`):(0,d.jsx)(X,{settings:a,authMode:f,redirectUri:"/api/auth/oidc/callback",onSaved:a=>b?.(a)},`oidc:${a.oidcIssuerUrl??""}:${a.oidcClientId??""}:${a.oidcConfigured??""}`)}),p&&(0,d.jsx)(o.default,{variant:"warn",title:`SSO login (${af(a.ssoType)}) is currently active.`,children:"Password login is disabled until you switch back."}),"both"===n&&(0,d.jsx)(o.default,{variant:"warn",title:`Password and SSO login (${af(a.ssoType)}) are both active.`})]})]})}ag.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var ah=c(79735),ai=c.n(ah),aj=c(69814),ak=c(24279),al=c(83035);function am(a={},b,c={}){let d={...a||{}},e={...a?.[b]||{}},{fallbackStrategy:f,stickyRoundRobinLimit:g}=c||{};f?e.fallbackStrategy=f:delete e.fallbackStrategy;let h=""===g||null==g?null:Number(g);return null!=h&&Number.isInteger(h)?e.stickyRoundRobinLimit=h:delete e.stickyRoundRobinLimit,0===Object.keys(e).length?delete d[b]:d[b]=e,d}let an=[{value:"fill-first",label:"Fill first"},{value:"round-robin",label:"Round robin"},{value:"weighted",label:"Weighted"}];function ao(a){if(!a||"object"!=typeof a)return"";let b="string"==typeof a.name?a.name.trim():"";return b&&b!==a.id?b:"string"==typeof a.displayName&&a.displayName.trim()?a.displayName.trim():a.id||""}function ap({overrides:a,onOverridesChange:b}){let[c,f]=(0,e.useState)([]),[g,h]=(0,e.useState)(""),[i,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(!1),[p,r]=(0,e.useState)(""),[s,t]=(0,e.useState)("round-robin"),[u,v]=(0,e.useState)(1),[w,x]=(0,e.useState)(""),y=(0,e.useMemo)(()=>{let b=c.map(a=>({value:a.id,label:ao(a)===a.id?a.id:`${ao(a)} (${a.id})`})),d=new Set(b.map(a=>a.value));for(let c of Object.keys(a))d.has(c)||b.push({value:c,label:c});return b.sort((a,b)=>a.value.localeCompare(b.value))},[c,a]),z=async c=>{k(!0),m("");try{let a=await fetch("/api/settings",{cache:"no-store"});if(!a.ok)throw Error("Could not load current overrides.");let d=await a.json(),e=d.providerStrategies&&"object"==typeof d.providerStrategies?d.providerStrategies:{},f=c(e);b?.(f);let g=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:f})}),h=await g.json().catch(()=>({}));if(!g.ok)throw Error(h.error||"Could not save overrides.");b?.(h.providerStrategies??f)}catch(c){b?.(a),m(c instanceof Error?c.message:"Could not save overrides.")}finally{k(!1)}},A=(b,c,d)=>{let e=a[b]||{};z(a=>am(a,b,"strategy"===c?{fallbackStrategy:d||"",stickyRoundRobinLimit:e.stickyRoundRobinLimit??""}:{fallbackStrategy:e.fallbackStrategy||"",stickyRoundRobinLimit:""===d?"":Number(d)}))};return(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-x-6 gap-y-3",children:[(0,d.jsxs)("div",{className:"min-w-52 flex-1",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Per-provider overrides"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Beat the global strategy for one provider."}),(0,d.jsx)("p",{className:"mt-0.5 font-mono text-[11px] text-subtle",children:"providerStrategies"})]}),(0,d.jsx)(j.default,{variant:"secondary",size:"sm",icon:"add",onClick:()=>{r(""),t("round-robin"),v(1),x(""),o(!0)},children:"Add"})]}),g&&(0,d.jsx)("p",{className:"pt-2 text-xs text-err",role:"alert",children:g}),l&&(0,d.jsx)("p",{className:"pt-2 text-xs text-err",role:"alert",children:l}),(0,d.jsx)("div",{className:"pt-3",children:0===Object.keys(a).length?(0,d.jsx)("p",{className:"text-sm text-muted",children:"No overrides yet. Every provider follows the global strategy above."}):(0,d.jsx)("ul",{className:"divide-y divide-line overflow-hidden rounded-xl border border-line",children:Object.keys(a).sort().map(b=>{let c=a[b]||{},e=y.find(a=>a.value===b)?.label||b;return(0,d.jsxs)("li",{className:"flex flex-wrap items-center gap-3 p-3",children:[(0,d.jsx)(al.default,{providerId:b,size:"md"}),(0,d.jsxs)("div",{className:"min-w-40 flex-1",children:[(0,d.jsx)("p",{className:"text-sm font-semibold text-text",children:e}),(0,d.jsx)("p",{className:"font-mono text-[11px] text-subtle",children:b})]}),(0,d.jsx)(B.default,{label:"Override strategy",value:c.fallbackStrategy||"",onChange:a=>A(b,"strategy",a.target.value),options:an,placeholder:"Inherit global",disabled:i,className:"w-44"}),(0,d.jsx)(aj.default,{label:"Override sticky",value:c.stickyRoundRobinLimit??"",onChange:a=>A(b,"sticky",a),min:1,max:100,disabled:i,"aria-label":`Sticky limit for ${b}`,className:"w-40"}),(0,d.jsx)(j.default,{variant:"ghost",size:"sm",icon:"delete",onClick:()=>{z(a=>(function(a={},b){let c={...a||{}},d={...a?.[b]||{}};return delete d.fallbackStrategy,delete d.stickyRoundRobinLimit,0===Object.keys(d).length?delete c[b]:c[b]=d,c})(a,b))},disabled:i,"aria-label":`Remove override for ${b}`,children:"Remove"})]},b)})})}),(0,d.jsx)(q.default,{isOpen:n,onClose:()=>o(!1),title:"Add provider override",description:"Beat the global strategy for one provider.",footer:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.default,{variant:"ghost",onClick:()=>o(!1),children:"Cancel"}),(0,d.jsx)(j.default,{onClick:()=>{p?Object.hasOwn(a,p)?x("That provider already has an override — edit it instead."):(o(!1),z(a=>am(a,p,{fallbackStrategy:s,stickyRoundRobinLimit:u}))):x("Pick a provider.")},disabled:!p||i,children:"Add override"})]}),children:(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)(B.default,{label:"Provider",value:p,onChange:a=>r(a.target.value),options:y.filter(b=>!Object.hasOwn(a,b.value)),placeholder:0===c.length?"No providers found":"Pick a provider",error:w}),(0,d.jsx)(B.default,{label:"Strategy",value:s,onChange:a=>t(a.target.value),options:an}),(0,d.jsx)(aj.default,{label:"Sticky limit",value:u,onChange:a=>v(Number(a)||1),min:1,max:100,hint:"Calls per account before rotating."})]})})]})}ap.propTypes={overrides:l().object.isRequired,onOverridesChange:l().func};let aq=[{value:"fill-first",label:"Fill first"},{value:"round-robin",label:"Round robin"},{value:"weighted",label:"Weighted"}],ar=new Set(["fallback","round-robin","fusion","weighted"]);function as({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),e=I("fallbackStrategy",a.fallbackStrategy??"fill-first",{onSaved:c("fallbackStrategy")}),f=I("stickyRoundRobinLimit",a.stickyRoundRobinLimit??3,{onSaved:c("stickyRoundRobinLimit")}),g=I("comboStrategy",a.comboStrategy??"fallback",{onSaved:c("comboStrategy")}),h=I("comboStickyRoundRobinLimit",a.comboStickyRoundRobinLimit??1,{onSaved:c("comboStickyRoundRobinLimit")}),i=a.providerStrategies&&"object"==typeof a.providerStrategies?a.providerStrategies:{},j=ar.has(g.value),k="round-robin"===g.value,l="round-robin"===e.value||"weighted"===e.value,m="weighted"===e.value&&1===Number(f.value),n=a.capacityAdapter&&"object"==typeof a.capacityAdapter?a.capacityAdapter:{},p=["vision","pdf","audioInput","videoInput"].map(a=>{let b=n[a];return{cap:a,label:"vision"===a?"Vision":"audioInput"===a?"Audio":"pdf"===a?"PDF":"Video",enabled:b&&"object"==typeof b?!1!==b.enabled:!!b}}),q=function(a={}){let b,c,d=a?.fallbackStrategy??"fill-first",e=a?.stickyRoundRobinLimit??3,f=a?.comboStrategy??"fallback",g=a?.comboStickyRoundRobinLimit??1,h=a?.providerStrategies??{},i=h&&"object"==typeof h?Object.keys(h).length:0;b="round-robin"===d?`Each provider rotates through its accounts in turn, staying ${e} request(s) on one account before moving on.`:"weighted"===d?`Each provider sends requests to accounts with the most remaining quota, staying ${e} request(s) on one account before reconsidering.`:"Right now: each provider uses its accounts in priority order and moves on only when one fails or runs dry.",c="round-robin"===f?`Combos rotate through their models, staying ${g} request(s) per model.`:"fusion"===f?"Combos fuse answers from several models (managed per combo on the Combos page).":"weighted"===f?"Combos weight models by quota (managed per combo on the Combos page).":"Combos try models in order.";let j=0===i?"":1===i?" 1 provider override beats the global strategy.":` ${i} provider overrides beat the global strategy.`;return`${b} ${c}${j}`}({fallbackStrategy:e.value,stickyRoundRobinLimit:f.value,comboStrategy:g.value,comboStickyRoundRobinLimit:h.value,providerStrategies:i});return(0,d.jsxs)("div",{id:"routing",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"route",title:"Routing",subtitle:"How accounts and combos take turns."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsxs)("div",{className:"py-4 first:pt-0",children:[(0,d.jsx)(z.default,{label:"Account strategy",description:"Picks between accounts of the same provider.",settingKey:"fallbackStrategy",control:(0,d.jsx)(A.default,{options:aq,value:e.value,onChange:a=>e.set(a),"aria-label":"Account strategy"})}),e.error&&(0,d.jsx)("p",{className:"py-1 text-xs text-err",role:"alert",children:e.error})]}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)(z.default,{label:"Sticky limit",description:"Calls per account before rotating. Round robin and weighted only.",settingKey:"stickyRoundRobinLimit",control:(0,d.jsx)(aj.default,{value:f.value??3,onChange:a=>f.set(a),min:1,max:100,disabled:!l||f.saving,error:f.error,"aria-label":"Sticky limit"})}),m&&(0,d.jsx)(o.default,{variant:"warn",title:"Sticky 1 with weighted routing",children:"Every request may land on a different subscription account, which can trip anti-abuse flags. Prefer 3 or higher."})]}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)(z.default,{label:"Combo round robin",description:j?"Rotate inside combos by default instead of falling back in order.":`This combo strategy is managed per combo: “${g.value}” is not one of the global options, so the toggle is shown off without changing it.`,settingKey:"comboStrategy",control:(0,d.jsx)(O.default,{checked:k,onChange:a=>g.set(a?"round-robin":"fallback"),"aria-label":"Combo round robin"})}),g.error&&(0,d.jsx)("p",{className:"py-1 text-xs text-err",role:"alert",children:g.error})]}),(0,d.jsx)("div",{className:"py-4",children:(0,d.jsx)(z.default,{label:"Combo sticky limit",description:"Calls per combo model before rotating.",settingKey:"comboStickyRoundRobinLimit",control:(0,d.jsx)(aj.default,{value:h.value??1,onChange:a=>h.set(a),min:1,max:100,disabled:!k||h.saving,error:h.error,"aria-label":"Combo sticky limit"})})}),(0,d.jsx)("div",{className:"py-4",children:(0,d.jsx)(o.default,{variant:"info",children:q})}),(0,d.jsx)("div",{className:"py-4",children:(0,d.jsx)(ap,{overrides:i,onOverridesChange:a=>b?.({providerStrategies:a})})}),(0,d.jsx)("div",{className:"py-4 last:pb-0",children:(0,d.jsx)(z.default,{label:"Capability adapter",description:(0,d.jsxs)("span",{children:["Images or audio go to a capable model when the chosen one can’t read them."," ",(0,d.jsx)(ai(),{href:"/dashboard/combos",className:"underline",children:"Edit in Combos"})]}),settingKey:"capacityAdapter",control:(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:p.map(({cap:a,label:b,enabled:c})=>(0,d.jsxs)(ak.default,{variant:c?"ok":"neutral",size:"sm",dot:!0,children:[b," ",c?"on":"off"]},a))})})})]})]})}as.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var at=c(3090);let au={retryPolicy:{502:{tries:3,delayMs:3e3},503:{tries:3,delayMs:2e3},504:{tries:2,delayMs:3e3}},cooldowns:{rateLimitCapMs:18e5,longMs:12e4,shortMs:5e3,transientMs:3e4},backoff:{startMs:2e3,maxMs:3e5,levels:15},streamTimeouts:{firstChunkMs:2e5,stallMs:36e4,connectMs:6e4}},av=[{status:"502",label:"bad gateway"},{status:"503",label:"unavailable"},{status:"504",label:"timeout"}],aw=["retryPolicy","cooldowns","backoff","streamTimeouts"],ax=[{key:"rateLimitCapMs",label:"Rate-limit cap"},{key:"transientMs",label:"Transient error"},{key:"longMs",label:"Long"},{key:"shortMs",label:"Short"}],ay=[{key:"firstChunkMs",label:"First chunk",envVar:"STREAM_FIRST_CHUNK_TIMEOUT_MS"},{key:"stallMs",label:"Stall",envVar:"STREAM_STALL_TIMEOUT_MS"},{key:"connectMs",label:"Connect",envVar:"FETCH_CONNECT_TIMEOUT_MS"}];function az(a){if(!Number.isFinite(a))return"—";if(a<1e3)return`${a}ms`;let b=a/1e3;if(b<60)return`${b}s`;let c=b/60;if(c<60)return`${Number.isInteger(c)?c:c.toFixed(1)}min`;let d=c/60;return`${Number.isInteger(d)?d:d.toFixed(1)}h`}async function aA(){let a={};for(let b of aw)a[b]=au[b];let b=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),c=await b.json().catch(()=>({}));if(!b.ok)throw Error(c.error||"Failed to save setting");return c}function aB({error:a}){return a?(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:a}):null}aB.propTypes={error:l().string};let aC=a=>{if(""===a)return;let b=Number(a);return Number.isFinite(b)?b:void 0};function aD({title:a,description:b,children:c,error:e}){return(0,d.jsxs)("div",{className:"py-4 first:pt-0",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:a}),b&&(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:b}),(0,d.jsx)("div",{className:"mt-3",children:c}),(0,d.jsx)(aB,{error:e})]})}function aE({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),f=I("retryPolicy",a.retryPolicy??au.retryPolicy,{debounced:!0,onSaved:c("retryPolicy")}),g=I("cooldowns",a.cooldowns??au.cooldowns,{debounced:!0,onSaved:c("cooldowns")}),h=I("backoff",a.backoff??au.backoff,{debounced:!0,onSaved:c("backoff")}),i=I("streamTimeouts",a.streamTimeouts??au.streamTimeouts,{debounced:!0,onSaved:c("streamTimeouts")}),k=a.streamEnvOverrides??{},[l,m]=(0,e.useState)(!1),o=(a,b,c)=>{void 0!==c&&a.set(function(a,b,c){let d={...a&&"object"==typeof a?a:{}},e=d;for(let a=0;a<b.length-1;a+=1){let c=b[a];e[c]={...e[c]&&"object"==typeof e[c]?e[c]:{}},e=e[c]}return e[b[b.length-1]]=c,d}(a.value,b,c))},[p,r]=(0,e.useState)(""),s=async()=>{r("");try{let a=await aA();for(let c of aw)b?.({[c]:a[c]??au[c]});m(!1)}catch(a){throw r(a.message),a}};return(0,d.jsxs)("div",{id:"reliability",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"restart_alt",title:(0,d.jsxs)("span",{className:"inline-flex items-center gap-2",children:["Reliability",(0,d.jsx)(n.default,{variant:"live",size:"sm",children:"New"})]}),subtitle:"Retries, cooldowns and timeouts. Changes apply to the next request, no restart."}),(0,d.jsxs)("div",{className:"divide-y divide-line rounded-2xl border border-line bg-panel p-5 shadow-card",children:[(0,d.jsx)(aD,{title:"Retries on upstream errors",description:"429s never retry. They cool the account down and fall back.",error:f.error,children:(0,d.jsxs)("div",{className:"overflow-hidden rounded-xl border border-line text-[13px]",children:[(0,d.jsxs)("div",{"aria-hidden":"true",className:"hidden grid-cols-[minmax(0,1.4fr)_minmax(11rem,1fr)_minmax(0,1fr)] gap-2 bg-raised px-3 py-2 text-xs font-semibold text-muted min-[420px]:grid",children:[(0,d.jsx)("span",{children:"Status"}),(0,d.jsx)("span",{children:"Tries"}),(0,d.jsx)("span",{children:"Delay"})]}),av.map(({status:a,label:b})=>(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 border-t border-line px-3 py-3 first:border-t-0 min-[420px]:grid-cols-[minmax(0,1.4fr)_minmax(11rem,1fr)_minmax(0,1fr)] min-[420px]:items-center min-[420px]:gap-2 min-[420px]:py-2",children:[(0,d.jsxs)("p",{className:"font-normal",children:[(0,d.jsx)("span",{className:"font-mono",children:a})," ",(0,d.jsx)("span",{className:"text-muted",children:b})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-12 text-xs font-semibold text-muted min-[420px]:hidden",children:"Tries"}),(0,d.jsx)(aj.default,{value:f.value?.[a]?.tries??au.retryPolicy[a].tries,onChange:b=>o(f,[a,"tries"],b),min:0,max:10,"aria-label":`${a} tries`})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-12 text-xs font-semibold text-muted min-[420px]:hidden",children:"Delay"}),(0,d.jsx)("div",{className:"min-w-0 flex-1",children:(0,d.jsx)(at.default,{value:f.value?.[a]?.delayMs??au.retryPolicy[a].delayMs,onChange:b=>o(f,[a,"delayMs"],aC(b.target.value)),unit:"ms",min:0,max:6e4,"aria-label":`${a} delay in milliseconds`})})]})]},a))]})}),(0,d.jsx)(aD,{title:"Cooldowns",description:"How long an account sits out after it fails.",error:g.error,children:(0,d.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:ax.map(({key:a,label:b})=>(0,d.jsx)(at.default,{label:b,value:g.value?.[a]??au.cooldowns[a],onChange:b=>o(g,[a],aC(b.target.value)),unit:"ms",hint:`Default ${az(au.cooldowns[a])}`},a))})}),(0,d.jsx)(aD,{title:"Backoff",description:"Grows with each repeated failure.",error:h.error,children:(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,d.jsx)(at.default,{label:"Start",value:h.value?.startMs??au.backoff.startMs,onChange:a=>o(h,["startMs"],aC(a.target.value)),unit:"ms",hint:`Default ${az(au.backoff.startMs)}`}),(0,d.jsx)(at.default,{label:"Max",value:h.value?.maxMs??au.backoff.maxMs,onChange:a=>o(h,["maxMs"],aC(a.target.value)),unit:"ms",hint:`Default ${az(au.backoff.maxMs)}`}),(0,d.jsx)(aj.default,{label:"Levels",value:h.value?.levels??au.backoff.levels,onChange:a=>o(h,["levels"],a),min:1,max:30,hint:`Default ${au.backoff.levels}`})]})}),(0,d.jsx)(aD,{title:"Stream timeouts",description:"When to give up on a slow or stalled upstream. Env vars win over this setting.",error:i.error,children:(0,d.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:ay.map(({key:a,label:b,envVar:c})=>{let e=!0===k[a];return(0,d.jsx)(at.default,{label:(0,d.jsxs)("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[b,e&&(0,d.jsx)(n.default,{variant:"neutral",size:"sm",children:".env overrides"})]}),value:i.value?.[a]??au.streamTimeouts[a],onChange:b=>o(i,[a],aC(b.target.value)),unit:"ms",disabled:e,hint:e?`Set by ${c} in .env. Read-only here.`:`Default ${az(au.streamTimeouts[a])}`},a)})})}),(0,d.jsx)("div",{className:"pt-4",children:(0,d.jsx)(j.default,{variant:"secondary",icon:"restart_alt",onClick:()=>m(!0),children:"Restore defaults"})})]}),(0,d.jsx)(q.ConfirmDialog,{isOpen:l,onClose:()=>{m(!1),r("")},onConfirm:s,title:"Restore reliability defaults?",message:"Retries, cooldowns, backoff and stream timeouts go back to the built-in values.",confirmText:"Restore defaults",error:p||void 0,variant:"primary"})]})}function aF(a){return a?a.enabled?{label:"Connected",variant:"ok"}:a.settingsEnabled?{label:"Starting",variant:"warn"}:{label:"Off",variant:"neutral"}:{label:"Checking",variant:"neutral"}}async function aG(){let a=await fetch("/api/tunnel/status",{cache:"no-store"});if(!a.ok)throw Error(`HTTP ${a.status}`);let b=await a.json();return{tunnel:b.tunnel??null,tailscale:b.tailscale??null}}function aH({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),f=I("outboundProxyEnabled",!0===a.outboundProxyEnabled,{onSaved:c("outboundProxyEnabled")}),g=I("outboundProxyUrl",a.outboundProxyUrl??"",{debounced:!0,onSaved:c("outboundProxyUrl")}),h=I("outboundNoProxy",a.outboundNoProxy??"",{debounced:!0,onSaved:c("outboundNoProxy")}),[i,k]=(0,e.useState)({type:"",message:""}),[l,n]=(0,e.useState)(!1),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)({tunnel:null,tailscale:null}),[u,v]=(0,e.useState)(!0),[w,x]=(0,e.useState)(""),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(null),[G,H]=(0,e.useState)(null),[J,K]=(0,e.useState)(""),L=(0,e.useCallback)(async()=>{v(!0),x("");try{t(await aG())}catch{x("Could not load tunnel status")}finally{v(!1)}},[]),M=async()=>{n(!0),k({type:"",message:""});try{let a=await fetch("/api/settings/proxy-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyUrl:g.value})}),b=await a.json().catch(()=>({}));if(a.ok&&!1!==b.ok){let a="number"==typeof b.elapsedMs?` \xb7 ${b.elapsedMs}ms`:"";k({type:"ok",message:`Reachable${a}`})}else k({type:"err",message:b.error||"Proxy test failed"})}catch{k({type:"err",message:"Proxy test failed"})}finally{n(!1)}},N=async()=>{r(!0),k({type:"",message:""});try{let a=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({outboundProxyEnabled:f.value,outboundProxyUrl:g.value,outboundNoProxy:h.value})}),c=await a.json().catch(()=>({}));if(!a.ok)throw Error(c.error||"Failed to apply proxy settings");b?.({outboundProxyEnabled:c.outboundProxyEnabled,outboundProxyUrl:c.outboundProxyUrl,outboundNoProxy:c.outboundNoProxy}),k({type:"ok",message:"Proxy settings applied"})}catch(a){k({type:"err",message:a.message||"Failed to apply proxy settings"})}finally{r(!1)}},P=async a=>{K(""),B(!0),F(a);try{let c=await fetch(a?"/api/tunnel/enable":"/api/tunnel/disable",{method:"POST"}),d=await c.json().catch(()=>({}));if(!c.ok)throw Error(d.error||"Failed to update tunnel");b?.({tunnelEnabled:a}),await L()}catch(a){K(a.message||"Failed to update tunnel")}finally{B(!1),F(null)}},Q=async a=>{K(""),D(!0),H(a);try{let c=await fetch(a?"/api/tunnel/tailscale-enable":"/api/tunnel/tailscale-disable",{method:"POST"}),d=await c.json().catch(()=>({}));if(!c.ok)throw Error(d.error||"Failed to update Tailscale");b?.({tailscaleEnabled:a}),await L()}catch(a){K(a.message||"Failed to update Tailscale")}finally{D(!1),H(null)}},R=aF(s.tunnel),S=aF(s.tailscale),T=E??s.tunnel?.settingsEnabled===!0,U=G??s.tailscale?.settingsEnabled===!0,V=function({requireLogin:a,hasPassword:b,requireApiKey:c}){return a?b?c?"":'Enable "Require API key" before activating the tunnel.':"Change the default dashboard password before activating the tunnel.":'Enable "Require login" and set a custom password before activating the tunnel.'}({requireLogin:!1!==a.requireLogin,hasPassword:!0===a.hasPassword,requireApiKey:!0===a.requireApiKey}),W=function({requireLogin:a,hasPassword:b}){return a?b?"":"Change the default dashboard password before activating Tailscale.":'Enable "Require login" and set a custom password before activating Tailscale.'}({requireLogin:!1!==a.requireLogin,hasPassword:!0===a.hasPassword}),X=g.error||h.error||f.error;return(0,d.jsxs)("div",{id:"network",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"public",title:"Network",subtitle:`How ${m.Hc.slug} reaches providers, and how you reach it.`}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Outbound proxy",description:"Send OAuth and provider calls through a proxy. Applies without restart.",settingKey:"outboundProxyEnabled",control:(0,d.jsx)(O.default,{checked:f.value,onChange:a=>f.set(a),disabled:f.saving,"aria-label":"Outbound proxy"})}),(0,d.jsxs)("div",{className:"py-4 space-y-3",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,d.jsx)(p.default,{label:"Proxy URL",value:g.value??"",onChange:a=>g.set(a.target.value),placeholder:"http://127.0.0.1:7897",inputClassName:"font-mono"}),(0,d.jsx)(p.default,{label:"Skip for",value:h.value??"",onChange:a=>h.set(a.target.value),placeholder:"localhost, .internal",inputClassName:"font-mono"})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)(j.default,{variant:"secondary",size:"sm",onClick:M,loading:l,disabled:!g.value?.trim?.(),children:"Test proxy"}),(0,d.jsx)(j.default,{size:"sm",onClick:N,loading:q,children:"Apply"}),i.message&&(0,d.jsx)(ak.default,{variant:"ok"===i.type?"ok":"err",size:"sm",dot:!0,children:i.message})]}),X&&(0,d.jsx)("p",{className:"text-xs text-err",role:"alert",children:X}),(0,d.jsx)("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:i.message||X})]}),(0,d.jsx)(z.default,{label:"Cloudflare tunnel",description:u?"Checking status…":s.tunnel?.publicUrl||s.tunnel?.tunnelUrl?`Public HTTPS URL: ${s.tunnel.publicUrl||s.tunnel.tunnelUrl}`:"Public HTTPS URL. Needs Require API key.",settingKey:"tunnelEnabled",control:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[!u&&!w&&(0,d.jsx)(ak.default,{variant:A?"info":R.variant,size:"sm",dot:!0,children:A?E?"Starting…":"Stopping…":R.label}),(0,d.jsx)(O.default,{checked:T,onChange:P,disabled:A||u||!!(V&&!T),title:V&&!T?V:void 0,"aria-label":"Cloudflare tunnel"})]})}),V&&!T&&(0,d.jsx)("p",{className:"py-2 text-xs text-muted",children:V}),(0,d.jsx)(z.default,{label:"Tailscale",description:u?"Checking status…":s.tailscale?.tunnelUrl||"Private mesh access.",settingKey:"tailscaleEnabled",control:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[!u&&!w&&(0,d.jsx)(ak.default,{variant:C?"info":S.variant,size:"sm",dot:!0,children:C?G?"Starting…":"Stopping…":S.label}),(0,d.jsx)(O.default,{checked:U,onChange:Q,disabled:C||u||!!(W&&!U),title:W&&!U?W:void 0,"aria-label":"Tailscale"})]})}),W&&!U&&(0,d.jsx)("p",{className:"py-2 text-xs text-muted",children:W}),(w||J)&&(0,d.jsx)(o.default,{variant:"err",title:J||w,children:!J&&(0,d.jsx)(j.default,{variant:"ghost",size:"sm",onClick:L,children:"Retry"})}),(0,d.jsx)(z.default,{label:"Tunnel provider",description:"Active tunnel backend.",settingKey:"tunnelProvider",control:(0,d.jsx)("span",{className:"font-mono text-[13px] text-muted",children:"string"==typeof a.tunnelProvider&&a.tunnelProvider?a.tunnelProvider:"cloudflare"})}),(0,d.jsx)(z.default,{label:"Web search backend",description:"SearXNG instance used by web search. Set SEARXNG_URL in .env and restart to change.",settingKey:"SEARXNG_URL",control:(0,d.jsx)("span",{className:"font-mono text-[13px] text-muted",children:"string"==typeof a.searxngUrl&&a.searxngUrl?a.searxngUrl:"not set (default http://localhost:8888/search)"})}),(0,d.jsx)("div",{className:"pt-4",children:(0,d.jsx)(j.default,{variant:"ghost",size:"sm",href:"/dashboard/proxy-pools",iconRight:"arrow_forward",children:"Per-connection proxies and relays live in Proxy pools"})})]})]})}aD.propTypes={title:l().node.isRequired,description:l().node,children:l().node,error:l().string},aE.propTypes={settings:l().object.isRequired,onSettingsChange:l().func},aH.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var aI=c(67960),aJ=c(99258);let aK=Object.freeze({rtkEnabled:!0,headroomEnabled:!1,headroomUrl:"http://localhost:8787",headroomTimeoutMs:3e3,headroomCompressUserMessages:!1,cavemanEnabled:!1,cavemanLevel:"full",ponytailEnabled:!1,ponytailLevel:"full",pxpipeEnabled:!1,pxpipeMinChars:25e3,pxpipeTimeoutMs:15e3,pxpipeAutoInstall:!0});function aL(a){return aI.hT.includes(a)}function aM(a,b){let c=aI.ev.find(a=>a.id===b);return c?c.wenyan&&!aL(a)?"ultra":b:aK.cavemanLevel}function aN(a){return aI.Nv.some(b=>b.id===a)?a:aK.ponytailLevel}function aO({error:a}){return a?(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:a}):null}function aP({settings:a,onSettingsChange:b}){var c;let f=a=>c=>b?.({[a]:c}),g=I("rtkEnabled",a.rtkEnabled??!0,{onSaved:f("rtkEnabled")}),h=I("headroomEnabled",a.headroomEnabled??!1,{onSaved:f("headroomEnabled")}),i=I("headroomUrl",a.headroomUrl??aK.headroomUrl,{debounced:!0,onSaved:f("headroomUrl")}),j=I("headroomTimeoutMs",a.headroomTimeoutMs??aK.headroomTimeoutMs,{onSaved:f("headroomTimeoutMs")}),k=I("headroomCompressUserMessages",a.headroomCompressUserMessages??!1,{onSaved:f("headroomCompressUserMessages")}),l=I("cavemanEnabled",a.cavemanEnabled??!1,{onSaved:f("cavemanEnabled")}),m=I("cavemanLevel",aM((0,aJ.kk)(),a.cavemanLevel??"full"),{onSaved:f("cavemanLevel")}),o=I("ponytailEnabled",a.ponytailEnabled??!1,{onSaved:f("ponytailEnabled")}),q=I("ponytailLevel",aN(a.ponytailLevel??"full"),{onSaved:f("ponytailLevel")}),r=I("pxpipeEnabled",a.pxpipeEnabled??!1,{onSaved:f("pxpipeEnabled")}),s=I("pxpipeMinChars",a.pxpipeMinChars??aK.pxpipeMinChars,{onSaved:f("pxpipeMinChars")}),t=I("pxpipeTimeoutMs",a.pxpipeTimeoutMs??aK.pxpipeTimeoutMs,{onSaved:f("pxpipeTimeoutMs")}),u=I("pxpipeAutoInstall",a.pxpipeAutoInstall??!0,{onSaved:f("pxpipeAutoInstall")}),[v,w]=(0,e.useState)("en"),x=aL(v)?aI.ev:aI.ev.filter(a=>!a.wenyan),B=aM(v,m.value??"full"),C=!h.value,D=!l.value,E=!o.value,F=!r.value,G=a?.headroomUrlFromEnv===!0;return(0,d.jsxs)("div",{id:"token-saver",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"bolt",title:"Token saver",subtitle:"Compress tool output, context and replies. Same store as the Token saver page."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Compress tool output",description:"git/grep/ls/tree/logs → 60-90% fewer input tokens (RTK).",settingKey:"rtkEnabled",control:(0,d.jsx)(O.default,{checked:!0===g.value,onChange:a=>g.set(a),disabled:g.saving,"aria-label":"Compress tool output"})}),(0,d.jsx)(aO,{error:g.error}),(0,d.jsx)(z.default,{label:"Compress context",description:"Compress prompts via Headroom before routing to the model.",settingKey:"headroomEnabled",control:(0,d.jsx)(O.default,{checked:!0===h.value,onChange:a=>h.set(a),disabled:h.saving,"aria-label":"Compress context"})}),(0,d.jsx)(aO,{error:h.error}),(0,d.jsx)(z.default,{label:"Headroom URL",description:G?(0,d.jsxs)(d.Fragment,{children:["Set by ",(0,d.jsx)("code",{className:"font-mono",children:"HEADROOM_URL"})," in .env — the env wins, this field is read-only."]}):"Local proxy for Start/Stop, or an external sidecar.",settingKey:"headroomUrl",control:(0,d.jsxs)("div",{className:"w-full sm:min-w-72 sm:max-w-sm",children:[(0,d.jsx)(p.default,{value:i.value??"",onChange:a=>i.set(a.target.value),disabled:C||i.saving||G,placeholder:"http://localhost:8787",inputClassName:"font-mono","aria-label":"Headroom URL"}),G&&(0,d.jsx)("div",{className:"mt-1.5",children:(0,d.jsx)(n.default,{variant:"info",size:"sm",icon:"lock",children:".env"})})]})}),(0,d.jsx)(aO,{error:i.error}),(0,d.jsx)(z.default,{label:"Headroom timeout",description:"Request timeout, in milliseconds.",settingKey:"headroomTimeoutMs",control:(0,d.jsx)("div",{className:"w-48",children:(0,d.jsx)(aj.default,{label:"Headroom timeout",value:j.value,onChange:a=>j.set(a),min:1,disabled:C||j.saving})})}),(0,d.jsx)(aO,{error:j.error}),(0,d.jsx)(z.default,{label:"Compress user messages",description:"Also compress user turns, not just tool output.",settingKey:"headroomCompressUserMessages",control:(0,d.jsx)(O.default,{checked:!0===k.value,onChange:a=>k.set(a),disabled:C||k.saving,"aria-label":"Compress user messages"})}),(0,d.jsx)(aO,{error:k.error}),(0,d.jsx)(z.default,{label:"Compress LLM output",description:"Terse-style system prompt → ~65% fewer output tokens (Caveman).",settingKey:"cavemanEnabled",control:(0,d.jsx)(O.default,{checked:!0===l.value,onChange:a=>l.set(a),disabled:l.saving,"aria-label":"Compress LLM output"})}),(0,d.jsx)(aO,{error:l.error}),(0,d.jsx)(z.default,{label:"Caveman level",description:aI.ev.find(a=>a.id===B)?.desc??"",settingKey:"cavemanLevel",control:(0,d.jsx)("fieldset",{disabled:D||m.saving,children:(0,d.jsx)(A.default,{options:x.map(a=>({value:a.id,label:a.label})),value:B,onChange:a=>m.set(a),"aria-label":"Caveman level"})})}),(0,d.jsx)(aO,{error:m.error}),(0,d.jsx)(z.default,{label:"Lazy senior dev",description:"Bias the model toward minimal code: YAGNI, reuse stdlib (Ponytail).",settingKey:"ponytailEnabled",control:(0,d.jsx)(O.default,{checked:!0===o.value,onChange:a=>o.set(a),disabled:o.saving,"aria-label":"Lazy senior dev"})}),(0,d.jsx)(aO,{error:o.error}),(0,d.jsx)(z.default,{label:"Ponytail level",description:(c=q.value,aI.Nv.find(a=>a.id===c)?.desc??""),settingKey:"ponytailLevel",control:(0,d.jsx)("fieldset",{disabled:E||q.saving,children:(0,d.jsx)(A.default,{options:aI.Nv.map(a=>({value:a.id,label:a.label})),value:aN(q.value),onChange:a=>q.set(a),"aria-label":"Ponytail level"})})}),(0,d.jsx)(aO,{error:q.error}),(0,d.jsx)(z.default,{label:(0,d.jsxs)("span",{className:"inline-flex items-center gap-2",children:["Prompts as images",(0,d.jsx)(n.default,{variant:"info",size:"sm",icon:"science",children:"Experimental"})]}),description:"Large context becomes optimized images before the LLM (PXPIPE).",settingKey:"pxpipeEnabled",control:(0,d.jsx)(O.default,{checked:!0===r.value,onChange:a=>r.set(a),disabled:r.saving,"aria-label":"Prompts as images"})}),(0,d.jsx)(aO,{error:r.error}),(0,d.jsx)(z.default,{label:"Minimum prompt size",description:"Requests smaller than this bypass PXPIPE as-is (chars).",settingKey:"pxpipeMinChars",control:(0,d.jsx)("div",{className:"w-48",children:(0,d.jsx)(aj.default,{label:"Minimum prompt size",value:s.value,onChange:a=>s.set(a),min:0,disabled:F||s.saving})})}),(0,d.jsx)(aO,{error:s.error}),(0,d.jsx)(z.default,{label:"PXPIPE timeout",description:"Request timeout, in milliseconds.",settingKey:"pxpipeTimeoutMs",control:(0,d.jsx)("div",{className:"w-48",children:(0,d.jsx)(aj.default,{label:"PXPIPE timeout",value:t.value,onChange:a=>t.set(a),min:1,disabled:F||t.saving})})}),(0,d.jsx)(aO,{error:t.error}),(0,d.jsx)(z.default,{label:"Auto-install PXPIPE",description:"Install the proxy package on first use when missing.",settingKey:"pxpipeAutoInstall",control:(0,d.jsx)(O.default,{checked:!0===u.value,onChange:a=>u.set(a),disabled:F||u.saving,"aria-label":"Auto-install PXPIPE"})}),(0,d.jsx)(aO,{error:u.error})]})]})}aO.propTypes={error:l().string},aP.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var aQ=c(91431),aR=c(83919);function aS(a={},b,c,d){let e=String(c||"").trim();if(!b||!e)throw Error("Provider and quota key are required");if(e.length>256)throw Error("Quota key too long");let f={...a?.[b]??{}},g=new Set(f.hidden??[]);if(d){if(g.add(e),g.size>1e3)throw Error("Too many hidden quota keys")}else g.delete(e);let h={...a||{}};return 0===g.size&&Object.keys(f).length<=1?delete h[b]:h[b]={...f,hidden:[...g]},h}function aT(a){let b=a?.connections;return!b||"object"!=typeof b||Array.isArray(b)?{}:Object.fromEntries(Object.entries(b).filter(([,a])=>"boolean"==typeof a))}function aU({providerId:a,label:b,settingKey:c,settings:f,onSettingsChange:g}){let[h,i]=(0,e.useState)(null),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)({}),o=(0,e.useCallback)(async()=>{l("");try{let b=await fetch("/api/providers",{cache:"no-store"});if(!b.ok)throw Error(`HTTP ${b.status}`);let c=await b.json();i((c.connections||[]).filter(b=>b.provider===a))}catch{l("Could not load connections"),i([])}},[a]),p=aT(f[c]),q=(0,e.useCallback)(async(a,b)=>{n(b=>({...b,[a]:!0}));try{let d=await fetch("/api/settings",{cache:"no-store"}),e=d.ok?await d.json():{},f=aT(e[c]),h={...e[c]||{},connections:{...f,[a]:b}},i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[c]:h})}),j=await i.json().catch(()=>({}));if(!i.ok)throw Error(j.error||"Failed to save");g?.({[c]:j[c]??h})}catch{l("Could not save auto-ping")}finally{n(b=>({...b,[a]:!1}))}},[g,c]);return(0,d.jsxs)("div",{className:"mt-3 rounded-xl border border-line bg-raised p-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)(al.default,{providerId:a,size:"md"}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("p",{className:"text-sm font-semibold text-text",children:["Auto-ping \xb7 ",b]}),(0,d.jsx)("p",{className:"font-mono text-[11px] text-subtle",children:c})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)(ai(),{href:`/dashboard/providers/${a}`,className:"text-[13px] font-semibold text-coral-ink hover:text-coral",children:["Open ",b," ",(0,d.jsx)("span",{"aria-hidden":"true",className:"inline-block rtl:-scale-x-100",children:"→"})]}),(0,d.jsx)(j.default,{variant:"ghost",size:"sm",onClick:o,children:"Load connections"})]})]}),k&&(0,d.jsx)("p",{className:"pt-2 text-xs text-err",role:"alert",children:k}),null===h?(0,d.jsx)("p",{className:"pt-2 text-[13px] text-muted",children:"Per-connection switches live on the provider page too. Load the list to edit them here."}):0===h.length?(0,d.jsxs)("p",{className:"pt-2 text-[13px] text-muted",children:["No ",b," connections yet."," ",(0,d.jsx)(ai(),{href:`/dashboard/providers/${a}`,className:"font-semibold text-coral-ink hover:text-coral",children:"Add one on the Providers page"}),"."]}):(0,d.jsx)("ul",{className:"mt-2 divide-y divide-line",children:h.map(a=>(0,d.jsxs)("li",{className:"flex items-center justify-between gap-3 py-2",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-text",children:a.name||a.id}),(0,d.jsx)(O.default,{checked:!0===p[a.id],onChange:b=>q(a.id,b),disabled:!0===m[a.id],"aria-label":`Auto-ping ${a.name||a.id}`})]},a.id))})]})}aU.propTypes={providerId:l().string.isRequired,label:l().string.isRequired,settingKey:l().string.isRequired,settings:l().object.isRequired,onSettingsChange:l().func};let aV="http://localhost:20128",aW=["claude","codex","gemini-cli","antigravity","kiro","cursor"],aX=[{id:"claude",label:"Claude Code",settingKey:"claudeAutoPing"},{id:"codex",label:"OpenAI Codex",settingKey:"codexAutoPing"}],aY=[{key:"CLAUDE_CLI_VERSION",label:"Claude CLI"},{key:"CODEX_CLI_VERSION",label:"Codex CLI"},{key:"GROK_CLI_VERSION",label:"Grok CLI"},{key:"ZED_CLIENT_VERSION",label:"Zed client"}];function aZ({error:a}){return a?(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:a}):null}function a$(a){try{return((0,aQ.KC)(a)||[]).map(a=>a.id)}catch{return[]}}function a_({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),f=a.providerThinking||{},g=function(a=[],b,c){return a.filter(a=>(b(a)||[]).some(b=>{let d=c(a,b);return Array.isArray(d)&&d.some(a=>"none"!==a)}))}(aW,a$,aR.k),h=I("ccFilterNaming",!0===a.ccFilterNaming,{onSaved:c("ccFilterNaming")}),i=I("mitmRouterBaseUrl",a.mitmRouterBaseUrl??aV,{debounced:!0,onSaved:c("mitmRouterBaseUrl")}),[k,l]=(0,e.useState)({}),[m,n]=(0,e.useState)({}),[o,q]=(0,e.useState)({}),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(!1),v=(0,e.useCallback)(async(a,b)=>{let c=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[a]:b})}),d=await c.json().catch(()=>({}));if(!c.ok)throw Error(d.error||"Failed to save setting");return Object.hasOwn(d,a)?d[a]:b},[]),w=(0,e.useCallback)(async(a,c)=>{l(b=>({...b,[a]:!0})),n(b=>({...b,[a]:""}));try{let d=await fetch("/api/settings",{cache:"no-store"}),e=d.ok?await d.json():{},f=function(a={},b,c){let d={...a||{}};return c&&"auto"!==c?d[b]={mode:c}:delete d[b],d}(e.providerThinking||{},a,c),g=await v("providerThinking",f);b?.({providerThinking:g})}catch(b){n(c=>({...c,[a]:b instanceof Error?b.message:"Failed to save"}))}finally{l(b=>({...b,[a]:!1}))}},[b,v]),x=(0,e.useCallback)(async a=>{u(!0),s("");try{let c=await fetch("/api/settings",{cache:"no-store"}),d={...(c.ok?await c.json():{}).quotaVisibility||{},...a};for(let b of Object.keys(d)){let c=d[b];c&&"object"==typeof c&&Array.isArray(c.hidden)&&0===c.hidden.length&&1===Object.keys(c).length&&Object.hasOwn(a,b)&&delete d[b]}let e=await v("quotaVisibility",d);b?.({quotaVisibility:e})}catch(a){s(a instanceof Error?a.message:"Failed to save")}finally{u(!1)}},[b,v]),A=a.quotaVisibility||{},C=function(a={}){return a&&"object"==typeof a?Object.keys(a):[]}(A);return(0,d.jsxs)("div",{id:"providers",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"dns",title:"Providers & models",subtitle:"Defaults that apply across providers."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Default thinking level"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Used when a request does not ask for one. Only providers with thinking levels are listed."}),(0,d.jsx)("p",{className:"mt-0.5 font-mono text-[11px] text-subtle",children:"providerThinking"}),0===g.length?(0,d.jsx)("p",{className:"mt-2 text-sm text-muted",children:"No provider with thinking levels found."}):(0,d.jsx)("div",{className:"mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:g.map(a=>{let b=function(a,b=[],c){let d=new Set,e=new Set;for(let f of b){if(!f||e.has(f))continue;e.add(f);let b=c(a,f);if(b)for(let a of b)"none"!==a&&d.add(a)}return 0===d.size?null:["auto",...[...d].sort()]}(a,a$(a),aR.k),c=f[a]?.mode||"auto";return(0,d.jsx)("div",{children:(0,d.jsx)(B.default,{label:(0,d.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,d.jsx)(al.default,{providerId:a,size:"sm"}),a]}),value:c,onChange:b=>w(a,b.target.value),disabled:!0===k[a],options:(b||["auto"]).map(a=>({value:a,label:"auto"===a?"Auto":a})),error:m[a]||void 0})},a)})})]}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Auto-ping quota windows"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"A tiny request keeps quota windows warm. Per connection only — there is no global switch."}),aX.map(({id:c,label:e,settingKey:f})=>(0,d.jsx)(aU,{providerId:c,label:e,settingKey:f,settings:a,onSettingsChange:b},c))]}),(0,d.jsx)(z.default,{label:"Filter naming requests",description:"Drop Claude Code title-naming calls to save quota.",settingKey:"ccFilterNaming",control:(0,d.jsx)(O.default,{checked:!0===h.value,onChange:a=>h.set(a),disabled:h.saving,"aria-label":"Filter naming requests"})}),(0,d.jsx)(aZ,{error:h.error}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"min-w-52 flex-1",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Quota rows shown"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Pick which limits appear on the Quota page. Same store as Usage → Limits."}),(0,d.jsx)("p",{className:"mt-0.5 font-mono text-[11px] text-subtle",children:"quotaVisibility"})]}),(0,d.jsx)(j.default,{variant:"secondary",size:"sm",icon:"tune",href:"/dashboard/quota",children:"Choose on Quota page"})]}),r&&(0,d.jsx)("p",{className:"pt-2 text-xs text-err",role:"alert",children:r}),0===C.length?(0,d.jsx)("p",{className:"pt-2 text-sm text-muted",children:"All quota rows are shown. Hide a row below by provider and key."}):(0,d.jsx)("ul",{className:"mt-3 space-y-2",children:C.map(a=>(0,d.jsxs)("li",{className:"rounded-lg border border-line bg-raised p-3 text-sm",children:[(0,d.jsxs)("p",{className:"flex items-center gap-2 font-mono text-xs text-text",children:[(0,d.jsx)(al.default,{providerId:a,size:"sm"}),a]}),(0,d.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:(function(a={},b){let c=a?.[b]?.hidden;return Array.isArray(c)?c.filter(a=>"string"==typeof a):[]})(A,a).map(b=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-line px-2 py-0.5 font-mono text-xs text-muted",children:[b,(0,d.jsx)("button",{type:"button","aria-label":`Show ${b}`,disabled:t,onClick:()=>x(aS(A,a,b,!1)),className:"text-coral-ink hover:text-coral disabled:opacity-50",children:"\xd7"})]},b))})]},a))}),(0,d.jsxs)("div",{className:"mt-3 flex flex-col gap-2 sm:flex-row sm:items-end",children:[(0,d.jsxs)("div",{className:"grid flex-1 grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,d.jsx)(p.default,{label:"Provider",value:o.provider??"",onChange:a=>q(b=>({...b,provider:a.target.value})),placeholder:"claude",inputClassName:"font-mono","aria-label":"Quota provider"}),(0,d.jsx)(p.default,{label:"Quota key",value:o.key??"",onChange:a=>q(b=>({...b,key:a.target.value})),placeholder:"weekly-5h",inputClassName:"font-mono","aria-label":"Quota key"})]}),(0,d.jsx)(j.default,{variant:"secondary",size:"sm",loading:t,disabled:t,onClick:()=>{try{let a=String(o.provider||"").trim(),b=String(o.key||"").trim(),c=aS(A,a,b,!0);q({}),x(c)}catch(a){s(a instanceof Error?a.message:"Invalid quota key")}},children:"Hide row"})]})]}),(0,d.jsx)(z.default,{label:"Intercept (MITM) router URL",description:"Base URL the MITM server routes through. Same behavior as the MITM card.",settingKey:"mitmRouterBaseUrl",control:(0,d.jsx)("div",{className:"w-full sm:min-w-72 sm:max-w-sm",children:(0,d.jsx)(p.default,{value:i.value??"",onChange:a=>i.set(a.target.value),disabled:i.saving,placeholder:aV,inputClassName:"font-mono","aria-label":"Intercept router URL"})})}),(0,d.jsx)(aZ,{error:i.error}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Client version pins"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Read from .env at startup. Read-only here."}),(0,d.jsx)("div",{className:"mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4",children:aY.map(({key:b,label:c})=>(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"mb-1 text-[13px] font-semibold text-text",children:c}),(0,d.jsx)("p",{className:"mb-1 font-mono text-[11px] text-subtle",children:b}),(0,d.jsx)(P.default,{value:a[b]?String(a[b]):"not set"})]},b))})]})]})]})}function a0({error:a}){return a?(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:a}):null}function a1({settings:a,onSettingsChange:b}){let c=a=>c=>b?.({[a]:c}),e=I("enableObservability",!0===a.enableObservability,{onSaved:c("enableObservability")}),g=!0===a.requestLogsOverridden||!0===a.requestLogEnvOverride,h=!0===a.translatorOverridden,i=I("observabilityMaxRecords",a.observabilityMaxRecords??1e3,{debounced:!0,onSaved:c("observabilityMaxRecords")}),j=I("observabilityBatchSize",a.observabilityBatchSize??20,{debounced:!0,onSaved:c("observabilityBatchSize")}),k=I("observabilityFlushIntervalMs",a.observabilityFlushIntervalMs??5e3,{debounced:!0,onSaved:c("observabilityFlushIntervalMs")}),l=I("observabilityMaxJsonSize",a.observabilityMaxJsonSize??5,{debounced:!0,onSaved:c("observabilityMaxJsonSize")}),m=I("requestLogsEnabled",!0===a.requestLogsEnabled,{onSaved:c("requestLogsEnabled")}),n=I("translatorEnabled",!0===a.translatorEnabled,{onSaved:a=>{c("translatorEnabled")(a),(0,f.q0)()}}),p=!e.value,q=g?!0===a.enableRequestLogs:m.value,r=h?!0===a.enableTranslator:n.value;return(0,d.jsxs)("div",{id:"logs",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"monitoring",title:"Observability & logs",subtitle:"What gets recorded, and for how long."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Record request details",description:g?(0,d.jsxs)(d.Fragment,{children:["Set by ",(0,d.jsx)("code",{className:"font-mono",children:"ENABLE_REQUEST_LOGS"})," in .env — the env wins, this toggle is read-only."]}):"Full payloads in Usage → Request log.",settingKey:"enableObservability",control:(0,d.jsx)(O.default,{checked:!0===e.value,onChange:a=>e.set(a),disabled:e.saving||g,"aria-label":"Record request details"})}),(0,d.jsx)(a0,{error:e.error}),(0,d.jsxs)("div",{className:"py-4",children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Storage limits"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"New in UI. Applies within ~5 seconds — no restart required."}),(0,d.jsxs)("div",{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2${p?" opacity-50":""}`,children:[(0,d.jsx)(aj.default,{label:"Max records",value:i.value,onChange:a=>i.set(a),min:1,disabled:p||i.saving,error:i.error||void 0}),(0,d.jsx)(aj.default,{label:"Batch size",value:j.value,onChange:a=>j.set(a),min:1,disabled:p||j.saving,error:j.error||void 0}),(0,d.jsx)(at.default,{label:"Flush every",value:k.value??"",onChange:a=>k.set(Number(a.target.value)),unit:"ms",disabled:p||k.saving,error:k.error?String(k.error):void 0}),(0,d.jsx)(at.default,{label:"Max payload size",value:l.value??"",onChange:a=>l.set(Number(a.target.value)),unit:"KB",hint:"Kilobytes per payload (code multiplies by 1024).",disabled:p||l.saving,error:l.error?String(l.error):void 0})]}),(0,d.jsx)("div",{className:"mt-3",children:(0,d.jsx)(o.default,{variant:"info",title:"No restart needed",children:"Changes take effect within ~5 seconds via the runtime config cache."})})]}),(0,d.jsx)(z.default,{label:"Log every request to console",description:g?"Controlled by ENABLE_REQUEST_LOGS in .env — change it there and restart.":"Writes request/response logs under logs/ for debugging.",settingKey:"ENABLE_REQUEST_LOGS",control:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[g&&(0,d.jsx)("span",{className:"rounded-full bg-raised px-2 py-0.5 font-mono text-[11px] text-muted",children:".env overrides"}),(0,d.jsx)(O.default,{checked:q,onChange:a=>m.set(a),disabled:g||m.saving,"aria-label":"Log every request to console"})]})}),m.error&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:m.error}),(0,d.jsx)(z.default,{label:"Show Translator page",description:h?"Controlled by ENABLE_TRANSLATOR in .env — change it there and restart.":"Debug tool for format translation.",settingKey:"ENABLE_TRANSLATOR",control:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[h&&(0,d.jsx)("span",{className:"rounded-full bg-raised px-2 py-0.5 font-mono text-[11px] text-muted",children:".env overrides"}),(0,d.jsx)(O.default,{checked:r,onChange:a=>n.set(a),disabled:h||n.saving,"aria-label":"Show Translator page"})]})}),n.error&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:n.error})]})]})}aZ.propTypes={error:l().string},a_.propTypes={settings:l().object.isRequired,onSettingsChange:l().func},a0.propTypes={error:l().string},a1.propTypes={settings:l().object.isRequired,onSettingsChange:l().func};var a2=c(47392),a3=c(18982),a4=c(73655),a5=c(58460);let a6=["input","output","cached","reasoning","cache_creation"],a7={input:"Input",output:"Output",cached:"Cached",reasoning:"Reasoning",cache_creation:"Cache creation"};function a8({isOpen:a,onClose:b,onSave:c}){let[f,g]=(0,e.useState)({}),[h,i]=(0,e.useState)(!0),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)(!1),r=(a,b,c,d)=>{let e=Number.parseFloat(d);Number.isNaN(e)||e<0||g(d=>({...d,[a]:{...d[a],[b]:{...d[a]?.[b],[c]:e}}}))},s=async()=>{l(!0),n("");try{let a=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(a.ok)c?.(),b();else{let b=await a.json().catch(()=>({}));n(`Failed to save pricing: ${b.error||a.status}`)}}catch(a){console.error("Failed to save pricing:",a),n("Failed to save pricing")}finally{l(!1)}},t=async()=>{if(!(await fetch("/api/pricing",{method:"DELETE"})).ok)throw Error("Failed to reset pricing");g((0,a3.ad)()),p(!1)},u=Object.keys(f).sort();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(q.default,{isOpen:a,onClose:b,title:"Pricing configuration",size:"full",className:"max-w-6xl",closeOnOverlay:!k,closeOnEscape:!k&&!o,footer:(0,d.jsxs)("div",{className:"flex w-full flex-wrap items-center justify-between gap-2",children:[(0,d.jsx)(j.default,{variant:"danger",onClick:()=>p(!0),disabled:k,children:"Reset to defaults"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(j.default,{variant:"ghost",onClick:b,disabled:k,children:"Cancel"}),(0,d.jsx)(j.default,{onClick:s,loading:k,disabled:h,children:k?"Saving...":"Save Changes"})]})]}),children:[(0,d.jsx)("div",{"aria-live":"polite",children:m&&(0,d.jsx)("p",{role:"alert",className:"mb-4 rounded-lg bg-err-bg px-3 py-2 text-sm text-err",children:m})}),h?(0,d.jsx)(a4.LoadingState,{label:"Loading pricing",lines:4}):(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsxs)("div",{className:"rounded-lg border border-line bg-raised p-3 text-sm",children:[(0,d.jsx)("p",{className:"mb-1 font-medium text-text",children:"Pricing rates format"}),(0,d.jsxs)("p",{className:"text-muted",children:["All rates are in ",(0,d.jsx)("strong",{children:"dollars per million tokens"})," ($/1M tokens). Example: Input rate of 2.50 means $2.50 per 1,000,000 input tokens."]})]}),u.map(a=>(0,d.jsx)(a9,{provider:a,models:f[a],onChange:r},a)),0===u.length&&(0,d.jsx)("div",{className:"py-8 text-center text-muted",children:"No pricing data available"})]})]}),(0,d.jsx)(q.ConfirmDialog,{isOpen:o,onClose:()=>p(!1),onConfirm:t,title:"Reset pricing",message:"Reset all pricing to defaults? This cannot be undone.",confirmText:"Reset to defaults"})]})}function a9({provider:a,models:b,onChange:c}){return(0,d.jsxs)("div",{className:"overflow-hidden rounded-lg border border-line",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 bg-raised px-4 py-2 text-sm font-semibold text-text",children:[(0,d.jsx)(al.default,{providerId:a,size:"sm"}),a.toUpperCase()]}),(0,d.jsx)("section",{className:"overflow-x-auto focus-visible:shadow-focus","aria-label":"Pricing table",tabIndex:0,children:(0,d.jsxs)("table",{className:"w-full text-sm",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:a5.pi,children:[(0,d.jsx)("th",{scope:"col",className:`${a5.PK} px-3 py-2 text-start`,children:"Model"}),a6.map(a=>(0,d.jsx)("th",{scope:"col",className:`${a5.PK} px-3 py-2 text-end`,children:a7[a]},a))]})}),(0,d.jsx)("tbody",{className:"divide-y divide-line",children:Object.keys(b).sort().map(e=>(0,d.jsxs)("tr",{className:"hover:bg-raised/60",children:[(0,d.jsx)("td",{className:"px-3 py-2 font-medium text-text",children:e}),a6.map(f=>(0,d.jsx)("td",{className:"px-3 py-2",children:(0,d.jsx)("input",{type:"number",step:"0.01",min:"0","aria-label":`${e} ${a7[f]}`,value:b[e][f]||0,onChange:b=>c(a,e,f,b.target.value),className:"w-20 rounded border border-line bg-raised px-2 py-1 text-end text-text focus:border-coral focus:shadow-focus focus:outline-none"})},f))]},e))})]})})]})}function ba({modalOpen:a,onModalChange:b}){let[c,f]=(0,e.useState)(null),[h,k]=(0,e.useState)(!0),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(!1),p=b||o,q=(0,e.useRef)(null),r=async()=>{q.current?.abort();let a=new AbortController;q.current=a,k(!0),m("");try{let b=await fetch("/api/pricing",{signal:a.signal});if(!b.ok)throw Error(`HTTP ${b.status}`);let c=await b.json();f(c)}catch(a){if(a?.name==="AbortError")return;m("Failed to load pricing data")}finally{q.current===a&&k(!1)}},s=c?Object.keys(c).sort():[],t=s.reduce((a,b)=>a+Object.keys(c[b]||{}).length,0),u=s.reduce((a,b)=>a+Object.values(c[b]||{}).filter(a=>a&&!0===a.custom).length,0);return(0,d.jsxs)("div",{id:"pricing",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"savings",title:"Pricing",subtitle:"What cost estimates use, in $ per 1M tokens."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card space-y-4",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[(0,d.jsx)(a2.default,{eyebrow:"Models",value:h?"…":String(t)}),(0,d.jsx)(a2.default,{eyebrow:"Providers",value:h?"…":String(s.length)}),(0,d.jsx)(a2.default,{eyebrow:"Custom",value:h?"…":String(u)})]}),h?(0,d.jsx)(i.Skeleton,{}):l?(0,d.jsx)(g.default,{icon:"error",title:"Could not load pricing",body:l,action:(0,d.jsx)(j.default,{variant:"secondary",onClick:r,children:"Retry"})}):(0,d.jsxs)("div",{className:"overflow-x-auto rounded-xl border border-line",children:[(0,d.jsxs)("table",{className:"w-full min-w-[42rem] text-sm",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:"text-start text-xs text-muted",children:[(0,d.jsx)("th",{className:"px-3 py-2 text-start font-semibold",children:"Model"}),(0,d.jsx)("th",{className:"px-3 py-2 text-end font-semibold",children:"Input"}),(0,d.jsx)("th",{className:"px-3 py-2 text-end font-semibold",children:"Output"}),(0,d.jsx)("th",{className:"px-3 py-2 text-end font-semibold",children:"Cached"})]})}),(0,d.jsx)("tbody",{children:s.slice(0,5).flatMap(a=>Object.keys(c[a]||{}).slice(0,10).map(b=>{let e=c[a][b]||{};return(0,d.jsxs)("tr",{className:"border-t border-line",children:[(0,d.jsxs)("td",{className:"px-3 py-2 font-mono text-xs text-text",children:[(0,d.jsx)(al.default,{providerId:a,size:"sm",className:"me-2 align-middle"}),a,"/",b,!0===e.custom&&(0,d.jsx)("span",{className:"ms-1.5 rounded-full bg-coral-bg px-1.5 py-0.5 text-[10px] font-semibold text-coral-ink",children:"Custom"})]}),(0,d.jsx)("td",{className:"px-3 py-2 text-end tabular-nums text-text",children:e.input??"—"}),(0,d.jsx)("td",{className:"px-3 py-2 text-end tabular-nums text-text",children:e.output??"—"}),(0,d.jsx)("td",{className:"px-3 py-2 text-end tabular-nums text-text",children:e.cached??"—"})]},`${a}/${b}`)}))})]}),s.length>5&&(0,d.jsxs)("p",{className:"border-t border-line px-3 py-2 text-xs text-muted",children:["+ ",s.length-5," more providers — open Edit pricing for full details."]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(j.default,{variant:"secondary",icon:"edit",onClick:()=>p(!0),children:"Edit pricing"}),(0,d.jsx)(j.default,{variant:"ghost",icon:"restart_alt",onClick:()=>p(!0),children:"Reset to defaults…"})]})]}),(0,d.jsx)(a8,{isOpen:void 0!==a?a:n,onClose:()=>p(!1),onSave:()=>r()})]})}a8.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onSave:l().func},a9.propTypes={provider:l().string.isRequired,models:l().object.isRequired,onChange:l().func.isRequired},ba.propTypes={modalOpen:l().bool,onModalChange:l().func};let bb=`~/.${m.Hc.dataDirName}/db/data.sqlite`;function bc({onSettingsChange:a}){let[b,c]=(0,e.useState)({type:"",message:""}),[f,g]=(0,e.useState)(!1),[h,i]=(0,e.useState)({open:!1,mode:"",password:""}),k=(0,e.useRef)(null),l=(0,e.useRef)(null),[n,r]=(0,e.useState)(bb),s=async a=>{g(!0),c({type:"",message:""});try{let b=await fetch("/api/settings/database",{headers:{"x-9r-password":a}});if(!b.ok){let a=await b.json().catch(()=>({}));throw Error(a.error||"Failed to export database")}let d=await b.json(),e=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),f=URL.createObjectURL(e),g=document.createElement("a"),h=new Date().toISOString().replace(/[.:]/g,"-");g.href=f,g.download=`${m.Hc.backupFilePrefix}${h}.json`,document.body.appendChild(g),g.click(),document.body.removeChild(g),URL.revokeObjectURL(f),c({type:"ok",message:"Database backup downloaded"})}catch(a){c({type:"err",message:a.message||"Failed to export database"})}finally{g(!1)}},t=async b=>{let d=k.current;if(d){g(!0);try{let e=await d.text(),f=JSON.parse(e),g=await fetch("/api/settings/database",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...f,password:b})}),h=await g.json().catch(()=>({}));if(!g.ok)throw Error(h.error||"Failed to import database");a?.(),c({type:"ok",message:"Database imported successfully"})}catch(a){c({type:"err",message:a.message||"Invalid backup file"})}finally{k.current=null,g(!1)}}},u=async()=>{let{mode:a,password:b}=h;i({open:!1,mode:"",password:""}),"export"===a?await s(b):"import"===a&&await t(b)};return(0,d.jsxs)("div",{id:"data",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"database",title:"Data & backup",subtitle:"Everything lives in one SQLite file."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Database",description:"SQLite file location.",settingKey:"DATA_DIR",control:(0,d.jsx)("div",{className:"w-full sm:min-w-72 sm:max-w-sm",children:(0,d.jsx)(P.default,{value:n})})}),(0,d.jsxs)("div",{className:"py-4 space-y-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-[15px] font-semibold text-text",children:"Backup"}),(0,d.jsx)("p",{className:"mt-0.5 text-[13px] text-muted",children:"Both ask for your password."})]}),(0,d.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,d.jsx)(j.default,{variant:"secondary",icon:"download",loading:f,onClick:()=>i({open:!0,mode:"export",password:""}),children:"Download"}),(0,d.jsx)(j.default,{variant:"secondary",icon:"upload",disabled:f,onClick:()=>l.current?.click(),children:"Import"}),(0,d.jsx)("input",{ref:l,type:"file",accept:"application/json,.json",onChange:a=>{let b=a.target.files?.[0];l.current&&(l.current.value=""),b&&(k.current=b,c({type:"",message:""}),i({open:!0,mode:"import",password:""}))},className:"hidden"})]}),b.message&&(0,d.jsx)(o.default,{variant:"ok"===b.type?"ok":"err",title:b.message})]}),(0,d.jsx)(z.default,{label:"Cloud sync",description:"Keep settings and connections in sync across machines.",settingKey:"cloudEnabled",control:(0,d.jsx)(O.default,{checked:!1,onChange:()=>{},disabled:!0,"aria-label":"Cloud sync (unavailable)"})}),(0,d.jsx)("div",{className:"py-3",children:(0,d.jsx)(o.default,{variant:"info",title:"Cloud sync is not available in this build",children:"No sync worker ships with this repo, so the toggle stays off. Your data stays local; use Download/Import backup to move it between machines."})})]}),(0,d.jsxs)(q.default,{isOpen:h.open,onClose:()=>i({open:!1,mode:"",password:""}),title:"Confirm password",size:"sm",footer:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.default,{variant:"ghost",onClick:()=>i({open:!1,mode:"",password:""}),disabled:f,children:"Cancel"}),(0,d.jsx)(j.default,{onClick:u,loading:f,disabled:!h.password,children:"Confirm"})]}),children:[(0,d.jsxs)("p",{className:"mb-3 text-sm text-muted",children:["Enter your current password to ","export"===h.mode?"export":"import"," the database."]}),(0,d.jsx)(p.default,{type:"password",autoComplete:"current-password",value:h.password,onChange:a=>i(b=>({...b,password:a.target.value})),onKeyDown:a=>{"Enter"===a.key&&h.password&&u()},placeholder:"Current password"})]})]})}bc.propTypes={onSettingsChange:l().func};let bd=`${m.qt.npmPackage} data migrate`;function be(){let[a,b]=(0,e.useState)(null),[c,f]=(0,e.useState)(null),[g,h]=(0,e.useState)(null),[j,k]=(0,e.useState)(""),l=a?Object.entries(a):[];return(0,d.jsxs)("div",{id:"environment",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"terminal",title:"Environment",subtitle:"Read from .env at startup. Edit the file and restart."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-line bg-panel p-5 shadow-card space-y-4",children:[(0,d.jsx)(o.default,{variant:"info",title:".env \xb7 restart",children:`Values come from the server environment. Change them in .env and restart ${m.Hc.slug}.`}),c&&(0,d.jsxs)(o.default,{variant:"warn",title:"Data directory",children:[(0,d.jsx)("p",{children:"Your data is in the old folder. Stop the server, then run this command to move it."}),(0,d.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,d.jsx)(P.default,{value:c,label:"Data directory"}),(0,d.jsx)(P.default,{value:bd,label:"Copy code"})]})]}),g&&(0,d.jsxs)(o.default,{variant:"warn",title:"Data directory",children:[(0,d.jsx)("p",{children:"An old data folder also exists and is not used. If your data is missing, check it before deleting anything."}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(P.default,{value:g,label:"Data directory"})})]}),j?(0,d.jsx)("p",{className:"text-sm text-err",role:"alert",children:j}):a?0===l.length?(0,d.jsx)("p",{className:"text-sm text-muted",children:"No environment values set."}):(0,d.jsx)("dl",{className:"grid grid-cols-1 gap-x-6 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.3fr)]",children:l.map(([a,b])=>(0,d.jsxs)("div",{className:"contents sm:[&>dd]:border-t-0 sm:[&>dt]:border-t-0 [&>*]:border-t [&>*]:border-line [&>*]:py-2",children:[(0,d.jsx)("dt",{className:"font-mono text-[13px] text-text",children:a}),(0,d.jsx)("dd",{className:"min-w-0",children:(0,d.jsx)(P.default,{value:String(b),label:`Copy ${a}`})})]},a))}):(0,d.jsx)(i.Skeleton,{})]})]})}function bf(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)(""),g=async()=>{f("");try{if(!(await fetch("/api/auth/logout",{method:"POST"})).ok)throw Error("Failed to log out");window.location.assign("/login")}catch(a){f(a.message||"Failed to log out")}},h=async()=>{try{await fetch("/api/version/shutdown",{method:"POST"})}catch{}b(!1)};return(0,d.jsxs)("div",{id:"danger",className:"scroll-mt-24 space-y-4",children:[(0,d.jsx)(y.default,{icon:"warning",title:"Danger zone",subtitle:"End sessions and stop the server."}),(0,d.jsxs)("div",{className:"rounded-2xl border border-err/40 bg-panel p-5 shadow-card divide-y divide-line",children:[(0,d.jsx)(z.default,{label:"Log out",description:"End this dashboard session.",control:(0,d.jsx)(j.default,{variant:"secondary",icon:"logout",onClick:g,children:"Log out"})}),c&&(0,d.jsx)("p",{className:"py-2 text-xs text-err",role:"alert",children:c}),(0,d.jsx)(z.default,{label:`Shut down ${m.Hc.slug}`,description:"Your tools lose their endpoint until you start it again.",control:(0,d.jsx)(j.default,{variant:"danger",icon:"power_settings_new",onClick:()=>b(!0),children:"Shut down"})})]}),(0,d.jsx)(q.ConfirmDialog,{isOpen:a,onClose:()=>b(!1),onConfirm:h,title:`Shut down ${m.Hc.slug}`,message:"Your tools lose their endpoint until you start it again.",confirmText:"Shut down",variant:"danger"})]})}var bg=c(71404);let bh={new:"bg-coral-bg text-coral",experimental:"bg-raised text-muted"};function bi({groups:a,sections:b,activeId:c,onSelect:e}){let f=Object.fromEntries(b.map(a=>[a.id,a])),g=a.find(a=>a.sections.includes(c))??a[0];return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("nav",{"aria-label":"Settings groups",className:"grid grid-cols-2 gap-2 md:grid-cols-4 lg:col-span-2",children:a.map(a=>{let b=a.id===g.id;return(0,d.jsxs)("button",{type:"button","aria-pressed":b,onClick:()=>e(a.sections[0]),className:(0,bg.cn)("group flex items-center gap-3 rounded-xl border px-4 py-3 text-left transition-all outline-none focus-visible:shadow-focus",b?"border-coral/40 bg-coral-bg shadow-card":"border-line bg-panel hover:-translate-y-0.5 hover:bg-raised"),children:[(0,d.jsx)("span",{"aria-hidden":"true",className:(0,bg.cn)("material-symbols-outlined flex size-9 shrink-0 items-center justify-center rounded-lg text-[20px]",b?"bg-coral text-on-coral":"bg-raised text-muted group-hover:text-text"),children:a.icon}),(0,d.jsxs)("span",{className:"min-w-0",children:[(0,d.jsx)("span",{className:(0,bg.cn)("block text-sm font-semibold",b?"text-coral":"text-text"),children:a.title}),(0,d.jsx)("span",{className:"block truncate text-xs text-muted",children:a.sections.map(a=>f[a]?.title).join(" \xb7 ")})]})]},a.id)})}),(0,d.jsx)("nav",{"aria-label":`${g.title} sections`,className:"lg:sticky lg:top-0 lg:self-start",children:(0,d.jsx)("ul",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2 lg:flex lg:flex-col",children:g.sections.map(a=>{let b=f[a];if(!b)return null;let g=a===c,h="danger"===a;return(0,d.jsx)("li",{className:"min-w-0",children:(0,d.jsxs)("a",{href:`#${a}`,onClick:b=>{b.preventDefault(),e(a)},"aria-current":g?"page":void 0,className:(0,bg.cn)("relative flex items-start gap-3 rounded-lg px-3 py-2.5 transition-colors outline-none focus-visible:shadow-focus",g?"bg-panel shadow-card":"hover:bg-raised",g&&"lg:before:absolute lg:before:inset-y-2 lg:before:left-0 lg:before:w-0.5 lg:before:rounded-full lg:before:bg-coral"),children:[(0,d.jsx)("span",{"aria-hidden":"true",className:(0,bg.cn)("material-symbols-outlined mt-0.5 text-[18px]",h?"text-err":g?"text-coral":"text-muted"),children:b.icon}),(0,d.jsxs)("span",{className:"min-w-0",children:[(0,d.jsxs)("span",{className:"flex items-center gap-2 text-sm font-semibold whitespace-nowrap text-text",children:[b.title,[...new Set(b.rows.flatMap(a=>a.tags??[]))].filter(a=>bh[a]).map(a=>(0,d.jsx)("span",{className:(0,bg.cn)("rounded px-1.5 py-px text-[10px] uppercase tracking-wide",bh[a]),children:a},a))]}),(0,d.jsx)("span",{className:"hidden text-xs text-muted lg:block",children:b.subtitle})]})]})},a)})})})]})}bi.propTypes={groups:l().arrayOf(l().shape({id:l().string.isRequired,title:l().string.isRequired,icon:l().string.isRequired,sections:l().arrayOf(l().string).isRequired})).isRequired,sections:l().arrayOf(l().object).isRequired,activeId:l().string.isRequired,onSelect:l().func.isRequired};var bj=c(85699);function bk(){let[a,b]=(0,e.useState)({requireLogin:!0}),[c,k]=(0,e.useState)(!0),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)("en"),[r,s]=(0,e.useState)(0),[t,u]=(0,e.useState)(0),[v,x]=(0,e.useState)("general"),y=(0,e.useCallback)(async()=>{k(!0),m("");try{let a=await fetch("/api/settings",{cache:"no-store"});if(!a.ok)throw Error(`HTTP ${a.status}`);let c=await a.json();b(c)}catch{m("Failed to load settings")}finally{k(!1)}},[]),z=(0,e.useCallback)(a=>{x(a),window.history.replaceState(null,"",`#${a}`),document.querySelector("main .custom-scrollbar")?.scrollTo({top:0,behavior:"smooth"})},[]),A=(0,e.useCallback)(a=>{if(!a){y(),u(a=>a+1),(0,f.q0)();return}b(b=>({...b,...a})),s(a=>a+1)},[y]),B=(0,bj.Ee)(n),C=new Set(n?B.map(a=>a.id):[v]),D=bj.HX.find(a=>a.id===v),[E,F]=(0,e.useState)(!1),G=(0,e.useCallback)(a=>{if(F(a),!a){let a=new URL(window.location.href);a.searchParams.delete("editPricing"),window.history.replaceState(null,"",`${a.pathname}${a.search}${a.hash}`)}},[]);return(0,d.jsxs)("div",{className:"mx-auto max-w-6xl space-y-6",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsx)("div",{children:(0,d.jsxs)("p",{className:"text-sm text-muted",children:["Changes save instantly."," ",(0,d.jsx)("span",{"aria-live":"polite","aria-atomic":"true",className:"font-medium text-ok",children:r>0?`All changes saved (${r})`:" "})]})}),(0,d.jsx)(w,{onSettingsChange:A})]}),(0,d.jsx)(h.default,{id:"settings-search",value:n,onChange:a=>o(a.target.value),placeholder:"Search settings",ariaLabel:"Search settings"})]}),(0,d.jsxs)("div",{className:"grid gap-6 lg:grid-cols-[15rem_minmax(0,1fr)]",children:[n?(0,d.jsxs)("p",{className:"text-sm text-muted lg:col-span-2","aria-live":"polite",children:[B.reduce((a,b)=>a+b.rows.length,0)," matching settings in"," ",B.length," sections"]}):(0,d.jsx)(bi,{groups:bj.lY,sections:bj.HX,activeId:v,onSelect:z}),(0,d.jsxs)("div",{className:(0,bg.cn)("min-w-0",n&&"lg:col-span-2"),children:[!n&&D&&(0,d.jsxs)("p",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-muted",children:[bj.lY.find(a=>a.sections.includes(v))?.title," /"," ",(0,d.jsx)("span",{className:"text-text",children:D.title})]}),c?(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)(i.Skeleton,{}),(0,d.jsx)(i.Skeleton,{})]}):l?(0,d.jsx)(g.default,{icon:"error",title:"Could not load settings",body:l,action:(0,d.jsx)(j.default,{onClick:y,children:"Retry"})}):0===B.length?(0,d.jsx)(g.default,{icon:"search",title:"No settings match",body:`Nothing matches “${n}”. Try a different search.`,action:(0,d.jsx)(j.default,{variant:"ghost",onClick:()=>o(""),children:"Clear search"})}):(0,d.jsxs)("div",{className:"space-y-6",children:[C.has("general")&&(0,d.jsx)(N,{settings:a,locale:p,onLocaleChange:q,onSettingsChange:A}),C.has("security")&&(0,d.jsx)(Q,{settings:a,onSettingsChange:A}),C.has("sso")&&(0,d.jsx)(ag,{settings:a,onSettingsChange:A}),C.has("routing")&&(0,d.jsx)(as,{settings:a,onSettingsChange:A}),C.has("reliability")&&(0,d.jsx)(aE,{settings:a,onSettingsChange:A}),C.has("network")&&(0,d.jsx)(aH,{settings:a,onSettingsChange:A}),C.has("token-saver")&&(0,d.jsx)(aP,{settings:a,onSettingsChange:A}),C.has("providers")&&(0,d.jsx)(a_,{settings:a,onSettingsChange:A}),C.has("logs")&&(0,d.jsx)(a1,{settings:a,onSettingsChange:A}),C.has("pricing")&&(0,d.jsx)(ba,{modalOpen:E,onModalChange:G},`pricing-${t}`),C.has("data")&&(0,d.jsx)(bc,{onSettingsChange:A}),C.has("environment")&&(0,d.jsx)(be,{}),C.has("danger")&&(0,d.jsx)(bf,{})]})]})]})]})}},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},30766:(a,b,c)=>{Promise.resolve().then(c.bind(c,27558))},31421:a=>{"use strict";a.exports=require("node:child_process")},32467:a=>{"use strict";a.exports=require("node:http2")},33597:(a,b,c)=>{"use strict";c.d(b,{default:()=>k});var d=c(48249),e=c(49885),f=c.n(e),g=c(67484),h=c(83552),i=c(21951),j=c(71404);function k({value:a,onChange:b,ariaLabel:c,placeholder:e,id:f,className:l,inputClassName:m}){let n=(0,g.useRef)(null);return(0,d.jsxs)("div",{className:(0,j.cn)("relative",l),children:[(0,d.jsx)(h.default,{ref:n,id:f,type:"search",icon:"search",value:a,onChange:b,placeholder:e,"aria-label":c,inputClassName:(0,j.cn)("min-h-10 sm:pe-10",m)}),!a&&(0,d.jsx)("span",{className:"pointer-events-none absolute inset-y-0 end-3 hidden items-center sm:flex","aria-hidden":"true",children:(0,d.jsx)(i.default,{children:"/"})})]})}c(77637),k.propTypes={value:f().string.isRequired,onChange:f().func.isRequired,ariaLabel:f().string.isRequired,placeholder:f().string,id:f().string,className:f().string,inputClassName:f().string}},33873:a=>{"use strict";a.exports=require("path")},34589:a=>{"use strict";a.exports=require("node:assert")},37067:a=>{"use strict";a.exports=require("node:http")},37540:a=>{"use strict";a.exports=require("node:console")},38522:a=>{"use strict";a.exports=require("node:zlib")},39973:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"default",{enumerable:!0,get:function(){return e}});let d=c(40399)._(c(80061));function e(a,b){let c={};"function"==typeof a&&(c.loader=a);let e={...c,...b};return(0,d.default)({...e,modules:e.loadableGenerated?.modules})}("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)},40610:a=>{"use strict";a.exports=require("node:dns")},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},41692:a=>{"use strict";a.exports=require("node:tls")},41792:a=>{"use strict";a.exports=require("node:querystring")},44928:(a,b,c)=>{"use strict";c.d(b,{default:()=>i});var d=c(48249),e=c(49885),f=c.n(e),g=c(71404),h=c(27444);function i({label:a,placeholder:b,value:c,onChange:e,error:f,hint:j,disabled:k=!1,required:l=!1,rows:m=3,className:n,textareaClassName:o,id:p,...q}){return(0,d.jsx)(h.default,{id:p,label:a,hint:j,error:f,required:l,className:n,children:({inputId:a,describedBy:f,invalid:h})=>(0,d.jsx)("textarea",{...q,id:a,placeholder:b,value:c,onChange:e,disabled:k,rows:m,"aria-describedby":f,"aria-invalid":h||void 0,className:(0,g.cn)("w-full px-3 py-2.5 text-sm text-text bg-raised rounded-lg","border border-line placeholder:text-subtle resize-y","focus:outline-none focus:border-coral focus:shadow-focus","transition-colors duration-150 disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",h&&"border-err focus:border-err",o)})})}i.propTypes={label:f().node,placeholder:f().string,value:f().oneOfType([f().string,f().number]),onChange:f().func,error:f().node,hint:f().node,disabled:f().bool,required:f().bool,rows:f().number,className:f().string,textareaClassName:f().string,id:f().string,"aria-label":f().string}},46060:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external.js")},46193:a=>{"use strict";a.exports=require("node:string_decoder")},46293:a=>{"use strict";a.exports=require("sql.js")},47392:(a,b,c)=>{"use strict";c.d(b,{default:()=>h});var d=c(48249),e=c(49885),f=c.n(e);function g(a,b){return(0,d.jsx)("span",{className:`text-sm ${a?"":"text-muted"}`,children:b})}function h({eyebrow:a,value:b,delta:c,trend:e,sparkline:f,hero:i=!1,className:j}){let k,l;return(0,d.jsxs)("div",{className:`flex flex-col gap-1 rounded-2xl border p-5 shadow-card ${i?"border-transparent bg-lime text-on-lime":"border-line bg-panel text-text"}${j?` ${j}`:""}`,children:[(0,d.jsx)("span",{className:`text-xs font-semibold uppercase tracking-[0.08em] ${i?"":"text-muted"}`,children:a}),(0,d.jsx)("span",{className:"min-w-0 font-display text-4xl font-bold tabular-nums [word-break:break-word]",children:b}),c&&g(i,c),e&&g(i,e),f&&f.length>1&&(0,d.jsx)("svg",{viewBox:"0 0 100 24",className:"mt-1 h-6 w-full","aria-hidden":"true",preserveAspectRatio:"none",children:(0,d.jsx)("polyline",{fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round",strokeLinecap:"round",points:(l=Math.max(...f)-(k=Math.min(...f))||1,f.map((a,b)=>{let c=b/(f.length-1)*100;return`${c},${22-(a-k)/l*20}`}).join(" "))})})]})}h.propTypes={eyebrow:f().string.isRequired,value:f().node.isRequired,delta:f().node,trend:f().node,sparkline:f().arrayOf(f().number),hero:f().bool,className:f().string}},48161:a=>{"use strict";a.exports=require("node:os")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},53053:a=>{"use strict";a.exports=require("node:diagnostics_channel")},55511:a=>{"use strict";a.exports=require("crypto")},55591:a=>{"use strict";a.exports=require("https")},57075:a=>{"use strict";a.exports=require("node:stream")},57975:a=>{"use strict";a.exports=require("node:util")},61030:(a,b,c)=>{Promise.resolve().then(c.bind(c,74669))},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},66958:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"BailoutToCSR",{enumerable:!0,get:function(){return e}});let d=c(49306);function e({reason:a,children:b}){throw Object.defineProperty(new d.BailoutToCSRError(a),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0})}},67635:(a,b,c)=>{"use strict";c.d(b,{default:()=>j});var d=c(48249),e=c(49885),f=c.n(e),g=c(67484),h=c(71404),i=c(31290);function j({value:a,copyValue:b,label:c="Copy to clipboard",showCopyButton:e=!0,className:f,...k}){let[l,m]=(0,g.useState)(null),n=(0,g.useRef)(null),o=a=>{m(a),clearTimeout(n.current),n.current=setTimeout(()=>m(null),2e3)},p=async()=>{try{await (0,i.eM)(b??a),o("copied")}catch{o("error")}};return(0,d.jsxs)("div",{className:(0,h.cn)("flex h-11 items-center gap-2 rounded-lg border border-line bg-raised ps-3 pe-1.5 transition-colors","focus-within:border-coral focus-within:shadow-focus",f),...k,children:[(0,d.jsx)("code",{title:String(b??a),className:"min-w-0 flex-1 truncate font-mono text-sm text-text",children:a}),e?(0,d.jsx)("button",{type:"button","aria-label":c,onClick:p,className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted transition-colors hover:bg-line/60 hover:text-text focus-visible:shadow-focus",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:"copied"===l?"check":"error"===l?"error":"content_copy"})}):null,e?(0,d.jsx)("span",{"aria-live":"polite",className:"sr-only",children:"copied"===l?"Copied":"error"===l?"Copy failed":""}):null]})}j.propTypes={value:f().oneOfType([f().string,f().number]).isRequired,copyValue:f().string,label:f().string,showCopyButton:f().bool,className:f().string}},67960:(a,b,c)=>{"use strict";c.d(b,{Cp:()=>g,Hx:()=>f,Iv:()=>k,Nv:()=>m,RL:()=>j,ev:()=>l,fl:()=>h,hT:()=>d,oX:()=>e,t6:()=>i});let d=["zh-CN","zh-TW"],e=[{icon:"public",title:"Access anywhere",desc:"Use your API from any network"},{icon:"group",title:"Share endpoint",desc:"Share URL with team members"},{icon:"code",title:"Use in Cursor/Cline",desc:"Connect AI tools remotely"},{icon:"lock",title:"Encrypted",desc:"End-to-end TLS via Cloudflare"}],f=2e3,g=3e5,h=5e3,i=5,j=1e4,k=5e3,l=[{id:"lite",label:"Lite",desc:"Drop filler, keep grammar"},{id:"full",label:"Full",desc:"Drop articles, fragments OK"},{id:"ultra",label:"Ultra",desc:"Telegraphic, max compression"},{id:"wenyan-lite",label:"文 Lite",desc:"Classical Chinese, light compression",wenyan:!0},{id:"wenyan",label:"文 Full",desc:"Maximum 文言文, 80-90% reduction",wenyan:!0},{id:"wenyan-ultra",label:"文 Ultra",desc:"Extreme classical compression",wenyan:!0}],m=[{id:"lite",label:"Lite",desc:"Build asked, name lazier option"},{id:"full",label:"Full",desc:"Ladder enforced: stdlib/native first"},{id:"ultra",label:"Ultra",desc:"YAGNI extremist, deletion first"}]},69814:(a,b,c)=>{"use strict";c.d(b,{default:()=>k});var d=c(48249),e=c(49885),f=c.n(e),g=c(67484),h=c(71404),i=c(31290),j=c(27444);function k({label:a,value:b,onChange:c,min:e,max:f,step:l=1,error:m,hint:n,disabled:o=!1,required:p=!1,className:q,id:r,...s}){let[t,u]=(0,g.useState)(null),v=t??b??"",w=a=>{let d=(0,i.N)(a,{min:e,max:f});u(null),("string"!=typeof d||""===d)&&d!==b&&c?.(d)},x=a=>{let d=t??b,g=(0,i.CD)(""===d?void 0:d,{min:e,max:f,step:l,direction:a});u(null),c?.(g)},y="inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-line bg-raised text-muted transition-colors hover:text-text focus-visible:shadow-focus disabled:cursor-not-allowed disabled:opacity-50";return(0,d.jsx)(j.default,{id:r,label:a,hint:n,error:m,required:p,className:q,children:({inputId:a,describedBy:b,invalid:c})=>(0,d.jsxs)("div",{className:"flex items-stretch gap-2",children:[(0,d.jsx)("button",{type:"button","aria-label":"Decrease value","aria-controls":a,disabled:o,onClick:()=>x(-1),className:y,children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"remove"})}),(0,d.jsx)("input",{...s,id:a,type:"number",inputMode:"decimal",value:v,min:e,max:f,step:l,disabled:o,"aria-describedby":b,"aria-invalid":c||void 0,onChange:a=>u(a.target.value),onBlur:a=>w(a.target.value),onKeyDown:a=>{"Enter"===a.key?w(a.currentTarget.value):"ArrowUp"===a.key?(a.preventDefault(),x(1)):"ArrowDown"===a.key&&(a.preventDefault(),x(-1))},className:(0,h.cn)("w-full h-11 px-3 text-center text-sm text-text bg-raised rounded-lg","border border-line focus:outline-none focus:border-coral focus:shadow-focus","transition-colors duration-150 disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",c&&"border-err focus:border-err")}),(0,d.jsx)("button",{type:"button","aria-label":"Increase value","aria-controls":a,disabled:o,onClick:()=>x(1),className:y,children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"add"})})]})})}k.propTypes={label:f().node,value:f().oneOfType([f().string,f().number]),onChange:f().func,min:f().number,max:f().number,step:f().number,error:f().node,hint:f().node,disabled:f().bool,required:f().bool,className:f().string,id:f().string}},71553:a=>{"use strict";a.exports=require("node:dns/promises")},71622:a=>{"use strict";a.exports=import("open")},73024:a=>{"use strict";a.exports=require("node:fs")},73136:a=>{"use strict";a.exports=require("node:url")},73429:a=>{"use strict";a.exports=require("node:util/types")},73496:a=>{"use strict";a.exports=require("http2")},74075:a=>{"use strict";a.exports=require("zlib")},74669:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/settings/page.js\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/settings/page.js","default")},75919:a=>{"use strict";a.exports=require("node:worker_threads")},76760:a=>{"use strict";a.exports=require("node:path")},77030:a=>{"use strict";a.exports=require("node:net")},77598:a=>{"use strict";a.exports=require("node:crypto")},78197:(a,b,c)=>{"use strict";c.d(b,{default:()=>h});var d=c(48249),e=c(49885),f=c.n(e),g=c(24279);function h({icon:a,title:b,subtitle:c,status:e,statusLabel:f,className:i}){return(0,d.jsxs)("div",{className:`flex items-center gap-4 rounded-2xl border border-line bg-panel p-5 shadow-card${i?` ${i}`:""}`,children:[(0,d.jsx)("span",{className:"flex size-12 shrink-0 items-center justify-center rounded-xl bg-coral-bg text-coral-ink",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:a})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,d.jsx)("h2",{className:"font-display text-2xl font-bold text-text",children:b}),c&&(0,d.jsx)("p",{className:"text-sm text-muted",children:c})]}),e&&(0,d.jsx)(g.default,{variant:e,size:"sm",dot:!0,children:f??e})]})}h.propTypes={icon:f().string.isRequired,title:f().node.isRequired,subtitle:f().node,status:f().string,statusLabel:f().string,className:f().string}},78474:a=>{"use strict";a.exports=require("node:events")},79646:a=>{"use strict";a.exports=require("child_process")},80061:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"default",{enumerable:!0,get:function(){return j}});let d=c(48249),e=c(67484),f=c(66958),g=c(85264);function h(a){return{default:a&&"default"in a?a.default:a}}let i={loader:()=>Promise.resolve(h(()=>null)),loading:null,ssr:!0},j=function(a){let b={...i,...a},c=(0,e.lazy)(()=>b.loader().then(h)),j=b.loading;function k(a){let h=j?(0,d.jsx)(j,{isLoading:!0,pastDelay:!0,error:null}):null,i=!b.ssr||!!b.loading,k=i?e.Suspense:e.Fragment,l=b.ssr?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.PreloadChunks,{moduleIds:b.modules}),(0,d.jsx)(c,{...a})]}):(0,d.jsx)(f.BailoutToCSR,{reason:"next/dynamic",children:(0,d.jsx)(c,{...a})});return(0,d.jsx)(k,{...i?{fallback:h}:{},children:l})}return k.displayName="LoadableComponent",k}},80099:a=>{"use strict";a.exports=require("node:sqlite")},81630:a=>{"use strict";a.exports=require("http")},81787:a=>{"use strict";a.exports=require("bun:sqlite")},85264:(a,b,c)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),Object.defineProperty(b,"PreloadChunks",{enumerable:!0,get:function(){return i}});let d=c(48249),e=c(74429),f=c(29294),g=c(10117),h=c(44217);function i({moduleIds:a}){let b=f.workAsyncStorage.getStore();if(void 0===b)return null;let c=[];if(b.reactLoadableManifest&&a){let d=b.reactLoadableManifest;for(let b of a){if(!d[b])continue;let a=d[b].files;c.push(...a)}}if(0===c.length)return null;let j=(0,h.getAssetTokenQuery)();return(0,d.jsx)(d.Fragment,{children:c.map(a=>{let c=`${b.assetPrefix}/_next/${(0,g.encodeURIPath)(a)}${j}`;return a.endsWith(".css")?(0,d.jsx)("link",{precedence:"dynamic",href:c,rel:"stylesheet",as:"style",nonce:b.nonce},a):((0,e.preload)(c,{as:"script",fetchPriority:"low",nonce:b.nonce}),null)})})}},87550:a=>{"use strict";a.exports=require("better-sqlite3")},87997:a=>{"use strict";a.exports=require("node:timers")},88453:(a,b,c)=>{"use strict";c.r(b),c.d(b,{__next_app__:()=>z,handler:()=>B,routeModule:()=>A});var d=c(21635),e=c(86315),f=c(1020),g=c(61287),h={};for(let a in g)0>["default","__next_app__","routeModule","handler"].indexOf(a)&&(h[a]=()=>g[a]);c.d(b,h);let i=(0,d.p)(()=>Promise.resolve().then(c.bind(c,57529))),j=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,95547,23))),k=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,55091,23))),l=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,45270,23))),m=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,28193,23))),n=(0,d.p)(()=>Promise.resolve().then(c.bind(c,79409))),o=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,95547,23))),p=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,55091,23))),q=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,45270,23))),r=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,28193,23))),s=(0,d.p)(()=>Promise.resolve().then(c.bind(c,79346))),t=(0,d.p)(()=>Promise.resolve().then(c.bind(c,70160))),u=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,95547,23))),v=(0,d.p)(()=>Promise.resolve().then(c.bind(c,55880))),w=(0,d.p)(()=>Promise.resolve().then(c.t.bind(c,95547,23))),x={children:["",{children:["(dashboard)",{children:["dashboard",{children:["settings",{children:["__PAGE__",{},{page:[(0,d.p)(()=>Promise.resolve().then(c.bind(c,74669))),"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/settings/page.js"]}]},{"global-error":[w,"next/dist/client/components/builtin/global-error.js"]},[]]},{error:[s,"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/error.js"],loading:[t,"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/loading.js"],"global-error":[u,"next/dist/client/components/builtin/global-error.js"],"not-found":[v,"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/dashboard/not-found.js"]},[]]},{layout:[n,"/home/runner/work/tokenhop/tokenhop/src/app/(dashboard)/layout.js"],"global-error":[o,"next/dist/client/components/builtin/global-error.js"],"not-found":[p,"next/dist/client/components/builtin/not-found.js"],forbidden:[q,"next/dist/client/components/builtin/forbidden.js"],unauthorized:[r,"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}},[]]},{layout:[i,"/home/runner/work/tokenhop/tokenhop/src/app/layout.js"],"global-error":[j,"next/dist/client/components/builtin/global-error.js"],"not-found":[k,"next/dist/client/components/builtin/not-found.js"],forbidden:[l,"next/dist/client/components/builtin/forbidden.js"],unauthorized:[m,"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}},[]]}.children,y=(0,e.H)({tree:x,page:"/(dashboard)/dashboard/settings/page",pathname:"/dashboard/settings",require:c,loadChunk:()=>Promise.resolve(),interopDefault:f.T}),z=y.__next_app__,A=y.routeModule,B=y.handler},89322:(a,b,c)=>{"use strict";function d({authMode:a,ssoType:b}={}){let c="sso"===a||"oidc"===a||"saml"===a,e=c||"both"===a,f="oidc"===a||"saml"===a?a:"saml"===b?"saml":"oidc";return{password:!c,oidc:e&&"oidc"===f,saml:e&&"saml"===f,protocol:f,ssoOnly:c}}c.d(b,{b:()=>d})},90314:(a,b,c)=>{"use strict";c.d(b,{default:()=>e.a});var d=c(39973),e=c.n(d)},91431:(a,b,c)=>{"use strict";c.d(b,{CP:()=>e,KC:()=>d.KC,Xg:()=>d.Xg,bs:()=>f});var d=c(66427);Object.entries(c(92592).Q2).filter(([,a])=>a.passthroughModels).map(([a])=>a),Object.entries(d.vq).flatMap(([a,b])=>b.map(b=>({provider:a,model:b.id,name:b.name})));let e=(a,b=null)=>a?.kind||a?.type||b,f={vision:{icon:"visibility",label:"Vision",desc:"Supports image input",color:"text-blue-500"},reasoning:{icon:"neurology",label:"Reasoning",desc:"Supports reasoning / thinking",color:"text-amber-500"}}},91645:a=>{"use strict";a.exports=require("net")},94735:a=>{"use strict";a.exports=require("events")},95514:(a,b,c)=>{"use strict";c.d(b,{default:()=>j});var d=c(48249),e=c(49885),f=c.n(e),g=c(67484),h=c(71404);let i={sm:"h-[26px] w-11",md:"h-[26px] w-11",lg:"h-7 w-12"};function j({checked:a=!1,onChange:b,label:c,description:e,disabled:f=!1,size:k="md",className:l,id:m,...n}){let o=(0,g.useId)(),p=m||o,q=`${p}-label`,r=`${p}-description`;if(!i[k])throw Error(`Toggle: unknown size "${k}"`);return(0,d.jsxs)("div",{className:(0,h.cn)("flex items-center gap-3",f&&"opacity-50",l),children:[(0,d.jsx)("button",{...n,id:p,type:"button",role:"switch","aria-checked":a,"aria-labelledby":c?q:n["aria-labelledby"],"aria-describedby":e?r:n["aria-describedby"],"aria-label":c?void 0:n["aria-label"]||n.title,disabled:f,onClick:()=>b?.(!a),className:(0,h.cn)("relative inline-flex shrink-0 rounded-full border border-line transition-colors duration-200","focus-visible:outline-none focus-visible:shadow-focus disabled:cursor-not-allowed","motion-reduce:transition-none",a?"bg-toggle-on":"bg-line",i[k]),children:(0,d.jsx)("span",{"aria-hidden":"true",className:(0,h.cn)("pointer-events-none absolute top-0.5 size-5 rounded-full shadow-sm transition-transform duration-200 motion-reduce:transition-none",a?"bg-toggle-knob-on translate-x-5 rtl:-translate-x-5":"bg-muted translate-x-0.5 rtl:-translate-x-0.5","start-0")})}),(c||e)&&(0,d.jsxs)("div",{className:"flex flex-col",children:[c&&(0,d.jsx)("label",{id:q,htmlFor:p,className:"text-sm font-medium text-text cursor-pointer",children:c}),e&&(0,d.jsx)("span",{id:r,className:"text-xs text-muted",children:e})]})]})}j.propTypes={checked:f().bool,onChange:f().func,label:f().node,description:f().node,disabled:f().bool,size:f().oneOf(Object.keys(i)),className:f().string,id:f().string,title:f().string,"aria-label":f().string}}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,8666,2430,2217,2116,6561,9421,7819,6070,1152,915,7642,4123,5649,1533,6244,6849,1320,8171,2592,6427,3919,5699],()=>b(b.s=88453));module.exports=c})();