@thangnm.nip/irouter 0.0.4 → 0.0.6

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 (280) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/app-path-routes-manifest.json +4 -4
  3. package/app/.next/build-manifest.json +2 -2
  4. package/app/.next/prerender-manifest.json +3 -3
  5. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  6. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/employees/[keyId]/page_client-reference-manifest.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/employees/page.js +2 -2
  10. package/app/.next/server/app/(dashboard)/dashboard/employees/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  26. package/app/.next/server/app/_global-error.html +1 -1
  27. package/app/.next/server/app/_global-error.rsc +1 -1
  28. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  29. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  30. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  31. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  32. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  33. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  34. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  35. package/app/.next/server/app/_not-found.html +1 -1
  36. package/app/.next/server/app/_not-found.rsc +5 -5
  37. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +5 -5
  38. package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  39. package/app/.next/server/app/_not-found.segments/_index.segment.rsc +4 -4
  40. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  41. package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  42. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  43. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  44. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +2 -2
  45. package/app/.next/server/app/api/cli-tools/claude-settings/route.js +1 -1
  46. package/app/.next/server/app/api/cli-tools/codex-settings/route.js +2 -2
  47. package/app/.next/server/app/api/cli-tools/copilot-settings/route.js +2 -2
  48. package/app/.next/server/app/api/cli-tools/droid-settings/route.js +1 -1
  49. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
  50. package/app/.next/server/app/api/cli-tools/opencode-settings/route.js +1 -1
  51. package/app/.next/server/app/api/employees/stats/route.js +1 -1
  52. package/app/.next/server/app/api/models/route.js +1 -1
  53. package/app/.next/server/app/api/provider-nodes/route.js +1 -1
  54. package/app/.next/server/app/api/providers/[id]/test-models/route.js +1 -1
  55. package/app/.next/server/app/api/providers/route.js +1 -1
  56. package/app/.next/server/app/api/providers/validate/route.js +1 -1
  57. package/app/.next/server/app/api/translator/console-logs/route.js +1 -1
  58. package/app/.next/server/app/api/translator/console-logs/stream/route.js +1 -1
  59. package/app/.next/server/app/api/usage/providers/route.js +1 -1
  60. package/app/.next/server/app/api/v1/models/route.js +1 -1
  61. package/app/.next/server/app/api/v1beta/models/route.js +1 -1
  62. package/app/.next/server/app/api/version/route.js +1 -1
  63. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  64. package/app/.next/server/app/callback.html +1 -1
  65. package/app/.next/server/app/callback.rsc +5 -5
  66. package/app/.next/server/app/callback.segments/_full.segment.rsc +5 -5
  67. package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
  68. package/app/.next/server/app/callback.segments/_index.segment.rsc +4 -4
  69. package/app/.next/server/app/callback.segments/_tree.segment.rsc +2 -2
  70. package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  71. package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
  72. package/app/.next/server/app/dashboard/cli-tools.html +1 -1
  73. package/app/.next/server/app/dashboard/cli-tools.rsc +7 -7
  74. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  75. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  76. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  77. package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  78. package/app/.next/server/app/dashboard/cli-tools.segments/_full.segment.rsc +7 -7
  79. package/app/.next/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  80. package/app/.next/server/app/dashboard/cli-tools.segments/_index.segment.rsc +4 -4
  81. package/app/.next/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +2 -2
  82. package/app/.next/server/app/dashboard/combos.html +1 -1
  83. package/app/.next/server/app/dashboard/combos.rsc +7 -7
  84. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  85. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  86. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  87. package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  88. package/app/.next/server/app/dashboard/combos.segments/_full.segment.rsc +7 -7
  89. package/app/.next/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  90. package/app/.next/server/app/dashboard/combos.segments/_index.segment.rsc +4 -4
  91. package/app/.next/server/app/dashboard/combos.segments/_tree.segment.rsc +2 -2
  92. package/app/.next/server/app/dashboard/employees.html +1 -1
  93. package/app/.next/server/app/dashboard/employees.rsc +7 -7
  94. package/app/.next/server/app/dashboard/employees.segments/!KGRhc2hib2FyZCk/dashboard/employees/__PAGE__.segment.rsc +2 -2
  95. package/app/.next/server/app/dashboard/employees.segments/!KGRhc2hib2FyZCk/dashboard/employees.segment.rsc +1 -1
  96. package/app/.next/server/app/dashboard/employees.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  97. package/app/.next/server/app/dashboard/employees.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  98. package/app/.next/server/app/dashboard/employees.segments/_full.segment.rsc +7 -7
  99. package/app/.next/server/app/dashboard/employees.segments/_head.segment.rsc +1 -1
  100. package/app/.next/server/app/dashboard/employees.segments/_index.segment.rsc +4 -4
  101. package/app/.next/server/app/dashboard/employees.segments/_tree.segment.rsc +2 -2
  102. package/app/.next/server/app/dashboard/endpoint.html +1 -1
  103. package/app/.next/server/app/dashboard/endpoint.rsc +7 -7
  104. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  105. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  106. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  107. package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  108. package/app/.next/server/app/dashboard/endpoint.segments/_full.segment.rsc +7 -7
  109. package/app/.next/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  110. package/app/.next/server/app/dashboard/endpoint.segments/_index.segment.rsc +4 -4
  111. package/app/.next/server/app/dashboard/endpoint.segments/_tree.segment.rsc +2 -2
  112. package/app/.next/server/app/dashboard/mitm.html +1 -1
  113. package/app/.next/server/app/dashboard/mitm.rsc +7 -7
  114. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  115. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  116. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  117. package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  118. package/app/.next/server/app/dashboard/mitm.segments/_full.segment.rsc +7 -7
  119. package/app/.next/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  120. package/app/.next/server/app/dashboard/mitm.segments/_index.segment.rsc +4 -4
  121. package/app/.next/server/app/dashboard/mitm.segments/_tree.segment.rsc +2 -2
  122. package/app/.next/server/app/dashboard/profile.html +1 -1
  123. package/app/.next/server/app/dashboard/profile.rsc +7 -7
  124. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  125. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  126. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  127. package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  128. package/app/.next/server/app/dashboard/profile.segments/_full.segment.rsc +7 -7
  129. package/app/.next/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  130. package/app/.next/server/app/dashboard/profile.segments/_index.segment.rsc +4 -4
  131. package/app/.next/server/app/dashboard/profile.segments/_tree.segment.rsc +2 -2
  132. package/app/.next/server/app/dashboard/providers/new.html +1 -1
  133. package/app/.next/server/app/dashboard/providers/new.rsc +7 -7
  134. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  135. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  136. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  137. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  138. package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  139. package/app/.next/server/app/dashboard/providers/new.segments/_full.segment.rsc +7 -7
  140. package/app/.next/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  141. package/app/.next/server/app/dashboard/providers/new.segments/_index.segment.rsc +4 -4
  142. package/app/.next/server/app/dashboard/providers/new.segments/_tree.segment.rsc +2 -2
  143. package/app/.next/server/app/dashboard/providers.html +1 -1
  144. package/app/.next/server/app/dashboard/providers.rsc +7 -7
  145. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  146. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  147. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  148. package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  149. package/app/.next/server/app/dashboard/providers.segments/_full.segment.rsc +7 -7
  150. package/app/.next/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  151. package/app/.next/server/app/dashboard/providers.segments/_index.segment.rsc +4 -4
  152. package/app/.next/server/app/dashboard/providers.segments/_tree.segment.rsc +2 -2
  153. package/app/.next/server/app/dashboard/proxy-pools.html +1 -1
  154. package/app/.next/server/app/dashboard/proxy-pools.rsc +7 -7
  155. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  156. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  157. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  158. package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  159. package/app/.next/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +7 -7
  160. package/app/.next/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  161. package/app/.next/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +4 -4
  162. package/app/.next/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +2 -2
  163. package/app/.next/server/app/dashboard/quota.html +2 -2
  164. package/app/.next/server/app/dashboard/quota.rsc +8 -8
  165. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  166. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  167. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  168. package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  169. package/app/.next/server/app/dashboard/quota.segments/_full.segment.rsc +8 -8
  170. package/app/.next/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  171. package/app/.next/server/app/dashboard/quota.segments/_index.segment.rsc +4 -4
  172. package/app/.next/server/app/dashboard/quota.segments/_tree.segment.rsc +2 -2
  173. package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  174. package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
  175. package/app/.next/server/app/dashboard/settings/pricing.rsc +5 -5
  176. package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +5 -5
  177. package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  178. package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
  179. package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
  180. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  181. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  182. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  183. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  184. package/app/.next/server/app/dashboard/translator.html +1 -1
  185. package/app/.next/server/app/dashboard/translator.rsc +7 -7
  186. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  187. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  188. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  189. package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  190. package/app/.next/server/app/dashboard/translator.segments/_full.segment.rsc +7 -7
  191. package/app/.next/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  192. package/app/.next/server/app/dashboard/translator.segments/_index.segment.rsc +4 -4
  193. package/app/.next/server/app/dashboard/translator.segments/_tree.segment.rsc +2 -2
  194. package/app/.next/server/app/dashboard/usage.html +1 -1
  195. package/app/.next/server/app/dashboard/usage.rsc +7 -7
  196. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  197. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  198. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  199. package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  200. package/app/.next/server/app/dashboard/usage.segments/_full.segment.rsc +7 -7
  201. package/app/.next/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  202. package/app/.next/server/app/dashboard/usage.segments/_index.segment.rsc +4 -4
  203. package/app/.next/server/app/dashboard/usage.segments/_tree.segment.rsc +2 -2
  204. package/app/.next/server/app/dashboard.html +1 -1
  205. package/app/.next/server/app/dashboard.rsc +6 -6
  206. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +1 -1
  207. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  208. package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  209. package/app/.next/server/app/dashboard.segments/_full.segment.rsc +6 -6
  210. package/app/.next/server/app/dashboard.segments/_head.segment.rsc +1 -1
  211. package/app/.next/server/app/dashboard.segments/_index.segment.rsc +4 -4
  212. package/app/.next/server/app/dashboard.segments/_tree.segment.rsc +2 -2
  213. package/app/.next/server/app/index.html +1 -1
  214. package/app/.next/server/app/index.rsc +5 -5
  215. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  216. package/app/.next/server/app/index.segments/_full.segment.rsc +5 -5
  217. package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
  218. package/app/.next/server/app/index.segments/_index.segment.rsc +4 -4
  219. package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  220. package/app/.next/server/app/landing/page.js +2 -2
  221. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  222. package/app/.next/server/app/landing.html +1 -1
  223. package/app/.next/server/app/landing.rsc +5 -5
  224. package/app/.next/server/app/landing.segments/_full.segment.rsc +5 -5
  225. package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
  226. package/app/.next/server/app/landing.segments/_index.segment.rsc +4 -4
  227. package/app/.next/server/app/landing.segments/_tree.segment.rsc +2 -2
  228. package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  229. package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
  230. package/app/.next/server/app/login/page.js +1 -1
  231. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  232. package/app/.next/server/app/login.html +1 -1
  233. package/app/.next/server/app/login.rsc +6 -6
  234. package/app/.next/server/app/login.segments/_full.segment.rsc +6 -6
  235. package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
  236. package/app/.next/server/app/login.segments/_index.segment.rsc +4 -4
  237. package/app/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  238. package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  239. package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
  240. package/app/.next/server/app/manifest.webmanifest/route.js +1 -1
  241. package/app/.next/server/app/manifest.webmanifest.body +1 -1
  242. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  243. package/app/.next/server/app-paths-manifest.json +4 -4
  244. package/app/.next/server/chunks/1424.js +1 -1
  245. package/app/.next/server/chunks/2664.js +1 -1
  246. package/app/.next/server/chunks/3093.js +1 -1
  247. package/app/.next/server/chunks/412.js +2 -2
  248. package/app/.next/server/chunks/4989.js +2 -2
  249. package/app/.next/server/chunks/5297.js +1 -1
  250. package/app/.next/server/chunks/5708.js +1 -1
  251. package/app/.next/server/chunks/6182.js +1 -1
  252. package/app/.next/server/chunks/649.js +2 -2
  253. package/app/.next/server/middleware-build-manifest.js +1 -1
  254. package/app/.next/server/pages/404.html +1 -1
  255. package/app/.next/server/pages/500.html +1 -1
  256. package/app/.next/server/server-reference-manifest.js +1 -1
  257. package/app/.next/server/server-reference-manifest.json +1 -1
  258. package/app/.next/static/chunks/{2652-47d84ce9c4da24cd.js → 2652-5d3ad13224961c58.js} +1 -1
  259. package/app/.next/static/chunks/5497-e27e4726f1346a2c.js +7 -0
  260. package/app/.next/static/chunks/7505-7bc93937f92f9117.js +1 -0
  261. package/app/.next/static/chunks/{9242-e979034a446994f6.js → 9242-b33771537db21368.js} +2 -2
  262. package/app/.next/static/chunks/app/(dashboard)/dashboard/employees/page-ddde5fb116c5e82f.js +1 -0
  263. package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/{page-88605a2347dee47b.js → page-e1e97af9d8b4d905.js} +1 -1
  264. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-91259a6310563c56.js → page-a6497b0cfbe0139a.js} +1 -1
  265. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/{page-b5a0564904ed5969.js → page-504ba05c48f68fd6.js} +1 -1
  266. package/app/.next/static/chunks/app/(dashboard)/{layout-ce060c64625acbdc.js → layout-a064f316272c9651.js} +1 -1
  267. package/app/.next/static/chunks/app/{layout-5f14b5ffaa464c15.js → layout-467d14e494472281.js} +1 -1
  268. package/app/.next/static/chunks/app/login/{page-5e162056267a89f6.js → page-3e6b223054acd213.js} +1 -1
  269. package/app/.next/static/css/5cdf9af08f4fc616.css +3 -0
  270. package/app/package.json +1 -1
  271. package/app/public/favicon.svg +2 -9
  272. package/app/public/icons/icon-192.svg +3 -3
  273. package/app/public/icons/icon-512.svg +3 -3
  274. package/package.json +1 -1
  275. package/app/.next/static/chunks/5497-95288063cad27087.js +0 -7
  276. package/app/.next/static/chunks/5909-8229484e56dff5af.js +0 -1
  277. package/app/.next/static/chunks/app/(dashboard)/dashboard/employees/page-ceaf0dc344eec2fe.js +0 -1
  278. package/app/.next/static/css/e83da33dd60e45a9.css +0 -3
  279. /package/app/.next/static/{kziRUh9x_T6WFTaeglA8u → 8g1QB1kGDsEVtVRXw9Gsv}/_buildManifest.js +0 -0
  280. /package/app/.next/static/{kziRUh9x_T6WFTaeglA8u → 8g1QB1kGDsEVtVRXw9Gsv}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9242],{3534:(e,t,s)=>{s.d(t,{dM:()=>a,wn:()=>l});let l={antigravity:{id:"antigravity",name:"Antigravity",image:"/providers/antigravity.png",color:"#4285F4",description:"Google Antigravity IDE with MITM",configType:"mitm",mitmDomain:"daily-cloudcode-pa.googleapis.com",modelAliases:["claude-opus-4-6-thinking","claude-sonnet-4-6","gemini-3-flash","gpt-oss-120b-medium","gemini-3-pro-high","gemini-3-pro-low"],defaultModels:[{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro High",alias:"gemini-3.1-pro-high"},{id:"gemini-3.1-pro-low",name:"Gemini 3.1 Pro Low",alias:"gemini-3.1-pro-low"},{id:"gemini-3-flash",name:"Gemini 3 Flash",alias:"gemini-3-flash"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"claude-sonnet-4-6"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",alias:"claude-opus-4-6-thinking"},{id:"gpt-oss-120b-medium",name:"GPT OSS 120B Medium",alias:"gpt-oss-120b-medium"}]},copilot:{id:"copilot",name:"GitHub Copilot",image:"/providers/copilot.png",color:"#1F6FEB",description:"GitHub Copilot IDE with MITM",configType:"mitm",mitmDomain:"api.individual.githubcopilot.com",modelAliases:["gpt-4o-mini","claude-haiku-4.5","gpt-4o","gpt-5-mini"],defaultModels:[{id:"gpt-4o",name:"GPT-4o",alias:"gpt-4o"},{id:"gpt-4.1",name:"GPT-4.1",alias:"gpt-4.1"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"}]},kiro:{id:"kiro",name:"Kiro",image:"/providers/kiro.png",color:"#FF6B00",description:"Kiro IDE with MITM",configType:"mitm",mitmDomain:"q.us-east-1.amazonaws.com",defaultModels:[{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",alias:"claude-sonnet-4.5"},{id:"claude-sonnet-4",name:"Claude Sonnet 4",alias:"claude-sonnet-4"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"},{id:"deepseek-3.2",name:"DeepSeek 3.2",alias:"deepseek-3.2"},{id:"minimax-m2.1",name:"MiniMax M2.1",alias:"minimax-m2.1"},{id:"simple-task",name:"Qwen3 Coder Next",alias:"simple-task"}]}},a={claude:{id:"claude",name:"Claude Code",icon:"terminal",color:"#D97757",description:"Anthropic Claude Code CLI",configType:"env",envVars:{baseUrl:"ANTHROPIC_BASE_URL",model:"ANTHROPIC_MODEL",opusModel:"ANTHROPIC_DEFAULT_OPUS_MODEL",sonnetModel:"ANTHROPIC_DEFAULT_SONNET_MODEL",haikuModel:"ANTHROPIC_DEFAULT_HAIKU_MODEL"},modelAliases:["default","sonnet","opus","haiku","opusplan"],settingsFile:"~/.claude/settings.json",defaultModels:[{id:"opus",name:"Claude Opus",alias:"opus",envKey:"ANTHROPIC_DEFAULT_OPUS_MODEL",defaultValue:"cc/claude-opus-4-6"},{id:"sonnet",name:"Claude Sonnet",alias:"sonnet",envKey:"ANTHROPIC_DEFAULT_SONNET_MODEL",defaultValue:"cc/claude-sonnet-4-6"},{id:"haiku",name:"Claude Haiku",alias:"haiku",envKey:"ANTHROPIC_DEFAULT_HAIKU_MODEL",defaultValue:"cc/claude-haiku-4-5-20251001"}]},openclaw:{id:"openclaw",name:"Open Claw",image:"/providers/openclaw.png",color:"#FF6B35",description:"Open Claw AI Assistant",configType:"custom"},codex:{id:"codex",name:"OpenAI Codex CLI",image:"/providers/codex.png",color:"#10A37F",description:"OpenAI Codex CLI",configType:"custom"},opencode:{id:"opencode",name:"OpenCode",image:"/providers/opencode.png",color:"#E87040",description:"OpenCode AI Terminal Assistant",configType:"custom"},droid:{id:"droid",name:"Factory Droid",image:"/providers/droid.png",color:"#00D4FF",description:"Factory Droid AI Assistant",configType:"custom"},cursor:{id:"cursor",name:"Cursor",image:"/providers/cursor.png",color:"#000000",description:"Cursor AI Code Editor",configType:"guide",requiresExternalUrl:!0,notes:[{type:"warning",text:"Requires Cursor Pro account to use this feature."},{type:"cloudCheck",text:"Cursor routes requests through its own server, so local endpoint is not supported. Please enable Tunnel or Cloud Endpoint in Settings."}],guideSteps:[{step:1,title:"Open Settings",desc:"Go to Settings → Models"},{step:2,title:"Enable OpenAI API",desc:'Enable "OpenAI API key" option'},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Add Custom Model",desc:'Click "View All Model" → "Add Custom Model"'},{step:6,title:"Select Model",type:"modelSelector"}]},cline:{id:"cline",name:"Cline",image:"/providers/cline.png",color:"#00D1B2",description:"Cline AI Coding Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Cline Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → OpenAI Compatible"},{step:3,title:"Base URL",value:"{{baseUrl}}/v1",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},kilo:{id:"kilo",name:"Kilo Code",image:"/providers/kilocode.png",color:"#FF6B6B",description:"Kilo Code AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Kilo Code Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → OpenAI Compatible"},{step:3,title:"Base URL",value:"{{baseUrl}}/v1",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},roo:{id:"roo",name:"Roo",image:"/providers/roo.png",color:"#FF6B6B",description:"Roo AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Roo Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → Ollama"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},continue:{id:"continue",name:"Continue",image:"/providers/continue.png",color:"#7C3AED",description:"Continue AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Config",desc:"Open Continue configuration file"},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Select Model",type:"modelSelector"},{step:4,title:"Add Model Config",desc:"Add the following configuration to your models array:"}],codeBlock:{language:"json",code:`{
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9242],{3534:(e,t,s)=>{s.d(t,{dM:()=>a,wn:()=>l});let l={antigravity:{id:"antigravity",name:"Antigravity",image:"/providers/antigravity.png",color:"#4285F4",description:"Google Antigravity IDE with MITM",configType:"mitm",mitmDomain:"daily-cloudcode-pa.googleapis.com",modelAliases:["claude-opus-4-6-thinking","claude-sonnet-4-6","gemini-3-flash","gpt-oss-120b-medium","gemini-3-pro-high","gemini-3-pro-low"],defaultModels:[{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro High",alias:"gemini-3.1-pro-high"},{id:"gemini-3.1-pro-low",name:"Gemini 3.1 Pro Low",alias:"gemini-3.1-pro-low"},{id:"gemini-3-flash",name:"Gemini 3 Flash",alias:"gemini-3-flash"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"claude-sonnet-4-6"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",alias:"claude-opus-4-6-thinking"},{id:"gpt-oss-120b-medium",name:"GPT OSS 120B Medium",alias:"gpt-oss-120b-medium"}]},copilot:{id:"copilot",name:"GitHub Copilot",image:"/providers/copilot.png",color:"#1F6FEB",description:"GitHub Copilot IDE with MITM",configType:"mitm",mitmDomain:"api.individual.githubcopilot.com",modelAliases:["gpt-4o-mini","claude-haiku-4.5","gpt-4o","gpt-5-mini"],defaultModels:[{id:"gpt-4o",name:"GPT-4o",alias:"gpt-4o"},{id:"gpt-4.1",name:"GPT-4.1",alias:"gpt-4.1"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"}]},kiro:{id:"kiro",name:"Kiro",image:"/providers/kiro.png",color:"#FF6B00",description:"Kiro IDE with MITM",configType:"mitm",mitmDomain:"q.us-east-1.amazonaws.com",defaultModels:[{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",alias:"claude-sonnet-4.5"},{id:"claude-sonnet-4",name:"Claude Sonnet 4",alias:"claude-sonnet-4"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"},{id:"deepseek-3.2",name:"DeepSeek 3.2",alias:"deepseek-3.2"},{id:"minimax-m2.1",name:"MiniMax M2.1",alias:"minimax-m2.1"},{id:"simple-task",name:"Qwen3 Coder Next",alias:"simple-task"}]}},a={claude:{id:"claude",name:"Claude Code",icon:"terminal",color:"#079A8B",description:"Anthropic Claude Code CLI",configType:"env",envVars:{baseUrl:"ANTHROPIC_BASE_URL",model:"ANTHROPIC_MODEL",opusModel:"ANTHROPIC_DEFAULT_OPUS_MODEL",sonnetModel:"ANTHROPIC_DEFAULT_SONNET_MODEL",haikuModel:"ANTHROPIC_DEFAULT_HAIKU_MODEL"},modelAliases:["default","sonnet","opus","haiku","opusplan"],settingsFile:"~/.claude/settings.json",defaultModels:[{id:"opus",name:"Claude Opus",alias:"opus",envKey:"ANTHROPIC_DEFAULT_OPUS_MODEL",defaultValue:"cc/claude-opus-4-6"},{id:"sonnet",name:"Claude Sonnet",alias:"sonnet",envKey:"ANTHROPIC_DEFAULT_SONNET_MODEL",defaultValue:"cc/claude-sonnet-4-6"},{id:"haiku",name:"Claude Haiku",alias:"haiku",envKey:"ANTHROPIC_DEFAULT_HAIKU_MODEL",defaultValue:"cc/claude-haiku-4-5-20251001"}]},openclaw:{id:"openclaw",name:"Open Claw",image:"/providers/openclaw.png",color:"#FF6B35",description:"Open Claw AI Assistant",configType:"custom"},codex:{id:"codex",name:"OpenAI Codex CLI",image:"/providers/codex.png",color:"#10A37F",description:"OpenAI Codex CLI",configType:"custom"},opencode:{id:"opencode",name:"OpenCode",image:"/providers/opencode.png",color:"#E87040",description:"OpenCode AI Terminal Assistant",configType:"custom"},droid:{id:"droid",name:"Factory Droid",image:"/providers/droid.png",color:"#00D4FF",description:"Factory Droid AI Assistant",configType:"custom"},cursor:{id:"cursor",name:"Cursor",image:"/providers/cursor.png",color:"#000000",description:"Cursor AI Code Editor",configType:"guide",requiresExternalUrl:!0,notes:[{type:"warning",text:"Requires Cursor Pro account to use this feature."},{type:"cloudCheck",text:"Cursor routes requests through its own server, so local endpoint is not supported. Please enable Tunnel or Cloud Endpoint in Settings."}],guideSteps:[{step:1,title:"Open Settings",desc:"Go to Settings → Models"},{step:2,title:"Enable OpenAI API",desc:'Enable "OpenAI API key" option'},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Add Custom Model",desc:'Click "View All Model" → "Add Custom Model"'},{step:6,title:"Select Model",type:"modelSelector"}]},cline:{id:"cline",name:"Cline",image:"/providers/cline.png",color:"#00D1B2",description:"Cline AI Coding Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Cline Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → OpenAI Compatible"},{step:3,title:"Base URL",value:"{{baseUrl}}/v1",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},kilo:{id:"kilo",name:"Kilo Code",image:"/providers/kilocode.png",color:"#FF6B6B",description:"Kilo Code AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Kilo Code Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → OpenAI Compatible"},{step:3,title:"Base URL",value:"{{baseUrl}}/v1",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},roo:{id:"roo",name:"Roo",image:"/providers/roo.png",color:"#FF6B6B",description:"Roo AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Roo Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → Ollama"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},continue:{id:"continue",name:"Continue",image:"/providers/continue.png",color:"#7C3AED",description:"Continue AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Config",desc:"Open Continue configuration file"},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Select Model",type:"modelSelector"},{step:4,title:"Add Model Config",desc:"Add the following configuration to your models array:"}],codeBlock:{language:"json",code:`{
2
2
  "apiBase": "{{baseUrl}}",
3
3
  "title": "{{model}}",
4
4
  "model": "{{model}}",
@@ -12,4 +12,4 @@ model_provider = "9router"
12
12
  name = "9Router"
13
13
  base_url = "${z()}"
14
14
  wire_api = "responses"
15
- `},{filename:"~/.codex/auth.json",content:JSON.stringify({OPENAI_API_KEY:h},null,2)}])})]})}let c=s(41463).env.NEXT_PUBLIC_CLOUD_URL;function x({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:m,cloudEnabled:p,initialStatus:u}){let h,g,f,y,[b,j]=(0,a.useState)(u||null),[N,v]=(0,a.useState)(!1),[w,k]=(0,a.useState)(!1),[C,S]=(0,a.useState)(!1),[_,A]=(0,a.useState)(null),[E,O]=(0,a.useState)(""),[I,P]=(0,a.useState)(""),[M,T]=(0,a.useState)(!1),[R,$]=(0,a.useState)({}),[L,K]=(0,a.useState)(!1),[U,D]=(0,a.useState)(""),F=(0,a.useRef)(!1),z=(()=>{if(!b?.installed)return null;let e=b.settings?.customModels?.find(e=>"custom:9Router-0"===e.id);if(!e)return"not_configured";let t=e.baseUrl?.includes("localhost")||e.baseUrl?.includes("127.0.0.1"),s=p&&c&&e.baseUrl?.startsWith(c),l=n&&e.baseUrl?.startsWith(n);return t||s||l?"configured":"other"})();(0,a.useEffect)(()=>{d?.length>0&&!E&&O(d[0].key)},[d,E]),(0,a.useEffect)(()=>{u&&j(u)},[u]),(0,a.useEffect)(()=>{t&&!b&&(B(),H()),t&&H()},[t]);let H=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&$(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(b?.installed&&!F.current){F.current=!0;let e=b.settings?.customModels?.find(e=>"custom:9Router-0"===e.id);e&&(e.model&&P(e.model),e.apiKey&&d?.some(t=>t.key===e.apiKey)&&O(e.apiKey))}},[b,d]);let B=async()=>{v(!0);try{let e=await fetch("/api/cli-tools/droid-settings"),t=await e.json();j(t)}catch(e){j({installed:!1,error:e.message})}finally{v(!1)}},q=()=>{let e=U||n;return e.endsWith("/v1")?e:`${e}/v1`},W=async()=>{k(!0),A(null);try{let e=E?.trim()||(d?.length>0?d[0].key:null)||(p?null:"sk_9router"),t=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:q(),apiKey:e,model:I})}),s=await t.json();t.ok?(A({type:"success",text:"Settings applied successfully!"}),B()):A({type:"error",text:s.error||"Failed to apply settings"})}catch(e){A({type:"error",text:e.message})}finally{k(!1)}},G=async()=>{S(!0),A(null);try{let e=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),t=await e.json();e.ok?(A({type:"success",text:"Settings reset successfully!"}),P(""),O(""),B()):A({type:"error",text:t.error||"Failed to reset settings"})}catch(e){A({type:"error",text:e.message})}finally{S(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:"/providers/droid.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===z&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===z&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===z&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[N&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!N&&b&&!b.installed&&(0,l.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Factory Droid CLI not installed"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Factory Droid CLI to use this feature."})]})]}),!N&&b?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[b?.settings?.customModels?.find(e=>"custom:9Router-0"===e.id)?.baseUrl&&(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:b.settings.customModels.find(e=>"custom:9Router-0"===e.id).baseUrl})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:(h=U||n).endsWith("/v1")?h:`${h}/v1`,onChange:e=>D(e.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),U&&U!==n&&(0,l.jsx)("button",{onClick:()=>D(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),d.length>0?(0,l.jsx)("select",{value:E,onChange:e=>O(e.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:d.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,l.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:p?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:I,onChange:e=>P(e.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>T(!0),disabled:!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),I&&(0,l.jsx)("button",{onClick:()=>P(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),_&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===_.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===_.type?"check_circle":"error"}),(0,l.jsx)("span",{children:_.text})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:W,disabled:!I,loading:w,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:G,disabled:!b?.has9Router,loading:C,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>K(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:M,onClose:()=>T(!1),onSelect:e=>{P(e.value),T(!1)},selectedModel:I,activeProviders:m,modelAliases:R,title:"Select Model for Factory Droid"}),(0,l.jsx)(r.uR,{isOpen:L,onClose:()=>K(!1),title:"Factory Droid - Manual Configuration",configs:(g=E&&E.trim()?E:p?"<API_KEY_FROM_DASHBOARD>":"sk_9router",f={customModels:[{model:I||"provider/model-id",id:"custom:9Router-0",index:0,baseUrl:q(),apiKey:g,displayName:I||"provider/model-id",maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}]},y="u">typeof navigator&&navigator.platform,[{filename:y?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(f,null,2)}])})]})}function m({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:x,initialStatus:p}){let u,h,[g,f]=(0,a.useState)(p||null),[y,b]=(0,a.useState)(!1),[j,N]=(0,a.useState)(!1),[v,w]=(0,a.useState)(!1),[k,C]=(0,a.useState)(null),[S,_]=(0,a.useState)(""),[A,E]=(0,a.useState)(""),[O,I]=(0,a.useState)(!1),[P,M]=(0,a.useState)({}),[T,R]=(0,a.useState)(!1),[$,L]=(0,a.useState)(""),K=(0,a.useRef)(!1),U=(()=>{if(!g?.installed)return null;let e=g.settings?.models?.providers?.["9router"];if(!e)return"not_configured";let t=e.baseUrl?.includes("localhost")||e.baseUrl?.includes("127.0.0.1")||e.baseUrl?.includes("0.0.0.0"),s=n&&e.baseUrl?.startsWith(n);return t||s?"configured":"other"})();(0,a.useEffect)(()=>{d?.length>0&&!S&&_(d[0].key)},[d,S]),(0,a.useEffect)(()=>{p&&f(p)},[p]),(0,a.useEffect)(()=>{t&&!g&&(F(),D()),t&&D()},[t]);let D=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&M(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(g?.installed&&!K.current){K.current=!0;let e=g.settings?.models?.providers?.["9router"];if(e){let t=g.settings?.agents?.defaults?.model?.primary;t&&E(t.replace("9router/","")),e.apiKey&&d?.some(t=>t.key===e.apiKey)&&_(e.apiKey)}}},[g,d]);let F=async()=>{b(!0);try{let e=await fetch("/api/cli-tools/openclaw-settings"),t=await e.json();f(t)}catch(e){f({installed:!1,error:e.message})}finally{b(!1)}},z=()=>window.location.origin.replace("://localhost","://127.0.0.1"),H=()=>{let e=$||z();return e.endsWith("/v1")?e:`${e}/v1`},B=async()=>{N(!0),C(null);try{let e=S?.trim()||(d?.length>0?d[0].key:null)||(x?null:"sk_9router"),t=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:H(),apiKey:e,model:A})}),s=await t.json();t.ok?(C({type:"success",text:"Settings applied successfully!"}),F()):C({type:"error",text:s.error||"Failed to apply settings"})}catch(e){C({type:"error",text:e.message})}finally{N(!1)}},q=async()=>{w(!0),C(null);try{let e=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),t=await e.json();e.ok?(C({type:"success",text:"Settings reset successfully!"}),E(""),_(""),F()):C({type:"error",text:t.error||"Failed to reset settings"})}catch(e){C({type:"error",text:e.message})}finally{w(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:"/providers/openclaw.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[y&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!y&&g&&!g.installed&&(0,l.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Open Claw CLI not installed"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Open Claw CLI to use this feature."})]})]}),!y&&g?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[g?.settings?.models?.providers?.["9router"]?.baseUrl&&(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:g.settings.models.providers["9router"].baseUrl})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:(u=$||z()).endsWith("/v1")?u:`${u}/v1`,onChange:e=>L(e.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),$&&$!==n&&(0,l.jsx)("button",{onClick:()=>L(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),d.length>0?(0,l.jsx)("select",{value:S,onChange:e=>_(e.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:d.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,l.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:x?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:A,onChange:e=>E(e.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>I(!0),disabled:!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),A&&(0,l.jsx)("button",{onClick:()=>E(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),k&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===k.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===k.type?"check_circle":"error"}),(0,l.jsx)("span",{children:k.text})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:B,disabled:!A,loading:j,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:q,disabled:!g?.has9Router,loading:v,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>R(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:O,onClose:()=>I(!1),onSelect:e=>{E(e.value),I(!1)},selectedModel:A,activeProviders:c,modelAliases:P,title:"Select Model for Open Claw"}),(0,l.jsx)(r.uR,{isOpen:T,onClose:()=>R(!1),title:"Open Claw - Manual Configuration",configs:(h=S&&S.trim()?S:x?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`9router/${A||"provider/model-id"}`}}},models:{providers:{"9router":{baseUrl:H(),apiKey:h,api:"openai-completions",models:[{id:A||"provider/model-id",name:(A||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}function p({toolId:e,tool:t,isExpanded:s,onToggle:n,baseUrl:o,apiKeys:d,activeProviders:c=[],cloudEnabled:x=!1,tunnelEnabled:m=!1}){let[u,h]=(0,a.useState)(null),[g,f]=(0,a.useState)(!1),[y,b]=(0,a.useState)(""),[j,N]=(0,a.useState)(()=>d?.length>0?d[0].key:""),v=e=>{let t=j&&j.trim()?j:x?"your-api-key":"sk_9router",s=o||"http://localhost:20128",l=s.endsWith("/v1")?s:`${s}/v1`;return e.replace(/\{\{baseUrl\}\}/g,l).replace(/\{\{apiKey\}\}/g,t).replace(/\{\{model\}\}/g,y||"provider/model-id")},w=async(e,t)=>{await navigator.clipboard.writeText(v(e)),h(t),setTimeout(()=>h(null),2e3)},k=c.length>0,C=()=>(!t.requiresExternalUrl||!!x||!!m)&&(!t.requiresCloud||!!x);return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:n,children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:t.image?(0,l.jsx)(i.default,{src:t.image,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}}):t.icon?(0,l.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:t.color},children:t.icon}):(0,l.jsx)(i.default,{src:`/providers/${e}.png`,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:t.name}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:t.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${s?"rotate-180":""}`,children:"expand_more"})]}),s&&(0,l.jsx)("div",{className:"mt-6 pt-6 border-t border-border",children:t.guideSteps?(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[t.notes&&0!==t.notes.length?(0,l.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:t.notes.map((e,t)=>{if("cloudCheck"===e.type&&(x||m))return null;let s="warning"===e.type,a="cloudCheck"===e.type&&!x&&!m,r="bg-blue-500/10 border-blue-500/30",i="text-blue-600 dark:text-blue-400",n="text-blue-500",o="info";return s?(r="bg-yellow-500/10 border-yellow-500/30",i="text-yellow-600 dark:text-yellow-400",n="text-yellow-500",o="warning"):a&&(r="bg-red-500/10 border-red-500/30",i="text-red-600 dark:text-red-400",n="text-red-500",o="error"),(0,l.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${r}`,children:[(0,l.jsx)("span",{className:`material-symbols-outlined text-lg ${n}`,children:o}),(0,l.jsx)("p",{className:`text-sm ${i}`,children:e.text})]},t)})}):null,C()&&t.guideSteps.map(e=>(0,l.jsxs)("div",{className:"flex items-start gap-4",children:[(0,l.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:t.color},children:e.step}),(0,l.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,l.jsx)("p",{className:"font-medium text-text",children:e.title}),e.desc&&(0,l.jsx)("p",{className:"text-sm text-text-muted mt-0.5",children:e.desc}),"apiKeySelector"===e.type&&(0,l.jsx)("div",{className:"mt-2 flex items-center gap-2",children:d&&d.length>0?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("select",{value:j,onChange:e=>N(e.target.value),className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:d.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}),(0,l.jsx)("button",{onClick:()=>w(j,"apiKey"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"apiKey"===u?"check":"content_copy"})})]}):(0,l.jsx)("span",{className:"text-sm text-text-muted",children:x?"No API keys - Create one in Keys page":"sk_9router"})}),"modelSelector"===e.type&&(0,l.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,l.jsx)("input",{type:"text",value:y,onChange:e=>b(e.target.value),placeholder:"provider/model-id",className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>f(!0),disabled:!k,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${k?"bg-bg-secondary border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),y&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{onClick:()=>w(y,"model"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"model"===u?"check":"content_copy"})}),(0,l.jsx)("button",{onClick:()=>b(""),className:"p-2 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]})]}),e.value&&(0,l.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,l.jsx)("code",{className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:v(e.value)}),e.copyable&&(0,l.jsx)("button",{onClick:()=>w(e.value,`${e.step}-${e.title}`),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:u===`${e.step}-${e.title}`?"check":"content_copy"})})]})]})]},e.step)),C()&&t.codeBlock&&(0,l.jsxs)("div",{className:"mt-2",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,l.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.codeBlock.language}),(0,l.jsxs)("button",{onClick:()=>w(t.codeBlock.code,"codeblock"),className:"flex items-center gap-1 px-2 py-1 text-xs bg-bg-secondary hover:bg-bg-tertiary rounded border border-border transition-colors",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-sm",children:"codeblock"===u?"check":"content_copy"}),"codeblock"===u?"Copied!":"Copy"]})]}),(0,l.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,l.jsx)("code",{className:"text-sm font-mono whitespace-pre",children:v(t.codeBlock.code)})})]})]}):(0,l.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),(0,l.jsx)(r.rq,{isOpen:g,onClose:()=>f(!1),onSelect:e=>{b(e.value)},selectedModel:y,activeProviders:c,title:"Select Model"})]})}function u({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:x}){let m,[p,h]=(0,a.useState)(x||null),[g,f]=(0,a.useState)(!1),[y,b]=(0,a.useState)(!1),[j,N]=(0,a.useState)(!1),[v,w]=(0,a.useState)(null),[k,C]=(0,a.useState)(!1),[S,_]=(0,a.useState)(""),[A,E]=(0,a.useState)(""),[O,I]=(0,a.useState)(!1),[P,M]=(0,a.useState)({}),[T,R]=(0,a.useState)(!1),[$,L]=(0,a.useState)("");(0,a.useEffect)(()=>{o?.length>0&&!S&&_(o[0].key)},[o,S]),(0,a.useEffect)(()=>{x&&h(x)},[x]),(0,a.useEffect)(()=>{t&&!p&&(F(),K()),t&&K()},[t]),(0,a.useEffect)(()=>{p?.config?.model?.startsWith("9router/")&&E(p.config.model.replace("9router/",""))},[p]);let K=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&M(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},U=(()=>{if(!p?.installed)return null;if(!p.config)return"not_configured";let e=p.config?.provider?.["9router"]?.options?.baseURL||"",t=e.includes("localhost")||e.includes("127.0.0.1");return p.has9Router&&(t||e.includes(n))?"configured":p.has9Router?"other":"not_configured"})(),D=()=>{let e=$||n;return e.endsWith("/v1")?e:`${e}/v1`},F=async()=>{f(!0);try{let e=await fetch("/api/cli-tools/opencode-settings"),t=await e.json();h(t)}catch(e){h({installed:!1,error:e.message})}finally{f(!1)}},z=async()=>{b(!0),w(null);try{let e=S&&S.trim()||c?S:"sk_9router",t=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:D(),apiKey:e,model:A})}),s=await t.json();t.ok?(w({type:"success",text:"Settings applied successfully!"}),F()):w({type:"error",text:s.error||"Failed to apply settings"})}catch(e){w({type:"error",text:e.message})}finally{b(!1)}},H=async()=>{N(!0),w(null);try{let e=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),t=await e.json();e.ok?(w({type:"success",text:"Settings reset successfully!"}),E(""),F()):w({type:"error",text:t.error||"Failed to reset settings"})}catch(e){w({type:"error",text:e.message})}finally{N(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:"/providers/opencode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[g&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!g&&p&&!p.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"OpenCode CLI not installed"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Please install OpenCode CLI to use auto-apply feature."})]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>C(!k),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:k?"expand_less":"help"}),k?"Hide":"How to Install"]})]}),k&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g opencode-ai"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!g&&p?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[p?.config?.provider?.["9router"]?.options?.baseURL&&(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:p.config.provider["9router"].options.baseURL})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:$||`${n}/v1`,onChange:e=>L(e.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),$&&$!==`${n}/v1`&&(0,l.jsx)("button",{onClick:()=>L(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),o.length>0?(0,l.jsx)("select",{value:S,onChange:e=>_(e.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:o.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,l.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:c?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:A,onChange:e=>E(e.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>I(!0),disabled:!d?.length,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),A&&(0,l.jsx)("button",{onClick:()=>E(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),v&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===v.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===v.type?"check_circle":"error"}),(0,l.jsx)("span",{children:v.text})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:z,disabled:!A,loading:y,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:H,disabled:!p.has9Router,loading:j,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>R(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:O,onClose:()=>I(!1),onSelect:e=>{E(e.value),I(!1)},selectedModel:A,activeProviders:d,modelAliases:P,title:"Select Model for OpenCode"}),(0,l.jsx)(r.uR,{isOpen:T,onClose:()=>R(!1),title:"OpenCode - Manual Configuration",configs:(m=S&&S.trim()?S:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{"9router":{npm:"@ai-sdk/openai-compatible",options:{baseURL:D(),apiKey:m},models:{[A||"provider/model-id"]:{name:A||"provider/model-id"}}}},model:`9router/${A||"provider/model-id"}`},null,2)}])})]})}function h({apiKeys:e,cloudEnabled:t,onStatusChange:s}){let[i,n]=(0,a.useState)(null),[o,d]=(0,a.useState)(!1),[c,x]=(0,a.useState)(!1),[m,p]=(0,a.useState)(""),[u,g]=(0,a.useState)(""),[f,y]=(0,a.useState)(null),[b,j]=(0,a.useState)(null),N="u">typeof navigator&&navigator.userAgent?.includes("Windows"),v=i?.isAdmin!==!1;(0,a.useEffect)(()=>{e?.length>0&&!u&&g(e[0].key)},[e,u]),(0,a.useEffect)(()=>{w()},[]);let w=async()=>{try{let e=await fetch("/api/cli-tools/antigravity-mitm");if(e.ok){let t=await e.json();n(t),s?.(t)}}catch{n({running:!1,certExists:!1,dnsStatus:{}})}},k=e=>{N||i?.hasCachedPassword?C(e,""):(j(e),x(!0),y(null))},C=async(s,l)=>{d(!0),y(null);try{if("trust-cert"===s){let e=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:l})}),t=await e.json();e.ok?y({type:"success",text:"Certificate trusted successfully"}):y({type:"error",text:t.error||"Failed to trust certificate"})}else if("start"===s){let s=u?.trim()||(e?.length>0?e[0].key:null)||(t?null:"sk_9router"),a=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:s,sudoPassword:l})}),r=await a.json();a.ok?y({type:"success",text:"Server started"}):y({type:"error",text:r.error||"Failed to start server"})}else{let e=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:l})}),t=await e.json();e.ok?y({type:"success",text:"Server stopped — all DNS cleared"}):y({type:"error",text:t.error||"Failed to stop server"})}x(!1),p(""),await w()}catch(e){y({type:"error",text:e.message})}finally{d(!1),j(null)}},S=()=>{m.trim()?C(b,m):y({type:"error",text:"Sudo password is required"})},_=i?.running;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(r.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"security"}),(0,l.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),_?(0,l.jsx)(r.Ex,{variant:"success",size:"sm",children:"Running"}):(0,l.jsx)(r.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,l.jsx)("div",{className:"flex items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:i?.certExists},{label:"Trusted",ok:i?.certTrusted},{label:"Server",ok:_}].map(({label:e,ok:t})=>(0,l.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${t?"text-green-600":"text-text-muted"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:t?"check_circle":"cancel"}),e]},e))})]}),(0,l.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,l.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from 9Router"]}),(0,l.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"How it works:"})," Antigravity/Copilot IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → 9Router → response to Antigravity/Copilot"]})]}),!_&&(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-xs text-text-muted shrink-0",children:"API Key"}),e?.length>0?(0,l.jsx)("select",{value:u,onChange:e=>g(e.target.value),className:"flex-1 px-2 py-1 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:e.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,l.jsx)("span",{className:"text-xs text-text-muted",children:t?"No API keys — create one in Keys page":"sk_9router (default)"})]}),f&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===f.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===f.type?"check_circle":"error"}),(0,l.jsx)("span",{children:f.text})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 flex-wrap","data-i18n-skip":"true",children:[i?.certExists&&!i?.certTrusted&&(0,l.jsxs)("button",{onClick:()=>k("trust-cert"),disabled:o,className:"px-4 py-1.5 rounded-lg bg-yellow-500/10 border border-yellow-500/30 text-yellow-600 font-medium text-xs flex items-center gap-1.5 hover:bg-yellow-500/20 transition-colors disabled:opacity-50",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"verified_user"}),"Trust Cert"]}),_?(0,l.jsxs)("button",{onClick:()=>k("stop"),disabled:o,className:"px-4 py-1.5 rounded-lg bg-red-500/10 border border-red-500/30 text-red-500 font-medium text-xs flex items-center gap-1.5 hover:bg-red-500/20 transition-colors disabled:opacity-50",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,l.jsxs)("button",{onClick:()=>k("start"),disabled:o||N&&!v,className:"px-4 py-1.5 rounded-lg bg-primary/10 border border-primary/30 text-primary font-medium text-xs flex items-center gap-1.5 hover:bg-primary/20 transition-colors disabled:opacity-50",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start Server"]}),_&&(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),N&&!v&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 border border-red-500/20",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"shield_lock"}),(0,l.jsx)("span",{children:"Administrator required — restart 9Router as Administrator to use MITM"})]})]})}),c&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,l.jsxs)("div",{className:"bg-surface border border-border rounded-xl p-6 w-full max-w-sm flex flex-col gap-4 shadow-xl",children:[(0,l.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,l.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,l.jsx)(r.pd,{type:"password",placeholder:"Enter sudo password",value:m,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"!==e.key||o||S()}}),f&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,l.jsx)("span",{children:f.text})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,l.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{x(!1),p(""),y(null)},disabled:o,children:"Cancel"}),(0,l.jsx)(r.$n,{variant:"primary",size:"sm",onClick:S,loading:o,children:"Confirm"})]})]})})]})}function g({tool:e,isExpanded:t,onToggle:s,serverRunning:n,dnsActive:o,hasCachedPassword:d,apiKeys:c,activeProviders:x,hasActiveProviders:m,modelAliases:p={},cloudEnabled:u,onDnsChange:h}){let[f,y]=(0,a.useState)(!1),[b,j]=(0,a.useState)(null),[N,v]=(0,a.useState)(!1),[w,k]=(0,a.useState)(""),[C,S]=(0,a.useState)(null),[_,A]=(0,a.useState)({}),[E,O]=(0,a.useState)(!1),[I,P]=(0,a.useState)(null),M="u">typeof navigator&&navigator.userAgent?.includes("Windows");(0,a.useEffect)(()=>{t&&T()},[t]);let T=async()=>{try{let t=await fetch(`/api/cli-tools/antigravity-mitm/alias?tool=${e.id}`);if(t.ok){let e=await t.json();Object.keys(e.aliases||{}).length>0&&A(e.aliases)}}catch{}},R=(0,a.useCallback)(async t=>{try{await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,mappings:t})})}catch{}},[e.id]),$=(e,t)=>{A(s=>({...s,[e]:t}))},L=()=>{if(!n)return;let e=o?"disable":"enable";M||d?K(e,""):(S(e),v(!0),j(null))},K=async(t,s)=>{y(!0),j(null);try{let l=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,action:t,sudoPassword:s})}),a=await l.json();if(!l.ok)throw Error(a.error||"Failed to toggle DNS");"enable"===t?j({type:"success",text:"DNS enabled successfully.",warning:`Please restart ${e.name} to apply changes.`}):j({type:"success",text:"DNS disabled — traffic restored"}),v(!1),k(""),h?.(a)}catch(e){j({type:"error",text:e.message})}finally{y(!1),S(null)}},U=()=>{w.trim()?K(C,w):j({type:"error",text:"Sudo password is required"})};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),n?o?(0,l.jsx)(r.Ex,{variant:"success",size:"sm",children:"Active"}):(0,l.jsx)(r.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,l.jsx)(r.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,l.jsxs)("p",{className:"text-xs text-text-muted",children:["Intercept ",e.name," requests via MITM proxy"]})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,l.jsxs)("p",{children:["Toggle DNS to redirect ",e.name," traffic through 9Router via MITM."]}),!o&&(0,l.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),b&&(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===b.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===b.type?"check_circle":"error"}),(0,l.jsx)("span",{children:b.text})]}),b.warning&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-amber-500/10 text-amber-600 border border-amber-500/20",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,l.jsx)("span",{className:"font-medium",children:b.warning})]})]}),e.defaultModels?.length>0&&(0,l.jsx)("div",{className:"flex flex-col gap-2",children:e.defaultModels.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-36 shrink-0 text-xs font-semibold text-text-main text-right",children:e.name}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:_[e.alias]||"",onChange:t=>$(e.alias,t.target.value),onBlur:t=>{var s,l;return s=e.alias,l=t.target.value,void R({..._,[s]:l})},placeholder:"provider/model-id",disabled:!o,className:`flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 ${!o?"opacity-50 cursor-not-allowed":""}`}),(0,l.jsx)("button",{onClick:()=>{P(e.alias),O(!0)},disabled:!m||!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 ${m&&o?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),_[e.alias]&&(0,l.jsx)("button",{onClick:()=>{$(e.alias,""),R({..._,[e.alias]:""})},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e.alias))}),e.defaultModels?.length===0&&(0,l.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."}),(0,l.jsx)("div",{children:o?(0,l.jsxs)("button",{onClick:L,disabled:!n||f,className:"px-4 py-1.5 rounded-lg bg-red-500/10 border border-red-500/30 text-red-500 font-medium text-xs flex items-center gap-1.5 hover:bg-red-500/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop DNS"]}):(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:L,loading:f,disabled:!n||f,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"play_circle"}),"Start DNS"]})})]})]}),N&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,l.jsxs)("div",{className:"bg-surface border border-border rounded-xl p-6 w-full max-w-sm flex flex-col gap-4 shadow-xl",children:[(0,l.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,l.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,l.jsx)(r.pd,{type:"password",placeholder:"Enter sudo password",value:w,onChange:e=>k(e.target.value),onKeyDown:e=>{"Enter"!==e.key||f||U()}}),b&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,l.jsx)("span",{children:b.text})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,l.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{v(!1),k(""),j(null)},disabled:f,children:"Cancel"}),(0,l.jsx)(r.$n,{variant:"primary",size:"sm",onClick:U,loading:f,children:"Confirm"})]})]})}),(0,l.jsx)(r.rq,{isOpen:E,onClose:()=>O(!1),onSelect:e=>{if(!I||e.isPlaceholder)return;let t={..._,[I]:e.value};A(t),R(t)},selectedModel:I?_[I]:null,activeProviders:x,modelAliases:p,title:`Select model for ${I}`})]})}}}]);
15
+ `},{filename:"~/.codex/auth.json",content:JSON.stringify({OPENAI_API_KEY:h},null,2)}])})]})}let c=s(41463).env.NEXT_PUBLIC_CLOUD_URL;function x({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:m,cloudEnabled:p,initialStatus:u}){let h,g,f,y,[b,j]=(0,a.useState)(u||null),[N,v]=(0,a.useState)(!1),[w,k]=(0,a.useState)(!1),[C,S]=(0,a.useState)(!1),[_,A]=(0,a.useState)(null),[E,O]=(0,a.useState)(""),[I,P]=(0,a.useState)(""),[M,T]=(0,a.useState)(!1),[R,$]=(0,a.useState)({}),[L,K]=(0,a.useState)(!1),[U,D]=(0,a.useState)(""),F=(0,a.useRef)(!1),z=(()=>{if(!b?.installed)return null;let e=b.settings?.customModels?.find(e=>"custom:9Router-0"===e.id);if(!e)return"not_configured";let t=e.baseUrl?.includes("localhost")||e.baseUrl?.includes("127.0.0.1"),s=p&&c&&e.baseUrl?.startsWith(c),l=n&&e.baseUrl?.startsWith(n);return t||s||l?"configured":"other"})();(0,a.useEffect)(()=>{d?.length>0&&!E&&O(d[0].key)},[d,E]),(0,a.useEffect)(()=>{u&&j(u)},[u]),(0,a.useEffect)(()=>{t&&!b&&(B(),H()),t&&H()},[t]);let H=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&$(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(b?.installed&&!F.current){F.current=!0;let e=b.settings?.customModels?.find(e=>"custom:9Router-0"===e.id);e&&(e.model&&P(e.model),e.apiKey&&d?.some(t=>t.key===e.apiKey)&&O(e.apiKey))}},[b,d]);let B=async()=>{v(!0);try{let e=await fetch("/api/cli-tools/droid-settings"),t=await e.json();j(t)}catch(e){j({installed:!1,error:e.message})}finally{v(!1)}},q=()=>{let e=U||n;return e.endsWith("/v1")?e:`${e}/v1`},W=async()=>{k(!0),A(null);try{let e=E?.trim()||(d?.length>0?d[0].key:null)||(p?null:"sk_9router"),t=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:q(),apiKey:e,model:I})}),s=await t.json();t.ok?(A({type:"success",text:"Settings applied successfully!"}),B()):A({type:"error",text:s.error||"Failed to apply settings"})}catch(e){A({type:"error",text:e.message})}finally{k(!1)}},G=async()=>{S(!0),A(null);try{let e=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),t=await e.json();e.ok?(A({type:"success",text:"Settings reset successfully!"}),P(""),O(""),B()):A({type:"error",text:t.error||"Failed to reset settings"})}catch(e){A({type:"error",text:e.message})}finally{S(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:"/providers/droid.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===z&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===z&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===z&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[N&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!N&&b&&!b.installed&&(0,l.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Factory Droid CLI not installed"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Factory Droid CLI to use this feature."})]})]}),!N&&b?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[b?.settings?.customModels?.find(e=>"custom:9Router-0"===e.id)?.baseUrl&&(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:b.settings.customModels.find(e=>"custom:9Router-0"===e.id).baseUrl})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:(h=U||n).endsWith("/v1")?h:`${h}/v1`,onChange:e=>D(e.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),U&&U!==n&&(0,l.jsx)("button",{onClick:()=>D(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),d.length>0?(0,l.jsx)("select",{value:E,onChange:e=>O(e.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:d.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,l.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:p?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:I,onChange:e=>P(e.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>T(!0),disabled:!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),I&&(0,l.jsx)("button",{onClick:()=>P(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),_&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===_.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===_.type?"check_circle":"error"}),(0,l.jsx)("span",{children:_.text})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:W,disabled:!I,loading:w,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:G,disabled:!b?.has9Router,loading:C,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>K(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:M,onClose:()=>T(!1),onSelect:e=>{P(e.value),T(!1)},selectedModel:I,activeProviders:m,modelAliases:R,title:"Select Model for Factory Droid"}),(0,l.jsx)(r.uR,{isOpen:L,onClose:()=>K(!1),title:"Factory Droid - Manual Configuration",configs:(g=E&&E.trim()?E:p?"<API_KEY_FROM_DASHBOARD>":"sk_9router",f={customModels:[{model:I||"provider/model-id",id:"custom:9Router-0",index:0,baseUrl:q(),apiKey:g,displayName:I||"provider/model-id",maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}]},y="u">typeof navigator&&navigator.platform,[{filename:y?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(f,null,2)}])})]})}function m({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:x,initialStatus:p}){let u,h,[g,f]=(0,a.useState)(p||null),[y,b]=(0,a.useState)(!1),[j,N]=(0,a.useState)(!1),[v,w]=(0,a.useState)(!1),[k,C]=(0,a.useState)(null),[S,_]=(0,a.useState)(""),[A,E]=(0,a.useState)(""),[O,I]=(0,a.useState)(!1),[P,M]=(0,a.useState)({}),[T,R]=(0,a.useState)(!1),[$,L]=(0,a.useState)(""),K=(0,a.useRef)(!1),U=(()=>{if(!g?.installed)return null;let e=g.settings?.models?.providers?.["9router"];if(!e)return"not_configured";let t=e.baseUrl?.includes("localhost")||e.baseUrl?.includes("127.0.0.1")||e.baseUrl?.includes("0.0.0.0"),s=n&&e.baseUrl?.startsWith(n);return t||s?"configured":"other"})();(0,a.useEffect)(()=>{d?.length>0&&!S&&_(d[0].key)},[d,S]),(0,a.useEffect)(()=>{p&&f(p)},[p]),(0,a.useEffect)(()=>{t&&!g&&(F(),D()),t&&D()},[t]);let D=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&M(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(g?.installed&&!K.current){K.current=!0;let e=g.settings?.models?.providers?.["9router"];if(e){let t=g.settings?.agents?.defaults?.model?.primary;t&&E(t.replace("9router/","")),e.apiKey&&d?.some(t=>t.key===e.apiKey)&&_(e.apiKey)}}},[g,d]);let F=async()=>{b(!0);try{let e=await fetch("/api/cli-tools/openclaw-settings"),t=await e.json();f(t)}catch(e){f({installed:!1,error:e.message})}finally{b(!1)}},z=()=>window.location.origin.replace("://localhost","://127.0.0.1"),H=()=>{let e=$||z();return e.endsWith("/v1")?e:`${e}/v1`},B=async()=>{N(!0),C(null);try{let e=S?.trim()||(d?.length>0?d[0].key:null)||(x?null:"sk_9router"),t=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:H(),apiKey:e,model:A})}),s=await t.json();t.ok?(C({type:"success",text:"Settings applied successfully!"}),F()):C({type:"error",text:s.error||"Failed to apply settings"})}catch(e){C({type:"error",text:e.message})}finally{N(!1)}},q=async()=>{w(!0),C(null);try{let e=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),t=await e.json();e.ok?(C({type:"success",text:"Settings reset successfully!"}),E(""),_(""),F()):C({type:"error",text:t.error||"Failed to reset settings"})}catch(e){C({type:"error",text:e.message})}finally{w(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:"/providers/openclaw.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[y&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!y&&g&&!g.installed&&(0,l.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Open Claw CLI not installed"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Open Claw CLI to use this feature."})]})]}),!y&&g?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[g?.settings?.models?.providers?.["9router"]?.baseUrl&&(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:g.settings.models.providers["9router"].baseUrl})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:(u=$||z()).endsWith("/v1")?u:`${u}/v1`,onChange:e=>L(e.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),$&&$!==n&&(0,l.jsx)("button",{onClick:()=>L(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),d.length>0?(0,l.jsx)("select",{value:S,onChange:e=>_(e.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:d.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,l.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:x?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:A,onChange:e=>E(e.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>I(!0),disabled:!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),A&&(0,l.jsx)("button",{onClick:()=>E(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),k&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===k.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===k.type?"check_circle":"error"}),(0,l.jsx)("span",{children:k.text})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:B,disabled:!A,loading:j,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:q,disabled:!g?.has9Router,loading:v,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>R(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:O,onClose:()=>I(!1),onSelect:e=>{E(e.value),I(!1)},selectedModel:A,activeProviders:c,modelAliases:P,title:"Select Model for Open Claw"}),(0,l.jsx)(r.uR,{isOpen:T,onClose:()=>R(!1),title:"Open Claw - Manual Configuration",configs:(h=S&&S.trim()?S:x?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`9router/${A||"provider/model-id"}`}}},models:{providers:{"9router":{baseUrl:H(),apiKey:h,api:"openai-completions",models:[{id:A||"provider/model-id",name:(A||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}function p({toolId:e,tool:t,isExpanded:s,onToggle:n,baseUrl:o,apiKeys:d,activeProviders:c=[],cloudEnabled:x=!1,tunnelEnabled:m=!1}){let[u,h]=(0,a.useState)(null),[g,f]=(0,a.useState)(!1),[y,b]=(0,a.useState)(""),[j,N]=(0,a.useState)(()=>d?.length>0?d[0].key:""),v=e=>{let t=j&&j.trim()?j:x?"your-api-key":"sk_9router",s=o||"http://localhost:20128",l=s.endsWith("/v1")?s:`${s}/v1`;return e.replace(/\{\{baseUrl\}\}/g,l).replace(/\{\{apiKey\}\}/g,t).replace(/\{\{model\}\}/g,y||"provider/model-id")},w=async(e,t)=>{await navigator.clipboard.writeText(v(e)),h(t),setTimeout(()=>h(null),2e3)},k=c.length>0,C=()=>(!t.requiresExternalUrl||!!x||!!m)&&(!t.requiresCloud||!!x);return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:n,children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:t.image?(0,l.jsx)(i.default,{src:t.image,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}}):t.icon?(0,l.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:t.color},children:t.icon}):(0,l.jsx)(i.default,{src:`/providers/${e}.png`,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:t.name}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:t.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${s?"rotate-180":""}`,children:"expand_more"})]}),s&&(0,l.jsx)("div",{className:"mt-6 pt-6 border-t border-border",children:t.guideSteps?(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[t.notes&&0!==t.notes.length?(0,l.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:t.notes.map((e,t)=>{if("cloudCheck"===e.type&&(x||m))return null;let s="warning"===e.type,a="cloudCheck"===e.type&&!x&&!m,r="bg-blue-500/10 border-blue-500/30",i="text-blue-600 dark:text-blue-400",n="text-blue-500",o="info";return s?(r="bg-yellow-500/10 border-yellow-500/30",i="text-yellow-600 dark:text-yellow-400",n="text-yellow-500",o="warning"):a&&(r="bg-red-500/10 border-red-500/30",i="text-red-600 dark:text-red-400",n="text-red-500",o="error"),(0,l.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${r}`,children:[(0,l.jsx)("span",{className:`material-symbols-outlined text-lg ${n}`,children:o}),(0,l.jsx)("p",{className:`text-sm ${i}`,children:e.text})]},t)})}):null,C()&&t.guideSteps.map(e=>(0,l.jsxs)("div",{className:"flex items-start gap-4",children:[(0,l.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:t.color},children:e.step}),(0,l.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,l.jsx)("p",{className:"font-medium text-text",children:e.title}),e.desc&&(0,l.jsx)("p",{className:"text-sm text-text-muted mt-0.5",children:e.desc}),"apiKeySelector"===e.type&&(0,l.jsx)("div",{className:"mt-2 flex items-center gap-2",children:d&&d.length>0?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("select",{value:j,onChange:e=>N(e.target.value),className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:d.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}),(0,l.jsx)("button",{onClick:()=>w(j,"apiKey"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"apiKey"===u?"check":"content_copy"})})]}):(0,l.jsx)("span",{className:"text-sm text-text-muted",children:x?"No API keys - Create one in Keys page":"sk_9router"})}),"modelSelector"===e.type&&(0,l.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,l.jsx)("input",{type:"text",value:y,onChange:e=>b(e.target.value),placeholder:"provider/model-id",className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>f(!0),disabled:!k,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${k?"bg-bg-secondary border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),y&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{onClick:()=>w(y,"model"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"model"===u?"check":"content_copy"})}),(0,l.jsx)("button",{onClick:()=>b(""),className:"p-2 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]})]}),e.value&&(0,l.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,l.jsx)("code",{className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:v(e.value)}),e.copyable&&(0,l.jsx)("button",{onClick:()=>w(e.value,`${e.step}-${e.title}`),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:u===`${e.step}-${e.title}`?"check":"content_copy"})})]})]})]},e.step)),C()&&t.codeBlock&&(0,l.jsxs)("div",{className:"mt-2",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,l.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.codeBlock.language}),(0,l.jsxs)("button",{onClick:()=>w(t.codeBlock.code,"codeblock"),className:"flex items-center gap-1 px-2 py-1 text-xs bg-bg-secondary hover:bg-bg-tertiary rounded border border-border transition-colors",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-sm",children:"codeblock"===u?"check":"content_copy"}),"codeblock"===u?"Copied!":"Copy"]})]}),(0,l.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,l.jsx)("code",{className:"text-sm font-mono whitespace-pre",children:v(t.codeBlock.code)})})]})]}):(0,l.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),(0,l.jsx)(r.rq,{isOpen:g,onClose:()=>f(!1),onSelect:e=>{b(e.value)},selectedModel:y,activeProviders:c,title:"Select Model"})]})}function u({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:x}){let m,[p,h]=(0,a.useState)(x||null),[g,f]=(0,a.useState)(!1),[y,b]=(0,a.useState)(!1),[j,N]=(0,a.useState)(!1),[v,w]=(0,a.useState)(null),[k,C]=(0,a.useState)(!1),[S,_]=(0,a.useState)(""),[A,E]=(0,a.useState)(""),[O,I]=(0,a.useState)(!1),[P,M]=(0,a.useState)({}),[T,R]=(0,a.useState)(!1),[$,L]=(0,a.useState)("");(0,a.useEffect)(()=>{o?.length>0&&!S&&_(o[0].key)},[o,S]),(0,a.useEffect)(()=>{x&&h(x)},[x]),(0,a.useEffect)(()=>{t&&!p&&(F(),K()),t&&K()},[t]),(0,a.useEffect)(()=>{p?.config?.model?.startsWith("9router/")&&E(p.config.model.replace("9router/",""))},[p]);let K=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&M(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},U=(()=>{if(!p?.installed)return null;if(!p.config)return"not_configured";let e=p.config?.provider?.["9router"]?.options?.baseURL||"",t=e.includes("localhost")||e.includes("127.0.0.1");return p.has9Router&&(t||e.includes(n))?"configured":p.has9Router?"other":"not_configured"})(),D=()=>{let e=$||n;return e.endsWith("/v1")?e:`${e}/v1`},F=async()=>{f(!0);try{let e=await fetch("/api/cli-tools/opencode-settings"),t=await e.json();h(t)}catch(e){h({installed:!1,error:e.message})}finally{f(!1)}},z=async()=>{b(!0),w(null);try{let e=S&&S.trim()||c?S:"sk_9router",t=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:D(),apiKey:e,model:A})}),s=await t.json();t.ok?(w({type:"success",text:"Settings applied successfully!"}),F()):w({type:"error",text:s.error||"Failed to apply settings"})}catch(e){w({type:"error",text:e.message})}finally{b(!1)}},H=async()=>{N(!0),w(null);try{let e=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),t=await e.json();e.ok?(w({type:"success",text:"Settings reset successfully!"}),E(""),F()):w({type:"error",text:t.error||"Failed to reset settings"})}catch(e){w({type:"error",text:e.message})}finally{N(!1)}};return(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:"/providers/opencode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===U&&(0,l.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,l.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[g&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!g&&p&&!p.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"OpenCode CLI not installed"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Please install OpenCode CLI to use auto-apply feature."})]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>C(!k),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:k?"expand_less":"help"}),k?"Hide":"How to Install"]})]}),k&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g opencode-ai"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!g&&p?.installed&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[p?.config?.provider?.["9router"]?.options?.baseURL&&(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Current"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("span",{className:"flex-1 px-2 py-1.5 text-xs text-text-muted truncate",children:p.config.provider["9router"].options.baseURL})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Base URL"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:$||`${n}/v1`,onChange:e=>L(e.target.value),placeholder:"https://.../v1",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),$&&$!==`${n}/v1`&&(0,l.jsx)("button",{onClick:()=>L(""),className:"p-1 text-text-muted hover:text-primary rounded transition-colors",title:"Reset to default",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"})})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"API Key"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),o.length>0?(0,l.jsx)("select",{value:S,onChange:e=>_(e.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:o.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,l.jsx)("span",{className:"flex-1 text-xs text-text-muted px-2 py-1.5",children:c?"No API keys - Create one in Keys page":"sk_9router (default)"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:A,onChange:e=>E(e.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>I(!0),disabled:!d?.length,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),A&&(0,l.jsx)("button",{onClick:()=>E(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),v&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===v.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===v.type?"check_circle":"error"}),(0,l.jsx)("span",{children:v.text})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:z,disabled:!A,loading:y,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:H,disabled:!p.has9Router,loading:j,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>R(!0),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:O,onClose:()=>I(!1),onSelect:e=>{E(e.value),I(!1)},selectedModel:A,activeProviders:d,modelAliases:P,title:"Select Model for OpenCode"}),(0,l.jsx)(r.uR,{isOpen:T,onClose:()=>R(!1),title:"OpenCode - Manual Configuration",configs:(m=S&&S.trim()?S:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{"9router":{npm:"@ai-sdk/openai-compatible",options:{baseURL:D(),apiKey:m},models:{[A||"provider/model-id"]:{name:A||"provider/model-id"}}}},model:`9router/${A||"provider/model-id"}`},null,2)}])})]})}function h({apiKeys:e,cloudEnabled:t,onStatusChange:s}){let[i,n]=(0,a.useState)(null),[o,d]=(0,a.useState)(!1),[c,x]=(0,a.useState)(!1),[m,p]=(0,a.useState)(""),[u,g]=(0,a.useState)(""),[f,y]=(0,a.useState)(null),[b,j]=(0,a.useState)(null),N="u">typeof navigator&&navigator.userAgent?.includes("Windows"),v=i?.isAdmin!==!1;(0,a.useEffect)(()=>{e?.length>0&&!u&&g(e[0].key)},[e,u]),(0,a.useEffect)(()=>{w()},[]);let w=async()=>{try{let e=await fetch("/api/cli-tools/antigravity-mitm");if(e.ok){let t=await e.json();n(t),s?.(t)}}catch{n({running:!1,certExists:!1,dnsStatus:{}})}},k=e=>{N||i?.hasCachedPassword?C(e,""):(j(e),x(!0),y(null))},C=async(s,l)=>{d(!0),y(null);try{if("trust-cert"===s){let e=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:l})}),t=await e.json();e.ok?y({type:"success",text:"Certificate trusted successfully"}):y({type:"error",text:t.error||"Failed to trust certificate"})}else if("start"===s){let s=u?.trim()||(e?.length>0?e[0].key:null)||(t?null:"sk_9router"),a=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:s,sudoPassword:l})}),r=await a.json();a.ok?y({type:"success",text:"Server started"}):y({type:"error",text:r.error||"Failed to start server"})}else{let e=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:l})}),t=await e.json();e.ok?y({type:"success",text:"Server stopped — all DNS cleared"}):y({type:"error",text:t.error||"Failed to stop server"})}x(!1),p(""),await w()}catch(e){y({type:"error",text:e.message})}finally{d(!1),j(null)}},S=()=>{m.trim()?C(b,m):y({type:"error",text:"Sudo password is required"})},_=i?.running;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(r.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"security"}),(0,l.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),_?(0,l.jsx)(r.Ex,{variant:"success",size:"sm",children:"Running"}):(0,l.jsx)(r.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,l.jsx)("div",{className:"flex items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:i?.certExists},{label:"Trusted",ok:i?.certTrusted},{label:"Server",ok:_}].map(({label:e,ok:t})=>(0,l.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${t?"text-green-600":"text-text-muted"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:t?"check_circle":"cancel"}),e]},e))})]}),(0,l.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,l.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from iRouter"]}),(0,l.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"How it works:"})," Antigravity/Copilot IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → iRouter → response to Antigravity/Copilot"]})]}),!_&&(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-xs text-text-muted shrink-0",children:"API Key"}),e?.length>0?(0,l.jsx)("select",{value:u,onChange:e=>g(e.target.value),className:"flex-1 px-2 py-1 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:e.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,l.jsx)("span",{className:"text-xs text-text-muted",children:t?"No API keys — create one in Keys page":"sk_9router (default)"})]}),f&&(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===f.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===f.type?"check_circle":"error"}),(0,l.jsx)("span",{children:f.text})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 flex-wrap","data-i18n-skip":"true",children:[i?.certExists&&!i?.certTrusted&&(0,l.jsxs)("button",{onClick:()=>k("trust-cert"),disabled:o,className:"px-4 py-1.5 rounded-lg bg-yellow-500/10 border border-yellow-500/30 text-yellow-600 font-medium text-xs flex items-center gap-1.5 hover:bg-yellow-500/20 transition-colors disabled:opacity-50",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"verified_user"}),"Trust Cert"]}),_?(0,l.jsxs)("button",{onClick:()=>k("stop"),disabled:o,className:"px-4 py-1.5 rounded-lg bg-red-500/10 border border-red-500/30 text-red-500 font-medium text-xs flex items-center gap-1.5 hover:bg-red-500/20 transition-colors disabled:opacity-50",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,l.jsxs)("button",{onClick:()=>k("start"),disabled:o||N&&!v,className:"px-4 py-1.5 rounded-lg bg-primary/10 border border-primary/30 text-primary font-medium text-xs flex items-center gap-1.5 hover:bg-primary/20 transition-colors disabled:opacity-50",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start Server"]}),_&&(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),N&&!v&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 border border-red-500/20",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"shield_lock"}),(0,l.jsx)("span",{children:"Administrator required — restart iRouter as Administrator to use MITM"})]})]})}),c&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,l.jsxs)("div",{className:"bg-surface border border-border rounded-xl p-6 w-full max-w-sm flex flex-col gap-4 shadow-xl",children:[(0,l.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,l.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,l.jsx)(r.pd,{type:"password",placeholder:"Enter sudo password",value:m,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"!==e.key||o||S()}}),f&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,l.jsx)("span",{children:f.text})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,l.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{x(!1),p(""),y(null)},disabled:o,children:"Cancel"}),(0,l.jsx)(r.$n,{variant:"primary",size:"sm",onClick:S,loading:o,children:"Confirm"})]})]})})]})}function g({tool:e,isExpanded:t,onToggle:s,serverRunning:n,dnsActive:o,hasCachedPassword:d,apiKeys:c,activeProviders:x,hasActiveProviders:m,modelAliases:p={},cloudEnabled:u,onDnsChange:h}){let[f,y]=(0,a.useState)(!1),[b,j]=(0,a.useState)(null),[N,v]=(0,a.useState)(!1),[w,k]=(0,a.useState)(""),[C,S]=(0,a.useState)(null),[_,A]=(0,a.useState)({}),[E,O]=(0,a.useState)(!1),[I,P]=(0,a.useState)(null),M="u">typeof navigator&&navigator.userAgent?.includes("Windows");(0,a.useEffect)(()=>{t&&T()},[t]);let T=async()=>{try{let t=await fetch(`/api/cli-tools/antigravity-mitm/alias?tool=${e.id}`);if(t.ok){let e=await t.json();Object.keys(e.aliases||{}).length>0&&A(e.aliases)}}catch{}},R=(0,a.useCallback)(async t=>{try{await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,mappings:t})})}catch{}},[e.id]),$=(e,t)=>{A(s=>({...s,[e]:t}))},L=()=>{if(!n)return;let e=o?"disable":"enable";M||d?K(e,""):(S(e),v(!0),j(null))},K=async(t,s)=>{y(!0),j(null);try{let l=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,action:t,sudoPassword:s})}),a=await l.json();if(!l.ok)throw Error(a.error||"Failed to toggle DNS");"enable"===t?j({type:"success",text:"DNS enabled successfully.",warning:`Please restart ${e.name} to apply changes.`}):j({type:"success",text:"DNS disabled — traffic restored"}),v(!1),k(""),h?.(a)}catch(e){j({type:"error",text:e.message})}finally{y(!1),S(null)}},U=()=>{w.trim()?K(C,w):j({type:"error",text:"Sudo password is required"})};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:s,children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,l.jsx)(i.default,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-medium text-sm",children:e.name}),n?o?(0,l.jsx)(r.Ex,{variant:"success",size:"sm",children:"Active"}):(0,l.jsx)(r.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,l.jsx)(r.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,l.jsxs)("p",{className:"text-xs text-text-muted",children:["Intercept ",e.name," requests via MITM proxy"]})]})]}),(0,l.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,l.jsxs)("p",{children:["Toggle DNS to redirect ",e.name," traffic through iRouter via MITM."]}),!o&&(0,l.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),b&&(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===b.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===b.type?"check_circle":"error"}),(0,l.jsx)("span",{children:b.text})]}),b.warning&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-amber-500/10 text-amber-600 border border-amber-500/20",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,l.jsx)("span",{className:"font-medium",children:b.warning})]})]}),e.defaultModels?.length>0&&(0,l.jsx)("div",{className:"flex flex-col gap-2",children:e.defaultModels.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-36 shrink-0 text-xs font-semibold text-text-main text-right",children:e.name}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:_[e.alias]||"",onChange:t=>$(e.alias,t.target.value),onBlur:t=>{var s,l;return s=e.alias,l=t.target.value,void R({..._,[s]:l})},placeholder:"provider/model-id",disabled:!o,className:`flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 ${!o?"opacity-50 cursor-not-allowed":""}`}),(0,l.jsx)("button",{onClick:()=>{P(e.alias),O(!0)},disabled:!m||!o,className:`px-2 py-1.5 rounded border text-xs transition-colors shrink-0 ${m&&o?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),_[e.alias]&&(0,l.jsx)("button",{onClick:()=>{$(e.alias,""),R({..._,[e.alias]:""})},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e.alias))}),e.defaultModels?.length===0&&(0,l.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."}),(0,l.jsx)("div",{children:o?(0,l.jsxs)("button",{onClick:L,disabled:!n||f,className:"px-4 py-1.5 rounded-lg bg-red-500/10 border border-red-500/30 text-red-500 font-medium text-xs flex items-center gap-1.5 hover:bg-red-500/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop DNS"]}):(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:L,loading:f,disabled:!n||f,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"play_circle"}),"Start DNS"]})})]})]}),N&&(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,l.jsxs)("div",{className:"bg-surface border border-border rounded-xl p-6 w-full max-w-sm flex flex-col gap-4 shadow-xl",children:[(0,l.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,l.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,l.jsx)(r.pd,{type:"password",placeholder:"Enter sudo password",value:w,onChange:e=>k(e.target.value),onKeyDown:e=>{"Enter"!==e.key||f||U()}}),b&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,l.jsx)("span",{children:b.text})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,l.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{v(!1),k(""),j(null)},disabled:f,children:"Cancel"}),(0,l.jsx)(r.$n,{variant:"primary",size:"sm",onClick:U,loading:f,children:"Confirm"})]})]})}),(0,l.jsx)(r.rq,{isOpen:E,onClose:()=>O(!1),onSelect:e=>{if(!I||e.isPlaceholder)return;let t={..._,[I]:e.value};A(t),R(t)},selectedModel:I?_[I]:null,activeProviders:x,modelAliases:p,title:`Select model for ${I}`})]})}}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7979],{52600:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>M});var r=s(95155),a=s(12115),l=s(73321),o=s(35497),i=s(84588),n=s(56061),c=s(14051),d=s.n(c),x=s(81750),m=s(6793);s(53255);var u=s(52679);function p({data:e}){let{label:t,color:s,imageUrl:l,textIcon:o,active:i}=e,[n,c]=(0,a.useState)(!1);return(0,r.jsxs)("div",{className:"flex items-center gap-2.5 px-4 py-2.5 rounded-lg border-2 transition-all duration-300 bg-bg",style:{borderColor:i?s:"var(--color-border)",boxShadow:i?`0 0 16px ${s}40`:"none",minWidth:"150px"},children:[(0,r.jsx)(x.h7,{type:"target",position:m.yX.Left,id:"left",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,r.jsx)("div",{className:"w-8 h-8 rounded-md flex items-center justify-center shrink-0",style:{backgroundColor:`${s}15`},children:n?(0,r.jsx)("span",{className:"text-sm font-bold",style:{color:s},children:o}):(0,r.jsx)("img",{src:l,alt:t,className:"w-6 h-6 rounded-sm object-contain",onError:()=>c(!0)})}),(0,r.jsx)("span",{className:"text-base font-medium truncate",style:{color:i?s:"var(--color-text)"},children:t}),i&&(0,r.jsxs)("span",{className:"relative flex h-2 w-2 shrink-0",children:[(0,r.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:s}}),(0,r.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2",style:{backgroundColor:s}})]})]})}function h({data:e}){let{label:t,active:s,color:a="#f59e0b"}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2.5 rounded-lg border-2 transition-all duration-300 bg-bg",style:{borderColor:s?a:"var(--color-border)",boxShadow:s?`0 0 12px ${a}40`:"none",minWidth:"120px"},children:[(0,r.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center shrink-0",style:{backgroundColor:`${a}15`},children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:s?a:"currentColor",style:{color:s?a:void 0},children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 5.25a3 3 0 013 3m3 0a6 6 0 01-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1121.75 8.25z"})})}),(0,r.jsx)("span",{className:"text-sm font-medium truncate",style:{color:s?a:"var(--color-text)"},children:t}),s&&(0,r.jsxs)("span",{className:"relative flex h-2 w-2 shrink-0",children:[(0,r.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:a}}),(0,r.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2",style:{backgroundColor:a}})]}),(0,r.jsx)(x.h7,{type:"source",position:m.yX.Right,id:"right",className:"!bg-transparent !border-0 !w-0 !h-0"})]})}function f({data:e}){return(0,r.jsxs)("div",{className:"flex items-center justify-center px-5 py-3 rounded-xl border-2 border-primary bg-primary/5 shadow-md min-w-[130px]",children:[(0,r.jsx)(x.h7,{type:"target",position:m.yX.Left,id:"left",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,r.jsx)(x.h7,{type:"source",position:m.yX.Right,id:"right",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,r.jsx)("img",{src:"/favicon.svg",alt:"iRouter",className:"w-6 h-6 mr-2"}),(0,r.jsx)("span",{className:"text-sm font-bold text-primary",children:"iRouter"}),e.activeCount>0&&(0,r.jsx)("span",{className:"ml-2 px-1.5 py-0.5 rounded-full bg-primary text-white text-xs font-bold",children:e.activeCount})]})}p.propTypes={data:d().object.isRequired},h.propTypes={data:d().object.isRequired},f.propTypes={data:d().object.isRequired};let g={provider:p,router:f,apikey:h};function b({providers:e=[],apiKeys:t=[],activeRequests:s=[],recentRequests:l=[],lastProvider:o="",errorProvider:i=""}){let n=(0,a.useMemo)(()=>s.map(e=>e.provider?.toLowerCase()).filter(Boolean).sort().join(","),[s]),c=o?.toLowerCase()||"",d=i?.toLowerCase()||"",m=(0,a.useMemo)(()=>new Set(n?n.split(","):[]),[n]),p=(0,a.useMemo)(()=>new Set(c?[c]:[]),[c]),h=(0,a.useMemo)(()=>new Set(d?[d]:[]),[d]),f=(0,a.useMemo)(()=>l.map(e=>`${e.keyName||""}:${e.provider||""}`).join(","),[l]),{nodes:y,edges:v}=(0,a.useMemo)(()=>(function(e,t,s,r,a,l){let o=e.length,i=t.length,n=[],c=[],d={},x={};for(let e of l){let t=e.keyName||"",s=e.provider?.toLowerCase()||"";t&&s&&(d[t]||(d[t]=new Set),d[t].add(s),x[s]||(x[s]=new Set),x[s].add(t))}let m=["#6366f1","#22c55e","#f59e0b","#ef4444","#ec4899","#06b6d4","#8b5cf6","#14b8a6"],p={};t.forEach((e,t)=>{p[e.name||e.key?.slice(0,12)]=m[t%m.length]}),n.push({id:"router",type:"router",position:{x:-65,y:-22},data:{activeCount:s.size},draggable:!1});let h=0-(i-1)*64/2;t.forEach((e,t)=>{let r=`apikey-${e.id}`,a=e.name||e.key?.slice(0,12)+"...",l=!!d[a],o=p[a]||"#6b7280",i=l&&s.size>0;n.push({id:r,type:"apikey",position:{x:-400,y:h+64*t-20},data:{label:a,active:i,color:o},draggable:!1}),c.push({id:`e-key-${r}`,source:r,sourceHandle:"right",target:"router",targetHandle:"left",animated:i,style:i?{stroke:o,strokeWidth:2.5,opacity:.9}:l?{stroke:o,strokeWidth:2,opacity:.7}:{stroke:"var(--color-border)",strokeWidth:1,opacity:.2}})});let f=0-(o-1)*64/2;return e.forEach((e,t)=>{var l,o;let i=(l=e.provider,u.Q2[l]||{color:"#6b7280",name:l}),d=s.has(e.provider?.toLowerCase()),m=!d&&r.has(e.provider?.toLowerCase()),h=!d&&a.has(e.provider?.toLowerCase()),g=`provider-${e.provider}`,b=x[e.provider?.toLowerCase()]||new Set,y=b.size>0,v="var(--color-border)",j=1,N=.2,k=!1;h?(v="#ef4444",j=2.5,N=.9):d?(v="#22c55e",j=2.5,N=.9,k=!0):y?(v=p[[...b][0]]||"#6366f1",j=2,N=.7):m&&(v="#f59e0b",j=2,N=.7),n.push({id:g,type:"provider",position:{x:230,y:f+64*t-20},data:{label:(i.name!==e.provider?i.name:null)||e.name||e.provider,color:i.color||"#6b7280",imageUrl:(o=e.provider,`/providers/${o}.png`),textIcon:i.textIcon||(e.provider||"?").slice(0,2).toUpperCase(),active:d||y},draggable:!1}),c.push({id:`e-prov-${g}`,source:"router",sourceHandle:"right",target:g,targetHandle:"left",animated:k,style:{stroke:v,strokeWidth:j,opacity:N}})}),{nodes:n,edges:c}})(e,t,m,p,h,l),[e,t,n,c,d,f]),j=(0,a.useMemo)(()=>e.map(e=>e.provider).sort().join(",")+"|"+t.map(e=>e.id).sort().join(","),[e,t]),N=(0,a.useRef)(null),k=(0,a.useCallback)(e=>{N.current=e,setTimeout(()=>e.fitView({padding:.25}),50)},[]);return(0,r.jsx)("div",{className:"w-full rounded-lg border border-border bg-bg-subtle/30",style:{height:480},children:0===e.length&&0===t.length?(0,r.jsx)("div",{className:"h-full flex items-center justify-center text-text-muted text-sm",children:"No providers or API keys configured"}):(0,r.jsx)(x.Gc,{nodes:y,edges:v,nodeTypes:g,fitView:!0,fitViewOptions:{padding:.25},onInit:k,proOptions:{hideAttribution:!0},panOnDrag:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,preventScrolling:!1,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1},j)})}b.propTypes={providers:d().arrayOf(d().shape({id:d().string,provider:d().string,name:d().string})),apiKeys:d().arrayOf(d().shape({id:d().string,name:d().string,key:d().string})),activeRequests:d().arrayOf(d().shape({provider:d().string,model:d().string})),recentRequests:d().array,lastProvider:d().string,errorProvider:d().string};var y=s(10124),v=s(1728),j=s(48035),N=s(28408),k=s(32539),w=s(59656),C=s(58021),S=s(61567),q=s(67389);let $=["#079A8B","#F57C00","#3B82F6","#EF4444","#8B5CF6","#EC4899","#22C55E","#F59E0B"],R=e=>new Intl.NumberFormat().format(e||0),T=e=>`$${(e||0).toFixed(2)}`;function L({timestamp:e}){let t,[,s]=(0,a.useState)(0);return(0,a.useEffect)(()=>{let e=setInterval(()=>s(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,r.jsx)(r.Fragment,{children:(t=Math.floor((Date.now()-new Date(e))/1e3))<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`})}function O({requests:e=[]}){return(0,r.jsxs)(i.default,{className:"flex flex-col overflow-hidden",padding:"sm",style:{height:480},children:[(0,r.jsx)("div",{className:"px-1 py-2 border-b border-border shrink-0",children:(0,r.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Recent Requests"})}),e.length?(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,r.jsxs)("table",{className:"w-full text-xs border-collapse",children:[(0,r.jsx)("thead",{className:"sticky top-0 bg-bg z-10",children:(0,r.jsxs)("tr",{className:"border-b border-border",children:[(0,r.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted w-2"}),(0,r.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted",children:"Model"}),(0,r.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted",children:"API Key"}),(0,r.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted whitespace-nowrap",children:"In / Out"}),(0,r.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted",children:"When"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-border/50",children:e.map((e,t)=>{let s=!e.status||"ok"===e.status||"success"===e.status;return(0,r.jsxs)("tr",{className:"hover:bg-bg-subtle transition-colors",children:[(0,r.jsx)("td",{className:"py-1.5",children:(0,r.jsx)("span",{className:`block w-1.5 h-1.5 rounded-full ${s?"bg-success":"bg-error"}`})}),(0,r.jsx)("td",{className:"py-1.5 font-mono truncate max-w-[120px]",title:e.model,children:e.model}),(0,r.jsx)("td",{className:"py-1.5 truncate max-w-[100px] text-text-muted",title:e.keyName,children:e.keyName||"—"}),(0,r.jsxs)("td",{className:"py-1.5 text-right whitespace-nowrap",children:[(0,r.jsxs)("span",{className:"text-primary",children:[R(e.promptTokens),"↑"]})," ",(0,r.jsxs)("span",{className:"text-success",children:[R(e.completionTokens),"↓"]})]}),(0,r.jsx)("td",{className:"py-1.5 text-right text-text-muted whitespace-nowrap",children:(0,r.jsx)(L,{timestamp:e.timestamp})})]},t)})})]})}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-text-muted text-sm",children:"No requests yet."})]})}let D=[{value:"24h",label:"24h"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"60d",label:"60D"}];function E(){let[e,t]=(0,a.useState)(null),[s,l]=(0,a.useState)(!0),[o,n]=(0,a.useState)("7d"),[c,d]=(0,a.useState)("cost"),[x,m]=(0,a.useState)([]),[u,p]=(0,a.useState)([]),[h,f]=(0,a.useState)([]),[g,L]=(0,a.useState)([]),[E,F]=(0,a.useState)({activeRequests:[],recentRequests:[],errorProvider:""}),z=(0,a.useCallback)(async()=>{l(!0);try{let[e,s]=await Promise.all([fetch(`/api/employees/stats?period=${o}`),fetch(`/api/usage/stats?period=${o}`)]);if(e.ok){let s=await e.json();t(s)}if(s.ok){let e=await s.json(),t=e.byAccount||{},r={};for(let e of Object.values(t)){let t=e.accountName||"Unknown";r[t]||(r[t]={name:t,requests:0,cost:0,tokens:0}),r[t].requests+=e.requests||0,r[t].cost+=e.cost||0,r[t].tokens+=(e.promptTokens||0)+(e.completionTokens||0)}m(Object.values(r).sort((e,t)=>t.requests-e.requests));let a=e.byModel||{},l=Object.values(a).map(e=>({name:e.rawModel||"Unknown",provider:e.provider||"",requests:e.requests||0,cost:e.cost||0,tokens:(e.promptTokens||0)+(e.completionTokens||0)})),o={};for(let e of l)o[e.name]||(o[e.name]={name:e.name,requests:0,cost:0,tokens:0}),o[e.name].requests+=e.requests,o[e.name].cost+=e.cost,o[e.name].tokens+=e.tokens;p(Object.values(o).sort((e,t)=>t.requests-e.requests))}}catch(e){console.error("Failed to fetch stats:",e)}finally{l(!1)}},[o]);(0,a.useEffect)(()=>{z()},[z]),(0,a.useEffect)(()=>{fetch("/api/providers").then(e=>e.ok?e.json():null).then(e=>{if(!e?.connections)return;let t=new Set;f(e.connections.filter(e=>!t.has(e.provider)&&(t.add(e.provider),!0)))}).catch(()=>{}),fetch("/api/keys").then(e=>e.ok?e.json():null).then(e=>{e?.keys&&L(e.keys)}).catch(()=>{}),fetch("/api/usage/stats?period=7d").then(e=>e.ok?e.json():null).then(e=>{e&&F({activeRequests:e.activeRequests||[],recentRequests:e.recentRequests||[],errorProvider:e.errorProvider||""})}).catch(()=>{})},[]),(0,a.useEffect)(()=>{let e=new EventSource("/api/usage/stream");return e.onmessage=e=>{try{let t=JSON.parse(e.data);F({activeRequests:t.activeRequests||[],recentRequests:t.recentRequests||[],errorProvider:t.errorProvider||""})}catch(e){console.error("[SSE CLIENT] parse error:",e)}},e.onerror=()=>{},()=>e.close()},[]);let A=(0,a.useMemo)(()=>e?.employees?[...e.employees].filter(e=>"cost"===c?e.totalCost>0:e.totalTokens>0).sort((e,t)=>"cost"===c?t.totalCost-e.totalCost:t.totalTokens-e.totalTokens).slice(0,10).map(e=>({name:e.name?.length>12?e.name.slice(0,12)+"…":e.name,fullName:e.name,value:"cost"===c?e.totalCost:e.totalTokens})):[],[e,c]);if(s)return(0,r.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] animate-spin",children:"progress_activity"})});if(!e)return(0,r.jsx)("div",{className:"text-text-muted text-center py-12",children:"Failed to load employee data."});let{summary:P}=e;return(0,r.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,r.jsx)("div",{className:"flex items-center gap-2 self-end",children:(0,r.jsx)("div",{className:"flex items-center gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:D.map(e=>(0,r.jsx)("button",{onClick:()=>n(e.value),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${o===e.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:e.label},e.value))})}),(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,r.jsxs)(i.default,{className:"px-4 py-3 flex flex-col gap-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Employees"}),(0,r.jsx)("span",{className:"text-2xl font-bold",children:R(P.totalEmployees)}),(0,r.jsxs)("span",{className:"text-xs text-text-muted",children:[R(P.activeEmployees)," active"]})]}),(0,r.jsxs)(i.default,{className:"px-4 py-3 flex flex-col gap-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Requests"}),(0,r.jsx)("span",{className:"text-2xl font-bold text-primary",children:R(P.totalRequests)})]}),(0,r.jsxs)(i.default,{className:"px-4 py-3 flex flex-col gap-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Cost"}),(0,r.jsxs)("span",{className:"text-2xl font-bold text-warning",children:["~",T(P.totalCost)]})]}),(0,r.jsxs)(i.default,{className:"px-4 py-3 flex flex-col gap-1",children:[(0,r.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Top Spender"}),(0,r.jsx)("span",{className:"text-2xl font-bold truncate",children:P.topSpender?.name||"—"}),(0,r.jsx)("span",{className:"text-xs text-text-muted",children:P.topSpender?T(P.topSpender.cost):"—"})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-[2fr_1fr] gap-2 items-stretch",children:[(0,r.jsx)(b,{providers:h,apiKeys:g,activeRequests:E.activeRequests,recentRequests:E.recentRequests,lastProvider:E.recentRequests?.[0]?.provider||"",errorProvider:E.errorProvider}),(0,r.jsx)(O,{requests:E.recentRequests})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_2fr] gap-4",children:[(0,r.jsxs)(i.default,{className:"p-4 flex flex-col gap-3",children:[(0,r.jsx)("h3",{className:"font-semibold text-sm text-text-muted uppercase",children:"By Model"}),u.length>0?(0,r.jsx)(v.u,{width:"100%",height:250,children:(0,r.jsxs)(j.E,{data:u.slice(0,8).map(e=>({name:e.name?.length>14?e.name.slice(0,14)+"…":e.name,fullName:e.name,requests:e.requests})),layout:"vertical",margin:{top:0,right:8,left:0,bottom:0},children:[(0,r.jsx)(N.d,{strokeDasharray:"3 3",strokeOpacity:.1,horizontal:!1}),(0,r.jsx)(k.W,{type:"number",tick:{fontSize:10,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(0)}K`:e}),(0,r.jsx)(w.h,{type:"category",dataKey:"name",tick:{fontSize:10,fill:"currentColor",fillOpacity:.6},tickLine:!1,axisLine:!1,width:100}),(0,r.jsx)(C.m,{cursor:!1,contentStyle:{backgroundColor:"var(--color-bg)",border:"1px solid var(--color-border)",borderRadius:"8px",fontSize:"12px"},formatter:e=>[R(e),"Requests"],labelFormatter:(e,t)=>t?.[0]?.payload?.fullName||e}),(0,r.jsx)(S.yP,{dataKey:"requests",radius:[0,4,4,0],maxBarSize:24,children:u.slice(0,8).map((e,t)=>(0,r.jsx)(q.f,{fill:$[t%$.length]},t))})]})}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-text-muted text-sm h-[250px]",children:"No data"})]}),A.length>0?(0,r.jsxs)(i.default,{className:"p-4 flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h3",{className:"font-semibold text-sm text-text-muted uppercase",children:"Employee Comparison"}),(0,r.jsxs)("div",{className:"flex items-center gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:[(0,r.jsx)("button",{onClick:()=>d("cost"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"cost"===c?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Cost"}),(0,r.jsx)("button",{onClick:()=>d("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===c?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"})]})]}),(0,r.jsx)(v.u,{width:"100%",height:250,children:(0,r.jsxs)(j.E,{data:A,margin:{top:4,right:8,left:0,bottom:0},children:[(0,r.jsx)(N.d,{strokeDasharray:"3 3",strokeOpacity:.1}),(0,r.jsx)(k.W,{dataKey:"name",tick:{fontSize:11,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1}),(0,r.jsx)(w.h,{tick:{fontSize:10,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1,tickFormatter:"cost"===c?e=>`$${e.toFixed(2)}`:e=>e>=1e3?`${(e/1e3).toFixed(0)}K`:e,width:55}),(0,r.jsx)(C.m,{cursor:!1,contentStyle:{backgroundColor:"var(--color-bg)",border:"1px solid var(--color-border)",borderRadius:"8px",fontSize:"12px"},formatter:e=>["cost"===c?`$${e.toFixed(4)}`:R(e),"cost"===c?"Cost":"Tokens"],labelFormatter:(e,t)=>t?.[0]?.payload?.fullName||e}),(0,r.jsx)(S.yP,{dataKey:"value",radius:[4,4,0,0],maxBarSize:40,children:A.map((e,t)=>(0,r.jsx)(q.f,{fill:$[t%$.length]},t))})]})})]}):(0,r.jsx)(i.default,{className:"p-4 flex items-center justify-center text-text-muted text-sm h-full",children:"No employee data"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-[2fr_1fr] gap-4",children:[(0,r.jsx)(y.A,{period:o}),(0,r.jsxs)(i.default,{className:"p-4 flex flex-col gap-3",children:[(0,r.jsx)("h3",{className:"font-semibold text-sm text-text-muted uppercase",children:"By Account"}),x.length>0?(0,r.jsx)(v.u,{width:"100%",height:200,children:(0,r.jsxs)(j.E,{data:x.slice(0,8).map(e=>({name:e.name?.length>12?e.name.slice(0,12)+"…":e.name,fullName:e.name,requests:e.requests})),layout:"vertical",margin:{top:0,right:8,left:0,bottom:0},children:[(0,r.jsx)(N.d,{strokeDasharray:"3 3",strokeOpacity:.1,horizontal:!1}),(0,r.jsx)(k.W,{type:"number",tick:{fontSize:10,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(0)}K`:e}),(0,r.jsx)(w.h,{type:"category",dataKey:"name",tick:{fontSize:11,fill:"currentColor",fillOpacity:.6},tickLine:!1,axisLine:!1,width:90}),(0,r.jsx)(C.m,{cursor:!1,contentStyle:{backgroundColor:"var(--color-bg)",border:"1px solid var(--color-border)",borderRadius:"8px",fontSize:"12px"},formatter:e=>[R(e),"Requests"],labelFormatter:(e,t)=>t?.[0]?.payload?.fullName||e}),(0,r.jsx)(S.yP,{dataKey:"requests",radius:[0,4,4,0],maxBarSize:24,children:x.slice(0,8).map((e,t)=>(0,r.jsx)(q.f,{fill:$[t%$.length]},t))})]})}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center text-text-muted text-sm h-[200px]",children:"No data"})]})]})]})}let F=e=>new Intl.NumberFormat().format(e||0),z=[{value:"24h",label:"24h"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"60d",label:"60D"}],A=[{key:"name",label:"Employee",align:"left"},{key:"isActive",label:"Status",align:"center"},{key:"totalRequests",label:"Requests",align:"right"},{key:"totalPromptTokens",label:"Input Tokens",align:"right"},{key:"totalCompletionTokens",label:"Output Tokens",align:"right"},{key:"totalTokens",label:"Total Tokens",align:"right"},{key:"totalCost",label:"Cost",align:"right"},{key:"modelsUsed",label:"Models",align:"right"},{key:"lastActive",label:"Last Active",align:"right"},{key:"apiKey",label:"API Key",align:"center",sortable:!1}];function P(){let e=(0,l.useRouter)(),[t,s]=(0,a.useState)("7d"),[o,c]=(0,a.useState)(null),[d,x]=(0,a.useState)(!0),[m,u]=(0,a.useState)(""),[p,h]=(0,a.useState)("lastActive"),[f,g]=(0,a.useState)("desc"),b=(0,a.useCallback)(async()=>{x(!0);try{let e=await fetch(`/api/employees/stats?period=${t}`);if(e.ok){let t=await e.json();c(t)}}catch(e){console.error("Failed to fetch:",e)}finally{x(!1)}},[t]);(0,a.useEffect)(()=>{b()},[b]);let y=o?.employees||[],v=(0,a.useMemo)(()=>(m?y.filter(e=>e.name?.toLowerCase().includes(m.toLowerCase())):[...y]).sort((e,t)=>{let s=e[p],r=t[p];return("name"===p?(s=(s||"").toLowerCase(),r=(r||"").toLowerCase()):"isActive"===p?(s=+!!s,r=+!!r):"lastActive"===p?(s=s?new Date(s).getTime():0,r=r?new Date(r).getTime():0):(s=s||0,r=r||0),s<r)?"asc"===f?-1:1:s>r?"asc"===f?1:-1:0}),[y,m,p,f]);return d?(0,r.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] animate-spin",children:"progress_activity"})}):(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("div",{className:"flex items-center gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:z.map(e=>(0,r.jsx)("button",{onClick:()=>s(e.value),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${t===e.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:e.label},e.value))}),(0,r.jsx)("input",{type:"text",placeholder:"Filter by name...",value:m,onChange:e=>u(e.target.value),className:"px-3 py-1.5 rounded-lg border border-border bg-bg text-sm text-text focus:outline-none focus:ring-2 focus:ring-primary/50 w-48"})]}),(0,r.jsx)(i.default,{className:"overflow-hidden",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,r.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,r.jsx)("tr",{children:A.map(e=>{let t=!1!==e.sortable,s=p===e.key,a="center"===e.align?"text-center":"right"===e.align?"text-right":"text-left";return(0,r.jsx)("th",{className:`px-6 py-3 ${a} ${t?"cursor-pointer select-none hover:text-text transition-colors":""}`,onClick:()=>{var s;return t&&void((s=e.key)===p?g(e=>"asc"===e?"desc":"asc"):(h(s),g("desc")))},children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[e.label,t&&s&&(0,r.jsx)("span",{className:"text-[10px]",children:"asc"===f?"↑":"↓"}),t&&!s&&(0,r.jsx)("span",{className:"opacity-20 text-[10px]",children:"↕"})]})},e.key)})})}),(0,r.jsxs)("tbody",{className:"divide-y divide-border",children:[v.map(t=>{let s;return(0,r.jsxs)("tr",{onClick:()=>e.push(`/dashboard/employees/${t.keyId}`),className:"hover:bg-bg-subtle/50 transition-colors cursor-pointer",children:[(0,r.jsx)("td",{className:"px-6 py-3 font-medium",children:t.name||"Unnamed"}),(0,r.jsx)("td",{className:"px-6 py-3 text-center",children:(0,r.jsx)(n.default,{variant:t.isActive?"success":"error",size:"sm",children:t.isActive?"Active":"Inactive"})}),(0,r.jsx)("td",{className:"px-6 py-3 text-right",children:F(t.totalRequests)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-primary",children:F(t.totalPromptTokens)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right text-success",children:F(t.totalCompletionTokens)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:F(t.totalTokens)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(s=t.totalCost,`$${(s||0).toFixed(2)}`)}),(0,r.jsx)("td",{className:"px-6 py-3 text-right",children:t.modelsUsed}),(0,r.jsx)("td",{className:"px-6 py-3 text-right whitespace-nowrap",children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[t.lastActive&&(0,r.jsx)("span",{className:`inline-block size-1.5 rounded-full ${function(e){if(!e)return"";let t=(Date.now()-new Date(e))/6e4;return t<1?"bg-green-500":t<=60?"bg-blue-400":"bg-red-500"}(t.lastActive)} ${(Date.now()-new Date(t.lastActive))/6e4<=60?"animate-pulse":""}`}),(0,r.jsx)("span",{className:`font-semibold ${function(e){if(!e)return"text-text-muted";let t=(Date.now()-new Date(e))/6e4;return t<1?"text-green-500":t<=60?"text-blue-400":"text-red-400"}(t.lastActive)}`,children:function(e){if(!e)return"Never";let t=Math.floor((Date.now()-new Date(e))/6e4);return t<1?"JUST NOW":t<60?`${t}m ago`:t<1440?`${Math.floor(t/60)}h ago`:new Date(e).toLocaleDateString()}(t.lastActive)})]})}),(0,r.jsx)("td",{className:"px-6 py-3 text-center",children:(0,r.jsx)("code",{className:"text-xs bg-bg-subtle px-2 py-0.5 rounded",children:t.apiKey})})]},t.keyId)}),0===v.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:10,className:"px-6 py-8 text-center text-text-muted",children:"No employees found."})})]})]})})})]})}function M(){return(0,r.jsx)(a.Suspense,{fallback:(0,r.jsx)(o.Qv,{}),children:(0,r.jsx)(I,{})})}function I(){let e=(0,l.useSearchParams)(),t=(0,l.useRouter)(),[s,i]=(0,a.useState)(!1),n=e.get("tab"),c=n&&["overview","details"].includes(n)?n:"overview";return(0,r.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,r.jsx)(o.Iz,{options:[{value:"overview",label:"Overview"},{value:"details",label:"Details"}],value:c,onChange:s=>{if(s===c)return;i(!0);let r=new URLSearchParams(e);r.set("tab",s),t.push(`/dashboard/employees?${r.toString()}`,{scroll:!1}),setTimeout(()=>i(!1),300)}}),s?(0,r.jsx)(o.Qv,{}):(0,r.jsxs)(r.Fragment,{children:["overview"===c&&(0,r.jsx)(a.Suspense,{fallback:(0,r.jsx)(o.Qv,{}),children:(0,r.jsx)(E,{})}),"details"===c&&(0,r.jsx)(P,{})]})]})}},70842:(e,t,s)=>{Promise.resolve().then(s.bind(s,52600))}},e=>{e.O(0,[2574,3862,5772,6902,7505,2652,5497,8441,3794,7358],()=>e(e.s=70842)),_N_E=e.O()}]);
@@ -1,3 +1,3 @@
1
1
  (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6099],{68093:(e,t,s)=>{Promise.resolve().then(s.bind(s,95907))},95907:(e,t,s)=>{"use strict";s.d(t,{default:()=>c});var l=s(95155),a=s(12115),r=s(14051),i=s.n(r),n=s(35497),o=s(11059);let d=[{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"}];function c({machineId:e}){let[t,s]=(0,a.useState)([]),[r,i]=(0,a.useState)(!0),[m,x]=(0,a.useState)(!1),[h,u]=(0,a.useState)(""),[p,y]=(0,a.useState)(null),[b,g]=(0,a.useState)(!1),[f,j]=(0,a.useState)(!1),[k,v]=(0,a.useState)(""),[N,w]=(0,a.useState)(""),[C,S]=(0,a.useState)(""),[T,A]=(0,a.useState)(!1),[E,P]=(0,a.useState)(""),[_,$]=(0,a.useState)(null),[I,O]=(0,a.useState)(!1),[U,D]=(0,a.useState)(!1),[K,R]=(0,a.useState)(new Set),{copied:W,copy:q}=(0,o.C)();(0,a.useEffect)(()=>{J(),F()},[]);let F=async()=>{try{let[e,t]=await Promise.all([fetch("/api/settings"),fetch("/api/tunnel/status")]);if(e.ok){let t=await e.json();g(t.requireApiKey||!1)}if(t.ok){let e=await t.json();j(e.enabled||!1),v(e.tunnelUrl||""),w(e.publicUrl||""),S(e.shortId||"")}}catch(e){console.log("Error loading settings:",e)}},L=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({requireApiKey:e})})).ok&&g(e)}catch(e){console.log("Error updating requireApiKey:",e)}},J=async()=>{try{let e=await fetch("/api/keys"),t=await e.json();e.ok&&s(t.keys||[])}catch(e){console.log("Error fetching data:",e)}finally{i(!1)}},z=async()=>{D(!1),A(!0),$(null),P("Connecting to server...");let e=[{delay:2e3,msg:"Creating tunnel..."},{delay:5e3,msg:"Starting cloudflared..."},{delay:15e3,msg:"Establishing connections..."},{delay:3e4,msg:"Waiting for tunnel ready..."}].map(({delay:e,msg:t})=>setTimeout(()=>P(t),e));try{let t=new AbortController,s=setTimeout(()=>t.abort(),9e4),l=await fetch("/api/tunnel/enable",{method:"POST",signal:t.signal});clearTimeout(s),e.forEach(clearTimeout);let a=await l.json();l.ok?(j(!0),v(a.tunnelUrl||""),w(a.publicUrl||""),S(a.shortId||""),$({type:"success",message:"Tunnel connected!"})):$({type:"error",message:a.error||"Failed to enable tunnel"})}catch(t){e.forEach(clearTimeout),$({type:"error",message:t?.name==="AbortError"?"Tunnel creation timed out":t.message})}finally{A(!1),P("")}},H=async()=>{A(!0),$(null);try{let e=await fetch("/api/tunnel/disable",{method:"POST"}),t=await e.json();e.ok?(j(!1),v(""),w(""),$({type:"success",message:"Tunnel disabled"}),O(!1)):$({type:"error",message:t.error||"Failed to disable tunnel"})}catch(e){$({type:"error",message:e.message})}finally{A(!1)}},M=async()=>{if(h.trim())try{let e=await fetch("/api/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:h})}),t=await e.json();e.ok&&(y(t.key),await J(),u(""),x(!1))}catch(e){console.log("Error creating key:",e)}},Q=async e=>{if(confirm("Delete this API key?"))try{(await fetch(`/api/keys/${e}`,{method:"DELETE"})).ok&&(s(t.filter(t=>t.id!==e)),R(t=>{let s=new Set(t);return s.delete(e),s}))}catch(e){console.log("Error deleting key:",e)}},Z=async(e,t)=>{try{(await fetch(`/api/keys/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&s(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){console.log("Error toggling key:",e)}},[B,G]=(0,a.useState)("/v1");if((0,a.useEffect)(()=>{G(`${window.location.origin}/v1`)},[]),r)return(0,l.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,l.jsx)(n.Qv,{}),(0,l.jsx)(n.Qv,{})]});let V=f&&N?`${N}/v1`:B;return(0,l.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,l.jsxs)(n.Zp,{children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{className:"text-lg font-semibold",children:"API Endpoint"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:f?"Using Tunnel":"Using Local Server"})]}),(0,l.jsx)("div",{className:"flex items-center gap-2",children:f?(0,l.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"cloud_off",onClick:()=>O(!0),disabled:T,className:"bg-red-500/10! text-red-500! hover:bg-red-500/20! border-red-500/30!",children:"Disable Tunnel"}):(0,l.jsx)(n.$n,{variant:"primary",icon:"cloud_upload",onClick:()=>D(!0),disabled:T,className:"bg-linear-to-r from-primary to-blue-500 hover:from-primary-hover hover:to-blue-600",children:T?(0,l.jsxs)("span",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),E||"Creating tunnel..."]}):"Enable Tunnel"})})]}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(n.pd,{value:V,readOnly:!0,className:`flex-1 font-mono text-sm ${f?"animate-border-glow":""}`}),(0,l.jsx)(n.$n,{variant:"secondary",icon:"endpoint_url"===W?"check":"content_copy",onClick:()=>q(V,"endpoint_url"),children:"endpoint_url"===W?"Copied!":"Copy"})]}),_&&(0,l.jsx)("div",{className:`mt-3 p-2 rounded text-sm ${"success"===_.type?"bg-green-500/10 text-green-600 dark:text-green-400":"warning"===_.type?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"bg-red-500/10 text-red-600 dark:text-red-400"}`,children:_.message})]}),(0,l.jsxs)(n.Zp,{children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,l.jsx)("h2",{className:"text-lg font-semibold",children:"API Keys"}),(0,l.jsx)(n.$n,{icon:"add",onClick:()=>x(!0),children:"Create Key"})]}),(0,l.jsxs)("div",{className:"flex items-center justify-between pb-4 mb-4 border-b border-border",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"font-medium",children:"Require API key"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Requests without a valid key will be rejected"})]}),(0,l.jsx)(n.lM,{checked:b,onChange:()=>L(!b)})]}),0===t.length?(0,l.jsxs)("div",{className:"text-center py-12",children:[(0,l.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"vpn_key"})}),(0,l.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No API keys yet"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create your first API key to get started"}),(0,l.jsx)(n.$n,{icon:"add",onClick:()=>x(!0),children:"Create Key"})]}):(0,l.jsx)("div",{className:"flex flex-col",children:t.map(e=>{var t;return(0,l.jsxs)("div",{className:`group flex items-center justify-between py-3 border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0 ${!1===e.isActive?"opacity-60":""}`,children:[(0,l.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,l.jsx)("p",{className:"text-sm font-medium",children:e.name}),(0,l.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,l.jsx)("code",{className:"text-xs text-text-muted font-mono",children:K.has(e.id)?e.key:(t=e.key)?t.length>8?t.slice(0,8)+"...":t:""}),(0,l.jsx)("button",{onClick:()=>{var t;return t=e.id,void R(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary opacity-0 group-hover:opacity-100 transition-all",title:K.has(e.id)?"Hide key":"Show key",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:K.has(e.id)?"visibility_off":"visibility"})}),(0,l.jsx)("button",{onClick:()=>q(e.key,e.id),className:"p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded text-text-muted hover:text-primary opacity-0 group-hover:opacity-100 transition-all",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:W===e.id?"check":"content_copy"})})]}),(0,l.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Created ",new Date(e.createdAt).toLocaleDateString()]}),!1===e.isActive&&(0,l.jsx)("p",{className:"text-xs text-orange-500 mt-1",children:"Paused"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(n.lM,{size:"sm",checked:e.isActive??!0,onChange:t=>{e.isActive&&!t?confirm(`Pause API key "${e.name}"?
2
2
 
3
- This key will stop working immediately but can be resumed later.`)&&Z(e.id,t):Z(e.id,t)},title:e.isActive?"Pause key":"Resume key"}),(0,l.jsx)("button",{onClick:()=>Q(e.id),className:"p-2 hover:bg-red-500/10 rounded text-red-500 opacity-0 group-hover:opacity-100 transition-all",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,l.jsx)(n.aF,{isOpen:m,title:"Create API Key",onClose:()=>{x(!1),u("")},children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsx)(n.pd,{label:"Key Name",value:h,onChange:e=>u(e.target.value),placeholder:"Production Key"}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(n.$n,{onClick:M,fullWidth:!0,disabled:!h.trim(),children:"Create"}),(0,l.jsx)(n.$n,{onClick:()=>{x(!1),u("")},variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,l.jsx)(n.aF,{isOpen:!!p,title:"API Key Created",onClose:()=>y(null),children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[(0,l.jsx)("p",{className:"text-sm text-yellow-800 dark:text-yellow-200 mb-2 font-medium",children:"Save this key now!"}),(0,l.jsx)("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"This is the only time you will see this key. Store it securely."})]}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(n.pd,{value:p||"",readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,l.jsx)(n.$n,{variant:"secondary",icon:"created_key"===W?"check":"content_copy",onClick:()=>q(p,"created_key"),children:"created_key"===W?"Copied!":"Copy"})]}),(0,l.jsx)(n.$n,{onClick:()=>y(null),fullWidth:!0,children:"Done"})]})}),(0,l.jsx)(n.aF,{isOpen:U,title:"Enable Tunnel",onClose:()=>D(!1),children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"cloud_upload"}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium mb-1",children:"Cloudflare Tunnel"}),(0,l.jsx)("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:"Expose your local 9Router to the internet. No port forwarding, no static IP needed. Share endpoint URL with your team or use it in Cursor, Cline, and other AI tools from anywhere."})]})]})}),(0,l.jsx)("div",{className:"grid grid-cols-2 gap-3",children:d.map(e=>(0,l.jsxs)("div",{className:"flex flex-col items-center text-center p-3 rounded-lg bg-sidebar/50",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-xl text-primary mb-1",children:e.icon}),(0,l.jsx)("p",{className:"text-xs font-semibold",children:e.title}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:e.desc})]},e.title))}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Requires outbound port 7844 (TCP/UDP). Connection may take 10-30s."}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(n.$n,{onClick:z,fullWidth:!0,className:"bg-linear-to-r from-primary to-blue-500 hover:from-primary-hover hover:to-blue-600 text-white!",children:"Start Tunnel"}),(0,l.jsx)(n.$n,{onClick:()=>D(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,l.jsx)(n.aF,{isOpen:I,title:"Disable Tunnel",onClose:()=>!T&&O(!1),children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-red-600 dark:text-red-400",children:"warning"}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-sm text-red-800 dark:text-red-200 font-medium mb-1",children:"Warning"}),(0,l.jsx)("p",{className:"text-sm text-red-700 dark:text-red-300",children:"The tunnel will be disconnected. Remote access will stop working."})]})]})}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Are you sure you want to disable the tunnel?"}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(n.$n,{onClick:H,fullWidth:!0,disabled:T,className:"bg-red-500! hover:bg-red-600! text-white!",children:T?(0,l.jsxs)("span",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),"Disabling..."]}):"Disable Tunnel"}),(0,l.jsx)(n.$n,{onClick:()=>O(!1),variant:"ghost",fullWidth:!0,disabled:T,children:"Cancel"})]})]})})]})}c.propTypes={machineId:i().string.isRequired}}},e=>{e.O(0,[2574,3862,5772,6902,2652,5497,8441,3794,7358],()=>e(e.s=68093)),_N_E=e.O()}]);
3
+ This key will stop working immediately but can be resumed later.`)&&Z(e.id,t):Z(e.id,t)},title:e.isActive?"Pause key":"Resume key"}),(0,l.jsx)("button",{onClick:()=>Q(e.id),className:"p-2 hover:bg-red-500/10 rounded text-red-500 opacity-0 group-hover:opacity-100 transition-all",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,l.jsx)(n.aF,{isOpen:m,title:"Create API Key",onClose:()=>{x(!1),u("")},children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsx)(n.pd,{label:"Key Name",value:h,onChange:e=>u(e.target.value),placeholder:"Production Key"}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(n.$n,{onClick:M,fullWidth:!0,disabled:!h.trim(),children:"Create"}),(0,l.jsx)(n.$n,{onClick:()=>{x(!1),u("")},variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,l.jsx)(n.aF,{isOpen:!!p,title:"API Key Created",onClose:()=>y(null),children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[(0,l.jsx)("p",{className:"text-sm text-yellow-800 dark:text-yellow-200 mb-2 font-medium",children:"Save this key now!"}),(0,l.jsx)("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"This is the only time you will see this key. Store it securely."})]}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(n.pd,{value:p||"",readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,l.jsx)(n.$n,{variant:"secondary",icon:"created_key"===W?"check":"content_copy",onClick:()=>q(p,"created_key"),children:"created_key"===W?"Copied!":"Copy"})]}),(0,l.jsx)(n.$n,{onClick:()=>y(null),fullWidth:!0,children:"Done"})]})}),(0,l.jsx)(n.aF,{isOpen:U,title:"Enable Tunnel",onClose:()=>D(!1),children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"cloud_upload"}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium mb-1",children:"Cloudflare Tunnel"}),(0,l.jsx)("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:"Expose your local iRouter to the internet. No port forwarding, no static IP needed. Share endpoint URL with your team or use it in Cursor, Cline, and other AI tools from anywhere."})]})]})}),(0,l.jsx)("div",{className:"grid grid-cols-2 gap-3",children:d.map(e=>(0,l.jsxs)("div",{className:"flex flex-col items-center text-center p-3 rounded-lg bg-sidebar/50",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-xl text-primary mb-1",children:e.icon}),(0,l.jsx)("p",{className:"text-xs font-semibold",children:e.title}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:e.desc})]},e.title))}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Requires outbound port 7844 (TCP/UDP). Connection may take 10-30s."}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(n.$n,{onClick:z,fullWidth:!0,className:"bg-linear-to-r from-primary to-blue-500 hover:from-primary-hover hover:to-blue-600 text-white!",children:"Start Tunnel"}),(0,l.jsx)(n.$n,{onClick:()=>D(!1),variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,l.jsx)(n.aF,{isOpen:I,title:"Disable Tunnel",onClose:()=>!T&&O(!1),children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-red-600 dark:text-red-400",children:"warning"}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-sm text-red-800 dark:text-red-200 font-medium mb-1",children:"Warning"}),(0,l.jsx)("p",{className:"text-sm text-red-700 dark:text-red-300",children:"The tunnel will be disconnected. Remote access will stop working."})]})]})}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Are you sure you want to disable the tunnel?"}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(n.$n,{onClick:H,fullWidth:!0,disabled:T,className:"bg-red-500! hover:bg-red-600! text-white!",children:T?(0,l.jsxs)("span",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin text-sm",children:"progress_activity"}),"Disabling..."]}):"Disable Tunnel"}),(0,l.jsx)(n.$n,{onClick:()=>O(!1),variant:"ghost",fullWidth:!0,disabled:T,children:"Cancel"})]})]})})]})}c.propTypes={machineId:i().string.isRequired}}},e=>{e.O(0,[2574,3862,5772,6902,2652,5497,8441,3794,7358],()=>e(e.s=68093)),_N_E=e.O()}]);