abc1181 commited on
Commit
a4cd60e
·
1 Parent(s): ca64345

fix: eliminate infinite reload loop between /login and /

Browse files

Root cause: standalone login page checked localStorage for auto-redirect
to /, but the server checks the cookie. When a user had a stale localStorage
token but no valid cookie, they'd bounce between /login → / → /login.

Fixes:
- Standalone login: check COOKIE (not localStorage) for auto-redirect to /
- api.ts getToken(): fall back to cookie if localStorage is empty
- This ensures React app works after form-based login (which only sets cookie)
- Rebuilt frontend to include all changes

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. frontend/src/lib/api.ts +7 -1
  2. opencode.json +20 -0
  3. static/404.html +1 -1
  4. static/_next/static/{6VYU5qR-4gYg0L7vwEHSN → 7SRs9Ntci43nzMnYnHM1A}/_buildManifest.js +0 -0
  5. static/_next/static/{6VYU5qR-4gYg0L7vwEHSN → 7SRs9Ntci43nzMnYnHM1A}/_ssgManifest.js +0 -0
  6. static/_next/static/_Q04VcFqEdiU4KDVIuAXo/_buildManifest.js +0 -1
  7. static/_next/static/_Q04VcFqEdiU4KDVIuAXo/_ssgManifest.js +0 -1
  8. static/_next/static/chunks/2117-1052cb5180af1179.js +0 -0
  9. static/_next/static/chunks/4953-535891cfa3c16f01.js +0 -1
  10. static/_next/static/chunks/5029-407359e83cfd8fd3.js +0 -1
  11. static/_next/static/chunks/7593-75b41f6f503ce100.js +0 -1
  12. static/_next/static/chunks/app/ab-tests/{page-07c292a107a6b7eb.js → page-2b8d2c50e2a70e90.js} +1 -1
  13. static/_next/static/chunks/app/ab-tests/page-48b03e034dff445e.js +0 -1
  14. static/_next/static/chunks/app/activity/{page-5a4807967b5002cd.js → page-03c92e6695ec079a.js} +1 -1
  15. static/_next/static/chunks/app/activity/page-d1a71f38c937f6b6.js +0 -1
  16. static/_next/static/chunks/app/admin/page-048442296e23ef4d.js +0 -1
  17. static/_next/static/chunks/app/admin/{page-2d512533ea7af2ec.js → page-cc1da0c8bc82e2cd.js} +1 -1
  18. static/_next/static/chunks/app/agent/page-12f7d7e3790a2607.js +0 -1
  19. static/_next/static/chunks/app/agent/{page-3e623457abaac9ba.js → page-a263a79fd957da1d.js} +1 -1
  20. static/_next/static/chunks/app/aliases/{page-4c00397d46a1ecfd.js → page-41cd8bb4b05195fc.js} +1 -1
  21. static/_next/static/chunks/app/aliases/page-d7baa78c5be07b1d.js +0 -1
  22. static/_next/static/chunks/app/analytics/page-06a4c26379b4ee7e.js +1 -0
  23. static/_next/static/chunks/app/analytics/page-a799d4a333cef333.js +0 -1
  24. static/_next/static/chunks/app/analytics/page-d99b46621eeb72d0.js +0 -1
  25. static/_next/static/chunks/app/batch-api/page-93e9632550aa7e6c.js +0 -1
  26. static/_next/static/chunks/app/batch-api/{page-77c5fb2136ff3a1a.js → page-efde9eb1301afc84.js} +1 -1
  27. static/_next/static/chunks/app/benchmarks/{page-af8fe334210c6570.js → page-2971e504ea962b1e.js} +1 -1
  28. static/_next/static/chunks/app/benchmarks/page-d6e2b98299937e6a.js +0 -1
  29. static/_next/static/chunks/app/cache/{page-02c4a057138aaaad.js → page-16bf5ae5f751e0ae.js} +1 -1
  30. static/_next/static/chunks/app/cache/page-1dceb2a7e680cdb2.js +0 -1
  31. static/_next/static/chunks/app/chat/page-eccb2a38589380fd.js +0 -1
  32. static/_next/static/chunks/app/chat/{page-ba53668baba0967f.js → page-fd7d09a808f0f08f.js} +1 -1
  33. static/_next/static/chunks/app/code-interpreter/page-2365e842d504748d.js +0 -1
  34. static/_next/static/chunks/app/code-interpreter/page-616c2499443c23ee.js +0 -1
  35. static/_next/static/chunks/app/code-interpreter/page-6263999561ce9799.js +1 -0
  36. static/_next/static/chunks/app/config-backup/{page-7792b5bc4dc19a5f.js → page-3da24ba3742904fe.js} +1 -1
  37. static/_next/static/chunks/app/config-backup/page-f8aede07552f28f7.js +0 -1
  38. static/_next/static/chunks/app/conversations/{page-832c737bd9527622.js → page-c7a6b871b4413f88.js} +1 -1
  39. static/_next/static/chunks/app/conversations/page-d1e1c668033ca84e.js +0 -1
  40. static/_next/static/chunks/app/custom-providers/{page-138528cda1a2fab8.js → page-4fc98b07b6fcfdb0.js} +1 -1
  41. static/_next/static/chunks/app/custom-providers/page-a35369052b2e039b.js +0 -1
  42. static/_next/static/chunks/app/docs/page-097f3b9b394516d9.js +0 -1
  43. static/_next/static/chunks/app/error-6f447ef91b6f7d27.js +0 -1
  44. static/_next/static/chunks/app/fallback-chains/{page-8e5925e44323ee69.js → page-85fd52fb5eae847a.js} +1 -1
  45. static/_next/static/chunks/app/fallback-chains/page-9e30e5f90985c3e3.js +0 -1
  46. static/_next/static/chunks/app/fine-tuning/{page-9b95c51fc01eb318.js → page-0f5de87c7b897ed1.js} +1 -1
  47. static/_next/static/chunks/app/fine-tuning/page-ecbefa6299ef7516.js +0 -1
  48. static/_next/static/chunks/app/global-error-cbe2d3ac15285c84.js +0 -1
  49. static/_next/static/chunks/app/health/page-afe3b6f5c87fbc55.js +0 -1
  50. static/_next/static/chunks/app/health/{page-0076cc8e10197b14.js → page-f9a55c9d3c1965a7.js} +1 -1
frontend/src/lib/api.ts CHANGED
@@ -9,7 +9,13 @@ export interface ApiOptions {
9
 
10
  function getToken(): string | null {
11
  if (typeof window === 'undefined') return null
12
- return localStorage.getItem('nexus_token')
 
 
 
 
 
 
13
  }
14
 
15
  function setCookie(name: string, value: string, days: number) {
 
9
 
10
  function getToken(): string | null {
11
  if (typeof window === 'undefined') return null
12
+ const ls = localStorage.getItem('nexus_token')
13
+ if (ls) return ls
14
+ try {
15
+ const m = document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/)
16
+ if (m) return decodeURIComponent(m[1])
17
+ } catch {}
18
+ return null
19
  }
20
 
21
  function setCookie(name: string, value: string, days: number) {
opencode.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "https://opencode.ai/config.json",
3
+ "provider": {
4
+ "mygateway": {
5
+ "npm": "@ai-sdk/openai-compatible",
6
+ "name": "My Custom Proxy",
7
+ "options": {
8
+ "baseURL": "https://opencode.ai/zen/v1"
9
+ },
10
+ "models": {
11
+ "minimax-m3-free": {
12
+ "name": "Zen Minimax M3 Free"
13
+ },
14
+ "mimo-v2.5-free": {
15
+ "name": "Zen Mimo V2.5 Free"
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
static/404.html CHANGED
@@ -1 +1 @@
1
- <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/ab9b26685aa74f86.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-c6074c84a5a563df.js"/><script src="/_next/static/chunks/fd9d1056-e5560c638053337c.js" async=""></script><script src="/_next/static/chunks/2117-c894010f721972a1.js" async=""></script><script src="/_next/static/chunks/main-app-9dc5d4d57b58ddf5.js" async=""></script><script src="/_next/static/chunks/app/not-found-94ff6d0f4372cc52.js" async=""></script><script src="/_next/static/chunks/7593-27216b2b02a4a8eb.js" async=""></script><script src="/_next/static/chunks/app/layout-8a0f8a17324939d0.js" async=""></script><script src="/_next/static/chunks/app/error-b2ab4ca55fe81703.js" async=""></script><script src="/_next/static/chunks/app/global-error-f7ad0458893e7c3c.js" async=""></script><meta name="robots" content="noindex"/><meta name="theme-color" content="#0a0a0a"/><meta name="color-scheme" content="dark"/><title>NexusAI Gateway</title><meta name="description" content="Self-hosted AI API Gateway"/><link rel="icon" href="/favicon.svg"/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body style="background:#0a0a0a;color:#fff;margin:0"><style data-critical="true">html,body{margin:0;padding:0;background:#0a0a0a;color:#fff;font-family:Inter,system-ui,-apple-system,sans-serif;-webkit-font-smoothing:antialiased}*{box-sizing:border-box}.nx-spinner-wrap{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;background:#0a0a0a;position:relative;padding:24px}.nx-spinner{width:32px;height:32px;border:2px solid #f97316;border-top-color:transparent;border-radius:50%;animation:nx-spin 1s linear infinite}@keyframes nx-spin{to{transform:rotate(1turn)}}.nx-noscript{padding:32px;text-align:center;max-width:480px;margin:80px auto;color:#a1a1a1}.nx-noscript h1{color:#fff;font-size:20px;margin:0 0 8px}.nx-noscript a{color:#f97316}.nx-fallback{display:inline-block;margin-top:24px;padding:10px 20px;background:#f97316;color:#fff;border-radius:8px;font-size:14px;text-decoration:none;font-family:Inter,system-ui,sans-serif;font-weight:500}.nx-fallback:hover{background:#ea580c}</style><script data-auth-guard="true">(function(){try{var p=window.location.pathname;if(p==='/login'||p==='/login.html')return;if(p.indexOf('/_next/')===0)return;if(p==='/favicon.svg'||p==='/icon.svg')return;if(p==='/health')return;var t=null;try{t=localStorage.getItem('nexus_token')}catch(e){}if(!t){var d='/login';try{window.location.replace(d)}catch(e){window.location.href=d}return}setTimeout(function(){try{var c=localStorage.getItem('nexus_token');if(!c){window.location.replace('/login')}}catch(e){}},8000)})();</script><noscript><div class="nx-noscript"><h1>JavaScript is required</h1><p>NexusAI Gateway is a single-page application. Please enable JavaScript or visit <a href="/login">/login</a> after enabling it.</p></div></noscript><div class="nx-spinner-wrap" data-static-fallback="true"><div class="nx-spinner"></div><a href="/login" class="nx-fallback" data-fallback-link="true">Continue to sign in →</a></div><div class="nx-spinner-wrap"><div class="nx-spinner"></div><a href="/login" class="nx-fallback" data-fallback-link="true">Continue to sign in →</a></div><script src="/_next/static/chunks/webpack-c6074c84a5a563df.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/css/ab9b26685aa74f86.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"2:I[2846,[],\"\"]\n4:I[9107,[],\"ClientPageRoot\"]\n5:I[5292,[\"9160\",\"static/chunks/app/not-found-94ff6d0f4372cc52.js\"],\"default\",1]\n6:I[4707,[],\"\"]\n7:I[6423,[],\"\"]\n8:I[6198,[\"7593\",\"static/chunks/7593-27216b2b02a4a8eb.js\",\"3185\",\"static/chunks/app/layout-8a0f8a17324939d0.js\"],\"Providers\"]\n9:I[376,[\"7601\",\"static/chunks/app/error-b2ab4ca55fe81703.js\"],\"default\"]\na:I[5292,[\"9160\",\"static/chunks/app/not-found-94ff6d0f4372cc52.js\"],\"default\"]\nc:I[1667,[\"6470\",\"static/chunks/app/global-error-f7ad0458893e7c3c.js\"],\"default\"]\nd:[]\n0:[\"$\",\"$L2\",null,{\"buildId\":\"6VYU5qR-4gYg0L7vwEHSN\",\"assetPrefix\":\"\",\"urlParts\":[\"\",\"_not-found\"],\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L3\",[\"$\",\"$L4\",null,{\"props\":{\"params\":{},\"searchParams\":{}},\"Component\":\"$5\"}],null],null],null]},[null,[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/ab9b26685aa74f86.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"style\":{\"background\":\"#0a0a0a\",\"color\":\"#fff\",\"margin\":0},\"children\":[\"$\",\"$L8\",null,{\"children\":[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$9\",\"errorStyles\":[],\"errorScripts\":[],\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[\"$\",\"$La\",null,{}],\"notFoundStyles\":[]}]}]}]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],\"$Lb\"],\"globalErrorComponent\":\"$c\",\"missingSlots\":\"$Wd\"}]\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"name\":\"theme-color\",\"content\":\"#0a0a0a\"}],[\"$\",\"meta\",\"2\",{\"name\":\"color-scheme\",\"content\":\"dark\"}],[\"$\",\"meta\",\"3\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"4\",{\"children\":\"NexusAI Gateway\"}],[\"$\",\"meta\",\"5\",{\"name\":\"description\",\"content\":\"Self-hosted AI API Gateway\"}],[\"$\",\"link\",\"6\",{\"rel\":\"icon\",\"href\":\"/favicon.svg\"}]]\n3:null\n"])</script></body></html>
 
1
+ <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/ab9b26685aa74f86.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-c6074c84a5a563df.js"/><script src="/_next/static/chunks/fd9d1056-e5560c638053337c.js" async=""></script><script src="/_next/static/chunks/2117-c894010f721972a1.js" async=""></script><script src="/_next/static/chunks/main-app-9dc5d4d57b58ddf5.js" async=""></script><script src="/_next/static/chunks/app/not-found-94ff6d0f4372cc52.js" async=""></script><script src="/_next/static/chunks/7593-27216b2b02a4a8eb.js" async=""></script><script src="/_next/static/chunks/app/layout-62b35e683e324a12.js" async=""></script><script src="/_next/static/chunks/app/error-b2ab4ca55fe81703.js" async=""></script><script src="/_next/static/chunks/app/global-error-f7ad0458893e7c3c.js" async=""></script><meta name="robots" content="noindex"/><meta name="theme-color" content="#0a0a0a"/><meta name="color-scheme" content="dark"/><title>NexusAI Gateway</title><meta name="description" content="Self-hosted AI API Gateway"/><link rel="icon" href="/favicon.svg"/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body style="background:#0a0a0a;color:#fff;margin:0"><style data-critical="true">html,body{margin:0;padding:0;background:#0a0a0a;color:#fff;font-family:Inter,system-ui,-apple-system,sans-serif;-webkit-font-smoothing:antialiased}*{box-sizing:border-box}.nx-spinner-wrap{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;background:#0a0a0a;position:relative;padding:24px}.nx-spinner{width:32px;height:32px;border:2px solid #f97316;border-top-color:transparent;border-radius:50%;animation:nx-spin 1s linear infinite}@keyframes nx-spin{to{transform:rotate(1turn)}}.nx-noscript{padding:32px;text-align:center;max-width:480px;margin:80px auto;color:#a1a1a1}.nx-noscript h1{color:#fff;font-size:20px;margin:0 0 8px}.nx-noscript a{color:#f97316}.nx-fallback{display:inline-block;margin-top:24px;padding:10px 20px;background:#f97316;color:#fff;border-radius:8px;font-size:14px;text-decoration:none;font-family:Inter,system-ui,sans-serif;font-weight:500}.nx-fallback:hover{background:#ea580c}</style><div class="nx-spinner-wrap" data-static-fallback="true"><div class="nx-spinner"></div><a href="/login" class="nx-fallback" data-fallback-link="true">Continue to sign in →</a></div><div class="nx-spinner-wrap"><div class="nx-spinner"></div><a href="/login" class="nx-fallback" data-fallback-link="true">Continue to sign in →</a></div><script src="/_next/static/chunks/webpack-c6074c84a5a563df.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/css/ab9b26685aa74f86.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"2:I[2846,[],\"\"]\n4:I[9107,[],\"ClientPageRoot\"]\n5:I[5292,[\"9160\",\"static/chunks/app/not-found-94ff6d0f4372cc52.js\"],\"default\",1]\n6:I[4707,[],\"\"]\n7:I[6423,[],\"\"]\n8:I[6198,[\"7593\",\"static/chunks/7593-27216b2b02a4a8eb.js\",\"3185\",\"static/chunks/app/layout-62b35e683e324a12.js\"],\"Providers\"]\n9:I[376,[\"7601\",\"static/chunks/app/error-b2ab4ca55fe81703.js\"],\"default\"]\na:I[5292,[\"9160\",\"static/chunks/app/not-found-94ff6d0f4372cc52.js\"],\"default\"]\nc:I[1667,[\"6470\",\"static/chunks/app/global-error-f7ad0458893e7c3c.js\"],\"default\"]\nd:[]\n0:[\"$\",\"$L2\",null,{\"buildId\":\"7SRs9Ntci43nzMnYnHM1A\",\"assetPrefix\":\"\",\"urlParts\":[\"\",\"_not-found\"],\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L3\",[\"$\",\"$L4\",null,{\"props\":{\"params\":{},\"searchParams\":{}},\"Component\":\"$5\"}],null],null],null]},[null,[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/ab9b26685aa74f86.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"style\":{\"background\":\"#0a0a0a\",\"color\":\"#fff\",\"margin\":0},\"children\":[\"$\",\"$L8\",null,{\"children\":[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$9\",\"errorStyles\":[],\"errorScripts\":[],\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[\"$\",\"$La\",null,{}],\"notFoundStyles\":[]}]}]}]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],\"$Lb\"],\"globalErrorComponent\":\"$c\",\"missingSlots\":\"$Wd\"}]\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"name\":\"theme-color\",\"content\":\"#0a0a0a\"}],[\"$\",\"meta\",\"2\",{\"name\":\"color-scheme\",\"content\":\"dark\"}],[\"$\",\"meta\",\"3\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"4\",{\"children\":\"NexusAI Gateway\"}],[\"$\",\"meta\",\"5\",{\"name\":\"description\",\"content\":\"Self-hosted AI API Gateway\"}],[\"$\",\"link\",\"6\",{\"rel\":\"icon\",\"href\":\"/favicon.svg\"}]]\n3:null\n"])</script></body></html>
static/_next/static/{6VYU5qR-4gYg0L7vwEHSN → 7SRs9Ntci43nzMnYnHM1A}/_buildManifest.js RENAMED
File without changes
static/_next/static/{6VYU5qR-4gYg0L7vwEHSN → 7SRs9Ntci43nzMnYnHM1A}/_ssgManifest.js RENAMED
File without changes
static/_next/static/_Q04VcFqEdiU4KDVIuAXo/_buildManifest.js DELETED
@@ -1 +0,0 @@
1
- self.__BUILD_MANIFEST={__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/_error":["static/chunks/pages/_error-7ce03bcf1df914ce.js"],sortedPages:["/_app","/_error"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
 
 
static/_next/static/_Q04VcFqEdiU4KDVIuAXo/_ssgManifest.js DELETED
@@ -1 +0,0 @@
1
- self.__SSG_MANIFEST=new Set([]);self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()
 
 
static/_next/static/chunks/2117-1052cb5180af1179.js DELETED
The diff for this file is too large to render. See raw diff
 
static/_next/static/chunks/4953-535891cfa3c16f01.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4953],{9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(2265);let i=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var o={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let u=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:i=24,strokeWidth:u=2,absoluteStrokeWidth:c,className:l="",children:a,iconNode:h,...d}=e;return(0,r.createElement)("svg",{ref:t,...o,width:i,height:i,stroke:n,strokeWidth:c?24*Number(u)/Number(i):u,className:s("lucide",l),...d},[...h.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(a)?a:[a]])}),c=(e,t)=>{let n=(0,r.forwardRef)((n,o)=>{let{className:c,...l}=n;return(0,r.createElement)(u,{ref:o,iconNode:t,className:s("lucide-".concat(i(e)),c),...l})});return n.displayName="".concat(e),n}},4001:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]])},3229:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},257:function(e,t,n){"use strict";var r,i;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(i=n.g.process)?void 0:i.env)?n.g.process:n(4227)},4601:function(){},4227:function(e){!function(){var t={229:function(e){var t,n,r,i=e.exports={};function s(){throw Error("setTimeout has not been defined")}function o(){throw Error("clearTimeout has not been defined")}function u(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(e){n=o}}();var c=[],l=!1,a=-1;function h(){l&&r&&(l=!1,r.length?c=r.concat(c):a=-1,c.length&&d())}function d(){if(!l){var e=u(h);l=!0;for(var t=c.length;t;){for(r=c,c=[];++a<t;)r&&r[a].run();a=-1,t=c.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function p(){}i.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||l||u(d)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(e){return[]},i.binding=function(e){throw Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw Error("process.chdir is not supported")},i.umask=function(){return 0}}},n={};function r(e){var i=n[e];if(void 0!==i)return i.exports;var s=n[e]={exports:{}},o=!0;try{t[e](s,s.exports,r),o=!1}finally{o&&delete n[e]}return s.exports}r.ab="//";var i=r(229);e.exports=i}()},8975:function(e,t,n){"use strict";var r=n(257);n(4601);var i=n(2265),s=i&&"object"==typeof i&&"default"in i?i:{default:i},o=void 0!==r&&r.env&&!0,u=function(e){return"[object String]"===Object.prototype.toString.call(e)},c=function(){function e(e){var t=void 0===e?{}:e,n=t.name,r=void 0===n?"stylesheet":n,i=t.optimizeForSpeed,s=void 0===i?o:i;l(u(r),"`name` must be a string"),this._name=r,this._deletedRulePlaceholder="#"+r+"-deleted-rule____{}",l("boolean"==typeof s,"`optimizeForSpeed` must be a boolean"),this._optimizeForSpeed=s,this._serverSheet=void 0,this._tags=[],this._injected=!1,this._rulesCount=0;var c="undefined"!=typeof window&&document.querySelector('meta[property="csp-nonce"]');this._nonce=c?c.getAttribute("content"):null}var t=e.prototype;return t.setOptimizeForSpeed=function(e){l("boolean"==typeof e,"`setOptimizeForSpeed` accepts a boolean"),l(0===this._rulesCount,"optimizeForSpeed cannot be when rules have already been inserted"),this.flush(),this._optimizeForSpeed=e,this.inject()},t.isOptimizeForSpeed=function(){return this._optimizeForSpeed},t.inject=function(){var e=this;if(l(!this._injected,"sheet already injected"),this._injected=!0,"undefined"!=typeof window&&this._optimizeForSpeed){this._tags[0]=this.makeStyleTag(this._name),this._optimizeForSpeed="insertRule"in this.getSheet(),this._optimizeForSpeed||(o||console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode."),this.flush(),this._injected=!0);return}this._serverSheet={cssRules:[],insertRule:function(t,n){return"number"==typeof n?e._serverSheet.cssRules[n]={cssText:t}:e._serverSheet.cssRules.push({cssText:t}),n},deleteRule:function(t){e._serverSheet.cssRules[t]=null}}},t.getSheetForTag=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]},t.getSheet=function(){return this.getSheetForTag(this._tags[this._tags.length-1])},t.insertRule=function(e,t){if(l(u(e),"`insertRule` accepts only strings"),"undefined"==typeof window)return"number"!=typeof t&&(t=this._serverSheet.cssRules.length),this._serverSheet.insertRule(e,t),this._rulesCount++;if(this._optimizeForSpeed){var n=this.getSheet();"number"!=typeof t&&(t=n.cssRules.length);try{n.insertRule(e,t)}catch(t){return o||console.warn("StyleSheet: illegal rule: \n\n"+e+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),-1}}else{var r=this._tags[t];this._tags.push(this.makeStyleTag(this._name,e,r))}return this._rulesCount++},t.replaceRule=function(e,t){if(this._optimizeForSpeed||"undefined"==typeof window){var n="undefined"!=typeof window?this.getSheet():this._serverSheet;if(t.trim()||(t=this._deletedRulePlaceholder),!n.cssRules[e])return e;n.deleteRule(e);try{n.insertRule(t,e)}catch(r){o||console.warn("StyleSheet: illegal rule: \n\n"+t+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),n.insertRule(this._deletedRulePlaceholder,e)}}else{var r=this._tags[e];l(r,"old rule at index `"+e+"` not found"),r.textContent=t}return e},t.deleteRule=function(e){if("undefined"==typeof window){this._serverSheet.deleteRule(e);return}if(this._optimizeForSpeed)this.replaceRule(e,"");else{var t=this._tags[e];l(t,"rule at index `"+e+"` not found"),t.parentNode.removeChild(t),this._tags[e]=null}},t.flush=function(){this._injected=!1,this._rulesCount=0,"undefined"!=typeof window?(this._tags.forEach(function(e){return e&&e.parentNode.removeChild(e)}),this._tags=[]):this._serverSheet.cssRules=[]},t.cssRules=function(){var e=this;return"undefined"==typeof window?this._serverSheet.cssRules:this._tags.reduce(function(t,n){return n?t=t.concat(Array.prototype.map.call(e.getSheetForTag(n).cssRules,function(t){return t.cssText===e._deletedRulePlaceholder?null:t})):t.push(null),t},[])},t.makeStyleTag=function(e,t,n){t&&l(u(t),"makeStyleTag accepts only strings as second parameter");var r=document.createElement("style");this._nonce&&r.setAttribute("nonce",this._nonce),r.type="text/css",r.setAttribute("data-"+e,""),t&&r.appendChild(document.createTextNode(t));var i=document.head||document.getElementsByTagName("head")[0];return n?i.insertBefore(r,n):i.appendChild(r),r},function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,[{key:"length",get:function(){return this._rulesCount}}]),e}();function l(e,t){if(!e)throw Error("StyleSheet: "+t+".")}var a=function(e){for(var t=5381,n=e.length;n;)t=33*t^e.charCodeAt(--n);return t>>>0},h={};function d(e,t){if(!t)return"jsx-"+e;var n=String(t),r=e+n;return h[r]||(h[r]="jsx-"+a(e+"-"+n)),h[r]}function f(e,t){"undefined"==typeof window&&(t=t.replace(/\/style/gi,"\\/style"));var n=e+t;return h[n]||(h[n]=t.replace(/__jsx-style-dynamic-selector/g,e)),h[n]}var p=function(){function e(e){var t=void 0===e?{}:e,n=t.styleSheet,r=void 0===n?null:n,i=t.optimizeForSpeed,s=void 0!==i&&i;this._sheet=r||new c({name:"styled-jsx",optimizeForSpeed:s}),this._sheet.inject(),r&&"boolean"==typeof s&&(this._sheet.setOptimizeForSpeed(s),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer=void 0,this._indices={},this._instancesCounts={}}var t=e.prototype;return t.add=function(e){var t=this;void 0===this._optimizeForSpeed&&(this._optimizeForSpeed=Array.isArray(e.children),this._sheet.setOptimizeForSpeed(this._optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),"undefined"==typeof window||this._fromServer||(this._fromServer=this.selectFromServer(),this._instancesCounts=Object.keys(this._fromServer).reduce(function(e,t){return e[t]=0,e},{}));var n=this.getIdAndRules(e),r=n.styleId,i=n.rules;if(r in this._instancesCounts){this._instancesCounts[r]+=1;return}var s=i.map(function(e){return t._sheet.insertRule(e)}).filter(function(e){return -1!==e});this._indices[r]=s,this._instancesCounts[r]=1},t.remove=function(e){var t=this,n=this.getIdAndRules(e).styleId;if(function(e,t){if(!e)throw Error("StyleSheetRegistry: "+t+".")}(n in this._instancesCounts,"styleId: `"+n+"` not found"),this._instancesCounts[n]-=1,this._instancesCounts[n]<1){var r=this._fromServer&&this._fromServer[n];r?(r.parentNode.removeChild(r),delete this._fromServer[n]):(this._indices[n].forEach(function(e){return t._sheet.deleteRule(e)}),delete this._indices[n]),delete this._instancesCounts[n]}},t.update=function(e,t){this.add(t),this.remove(e)},t.flush=function(){this._sheet.flush(),this._sheet.inject(),this._fromServer=void 0,this._indices={},this._instancesCounts={}},t.cssRules=function(){var e=this,t=this._fromServer?Object.keys(this._fromServer).map(function(t){return[t,e._fromServer[t]]}):[],n=this._sheet.cssRules();return t.concat(Object.keys(this._indices).map(function(t){return[t,e._indices[t].map(function(e){return n[e].cssText}).join(e._optimizeForSpeed?"":"\n")]}).filter(function(e){return!!e[1]}))},t.styles=function(e){var t,n;return t=this.cssRules(),void 0===(n=e)&&(n={}),t.map(function(e){var t=e[0],r=e[1];return s.default.createElement("style",{id:"__"+t,key:"__"+t,nonce:n.nonce?n.nonce:void 0,dangerouslySetInnerHTML:{__html:r}})})},t.getIdAndRules=function(e){var t=e.children,n=e.dynamic,r=e.id;if(n){var i=d(r,n);return{styleId:i,rules:Array.isArray(t)?t.map(function(e){return f(i,e)}):[f(i,t)]}}return{styleId:d(r),rules:Array.isArray(t)?t:[t]}},t.selectFromServer=function(){return Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]')).reduce(function(e,t){return e[t.id.slice(2)]=t,e},{})},e}(),m=i.createContext(null);m.displayName="StyleSheetContext";var y=s.default.useInsertionEffect||s.default.useLayoutEffect,v="undefined"!=typeof window?new p:void 0;function _(e){var t=v||i.useContext(m);return t&&("undefined"==typeof window?t.add(e):y(function(){return t.add(e),function(){t.remove(e)}},[e.id,String(e.dynamic)])),null}_.dynamic=function(e){return e.map(function(e){return d(e[0],e[1])}).join(" ")},t.style=_},29:function(e,t,n){"use strict";e.exports=n(8975).style}}]);
 
 
static/_next/static/chunks/5029-407359e83cfd8fd3.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5029],{9205:function(t,e,n){"use strict";n.d(e,{Z:function(){return o}});var r=n(2265);let i=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.filter((t,e,n)=>!!t&&n.indexOf(t)===e).join(" ")};var u={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,r.forwardRef)((t,e)=>{let{color:n="currentColor",size:i=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:l="",children:s,iconNode:f,...h}=t;return(0,r.createElement)("svg",{ref:e,...u,width:i,height:i,stroke:n,strokeWidth:o?24*Number(c)/Number(i):c,className:a("lucide",l),...h},[...f.map(t=>{let[e,n]=t;return(0,r.createElement)(e,n)}),...Array.isArray(s)?s:[s]])}),o=(t,e)=>{let n=(0,r.forwardRef)((n,u)=>{let{className:o,...l}=n;return(0,r.createElement)(c,{ref:u,iconNode:e,className:a("lucide-".concat(i(t)),o),...l})});return n.displayName="".concat(t),n}},4401:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]])},875:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},2135:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},9322:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},1723:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},5252:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]])},5621:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},3417:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},730:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]])},8662:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]])},7133:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("PhoneOff",[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]])},3041:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]])},7168:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},4743:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},8728:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},8930:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1706:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]])},5395:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]])},2926:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]])},2489:function(t,e,n){"use strict";n.d(e,{Z:function(){return r}});let r=(0,n(9205).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},257:function(t,e,n){"use strict";var r,i;t.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(i=n.g.process)?void 0:i.env)?n.g.process:n(4227)},4227:function(t){!function(){var e={229:function(t){var e,n,r,i=t.exports={};function a(){throw Error("setTimeout has not been defined")}function u(){throw Error("clearTimeout has not been defined")}function c(t){if(e===setTimeout)return setTimeout(t,0);if((e===a||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:a}catch(t){e=a}try{n="function"==typeof clearTimeout?clearTimeout:u}catch(t){n=u}}();var o=[],l=!1,s=-1;function f(){l&&r&&(l=!1,r.length?o=r.concat(o):s=-1,o.length&&h())}function h(){if(!l){var t=c(f);l=!0;for(var e=o.length;e;){for(r=o,o=[];++s<e;)r&&r[s].run();s=-1,e=o.length}r=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===u||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function y(t,e){this.fun=t,this.array=e}function d(){}i.nextTick=function(t){var e=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];o.push(new y(t,e)),1!==o.length||l||c(h)},y.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=d,i.addListener=d,i.once=d,i.off=d,i.removeListener=d,i.removeAllListeners=d,i.emit=d,i.prependListener=d,i.prependOnceListener=d,i.listeners=function(t){return[]},i.binding=function(t){throw Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw Error("process.chdir is not supported")},i.umask=function(){return 0}}},n={};function r(t){var i=n[t];if(void 0!==i)return i.exports;var a=n[t]={exports:{}},u=!0;try{e[t](a,a.exports,r),u=!1}finally{u&&delete n[t]}return a.exports}r.ab="//";var i=r(229);t.exports=i}()}}]);
 
 
static/_next/static/chunks/7593-75b41f6f503ce100.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7593],{9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return s}});var r=n(2265);let o=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let u=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:o=24,strokeWidth:u=2,absoluteStrokeWidth:s,className:c="",children:l,iconNode:f,...d}=e;return(0,r.createElement)("svg",{ref:t,...i,width:o,height:o,stroke:n,strokeWidth:s?24*Number(u)/Number(o):u,className:a("lucide",c),...d},[...f.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(l)?l:[l]])}),s=(e,t)=>{let n=(0,r.forwardRef)((n,i)=>{let{className:s,...c}=n;return(0,r.createElement)(u,{ref:i,iconNode:t,className:a("lucide-".concat(o(e)),s),...c})});return n.displayName="".concat(e),n}},4401:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]])},8428:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]])},1769:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]])},1178:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]])},2222:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]])},4972:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]])},6215:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]])},2451:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]])},1723:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},91:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},5252:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]])},2735:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},8736:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},8220:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]])},3781:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]])},6272:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]])},9659:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("HeartPulse",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"1uw2ng"}]])},8997:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]])},4001:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]])},8124:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]])},5466:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]])},7692:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]])},3417:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},8662:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]])},3073:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Puzzle",[["path",{d:"M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.077.877.528 1.073 1.01a2.5 2.5 0 1 0 3.259-3.259c-.482-.196-.933-.558-1.01-1.073-.05-.336.062-.676.303-.917l1.525-1.525A2.402 2.402 0 0 1 12 1.998c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.237 3.237c-.464.18-.894.527-.967 1.02Z",key:"i0oyt7"}]])},8406:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]])},6137:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},8728:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},8906:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]])},2023:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]])},221:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]])},7829:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]])},6865:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},3628:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]])},1239:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]])},7648:function(e,t,n){"use strict";n.d(t,{default:function(){return o.a}});var r=n(2972),o=n.n(r)},9376:function(e,t,n){"use strict";var r=n(5475);n.o(r,"usePathname")&&n.d(t,{usePathname:function(){return r.usePathname}}),n.o(r,"useRouter")&&n.d(t,{useRouter:function(){return r.useRouter}}),n.o(r,"useSearchParams")&&n.d(t,{useSearchParams:function(){return r.useSearchParams}})},257:function(e,t,n){"use strict";var r,o;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(o=n.g.process)?void 0:o.env)?n.g.process:n(4227)},5449:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"addLocale",{enumerable:!0,get:function(){return r}}),n(8521);let r=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},6958:function(e,t,n){"use strict";function r(e,t,n,r){return!1}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"getDomainLocale",{enumerable:!0,get:function(){return r}}),n(8521),("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2972:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return R}});let r=n(7043),o=n(7437),a=r._(n(2265)),i=n(5246),u=n(3552),s=n(7497),c=n(3987),l=n(5449),f=n(5523),d=n(1956),p=n(6081),h=n(6958),y=n(1634),m=n(4673),g=new Set;function _(e,t,n,r,o,a){if("undefined"!=typeof window&&(a||(0,u.isLocalURL)(t))){if(!r.bypassPrefetchedCheck){let o=t+"%"+n+"%"+(void 0!==r.locale?r.locale:"locale"in e?e.locale:void 0);if(g.has(o))return;g.add(o)}(async()=>a?e.prefetch(t,o):e.prefetch(t,n,r))().catch(e=>{})}}function E(e){return"string"==typeof e?e:(0,s.formatUrl)(e)}let R=a.default.forwardRef(function(e,t){let n,r;let{href:s,as:g,children:R,prefetch:v=null,passHref:k,replace:b,shallow:x,scroll:P,locale:S,onClick:A,onMouseEnter:M,onTouchStart:T,legacyBehavior:O=!1,...N}=e;n=R,O&&("string"==typeof n||"number"==typeof n)&&(n=(0,o.jsx)("a",{children:n}));let w=a.default.useContext(f.RouterContext),I=a.default.useContext(d.AppRouterContext),C=null!=w?w:I,j=!w,L=!1!==v,Z=null===v?m.PrefetchKind.AUTO:m.PrefetchKind.FULL,{href:D,as:U}=a.default.useMemo(()=>{if(!w){let e=E(s);return{href:e,as:g?E(g):e}}let[e,t]=(0,i.resolveHref)(w,s,!0);return{href:e,as:g?(0,i.resolveHref)(w,g):t||e}},[w,s,g]),H=a.default.useRef(D),z=a.default.useRef(U);O&&(r=a.default.Children.only(n));let q=O?r&&"object"==typeof r&&r.ref:t,[F,V,X]=(0,p.useIntersection)({rootMargin:"200px"}),W=a.default.useCallback(e=>{(z.current!==U||H.current!==D)&&(X(),z.current=U,H.current=D),F(e),q&&("function"==typeof q?q(e):"object"==typeof q&&(q.current=e))},[U,q,D,X,F]);a.default.useEffect(()=>{C&&V&&L&&_(C,D,U,{locale:S},{kind:Z},j)},[U,D,V,S,L,null==w?void 0:w.locale,C,j,Z]);let G={ref:W,onClick(e){O||"function"!=typeof A||A(e),O&&r.props&&"function"==typeof r.props.onClick&&r.props.onClick(e),C&&!e.defaultPrevented&&function(e,t,n,r,o,i,s,c,l){let{nodeName:f}=e.currentTarget;if("A"===f.toUpperCase()&&(function(e){let t=e.currentTarget.getAttribute("target");return t&&"_self"!==t||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.nativeEvent&&2===e.nativeEvent.which}(e)||!l&&!(0,u.isLocalURL)(n)))return;e.preventDefault();let d=()=>{let e=null==s||s;"beforePopState"in t?t[o?"replace":"push"](n,r,{shallow:i,locale:c,scroll:e}):t[o?"replace":"push"](r||n,{scroll:e})};l?a.default.startTransition(d):d()}(e,C,D,U,b,x,P,S,j)},onMouseEnter(e){O||"function"!=typeof M||M(e),O&&r.props&&"function"==typeof r.props.onMouseEnter&&r.props.onMouseEnter(e),C&&(L||!j)&&_(C,D,U,{locale:S,priority:!0,bypassPrefetchedCheck:!0},{kind:Z},j)},onTouchStart:function(e){O||"function"!=typeof T||T(e),O&&r.props&&"function"==typeof r.props.onTouchStart&&r.props.onTouchStart(e),C&&(L||!j)&&_(C,D,U,{locale:S,priority:!0,bypassPrefetchedCheck:!0},{kind:Z},j)}};if((0,c.isAbsoluteUrl)(U))G.href=U;else if(!O||k||"a"===r.type&&!("href"in r.props)){let e=void 0!==S?S:null==w?void 0:w.locale,t=(null==w?void 0:w.isLocaleDomain)&&(0,h.getDomainLocale)(U,e,null==w?void 0:w.locales,null==w?void 0:w.domainLocales);G.href=t||(0,y.addBasePath)((0,l.addLocale)(U,e,null==w?void 0:w.defaultLocale))}return O?a.default.cloneElement(r,G):(0,o.jsx)("a",{...N,...G,children:n})});("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3515:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(t,{cancelIdleCallback:function(){return r},requestIdleCallback:function(){return n}});let n="undefined"!=typeof self&&self.requestIdleCallback&&self.requestIdleCallback.bind(window)||function(e){let t=Date.now();return self.setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1)},r="undefined"!=typeof self&&self.cancelIdleCallback&&self.cancelIdleCallback.bind(window)||function(e){return clearTimeout(e)};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},5246:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"resolveHref",{enumerable:!0,get:function(){return f}});let r=n(8637),o=n(7497),a=n(7053),i=n(3987),u=n(8521),s=n(3552),c=n(6279),l=n(7205);function f(e,t,n){let f;let d="string"==typeof t?t:(0,o.formatWithValidation)(t),p=d.match(/^[a-zA-Z]{1,}:\/\//),h=p?d.slice(p[0].length):d;if((h.split("?",1)[0]||"").match(/(\/\/|\\)/)){console.error("Invalid href '"+d+"' passed to next/router in page: '"+e.pathname+"'. Repeated forward-slashes (//) or backslashes \\ are not valid in the href.");let t=(0,i.normalizeRepeatedSlashes)(h);d=(p?p[0]:"")+t}if(!(0,s.isLocalURL)(d))return n?[d]:d;try{f=new URL(d.startsWith("#")?e.asPath:e.pathname,"http://n")}catch(e){f=new URL("/","http://n")}try{let e=new URL(d,f);e.pathname=(0,u.normalizePathTrailingSlash)(e.pathname);let t="";if((0,c.isDynamicRoute)(e.pathname)&&e.searchParams&&n){let n=(0,r.searchParamsToUrlQuery)(e.searchParams),{result:i,params:u}=(0,l.interpolateAs)(e.pathname,e.pathname,n);i&&(t=(0,o.formatWithValidation)({pathname:i,hash:e.hash,query:(0,a.omit)(n,u)}))}let i=e.origin===f.origin?e.href.slice(e.origin.length):e.href;return n?[i,t||i]:i}catch(e){return n?[d]:d}}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},6081:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"useIntersection",{enumerable:!0,get:function(){return s}});let r=n(2265),o=n(3515),a="function"==typeof IntersectionObserver,i=new Map,u=[];function s(e){let{rootRef:t,rootMargin:n,disabled:s}=e,c=s||!a,[l,f]=(0,r.useState)(!1),d=(0,r.useRef)(null),p=(0,r.useCallback)(e=>{d.current=e},[]);return(0,r.useEffect)(()=>{if(a){if(c||l)return;let e=d.current;if(e&&e.tagName)return function(e,t,n){let{id:r,observer:o,elements:a}=function(e){let t;let n={root:e.root||null,margin:e.rootMargin||""},r=u.find(e=>e.root===n.root&&e.margin===n.margin);if(r&&(t=i.get(r)))return t;let o=new Map;return t={id:n,observer:new IntersectionObserver(e=>{e.forEach(e=>{let t=o.get(e.target),n=e.isIntersecting||e.intersectionRatio>0;t&&n&&t(n)})},e),elements:o},u.push(n),i.set(n,t),t}(n);return a.set(e,t),o.observe(e),function(){if(a.delete(e),o.unobserve(e),0===a.size){o.disconnect(),i.delete(r);let e=u.findIndex(e=>e.root===r.root&&e.margin===r.margin);e>-1&&u.splice(e,1)}}}(e,e=>e&&f(e),{root:null==t?void 0:t.current,rootMargin:n})}else if(!l){let e=(0,o.requestIdleCallback)(()=>f(!0));return()=>(0,o.cancelIdleCallback)(e)}},[c,n,t,l,d.current]),[p,l,(0,r.useCallback)(()=>{f(!1)},[])]}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},4227:function(e){!function(){var t={229:function(e){var t,n,r,o=e.exports={};function a(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function u(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var s=[],c=!1,l=-1;function f(){c&&r&&(c=!1,r.length?s=r.concat(s):l=-1,s.length&&d())}function d(){if(!c){var e=u(f);c=!0;for(var t=s.length;t;){for(r=s,s=[];++l<t;)r&&r[l].run();l=-1,t=s.length}r=null,c=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function h(){}o.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];s.push(new p(e,t)),1!==s.length||c||u(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=h,o.addListener=h,o.once=h,o.off=h,o.removeListener=h,o.removeAllListeners=h,o.emit=h,o.prependListener=h,o.prependOnceListener=h,o.listeners=function(e){return[]},o.binding=function(e){throw Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw Error("process.chdir is not supported")},o.umask=function(){return 0}}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}},i=!0;try{t[e](a,a.exports,r),i=!1}finally{i&&delete n[e]}return a.exports}r.ab="//";var o=r(229);e.exports=o}()},9259:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(t,{ACTION_SUFFIX:function(){return s},APP_DIR_ALIAS:function(){return A},CACHE_ONE_YEAR:function(){return R},DOT_NEXT_ALIAS:function(){return P},ESLINT_DEFAULT_DIRS:function(){return X},GSP_NO_RETURNED_VALUE:function(){return U},GSSP_COMPONENT_MEMBER_ERROR:function(){return q},GSSP_NO_RETURNED_VALUE:function(){return H},INSTRUMENTATION_HOOK_FILENAME:function(){return b},MIDDLEWARE_FILENAME:function(){return v},MIDDLEWARE_LOCATION_REGEXP:function(){return k},NEXT_BODY_SUFFIX:function(){return f},NEXT_CACHE_IMPLICIT_TAG_ID:function(){return E},NEXT_CACHE_REVALIDATED_TAGS_HEADER:function(){return h},NEXT_CACHE_REVALIDATE_TAG_TOKEN_HEADER:function(){return y},NEXT_CACHE_SOFT_TAGS_HEADER:function(){return p},NEXT_CACHE_SOFT_TAG_MAX_LENGTH:function(){return _},NEXT_CACHE_TAGS_HEADER:function(){return d},NEXT_CACHE_TAG_MAX_ITEMS:function(){return m},NEXT_CACHE_TAG_MAX_LENGTH:function(){return g},NEXT_DATA_SUFFIX:function(){return c},NEXT_INTERCEPTION_MARKER_PREFIX:function(){return r},NEXT_META_SUFFIX:function(){return l},NEXT_QUERY_PARAM_PREFIX:function(){return n},NON_STANDARD_NODE_ENV:function(){return F},PAGES_DIR_ALIAS:function(){return x},PRERENDER_REVALIDATE_HEADER:function(){return o},PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER:function(){return a},PUBLIC_DIR_MIDDLEWARE_CONFLICT:function(){return I},ROOT_DIR_ALIAS:function(){return S},RSC_ACTION_CLIENT_WRAPPER_ALIAS:function(){return w},RSC_ACTION_ENCRYPTION_ALIAS:function(){return N},RSC_ACTION_PROXY_ALIAS:function(){return O},RSC_ACTION_VALIDATE_ALIAS:function(){return T},RSC_MOD_REF_PROXY_ALIAS:function(){return M},RSC_PREFETCH_SUFFIX:function(){return i},RSC_SUFFIX:function(){return u},SERVER_PROPS_EXPORT_ERROR:function(){return D},SERVER_PROPS_GET_INIT_PROPS_CONFLICT:function(){return j},SERVER_PROPS_SSG_CONFLICT:function(){return L},SERVER_RUNTIME:function(){return W},SSG_FALLBACK_EXPORT_ERROR:function(){return V},SSG_GET_INITIAL_PROPS_CONFLICT:function(){return C},STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR:function(){return Z},UNSTABLE_REVALIDATE_RENAME_ERROR:function(){return z},WEBPACK_LAYERS:function(){return B},WEBPACK_RESOURCE_QUERIES:function(){return Y}});let n="nxtP",r="nxtI",o="x-prerender-revalidate",a="x-prerender-revalidate-if-generated",i=".prefetch.rsc",u=".rsc",s=".action",c=".json",l=".meta",f=".body",d="x-next-cache-tags",p="x-next-cache-soft-tags",h="x-next-revalidated-tags",y="x-next-revalidate-tag-token",m=128,g=256,_=1024,E="_N_T_",R=31536e3,v="middleware",k=`(?:src/)?${v}`,b="instrumentation",x="private-next-pages",P="private-dot-next",S="private-next-root-dir",A="private-next-app-dir",M="private-next-rsc-mod-ref-proxy",T="private-next-rsc-action-validate",O="private-next-rsc-server-reference",N="private-next-rsc-action-encryption",w="private-next-rsc-action-client-wrapper",I="You can not have a '_next' folder inside of your public folder. This conflicts with the internal '/_next' route. https://nextjs.org/docs/messages/public-next-folder-conflict",C="You can not use getInitialProps with getStaticProps. To use SSG, please remove your getInitialProps",j="You can not use getInitialProps with getServerSideProps. Please remove getInitialProps.",L="You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps",Z="can not have getInitialProps/getServerSideProps, https://nextjs.org/docs/messages/404-get-initial-props",D="pages with `getServerSideProps` can not be exported. See more info here: https://nextjs.org/docs/messages/gssp-export",U="Your `getStaticProps` function did not return an object. Did you forget to add a `return`?",H="Your `getServerSideProps` function did not return an object. Did you forget to add a `return`?",z="The `unstable_revalidate` property is available for general use.\nPlease use `revalidate` instead.",q="can not be attached to a page's component and must be exported from the page. See more info here: https://nextjs.org/docs/messages/gssp-component-member",F='You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env',V="Pages with `fallback` enabled in `getStaticPaths` can not be exported. See more info here: https://nextjs.org/docs/messages/ssg-fallback-true-export",X=["app","pages","components","lib","src"],W={edge:"edge",experimentalEdge:"experimental-edge",nodejs:"nodejs"},G={shared:"shared",reactServerComponents:"rsc",serverSideRendering:"ssr",actionBrowser:"action-browser",api:"api",middleware:"middleware",instrument:"instrument",edgeAsset:"edge-asset",appPagesBrowser:"app-pages-browser",appMetadataRoute:"app-metadata-route",appRouteHandler:"app-route-handler"},B={...G,GROUP:{serverOnly:[G.reactServerComponents,G.actionBrowser,G.appMetadataRoute,G.appRouteHandler,G.instrument],clientOnly:[G.serverSideRendering,G.appPagesBrowser],nonClientServerTarget:[G.middleware,G.api],app:[G.reactServerComponents,G.actionBrowser,G.appMetadataRoute,G.appRouteHandler,G.serverSideRendering,G.appPagesBrowser,G.shared,G.instrument]}},Y={edgeSSREntry:"__next_edge_ssr_entry__",metadata:"__next_metadata__",metadataRoute:"__next_metadata_route__",metadataImageMeta:"__next_metadata_image_meta__"}},42:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"escapeStringRegexp",{enumerable:!0,get:function(){return o}});let n=/[|\\{}()[\]^$+*?.-]/,r=/[|\\{}()[\]^$+*?.-]/g;function o(e){return n.test(e)?e.replace(r,"\\$&"):e}},5523:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"RouterContext",{enumerable:!0,get:function(){return r}});let r=n(7043)._(n(2265)).default.createContext(null)},7497:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(t,{formatUrl:function(){return a},formatWithValidation:function(){return u},urlObjectKeys:function(){return i}});let r=n(3099)._(n(8637)),o=/https?|ftp|gopher|file/;function a(e){let{auth:t,hostname:n}=e,a=e.protocol||"",i=e.pathname||"",u=e.hash||"",s=e.query||"",c=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?c=t+e.host:n&&(c=t+(~n.indexOf(":")?"["+n+"]":n),e.port&&(c+=":"+e.port)),s&&"object"==typeof s&&(s=String(r.urlQueryToSearchParams(s)));let l=e.search||s&&"?"+s||"";return a&&!a.endsWith(":")&&(a+=":"),e.slashes||(!a||o.test(a))&&!1!==c?(c="//"+(c||""),i&&"/"!==i[0]&&(i="/"+i)):c||(c=""),u&&"#"!==u[0]&&(u="#"+u),l&&"?"!==l[0]&&(l="?"+l),""+a+c+(i=i.replace(/[?#]/g,encodeURIComponent))+(l=l.replace("#","%23"))+u}let i=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function u(e){return a(e)}},6279:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(t,{getSortedRoutes:function(){return r.getSortedRoutes},isDynamicRoute:function(){return o.isDynamicRoute}});let r=n(4777),o=n(8104)},7205:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"interpolateAs",{enumerable:!0,get:function(){return a}});let r=n(4199),o=n(9964);function a(e,t,n){let a="",i=(0,o.getRouteRegex)(e),u=i.groups,s=(t!==e?(0,r.getRouteMatcher)(i)(t):"")||n;a=e;let c=Object.keys(u);return c.every(e=>{let t=s[e]||"",{repeat:n,optional:r}=u[e],o="["+(n?"...":"")+e+"]";return r&&(o=(t?"":"/")+"["+o+"]"),n&&!Array.isArray(t)&&(t=[t]),(r||e in s)&&(a=a.replace(o,n?t.map(e=>encodeURIComponent(e)).join("/"):encodeURIComponent(t))||"/")})||(a=""),{params:c,result:a}}},8104:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"isDynamicRoute",{enumerable:!0,get:function(){return a}});let r=n(1182),o=/\/\[[^/]+?\](?=\/|$)/;function a(e){return(0,r.isInterceptionRouteAppPath)(e)&&(e=(0,r.extractInterceptionRouteInformation)(e).interceptedRoute),o.test(e)}},3552:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"isLocalURL",{enumerable:!0,get:function(){return a}});let r=n(3987),o=n(1283);function a(e){if(!(0,r.isAbsoluteUrl)(e))return!0;try{let t=(0,r.getLocationOrigin)(),n=new URL(e,t);return n.origin===t&&(0,o.hasBasePath)(n.pathname)}catch(e){return!1}}},7053:function(e,t){"use strict";function n(e,t){let n={};return Object.keys(e).forEach(r=>{t.includes(r)||(n[r]=e[r])}),n}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"omit",{enumerable:!0,get:function(){return n}})},8637:function(e,t){"use strict";function n(e){let t={};return e.forEach((e,n)=>{void 0===t[n]?t[n]=e:Array.isArray(t[n])?t[n].push(e):t[n]=[t[n],e]}),t}function r(e){return"string"!=typeof e&&("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function o(e){let t=new URLSearchParams;return Object.entries(e).forEach(e=>{let[n,o]=e;Array.isArray(o)?o.forEach(e=>t.append(n,r(e))):t.set(n,r(o))}),t}function a(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.forEach(t=>{Array.from(t.keys()).forEach(t=>e.delete(t)),t.forEach((t,n)=>e.append(n,t))}),e}Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(t,{assign:function(){return a},searchParamsToUrlQuery:function(){return n},urlQueryToSearchParams:function(){return o}})},4199:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"getRouteMatcher",{enumerable:!0,get:function(){return o}});let r=n(3987);function o(e){let{re:t,groups:n}=e;return e=>{let o=t.exec(e);if(!o)return!1;let a=e=>{try{return decodeURIComponent(e)}catch(e){throw new r.DecodeError("failed to decode param")}},i={};return Object.keys(n).forEach(e=>{let t=n[e],r=o[t.pos];void 0!==r&&(i[e]=~r.indexOf("/")?r.split("/").map(e=>a(e)):t.repeat?[a(r)]:a(r))}),i}}},9964:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(t,{getNamedMiddlewareRegex:function(){return p},getNamedRouteRegex:function(){return d},getRouteRegex:function(){return c},parseParameter:function(){return u}});let r=n(9259),o=n(1182),a=n(42),i=n(6674);function u(e){let t=e.startsWith("[")&&e.endsWith("]");t&&(e=e.slice(1,-1));let n=e.startsWith("...");return n&&(e=e.slice(3)),{key:e,repeat:n,optional:t}}function s(e){let t=(0,i.removeTrailingSlash)(e).slice(1).split("/"),n={},r=1;return{parameterizedRoute:t.map(e=>{let t=o.INTERCEPTION_ROUTE_MARKERS.find(t=>e.startsWith(t)),i=e.match(/\[((?:\[.*\])|.+)\]/);if(t&&i){let{key:e,optional:o,repeat:s}=u(i[1]);return n[e]={pos:r++,repeat:s,optional:o},"/"+(0,a.escapeStringRegexp)(t)+"([^/]+?)"}if(!i)return"/"+(0,a.escapeStringRegexp)(e);{let{key:e,repeat:t,optional:o}=u(i[1]);return n[e]={pos:r++,repeat:t,optional:o},t?o?"(?:/(.+?))?":"/(.+?)":"/([^/]+?)"}}).join(""),groups:n}}function c(e){let{parameterizedRoute:t,groups:n}=s(e);return{re:RegExp("^"+t+"(?:/)?$"),groups:n}}function l(e){let{interceptionMarker:t,getSafeRouteKey:n,segment:r,routeKeys:o,keyPrefix:i}=e,{key:s,optional:c,repeat:l}=u(r),f=s.replace(/\W/g,"");i&&(f=""+i+f);let d=!1;(0===f.length||f.length>30)&&(d=!0),isNaN(parseInt(f.slice(0,1)))||(d=!0),d&&(f=n()),i?o[f]=""+i+s:o[f]=s;let p=t?(0,a.escapeStringRegexp)(t):"";return l?c?"(?:/"+p+"(?<"+f+">.+?))?":"/"+p+"(?<"+f+">.+?)":"/"+p+"(?<"+f+">[^/]+?)"}function f(e,t){let n;let u=(0,i.removeTrailingSlash)(e).slice(1).split("/"),s=(n=0,()=>{let e="",t=++n;for(;t>0;)e+=String.fromCharCode(97+(t-1)%26),t=Math.floor((t-1)/26);return e}),c={};return{namedParameterizedRoute:u.map(e=>{let n=o.INTERCEPTION_ROUTE_MARKERS.some(t=>e.startsWith(t)),i=e.match(/\[((?:\[.*\])|.+)\]/);if(n&&i){let[n]=e.split(i[0]);return l({getSafeRouteKey:s,interceptionMarker:n,segment:i[1],routeKeys:c,keyPrefix:t?r.NEXT_INTERCEPTION_MARKER_PREFIX:void 0})}return i?l({getSafeRouteKey:s,segment:i[1],routeKeys:c,keyPrefix:t?r.NEXT_QUERY_PARAM_PREFIX:void 0}):"/"+(0,a.escapeStringRegexp)(e)}).join(""),routeKeys:c}}function d(e,t){let n=f(e,t);return{...c(e),namedRegex:"^"+n.namedParameterizedRoute+"(?:/)?$",routeKeys:n.routeKeys}}function p(e,t){let{parameterizedRoute:n}=s(e),{catchAll:r=!0}=t;if("/"===n)return{namedRegex:"^/"+(r?".*":"")+"$"};let{namedParameterizedRoute:o}=f(e,!1);return{namedRegex:"^"+o+(r?"(?:(/.*)?)":"")+"$"}}},4777:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"getSortedRoutes",{enumerable:!0,get:function(){return r}});class n{insert(e){this._insert(e.split("/").filter(Boolean),[],!1)}smoosh(){return this._smoosh()}_smoosh(e){void 0===e&&(e="/");let t=[...this.children.keys()].sort();null!==this.slugName&&t.splice(t.indexOf("[]"),1),null!==this.restSlugName&&t.splice(t.indexOf("[...]"),1),null!==this.optionalRestSlugName&&t.splice(t.indexOf("[[...]]"),1);let n=t.map(t=>this.children.get(t)._smoosh(""+e+t+"/")).reduce((e,t)=>[...e,...t],[]);if(null!==this.slugName&&n.push(...this.children.get("[]")._smoosh(e+"["+this.slugName+"]/")),!this.placeholder){let t="/"===e?"/":e.slice(0,-1);if(null!=this.optionalRestSlugName)throw Error('You cannot define a route with the same specificity as a optional catch-all route ("'+t+'" and "'+t+"[[..."+this.optionalRestSlugName+']]").');n.unshift(t)}return null!==this.restSlugName&&n.push(...this.children.get("[...]")._smoosh(e+"[..."+this.restSlugName+"]/")),null!==this.optionalRestSlugName&&n.push(...this.children.get("[[...]]")._smoosh(e+"[[..."+this.optionalRestSlugName+"]]/")),n}_insert(e,t,r){if(0===e.length){this.placeholder=!1;return}if(r)throw Error("Catch-all must be the last part of the URL.");let o=e[0];if(o.startsWith("[")&&o.endsWith("]")){let n=o.slice(1,-1),i=!1;if(n.startsWith("[")&&n.endsWith("]")&&(n=n.slice(1,-1),i=!0),n.startsWith("...")&&(n=n.substring(3),r=!0),n.startsWith("[")||n.endsWith("]"))throw Error("Segment names may not start or end with extra brackets ('"+n+"').");if(n.startsWith("."))throw Error("Segment names may not start with erroneous periods ('"+n+"').");function a(e,n){if(null!==e&&e!==n)throw Error("You cannot use different slug names for the same dynamic path ('"+e+"' !== '"+n+"').");t.forEach(e=>{if(e===n)throw Error('You cannot have the same slug name "'+n+'" repeat within a single dynamic path');if(e.replace(/\W/g,"")===o.replace(/\W/g,""))throw Error('You cannot have the slug names "'+e+'" and "'+n+'" differ only by non-word symbols within a single dynamic path')}),t.push(n)}if(r){if(i){if(null!=this.restSlugName)throw Error('You cannot use both an required and optional catch-all route at the same level ("[...'+this.restSlugName+']" and "'+e[0]+'" ).');a(this.optionalRestSlugName,n),this.optionalRestSlugName=n,o="[[...]]"}else{if(null!=this.optionalRestSlugName)throw Error('You cannot use both an optional and required catch-all route at the same level ("[[...'+this.optionalRestSlugName+']]" and "'+e[0]+'").');a(this.restSlugName,n),this.restSlugName=n,o="[...]"}}else{if(i)throw Error('Optional route parameters are not yet supported ("'+e[0]+'").');a(this.slugName,n),this.slugName=n,o="[]"}}this.children.has(o)||this.children.set(o,new n),this.children.get(o)._insert(e.slice(1),t,r)}constructor(){this.placeholder=!0,this.children=new Map,this.slugName=null,this.restSlugName=null,this.optionalRestSlugName=null}}function r(e){let t=new n;return e.forEach(e=>t.insert(e)),t.smoosh()}},3987:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(t,{DecodeError:function(){return h},MiddlewareNotFoundError:function(){return _},MissingStaticPage:function(){return g},NormalizeError:function(){return y},PageNotFoundError:function(){return m},SP:function(){return d},ST:function(){return p},WEB_VITALS:function(){return n},execOnce:function(){return r},getDisplayName:function(){return s},getLocationOrigin:function(){return i},getURL:function(){return u},isAbsoluteUrl:function(){return a},isResSent:function(){return c},loadGetInitialProps:function(){return f},normalizeRepeatedSlashes:function(){return l},stringifyError:function(){return E}});let n=["CLS","FCP","FID","INP","LCP","TTFB"];function r(e){let t,n=!1;return function(){for(var r=arguments.length,o=Array(r),a=0;a<r;a++)o[a]=arguments[a];return n||(n=!0,t=e(...o)),t}}let o=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,a=e=>o.test(e);function i(){let{protocol:e,hostname:t,port:n}=window.location;return e+"//"+t+(n?":"+n:"")}function u(){let{href:e}=window.location,t=i();return e.substring(t.length)}function s(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function c(e){return e.finished||e.headersSent}function l(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?"?"+t.slice(1).join("?"):"")}async function f(e,t){let n=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await f(t.Component,t.ctx)}:{};let r=await e.getInitialProps(t);if(n&&c(n))return r;if(!r)throw Error('"'+s(e)+'.getInitialProps()" should resolve to an object. But found "'+r+'" instead.');return r}let d="undefined"!=typeof performance,p=d&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class h extends Error{}class y extends Error{}class m extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message="Cannot find module for page: "+e}}class g extends Error{constructor(e,t){super(),this.message="Failed to load static file for page: "+e+" "+t}}class _ extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function E(e){return JSON.stringify({message:e.message,stack:e.stack})}}}]);
 
 
static/_next/static/chunks/app/ab-tests/{page-07c292a107a6b7eb.js → page-2b8d2c50e2a70e90.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4502],{7452:function(e,t,a){Promise.resolve().then(a.bind(a,8580))},9205:function(e,t,a){"use strict";a.d(t,{Z:function(){return c}});var s=a(2265);let r=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),n=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&a.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,s.forwardRef)((e,t)=>{let{color:a="currentColor",size:r=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...m}=e;return(0,s.createElement)("svg",{ref:t,...i,width:r,height:r,stroke:a,strokeWidth:c?24*Number(l)/Number(r):l,className:n("lucide",o),...m},[...u.map(e=>{let[t,a]=e;return(0,s.createElement)(t,a)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let a=(0,s.forwardRef)((a,i)=>{let{className:c,...o}=a;return(0,s.createElement)(l,{ref:i,iconNode:t,className:n("lucide-".concat(r(e)),c),...o})});return a.displayName="".concat(e),a}},6272:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(9205).Z)("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]])},3276:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(9205).Z)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},9397:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7168:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},8930:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,a){"use strict";var s,r;e.exports=(null==(s=a.g.process)?void 0:s.env)&&"object"==typeof(null==(r=a.g.process)?void 0:r.env)?a.g.process:a(4227)},4227:function(e){!function(){var t={229:function(e){var t,a,s,r=e.exports={};function n(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:n}catch(e){t=n}try{a="function"==typeof clearTimeout?clearTimeout:i}catch(e){a=i}}();var c=[],o=!1,d=-1;function u(){o&&s&&(o=!1,s.length?c=s.concat(c):d=-1,c.length&&m())}function m(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(s=c,c=[];++d<t;)s&&s[d].run();d=-1,t=c.length}s=null,o=!1,function(e){if(a===clearTimeout)return clearTimeout(e);if((a===i||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function p(){}r.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)t[a-1]=arguments[a];c.push(new h(e,t)),1!==c.length||o||l(m)},h.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=p,r.addListener=p,r.once=p,r.off=p,r.removeListener=p,r.removeAllListeners=p,r.emit=p,r.prependListener=p,r.prependOnceListener=p,r.listeners=function(e){return[]},r.binding=function(e){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw Error("process.chdir is not supported")},r.umask=function(){return 0}}},a={};function s(e){var r=a[e];if(void 0!==r)return r.exports;var n=a[e]={exports:{}},i=!0;try{t[e](n,n.exports,s),i=!1}finally{i&&delete a[e]}return n.exports}s.ab="//";var r=s(229);e.exports=r}()},8580:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return m}});var s=a(7437),r=a(2265),n=a(1837),i=a(9397),l=a(6272);let c=(0,a(9205).Z)("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);var o=a(3276),d=a(7168),u=a(8930);function m(){let[e,t]=(0,r.useState)([]),[a,m]=(0,r.useState)(!0),[h,p]=(0,r.useState)(""),[x,v]=(0,r.useState)(!1),[f,j]=(0,r.useState)([]),[g,b]=(0,r.useState)({name:"",description:"",split_percent:50,variant_a_provider:"",variant_a_model:"",variant_b_provider:"",variant_b_model:"",trigger_models:""}),_=()=>{m(!0),Promise.all([n.hi.get("/api/ab-tests").catch(()=>[]),n.hi.get("/api/providers").then(e=>j(Object.keys(e))).catch(()=>{})]).then(e=>{let[a]=e;return t(a)}).finally(()=>m(!1))};(0,r.useEffect)(()=>{_()},[]);let y=async e=>{await n.hi.patch("/api/ab-tests/".concat(e,"/toggle")),_()},N=async e=>{confirm("Reset stats for this A/B test?")&&(await n.hi.post("/api/ab-tests/".concat(e,"/reset")),_())},w=async e=>{confirm("Delete this A/B test?")&&(await n.hi.delete("/api/ab-tests/".concat(e)),_())},k=async()=>{if(g.name&&g.variant_a_provider&&g.variant_a_model&&g.variant_b_provider&&g.variant_b_model)try{let e={name:g.name,split_percent:g.split_percent,variant_a_provider:g.variant_a_provider,variant_a_model:g.variant_a_model,variant_b_provider:g.variant_b_provider,variant_b_model:g.variant_b_model};g.description&&(e.description=g.description),g.trigger_models&&(e.trigger_models=g.trigger_models.split(",").map(e=>e.trim()).filter(Boolean)),await n.hi.post("/api/ab-tests",e),v(!1),b({name:"",description:"",split_percent:50,variant_a_provider:"",variant_a_model:"",variant_b_provider:"",variant_b_model:"",trigger_models:""}),_()}catch(e){p(e instanceof Error?e.message:"Failed")}};r.useEffect(()=>{if(h){let e=setTimeout(()=>p(""),3e3);return()=>clearTimeout(e)}},[h]);let T=e=>{if(0===e.total_a&&0===e.total_b)return null;let t=100*e.error_rate_a+.01*e.avg_latency_a+e.avg_cost_a,a=100*e.error_rate_b+.01*e.avg_latency_b+e.avg_cost_b;return .001>Math.abs(t-a)?null:t<a?"a":"b"},C=e=>(100*e).toFixed(1)+"%",E=e=>"$"+e.toFixed(4),A=e=>e.toFixed(0)+"ms";return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"page-header",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"page-title",children:"A/B Tests"}),(0,s.jsx)("p",{className:"page-sub",children:"Compare model variants side-by-side"})]}),(0,s.jsxs)("button",{className:"btn-primary",onClick:()=>v(!0),children:[(0,s.jsx)(i.Z,{size:16})," New Test"]})]}),x&&(0,s.jsx)("div",{className:"modal-overlay",onClick:()=>v(!1),children:(0,s.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"New A/B Test"}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Name"}),(0,s.jsx)("input",{className:"input",value:g.name,onChange:e=>b(t=>({...t,name:e.target.value})),autoFocus:!0})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Description"}),(0,s.jsx)("input",{className:"input",value:g.description,onChange:e=>b(t=>({...t,description:e.target.value}))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Split % (first variant)"}),(0,s.jsx)("input",{className:"input",type:"number",min:1,max:99,value:g.split_percent,onChange:e=>b(t=>({...t,split_percent:Number(e.target.value)}))})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-blue-400",children:"Variant A"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Provider"}),(0,s.jsxs)("select",{className:"select",value:g.variant_a_provider,onChange:e=>b(t=>({...t,variant_a_provider:e.target.value})),children:[(0,s.jsx)("option",{value:"",children:"Select"}),f.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Model"}),(0,s.jsx)("input",{className:"input",value:g.variant_a_model,onChange:e=>b(t=>({...t,variant_a_model:e.target.value})),placeholder:"gpt-4o"})]})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-purple-400",children:"Variant B"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Provider"}),(0,s.jsxs)("select",{className:"select",value:g.variant_b_provider,onChange:e=>b(t=>({...t,variant_b_provider:e.target.value})),children:[(0,s.jsx)("option",{value:"",children:"Select"}),f.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Model"}),(0,s.jsx)("input",{className:"input",value:g.variant_b_model,onChange:e=>b(t=>({...t,variant_b_model:e.target.value})),placeholder:"claude-3-opus"})]})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"label",children:["Trigger Models ",(0,s.jsx)("span",{className:"text-[var(--text-tertiary)] font-normal",children:"comma-separated, leave empty for all"})]}),(0,s.jsx)("input",{className:"input",value:g.trigger_models,onChange:e=>b(t=>({...t,trigger_models:e.target.value})),placeholder:"gpt-4o, claude-3-opus"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:k,children:"Create"}),(0,s.jsx)("button",{className:"btn-ghost",onClick:()=>v(!1),children:"Cancel"})]})]})]})}),a?(0,s.jsx)("div",{className:"card",children:(0,s.jsx)("div",{className:"skeleton h-48 w-full"})}):0===e.length?(0,s.jsxs)("div",{className:"card text-center py-12",children:[(0,s.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,s.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No A/B tests configured."})]}):(0,s.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:e.map(e=>{let t=T(e);return(0,s.jsxs)("div",{className:"card",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold truncate",children:e.name}),e.description&&(0,s.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 truncate",children:e.description})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 ml-3 shrink-0",children:[(0,s.jsx)("button",{onClick:()=>y(e.id),title:e.is_active?"Disable":"Enable",children:e.is_active?(0,s.jsx)(c,{size:14,className:"text-green-400"}):(0,s.jsx)(o.Z,{size:14,className:"text-[var(--text-tertiary)]"})}),(0,s.jsx)("button",{onClick:()=>N(e.id),title:"Reset stats",children:(0,s.jsx)(d.Z,{size:14,className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"})}),(0,s.jsx)("button",{onClick:()=>w(e.id),title:"Delete",children:(0,s.jsx)(u.Z,{size:14,className:"text-red-400"})})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)("span",{className:"badge-".concat(e.is_active?"green":"red"),children:e.is_active?"Active":"Paused"}),(0,s.jsxs)("span",{className:"text-xs text-[var(--text-tertiary)]",children:[e.split_percent,"% / ",100-e.split_percent,"% split"]}),e.trigger_models.length>0&&(0,s.jsxs)("span",{className:"text-xs text-[var(--text-tertiary)] ml-auto truncate",title:e.trigger_models.join(", "),children:["triggers: ",e.trigger_models.join(", ")]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("div",{className:"p-3 rounded-lg border ".concat("a"===t?"border-blue-500/40 bg-blue-500/5":"border-[var(--border)]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-blue-400",children:"Variant A"}),"a"===t&&(0,s.jsx)("span",{className:"text-[10px] font-semibold text-blue-400",children:"WINNING"})]}),(0,s.jsxs)("p",{className:"text-xs font-mono mb-1 truncate",children:[e.variant_a_provider,"/",e.variant_a_model]}),(0,s.jsxs)("div",{className:"space-y-0.5 text-[11px] text-[var(--text-secondary)]",children:[(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Requests"}),(0,s.jsx)("span",{className:"font-mono",children:e.total_a})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Avg Latency"}),(0,s.jsx)("span",{className:"font-mono",children:A(e.avg_latency_a)})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Avg Cost"}),(0,s.jsx)("span",{className:"font-mono",children:E(e.avg_cost_a)})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Error Rate"}),(0,s.jsx)("span",{className:"font-mono",children:C(e.error_rate_a)})]})]})]}),(0,s.jsxs)("div",{className:"p-3 rounded-lg border ".concat("b"===t?"border-purple-500/40 bg-purple-500/5":"border-[var(--border)]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-purple-400",children:"Variant B"}),"b"===t&&(0,s.jsx)("span",{className:"text-[10px] font-semibold text-purple-400",children:"WINNING"})]}),(0,s.jsxs)("p",{className:"text-xs font-mono mb-1 truncate",children:[e.variant_b_provider,"/",e.variant_b_model]}),(0,s.jsxs)("div",{className:"space-y-0.5 text-[11px] text-[var(--text-secondary)]",children:[(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Requests"}),(0,s.jsx)("span",{className:"font-mono",children:e.total_b})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Avg Latency"}),(0,s.jsx)("span",{className:"font-mono",children:A(e.avg_latency_b)})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Avg Cost"}),(0,s.jsx)("span",{className:"font-mono",children:E(e.avg_cost_b)})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Error Rate"}),(0,s.jsx)("span",{className:"font-mono",children:C(e.error_rate_b)})]})]})]})]})]},e.id)})}),h&&(0,s.jsx)("div",{className:"toast",children:h})]})}},1837:function(e,t,a){"use strict";a.d(t,{KF:function(){return m},hi:function(){return u},jl:function(){return i},qz:function(){return n}});let s=a(257).env.NEXT_PUBLIC_API_BASE||"";function r(){return localStorage.getItem("nexus_token")}function n(){localStorage.removeItem("nexus_token")}function i(){return!!r()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.method||"GET",i=r(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===a&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let a=o.get(e);if(a)return a}let u=(async()=>{let r=await fetch("".concat(s).concat(e),{method:a,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return r;if(401===r.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw n(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!r.ok)throw Error((await r.json().catch(()=>({detail:r.statusText}))).detail||"HTTP ".concat(r.status));if(204===r.status)return;let l=await r.json();return"GET"!==a||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===a&&!i){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var a;let s=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return a=s.access_token,localStorage.setItem("nexus_token",a),s},getMe:()=>d("/api/auth/me"),logout:()=>{n(),c.clear(),window.location.href="/login"}},m=async e=>{let t=r(),a=await fetch("".concat(s).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!a.ok)throw Error("Failed to download");let n=await a.blob(),i=URL.createObjectURL(n),l=document.createElement("a");l.href=i,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=7452)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4502],{7452:function(e,t,a){Promise.resolve().then(a.bind(a,8580))},9205:function(e,t,a){"use strict";a.d(t,{Z:function(){return c}});var r=a(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),n=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&a.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,r.forwardRef)((e,t)=>{let{color:a="currentColor",size:s=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...m}=e;return(0,r.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:a,strokeWidth:c?24*Number(l)/Number(s):l,className:n("lucide",o),...m},[...u.map(e=>{let[t,a]=e;return(0,r.createElement)(t,a)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let a=(0,r.forwardRef)((a,i)=>{let{className:c,...o}=a;return(0,r.createElement)(l,{ref:i,iconNode:t,className:n("lucide-".concat(s(e)),c),...o})});return a.displayName="".concat(e),a}},6272:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]])},3276:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},9397:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7168:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},8930:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,a){"use strict";var r,s;e.exports=(null==(r=a.g.process)?void 0:r.env)&&"object"==typeof(null==(s=a.g.process)?void 0:s.env)?a.g.process:a(4227)},4227:function(e){!function(){var t={229:function(e){var t,a,r,s=e.exports={};function n(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:n}catch(e){t=n}try{a="function"==typeof clearTimeout?clearTimeout:i}catch(e){a=i}}();var c=[],o=!1,d=-1;function u(){o&&r&&(o=!1,r.length?c=r.concat(c):d=-1,c.length&&m())}function m(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(r=c,c=[];++d<t;)r&&r[d].run();d=-1,t=c.length}r=null,o=!1,function(e){if(a===clearTimeout)return clearTimeout(e);if((a===i||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function p(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)t[a-1]=arguments[a];c.push(new h(e,t)),1!==c.length||o||l(m)},h.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=p,s.addListener=p,s.once=p,s.off=p,s.removeListener=p,s.removeAllListeners=p,s.emit=p,s.prependListener=p,s.prependOnceListener=p,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},a={};function r(e){var s=a[e];if(void 0!==s)return s.exports;var n=a[e]={exports:{}},i=!0;try{t[e](n,n.exports,r),i=!1}finally{i&&delete a[e]}return n.exports}r.ab="//";var s=r(229);e.exports=s}()},8580:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return m}});var r=a(7437),s=a(2265),n=a(1837),i=a(9397),l=a(6272);let c=(0,a(9205).Z)("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);var o=a(3276),d=a(7168),u=a(8930);function m(){let[e,t]=(0,s.useState)([]),[a,m]=(0,s.useState)(!0),[h,p]=(0,s.useState)(""),[x,v]=(0,s.useState)(!1),[f,g]=(0,s.useState)([]),[j,b]=(0,s.useState)({name:"",description:"",split_percent:50,variant_a_provider:"",variant_a_model:"",variant_b_provider:"",variant_b_model:"",trigger_models:""}),_=()=>{m(!0),Promise.all([n.hi.get("/api/ab-tests").catch(()=>[]),n.hi.get("/api/providers").then(e=>g(Object.keys(e))).catch(()=>{})]).then(e=>{let[a]=e;return t(a)}).finally(()=>m(!1))};(0,s.useEffect)(()=>{_()},[]);let y=async e=>{await n.hi.patch("/api/ab-tests/".concat(e,"/toggle")),_()},N=async e=>{confirm("Reset stats for this A/B test?")&&(await n.hi.post("/api/ab-tests/".concat(e,"/reset")),_())},w=async e=>{confirm("Delete this A/B test?")&&(await n.hi.delete("/api/ab-tests/".concat(e)),_())},k=async()=>{if(j.name&&j.variant_a_provider&&j.variant_a_model&&j.variant_b_provider&&j.variant_b_model)try{let e={name:j.name,split_percent:j.split_percent,variant_a_provider:j.variant_a_provider,variant_a_model:j.variant_a_model,variant_b_provider:j.variant_b_provider,variant_b_model:j.variant_b_model};j.description&&(e.description=j.description),j.trigger_models&&(e.trigger_models=j.trigger_models.split(",").map(e=>e.trim()).filter(Boolean)),await n.hi.post("/api/ab-tests",e),v(!1),b({name:"",description:"",split_percent:50,variant_a_provider:"",variant_a_model:"",variant_b_provider:"",variant_b_model:"",trigger_models:""}),_()}catch(e){p(e instanceof Error?e.message:"Failed")}};s.useEffect(()=>{if(h){let e=setTimeout(()=>p(""),3e3);return()=>clearTimeout(e)}},[h]);let T=e=>{if(0===e.total_a&&0===e.total_b)return null;let t=100*e.error_rate_a+.01*e.avg_latency_a+e.avg_cost_a,a=100*e.error_rate_b+.01*e.avg_latency_b+e.avg_cost_b;return .001>Math.abs(t-a)?null:t<a?"a":"b"},C=e=>(100*e).toFixed(1)+"%",E=e=>"$"+e.toFixed(4),A=e=>e.toFixed(0)+"ms";return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"A/B Tests"}),(0,r.jsx)("p",{className:"page-sub",children:"Compare model variants side-by-side"})]}),(0,r.jsxs)("button",{className:"btn-primary",onClick:()=>v(!0),children:[(0,r.jsx)(i.Z,{size:16})," New Test"]})]}),x&&(0,r.jsx)("div",{className:"modal-overlay",onClick:()=>v(!1),children:(0,r.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"New A/B Test"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Name"}),(0,r.jsx)("input",{className:"input",value:j.name,onChange:e=>b(t=>({...t,name:e.target.value})),autoFocus:!0})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Description"}),(0,r.jsx)("input",{className:"input",value:j.description,onChange:e=>b(t=>({...t,description:e.target.value}))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Split % (first variant)"}),(0,r.jsx)("input",{className:"input",type:"number",min:1,max:99,value:j.split_percent,onChange:e=>b(t=>({...t,split_percent:Number(e.target.value)}))})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"text-sm font-semibold text-blue-400",children:"Variant A"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Provider"}),(0,r.jsxs)("select",{className:"select",value:j.variant_a_provider,onChange:e=>b(t=>({...t,variant_a_provider:e.target.value})),children:[(0,r.jsx)("option",{value:"",children:"Select"}),f.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Model"}),(0,r.jsx)("input",{className:"input",value:j.variant_a_model,onChange:e=>b(t=>({...t,variant_a_model:e.target.value})),placeholder:"gpt-4o"})]})]}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"text-sm font-semibold text-purple-400",children:"Variant B"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Provider"}),(0,r.jsxs)("select",{className:"select",value:j.variant_b_provider,onChange:e=>b(t=>({...t,variant_b_provider:e.target.value})),children:[(0,r.jsx)("option",{value:"",children:"Select"}),f.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Model"}),(0,r.jsx)("input",{className:"input",value:j.variant_b_model,onChange:e=>b(t=>({...t,variant_b_model:e.target.value})),placeholder:"claude-3-opus"})]})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"label",children:["Trigger Models ",(0,r.jsx)("span",{className:"text-[var(--text-tertiary)] font-normal",children:"comma-separated, leave empty for all"})]}),(0,r.jsx)("input",{className:"input",value:j.trigger_models,onChange:e=>b(t=>({...t,trigger_models:e.target.value})),placeholder:"gpt-4o, claude-3-opus"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:k,children:"Create"}),(0,r.jsx)("button",{className:"btn-ghost",onClick:()=>v(!1),children:"Cancel"})]})]})]})}),a?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-48 w-full"})}):0===e.length?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No A/B tests configured."})]}):(0,r.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:e.map(e=>{let t=T(e);return(0,r.jsxs)("div",{className:"card",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold truncate",children:e.name}),e.description&&(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 truncate",children:e.description})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 ml-3 shrink-0",children:[(0,r.jsx)("button",{onClick:()=>y(e.id),title:e.is_active?"Disable":"Enable",children:e.is_active?(0,r.jsx)(c,{size:14,className:"text-green-400"}):(0,r.jsx)(o.Z,{size:14,className:"text-[var(--text-tertiary)]"})}),(0,r.jsx)("button",{onClick:()=>N(e.id),title:"Reset stats",children:(0,r.jsx)(d.Z,{size:14,className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"})}),(0,r.jsx)("button",{onClick:()=>w(e.id),title:"Delete",children:(0,r.jsx)(u.Z,{size:14,className:"text-red-400"})})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,r.jsx)("span",{className:"badge-".concat(e.is_active?"green":"red"),children:e.is_active?"Active":"Paused"}),(0,r.jsxs)("span",{className:"text-xs text-[var(--text-tertiary)]",children:[e.split_percent,"% / ",100-e.split_percent,"% split"]}),e.trigger_models.length>0&&(0,r.jsxs)("span",{className:"text-xs text-[var(--text-tertiary)] ml-auto truncate",title:e.trigger_models.join(", "),children:["triggers: ",e.trigger_models.join(", ")]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{className:"p-3 rounded-lg border ".concat("a"===t?"border-blue-500/40 bg-blue-500/5":"border-[var(--border)]"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-blue-400",children:"Variant A"}),"a"===t&&(0,r.jsx)("span",{className:"text-[10px] font-semibold text-blue-400",children:"WINNING"})]}),(0,r.jsxs)("p",{className:"text-xs font-mono mb-1 truncate",children:[e.variant_a_provider,"/",e.variant_a_model]}),(0,r.jsxs)("div",{className:"space-y-0.5 text-[11px] text-[var(--text-secondary)]",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Requests"}),(0,r.jsx)("span",{className:"font-mono",children:e.total_a})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Avg Latency"}),(0,r.jsx)("span",{className:"font-mono",children:A(e.avg_latency_a)})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Avg Cost"}),(0,r.jsx)("span",{className:"font-mono",children:E(e.avg_cost_a)})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Error Rate"}),(0,r.jsx)("span",{className:"font-mono",children:C(e.error_rate_a)})]})]})]}),(0,r.jsxs)("div",{className:"p-3 rounded-lg border ".concat("b"===t?"border-purple-500/40 bg-purple-500/5":"border-[var(--border)]"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-purple-400",children:"Variant B"}),"b"===t&&(0,r.jsx)("span",{className:"text-[10px] font-semibold text-purple-400",children:"WINNING"})]}),(0,r.jsxs)("p",{className:"text-xs font-mono mb-1 truncate",children:[e.variant_b_provider,"/",e.variant_b_model]}),(0,r.jsxs)("div",{className:"space-y-0.5 text-[11px] text-[var(--text-secondary)]",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Requests"}),(0,r.jsx)("span",{className:"font-mono",children:e.total_b})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Avg Latency"}),(0,r.jsx)("span",{className:"font-mono",children:A(e.avg_latency_b)})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Avg Cost"}),(0,r.jsx)("span",{className:"font-mono",children:E(e.avg_cost_b)})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Error Rate"}),(0,r.jsx)("span",{className:"font-mono",children:C(e.error_rate_b)})]})]})]})]})]},e.id)})}),h&&(0,r.jsx)("div",{className:"toast",children:h})]})}},1837:function(e,t,a){"use strict";a.d(t,{KF:function(){return m},hi:function(){return u},jl:function(){return i},qz:function(){return n}});let r=a(257).env.NEXT_PUBLIC_API_BASE||"";function s(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function n(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function i(){return!!s()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.method||"GET",i=s(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===a&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let a=o.get(e);if(a)return a}let u=(async()=>{let s=await fetch("".concat(r).concat(e),{method:a,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw n(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let l=await s.json();return"GET"!==a||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===a&&!i){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var a;let r=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return a=r.access_token,localStorage.setItem("nexus_token",a),function(e,t,a){try{let a="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(a)}catch(e){}}("nexus_token",a,0),r},getMe:()=>d("/api/auth/me"),logout:()=>{n(),c.clear(),window.location.href="/login"}},m=async e=>{let t=s(),a=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!a.ok)throw Error("Failed to download");let n=await a.blob(),i=URL.createObjectURL(n),l=document.createElement("a");l.href=i,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=7452)}),_N_E=e.O()}]);
static/_next/static/chunks/app/ab-tests/page-48b03e034dff445e.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4502],{7452:function(e,t,a){Promise.resolve().then(a.bind(a,8580))},9205:function(e,t,a){"use strict";a.d(t,{Z:function(){return c}});var s=a(2265);let r=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),n=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&a.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,s.forwardRef)((e,t)=>{let{color:a="currentColor",size:r=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...m}=e;return(0,s.createElement)("svg",{ref:t,...i,width:r,height:r,stroke:a,strokeWidth:c?24*Number(l)/Number(r):l,className:n("lucide",o),...m},[...u.map(e=>{let[t,a]=e;return(0,s.createElement)(t,a)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let a=(0,s.forwardRef)((a,i)=>{let{className:c,...o}=a;return(0,s.createElement)(l,{ref:i,iconNode:t,className:n("lucide-".concat(r(e)),c),...o})});return a.displayName="".concat(e),a}},6272:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(9205).Z)("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]])},3276:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(9205).Z)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},9397:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7168:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},8930:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,a){"use strict";var s,r;e.exports=(null==(s=a.g.process)?void 0:s.env)&&"object"==typeof(null==(r=a.g.process)?void 0:r.env)?a.g.process:a(4227)},4227:function(e){!function(){var t={229:function(e){var t,a,s,r=e.exports={};function n(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:n}catch(e){t=n}try{a="function"==typeof clearTimeout?clearTimeout:i}catch(e){a=i}}();var c=[],o=!1,d=-1;function u(){o&&s&&(o=!1,s.length?c=s.concat(c):d=-1,c.length&&m())}function m(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(s=c,c=[];++d<t;)s&&s[d].run();d=-1,t=c.length}s=null,o=!1,function(e){if(a===clearTimeout)return clearTimeout(e);if((a===i||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function p(){}r.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)t[a-1]=arguments[a];c.push(new h(e,t)),1!==c.length||o||l(m)},h.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=p,r.addListener=p,r.once=p,r.off=p,r.removeListener=p,r.removeAllListeners=p,r.emit=p,r.prependListener=p,r.prependOnceListener=p,r.listeners=function(e){return[]},r.binding=function(e){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw Error("process.chdir is not supported")},r.umask=function(){return 0}}},a={};function s(e){var r=a[e];if(void 0!==r)return r.exports;var n=a[e]={exports:{}},i=!0;try{t[e](n,n.exports,s),i=!1}finally{i&&delete a[e]}return n.exports}s.ab="//";var r=s(229);e.exports=r}()},8580:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return m}});var s=a(7437),r=a(2265),n=a(1837),i=a(9397),l=a(6272);let c=(0,a(9205).Z)("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);var o=a(3276),d=a(7168),u=a(8930);function m(){let[e,t]=(0,r.useState)([]),[a,m]=(0,r.useState)(!0),[h,p]=(0,r.useState)(""),[x,v]=(0,r.useState)(!1),[f,j]=(0,r.useState)([]),[g,b]=(0,r.useState)({name:"",description:"",split_percent:50,variant_a_provider:"",variant_a_model:"",variant_b_provider:"",variant_b_model:"",trigger_models:""}),_=()=>{m(!0),Promise.all([n.hi.get("/api/ab-tests").catch(()=>[]),n.hi.get("/api/providers").then(e=>j(Object.keys(e))).catch(()=>{})]).then(e=>{let[a]=e;return t(a)}).finally(()=>m(!1))};(0,r.useEffect)(()=>{_()},[]);let y=async e=>{await n.hi.patch("/api/ab-tests/".concat(e,"/toggle")),_()},N=async e=>{confirm("Reset stats for this A/B test?")&&(await n.hi.post("/api/ab-tests/".concat(e,"/reset")),_())},w=async e=>{confirm("Delete this A/B test?")&&(await n.hi.delete("/api/ab-tests/".concat(e)),_())},k=async()=>{if(g.name&&g.variant_a_provider&&g.variant_a_model&&g.variant_b_provider&&g.variant_b_model)try{let e={name:g.name,split_percent:g.split_percent,variant_a_provider:g.variant_a_provider,variant_a_model:g.variant_a_model,variant_b_provider:g.variant_b_provider,variant_b_model:g.variant_b_model};g.description&&(e.description=g.description),g.trigger_models&&(e.trigger_models=g.trigger_models.split(",").map(e=>e.trim()).filter(Boolean)),await n.hi.post("/api/ab-tests",e),v(!1),b({name:"",description:"",split_percent:50,variant_a_provider:"",variant_a_model:"",variant_b_provider:"",variant_b_model:"",trigger_models:""}),_()}catch(e){p(e instanceof Error?e.message:"Failed")}};r.useEffect(()=>{if(h){let e=setTimeout(()=>p(""),3e3);return()=>clearTimeout(e)}},[h]);let T=e=>{if(0===e.total_a&&0===e.total_b)return null;let t=100*e.error_rate_a+.01*e.avg_latency_a+e.avg_cost_a,a=100*e.error_rate_b+.01*e.avg_latency_b+e.avg_cost_b;return .001>Math.abs(t-a)?null:t<a?"a":"b"},C=e=>(100*e).toFixed(1)+"%",E=e=>"$"+e.toFixed(4),A=e=>e.toFixed(0)+"ms";return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"page-header",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"page-title",children:"A/B Tests"}),(0,s.jsx)("p",{className:"page-sub",children:"Compare model variants side-by-side"})]}),(0,s.jsxs)("button",{className:"btn-primary",onClick:()=>v(!0),children:[(0,s.jsx)(i.Z,{size:16})," New Test"]})]}),x&&(0,s.jsx)("div",{className:"modal-overlay",onClick:()=>v(!1),children:(0,s.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"New A/B Test"}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Name"}),(0,s.jsx)("input",{className:"input",value:g.name,onChange:e=>b(t=>({...t,name:e.target.value})),autoFocus:!0})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Description"}),(0,s.jsx)("input",{className:"input",value:g.description,onChange:e=>b(t=>({...t,description:e.target.value}))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Split % (first variant)"}),(0,s.jsx)("input",{className:"input",type:"number",min:1,max:99,value:g.split_percent,onChange:e=>b(t=>({...t,split_percent:Number(e.target.value)}))})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-blue-400",children:"Variant A"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Provider"}),(0,s.jsxs)("select",{className:"select",value:g.variant_a_provider,onChange:e=>b(t=>({...t,variant_a_provider:e.target.value})),children:[(0,s.jsx)("option",{value:"",children:"Select"}),f.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Model"}),(0,s.jsx)("input",{className:"input",value:g.variant_a_model,onChange:e=>b(t=>({...t,variant_a_model:e.target.value})),placeholder:"gpt-4o"})]})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-purple-400",children:"Variant B"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Provider"}),(0,s.jsxs)("select",{className:"select",value:g.variant_b_provider,onChange:e=>b(t=>({...t,variant_b_provider:e.target.value})),children:[(0,s.jsx)("option",{value:"",children:"Select"}),f.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Model"}),(0,s.jsx)("input",{className:"input",value:g.variant_b_model,onChange:e=>b(t=>({...t,variant_b_model:e.target.value})),placeholder:"claude-3-opus"})]})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"label",children:["Trigger Models ",(0,s.jsx)("span",{className:"text-[var(--text-tertiary)] font-normal",children:"comma-separated, leave empty for all"})]}),(0,s.jsx)("input",{className:"input",value:g.trigger_models,onChange:e=>b(t=>({...t,trigger_models:e.target.value})),placeholder:"gpt-4o, claude-3-opus"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:k,children:"Create"}),(0,s.jsx)("button",{className:"btn-ghost",onClick:()=>v(!1),children:"Cancel"})]})]})]})}),a?(0,s.jsx)("div",{className:"card",children:(0,s.jsx)("div",{className:"skeleton h-48 w-full"})}):0===e.length?(0,s.jsxs)("div",{className:"card text-center py-12",children:[(0,s.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,s.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No A/B tests configured."})]}):(0,s.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:e.map(e=>{let t=T(e);return(0,s.jsxs)("div",{className:"card",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold truncate",children:e.name}),e.description&&(0,s.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mt-0.5 truncate",children:e.description})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 ml-3 shrink-0",children:[(0,s.jsx)("button",{onClick:()=>y(e.id),title:e.is_active?"Disable":"Enable",children:e.is_active?(0,s.jsx)(c,{size:14,className:"text-green-400"}):(0,s.jsx)(o.Z,{size:14,className:"text-[var(--text-tertiary)]"})}),(0,s.jsx)("button",{onClick:()=>N(e.id),title:"Reset stats",children:(0,s.jsx)(d.Z,{size:14,className:"text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"})}),(0,s.jsx)("button",{onClick:()=>w(e.id),title:"Delete",children:(0,s.jsx)(u.Z,{size:14,className:"text-red-400"})})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)("span",{className:"badge-".concat(e.is_active?"green":"red"),children:e.is_active?"Active":"Paused"}),(0,s.jsxs)("span",{className:"text-xs text-[var(--text-tertiary)]",children:[e.split_percent,"% / ",100-e.split_percent,"% split"]}),e.trigger_models.length>0&&(0,s.jsxs)("span",{className:"text-xs text-[var(--text-tertiary)] ml-auto truncate",title:e.trigger_models.join(", "),children:["triggers: ",e.trigger_models.join(", ")]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("div",{className:"p-3 rounded-lg border ".concat("a"===t?"border-blue-500/40 bg-blue-500/5":"border-[var(--border)]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-blue-400",children:"Variant A"}),"a"===t&&(0,s.jsx)("span",{className:"text-[10px] font-semibold text-blue-400",children:"WINNING"})]}),(0,s.jsxs)("p",{className:"text-xs font-mono mb-1 truncate",children:[e.variant_a_provider,"/",e.variant_a_model]}),(0,s.jsxs)("div",{className:"space-y-0.5 text-[11px] text-[var(--text-secondary)]",children:[(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Requests"}),(0,s.jsx)("span",{className:"font-mono",children:e.total_a})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Avg Latency"}),(0,s.jsx)("span",{className:"font-mono",children:A(e.avg_latency_a)})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Avg Cost"}),(0,s.jsx)("span",{className:"font-mono",children:E(e.avg_cost_a)})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Error Rate"}),(0,s.jsx)("span",{className:"font-mono",children:C(e.error_rate_a)})]})]})]}),(0,s.jsxs)("div",{className:"p-3 rounded-lg border ".concat("b"===t?"border-purple-500/40 bg-purple-500/5":"border-[var(--border)]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-purple-400",children:"Variant B"}),"b"===t&&(0,s.jsx)("span",{className:"text-[10px] font-semibold text-purple-400",children:"WINNING"})]}),(0,s.jsxs)("p",{className:"text-xs font-mono mb-1 truncate",children:[e.variant_b_provider,"/",e.variant_b_model]}),(0,s.jsxs)("div",{className:"space-y-0.5 text-[11px] text-[var(--text-secondary)]",children:[(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Requests"}),(0,s.jsx)("span",{className:"font-mono",children:e.total_b})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Avg Latency"}),(0,s.jsx)("span",{className:"font-mono",children:A(e.avg_latency_b)})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Avg Cost"}),(0,s.jsx)("span",{className:"font-mono",children:E(e.avg_cost_b)})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{children:"Error Rate"}),(0,s.jsx)("span",{className:"font-mono",children:C(e.error_rate_b)})]})]})]})]})]},e.id)})}),h&&(0,s.jsx)("div",{className:"toast",children:h})]})}},1837:function(e,t,a){"use strict";a.d(t,{KF:function(){return m},hi:function(){return u},jl:function(){return i},qz:function(){return n}});let s=a(257).env.NEXT_PUBLIC_API_BASE||"";function r(){return localStorage.getItem("nexus_token")}function n(){localStorage.removeItem("nexus_token")}function i(){return!!r()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.method||"GET",i=r(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===a&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let a=o.get(e);if(a)return a}let u=(async()=>{let r=await fetch("".concat(s).concat(e),{method:a,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return r;if(401===r.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw n(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!r.ok)throw Error((await r.json().catch(()=>({detail:r.statusText}))).detail||"HTTP ".concat(r.status));if(204===r.status)return;let l=await r.json();return"GET"!==a||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===a&&!i){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var a;let s=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return a=s.access_token,localStorage.setItem("nexus_token",a),s},getMe:()=>d("/api/auth/me"),logout:()=>{n(),c.clear(),window.location.href="/login"}},m=async e=>{let t=r(),a=await fetch("".concat(s).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!a.ok)throw Error("Failed to download");let n=await a.blob(),i=URL.createObjectURL(n),l=document.createElement("a");l.href=i,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=7452)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/activity/{page-5a4807967b5002cd.js → page-03c92e6695ec079a.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6263],{8973:function(e,t,n){Promise.resolve().then(n.bind(n,6105))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:s=24,strokeWidth:o=2,absoluteStrokeWidth:c,className:l="",children:d,iconNode:u,...h}=e;return(0,r.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:n,strokeWidth:c?24*Number(o)/Number(s):o,className:a("lucide",l),...h},[...u.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let n=(0,r.forwardRef)((n,i)=>{let{className:c,...l}=n;return(0,r.createElement)(o,{ref:i,iconNode:t,className:a("lucide-".concat(s(e)),c),...l})});return n.displayName="".concat(e),n}},401:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},9322:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},2735:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},5621:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},8930:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},2489:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},257:function(e,t,n){"use strict";var r,s;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(s=n.g.process)?void 0:s.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,s=e.exports={};function a(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var c=[],l=!1,d=-1;function u(){l&&r&&(l=!1,r.length?c=r.concat(c):d=-1,c.length&&h())}function h(){if(!l){var e=o(u);l=!0;for(var t=c.length;t;){for(r=c,c=[];++d<t;)r&&r[d].run();d=-1,t=c.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function x(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||l||o(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=x,s.addListener=x,s.once=x,s.off=x,s.removeListener=x,s.removeAllListeners=x,s.emit=x,s.prependListener=x,s.prependOnceListener=x,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},n={};function r(e){var s=n[e];if(void 0!==s)return s.exports;var a=n[e]={exports:{}},i=!0;try{t[e](a,a.exports,r),i=!1}finally{i&&delete n[e]}return a.exports}r.ab="//";var s=r(229);e.exports=s}()},6105:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return h}});var r=n(7437),s=n(2265),a=n(1837),i=n(2735),o=n(8930),c=n(9322),l=n(5621),d=n(401),u=n(2489);function h(){let[e,t]=(0,s.useState)([]),[n,h]=(0,s.useState)(!0),[f,x]=(0,s.useState)(""),[m,p]=(0,s.useState)(0),[y,g]=(0,s.useState)(0),[v,j]=(0,s.useState)(!1),[w,k]=(0,s.useState)(!1),[,b]=s.useTransition();(0,s.useEffect)(()=>{h(!0),x(""),a.hi.get("/api/logs?offset=".concat(m,"&limit=").concat(25)).then(e=>{t(e.logs),g(e.total)}).catch(e=>x(e instanceof Error?e.message:"Failed to load activity")).finally(()=>h(!1))},[m]);let N=Math.ceil(y/25),T=async()=>{if(confirm("Delete all activity logs? This cannot be undone.")){j(!0);try{await a.hi.delete("/api/logs"),p(0),t([]),g(0)}catch(e){x(e instanceof Error?e.message:"Failed to clear logs")}finally{j(!1)}}},E=async()=>{k(!0);try{await (0,a.KF)("/api/logs/export.csv")}catch(e){x(e instanceof Error?e.message:"Failed to export CSV")}finally{k(!1)}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Activity Log"}),(0,r.jsx)("p",{className:"page-sub",children:"Recent API requests and responses"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("button",{className:"btn-secondary",onClick:E,disabled:w||0===e.length,children:[(0,r.jsx)(i.Z,{size:16}),w?"Downloading...":"Download CSV"]}),(0,r.jsxs)("button",{className:"btn-danger",onClick:T,disabled:v||0===y,children:[(0,r.jsx)(o.Z,{size:16}),v?"Clearing...":"Clear Logs"]})]})]}),f?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(c.Z,{size:32,className:"mx-auto mb-3 text-red-400"}),(0,r.jsx)("p",{className:"text-red-400",children:f})]}):n?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-48 w-full"})}):0===e.length?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No activity yet. Start making requests to see logs."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"card p-0",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Time"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Provider"}),(0,r.jsx)("th",{children:"Tokens"}),(0,r.jsx)("th",{children:"Cost"}),(0,r.jsx)("th",{children:"Latency"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:"Flags"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"text-xs text-[var(--text-tertiary)] whitespace-nowrap",children:e.timestamp}),(0,r.jsx)("td",{className:"font-medium text-sm max-w-[200px] truncate",title:e.model,children:e.model}),(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"text-sm capitalize",children:e.provider})}),(0,r.jsxs)("td",{className:"text-xs",children:[e.tokens_in," → ",e.tokens_out]}),(0,r.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.cost).toFixed(6)]}),(0,r.jsxs)("td",{className:"text-xs",children:[e.latency_ms,"ms"]}),(0,r.jsx)("td",{children:e.error?(0,r.jsxs)("span",{className:"badge-red",title:e.error,children:[(0,r.jsx)(u.Z,{size:12})," Error"]}):(0,r.jsxs)("span",{className:"badge-green",children:[(0,r.jsx)(d.Z,{size:12})," Success"]})}),(0,r.jsx)("td",{children:(0,r.jsxs)("div",{className:"flex gap-1",children:[1===e.streaming&&(0,r.jsx)("span",{className:"badge-blue text-xs",children:"stream"}),1===e.cached&&(0,r.jsx)("span",{className:"badge-green text-xs",children:"cached"})]})})]},e.id))})]})})}),N>1&&(0,r.jsxs)("div",{className:"flex items-center justify-between mt-4 text-sm",children:[(0,r.jsxs)("span",{className:"text-[var(--text-tertiary)]",children:["Page ",Math.floor(m/25)+1," of ",N," (",y," total)"]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-ghost btn-sm",disabled:m<=0,onClick:()=>b(()=>p(e=>Math.max(0,e-25))),children:"← Prev"}),(0,r.jsx)("button",{className:"btn-ghost btn-sm",disabled:m+25>=y,onClick:()=>b(()=>p(e=>e+25)),children:"Next →"})]})]})]})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return i},qz:function(){return a}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function s(){return localStorage.getItem("nexus_token")}function a(){localStorage.removeItem("nexus_token")}function i(){return!!s()}let o={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,l=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",i=s(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===n&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in o)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return o[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=l.get(e);if(n)return n}let u=(async()=>{let s=await fetch("".concat(r).concat(e),{method:n,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw a(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let o=await s.json();return"GET"!==n||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,o),o})();if("GET"===n&&!i){l.set(e,u);try{return await u}finally{l.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),r},getMe:()=>d("/api/auth/me"),logout:()=>{a(),c.clear(),window.location.href="/login"}},h=async e=>{let t=s(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let a=await n.blob(),i=URL.createObjectURL(a),o=document.createElement("a");o.href=i,o.download=e.split("/").pop()||"export.csv",o.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=8973)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6263],{8973:function(e,t,n){Promise.resolve().then(n.bind(n,6105))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:s=24,strokeWidth:o=2,absoluteStrokeWidth:c,className:l="",children:u,iconNode:d,...h}=e;return(0,r.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:n,strokeWidth:c?24*Number(o)/Number(s):o,className:a("lucide",l),...h},[...d.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(u)?u:[u]])}),c=(e,t)=>{let n=(0,r.forwardRef)((n,i)=>{let{className:c,...l}=n;return(0,r.createElement)(o,{ref:i,iconNode:t,className:a("lucide-".concat(s(e)),c),...l})});return n.displayName="".concat(e),n}},401:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},9322:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},2735:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},5621:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},8930:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},2489:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},257:function(e,t,n){"use strict";var r,s;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(s=n.g.process)?void 0:s.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,s=e.exports={};function a(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var c=[],l=!1,u=-1;function d(){l&&r&&(l=!1,r.length?c=r.concat(c):u=-1,c.length&&h())}function h(){if(!l){var e=o(d);l=!0;for(var t=c.length;t;){for(r=c,c=[];++u<t;)r&&r[u].run();u=-1,t=c.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function x(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||l||o(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=x,s.addListener=x,s.once=x,s.off=x,s.removeListener=x,s.removeAllListeners=x,s.emit=x,s.prependListener=x,s.prependOnceListener=x,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},n={};function r(e){var s=n[e];if(void 0!==s)return s.exports;var a=n[e]={exports:{}},i=!0;try{t[e](a,a.exports,r),i=!1}finally{i&&delete n[e]}return a.exports}r.ab="//";var s=r(229);e.exports=s}()},6105:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return h}});var r=n(7437),s=n(2265),a=n(1837),i=n(2735),o=n(8930),c=n(9322),l=n(5621),u=n(401),d=n(2489);function h(){let[e,t]=(0,s.useState)([]),[n,h]=(0,s.useState)(!0),[f,x]=(0,s.useState)(""),[m,p]=(0,s.useState)(0),[y,g]=(0,s.useState)(0),[v,j]=(0,s.useState)(!1),[k,w]=(0,s.useState)(!1),[,b]=s.useTransition();(0,s.useEffect)(()=>{h(!0),x(""),a.hi.get("/api/logs?offset=".concat(m,"&limit=").concat(25)).then(e=>{t(e.logs),g(e.total)}).catch(e=>x(e instanceof Error?e.message:"Failed to load activity")).finally(()=>h(!1))},[m]);let N=Math.ceil(y/25),T=async()=>{if(confirm("Delete all activity logs? This cannot be undone.")){j(!0);try{await a.hi.delete("/api/logs"),p(0),t([]),g(0)}catch(e){x(e instanceof Error?e.message:"Failed to clear logs")}finally{j(!1)}}},E=async()=>{w(!0);try{await (0,a.KF)("/api/logs/export.csv")}catch(e){x(e instanceof Error?e.message:"Failed to export CSV")}finally{w(!1)}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Activity Log"}),(0,r.jsx)("p",{className:"page-sub",children:"Recent API requests and responses"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("button",{className:"btn-secondary",onClick:E,disabled:k||0===e.length,children:[(0,r.jsx)(i.Z,{size:16}),k?"Downloading...":"Download CSV"]}),(0,r.jsxs)("button",{className:"btn-danger",onClick:T,disabled:v||0===y,children:[(0,r.jsx)(o.Z,{size:16}),v?"Clearing...":"Clear Logs"]})]})]}),f?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(c.Z,{size:32,className:"mx-auto mb-3 text-red-400"}),(0,r.jsx)("p",{className:"text-red-400",children:f})]}):n?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-48 w-full"})}):0===e.length?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No activity yet. Start making requests to see logs."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"card p-0",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Time"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Provider"}),(0,r.jsx)("th",{children:"Tokens"}),(0,r.jsx)("th",{children:"Cost"}),(0,r.jsx)("th",{children:"Latency"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:"Flags"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"text-xs text-[var(--text-tertiary)] whitespace-nowrap",children:e.timestamp}),(0,r.jsx)("td",{className:"font-medium text-sm max-w-[200px] truncate",title:e.model,children:e.model}),(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"text-sm capitalize",children:e.provider})}),(0,r.jsxs)("td",{className:"text-xs",children:[e.tokens_in," → ",e.tokens_out]}),(0,r.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.cost).toFixed(6)]}),(0,r.jsxs)("td",{className:"text-xs",children:[e.latency_ms,"ms"]}),(0,r.jsx)("td",{children:e.error?(0,r.jsxs)("span",{className:"badge-red",title:e.error,children:[(0,r.jsx)(d.Z,{size:12})," Error"]}):(0,r.jsxs)("span",{className:"badge-green",children:[(0,r.jsx)(u.Z,{size:12})," Success"]})}),(0,r.jsx)("td",{children:(0,r.jsxs)("div",{className:"flex gap-1",children:[1===e.streaming&&(0,r.jsx)("span",{className:"badge-blue text-xs",children:"stream"}),1===e.cached&&(0,r.jsx)("span",{className:"badge-green text-xs",children:"cached"})]})})]},e.id))})]})})}),N>1&&(0,r.jsxs)("div",{className:"flex items-center justify-between mt-4 text-sm",children:[(0,r.jsxs)("span",{className:"text-[var(--text-tertiary)]",children:["Page ",Math.floor(m/25)+1," of ",N," (",y," total)"]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-ghost btn-sm",disabled:m<=0,onClick:()=>b(()=>p(e=>Math.max(0,e-25))),children:"← Prev"}),(0,r.jsx)("button",{className:"btn-ghost btn-sm",disabled:m+25>=y,onClick:()=>b(()=>p(e=>e+25)),children:"Next →"})]})]})]})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return i},qz:function(){return a}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function s(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function a(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function i(){return!!s()}let o={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,l=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",i=s(),u={"Content-Type":"application/json",...t.headers};if(i&&(u.Authorization="Bearer ".concat(i)),"GET"===n&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in o)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return o[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=l.get(e);if(n)return n}let d=(async()=>{let s=await fetch("".concat(r).concat(e),{method:n,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw a(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let o=await s.json();return"GET"!==n||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,o),o})();if("GET"===n&&!i){l.set(e,d);try{return await d}finally{l.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),function(e,t,n){try{let n="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(n)}catch(e){}}("nexus_token",n,0),r},getMe:()=>u("/api/auth/me"),logout:()=>{a(),c.clear(),window.location.href="/login"}},h=async e=>{let t=s(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let a=await n.blob(),i=URL.createObjectURL(a),o=document.createElement("a");o.href=i,o.download=e.split("/").pop()||"export.csv",o.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=8973)}),_N_E=e.O()}]);
static/_next/static/chunks/app/activity/page-d1a71f38c937f6b6.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6263],{8973:function(e,t,n){Promise.resolve().then(n.bind(n,6105))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:s=24,strokeWidth:o=2,absoluteStrokeWidth:c,className:l="",children:d,iconNode:u,...h}=e;return(0,r.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:n,strokeWidth:c?24*Number(o)/Number(s):o,className:a("lucide",l),...h},[...u.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let n=(0,r.forwardRef)((n,i)=>{let{className:c,...l}=n;return(0,r.createElement)(o,{ref:i,iconNode:t,className:a("lucide-".concat(s(e)),c),...l})});return n.displayName="".concat(e),n}},401:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},9322:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},2735:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},5621:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},8930:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},2489:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},257:function(e,t,n){"use strict";var r,s;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(s=n.g.process)?void 0:s.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,s=e.exports={};function a(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var c=[],l=!1,d=-1;function u(){l&&r&&(l=!1,r.length?c=r.concat(c):d=-1,c.length&&h())}function h(){if(!l){var e=o(u);l=!0;for(var t=c.length;t;){for(r=c,c=[];++d<t;)r&&r[d].run();d=-1,t=c.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function x(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||l||o(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=x,s.addListener=x,s.once=x,s.off=x,s.removeListener=x,s.removeAllListeners=x,s.emit=x,s.prependListener=x,s.prependOnceListener=x,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},n={};function r(e){var s=n[e];if(void 0!==s)return s.exports;var a=n[e]={exports:{}},i=!0;try{t[e](a,a.exports,r),i=!1}finally{i&&delete n[e]}return a.exports}r.ab="//";var s=r(229);e.exports=s}()},6105:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return h}});var r=n(7437),s=n(2265),a=n(1837),i=n(2735),o=n(8930),c=n(9322),l=n(5621),d=n(401),u=n(2489);function h(){let[e,t]=(0,s.useState)([]),[n,h]=(0,s.useState)(!0),[f,x]=(0,s.useState)(""),[m,p]=(0,s.useState)(0),[y,g]=(0,s.useState)(0),[v,j]=(0,s.useState)(!1),[w,k]=(0,s.useState)(!1),[,b]=s.useTransition();(0,s.useEffect)(()=>{h(!0),x(""),a.hi.get("/api/logs?offset=".concat(m,"&limit=").concat(25)).then(e=>{t(e.logs),g(e.total)}).catch(e=>x(e instanceof Error?e.message:"Failed to load activity")).finally(()=>h(!1))},[m]);let N=Math.ceil(y/25),T=async()=>{if(confirm("Delete all activity logs? This cannot be undone.")){j(!0);try{await a.hi.delete("/api/logs"),p(0),t([]),g(0)}catch(e){x(e instanceof Error?e.message:"Failed to clear logs")}finally{j(!1)}}},E=async()=>{k(!0);try{await (0,a.KF)("/api/logs/export.csv")}catch(e){x(e instanceof Error?e.message:"Failed to export CSV")}finally{k(!1)}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Activity Log"}),(0,r.jsx)("p",{className:"page-sub",children:"Recent API requests and responses"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("button",{className:"btn-secondary",onClick:E,disabled:w||0===e.length,children:[(0,r.jsx)(i.Z,{size:16}),w?"Downloading...":"Download CSV"]}),(0,r.jsxs)("button",{className:"btn-danger",onClick:T,disabled:v||0===y,children:[(0,r.jsx)(o.Z,{size:16}),v?"Clearing...":"Clear Logs"]})]})]}),f?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(c.Z,{size:32,className:"mx-auto mb-3 text-red-400"}),(0,r.jsx)("p",{className:"text-red-400",children:f})]}):n?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-48 w-full"})}):0===e.length?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No activity yet. Start making requests to see logs."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"card p-0",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Time"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Provider"}),(0,r.jsx)("th",{children:"Tokens"}),(0,r.jsx)("th",{children:"Cost"}),(0,r.jsx)("th",{children:"Latency"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:"Flags"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"text-xs text-[var(--text-tertiary)] whitespace-nowrap",children:e.timestamp}),(0,r.jsx)("td",{className:"font-medium text-sm max-w-[200px] truncate",title:e.model,children:e.model}),(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"text-sm capitalize",children:e.provider})}),(0,r.jsxs)("td",{className:"text-xs",children:[e.tokens_in," → ",e.tokens_out]}),(0,r.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.cost).toFixed(6)]}),(0,r.jsxs)("td",{className:"text-xs",children:[e.latency_ms,"ms"]}),(0,r.jsx)("td",{children:e.error?(0,r.jsxs)("span",{className:"badge-red",title:e.error,children:[(0,r.jsx)(u.Z,{size:12})," Error"]}):(0,r.jsxs)("span",{className:"badge-green",children:[(0,r.jsx)(d.Z,{size:12})," Success"]})}),(0,r.jsx)("td",{children:(0,r.jsxs)("div",{className:"flex gap-1",children:[1===e.streaming&&(0,r.jsx)("span",{className:"badge-blue text-xs",children:"stream"}),1===e.cached&&(0,r.jsx)("span",{className:"badge-green text-xs",children:"cached"})]})})]},e.id))})]})})}),N>1&&(0,r.jsxs)("div",{className:"flex items-center justify-between mt-4 text-sm",children:[(0,r.jsxs)("span",{className:"text-[var(--text-tertiary)]",children:["Page ",Math.floor(m/25)+1," of ",N," (",y," total)"]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-ghost btn-sm",disabled:m<=0,onClick:()=>b(()=>p(e=>Math.max(0,e-25))),children:"← Prev"}),(0,r.jsx)("button",{className:"btn-ghost btn-sm",disabled:m+25>=y,onClick:()=>b(()=>p(e=>e+25)),children:"Next →"})]})]})]})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return i},qz:function(){return a}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function s(){return localStorage.getItem("nexus_token")}function a(){localStorage.removeItem("nexus_token")}function i(){return!!s()}let o={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,l=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",i=s(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===n&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in o)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return o[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=l.get(e);if(n)return n}let u=(async()=>{let s=await fetch("".concat(r).concat(e),{method:n,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw a(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let o=await s.json();return"GET"!==n||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,o),o})();if("GET"===n&&!i){l.set(e,u);try{return await u}finally{l.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),r},getMe:()=>d("/api/auth/me"),logout:()=>{a(),c.clear(),window.location.href="/login"}},h=async e=>{let t=s(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let a=await n.blob(),i=URL.createObjectURL(a),o=document.createElement("a");o.href=i,o.download=e.split("/").pop()||"export.csv",o.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=8973)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/admin/page-048442296e23ef4d.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3],{3429:function(e,s,a){Promise.resolve().then(a.bind(a,6683))},6683:function(e,s,a){"use strict";a.r(s),a.d(s,{default:function(){return f}});var d=a(7437),l=a(29),t=a.n(l),n=a(2265),c=a(1837),i=a(3229),r=a(4001);function f(){let[e,s]=(0,n.useState)({}),[a,l]=(0,n.useState)(!0),[f,x]=(0,n.useState)(!1),[j,o]=(0,n.useState)(""),[h,m]=(0,n.useState)(""),[u,p]=(0,n.useState)("");(0,n.useEffect)(()=>{c.hi.get("/api/settings").then(e=>{s(e)}).finally(()=>l(!1))},[]);let g=(e,a)=>{s(s=>({...s,[e]:String(a)}))},b=s=>"true"===e[s],N=s=>e[s]||"",v=s=>parseInt(e[s])||0,_=s=>parseFloat(e[s])||0,y=async()=>{x(!0);try{await c.hi.put("/api/settings",e),o("Settings saved")}catch(e){o(e instanceof Error?e.message:"Failed")}finally{x(!1)}},k=async()=>{if(!h||!u||u.length<6){o("Both fields required, new password min 6 chars");return}try{await c.hi.post("/api/auth/change-password",{old_password:h,new_password:u}),o("Password changed"),m(""),p("")}catch(e){o(e instanceof Error?e.message:"Failed")}};return(n.useEffect(()=>{if(j){let e=setTimeout(()=>o(""),3e3);return()=>clearTimeout(e)}},[j]),a)?(0,d.jsx)("div",{className:"card",children:(0,d.jsx)("div",{className:"skeleton h-64 w-full"})}):(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 page-header",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("h1",{className:"jsx-d7f00f396e984d2 page-title",children:"Settings"}),(0,d.jsx)("p",{className:"jsx-d7f00f396e984d2 page-sub",children:"Gateway configuration"})]}),(0,d.jsxs)("button",{onClick:y,disabled:f,className:"jsx-d7f00f396e984d2 btn-primary",children:[f?(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,d.jsx)(i.Z,{size:16}),"Save"]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Load Balancing"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Strategy"}),(0,d.jsxs)("select",{value:N("load_balance_strategy"),onChange:e=>g("load_balance_strategy",e.target.value),className:"jsx-d7f00f396e984d2 select",children:[(0,d.jsx)("option",{value:"round_robin",className:"jsx-d7f00f396e984d2",children:"Round Robin"}),(0,d.jsx)("option",{value:"weighted",className:"jsx-d7f00f396e984d2",children:"Weighted"}),(0,d.jsx)("option",{value:"least_used",className:"jsx-d7f00f396e984d2",children:"Least Used"}),(0,d.jsx)("option",{value:"random",className:"jsx-d7f00f396e984d2",children:"Random"}),(0,d.jsx)("option",{value:"lowest_cost",className:"jsx-d7f00f396e984d2",children:"Lowest Cost"}),(0,d.jsx)("option",{value:"lowest_latency",className:"jsx-d7f00f396e984d2",children:"Lowest Latency"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Fallback Chains"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-retry on failure"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_fallback"),onChange:e=>g("enable_fallback",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Retry Attempts"}),(0,d.jsx)("input",{type:"number",min:"1",max:"10",value:v("retry_attempts"),onChange:e=>g("retry_attempts",parseInt(e.target.value)||3),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Cooldown on Error (s)"}),(0,d.jsx)("input",{type:"number",value:v("cooldown_on_error_seconds"),onChange:e=>g("cooldown_on_error_seconds",parseInt(e.target.value)||60),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Request Timeout (s)"}),(0,d.jsx)("input",{type:"number",value:v("default_timeout_seconds"),onChange:e=>g("default_timeout_seconds",parseInt(e.target.value)||120),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Auto Model Selection"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Auto Selection"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Route to best model when model is empty"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_auto_model_selection"),onChange:e=>g("enable_auto_model_selection",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Strategy"}),(0,d.jsxs)("select",{value:N("auto_select_strategy"),onChange:e=>g("auto_select_strategy",e.target.value),className:"jsx-d7f00f396e984d2 select",children:[(0,d.jsx)("option",{value:"cheapest",className:"jsx-d7f00f396e984d2",children:"Cheapest"}),(0,d.jsx)("option",{value:"fastest",className:"jsx-d7f00f396e984d2",children:"Fastest"}),(0,d.jsx)("option",{value:"best_context",className:"jsx-d7f00f396e984d2",children:"Best Context Window"}),(0,d.jsx)("option",{value:"reasoning",className:"jsx-d7f00f396e984d2",children:"Best Reasoning"}),(0,d.jsx)("option",{value:"coding",className:"jsx-d7f00f396e984d2",children:"Best Coding"}),(0,d.jsx)("option",{value:"vision",className:"jsx-d7f00f396e984d2",children:"Best Vision"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"A/B Testing"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-route to active A/B tests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_ab_testing"),onChange:e=>g("enable_ab_testing",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Vision Routing"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Route image requests to vision-capable models"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_vision_routing"),onChange:e=>g("enable_vision_routing",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Function Validation"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Validate tool/function call schemas"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_function_validation"),onChange:e=>g("enable_function_validation",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Security"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Require Auth for Proxy"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Protect /v1/* with JWT or hub key"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("require_auth_for_proxy"),onChange:e=>g("require_auth_for_proxy",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Injection Detection"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Scan prompts for injection attempts"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_injection_detection"),onChange:e=>g("enable_injection_detection",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 label",children:["Block Threshold (0-1) ",(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 text-[var(--text-tertiary)] font-normal",children:"requests above this score are rejected"})]}),(0,d.jsx)("input",{type:"number",step:"0.05",min:"0",max:"1",value:_("injection_block_threshold"),onChange:e=>g("injection_block_threshold",parseFloat(e.target.value)||.7),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 label",children:["Flag Threshold (0-1) ",(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 text-[var(--text-tertiary)] font-normal",children:"requests above this score are logged"})]}),(0,d.jsx)("input",{type:"number",step:"0.05",min:"0",max:"1",value:_("injection_flag_threshold"),onChange:e=>g("injection_flag_threshold",parseFloat(e.target.value)||.4),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Response Filtering"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Filter/modify responses"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_response_filtering"),onChange:e=>g("enable_response_filtering",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Request Transforms"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Apply transformer rules to requests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_request_transforms"),onChange:e=>g("enable_request_transforms",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Observability"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Request Logging"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Store all requests in database"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_request_logging"),onChange:e=>g("enable_request_logging",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Cost Tracking"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Estimate USD cost per request"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_cost_tracking"),onChange:e=>g("enable_cost_tracking",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Uptime Tracking"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Background provider health checks"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_uptime_tracking"),onChange:e=>g("enable_uptime_tracking",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Log Entries"}),(0,d.jsx)("input",{type:"number",value:v("max_log_entries"),onChange:e=>g("max_log_entries",parseInt(e.target.value)||1e4),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Uptime Check Interval (s)"}),(0,d.jsx)("input",{type:"number",value:v("uptime_check_interval"),onChange:e=>g("uptime_check_interval",parseInt(e.target.value)||300),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Spend Alert Threshold ($)"}),(0,d.jsx)("input",{type:"number",step:"0.01",value:_("spend_alert_threshold"),onChange:e=>g("spend_alert_threshold",parseFloat(e.target.value)||0),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Error Spike Threshold"}),(0,d.jsx)("input",{type:"number",value:v("error_spike_threshold"),onChange:e=>g("error_spike_threshold",parseInt(e.target.value)||0),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Error Spike Window (s)"}),(0,d.jsx)("input",{type:"number",value:v("error_spike_window_seconds"),onChange:e=>g("error_spike_window_seconds",parseInt(e.target.value)||60),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Caching"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Exact Cache"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Cache identical requests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_exact_cache"),onChange:e=>g("enable_exact_cache",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Semantic Cache"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Cache semantically similar requests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_semantic_cache"),onChange:e=>g("enable_semantic_cache",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Anthropic Cache"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Use Anthropic prompt caching"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_anthropic_cache"),onChange:e=>g("enable_anthropic_cache",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Cache TTL (s)"}),(0,d.jsx)("input",{type:"number",value:v("cache_ttl_seconds"),onChange:e=>g("cache_ttl_seconds",parseInt(e.target.value)||3600),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Web Search"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Web Search"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Allow :online suffix and auto web search"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_web_search"),onChange:e=>g("enable_web_search",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Search Provider"}),(0,d.jsxs)("select",{value:N("search_provider"),onChange:e=>g("search_provider",e.target.value),className:"jsx-d7f00f396e984d2 select",children:[(0,d.jsx)("option",{value:"",className:"jsx-d7f00f396e984d2",children:"None"}),(0,d.jsx)("option",{value:"tavily",className:"jsx-d7f00f396e984d2",children:"Tavily"}),(0,d.jsx)("option",{value:"brave",className:"jsx-d7f00f396e984d2",children:"Brave"}),(0,d.jsx)("option",{value:"searxng",className:"jsx-d7f00f396e984d2",children:"SearXNG"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Tavily API Key"}),(0,d.jsx)("input",{type:"password",value:N("search_tavily_key"),onChange:e=>g("search_tavily_key",e.target.value),placeholder:"sk-...",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Brave API Key"}),(0,d.jsx)("input",{type:"password",value:N("search_brave_key"),onChange:e=>g("search_brave_key",e.target.value),placeholder:"BSA...",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"SearXNG URL"}),(0,d.jsx)("input",{value:N("search_searxng_url"),onChange:e=>g("search_searxng_url",e.target.value),placeholder:"http://localhost:8888",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Results"}),(0,d.jsx)("input",{type:"number",value:v("search_max_results"),onChange:e=>g("search_max_results",parseInt(e.target.value)||5),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Code Interpreter"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Code Interpreter"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Allow :code suffix for code execution"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_code_interpreter"),onChange:e=>g("enable_code_interpreter",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Jupyter URL"}),(0,d.jsx)("input",{value:N("jupyter_url"),onChange:e=>g("jupyter_url",e.target.value),placeholder:"http://localhost:8888",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Jupyter Token"}),(0,d.jsx)("input",{type:"password",value:N("jupyter_token"),onChange:e=>g("jupyter_token",e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Timeout (s)"}),(0,d.jsx)("input",{type:"number",value:v("jupyter_timeout_seconds"),onChange:e=>g("jupyter_timeout_seconds",parseInt(e.target.value)||60),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Iterations"}),(0,d.jsx)("input",{type:"number",value:v("code_interpreter_max_iterations"),onChange:e=>g("code_interpreter_max_iterations",parseInt(e.target.value)||3),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"RAG"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable RAG"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Retrieval-augmented generation"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_rag"),onChange:e=>g("enable_rag",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"RAG TTL (s)"}),(0,d.jsx)("input",{type:"number",value:v("rag_ttl_seconds"),onChange:e=>g("rag_ttl_seconds",parseInt(e.target.value)||3600),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Embedding Provider"}),(0,d.jsx)("input",{value:N("rag_embed_provider"),onChange:e=>g("rag_embed_provider",e.target.value),placeholder:"openai",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Embedding Model"}),(0,d.jsx)("input",{value:N("rag_embed_model"),onChange:e=>g("rag_embed_model",e.target.value),placeholder:"text-embedding-3-small",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Top K Results"}),(0,d.jsx)("input",{type:"number",value:v("rag_top_k"),onChange:e=>g("rag_top_k",parseInt(e.target.value)||3),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Conversation History"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Conversation History"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Store conversation context"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_conversation_history"),onChange:e=>g("enable_conversation_history",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Turns"}),(0,d.jsx)("input",{type:"number",value:v("conversation_max_turns"),onChange:e=>g("conversation_max_turns",parseInt(e.target.value)||10),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"TTL (s)"}),(0,d.jsx)("input",{type:"number",value:v("conversation_ttl_seconds"),onChange:e=>g("conversation_ttl_seconds",parseInt(e.target.value)||3600),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"General"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Hub Name"}),(0,d.jsx)("input",{value:N("hub_name"),onChange:e=>g("hub_name",e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Model Catalog"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-refresh model catalog"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_model_catalog"),onChange:e=>g("enable_model_catalog",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Catalog Refresh Interval (s)"}),(0,d.jsx)("input",{type:"number",value:v("catalog_refresh_interval"),onChange:e=>g("catalog_refresh_interval",parseInt(e.target.value)||86400),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Batch API"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Enable batch request processing"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_batch_api"),onChange:e=>g("enable_batch_api",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Batch Size"}),(0,d.jsx)("input",{type:"number",value:v("max_batch_size"),onChange:e=>g("max_batch_size",parseInt(e.target.value)||100),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Config Backup"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-backup configuration"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_config_backup"),onChange:e=>g("enable_config_backup",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Public Status Page"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Allow unauthenticated uptime view"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("public_status_page"),onChange:e=>g("public_status_page",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Admin Username"}),(0,d.jsx)("input",{value:N("admin_username"),onChange:e=>g("admin_username",e.target.value),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsxs)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:[(0,d.jsx)(r.Z,{size:16})," Change Password"]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Current Password"}),(0,d.jsx)("input",{type:"password",value:h,onChange:e=>m(e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 label",children:["New Password ",(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 text-[var(--text-tertiary)] font-normal",children:"min 6 chars"})]}),(0,d.jsx)("input",{type:"password",value:u,onChange:e=>p(e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsx)("button",{onClick:k,className:"jsx-d7f00f396e984d2 btn-secondary justify-center w-full",children:"Update Password"})]})]})]}),j&&(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 toast",children:j}),(0,d.jsx)(t(),{id:"d7f00f396e984d2",children:'.t-title.jsx-d7f00f396e984d2{font-size:13px;font-weight:600}.t-sub.jsx-d7f00f396e984d2{font-size:11px;color:var(--text-tertiary);margin-top:2px}.toggle.jsx-d7f00f396e984d2{position:relative;width:40px;height:22px;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0}.toggle.jsx-d7f00f396e984d2 input.jsx-d7f00f396e984d2{opacity:0;width:0;height:0}.toggle-slider.jsx-d7f00f396e984d2{position:absolute;inset:0;background:var(--surface-100);-webkit-border-radius:22px;-moz-border-radius:22px;border-radius:22px;cursor:pointer;-webkit-transition:all.16s;-moz-transition:all.16s;-o-transition:all.16s;transition:all.16s;border:1px solid var(--border)}.toggle-slider.jsx-d7f00f396e984d2:before{content:"";position:absolute;left:3px;top:3px;width:14px;height:14px;background:var(--text-tertiary);-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;-webkit-transition:all.16s;-moz-transition:all.16s;-o-transition:all.16s;transition:all.16s}.toggle.jsx-d7f00f396e984d2 input.jsx-d7f00f396e984d2:checked+.toggle-slider.jsx-d7f00f396e984d2{background:rgba(59,130,246,.2);border-color:rgba(59,130,246,.4)}.toggle.jsx-d7f00f396e984d2 input.jsx-d7f00f396e984d2:checked+.toggle-slider.jsx-d7f00f396e984d2:before{background:var(--blue);-webkit-transform:translatex(18px);-moz-transform:translatex(18px);-ms-transform:translatex(18px);-o-transform:translatex(18px);transform:translatex(18px)}'})]})}},1837:function(e,s,a){"use strict";a.d(s,{KF:function(){return j},hi:function(){return x},jl:function(){return n},qz:function(){return t}});let d=a(257).env.NEXT_PUBLIC_API_BASE||"";function l(){return localStorage.getItem("nexus_token")}function t(){localStorage.removeItem("nexus_token")}function n(){return!!l()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},i=new Map,r=new Map;async function f(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=s.method||"GET",n=l(),f={"Content-Type":"application/json",...s.headers};if(n&&(f.Authorization="Bearer ".concat(n)),"GET"===a&&!n){let s=function(e){let s=i.get(e);if(s){if(Date.now()-s.ts>function(e){for(let s in c)if(e===s||e.startsWith(s+"/")||e.startsWith(s+"?"))return c[s];return 5e3}(e)){i.delete(e);return}return s.data}}(e);if(void 0!==s)return s;let a=r.get(e);if(a)return a}let x=(async()=>{let l=await fetch("".concat(d).concat(e),{method:a,headers:f,body:s.body?JSON.stringify(s.body):void 0});if(s.raw)return l;if(401===l.status&&n&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw t(),i.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!l.ok)throw Error((await l.json().catch(()=>({detail:l.statusText}))).detail||"HTTP ".concat(l.status));if(204===l.status)return;let c=await l.json();return"GET"!==a||n||function(e,s){if(i.size>=200){let e=i.keys().next().value;void 0!==e&&i.delete(e)}i.set(e,{ts:Date.now(),data:s})}(e,c),c})();if("GET"===a&&!n){r.set(e,x);try{return await x}finally{r.delete(e)}}return x}let x={get:e=>f(e),post:(e,s)=>f(e,{method:"POST",body:s}),put:(e,s)=>f(e,{method:"PUT",body:s}),patch:(e,s)=>f(e,{method:"PATCH",body:s}),delete:e=>f(e,{method:"DELETE"}),login:async(e,s)=>{var a;let d=await f("/api/auth/login",{method:"POST",body:{username:e,password:s}});return a=d.access_token,localStorage.setItem("nexus_token",a),d},getMe:()=>f("/api/auth/me"),logout:()=>{t(),i.clear(),window.location.href="/login"}},j=async e=>{let s=l(),a=await fetch("".concat(d).concat(e),{headers:s?{Authorization:"Bearer ".concat(s)}:{}});if(!a.ok)throw Error("Failed to download");let t=await a.blob(),n=URL.createObjectURL(t),c=document.createElement("a");c.href=n,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(n)}}},function(e){e.O(0,[4953,2971,2117,1744],function(){return e(e.s=3429)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/admin/{page-2d512533ea7af2ec.js → page-cc1da0c8bc82e2cd.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3],{3429:function(e,s,a){Promise.resolve().then(a.bind(a,6683))},6683:function(e,s,a){"use strict";a.r(s),a.d(s,{default:function(){return f}});var d=a(7437),l=a(29),t=a.n(l),n=a(2265),c=a(1837),i=a(3229),r=a(4001);function f(){let[e,s]=(0,n.useState)({}),[a,l]=(0,n.useState)(!0),[f,x]=(0,n.useState)(!1),[j,o]=(0,n.useState)(""),[h,m]=(0,n.useState)(""),[u,p]=(0,n.useState)("");(0,n.useEffect)(()=>{c.hi.get("/api/settings").then(e=>{s(e)}).finally(()=>l(!1))},[]);let g=(e,a)=>{s(s=>({...s,[e]:String(a)}))},b=s=>"true"===e[s],N=s=>e[s]||"",v=s=>parseInt(e[s])||0,_=s=>parseFloat(e[s])||0,y=async()=>{x(!0);try{await c.hi.put("/api/settings",e),o("Settings saved")}catch(e){o(e instanceof Error?e.message:"Failed")}finally{x(!1)}},k=async()=>{if(!h||!u||u.length<6){o("Both fields required, new password min 6 chars");return}try{await c.hi.post("/api/auth/change-password",{old_password:h,new_password:u}),o("Password changed"),m(""),p("")}catch(e){o(e instanceof Error?e.message:"Failed")}};return(n.useEffect(()=>{if(j){let e=setTimeout(()=>o(""),3e3);return()=>clearTimeout(e)}},[j]),a)?(0,d.jsx)("div",{className:"card",children:(0,d.jsx)("div",{className:"skeleton h-64 w-full"})}):(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 page-header",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("h1",{className:"jsx-d7f00f396e984d2 page-title",children:"Settings"}),(0,d.jsx)("p",{className:"jsx-d7f00f396e984d2 page-sub",children:"Gateway configuration"})]}),(0,d.jsxs)("button",{onClick:y,disabled:f,className:"jsx-d7f00f396e984d2 btn-primary",children:[f?(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,d.jsx)(i.Z,{size:16}),"Save"]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Load Balancing"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Strategy"}),(0,d.jsxs)("select",{value:N("load_balance_strategy"),onChange:e=>g("load_balance_strategy",e.target.value),className:"jsx-d7f00f396e984d2 select",children:[(0,d.jsx)("option",{value:"round_robin",className:"jsx-d7f00f396e984d2",children:"Round Robin"}),(0,d.jsx)("option",{value:"weighted",className:"jsx-d7f00f396e984d2",children:"Weighted"}),(0,d.jsx)("option",{value:"least_used",className:"jsx-d7f00f396e984d2",children:"Least Used"}),(0,d.jsx)("option",{value:"random",className:"jsx-d7f00f396e984d2",children:"Random"}),(0,d.jsx)("option",{value:"lowest_cost",className:"jsx-d7f00f396e984d2",children:"Lowest Cost"}),(0,d.jsx)("option",{value:"lowest_latency",className:"jsx-d7f00f396e984d2",children:"Lowest Latency"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Fallback Chains"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-retry on failure"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_fallback"),onChange:e=>g("enable_fallback",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Retry Attempts"}),(0,d.jsx)("input",{type:"number",min:"1",max:"10",value:v("retry_attempts"),onChange:e=>g("retry_attempts",parseInt(e.target.value)||3),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Cooldown on Error (s)"}),(0,d.jsx)("input",{type:"number",value:v("cooldown_on_error_seconds"),onChange:e=>g("cooldown_on_error_seconds",parseInt(e.target.value)||60),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Request Timeout (s)"}),(0,d.jsx)("input",{type:"number",value:v("default_timeout_seconds"),onChange:e=>g("default_timeout_seconds",parseInt(e.target.value)||120),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Auto Model Selection"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Auto Selection"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Route to best model when model is empty"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_auto_model_selection"),onChange:e=>g("enable_auto_model_selection",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Strategy"}),(0,d.jsxs)("select",{value:N("auto_select_strategy"),onChange:e=>g("auto_select_strategy",e.target.value),className:"jsx-d7f00f396e984d2 select",children:[(0,d.jsx)("option",{value:"cheapest",className:"jsx-d7f00f396e984d2",children:"Cheapest"}),(0,d.jsx)("option",{value:"fastest",className:"jsx-d7f00f396e984d2",children:"Fastest"}),(0,d.jsx)("option",{value:"best_context",className:"jsx-d7f00f396e984d2",children:"Best Context Window"}),(0,d.jsx)("option",{value:"reasoning",className:"jsx-d7f00f396e984d2",children:"Best Reasoning"}),(0,d.jsx)("option",{value:"coding",className:"jsx-d7f00f396e984d2",children:"Best Coding"}),(0,d.jsx)("option",{value:"vision",className:"jsx-d7f00f396e984d2",children:"Best Vision"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"A/B Testing"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-route to active A/B tests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_ab_testing"),onChange:e=>g("enable_ab_testing",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Vision Routing"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Route image requests to vision-capable models"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_vision_routing"),onChange:e=>g("enable_vision_routing",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Function Validation"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Validate tool/function call schemas"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_function_validation"),onChange:e=>g("enable_function_validation",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Security"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Require Auth for Proxy"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Protect /v1/* with JWT or hub key"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("require_auth_for_proxy"),onChange:e=>g("require_auth_for_proxy",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Injection Detection"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Scan prompts for injection attempts"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_injection_detection"),onChange:e=>g("enable_injection_detection",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 label",children:["Block Threshold (0-1) ",(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 text-[var(--text-tertiary)] font-normal",children:"requests above this score are rejected"})]}),(0,d.jsx)("input",{type:"number",step:"0.05",min:"0",max:"1",value:_("injection_block_threshold"),onChange:e=>g("injection_block_threshold",parseFloat(e.target.value)||.7),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 label",children:["Flag Threshold (0-1) ",(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 text-[var(--text-tertiary)] font-normal",children:"requests above this score are logged"})]}),(0,d.jsx)("input",{type:"number",step:"0.05",min:"0",max:"1",value:_("injection_flag_threshold"),onChange:e=>g("injection_flag_threshold",parseFloat(e.target.value)||.4),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Response Filtering"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Filter/modify responses"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_response_filtering"),onChange:e=>g("enable_response_filtering",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Request Transforms"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Apply transformer rules to requests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_request_transforms"),onChange:e=>g("enable_request_transforms",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Observability"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Request Logging"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Store all requests in database"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_request_logging"),onChange:e=>g("enable_request_logging",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Cost Tracking"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Estimate USD cost per request"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_cost_tracking"),onChange:e=>g("enable_cost_tracking",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Uptime Tracking"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Background provider health checks"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_uptime_tracking"),onChange:e=>g("enable_uptime_tracking",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Log Entries"}),(0,d.jsx)("input",{type:"number",value:v("max_log_entries"),onChange:e=>g("max_log_entries",parseInt(e.target.value)||1e4),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Uptime Check Interval (s)"}),(0,d.jsx)("input",{type:"number",value:v("uptime_check_interval"),onChange:e=>g("uptime_check_interval",parseInt(e.target.value)||300),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Spend Alert Threshold ($)"}),(0,d.jsx)("input",{type:"number",step:"0.01",value:_("spend_alert_threshold"),onChange:e=>g("spend_alert_threshold",parseFloat(e.target.value)||0),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Error Spike Threshold"}),(0,d.jsx)("input",{type:"number",value:v("error_spike_threshold"),onChange:e=>g("error_spike_threshold",parseInt(e.target.value)||0),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Error Spike Window (s)"}),(0,d.jsx)("input",{type:"number",value:v("error_spike_window_seconds"),onChange:e=>g("error_spike_window_seconds",parseInt(e.target.value)||60),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Caching"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Exact Cache"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Cache identical requests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_exact_cache"),onChange:e=>g("enable_exact_cache",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Semantic Cache"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Cache semantically similar requests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_semantic_cache"),onChange:e=>g("enable_semantic_cache",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Anthropic Cache"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Use Anthropic prompt caching"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_anthropic_cache"),onChange:e=>g("enable_anthropic_cache",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Cache TTL (s)"}),(0,d.jsx)("input",{type:"number",value:v("cache_ttl_seconds"),onChange:e=>g("cache_ttl_seconds",parseInt(e.target.value)||3600),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Web Search"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Web Search"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Allow :online suffix and auto web search"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_web_search"),onChange:e=>g("enable_web_search",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Search Provider"}),(0,d.jsxs)("select",{value:N("search_provider"),onChange:e=>g("search_provider",e.target.value),className:"jsx-d7f00f396e984d2 select",children:[(0,d.jsx)("option",{value:"",className:"jsx-d7f00f396e984d2",children:"None"}),(0,d.jsx)("option",{value:"tavily",className:"jsx-d7f00f396e984d2",children:"Tavily"}),(0,d.jsx)("option",{value:"brave",className:"jsx-d7f00f396e984d2",children:"Brave"}),(0,d.jsx)("option",{value:"searxng",className:"jsx-d7f00f396e984d2",children:"SearXNG"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Tavily API Key"}),(0,d.jsx)("input",{type:"password",value:N("search_tavily_key"),onChange:e=>g("search_tavily_key",e.target.value),placeholder:"sk-...",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Brave API Key"}),(0,d.jsx)("input",{type:"password",value:N("search_brave_key"),onChange:e=>g("search_brave_key",e.target.value),placeholder:"BSA...",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"SearXNG URL"}),(0,d.jsx)("input",{value:N("search_searxng_url"),onChange:e=>g("search_searxng_url",e.target.value),placeholder:"http://localhost:8888",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Results"}),(0,d.jsx)("input",{type:"number",value:v("search_max_results"),onChange:e=>g("search_max_results",parseInt(e.target.value)||5),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Code Interpreter"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Code Interpreter"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Allow :code suffix for code execution"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_code_interpreter"),onChange:e=>g("enable_code_interpreter",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Jupyter URL"}),(0,d.jsx)("input",{value:N("jupyter_url"),onChange:e=>g("jupyter_url",e.target.value),placeholder:"http://localhost:8888",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Jupyter Token"}),(0,d.jsx)("input",{type:"password",value:N("jupyter_token"),onChange:e=>g("jupyter_token",e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Timeout (s)"}),(0,d.jsx)("input",{type:"number",value:v("jupyter_timeout_seconds"),onChange:e=>g("jupyter_timeout_seconds",parseInt(e.target.value)||60),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Iterations"}),(0,d.jsx)("input",{type:"number",value:v("code_interpreter_max_iterations"),onChange:e=>g("code_interpreter_max_iterations",parseInt(e.target.value)||3),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"RAG"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable RAG"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Retrieval-augmented generation"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_rag"),onChange:e=>g("enable_rag",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"RAG TTL (s)"}),(0,d.jsx)("input",{type:"number",value:v("rag_ttl_seconds"),onChange:e=>g("rag_ttl_seconds",parseInt(e.target.value)||3600),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Embedding Provider"}),(0,d.jsx)("input",{value:N("rag_embed_provider"),onChange:e=>g("rag_embed_provider",e.target.value),placeholder:"openai",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Embedding Model"}),(0,d.jsx)("input",{value:N("rag_embed_model"),onChange:e=>g("rag_embed_model",e.target.value),placeholder:"text-embedding-3-small",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Top K Results"}),(0,d.jsx)("input",{type:"number",value:v("rag_top_k"),onChange:e=>g("rag_top_k",parseInt(e.target.value)||3),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Conversation History"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Conversation History"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Store conversation context"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_conversation_history"),onChange:e=>g("enable_conversation_history",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Turns"}),(0,d.jsx)("input",{type:"number",value:v("conversation_max_turns"),onChange:e=>g("conversation_max_turns",parseInt(e.target.value)||10),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"TTL (s)"}),(0,d.jsx)("input",{type:"number",value:v("conversation_ttl_seconds"),onChange:e=>g("conversation_ttl_seconds",parseInt(e.target.value)||3600),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"General"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Hub Name"}),(0,d.jsx)("input",{value:N("hub_name"),onChange:e=>g("hub_name",e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Model Catalog"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-refresh model catalog"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_model_catalog"),onChange:e=>g("enable_model_catalog",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Catalog Refresh Interval (s)"}),(0,d.jsx)("input",{type:"number",value:v("catalog_refresh_interval"),onChange:e=>g("catalog_refresh_interval",parseInt(e.target.value)||86400),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Batch API"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Enable batch request processing"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_batch_api"),onChange:e=>g("enable_batch_api",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Batch Size"}),(0,d.jsx)("input",{type:"number",value:v("max_batch_size"),onChange:e=>g("max_batch_size",parseInt(e.target.value)||100),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Config Backup"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-backup configuration"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_config_backup"),onChange:e=>g("enable_config_backup",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Public Status Page"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Allow unauthenticated uptime view"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("public_status_page"),onChange:e=>g("public_status_page",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Admin Username"}),(0,d.jsx)("input",{value:N("admin_username"),onChange:e=>g("admin_username",e.target.value),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsxs)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:[(0,d.jsx)(r.Z,{size:16})," Change Password"]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Current Password"}),(0,d.jsx)("input",{type:"password",value:h,onChange:e=>m(e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 label",children:["New Password ",(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 text-[var(--text-tertiary)] font-normal",children:"min 6 chars"})]}),(0,d.jsx)("input",{type:"password",value:u,onChange:e=>p(e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsx)("button",{onClick:k,className:"jsx-d7f00f396e984d2 btn-secondary justify-center w-full",children:"Update Password"})]})]})]}),j&&(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 toast",children:j}),(0,d.jsx)(t(),{id:"d7f00f396e984d2",children:'.t-title.jsx-d7f00f396e984d2{font-size:13px;font-weight:600}.t-sub.jsx-d7f00f396e984d2{font-size:11px;color:var(--text-tertiary);margin-top:2px}.toggle.jsx-d7f00f396e984d2{position:relative;width:40px;height:22px;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0}.toggle.jsx-d7f00f396e984d2 input.jsx-d7f00f396e984d2{opacity:0;width:0;height:0}.toggle-slider.jsx-d7f00f396e984d2{position:absolute;inset:0;background:var(--surface-100);-webkit-border-radius:22px;-moz-border-radius:22px;border-radius:22px;cursor:pointer;-webkit-transition:all.16s;-moz-transition:all.16s;-o-transition:all.16s;transition:all.16s;border:1px solid var(--border)}.toggle-slider.jsx-d7f00f396e984d2:before{content:"";position:absolute;left:3px;top:3px;width:14px;height:14px;background:var(--text-tertiary);-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;-webkit-transition:all.16s;-moz-transition:all.16s;-o-transition:all.16s;transition:all.16s}.toggle.jsx-d7f00f396e984d2 input.jsx-d7f00f396e984d2:checked+.toggle-slider.jsx-d7f00f396e984d2{background:rgba(59,130,246,.2);border-color:rgba(59,130,246,.4)}.toggle.jsx-d7f00f396e984d2 input.jsx-d7f00f396e984d2:checked+.toggle-slider.jsx-d7f00f396e984d2:before{background:var(--blue);-webkit-transform:translatex(18px);-moz-transform:translatex(18px);-ms-transform:translatex(18px);-o-transform:translatex(18px);transform:translatex(18px)}'})]})}},1837:function(e,s,a){"use strict";a.d(s,{KF:function(){return j},hi:function(){return x},jl:function(){return n},qz:function(){return t}});let d=a(257).env.NEXT_PUBLIC_API_BASE||"";function l(){return localStorage.getItem("nexus_token")}function t(){localStorage.removeItem("nexus_token")}function n(){return!!l()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},i=new Map,r=new Map;async function f(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=s.method||"GET",n=l(),f={"Content-Type":"application/json",...s.headers};if(n&&(f.Authorization="Bearer ".concat(n)),"GET"===a&&!n){let s=function(e){let s=i.get(e);if(s){if(Date.now()-s.ts>function(e){for(let s in c)if(e===s||e.startsWith(s+"/")||e.startsWith(s+"?"))return c[s];return 5e3}(e)){i.delete(e);return}return s.data}}(e);if(void 0!==s)return s;let a=r.get(e);if(a)return a}let x=(async()=>{let l=await fetch("".concat(d).concat(e),{method:a,headers:f,body:s.body?JSON.stringify(s.body):void 0});if(s.raw)return l;if(401===l.status&&n&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw t(),i.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!l.ok)throw Error((await l.json().catch(()=>({detail:l.statusText}))).detail||"HTTP ".concat(l.status));if(204===l.status)return;let c=await l.json();return"GET"!==a||n||function(e,s){if(i.size>=200){let e=i.keys().next().value;void 0!==e&&i.delete(e)}i.set(e,{ts:Date.now(),data:s})}(e,c),c})();if("GET"===a&&!n){r.set(e,x);try{return await x}finally{r.delete(e)}}return x}let x={get:e=>f(e),post:(e,s)=>f(e,{method:"POST",body:s}),put:(e,s)=>f(e,{method:"PUT",body:s}),patch:(e,s)=>f(e,{method:"PATCH",body:s}),delete:e=>f(e,{method:"DELETE"}),login:async(e,s)=>{var a;let d=await f("/api/auth/login",{method:"POST",body:{username:e,password:s}});return a=d.access_token,localStorage.setItem("nexus_token",a),d},getMe:()=>f("/api/auth/me"),logout:()=>{t(),i.clear(),window.location.href="/login"}},j=async e=>{let s=l(),a=await fetch("".concat(d).concat(e),{headers:s?{Authorization:"Bearer ".concat(s)}:{}});if(!a.ok)throw Error("Failed to download");let t=await a.blob(),n=URL.createObjectURL(t),c=document.createElement("a");c.href=n,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(n)}}},function(e){e.O(0,[4953,2971,2117,1744],function(){return e(e.s=3429)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3],{3429:function(e,s,a){Promise.resolve().then(a.bind(a,6683))},6683:function(e,s,a){"use strict";a.r(s),a.d(s,{default:function(){return f}});var d=a(7437),l=a(29),t=a.n(l),n=a(2265),c=a(1837),i=a(3229),r=a(4001);function f(){let[e,s]=(0,n.useState)({}),[a,l]=(0,n.useState)(!0),[f,x]=(0,n.useState)(!1),[j,o]=(0,n.useState)(""),[h,m]=(0,n.useState)(""),[u,p]=(0,n.useState)("");(0,n.useEffect)(()=>{c.hi.get("/api/settings").then(e=>{s(e)}).finally(()=>l(!1))},[]);let g=(e,a)=>{s(s=>({...s,[e]:String(a)}))},b=s=>"true"===e[s],N=s=>e[s]||"",v=s=>parseInt(e[s])||0,_=s=>parseFloat(e[s])||0,y=async()=>{x(!0);try{await c.hi.put("/api/settings",e),o("Settings saved")}catch(e){o(e instanceof Error?e.message:"Failed")}finally{x(!1)}},k=async()=>{if(!h||!u||u.length<6){o("Both fields required, new password min 6 chars");return}try{await c.hi.post("/api/auth/change-password",{old_password:h,new_password:u}),o("Password changed"),m(""),p("")}catch(e){o(e instanceof Error?e.message:"Failed")}};return(n.useEffect(()=>{if(j){let e=setTimeout(()=>o(""),3e3);return()=>clearTimeout(e)}},[j]),a)?(0,d.jsx)("div",{className:"card",children:(0,d.jsx)("div",{className:"skeleton h-64 w-full"})}):(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 page-header",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("h1",{className:"jsx-d7f00f396e984d2 page-title",children:"Settings"}),(0,d.jsx)("p",{className:"jsx-d7f00f396e984d2 page-sub",children:"Gateway configuration"})]}),(0,d.jsxs)("button",{onClick:y,disabled:f,className:"jsx-d7f00f396e984d2 btn-primary",children:[f?(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,d.jsx)(i.Z,{size:16}),"Save"]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Load Balancing"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Strategy"}),(0,d.jsxs)("select",{value:N("load_balance_strategy"),onChange:e=>g("load_balance_strategy",e.target.value),className:"jsx-d7f00f396e984d2 select",children:[(0,d.jsx)("option",{value:"round_robin",className:"jsx-d7f00f396e984d2",children:"Round Robin"}),(0,d.jsx)("option",{value:"weighted",className:"jsx-d7f00f396e984d2",children:"Weighted"}),(0,d.jsx)("option",{value:"least_used",className:"jsx-d7f00f396e984d2",children:"Least Used"}),(0,d.jsx)("option",{value:"random",className:"jsx-d7f00f396e984d2",children:"Random"}),(0,d.jsx)("option",{value:"lowest_cost",className:"jsx-d7f00f396e984d2",children:"Lowest Cost"}),(0,d.jsx)("option",{value:"lowest_latency",className:"jsx-d7f00f396e984d2",children:"Lowest Latency"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Fallback Chains"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-retry on failure"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_fallback"),onChange:e=>g("enable_fallback",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Retry Attempts"}),(0,d.jsx)("input",{type:"number",min:"1",max:"10",value:v("retry_attempts"),onChange:e=>g("retry_attempts",parseInt(e.target.value)||3),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Cooldown on Error (s)"}),(0,d.jsx)("input",{type:"number",value:v("cooldown_on_error_seconds"),onChange:e=>g("cooldown_on_error_seconds",parseInt(e.target.value)||60),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Request Timeout (s)"}),(0,d.jsx)("input",{type:"number",value:v("default_timeout_seconds"),onChange:e=>g("default_timeout_seconds",parseInt(e.target.value)||120),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Auto Model Selection"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Auto Selection"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Route to best model when model is empty"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_auto_model_selection"),onChange:e=>g("enable_auto_model_selection",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Strategy"}),(0,d.jsxs)("select",{value:N("auto_select_strategy"),onChange:e=>g("auto_select_strategy",e.target.value),className:"jsx-d7f00f396e984d2 select",children:[(0,d.jsx)("option",{value:"cheapest",className:"jsx-d7f00f396e984d2",children:"Cheapest"}),(0,d.jsx)("option",{value:"fastest",className:"jsx-d7f00f396e984d2",children:"Fastest"}),(0,d.jsx)("option",{value:"best_context",className:"jsx-d7f00f396e984d2",children:"Best Context Window"}),(0,d.jsx)("option",{value:"reasoning",className:"jsx-d7f00f396e984d2",children:"Best Reasoning"}),(0,d.jsx)("option",{value:"coding",className:"jsx-d7f00f396e984d2",children:"Best Coding"}),(0,d.jsx)("option",{value:"vision",className:"jsx-d7f00f396e984d2",children:"Best Vision"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"A/B Testing"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-route to active A/B tests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_ab_testing"),onChange:e=>g("enable_ab_testing",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Vision Routing"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Route image requests to vision-capable models"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_vision_routing"),onChange:e=>g("enable_vision_routing",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Function Validation"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Validate tool/function call schemas"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_function_validation"),onChange:e=>g("enable_function_validation",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Security"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Require Auth for Proxy"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Protect /v1/* with JWT or hub key"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("require_auth_for_proxy"),onChange:e=>g("require_auth_for_proxy",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Injection Detection"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Scan prompts for injection attempts"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_injection_detection"),onChange:e=>g("enable_injection_detection",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 label",children:["Block Threshold (0-1) ",(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 text-[var(--text-tertiary)] font-normal",children:"requests above this score are rejected"})]}),(0,d.jsx)("input",{type:"number",step:"0.05",min:"0",max:"1",value:_("injection_block_threshold"),onChange:e=>g("injection_block_threshold",parseFloat(e.target.value)||.7),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 label",children:["Flag Threshold (0-1) ",(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 text-[var(--text-tertiary)] font-normal",children:"requests above this score are logged"})]}),(0,d.jsx)("input",{type:"number",step:"0.05",min:"0",max:"1",value:_("injection_flag_threshold"),onChange:e=>g("injection_flag_threshold",parseFloat(e.target.value)||.4),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Response Filtering"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Filter/modify responses"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_response_filtering"),onChange:e=>g("enable_response_filtering",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Request Transforms"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Apply transformer rules to requests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_request_transforms"),onChange:e=>g("enable_request_transforms",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Observability"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Request Logging"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Store all requests in database"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_request_logging"),onChange:e=>g("enable_request_logging",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Cost Tracking"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Estimate USD cost per request"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_cost_tracking"),onChange:e=>g("enable_cost_tracking",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Uptime Tracking"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Background provider health checks"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_uptime_tracking"),onChange:e=>g("enable_uptime_tracking",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Log Entries"}),(0,d.jsx)("input",{type:"number",value:v("max_log_entries"),onChange:e=>g("max_log_entries",parseInt(e.target.value)||1e4),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Uptime Check Interval (s)"}),(0,d.jsx)("input",{type:"number",value:v("uptime_check_interval"),onChange:e=>g("uptime_check_interval",parseInt(e.target.value)||300),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Spend Alert Threshold ($)"}),(0,d.jsx)("input",{type:"number",step:"0.01",value:_("spend_alert_threshold"),onChange:e=>g("spend_alert_threshold",parseFloat(e.target.value)||0),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Error Spike Threshold"}),(0,d.jsx)("input",{type:"number",value:v("error_spike_threshold"),onChange:e=>g("error_spike_threshold",parseInt(e.target.value)||0),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Error Spike Window (s)"}),(0,d.jsx)("input",{type:"number",value:v("error_spike_window_seconds"),onChange:e=>g("error_spike_window_seconds",parseInt(e.target.value)||60),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Caching"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Exact Cache"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Cache identical requests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_exact_cache"),onChange:e=>g("enable_exact_cache",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Semantic Cache"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Cache semantically similar requests"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_semantic_cache"),onChange:e=>g("enable_semantic_cache",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Anthropic Cache"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Use Anthropic prompt caching"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_anthropic_cache"),onChange:e=>g("enable_anthropic_cache",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Cache TTL (s)"}),(0,d.jsx)("input",{type:"number",value:v("cache_ttl_seconds"),onChange:e=>g("cache_ttl_seconds",parseInt(e.target.value)||3600),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Web Search"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Web Search"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Allow :online suffix and auto web search"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_web_search"),onChange:e=>g("enable_web_search",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Search Provider"}),(0,d.jsxs)("select",{value:N("search_provider"),onChange:e=>g("search_provider",e.target.value),className:"jsx-d7f00f396e984d2 select",children:[(0,d.jsx)("option",{value:"",className:"jsx-d7f00f396e984d2",children:"None"}),(0,d.jsx)("option",{value:"tavily",className:"jsx-d7f00f396e984d2",children:"Tavily"}),(0,d.jsx)("option",{value:"brave",className:"jsx-d7f00f396e984d2",children:"Brave"}),(0,d.jsx)("option",{value:"searxng",className:"jsx-d7f00f396e984d2",children:"SearXNG"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Tavily API Key"}),(0,d.jsx)("input",{type:"password",value:N("search_tavily_key"),onChange:e=>g("search_tavily_key",e.target.value),placeholder:"sk-...",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Brave API Key"}),(0,d.jsx)("input",{type:"password",value:N("search_brave_key"),onChange:e=>g("search_brave_key",e.target.value),placeholder:"BSA...",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"SearXNG URL"}),(0,d.jsx)("input",{value:N("search_searxng_url"),onChange:e=>g("search_searxng_url",e.target.value),placeholder:"http://localhost:8888",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Results"}),(0,d.jsx)("input",{type:"number",value:v("search_max_results"),onChange:e=>g("search_max_results",parseInt(e.target.value)||5),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Code Interpreter"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Code Interpreter"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Allow :code suffix for code execution"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_code_interpreter"),onChange:e=>g("enable_code_interpreter",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Jupyter URL"}),(0,d.jsx)("input",{value:N("jupyter_url"),onChange:e=>g("jupyter_url",e.target.value),placeholder:"http://localhost:8888",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Jupyter Token"}),(0,d.jsx)("input",{type:"password",value:N("jupyter_token"),onChange:e=>g("jupyter_token",e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Timeout (s)"}),(0,d.jsx)("input",{type:"number",value:v("jupyter_timeout_seconds"),onChange:e=>g("jupyter_timeout_seconds",parseInt(e.target.value)||60),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Iterations"}),(0,d.jsx)("input",{type:"number",value:v("code_interpreter_max_iterations"),onChange:e=>g("code_interpreter_max_iterations",parseInt(e.target.value)||3),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"RAG"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable RAG"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Retrieval-augmented generation"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_rag"),onChange:e=>g("enable_rag",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"RAG TTL (s)"}),(0,d.jsx)("input",{type:"number",value:v("rag_ttl_seconds"),onChange:e=>g("rag_ttl_seconds",parseInt(e.target.value)||3600),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Embedding Provider"}),(0,d.jsx)("input",{value:N("rag_embed_provider"),onChange:e=>g("rag_embed_provider",e.target.value),placeholder:"openai",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Embedding Model"}),(0,d.jsx)("input",{value:N("rag_embed_model"),onChange:e=>g("rag_embed_model",e.target.value),placeholder:"text-embedding-3-small",className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Top K Results"}),(0,d.jsx)("input",{type:"number",value:v("rag_top_k"),onChange:e=>g("rag_top_k",parseInt(e.target.value)||3),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"Conversation History"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Enable Conversation History"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Store conversation context"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_conversation_history"),onChange:e=>g("enable_conversation_history",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Turns"}),(0,d.jsx)("input",{type:"number",value:v("conversation_max_turns"),onChange:e=>g("conversation_max_turns",parseInt(e.target.value)||10),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"TTL (s)"}),(0,d.jsx)("input",{type:"number",value:v("conversation_ttl_seconds"),onChange:e=>g("conversation_ttl_seconds",parseInt(e.target.value)||3600),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsx)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:"General"}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Hub Name"}),(0,d.jsx)("input",{value:N("hub_name"),onChange:e=>g("hub_name",e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Model Catalog"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-refresh model catalog"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_model_catalog"),onChange:e=>g("enable_model_catalog",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Catalog Refresh Interval (s)"}),(0,d.jsx)("input",{type:"number",value:v("catalog_refresh_interval"),onChange:e=>g("catalog_refresh_interval",parseInt(e.target.value)||86400),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Batch API"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Enable batch request processing"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_batch_api"),onChange:e=>g("enable_batch_api",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Max Batch Size"}),(0,d.jsx)("input",{type:"number",value:v("max_batch_size"),onChange:e=>g("max_batch_size",parseInt(e.target.value)||100),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Config Backup"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Auto-backup configuration"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("enable_config_backup"),onChange:e=>g("enable_config_backup",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-title",children:"Public Status Page"}),(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 t-sub",children:"Allow unauthenticated uptime view"})]}),(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 toggle",children:[(0,d.jsx)("input",{type:"checkbox",checked:b("public_status_page"),onChange:e=>g("public_status_page",e.target.checked),className:"jsx-d7f00f396e984d2"}),(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 toggle-slider"})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Admin Username"}),(0,d.jsx)("input",{value:N("admin_username"),onChange:e=>g("admin_username",e.target.value),className:"jsx-d7f00f396e984d2 input"})]})]})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 card",children:[(0,d.jsxs)("h2",{className:"jsx-d7f00f396e984d2 text-sm font-semibold mb-4",children:[(0,d.jsx)(r.Z,{size:16})," Change Password"]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2 space-y-4",children:[(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsx)("label",{className:"jsx-d7f00f396e984d2 label",children:"Current Password"}),(0,d.jsx)("input",{type:"password",value:h,onChange:e=>m(e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsxs)("div",{className:"jsx-d7f00f396e984d2",children:[(0,d.jsxs)("label",{className:"jsx-d7f00f396e984d2 label",children:["New Password ",(0,d.jsx)("span",{className:"jsx-d7f00f396e984d2 text-[var(--text-tertiary)] font-normal",children:"min 6 chars"})]}),(0,d.jsx)("input",{type:"password",value:u,onChange:e=>p(e.target.value),className:"jsx-d7f00f396e984d2 input"})]}),(0,d.jsx)("button",{onClick:k,className:"jsx-d7f00f396e984d2 btn-secondary justify-center w-full",children:"Update Password"})]})]})]}),j&&(0,d.jsx)("div",{className:"jsx-d7f00f396e984d2 toast",children:j}),(0,d.jsx)(t(),{id:"d7f00f396e984d2",children:'.t-title.jsx-d7f00f396e984d2{font-size:13px;font-weight:600}.t-sub.jsx-d7f00f396e984d2{font-size:11px;color:var(--text-tertiary);margin-top:2px}.toggle.jsx-d7f00f396e984d2{position:relative;width:40px;height:22px;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0}.toggle.jsx-d7f00f396e984d2 input.jsx-d7f00f396e984d2{opacity:0;width:0;height:0}.toggle-slider.jsx-d7f00f396e984d2{position:absolute;inset:0;background:var(--surface-100);-webkit-border-radius:22px;-moz-border-radius:22px;border-radius:22px;cursor:pointer;-webkit-transition:all.16s;-moz-transition:all.16s;-o-transition:all.16s;transition:all.16s;border:1px solid var(--border)}.toggle-slider.jsx-d7f00f396e984d2:before{content:"";position:absolute;left:3px;top:3px;width:14px;height:14px;background:var(--text-tertiary);-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;-webkit-transition:all.16s;-moz-transition:all.16s;-o-transition:all.16s;transition:all.16s}.toggle.jsx-d7f00f396e984d2 input.jsx-d7f00f396e984d2:checked+.toggle-slider.jsx-d7f00f396e984d2{background:rgba(59,130,246,.2);border-color:rgba(59,130,246,.4)}.toggle.jsx-d7f00f396e984d2 input.jsx-d7f00f396e984d2:checked+.toggle-slider.jsx-d7f00f396e984d2:before{background:var(--blue);-webkit-transform:translatex(18px);-moz-transform:translatex(18px);-ms-transform:translatex(18px);-o-transform:translatex(18px);transform:translatex(18px)}'})]})}},1837:function(e,s,a){"use strict";a.d(s,{KF:function(){return j},hi:function(){return x},jl:function(){return n},qz:function(){return t}});let d=a(257).env.NEXT_PUBLIC_API_BASE||"";function l(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function t(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function n(){return!!l()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},i=new Map,r=new Map;async function f(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=s.method||"GET",n=l(),f={"Content-Type":"application/json",...s.headers};if(n&&(f.Authorization="Bearer ".concat(n)),"GET"===a&&!n){let s=function(e){let s=i.get(e);if(s){if(Date.now()-s.ts>function(e){for(let s in c)if(e===s||e.startsWith(s+"/")||e.startsWith(s+"?"))return c[s];return 5e3}(e)){i.delete(e);return}return s.data}}(e);if(void 0!==s)return s;let a=r.get(e);if(a)return a}let x=(async()=>{let l=await fetch("".concat(d).concat(e),{method:a,headers:f,body:s.body?JSON.stringify(s.body):void 0});if(s.raw)return l;if(401===l.status&&n&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw t(),i.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!l.ok)throw Error((await l.json().catch(()=>({detail:l.statusText}))).detail||"HTTP ".concat(l.status));if(204===l.status)return;let c=await l.json();return"GET"!==a||n||function(e,s){if(i.size>=200){let e=i.keys().next().value;void 0!==e&&i.delete(e)}i.set(e,{ts:Date.now(),data:s})}(e,c),c})();if("GET"===a&&!n){r.set(e,x);try{return await x}finally{r.delete(e)}}return x}let x={get:e=>f(e),post:(e,s)=>f(e,{method:"POST",body:s}),put:(e,s)=>f(e,{method:"PUT",body:s}),patch:(e,s)=>f(e,{method:"PATCH",body:s}),delete:e=>f(e,{method:"DELETE"}),login:async(e,s)=>{var a;let d=await f("/api/auth/login",{method:"POST",body:{username:e,password:s}});return a=d.access_token,localStorage.setItem("nexus_token",a),function(e,s,a){try{let a="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(s),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(a)}catch(e){}}("nexus_token",a,0),d},getMe:()=>f("/api/auth/me"),logout:()=>{t(),i.clear(),window.location.href="/login"}},j=async e=>{let s=l(),a=await fetch("".concat(d).concat(e),{headers:s?{Authorization:"Bearer ".concat(s)}:{}});if(!a.ok)throw Error("Failed to download");let t=await a.blob(),n=URL.createObjectURL(t),c=document.createElement("a");c.href=n,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(n)}}},function(e){e.O(0,[4953,2971,2117,1744],function(){return e(e.s=3429)}),_N_E=e.O()}]);
static/_next/static/chunks/app/agent/page-12f7d7e3790a2607.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2060],{9763:function(e,t,r){Promise.resolve().then(r.bind(r,5126))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return c}});var a=r(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),n=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,a.forwardRef)((e,t)=>{let{color:r="currentColor",size:s=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:r,strokeWidth:c?24*Number(l)/Number(s):l,className:n("lucide",o),...h},[...u.map(e=>{let[t,r]=e;return(0,a.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let r=(0,a.forwardRef)((r,i)=>{let{className:c,...o}=r;return(0,a.createElement)(l,{ref:i,iconNode:t,className:n("lucide-".concat(s(e)),c),...o})});return r.displayName="".concat(e),r}},2222:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]])},875:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},9322:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},9388:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},2208:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},4001:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]])},3417:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},9397:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7168:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},4743:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},2023:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]])},8930:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},2489:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},257:function(e,t,r){"use strict";var a,s;e.exports=(null==(a=r.g.process)?void 0:a.env)&&"object"==typeof(null==(s=r.g.process)?void 0:s.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,a,s=e.exports={};function n(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:n}catch(e){t=n}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var c=[],o=!1,d=-1;function u(){o&&a&&(o=!1,a.length?c=a.concat(c):d=-1,c.length&&h())}function h(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(a=c,c=[];++d<t;)a&&a[d].run();d=-1,t=c.length}a=null,o=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function x(e,t){this.fun=e,this.array=t}function m(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new x(e,t)),1!==c.length||o||l(h)},x.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},r={};function a(e){var s=r[e];if(void 0!==s)return s.exports;var n=r[e]={exports:{}},i=!0;try{t[e](n,n.exports,a),i=!1}finally{i&&delete r[e]}return n.exports}a.ab="//";var s=a(229);e.exports=s}()},5126:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return T}});var a=r(7437),s=r(2265),n=r(1837),i=r(9205);let l=(0,i.Z)("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var c=r(9388);let o=(0,i.Z)("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);var d=r(875);let u=(0,i.Z)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var h=r(4001);let x=(0,i.Z)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var m=r(2489);let f=(0,i.Z)("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var p=r(2208),v=r(9322),y=r(2222),g=r(9397),b=r(3417),j=r(8930),k=r(2023),w=r(7168);let N=(0,i.Z)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);var C=r(4743);let Z=s.memo(function(e){let{item:t}=e,[r,n]=(0,s.useState)(!1),i="tool_result"===t.type;return(0,a.jsxs)("div",{className:"my-2 rounded-lg border border-[var(--border)] bg-[var(--surface-50)] overflow-hidden",children:[(0,a.jsxs)("button",{onClick:()=>n(e=>!e),className:"w-full flex items-center gap-2 px-3 py-2 text-left text-xs hover:bg-[var(--surface-100)]",children:[i?t.ok?(0,a.jsx)(l,{size:14,className:"text-emerald-400 shrink-0"}):(0,a.jsx)(c.Z,{size:14,className:"text-red-400 shrink-0"}):(0,a.jsx)(o,{size:14,className:"text-blue-400 shrink-0"}),(0,a.jsx)("span",{className:"font-mono text-[var(--text-secondary)]",children:t.name}),(0,a.jsx)("span",{className:"text-[var(--text-tertiary)] truncate flex-1",children:i?t.summary:t.args_display}),r?(0,a.jsx)(d.Z,{size:12}):(0,a.jsx)(u,{size:12})]}),r&&(0,a.jsx)("div",{className:"px-3 py-2 border-t border-[var(--border)] bg-[var(--bg)] text-xs font-mono whitespace-pre-wrap break-all",children:i?t.summary:t.args_display})]})}),z=s.memo(function(e){var t;let{schema:r,onSubmit:n,onCancel:i}=e,[l,c]=(0,s.useState)(!1),[o,d]=(0,s.useState)(()=>{let e={};for(let t of r.fields||[])e[t.name]="";return e}),u=null===(t=r.fields)||void 0===t?void 0:t[0],v=(null==u?void 0:u.type)==="password",y=u&&o[u.name]||"",g=!(null==u?void 0:u.required)||y.length>=(u.minLength||0);return(0,a.jsxs)("div",{className:"my-3 rounded-lg border-2 border-[var(--accent)] bg-[var(--surface)] p-4 shadow-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-lg bg-[var(--accent)]/20 flex items-center justify-center shrink-0",children:v?(0,a.jsx)(h.Z,{size:20,className:"text-[var(--accent)]"}):(0,a.jsx)(x,{size:20,className:"text-[var(--accent)]"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold",children:r.title}),(0,a.jsx)("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:r.description})]}),(0,a.jsx)("button",{onClick:i,className:"text-[var(--text-tertiary)] hover:text-white p-1","aria-label":"Cancel",children:(0,a.jsx)(m.Z,{size:16})})]}),u&&(0,a.jsxs)("div",{className:"mb-3",children:[(0,a.jsxs)("label",{className:"text-xs font-medium text-[var(--text-secondary)] mb-1 block",children:[u.label,u.required&&(0,a.jsx)("span",{className:"text-red-400 ml-1",children:"*"})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{type:v&&!l?"password":"text",value:y,onChange:e=>d(t=>({...t,[u.name]:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&g&&n(o),"Escape"===e.key&&i()},autoFocus:!0,autoComplete:"off",spellCheck:!1,className:"w-full bg-[var(--bg)] border border-[var(--border)] rounded-lg px-3 py-2 pr-10 text-sm font-mono focus:outline-none focus:border-[var(--accent)]",placeholder:"••••••••"}),v&&(0,a.jsx)("button",{type:"button",onClick:()=>c(e=>!e),className:"absolute right-2 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-white p-1","aria-label":l?"Hide":"Show",children:l?(0,a.jsx)(f,{size:14}):(0,a.jsx)(p.Z,{size:14})})]}),v&&(0,a.jsxs)("p",{className:"text-[10px] text-[var(--text-tertiary)] mt-1 flex items-center gap-1",children:[(0,a.jsx)(x,{size:10}),"Sent directly to gateway — never appears in chat history or LLM context"]})]}),(0,a.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,a.jsx)("button",{onClick:i,className:"px-3 py-1.5 text-xs rounded-md border border-[var(--border)] hover:bg-[var(--surface-100)]",children:"Cancel"}),(0,a.jsx)("button",{onClick:()=>n(o),disabled:!g,className:"px-3 py-1.5 text-xs rounded-md bg-[var(--accent)] text-white font-medium disabled:opacity-50 hover:opacity-90",children:r.submit_label||"Submit"})]})]})}),E=s.memo(function(e){let{schema:t,onConfirm:r,onCancel:s}=e;return(0,a.jsxs)("div",{className:"my-3 rounded-lg border-2 border-yellow-500/50 bg-[var(--surface)] p-4 shadow-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center shrink-0",children:(0,a.jsx)(v.Z,{size:20,className:"text-yellow-400"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold",children:t.title}),(0,a.jsx)("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:t.description})]})]}),(0,a.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,a.jsx)("button",{onClick:s,className:"px-3 py-1.5 text-xs rounded-md border border-[var(--border)] hover:bg-[var(--surface-100)]",children:"Cancel"}),(0,a.jsx)("button",{onClick:r,className:"px-3 py-1.5 text-xs rounded-md text-white font-medium hover:opacity-90 ".concat(t.danger?"bg-red-500":"bg-[var(--accent)]"),children:t.confirm_label||"Confirm"})]})]})}),M=s.memo(function(e){let{role:t,content:r,transcript:s}=e,n="user"===t;return(0,a.jsxs)("div",{className:"flex gap-3 ".concat(n?"justify-end":"justify-start"),children:[!n&&(0,a.jsx)("div",{className:"w-7 h-7 rounded-lg bg-gradient-to-br from-[var(--accent)] to-nexus-400 flex items-center justify-center shrink-0",children:(0,a.jsx)(y.Z,{size:14,className:"text-white"})}),(0,a.jsxs)("div",{className:"max-w-[80%] ".concat(n?"order-1":""),children:[s&&s.length>0&&(0,a.jsx)("div",{className:"mb-2",children:s.map((e,t)=>(0,a.jsx)(Z,{item:e},t))}),r&&(0,a.jsx)("div",{className:"rounded-2xl px-4 py-2.5 text-sm leading-relaxed ".concat(n?"bg-[var(--accent)] text-white whitespace-pre-wrap":"bg-[var(--surface-100)] text-[var(--text)] whitespace-pre-wrap"),children:r})]}),n&&(0,a.jsx)("div",{className:"w-7 h-7 rounded-lg bg-[var(--surface-200)] flex items-center justify-center shrink-0 text-xs font-semibold order-2",children:"U"})]})});function T(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(null),[l,c]=(0,s.useState)([]),[o,d]=(0,s.useState)(""),[u,h]=(0,s.useState)(!1),[x,f]=(0,s.useState)([]),[p,Z]=(0,s.useState)(""),[T,S]=(0,s.useState)(null),[_,A]=(0,s.useState)(null),[L,q]=(0,s.useState)(""),P=(0,s.useRef)(null),O=(0,s.useRef)(null),R=(0,s.useMemo)(()=>e.find(e=>e.id===r)||null,[e,r]),D=(0,s.useCallback)(async()=>{try{let e=await n.hi.get("/api/agent/conversations");t(e.conversations||[])}catch(e){console.error(e)}},[]),H=(0,s.useCallback)(async e=>{try{let t=((await n.hi.get("/api/agent/conversations/".concat(e))).messages||[]).map(e=>{let t=[];for(let s of e.tool_calls||[]){var r,a;let e=(null===(r=s.function)||void 0===r?void 0:r.name)||"tool",n={};try{n=JSON.parse((null===(a=s.function)||void 0===a?void 0:a.arguments)||"{}")}catch(e){}t.push({type:"tool_call",name:e,args_display:"".concat(e,"(").concat(Object.entries(n).map(e=>{let[t,r]=e;return"".concat(t,"=").concat(JSON.stringify(r))}).join(", "),")"),tool_call_id:s.id})}return{role:e.role,content:e.content||"",transcript:t.length?t:void 0}});c(t)}catch(e){console.error(e),c([])}},[]);(0,s.useEffect)(()=>{D(),n.hi.get("/api/agent/models").then(e=>{var t;f(e.models||[]),(null===(t=e.models)||void 0===t?void 0:t[0])&&Z(e.models[0])}).catch(()=>{})},[D]),(0,s.useEffect)(()=>{r?H(r):c([])},[r,H]),(0,s.useEffect)(()=>{let e=P.current;e&&(e.scrollTop=e.scrollHeight)},[l,T,_]);let F=(0,s.useCallback)(async()=>{try{let e=await n.hi.post("/api/agent/conversations",{model:p});await D(),i(e.id),c([]),S(null),A(null)}catch(e){q(e instanceof Error?e.message:"Failed to create conversation")}},[p,D]),I=(0,s.useCallback)(async e=>{if(confirm("Delete this conversation?"))try{await n.hi.delete("/api/agent/conversations/".concat(e)),r===e&&i(null),await D()}catch(e){q(e instanceof Error?e.message:"Failed to delete")}},[r,D]),U=(0,s.useCallback)(async()=>{let e=o.trim();if(e&&!u&&r){d(""),q(""),h(!0),c(t=>[...t,{role:"user",content:e}]);try{let t=await n.hi.post("/api/agent/conversations/".concat(r,"/message"),{message:e,model:p||void 0});B(t)}catch(e){q(e instanceof Error?e.message:"Request failed"),c(e=>[...e,{role:"assistant",content:"❌ Request failed. Check the error above."}])}finally{var t;h(!1),null===(t=O.current)||void 0===t||t.focus()}}},[o,u,r,p]),B=(0,s.useCallback)(e=>{if("error"===e.status){q(e.error||"Unknown error"),c(t=>[...t,{role:"assistant",content:"❌ ".concat(e.error||"Unknown error")}]);return}if("needs_input"===e.status&&e.form_schema){S({schema:e.form_schema,calls:e.pending_calls||[]}),c(t=>[...t,{role:"assistant",content:"",transcript:e.transcript}]);return}if("needs_confirm"===e.status&&e.confirm_schema){A({schema:e.confirm_schema,calls:e.pending_calls||[]}),c(t=>[...t,{role:"assistant",content:"",transcript:e.transcript}]);return}c(t=>[...t,{role:"assistant",content:e.message||"(no response)",transcript:e.transcript}])},[]),K=(0,s.useCallback)(async e=>{if(!T||!r)return;h(!0),q("");let t=T.calls;S(null);try{let a=await n.hi.post("/api/agent/conversations/".concat(r,"/continue"),{pending_calls:t,form_data:e});B(a)}catch(e){q(e instanceof Error?e.message:"Failed to submit")}finally{h(!1)}},[T,r,B]),W=(0,s.useCallback)(async()=>{if(!_||!r)return;h(!0),q("");let e=_.calls;A(null);try{let t=await n.hi.post("/api/agent/conversations/".concat(r,"/continue"),{pending_calls:e,confirmed:!0});B(t)}catch(e){q(e instanceof Error?e.message:"Failed to confirm")}finally{h(!1)}},[_,r,B]),G=(0,s.useCallback)(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),U())},[U]);return(0,a.jsxs)("div",{className:"flex h-[calc(100vh-3rem)] -m-6 lg:-m-8",children:[(0,a.jsxs)("aside",{className:"w-64 border-r border-[var(--border)] bg-[var(--surface)] flex flex-col shrink-0",children:[(0,a.jsx)("div",{className:"p-3 border-b border-[var(--border)]",children:(0,a.jsxs)("button",{onClick:F,className:"w-full flex items-center justify-center gap-2 bg-[var(--accent)] hover:opacity-90 text-white text-sm font-medium py-2 rounded-lg",children:[(0,a.jsx)(g.Z,{size:16}),"New conversation"]})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:0===e.length?(0,a.jsxs)("div",{className:"text-center text-xs text-[var(--text-tertiary)] py-8 px-3",children:["No conversations yet.",(0,a.jsx)("br",{}),"Click ",(0,a.jsx)("span",{className:"text-[var(--accent)]",children:"+"})," to start."]}):e.map(e=>(0,a.jsxs)("div",{className:"group flex items-center gap-2 px-2 py-2 rounded-md cursor-pointer text-sm ".concat(r===e.id?"bg-[var(--surface-100)] text-white":"hover:bg-[var(--surface-50)] text-[var(--text-secondary)]"),onClick:()=>i(e.id),children:[(0,a.jsx)(b.Z,{size:14,className:"shrink-0"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"truncate text-xs font-medium",children:e.title}),(0,a.jsxs)("div",{className:"text-[10px] text-[var(--text-tertiary)] truncate",children:[e.model?e.model.split("/").pop():"no model"," \xb7 ",function(e){if(!e)return"";try{let t=new Date(e.replace(" ","T")+(e.includes("Z")?"":"Z")).getTime(),r=Date.now()-t;if(r<6e4)return"just now";if(r<36e5)return Math.floor(r/6e4)+"m ago";if(r<864e5)return Math.floor(r/36e5)+"h ago";return Math.floor(r/864e5)+"d ago"}catch(e){return""}}(e.updated_at)]})]}),(0,a.jsx)("button",{onClick:t=>{t.stopPropagation(),I(e.id)},className:"opacity-0 group-hover:opacity-100 text-[var(--text-tertiary)] hover:text-red-400 p-1","aria-label":"Delete",children:(0,a.jsx)(j.Z,{size:12})})]},e.id))}),(0,a.jsx)("div",{className:"p-3 border-t border-[var(--border)] text-[10px] text-[var(--text-tertiary)]",children:x.length>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"mb-1",children:"Powered by"}),(0,a.jsx)("select",{value:p,onChange:e=>Z(e.target.value),className:"w-full bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1 text-xs",children:x.map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]}):(0,a.jsxs)("div",{className:"text-yellow-400",children:["No active provider keys. Add one in ",(0,a.jsx)("span",{className:"font-mono",children:"Provider Keys"})," to power the agent."]})})]}),(0,a.jsxs)("main",{className:"flex-1 flex flex-col bg-[var(--bg)] min-w-0",children:[(0,a.jsxs)("header",{className:"border-b border-[var(--border)] px-4 py-3 flex items-center gap-3 bg-[var(--surface)]",children:[(0,a.jsx)(k.Z,{size:20,className:"text-[var(--accent)]"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h1",{className:"text-sm font-semibold truncate",children:(null==R?void 0:R.title)||"NexusAgent"}),(0,a.jsxs)("p",{className:"text-[10px] text-[var(--text-tertiary)]",children:["AI agent \xb7 ",p||"no model selected"," \xb7 secrets stay secret"]})]}),r&&(0,a.jsx)("button",{onClick:()=>H(r),className:"text-[var(--text-tertiary)] hover:text-white p-2",title:"Reload conversation",children:(0,a.jsx)(w.Z,{size:14})})]}),(0,a.jsx)("div",{ref:P,className:"flex-1 overflow-y-auto p-4 space-y-4",children:r?0===l.length?(0,a.jsx)("div",{className:"text-center text-sm text-[var(--text-tertiary)] py-12",children:"Send a message to start."}):(0,a.jsxs)(a.Fragment,{children:[l.map((e,t)=>(0,a.jsx)(M,{role:e.role,content:e.content,transcript:e.transcript},t)),T&&(0,a.jsx)(z,{schema:T.schema,onSubmit:K,onCancel:()=>S(null)}),_&&(0,a.jsx)(E,{schema:_.schema,onConfirm:W,onCancel:()=>A(null)}),u&&(0,a.jsxs)("div",{className:"flex gap-3",children:[(0,a.jsx)("div",{className:"w-7 h-7 rounded-lg bg-gradient-to-br from-[var(--accent)] to-nexus-400 flex items-center justify-center shrink-0",children:(0,a.jsx)(y.Z,{size:14,className:"text-white"})}),(0,a.jsxs)("div",{className:"bg-[var(--surface-100)] rounded-2xl px-4 py-2.5 flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[(0,a.jsx)(N,{size:14,className:"animate-spin"}),(0,a.jsx)("span",{children:"Agent is thinking…"})]})]})]}):(0,a.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-center max-w-md mx-auto",children:[(0,a.jsx)("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-[var(--accent)] to-nexus-400 flex items-center justify-center mb-4",children:(0,a.jsx)(k.Z,{size:28,className:"text-white"})}),(0,a.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"NexusAgent"}),(0,a.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-6",children:"An AI agent that can manage your gateway directly. Ask it to add API keys, test models, create aliases, inspect stats — anything."}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 w-full text-left",children:["Add my Gemini key and test it","Show me the slowest models",'Create an alias "fast" → gpt-4o-mini',"Why are my requests failing?"].map(e=>(0,a.jsx)("button",{onClick:()=>{F().then(()=>{d(e)})},className:"text-xs text-left px-3 py-2 rounded-lg border border-[var(--border)] hover:border-[var(--accent)] text-[var(--text-secondary)] hover:text-white",children:e},e))})]})}),L&&(0,a.jsxs)("div",{className:"mx-4 mb-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30 text-xs text-red-300 flex items-start gap-2",children:[(0,a.jsx)(v.Z,{size:14,className:"shrink-0 mt-0.5"}),(0,a.jsx)("span",{className:"flex-1",children:L}),(0,a.jsx)("button",{onClick:()=>q(""),className:"text-red-300/60 hover:text-red-300",children:(0,a.jsx)(m.Z,{size:12})})]}),(0,a.jsxs)("div",{className:"border-t border-[var(--border)] p-4 bg-[var(--surface)]",children:[(0,a.jsxs)("div",{className:"flex items-end gap-2 max-w-4xl mx-auto",children:[(0,a.jsx)("textarea",{ref:O,value:o,onChange:e=>d(e.target.value),onKeyDown:G,placeholder:r?"Tell the agent what to do…":"Click + to start a new conversation",disabled:!r||u,rows:1,className:"flex-1 bg-[var(--bg)] border border-[var(--border)] rounded-xl px-4 py-3 text-sm resize-none focus:outline-none focus:border-[var(--accent)] disabled:opacity-50",style:{minHeight:44,maxHeight:160}}),(0,a.jsx)("button",{onClick:U,disabled:!r||u||!o.trim(),className:"bg-[var(--accent)] hover:opacity-90 text-white p-3 rounded-xl disabled:opacity-30","aria-label":"Send",children:(0,a.jsx)(C.Z,{size:16})})]}),(0,a.jsx)("p",{className:"text-[10px] text-center text-[var(--text-tertiary)] mt-2",children:"Enter to send \xb7 Shift+Enter for newline \xb7 API keys are entered via secure form, never in chat"})]})]})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return i},qz:function(){return n}});let a=r(257).env.NEXT_PUBLIC_API_BASE||"";function s(){return localStorage.getItem("nexus_token")}function n(){localStorage.removeItem("nexus_token")}function i(){return!!s()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",i=s(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===r&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=o.get(e);if(r)return r}let u=(async()=>{let s=await fetch("".concat(a).concat(e),{method:r,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw n(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let l=await s.json();return"GET"!==r||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===r&&!i){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var r;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=a.access_token,localStorage.setItem("nexus_token",r),a},getMe:()=>d("/api/auth/me"),logout:()=>{n(),c.clear(),window.location.href="/login"}},h=async e=>{let t=s(),r=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let n=await r.blob(),i=URL.createObjectURL(n),l=document.createElement("a");l.href=i,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=9763)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/agent/{page-3e623457abaac9ba.js → page-a263a79fd957da1d.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2060],{9763:function(e,t,r){Promise.resolve().then(r.bind(r,5126))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return c}});var a=r(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),n=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,a.forwardRef)((e,t)=>{let{color:r="currentColor",size:s=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:r,strokeWidth:c?24*Number(l)/Number(s):l,className:n("lucide",o),...h},[...u.map(e=>{let[t,r]=e;return(0,a.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let r=(0,a.forwardRef)((r,i)=>{let{className:c,...o}=r;return(0,a.createElement)(l,{ref:i,iconNode:t,className:n("lucide-".concat(s(e)),c),...o})});return r.displayName="".concat(e),r}},2222:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]])},875:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},9322:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},9388:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},2208:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},4001:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]])},3417:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},9397:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7168:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},4743:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},2023:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]])},8930:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},2489:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},257:function(e,t,r){"use strict";var a,s;e.exports=(null==(a=r.g.process)?void 0:a.env)&&"object"==typeof(null==(s=r.g.process)?void 0:s.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,a,s=e.exports={};function n(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:n}catch(e){t=n}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var c=[],o=!1,d=-1;function u(){o&&a&&(o=!1,a.length?c=a.concat(c):d=-1,c.length&&h())}function h(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(a=c,c=[];++d<t;)a&&a[d].run();d=-1,t=c.length}a=null,o=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function x(e,t){this.fun=e,this.array=t}function m(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new x(e,t)),1!==c.length||o||l(h)},x.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},r={};function a(e){var s=r[e];if(void 0!==s)return s.exports;var n=r[e]={exports:{}},i=!0;try{t[e](n,n.exports,a),i=!1}finally{i&&delete r[e]}return n.exports}a.ab="//";var s=a(229);e.exports=s}()},5126:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return T}});var a=r(7437),s=r(2265),n=r(1837),i=r(9205);let l=(0,i.Z)("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var c=r(9388);let o=(0,i.Z)("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);var d=r(875);let u=(0,i.Z)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var h=r(4001);let x=(0,i.Z)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var m=r(2489);let f=(0,i.Z)("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var p=r(2208),v=r(9322),y=r(2222),g=r(9397),b=r(3417),j=r(8930),k=r(2023),w=r(7168);let N=(0,i.Z)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);var C=r(4743);let Z=s.memo(function(e){let{item:t}=e,[r,n]=(0,s.useState)(!1),i="tool_result"===t.type;return(0,a.jsxs)("div",{className:"my-2 rounded-lg border border-[var(--border)] bg-[var(--surface-50)] overflow-hidden",children:[(0,a.jsxs)("button",{onClick:()=>n(e=>!e),className:"w-full flex items-center gap-2 px-3 py-2 text-left text-xs hover:bg-[var(--surface-100)]",children:[i?t.ok?(0,a.jsx)(l,{size:14,className:"text-emerald-400 shrink-0"}):(0,a.jsx)(c.Z,{size:14,className:"text-red-400 shrink-0"}):(0,a.jsx)(o,{size:14,className:"text-blue-400 shrink-0"}),(0,a.jsx)("span",{className:"font-mono text-[var(--text-secondary)]",children:t.name}),(0,a.jsx)("span",{className:"text-[var(--text-tertiary)] truncate flex-1",children:i?t.summary:t.args_display}),r?(0,a.jsx)(d.Z,{size:12}):(0,a.jsx)(u,{size:12})]}),r&&(0,a.jsx)("div",{className:"px-3 py-2 border-t border-[var(--border)] bg-[var(--bg)] text-xs font-mono whitespace-pre-wrap break-all",children:i?t.summary:t.args_display})]})}),z=s.memo(function(e){var t;let{schema:r,onSubmit:n,onCancel:i}=e,[l,c]=(0,s.useState)(!1),[o,d]=(0,s.useState)(()=>{let e={};for(let t of r.fields||[])e[t.name]="";return e}),u=null===(t=r.fields)||void 0===t?void 0:t[0],v=(null==u?void 0:u.type)==="password",y=u&&o[u.name]||"",g=!(null==u?void 0:u.required)||y.length>=(u.minLength||0);return(0,a.jsxs)("div",{className:"my-3 rounded-lg border-2 border-[var(--accent)] bg-[var(--surface)] p-4 shadow-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-lg bg-[var(--accent)]/20 flex items-center justify-center shrink-0",children:v?(0,a.jsx)(h.Z,{size:20,className:"text-[var(--accent)]"}):(0,a.jsx)(x,{size:20,className:"text-[var(--accent)]"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold",children:r.title}),(0,a.jsx)("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:r.description})]}),(0,a.jsx)("button",{onClick:i,className:"text-[var(--text-tertiary)] hover:text-white p-1","aria-label":"Cancel",children:(0,a.jsx)(m.Z,{size:16})})]}),u&&(0,a.jsxs)("div",{className:"mb-3",children:[(0,a.jsxs)("label",{className:"text-xs font-medium text-[var(--text-secondary)] mb-1 block",children:[u.label,u.required&&(0,a.jsx)("span",{className:"text-red-400 ml-1",children:"*"})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{type:v&&!l?"password":"text",value:y,onChange:e=>d(t=>({...t,[u.name]:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&g&&n(o),"Escape"===e.key&&i()},autoFocus:!0,autoComplete:"off",spellCheck:!1,className:"w-full bg-[var(--bg)] border border-[var(--border)] rounded-lg px-3 py-2 pr-10 text-sm font-mono focus:outline-none focus:border-[var(--accent)]",placeholder:"••••••••"}),v&&(0,a.jsx)("button",{type:"button",onClick:()=>c(e=>!e),className:"absolute right-2 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-white p-1","aria-label":l?"Hide":"Show",children:l?(0,a.jsx)(f,{size:14}):(0,a.jsx)(p.Z,{size:14})})]}),v&&(0,a.jsxs)("p",{className:"text-[10px] text-[var(--text-tertiary)] mt-1 flex items-center gap-1",children:[(0,a.jsx)(x,{size:10}),"Sent directly to gateway — never appears in chat history or LLM context"]})]}),(0,a.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,a.jsx)("button",{onClick:i,className:"px-3 py-1.5 text-xs rounded-md border border-[var(--border)] hover:bg-[var(--surface-100)]",children:"Cancel"}),(0,a.jsx)("button",{onClick:()=>n(o),disabled:!g,className:"px-3 py-1.5 text-xs rounded-md bg-[var(--accent)] text-white font-medium disabled:opacity-50 hover:opacity-90",children:r.submit_label||"Submit"})]})]})}),E=s.memo(function(e){let{schema:t,onConfirm:r,onCancel:s}=e;return(0,a.jsxs)("div",{className:"my-3 rounded-lg border-2 border-yellow-500/50 bg-[var(--surface)] p-4 shadow-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center shrink-0",children:(0,a.jsx)(v.Z,{size:20,className:"text-yellow-400"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold",children:t.title}),(0,a.jsx)("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:t.description})]})]}),(0,a.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,a.jsx)("button",{onClick:s,className:"px-3 py-1.5 text-xs rounded-md border border-[var(--border)] hover:bg-[var(--surface-100)]",children:"Cancel"}),(0,a.jsx)("button",{onClick:r,className:"px-3 py-1.5 text-xs rounded-md text-white font-medium hover:opacity-90 ".concat(t.danger?"bg-red-500":"bg-[var(--accent)]"),children:t.confirm_label||"Confirm"})]})]})}),M=s.memo(function(e){let{role:t,content:r,transcript:s}=e,n="user"===t;return(0,a.jsxs)("div",{className:"flex gap-3 ".concat(n?"justify-end":"justify-start"),children:[!n&&(0,a.jsx)("div",{className:"w-7 h-7 rounded-lg bg-gradient-to-br from-[var(--accent)] to-nexus-400 flex items-center justify-center shrink-0",children:(0,a.jsx)(y.Z,{size:14,className:"text-white"})}),(0,a.jsxs)("div",{className:"max-w-[80%] ".concat(n?"order-1":""),children:[s&&s.length>0&&(0,a.jsx)("div",{className:"mb-2",children:s.map((e,t)=>(0,a.jsx)(Z,{item:e},t))}),r&&(0,a.jsx)("div",{className:"rounded-2xl px-4 py-2.5 text-sm leading-relaxed ".concat(n?"bg-[var(--accent)] text-white whitespace-pre-wrap":"bg-[var(--surface-100)] text-[var(--text)] whitespace-pre-wrap"),children:r})]}),n&&(0,a.jsx)("div",{className:"w-7 h-7 rounded-lg bg-[var(--surface-200)] flex items-center justify-center shrink-0 text-xs font-semibold order-2",children:"U"})]})});function T(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(null),[l,c]=(0,s.useState)([]),[o,d]=(0,s.useState)(""),[u,h]=(0,s.useState)(!1),[x,f]=(0,s.useState)([]),[p,Z]=(0,s.useState)(""),[T,S]=(0,s.useState)(null),[_,A]=(0,s.useState)(null),[L,q]=(0,s.useState)(""),P=(0,s.useRef)(null),O=(0,s.useRef)(null),R=(0,s.useMemo)(()=>e.find(e=>e.id===r)||null,[e,r]),D=(0,s.useCallback)(async()=>{try{let e=await n.hi.get("/api/agent/conversations");t(e.conversations||[])}catch(e){console.error(e)}},[]),H=(0,s.useCallback)(async e=>{try{let t=((await n.hi.get("/api/agent/conversations/".concat(e))).messages||[]).map(e=>{let t=[];for(let s of e.tool_calls||[]){var r,a;let e=(null===(r=s.function)||void 0===r?void 0:r.name)||"tool",n={};try{n=JSON.parse((null===(a=s.function)||void 0===a?void 0:a.arguments)||"{}")}catch(e){}t.push({type:"tool_call",name:e,args_display:"".concat(e,"(").concat(Object.entries(n).map(e=>{let[t,r]=e;return"".concat(t,"=").concat(JSON.stringify(r))}).join(", "),")"),tool_call_id:s.id})}return{role:e.role,content:e.content||"",transcript:t.length?t:void 0}});c(t)}catch(e){console.error(e),c([])}},[]);(0,s.useEffect)(()=>{D(),n.hi.get("/api/agent/models").then(e=>{var t;f(e.models||[]),(null===(t=e.models)||void 0===t?void 0:t[0])&&Z(e.models[0])}).catch(()=>{})},[D]),(0,s.useEffect)(()=>{r?H(r):c([])},[r,H]),(0,s.useEffect)(()=>{let e=P.current;e&&(e.scrollTop=e.scrollHeight)},[l,T,_]);let F=(0,s.useCallback)(async()=>{try{let e=await n.hi.post("/api/agent/conversations",{model:p});await D(),i(e.id),c([]),S(null),A(null)}catch(e){q(e instanceof Error?e.message:"Failed to create conversation")}},[p,D]),I=(0,s.useCallback)(async e=>{if(confirm("Delete this conversation?"))try{await n.hi.delete("/api/agent/conversations/".concat(e)),r===e&&i(null),await D()}catch(e){q(e instanceof Error?e.message:"Failed to delete")}},[r,D]),U=(0,s.useCallback)(async()=>{let e=o.trim();if(e&&!u&&r){d(""),q(""),h(!0),c(t=>[...t,{role:"user",content:e}]);try{let t=await n.hi.post("/api/agent/conversations/".concat(r,"/message"),{message:e,model:p||void 0});B(t)}catch(e){q(e instanceof Error?e.message:"Request failed"),c(e=>[...e,{role:"assistant",content:"❌ Request failed. Check the error above."}])}finally{var t;h(!1),null===(t=O.current)||void 0===t||t.focus()}}},[o,u,r,p]),B=(0,s.useCallback)(e=>{if("error"===e.status){q(e.error||"Unknown error"),c(t=>[...t,{role:"assistant",content:"❌ ".concat(e.error||"Unknown error")}]);return}if("needs_input"===e.status&&e.form_schema){S({schema:e.form_schema,calls:e.pending_calls||[]}),c(t=>[...t,{role:"assistant",content:"",transcript:e.transcript}]);return}if("needs_confirm"===e.status&&e.confirm_schema){A({schema:e.confirm_schema,calls:e.pending_calls||[]}),c(t=>[...t,{role:"assistant",content:"",transcript:e.transcript}]);return}c(t=>[...t,{role:"assistant",content:e.message||"(no response)",transcript:e.transcript}])},[]),K=(0,s.useCallback)(async e=>{if(!T||!r)return;h(!0),q("");let t=T.calls;S(null);try{let a=await n.hi.post("/api/agent/conversations/".concat(r,"/continue"),{pending_calls:t,form_data:e});B(a)}catch(e){q(e instanceof Error?e.message:"Failed to submit")}finally{h(!1)}},[T,r,B]),W=(0,s.useCallback)(async()=>{if(!_||!r)return;h(!0),q("");let e=_.calls;A(null);try{let t=await n.hi.post("/api/agent/conversations/".concat(r,"/continue"),{pending_calls:e,confirmed:!0});B(t)}catch(e){q(e instanceof Error?e.message:"Failed to confirm")}finally{h(!1)}},[_,r,B]),G=(0,s.useCallback)(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),U())},[U]);return(0,a.jsxs)("div",{className:"flex h-[calc(100vh-3rem)] -m-6 lg:-m-8",children:[(0,a.jsxs)("aside",{className:"w-64 border-r border-[var(--border)] bg-[var(--surface)] flex flex-col shrink-0",children:[(0,a.jsx)("div",{className:"p-3 border-b border-[var(--border)]",children:(0,a.jsxs)("button",{onClick:F,className:"w-full flex items-center justify-center gap-2 bg-[var(--accent)] hover:opacity-90 text-white text-sm font-medium py-2 rounded-lg",children:[(0,a.jsx)(g.Z,{size:16}),"New conversation"]})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:0===e.length?(0,a.jsxs)("div",{className:"text-center text-xs text-[var(--text-tertiary)] py-8 px-3",children:["No conversations yet.",(0,a.jsx)("br",{}),"Click ",(0,a.jsx)("span",{className:"text-[var(--accent)]",children:"+"})," to start."]}):e.map(e=>(0,a.jsxs)("div",{className:"group flex items-center gap-2 px-2 py-2 rounded-md cursor-pointer text-sm ".concat(r===e.id?"bg-[var(--surface-100)] text-white":"hover:bg-[var(--surface-50)] text-[var(--text-secondary)]"),onClick:()=>i(e.id),children:[(0,a.jsx)(b.Z,{size:14,className:"shrink-0"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"truncate text-xs font-medium",children:e.title}),(0,a.jsxs)("div",{className:"text-[10px] text-[var(--text-tertiary)] truncate",children:[e.model?e.model.split("/").pop():"no model"," \xb7 ",function(e){if(!e)return"";try{let t=new Date(e.replace(" ","T")+(e.includes("Z")?"":"Z")).getTime(),r=Date.now()-t;if(r<6e4)return"just now";if(r<36e5)return Math.floor(r/6e4)+"m ago";if(r<864e5)return Math.floor(r/36e5)+"h ago";return Math.floor(r/864e5)+"d ago"}catch(e){return""}}(e.updated_at)]})]}),(0,a.jsx)("button",{onClick:t=>{t.stopPropagation(),I(e.id)},className:"opacity-0 group-hover:opacity-100 text-[var(--text-tertiary)] hover:text-red-400 p-1","aria-label":"Delete",children:(0,a.jsx)(j.Z,{size:12})})]},e.id))}),(0,a.jsx)("div",{className:"p-3 border-t border-[var(--border)] text-[10px] text-[var(--text-tertiary)]",children:x.length>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"mb-1",children:"Powered by"}),(0,a.jsx)("select",{value:p,onChange:e=>Z(e.target.value),className:"w-full bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1 text-xs",children:x.map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]}):(0,a.jsxs)("div",{className:"text-yellow-400",children:["No active provider keys. Add one in ",(0,a.jsx)("span",{className:"font-mono",children:"Provider Keys"})," to power the agent."]})})]}),(0,a.jsxs)("main",{className:"flex-1 flex flex-col bg-[var(--bg)] min-w-0",children:[(0,a.jsxs)("header",{className:"border-b border-[var(--border)] px-4 py-3 flex items-center gap-3 bg-[var(--surface)]",children:[(0,a.jsx)(k.Z,{size:20,className:"text-[var(--accent)]"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h1",{className:"text-sm font-semibold truncate",children:(null==R?void 0:R.title)||"NexusAgent"}),(0,a.jsxs)("p",{className:"text-[10px] text-[var(--text-tertiary)]",children:["AI agent \xb7 ",p||"no model selected"," \xb7 secrets stay secret"]})]}),r&&(0,a.jsx)("button",{onClick:()=>H(r),className:"text-[var(--text-tertiary)] hover:text-white p-2",title:"Reload conversation",children:(0,a.jsx)(w.Z,{size:14})})]}),(0,a.jsx)("div",{ref:P,className:"flex-1 overflow-y-auto p-4 space-y-4",children:r?0===l.length?(0,a.jsx)("div",{className:"text-center text-sm text-[var(--text-tertiary)] py-12",children:"Send a message to start."}):(0,a.jsxs)(a.Fragment,{children:[l.map((e,t)=>(0,a.jsx)(M,{role:e.role,content:e.content,transcript:e.transcript},t)),T&&(0,a.jsx)(z,{schema:T.schema,onSubmit:K,onCancel:()=>S(null)}),_&&(0,a.jsx)(E,{schema:_.schema,onConfirm:W,onCancel:()=>A(null)}),u&&(0,a.jsxs)("div",{className:"flex gap-3",children:[(0,a.jsx)("div",{className:"w-7 h-7 rounded-lg bg-gradient-to-br from-[var(--accent)] to-nexus-400 flex items-center justify-center shrink-0",children:(0,a.jsx)(y.Z,{size:14,className:"text-white"})}),(0,a.jsxs)("div",{className:"bg-[var(--surface-100)] rounded-2xl px-4 py-2.5 flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[(0,a.jsx)(N,{size:14,className:"animate-spin"}),(0,a.jsx)("span",{children:"Agent is thinking…"})]})]})]}):(0,a.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-center max-w-md mx-auto",children:[(0,a.jsx)("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-[var(--accent)] to-nexus-400 flex items-center justify-center mb-4",children:(0,a.jsx)(k.Z,{size:28,className:"text-white"})}),(0,a.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"NexusAgent"}),(0,a.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-6",children:"An AI agent that can manage your gateway directly. Ask it to add API keys, test models, create aliases, inspect stats — anything."}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 w-full text-left",children:["Add my Gemini key and test it","Show me the slowest models",'Create an alias "fast" → gpt-4o-mini',"Why are my requests failing?"].map(e=>(0,a.jsx)("button",{onClick:()=>{F().then(()=>{d(e)})},className:"text-xs text-left px-3 py-2 rounded-lg border border-[var(--border)] hover:border-[var(--accent)] text-[var(--text-secondary)] hover:text-white",children:e},e))})]})}),L&&(0,a.jsxs)("div",{className:"mx-4 mb-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30 text-xs text-red-300 flex items-start gap-2",children:[(0,a.jsx)(v.Z,{size:14,className:"shrink-0 mt-0.5"}),(0,a.jsx)("span",{className:"flex-1",children:L}),(0,a.jsx)("button",{onClick:()=>q(""),className:"text-red-300/60 hover:text-red-300",children:(0,a.jsx)(m.Z,{size:12})})]}),(0,a.jsxs)("div",{className:"border-t border-[var(--border)] p-4 bg-[var(--surface)]",children:[(0,a.jsxs)("div",{className:"flex items-end gap-2 max-w-4xl mx-auto",children:[(0,a.jsx)("textarea",{ref:O,value:o,onChange:e=>d(e.target.value),onKeyDown:G,placeholder:r?"Tell the agent what to do…":"Click + to start a new conversation",disabled:!r||u,rows:1,className:"flex-1 bg-[var(--bg)] border border-[var(--border)] rounded-xl px-4 py-3 text-sm resize-none focus:outline-none focus:border-[var(--accent)] disabled:opacity-50",style:{minHeight:44,maxHeight:160}}),(0,a.jsx)("button",{onClick:U,disabled:!r||u||!o.trim(),className:"bg-[var(--accent)] hover:opacity-90 text-white p-3 rounded-xl disabled:opacity-30","aria-label":"Send",children:(0,a.jsx)(C.Z,{size:16})})]}),(0,a.jsx)("p",{className:"text-[10px] text-center text-[var(--text-tertiary)] mt-2",children:"Enter to send \xb7 Shift+Enter for newline \xb7 API keys are entered via secure form, never in chat"})]})]})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return i},qz:function(){return n}});let a=r(257).env.NEXT_PUBLIC_API_BASE||"";function s(){return localStorage.getItem("nexus_token")}function n(){localStorage.removeItem("nexus_token")}function i(){return!!s()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",i=s(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===r&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=o.get(e);if(r)return r}let u=(async()=>{let s=await fetch("".concat(a).concat(e),{method:r,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw n(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let l=await s.json();return"GET"!==r||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===r&&!i){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var r;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=a.access_token,localStorage.setItem("nexus_token",r),a},getMe:()=>d("/api/auth/me"),logout:()=>{n(),c.clear(),window.location.href="/login"}},h=async e=>{let t=s(),r=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let n=await r.blob(),i=URL.createObjectURL(n),l=document.createElement("a");l.href=i,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=9763)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2060],{9763:function(e,t,r){Promise.resolve().then(r.bind(r,5126))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return o}});var a=r(2265);let n=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var c={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,a.forwardRef)((e,t)=>{let{color:r="currentColor",size:n=24,strokeWidth:i=2,absoluteStrokeWidth:o,className:l="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...c,width:n,height:n,stroke:r,strokeWidth:o?24*Number(i)/Number(n):i,className:s("lucide",l),...h},[...u.map(e=>{let[t,r]=e;return(0,a.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),o=(e,t)=>{let r=(0,a.forwardRef)((r,c)=>{let{className:o,...l}=r;return(0,a.createElement)(i,{ref:c,iconNode:t,className:s("lucide-".concat(n(e)),o),...l})});return r.displayName="".concat(e),r}},2222:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]])},875:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},9322:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},9388:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},2208:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},4001:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]])},3417:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},9397:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7168:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},4743:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},2023:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]])},8930:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},2489:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},257:function(e,t,r){"use strict";var a,n;e.exports=(null==(a=r.g.process)?void 0:a.env)&&"object"==typeof(null==(n=r.g.process)?void 0:n.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,a,n=e.exports={};function s(){throw Error("setTimeout has not been defined")}function c(){throw Error("clearTimeout has not been defined")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{r="function"==typeof clearTimeout?clearTimeout:c}catch(e){r=c}}();var o=[],l=!1,d=-1;function u(){l&&a&&(l=!1,a.length?o=a.concat(o):d=-1,o.length&&h())}function h(){if(!l){var e=i(u);l=!0;for(var t=o.length;t;){for(a=o,o=[];++d<t;)a&&a[d].run();d=-1,t=o.length}a=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===c||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function x(e,t){this.fun=e,this.array=t}function m(){}n.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];o.push(new x(e,t)),1!==o.length||l||i(h)},x.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=m,n.addListener=m,n.once=m,n.off=m,n.removeListener=m,n.removeAllListeners=m,n.emit=m,n.prependListener=m,n.prependOnceListener=m,n.listeners=function(e){return[]},n.binding=function(e){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw Error("process.chdir is not supported")},n.umask=function(){return 0}}},r={};function a(e){var n=r[e];if(void 0!==n)return n.exports;var s=r[e]={exports:{}},c=!0;try{t[e](s,s.exports,a),c=!1}finally{c&&delete r[e]}return s.exports}a.ab="//";var n=a(229);e.exports=n}()},5126:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return S}});var a=r(7437),n=r(2265),s=r(1837),c=r(9205);let i=(0,c.Z)("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var o=r(9388);let l=(0,c.Z)("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);var d=r(875);let u=(0,c.Z)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var h=r(4001);let x=(0,c.Z)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var m=r(2489);let f=(0,c.Z)("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var p=r(2208),v=r(9322),y=r(2222),g=r(9397),b=r(3417),j=r(8930),k=r(2023),w=r(7168);let N=(0,c.Z)("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);var C=r(4743);let Z=n.memo(function(e){let{item:t}=e,[r,s]=(0,n.useState)(!1),c="tool_result"===t.type;return(0,a.jsxs)("div",{className:"my-2 rounded-lg border border-[var(--border)] bg-[var(--surface-50)] overflow-hidden",children:[(0,a.jsxs)("button",{onClick:()=>s(e=>!e),className:"w-full flex items-center gap-2 px-3 py-2 text-left text-xs hover:bg-[var(--surface-100)]",children:[c?t.ok?(0,a.jsx)(i,{size:14,className:"text-emerald-400 shrink-0"}):(0,a.jsx)(o.Z,{size:14,className:"text-red-400 shrink-0"}):(0,a.jsx)(l,{size:14,className:"text-blue-400 shrink-0"}),(0,a.jsx)("span",{className:"font-mono text-[var(--text-secondary)]",children:t.name}),(0,a.jsx)("span",{className:"text-[var(--text-tertiary)] truncate flex-1",children:c?t.summary:t.args_display}),r?(0,a.jsx)(d.Z,{size:12}):(0,a.jsx)(u,{size:12})]}),r&&(0,a.jsx)("div",{className:"px-3 py-2 border-t border-[var(--border)] bg-[var(--bg)] text-xs font-mono whitespace-pre-wrap break-all",children:c?t.summary:t.args_display})]})}),z=n.memo(function(e){var t;let{schema:r,onSubmit:s,onCancel:c}=e,[i,o]=(0,n.useState)(!1),[l,d]=(0,n.useState)(()=>{let e={};for(let t of r.fields||[])e[t.name]="";return e}),u=null===(t=r.fields)||void 0===t?void 0:t[0],v=(null==u?void 0:u.type)==="password",y=u&&l[u.name]||"",g=!(null==u?void 0:u.required)||y.length>=(u.minLength||0);return(0,a.jsxs)("div",{className:"my-3 rounded-lg border-2 border-[var(--accent)] bg-[var(--surface)] p-4 shadow-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-lg bg-[var(--accent)]/20 flex items-center justify-center shrink-0",children:v?(0,a.jsx)(h.Z,{size:20,className:"text-[var(--accent)]"}):(0,a.jsx)(x,{size:20,className:"text-[var(--accent)]"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold",children:r.title}),(0,a.jsx)("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:r.description})]}),(0,a.jsx)("button",{onClick:c,className:"text-[var(--text-tertiary)] hover:text-white p-1","aria-label":"Cancel",children:(0,a.jsx)(m.Z,{size:16})})]}),u&&(0,a.jsxs)("div",{className:"mb-3",children:[(0,a.jsxs)("label",{className:"text-xs font-medium text-[var(--text-secondary)] mb-1 block",children:[u.label,u.required&&(0,a.jsx)("span",{className:"text-red-400 ml-1",children:"*"})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{type:v&&!i?"password":"text",value:y,onChange:e=>d(t=>({...t,[u.name]:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&g&&s(l),"Escape"===e.key&&c()},autoFocus:!0,autoComplete:"off",spellCheck:!1,className:"w-full bg-[var(--bg)] border border-[var(--border)] rounded-lg px-3 py-2 pr-10 text-sm font-mono focus:outline-none focus:border-[var(--accent)]",placeholder:"••••••••"}),v&&(0,a.jsx)("button",{type:"button",onClick:()=>o(e=>!e),className:"absolute right-2 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-white p-1","aria-label":i?"Hide":"Show",children:i?(0,a.jsx)(f,{size:14}):(0,a.jsx)(p.Z,{size:14})})]}),v&&(0,a.jsxs)("p",{className:"text-[10px] text-[var(--text-tertiary)] mt-1 flex items-center gap-1",children:[(0,a.jsx)(x,{size:10}),"Sent directly to gateway — never appears in chat history or LLM context"]})]}),(0,a.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,a.jsx)("button",{onClick:c,className:"px-3 py-1.5 text-xs rounded-md border border-[var(--border)] hover:bg-[var(--surface-100)]",children:"Cancel"}),(0,a.jsx)("button",{onClick:()=>s(l),disabled:!g,className:"px-3 py-1.5 text-xs rounded-md bg-[var(--accent)] text-white font-medium disabled:opacity-50 hover:opacity-90",children:r.submit_label||"Submit"})]})]})}),E=n.memo(function(e){let{schema:t,onConfirm:r,onCancel:n}=e;return(0,a.jsxs)("div",{className:"my-3 rounded-lg border-2 border-yellow-500/50 bg-[var(--surface)] p-4 shadow-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center shrink-0",children:(0,a.jsx)(v.Z,{size:20,className:"text-yellow-400"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold",children:t.title}),(0,a.jsx)("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:t.description})]})]}),(0,a.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,a.jsx)("button",{onClick:n,className:"px-3 py-1.5 text-xs rounded-md border border-[var(--border)] hover:bg-[var(--surface-100)]",children:"Cancel"}),(0,a.jsx)("button",{onClick:r,className:"px-3 py-1.5 text-xs rounded-md text-white font-medium hover:opacity-90 ".concat(t.danger?"bg-red-500":"bg-[var(--accent)]"),children:t.confirm_label||"Confirm"})]})]})}),M=n.memo(function(e){let{role:t,content:r,transcript:n}=e,s="user"===t;return(0,a.jsxs)("div",{className:"flex gap-3 ".concat(s?"justify-end":"justify-start"),children:[!s&&(0,a.jsx)("div",{className:"w-7 h-7 rounded-lg bg-gradient-to-br from-[var(--accent)] to-nexus-400 flex items-center justify-center shrink-0",children:(0,a.jsx)(y.Z,{size:14,className:"text-white"})}),(0,a.jsxs)("div",{className:"max-w-[80%] ".concat(s?"order-1":""),children:[n&&n.length>0&&(0,a.jsx)("div",{className:"mb-2",children:n.map((e,t)=>(0,a.jsx)(Z,{item:e},t))}),r&&(0,a.jsx)("div",{className:"rounded-2xl px-4 py-2.5 text-sm leading-relaxed ".concat(s?"bg-[var(--accent)] text-white whitespace-pre-wrap":"bg-[var(--surface-100)] text-[var(--text)] whitespace-pre-wrap"),children:r})]}),s&&(0,a.jsx)("div",{className:"w-7 h-7 rounded-lg bg-[var(--surface-200)] flex items-center justify-center shrink-0 text-xs font-semibold order-2",children:"U"})]})});function S(){let[e,t]=(0,n.useState)([]),[r,c]=(0,n.useState)(null),[i,o]=(0,n.useState)([]),[l,d]=(0,n.useState)(""),[u,h]=(0,n.useState)(!1),[x,f]=(0,n.useState)([]),[p,Z]=(0,n.useState)(""),[S,_]=(0,n.useState)(null),[T,A]=(0,n.useState)(null),[L,q]=(0,n.useState)(""),P=(0,n.useRef)(null),R=(0,n.useRef)(null),O=(0,n.useMemo)(()=>e.find(e=>e.id===r)||null,[e,r]),D=(0,n.useCallback)(async()=>{try{let e=await s.hi.get("/api/agent/conversations");t(e.conversations||[])}catch(e){console.error(e)}},[]),H=(0,n.useCallback)(async e=>{try{let t=((await s.hi.get("/api/agent/conversations/".concat(e))).messages||[]).map(e=>{let t=[];for(let n of e.tool_calls||[]){var r,a;let e=(null===(r=n.function)||void 0===r?void 0:r.name)||"tool",s={};try{s=JSON.parse((null===(a=n.function)||void 0===a?void 0:a.arguments)||"{}")}catch(e){}t.push({type:"tool_call",name:e,args_display:"".concat(e,"(").concat(Object.entries(s).map(e=>{let[t,r]=e;return"".concat(t,"=").concat(JSON.stringify(r))}).join(", "),")"),tool_call_id:n.id})}return{role:e.role,content:e.content||"",transcript:t.length?t:void 0}});o(t)}catch(e){console.error(e),o([])}},[]);(0,n.useEffect)(()=>{D(),s.hi.get("/api/agent/models").then(e=>{var t;f(e.models||[]),(null===(t=e.models)||void 0===t?void 0:t[0])&&Z(e.models[0])}).catch(()=>{})},[D]),(0,n.useEffect)(()=>{r?H(r):o([])},[r,H]),(0,n.useEffect)(()=>{let e=P.current;e&&(e.scrollTop=e.scrollHeight)},[i,S,T]);let I=(0,n.useCallback)(async()=>{try{let e=await s.hi.post("/api/agent/conversations",{model:p});await D(),c(e.id),o([]),_(null),A(null)}catch(e){q(e instanceof Error?e.message:"Failed to create conversation")}},[p,D]),U=(0,n.useCallback)(async e=>{if(confirm("Delete this conversation?"))try{await s.hi.delete("/api/agent/conversations/".concat(e)),r===e&&c(null),await D()}catch(e){q(e instanceof Error?e.message:"Failed to delete")}},[r,D]),F=(0,n.useCallback)(async()=>{let e=l.trim();if(e&&!u&&r){d(""),q(""),h(!0),o(t=>[...t,{role:"user",content:e}]);try{let t=await s.hi.post("/api/agent/conversations/".concat(r,"/message"),{message:e,model:p||void 0});B(t)}catch(e){q(e instanceof Error?e.message:"Request failed"),o(e=>[...e,{role:"assistant",content:"❌ Request failed. Check the error above."}])}finally{var t;h(!1),null===(t=R.current)||void 0===t||t.focus()}}},[l,u,r,p]),B=(0,n.useCallback)(e=>{if("error"===e.status){q(e.error||"Unknown error"),o(t=>[...t,{role:"assistant",content:"❌ ".concat(e.error||"Unknown error")}]);return}if("needs_input"===e.status&&e.form_schema){_({schema:e.form_schema,calls:e.pending_calls||[]}),o(t=>[...t,{role:"assistant",content:"",transcript:e.transcript}]);return}if("needs_confirm"===e.status&&e.confirm_schema){A({schema:e.confirm_schema,calls:e.pending_calls||[]}),o(t=>[...t,{role:"assistant",content:"",transcript:e.transcript}]);return}o(t=>[...t,{role:"assistant",content:e.message||"(no response)",transcript:e.transcript}])},[]),K=(0,n.useCallback)(async e=>{if(!S||!r)return;h(!0),q("");let t=S.calls;_(null);try{let a=await s.hi.post("/api/agent/conversations/".concat(r,"/continue"),{pending_calls:t,form_data:e});B(a)}catch(e){q(e instanceof Error?e.message:"Failed to submit")}finally{h(!1)}},[S,r,B]),W=(0,n.useCallback)(async()=>{if(!T||!r)return;h(!0),q("");let e=T.calls;A(null);try{let t=await s.hi.post("/api/agent/conversations/".concat(r,"/continue"),{pending_calls:e,confirmed:!0});B(t)}catch(e){q(e instanceof Error?e.message:"Failed to confirm")}finally{h(!1)}},[T,r,B]),G=(0,n.useCallback)(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),F())},[F]);return(0,a.jsxs)("div",{className:"flex h-[calc(100vh-3rem)] -m-6 lg:-m-8",children:[(0,a.jsxs)("aside",{className:"w-64 border-r border-[var(--border)] bg-[var(--surface)] flex flex-col shrink-0",children:[(0,a.jsx)("div",{className:"p-3 border-b border-[var(--border)]",children:(0,a.jsxs)("button",{onClick:I,className:"w-full flex items-center justify-center gap-2 bg-[var(--accent)] hover:opacity-90 text-white text-sm font-medium py-2 rounded-lg",children:[(0,a.jsx)(g.Z,{size:16}),"New conversation"]})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:0===e.length?(0,a.jsxs)("div",{className:"text-center text-xs text-[var(--text-tertiary)] py-8 px-3",children:["No conversations yet.",(0,a.jsx)("br",{}),"Click ",(0,a.jsx)("span",{className:"text-[var(--accent)]",children:"+"})," to start."]}):e.map(e=>(0,a.jsxs)("div",{className:"group flex items-center gap-2 px-2 py-2 rounded-md cursor-pointer text-sm ".concat(r===e.id?"bg-[var(--surface-100)] text-white":"hover:bg-[var(--surface-50)] text-[var(--text-secondary)]"),onClick:()=>c(e.id),children:[(0,a.jsx)(b.Z,{size:14,className:"shrink-0"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"truncate text-xs font-medium",children:e.title}),(0,a.jsxs)("div",{className:"text-[10px] text-[var(--text-tertiary)] truncate",children:[e.model?e.model.split("/").pop():"no model"," \xb7 ",function(e){if(!e)return"";try{let t=new Date(e.replace(" ","T")+(e.includes("Z")?"":"Z")).getTime(),r=Date.now()-t;if(r<6e4)return"just now";if(r<36e5)return Math.floor(r/6e4)+"m ago";if(r<864e5)return Math.floor(r/36e5)+"h ago";return Math.floor(r/864e5)+"d ago"}catch(e){return""}}(e.updated_at)]})]}),(0,a.jsx)("button",{onClick:t=>{t.stopPropagation(),U(e.id)},className:"opacity-0 group-hover:opacity-100 text-[var(--text-tertiary)] hover:text-red-400 p-1","aria-label":"Delete",children:(0,a.jsx)(j.Z,{size:12})})]},e.id))}),(0,a.jsx)("div",{className:"p-3 border-t border-[var(--border)] text-[10px] text-[var(--text-tertiary)]",children:x.length>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"mb-1",children:"Powered by"}),(0,a.jsx)("select",{value:p,onChange:e=>Z(e.target.value),className:"w-full bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1 text-xs",children:x.map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]}):(0,a.jsxs)("div",{className:"text-yellow-400",children:["No active provider keys. Add one in ",(0,a.jsx)("span",{className:"font-mono",children:"Provider Keys"})," to power the agent."]})})]}),(0,a.jsxs)("main",{className:"flex-1 flex flex-col bg-[var(--bg)] min-w-0",children:[(0,a.jsxs)("header",{className:"border-b border-[var(--border)] px-4 py-3 flex items-center gap-3 bg-[var(--surface)]",children:[(0,a.jsx)(k.Z,{size:20,className:"text-[var(--accent)]"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h1",{className:"text-sm font-semibold truncate",children:(null==O?void 0:O.title)||"NexusAgent"}),(0,a.jsxs)("p",{className:"text-[10px] text-[var(--text-tertiary)]",children:["AI agent \xb7 ",p||"no model selected"," \xb7 secrets stay secret"]})]}),r&&(0,a.jsx)("button",{onClick:()=>H(r),className:"text-[var(--text-tertiary)] hover:text-white p-2",title:"Reload conversation",children:(0,a.jsx)(w.Z,{size:14})})]}),(0,a.jsx)("div",{ref:P,className:"flex-1 overflow-y-auto p-4 space-y-4",children:r?0===i.length?(0,a.jsx)("div",{className:"text-center text-sm text-[var(--text-tertiary)] py-12",children:"Send a message to start."}):(0,a.jsxs)(a.Fragment,{children:[i.map((e,t)=>(0,a.jsx)(M,{role:e.role,content:e.content,transcript:e.transcript},t)),S&&(0,a.jsx)(z,{schema:S.schema,onSubmit:K,onCancel:()=>_(null)}),T&&(0,a.jsx)(E,{schema:T.schema,onConfirm:W,onCancel:()=>A(null)}),u&&(0,a.jsxs)("div",{className:"flex gap-3",children:[(0,a.jsx)("div",{className:"w-7 h-7 rounded-lg bg-gradient-to-br from-[var(--accent)] to-nexus-400 flex items-center justify-center shrink-0",children:(0,a.jsx)(y.Z,{size:14,className:"text-white"})}),(0,a.jsxs)("div",{className:"bg-[var(--surface-100)] rounded-2xl px-4 py-2.5 flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[(0,a.jsx)(N,{size:14,className:"animate-spin"}),(0,a.jsx)("span",{children:"Agent is thinking…"})]})]})]}):(0,a.jsxs)("div",{className:"h-full flex flex-col items-center justify-center text-center max-w-md mx-auto",children:[(0,a.jsx)("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-[var(--accent)] to-nexus-400 flex items-center justify-center mb-4",children:(0,a.jsx)(k.Z,{size:28,className:"text-white"})}),(0,a.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"NexusAgent"}),(0,a.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-6",children:"An AI agent that can manage your gateway directly. Ask it to add API keys, test models, create aliases, inspect stats — anything."}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 w-full text-left",children:["Add my Gemini key and test it","Show me the slowest models",'Create an alias "fast" → gpt-4o-mini',"Why are my requests failing?"].map(e=>(0,a.jsx)("button",{onClick:()=>{I().then(()=>{d(e)})},className:"text-xs text-left px-3 py-2 rounded-lg border border-[var(--border)] hover:border-[var(--accent)] text-[var(--text-secondary)] hover:text-white",children:e},e))})]})}),L&&(0,a.jsxs)("div",{className:"mx-4 mb-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30 text-xs text-red-300 flex items-start gap-2",children:[(0,a.jsx)(v.Z,{size:14,className:"shrink-0 mt-0.5"}),(0,a.jsx)("span",{className:"flex-1",children:L}),(0,a.jsx)("button",{onClick:()=>q(""),className:"text-red-300/60 hover:text-red-300",children:(0,a.jsx)(m.Z,{size:12})})]}),(0,a.jsxs)("div",{className:"border-t border-[var(--border)] p-4 bg-[var(--surface)]",children:[(0,a.jsxs)("div",{className:"flex items-end gap-2 max-w-4xl mx-auto",children:[(0,a.jsx)("textarea",{ref:R,value:l,onChange:e=>d(e.target.value),onKeyDown:G,placeholder:r?"Tell the agent what to do…":"Click + to start a new conversation",disabled:!r||u,rows:1,className:"flex-1 bg-[var(--bg)] border border-[var(--border)] rounded-xl px-4 py-3 text-sm resize-none focus:outline-none focus:border-[var(--accent)] disabled:opacity-50",style:{minHeight:44,maxHeight:160}}),(0,a.jsx)("button",{onClick:F,disabled:!r||u||!l.trim(),className:"bg-[var(--accent)] hover:opacity-90 text-white p-3 rounded-xl disabled:opacity-30","aria-label":"Send",children:(0,a.jsx)(C.Z,{size:16})})]}),(0,a.jsx)("p",{className:"text-[10px] text-center text-[var(--text-tertiary)] mt-2",children:"Enter to send \xb7 Shift+Enter for newline \xb7 API keys are entered via secure form, never in chat"})]})]})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return c},qz:function(){return s}});let a=r(257).env.NEXT_PUBLIC_API_BASE||"";function n(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function s(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function c(){return!!n()}let i={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,l=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",c=n(),d={"Content-Type":"application/json",...t.headers};if(c&&(d.Authorization="Bearer ".concat(c)),"GET"===r&&!c){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in i)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return i[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=l.get(e);if(r)return r}let u=(async()=>{let n=await fetch("".concat(a).concat(e),{method:r,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return n;if(401===n.status&&c&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!n.ok)throw Error((await n.json().catch(()=>({detail:n.statusText}))).detail||"HTTP ".concat(n.status));if(204===n.status)return;let i=await n.json();return"GET"!==r||c||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,i),i})();if("GET"===r&&!c){l.set(e,u);try{return await u}finally{l.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var r;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=a.access_token,localStorage.setItem("nexus_token",r),function(e,t,r){try{let r="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(r)}catch(e){}}("nexus_token",r,0),a},getMe:()=>d("/api/auth/me"),logout:()=>{s(),o.clear(),window.location.href="/login"}},h=async e=>{let t=n(),r=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let s=await r.blob(),c=URL.createObjectURL(s),i=document.createElement("a");i.href=c,i.download=e.split("/").pop()||"export.csv",i.click(),URL.revokeObjectURL(c)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=9763)}),_N_E=e.O()}]);
static/_next/static/chunks/app/aliases/{page-4c00397d46a1ecfd.js → page-41cd8bb4b05195fc.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5781],{1718:function(e,t,a){Promise.resolve().then(a.bind(a,947))},9205:function(e,t,a){"use strict";a.d(t,{Z:function(){return o}});var r=a(2265);let l=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&a.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let n=(0,r.forwardRef)((e,t)=>{let{color:a="currentColor",size:l=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:c="",children:d,iconNode:u,...h}=e;return(0,r.createElement)("svg",{ref:t,...s,width:l,height:l,stroke:a,strokeWidth:o?24*Number(n)/Number(l):n,className:i("lucide",c),...h},[...u.map(e=>{let[t,a]=e;return(0,r.createElement)(t,a)}),...Array.isArray(d)?d:[d]])}),o=(e,t)=>{let a=(0,r.forwardRef)((a,s)=>{let{className:o,...c}=a;return(0,r.createElement)(n,{ref:s,iconNode:t,className:i("lucide-".concat(l(e)),o),...c})});return a.displayName="".concat(e),a}},9397:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},3247:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},8930:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,a){"use strict";var r,l;e.exports=(null==(r=a.g.process)?void 0:r.env)&&"object"==typeof(null==(l=a.g.process)?void 0:l.env)?a.g.process:a(4227)},4227:function(e){!function(){var t={229:function(e){var t,a,r,l=e.exports={};function i(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function n(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{a="function"==typeof clearTimeout?clearTimeout:s}catch(e){a=s}}();var o=[],c=!1,d=-1;function u(){c&&r&&(c=!1,r.length?o=r.concat(o):d=-1,o.length&&h())}function h(){if(!c){var e=n(u);c=!0;for(var t=o.length;t;){for(r=o,o=[];++d<t;)r&&r[d].run();d=-1,t=o.length}r=null,c=!1,function(e){if(a===clearTimeout)return clearTimeout(e);if((a===s||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function m(){}l.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)t[a-1]=arguments[a];o.push(new p(e,t)),1!==o.length||c||n(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},l.title="browser",l.browser=!0,l.env={},l.argv=[],l.version="",l.versions={},l.on=m,l.addListener=m,l.once=m,l.off=m,l.removeListener=m,l.removeAllListeners=m,l.emit=m,l.prependListener=m,l.prependOnceListener=m,l.listeners=function(e){return[]},l.binding=function(e){throw Error("process.binding is not supported")},l.cwd=function(){return"/"},l.chdir=function(e){throw Error("process.chdir is not supported")},l.umask=function(){return 0}}},a={};function r(e){var l=a[e];if(void 0!==l)return l.exports;var i=a[e]={exports:{}},s=!0;try{t[e](i,i.exports,r),s=!1}finally{s&&delete a[e]}return i.exports}r.ab="//";var l=r(229);e.exports=l}()},947:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return u}});var r=a(7437),l=a(2265),i=a(1837),s=a(3247),n=a(9397);let o=(0,a(9205).Z)("Shuffle",[["path",{d:"M2 18h1.4c1.3 0 2.5-.6 3.3-1.7l6.1-8.6c.7-1.1 2-1.7 3.3-1.7H22",key:"1wmou1"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 6h1.9c1.5 0 2.9.9 3.6 2.2",key:"10bdb2"}],["path",{d:"M22 18h-5.9c-1.3 0-2.6-.7-3.3-1.8l-.5-.8",key:"vgxac0"}],["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}]]);var c=a(8930);let d={alias:"",provider:"",provider_model:"",description:"",max_tokens_override:"",prompt_template_id:"",fallback_provider:"",fallback_model:""};function u(){let[e,t]=(0,l.useState)([]),[a,u]=(0,l.useState)([]),[h,p]=(0,l.useState)(!0),[m,x]=(0,l.useState)(!1),[v,f]=(0,l.useState)(d),[g,j]=(0,l.useState)(""),[b,y]=(0,l.useState)(""),k=()=>{p(!0),i.hi.get("/api/models/aliases").then(t).finally(()=>p(!1))},N=()=>{i.hi.get("/api/providers").then(e=>{Array.isArray(e)?u(e):u(Object.keys(e).map(e=>({name:e})))}).catch(()=>u([]))};(0,l.useEffect)(()=>{k(),N()},[]);let _=async()=>{if(v.alias&&v.provider&&v.provider_model)try{let e={alias:v.alias,provider:v.provider,provider_model:v.provider_model};v.description&&(e.description=v.description),v.max_tokens_override&&(e.max_tokens_override=Number(v.max_tokens_override)),v.prompt_template_id&&(e.prompt_template_id=Number(v.prompt_template_id)),v.fallback_provider&&(e.fallback_provider=v.fallback_provider),v.fallback_model&&(e.fallback_model=v.fallback_model),await i.hi.post("/api/models/aliases",e),x(!1),f(d),k(),y("Alias created")}catch(e){y(e instanceof Error?e.message:"Failed to create alias")}},w=async e=>{await i.hi.patch("/api/models/aliases/".concat(e,"/toggle")),k()},T=async e=>{confirm("Delete this alias?")&&(await i.hi.delete("/api/models/aliases/".concat(e)),k(),y("Alias deleted"))};l.useEffect(()=>{if(b){let e=setTimeout(()=>y(""),3e3);return()=>clearTimeout(e)}},[b]);let C=e.filter(e=>!g||e.alias.toLowerCase().includes(g.toLowerCase())||e.provider.toLowerCase().includes(g.toLowerCase())||e.provider_model.toLowerCase().includes(g.toLowerCase()));return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Model Aliases"}),(0,r.jsx)("p",{className:"page-sub",children:"Manage friendly names for provider models"})]}),(0,r.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(s.Z,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),(0,r.jsx)("input",{className:"input pl-8 max-w-xs",placeholder:"Search aliases...",value:g,onChange:e=>j(e.target.value)})]}),(0,r.jsxs)("button",{className:"btn-primary",onClick:()=>{x(!0),f(d)},children:[(0,r.jsx)(n.Z,{size:16})," New Alias"]})]})]}),m&&(0,r.jsx)("div",{className:"modal-overlay",onClick:()=>x(!1),children:(0,r.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Create Model Alias"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Alias *"}),(0,r.jsx)("input",{className:"input",value:v.alias,onChange:e=>f(t=>({...t,alias:e.target.value})),placeholder:"my-model",autoFocus:!0})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Provider *"}),(0,r.jsxs)("select",{className:"select",value:v.provider,onChange:e=>f(t=>({...t,provider:e.target.value})),children:[(0,r.jsx)("option",{value:"",children:"Select provider"}),a.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Provider Model *"}),(0,r.jsx)("input",{className:"input",value:v.provider_model,onChange:e=>f(t=>({...t,provider_model:e.target.value})),placeholder:"gpt-4o"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Description"}),(0,r.jsx)("input",{className:"input",value:v.description,onChange:e=>f(t=>({...t,description:e.target.value})),placeholder:"Optional description"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Max Tokens Override"}),(0,r.jsx)("input",{className:"input",type:"number",value:v.max_tokens_override,onChange:e=>f(t=>({...t,max_tokens_override:e.target.value})),placeholder:"e.g. 4096"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Prompt Template ID"}),(0,r.jsx)("input",{className:"input",type:"number",value:v.prompt_template_id,onChange:e=>f(t=>({...t,prompt_template_id:e.target.value})),placeholder:"Optional ID"})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Fallback Provider"}),(0,r.jsxs)("select",{className:"select",value:v.fallback_provider,onChange:e=>f(t=>({...t,fallback_provider:e.target.value})),children:[(0,r.jsx)("option",{value:"",children:"None"}),a.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Fallback Model"}),(0,r.jsx)("input",{className:"input",value:v.fallback_model,onChange:e=>f(t=>({...t,fallback_model:e.target.value})),placeholder:"e.g. gpt-3.5-turbo"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:_,children:"Create"}),(0,r.jsx)("button",{className:"btn-ghost",onClick:()=>x(!1),children:"Cancel"})]})]})]})}),h?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-32 w-full"})}):0===C.length?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(o,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:g?"No aliases match your search.":"No aliases yet. Create one to get started."})]}):(0,r.jsxs)("div",{className:"card p-0",children:[(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Alias"}),(0,r.jsx)("th",{children:"Provider"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Max Tokens"}),(0,r.jsx)("th",{children:"Fallback"}),(0,r.jsx)("th",{children:"Auto"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:C.map(e=>{var t;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"font-medium max-w-[160px] truncate",title:e.alias,children:e.alias}),(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"capitalize",children:e.provider})}),(0,r.jsx)("td",{className:"max-w-[200px] truncate text-xs font-mono text-[var(--text-tertiary)]",title:e.provider_model,children:e.provider_model}),(0,r.jsx)("td",{className:"text-xs",children:(null===(t=e.max_tokens_override)||void 0===t?void 0:t.toLocaleString())||"-"}),(0,r.jsx)("td",{className:"text-xs",children:e.fallback_provider&&e.fallback_model?"".concat(e.fallback_provider,"/").concat(e.fallback_model):"-"}),(0,r.jsx)("td",{children:e.auto_select?(0,r.jsx)("span",{className:"badge-green text-xs",children:"auto"}):(0,r.jsx)("span",{className:"text-[var(--text-tertiary)] text-xs",children:"-"})}),(0,r.jsx)("td",{children:(0,r.jsx)("button",{onClick:()=>w(e.id),className:e.is_active?"badge-green cursor-pointer":"badge-red cursor-pointer",children:e.is_active?"Active":"Disabled"})}),(0,r.jsx)("td",{className:"text-right",children:(0,r.jsx)("button",{onClick:()=>T(e.id),className:"btn-danger btn-xs",children:(0,r.jsx)(c.Z,{size:14})})})]},e.id)})})]})}),(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-[var(--border)] text-xs text-[var(--text-tertiary)] text-right",children:[C.length," alias",1!==C.length?"es":""]})]}),b&&(0,r.jsx)("div",{className:"toast",children:b})]})}},1837:function(e,t,a){"use strict";a.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return s},qz:function(){return i}});let r=a(257).env.NEXT_PUBLIC_API_BASE||"";function l(){return localStorage.getItem("nexus_token")}function i(){localStorage.removeItem("nexus_token")}function s(){return!!l()}let n={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,c=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.method||"GET",s=l(),d={"Content-Type":"application/json",...t.headers};if(s&&(d.Authorization="Bearer ".concat(s)),"GET"===a&&!s){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in n)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return n[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let a=c.get(e);if(a)return a}let u=(async()=>{let l=await fetch("".concat(r).concat(e),{method:a,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return l;if(401===l.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!l.ok)throw Error((await l.json().catch(()=>({detail:l.statusText}))).detail||"HTTP ".concat(l.status));if(204===l.status)return;let n=await l.json();return"GET"!==a||s||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,n),n})();if("GET"===a&&!s){c.set(e,u);try{return await u}finally{c.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var a;let r=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return a=r.access_token,localStorage.setItem("nexus_token",a),r},getMe:()=>d("/api/auth/me"),logout:()=>{i(),o.clear(),window.location.href="/login"}},h=async e=>{let t=l(),a=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!a.ok)throw Error("Failed to download");let i=await a.blob(),s=URL.createObjectURL(i),n=document.createElement("a");n.href=s,n.download=e.split("/").pop()||"export.csv",n.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=1718)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5781],{1718:function(e,t,a){Promise.resolve().then(a.bind(a,947))},9205:function(e,t,a){"use strict";a.d(t,{Z:function(){return o}});var r=a(2265);let n=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),l=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&a.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let s=(0,r.forwardRef)((e,t)=>{let{color:a="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:c="",children:d,iconNode:u,...h}=e;return(0,r.createElement)("svg",{ref:t,...i,width:n,height:n,stroke:a,strokeWidth:o?24*Number(s)/Number(n):s,className:l("lucide",c),...h},[...u.map(e=>{let[t,a]=e;return(0,r.createElement)(t,a)}),...Array.isArray(d)?d:[d]])}),o=(e,t)=>{let a=(0,r.forwardRef)((a,i)=>{let{className:o,...c}=a;return(0,r.createElement)(s,{ref:i,iconNode:t,className:l("lucide-".concat(n(e)),o),...c})});return a.displayName="".concat(e),a}},9397:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},3247:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},8930:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,a){"use strict";var r,n;e.exports=(null==(r=a.g.process)?void 0:r.env)&&"object"==typeof(null==(n=a.g.process)?void 0:n.env)?a.g.process:a(4227)},4227:function(e){!function(){var t={229:function(e){var t,a,r,n=e.exports={};function l(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===l||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:l}catch(e){t=l}try{a="function"==typeof clearTimeout?clearTimeout:i}catch(e){a=i}}();var o=[],c=!1,d=-1;function u(){c&&r&&(c=!1,r.length?o=r.concat(o):d=-1,o.length&&h())}function h(){if(!c){var e=s(u);c=!0;for(var t=o.length;t;){for(r=o,o=[];++d<t;)r&&r[d].run();d=-1,t=o.length}r=null,c=!1,function(e){if(a===clearTimeout)return clearTimeout(e);if((a===i||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function m(){}n.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)t[a-1]=arguments[a];o.push(new p(e,t)),1!==o.length||c||s(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=m,n.addListener=m,n.once=m,n.off=m,n.removeListener=m,n.removeAllListeners=m,n.emit=m,n.prependListener=m,n.prependOnceListener=m,n.listeners=function(e){return[]},n.binding=function(e){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw Error("process.chdir is not supported")},n.umask=function(){return 0}}},a={};function r(e){var n=a[e];if(void 0!==n)return n.exports;var l=a[e]={exports:{}},i=!0;try{t[e](l,l.exports,r),i=!1}finally{i&&delete a[e]}return l.exports}r.ab="//";var n=r(229);e.exports=n}()},947:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return u}});var r=a(7437),n=a(2265),l=a(1837),i=a(3247),s=a(9397);let o=(0,a(9205).Z)("Shuffle",[["path",{d:"M2 18h1.4c1.3 0 2.5-.6 3.3-1.7l6.1-8.6c.7-1.1 2-1.7 3.3-1.7H22",key:"1wmou1"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 6h1.9c1.5 0 2.9.9 3.6 2.2",key:"10bdb2"}],["path",{d:"M22 18h-5.9c-1.3 0-2.6-.7-3.3-1.8l-.5-.8",key:"vgxac0"}],["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}]]);var c=a(8930);let d={alias:"",provider:"",provider_model:"",description:"",max_tokens_override:"",prompt_template_id:"",fallback_provider:"",fallback_model:""};function u(){let[e,t]=(0,n.useState)([]),[a,u]=(0,n.useState)([]),[h,p]=(0,n.useState)(!0),[m,x]=(0,n.useState)(!1),[v,f]=(0,n.useState)(d),[g,j]=(0,n.useState)(""),[b,y]=(0,n.useState)(""),k=()=>{p(!0),l.hi.get("/api/models/aliases").then(t).finally(()=>p(!1))},_=()=>{l.hi.get("/api/providers").then(e=>{Array.isArray(e)?u(e):u(Object.keys(e).map(e=>({name:e})))}).catch(()=>u([]))};(0,n.useEffect)(()=>{k(),_()},[]);let N=async()=>{if(v.alias&&v.provider&&v.provider_model)try{let e={alias:v.alias,provider:v.provider,provider_model:v.provider_model};v.description&&(e.description=v.description),v.max_tokens_override&&(e.max_tokens_override=Number(v.max_tokens_override)),v.prompt_template_id&&(e.prompt_template_id=Number(v.prompt_template_id)),v.fallback_provider&&(e.fallback_provider=v.fallback_provider),v.fallback_model&&(e.fallback_model=v.fallback_model),await l.hi.post("/api/models/aliases",e),x(!1),f(d),k(),y("Alias created")}catch(e){y(e instanceof Error?e.message:"Failed to create alias")}},w=async e=>{await l.hi.patch("/api/models/aliases/".concat(e,"/toggle")),k()},T=async e=>{confirm("Delete this alias?")&&(await l.hi.delete("/api/models/aliases/".concat(e)),k(),y("Alias deleted"))};n.useEffect(()=>{if(b){let e=setTimeout(()=>y(""),3e3);return()=>clearTimeout(e)}},[b]);let C=e.filter(e=>!g||e.alias.toLowerCase().includes(g.toLowerCase())||e.provider.toLowerCase().includes(g.toLowerCase())||e.provider_model.toLowerCase().includes(g.toLowerCase()));return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Model Aliases"}),(0,r.jsx)("p",{className:"page-sub",children:"Manage friendly names for provider models"})]}),(0,r.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(i.Z,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),(0,r.jsx)("input",{className:"input pl-8 max-w-xs",placeholder:"Search aliases...",value:g,onChange:e=>j(e.target.value)})]}),(0,r.jsxs)("button",{className:"btn-primary",onClick:()=>{x(!0),f(d)},children:[(0,r.jsx)(s.Z,{size:16})," New Alias"]})]})]}),m&&(0,r.jsx)("div",{className:"modal-overlay",onClick:()=>x(!1),children:(0,r.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Create Model Alias"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Alias *"}),(0,r.jsx)("input",{className:"input",value:v.alias,onChange:e=>f(t=>({...t,alias:e.target.value})),placeholder:"my-model",autoFocus:!0})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Provider *"}),(0,r.jsxs)("select",{className:"select",value:v.provider,onChange:e=>f(t=>({...t,provider:e.target.value})),children:[(0,r.jsx)("option",{value:"",children:"Select provider"}),a.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Provider Model *"}),(0,r.jsx)("input",{className:"input",value:v.provider_model,onChange:e=>f(t=>({...t,provider_model:e.target.value})),placeholder:"gpt-4o"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Description"}),(0,r.jsx)("input",{className:"input",value:v.description,onChange:e=>f(t=>({...t,description:e.target.value})),placeholder:"Optional description"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Max Tokens Override"}),(0,r.jsx)("input",{className:"input",type:"number",value:v.max_tokens_override,onChange:e=>f(t=>({...t,max_tokens_override:e.target.value})),placeholder:"e.g. 4096"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Prompt Template ID"}),(0,r.jsx)("input",{className:"input",type:"number",value:v.prompt_template_id,onChange:e=>f(t=>({...t,prompt_template_id:e.target.value})),placeholder:"Optional ID"})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Fallback Provider"}),(0,r.jsxs)("select",{className:"select",value:v.fallback_provider,onChange:e=>f(t=>({...t,fallback_provider:e.target.value})),children:[(0,r.jsx)("option",{value:"",children:"None"}),a.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Fallback Model"}),(0,r.jsx)("input",{className:"input",value:v.fallback_model,onChange:e=>f(t=>({...t,fallback_model:e.target.value})),placeholder:"e.g. gpt-3.5-turbo"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:N,children:"Create"}),(0,r.jsx)("button",{className:"btn-ghost",onClick:()=>x(!1),children:"Cancel"})]})]})]})}),h?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-32 w-full"})}):0===C.length?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(o,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:g?"No aliases match your search.":"No aliases yet. Create one to get started."})]}):(0,r.jsxs)("div",{className:"card p-0",children:[(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Alias"}),(0,r.jsx)("th",{children:"Provider"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Max Tokens"}),(0,r.jsx)("th",{children:"Fallback"}),(0,r.jsx)("th",{children:"Auto"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:C.map(e=>{var t;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"font-medium max-w-[160px] truncate",title:e.alias,children:e.alias}),(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"capitalize",children:e.provider})}),(0,r.jsx)("td",{className:"max-w-[200px] truncate text-xs font-mono text-[var(--text-tertiary)]",title:e.provider_model,children:e.provider_model}),(0,r.jsx)("td",{className:"text-xs",children:(null===(t=e.max_tokens_override)||void 0===t?void 0:t.toLocaleString())||"-"}),(0,r.jsx)("td",{className:"text-xs",children:e.fallback_provider&&e.fallback_model?"".concat(e.fallback_provider,"/").concat(e.fallback_model):"-"}),(0,r.jsx)("td",{children:e.auto_select?(0,r.jsx)("span",{className:"badge-green text-xs",children:"auto"}):(0,r.jsx)("span",{className:"text-[var(--text-tertiary)] text-xs",children:"-"})}),(0,r.jsx)("td",{children:(0,r.jsx)("button",{onClick:()=>w(e.id),className:e.is_active?"badge-green cursor-pointer":"badge-red cursor-pointer",children:e.is_active?"Active":"Disabled"})}),(0,r.jsx)("td",{className:"text-right",children:(0,r.jsx)("button",{onClick:()=>T(e.id),className:"btn-danger btn-xs",children:(0,r.jsx)(c.Z,{size:14})})})]},e.id)})})]})}),(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-[var(--border)] text-xs text-[var(--text-tertiary)] text-right",children:[C.length," alias",1!==C.length?"es":""]})]}),b&&(0,r.jsx)("div",{className:"toast",children:b})]})}},1837:function(e,t,a){"use strict";a.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return i},qz:function(){return l}});let r=a(257).env.NEXT_PUBLIC_API_BASE||"";function n(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function l(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function i(){return!!n()}let s={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,c=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.method||"GET",i=n(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===a&&!i){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in s)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return s[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let a=c.get(e);if(a)return a}let u=(async()=>{let n=await fetch("".concat(r).concat(e),{method:a,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return n;if(401===n.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw l(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!n.ok)throw Error((await n.json().catch(()=>({detail:n.statusText}))).detail||"HTTP ".concat(n.status));if(204===n.status)return;let s=await n.json();return"GET"!==a||i||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,s),s})();if("GET"===a&&!i){c.set(e,u);try{return await u}finally{c.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var a;let r=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return a=r.access_token,localStorage.setItem("nexus_token",a),function(e,t,a){try{let a="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(a)}catch(e){}}("nexus_token",a,0),r},getMe:()=>d("/api/auth/me"),logout:()=>{l(),o.clear(),window.location.href="/login"}},h=async e=>{let t=n(),a=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!a.ok)throw Error("Failed to download");let l=await a.blob(),i=URL.createObjectURL(l),s=document.createElement("a");s.href=i,s.download=e.split("/").pop()||"export.csv",s.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=1718)}),_N_E=e.O()}]);
static/_next/static/chunks/app/aliases/page-d7baa78c5be07b1d.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5781],{1718:function(e,t,a){Promise.resolve().then(a.bind(a,947))},9205:function(e,t,a){"use strict";a.d(t,{Z:function(){return o}});var r=a(2265);let l=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&a.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let n=(0,r.forwardRef)((e,t)=>{let{color:a="currentColor",size:l=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:c="",children:d,iconNode:u,...h}=e;return(0,r.createElement)("svg",{ref:t,...s,width:l,height:l,stroke:a,strokeWidth:o?24*Number(n)/Number(l):n,className:i("lucide",c),...h},[...u.map(e=>{let[t,a]=e;return(0,r.createElement)(t,a)}),...Array.isArray(d)?d:[d]])}),o=(e,t)=>{let a=(0,r.forwardRef)((a,s)=>{let{className:o,...c}=a;return(0,r.createElement)(n,{ref:s,iconNode:t,className:i("lucide-".concat(l(e)),o),...c})});return a.displayName="".concat(e),a}},9397:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},3247:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},8930:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,a){"use strict";var r,l;e.exports=(null==(r=a.g.process)?void 0:r.env)&&"object"==typeof(null==(l=a.g.process)?void 0:l.env)?a.g.process:a(4227)},4227:function(e){!function(){var t={229:function(e){var t,a,r,l=e.exports={};function i(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function n(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{a="function"==typeof clearTimeout?clearTimeout:s}catch(e){a=s}}();var o=[],c=!1,d=-1;function u(){c&&r&&(c=!1,r.length?o=r.concat(o):d=-1,o.length&&h())}function h(){if(!c){var e=n(u);c=!0;for(var t=o.length;t;){for(r=o,o=[];++d<t;)r&&r[d].run();d=-1,t=o.length}r=null,c=!1,function(e){if(a===clearTimeout)return clearTimeout(e);if((a===s||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function m(){}l.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)t[a-1]=arguments[a];o.push(new p(e,t)),1!==o.length||c||n(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},l.title="browser",l.browser=!0,l.env={},l.argv=[],l.version="",l.versions={},l.on=m,l.addListener=m,l.once=m,l.off=m,l.removeListener=m,l.removeAllListeners=m,l.emit=m,l.prependListener=m,l.prependOnceListener=m,l.listeners=function(e){return[]},l.binding=function(e){throw Error("process.binding is not supported")},l.cwd=function(){return"/"},l.chdir=function(e){throw Error("process.chdir is not supported")},l.umask=function(){return 0}}},a={};function r(e){var l=a[e];if(void 0!==l)return l.exports;var i=a[e]={exports:{}},s=!0;try{t[e](i,i.exports,r),s=!1}finally{s&&delete a[e]}return i.exports}r.ab="//";var l=r(229);e.exports=l}()},947:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return u}});var r=a(7437),l=a(2265),i=a(1837),s=a(3247),n=a(9397);let o=(0,a(9205).Z)("Shuffle",[["path",{d:"M2 18h1.4c1.3 0 2.5-.6 3.3-1.7l6.1-8.6c.7-1.1 2-1.7 3.3-1.7H22",key:"1wmou1"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 6h1.9c1.5 0 2.9.9 3.6 2.2",key:"10bdb2"}],["path",{d:"M22 18h-5.9c-1.3 0-2.6-.7-3.3-1.8l-.5-.8",key:"vgxac0"}],["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}]]);var c=a(8930);let d={alias:"",provider:"",provider_model:"",description:"",max_tokens_override:"",prompt_template_id:"",fallback_provider:"",fallback_model:""};function u(){let[e,t]=(0,l.useState)([]),[a,u]=(0,l.useState)([]),[h,p]=(0,l.useState)(!0),[m,x]=(0,l.useState)(!1),[v,f]=(0,l.useState)(d),[g,j]=(0,l.useState)(""),[b,y]=(0,l.useState)(""),k=()=>{p(!0),i.hi.get("/api/models/aliases").then(t).finally(()=>p(!1))},N=()=>{i.hi.get("/api/providers").then(e=>{Array.isArray(e)?u(e):u(Object.keys(e).map(e=>({name:e})))}).catch(()=>u([]))};(0,l.useEffect)(()=>{k(),N()},[]);let _=async()=>{if(v.alias&&v.provider&&v.provider_model)try{let e={alias:v.alias,provider:v.provider,provider_model:v.provider_model};v.description&&(e.description=v.description),v.max_tokens_override&&(e.max_tokens_override=Number(v.max_tokens_override)),v.prompt_template_id&&(e.prompt_template_id=Number(v.prompt_template_id)),v.fallback_provider&&(e.fallback_provider=v.fallback_provider),v.fallback_model&&(e.fallback_model=v.fallback_model),await i.hi.post("/api/models/aliases",e),x(!1),f(d),k(),y("Alias created")}catch(e){y(e instanceof Error?e.message:"Failed to create alias")}},w=async e=>{await i.hi.patch("/api/models/aliases/".concat(e,"/toggle")),k()},T=async e=>{confirm("Delete this alias?")&&(await i.hi.delete("/api/models/aliases/".concat(e)),k(),y("Alias deleted"))};l.useEffect(()=>{if(b){let e=setTimeout(()=>y(""),3e3);return()=>clearTimeout(e)}},[b]);let C=e.filter(e=>!g||e.alias.toLowerCase().includes(g.toLowerCase())||e.provider.toLowerCase().includes(g.toLowerCase())||e.provider_model.toLowerCase().includes(g.toLowerCase()));return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Model Aliases"}),(0,r.jsx)("p",{className:"page-sub",children:"Manage friendly names for provider models"})]}),(0,r.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(s.Z,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),(0,r.jsx)("input",{className:"input pl-8 max-w-xs",placeholder:"Search aliases...",value:g,onChange:e=>j(e.target.value)})]}),(0,r.jsxs)("button",{className:"btn-primary",onClick:()=>{x(!0),f(d)},children:[(0,r.jsx)(n.Z,{size:16})," New Alias"]})]})]}),m&&(0,r.jsx)("div",{className:"modal-overlay",onClick:()=>x(!1),children:(0,r.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Create Model Alias"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Alias *"}),(0,r.jsx)("input",{className:"input",value:v.alias,onChange:e=>f(t=>({...t,alias:e.target.value})),placeholder:"my-model",autoFocus:!0})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Provider *"}),(0,r.jsxs)("select",{className:"select",value:v.provider,onChange:e=>f(t=>({...t,provider:e.target.value})),children:[(0,r.jsx)("option",{value:"",children:"Select provider"}),a.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Provider Model *"}),(0,r.jsx)("input",{className:"input",value:v.provider_model,onChange:e=>f(t=>({...t,provider_model:e.target.value})),placeholder:"gpt-4o"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Description"}),(0,r.jsx)("input",{className:"input",value:v.description,onChange:e=>f(t=>({...t,description:e.target.value})),placeholder:"Optional description"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Max Tokens Override"}),(0,r.jsx)("input",{className:"input",type:"number",value:v.max_tokens_override,onChange:e=>f(t=>({...t,max_tokens_override:e.target.value})),placeholder:"e.g. 4096"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Prompt Template ID"}),(0,r.jsx)("input",{className:"input",type:"number",value:v.prompt_template_id,onChange:e=>f(t=>({...t,prompt_template_id:e.target.value})),placeholder:"Optional ID"})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Fallback Provider"}),(0,r.jsxs)("select",{className:"select",value:v.fallback_provider,onChange:e=>f(t=>({...t,fallback_provider:e.target.value})),children:[(0,r.jsx)("option",{value:"",children:"None"}),a.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Fallback Model"}),(0,r.jsx)("input",{className:"input",value:v.fallback_model,onChange:e=>f(t=>({...t,fallback_model:e.target.value})),placeholder:"e.g. gpt-3.5-turbo"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:_,children:"Create"}),(0,r.jsx)("button",{className:"btn-ghost",onClick:()=>x(!1),children:"Cancel"})]})]})]})}),h?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-32 w-full"})}):0===C.length?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(o,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:g?"No aliases match your search.":"No aliases yet. Create one to get started."})]}):(0,r.jsxs)("div",{className:"card p-0",children:[(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Alias"}),(0,r.jsx)("th",{children:"Provider"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Max Tokens"}),(0,r.jsx)("th",{children:"Fallback"}),(0,r.jsx)("th",{children:"Auto"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:C.map(e=>{var t;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"font-medium max-w-[160px] truncate",title:e.alias,children:e.alias}),(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"capitalize",children:e.provider})}),(0,r.jsx)("td",{className:"max-w-[200px] truncate text-xs font-mono text-[var(--text-tertiary)]",title:e.provider_model,children:e.provider_model}),(0,r.jsx)("td",{className:"text-xs",children:(null===(t=e.max_tokens_override)||void 0===t?void 0:t.toLocaleString())||"-"}),(0,r.jsx)("td",{className:"text-xs",children:e.fallback_provider&&e.fallback_model?"".concat(e.fallback_provider,"/").concat(e.fallback_model):"-"}),(0,r.jsx)("td",{children:e.auto_select?(0,r.jsx)("span",{className:"badge-green text-xs",children:"auto"}):(0,r.jsx)("span",{className:"text-[var(--text-tertiary)] text-xs",children:"-"})}),(0,r.jsx)("td",{children:(0,r.jsx)("button",{onClick:()=>w(e.id),className:e.is_active?"badge-green cursor-pointer":"badge-red cursor-pointer",children:e.is_active?"Active":"Disabled"})}),(0,r.jsx)("td",{className:"text-right",children:(0,r.jsx)("button",{onClick:()=>T(e.id),className:"btn-danger btn-xs",children:(0,r.jsx)(c.Z,{size:14})})})]},e.id)})})]})}),(0,r.jsxs)("div",{className:"px-3 py-2 border-t border-[var(--border)] text-xs text-[var(--text-tertiary)] text-right",children:[C.length," alias",1!==C.length?"es":""]})]}),b&&(0,r.jsx)("div",{className:"toast",children:b})]})}},1837:function(e,t,a){"use strict";a.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return s},qz:function(){return i}});let r=a(257).env.NEXT_PUBLIC_API_BASE||"";function l(){return localStorage.getItem("nexus_token")}function i(){localStorage.removeItem("nexus_token")}function s(){return!!l()}let n={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,c=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.method||"GET",s=l(),d={"Content-Type":"application/json",...t.headers};if(s&&(d.Authorization="Bearer ".concat(s)),"GET"===a&&!s){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in n)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return n[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let a=c.get(e);if(a)return a}let u=(async()=>{let l=await fetch("".concat(r).concat(e),{method:a,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return l;if(401===l.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!l.ok)throw Error((await l.json().catch(()=>({detail:l.statusText}))).detail||"HTTP ".concat(l.status));if(204===l.status)return;let n=await l.json();return"GET"!==a||s||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,n),n})();if("GET"===a&&!s){c.set(e,u);try{return await u}finally{c.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var a;let r=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return a=r.access_token,localStorage.setItem("nexus_token",a),r},getMe:()=>d("/api/auth/me"),logout:()=>{i(),o.clear(),window.location.href="/login"}},h=async e=>{let t=l(),a=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!a.ok)throw Error("Failed to download");let i=await a.blob(),s=URL.createObjectURL(i),n=document.createElement("a");n.href=s,n.download=e.split("/").pop()||"export.csv",n.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=1718)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/analytics/page-06a4c26379b4ee7e.js ADDED
@@ -0,0 +1 @@
 
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4109],{7880:function(e,t,s){Promise.resolve().then(s.bind(s,6351))},9205:function(e,t,s){"use strict";s.d(t,{Z:function(){return l}});var a=s(2265);let r=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),n=function(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return t.filter((e,t,s)=>!!e&&s.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,a.forwardRef)((e,t)=>{let{color:s="currentColor",size:r=24,strokeWidth:c=2,absoluteStrokeWidth:l,className:o="",children:d,iconNode:x,...h}=e;return(0,a.createElement)("svg",{ref:t,...i,width:r,height:r,stroke:s,strokeWidth:l?24*Number(c)/Number(r):c,className:n("lucide",o),...h},[...x.map(e=>{let[t,s]=e;return(0,a.createElement)(t,s)}),...Array.isArray(d)?d:[d]])}),l=(e,t)=>{let s=(0,a.forwardRef)((s,i)=>{let{className:l,...o}=s;return(0,a.createElement)(c,{ref:i,iconNode:t,className:n("lucide-".concat(r(e)),l),...o})});return s.displayName="".concat(e),s}},6215:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});let a=(0,s(9205).Z)("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]])},9322:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});let a=(0,s(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},4001:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});let a=(0,s(9205).Z)("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]])},525:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});let a=(0,s(9205).Z)("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]])},257:function(e,t,s){"use strict";var a,r;e.exports=(null==(a=s.g.process)?void 0:a.env)&&"object"==typeof(null==(r=s.g.process)?void 0:r.env)?s.g.process:s(4227)},4227:function(e){!function(){var t={229:function(e){var t,s,a,r=e.exports={};function n(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(s){try{return t.call(null,e,0)}catch(s){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:n}catch(e){t=n}try{s="function"==typeof clearTimeout?clearTimeout:i}catch(e){s=i}}();var l=[],o=!1,d=-1;function x(){o&&a&&(o=!1,a.length?l=a.concat(l):d=-1,l.length&&h())}function h(){if(!o){var e=c(x);o=!0;for(var t=l.length;t;){for(a=l,l=[];++d<t;)a&&a[d].run();d=-1,t=l.length}a=null,o=!1,function(e){if(s===clearTimeout)return clearTimeout(e);if((s===i||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function u(){}r.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)t[s-1]=arguments[s];l.push(new m(e,t)),1!==l.length||o||c(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=u,r.addListener=u,r.once=u,r.off=u,r.removeListener=u,r.removeAllListeners=u,r.emit=u,r.prependListener=u,r.prependOnceListener=u,r.listeners=function(e){return[]},r.binding=function(e){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw Error("process.chdir is not supported")},r.umask=function(){return 0}}},s={};function a(e){var r=s[e];if(void 0!==r)return r.exports;var n=s[e]={exports:{}},i=!0;try{t[e](n,n.exports,a),i=!1}finally{i&&delete s[e]}return n.exports}a.ab="//";var r=a(229);e.exports=r}()},6351:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return x}});var a=s(7437),r=s(2265),n=s(1837),i=s(9322),c=s(6215);let l=(0,s(9205).Z)("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);var o=s(4001),d=s(525);function x(){let[e,t]=(0,r.useState)(null),[s,x]=(0,r.useState)(null),[h,m]=(0,r.useState)(null),[u,j]=(0,r.useState)([]),[p,f]=(0,r.useState)([]),[v,g]=(0,r.useState)(!0),[N,y]=(0,r.useState)("");return((0,r.useEffect)(()=>{g(!0),Promise.all([n.hi.get("/api/stats/dashboard"),n.hi.get("/api/stats/forecast"),n.hi.get("/api/stats/today").catch(()=>null),n.hi.get("/api/stats/trending-models").catch(()=>[]),n.hi.get("/api/stats/keys").catch(()=>[])]).then(e=>{let[s,a,r,n,i]=e;t(s),x(a),m(r),j(n),f(i)}).catch(e=>y(e instanceof Error?e.message:"Failed to load analytics")).finally(()=>g(!1))},[]),N)?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"page-header",children:[(0,a.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,a.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]}),(0,a.jsxs)("div",{className:"card text-center py-12",children:[(0,a.jsx)(i.Z,{size:32,className:"mx-auto mb-3 text-red-400"}),(0,a.jsx)("p",{className:"text-red-400",children:N})]})]}):v?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"page-header",children:[(0,a.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,a.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]}),(0,a.jsx)("div",{className:"card",children:(0,a.jsx)("div",{className:"skeleton h-64 w-full"})})]}):e?(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"page-header",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,a.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]})}),(0,a.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Total Requests"}),(0,a.jsx)("p",{className:"text-2xl font-semibold",children:e.total_requests.toLocaleString()})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Total Cost"}),(0,a.jsxs)("p",{className:"text-2xl font-semibold",children:["$",e.total_cost.toFixed(2)]})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Today"}),(0,a.jsxs)("p",{className:"text-2xl font-semibold",children:[e.requests_today.toLocaleString()," req / $",e.today_cost.toFixed(2)]})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Avg Latency"}),(0,a.jsxs)("p",{className:"text-2xl font-semibold",children:[e.avg_latency_ms,"ms"]})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Error Rate"}),(0,a.jsxs)("p",{className:"text-2xl font-semibold",children:[e.error_rate.toFixed(1),"%"]})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Active Keys"}),(0,a.jsx)("p",{className:"text-2xl font-semibold",children:e.active_keys})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Cache Hit Rate"}),(0,a.jsxs)("p",{className:"text-2xl font-semibold",children:[e.cache_hit_rate.toFixed(1),"%"]})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Providers"}),(0,a.jsx)("p",{className:"text-2xl font-semibold",children:Object.keys(e.requests_by_provider).length})]})]}),h&&(0,a.jsxs)("div",{className:"card mb-6",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-3",children:"Today"}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Requests"}),(0,a.jsx)("p",{className:"text-xl font-semibold",children:h.requests.toLocaleString()})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Cost"}),(0,a.jsxs)("p",{className:"text-xl font-semibold",children:["$",h.cost.toFixed(4)]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Tokens"}),(0,a.jsx)("p",{className:"text-xl font-semibold",children:h.tokens.toLocaleString()})]})]})]}),u.length>0&&(0,a.jsxs)("div",{className:"card mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,a.jsx)(l,{size:18,className:"text-[var(--accent)]"}),(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Trending Models (7d)"})]}),(0,a.jsx)("div",{className:"table-wrap",children:(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Model"}),(0,a.jsx)("th",{children:"Requests"}),(0,a.jsx)("th",{children:"Avg Latency"}),(0,a.jsx)("th",{children:"Total Cost"})]})}),(0,a.jsx)("tbody",{children:u.map(e=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"font-medium text-sm max-w-[280px] truncate",title:e.model,children:e.model}),(0,a.jsx)("td",{children:e.requests.toLocaleString()}),(0,a.jsxs)("td",{className:"text-xs",children:[Math.round(e.avg_latency),"ms"]}),(0,a.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.total_cost).toFixed(4)]})]},e.model))})]})})]}),p.length>0&&(0,a.jsxs)("div",{className:"card mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,a.jsx)(o.Z,{size:18,className:"text-[var(--accent)]"}),(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Per-Key Statistics"})]}),(0,a.jsx)("div",{className:"table-wrap",children:(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Provider"}),(0,a.jsx)("th",{children:"Name"}),(0,a.jsx)("th",{children:"Requests"}),(0,a.jsx)("th",{children:"Tokens In"}),(0,a.jsx)("th",{children:"Tokens Out"}),(0,a.jsx)("th",{children:"Cost"}),(0,a.jsx)("th",{children:"Budget"}),(0,a.jsx)("th",{children:"Errors"})]})}),(0,a.jsx)("tbody",{children:p.map((e,t)=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{children:(0,a.jsx)("span",{className:"capitalize text-sm",children:e.provider})}),(0,a.jsx)("td",{className:"text-sm",children:e.name}),(0,a.jsx)("td",{children:(e.total_requests||0).toLocaleString()}),(0,a.jsx)("td",{className:"text-xs",children:(e.total_tokens_in||0).toLocaleString()}),(0,a.jsx)("td",{className:"text-xs",children:(e.total_tokens_out||0).toLocaleString()}),(0,a.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.total_cost||0).toFixed(4)]}),(0,a.jsx)("td",{className:"text-xs font-mono",children:e.cost_budget?"$".concat(e.cost_budget):"∞"}),(0,a.jsx)("td",{className:"text-xs",children:e.error_count||0})]},"".concat(e.provider,"-").concat(e.name,"-").concat(t)))})]})})]}),(0,a.jsxs)("div",{className:"card mb-6",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-3",children:"Top Models"}),0===e.top_models.length?(0,a.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:"No model data yet."}):(0,a.jsx)("div",{className:"table-wrap",children:(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Model"}),(0,a.jsx)("th",{children:"Requests"}),(0,a.jsx)("th",{children:"Avg Latency"}),(0,a.jsx)("th",{children:"Cost"}),(0,a.jsx)("th",{children:"Tokens"}),(0,a.jsx)("th",{children:"Error Rate"})]})}),(0,a.jsx)("tbody",{children:e.top_models.map(e=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"font-medium text-sm max-w-[200px] truncate",title:e.model,children:e.model}),(0,a.jsx)("td",{children:e.requests.toLocaleString()}),(0,a.jsxs)("td",{className:"text-xs",children:[e.avg_latency,"ms"]}),(0,a.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.cost).toFixed(4)]}),(0,a.jsx)("td",{className:"text-xs",children:e.tokens.toLocaleString()}),(0,a.jsxs)("td",{className:"text-xs",children:[e.error_rate.toFixed(1),"%"]})]},e.model))})]})})]}),s&&(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,a.jsx)(d.Z,{size:18,className:"text-[var(--accent)]"}),(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Forecast"})]}),s.insufficient_data?(0,a.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:s.message||"Insufficient data for forecast."}):s.forecast?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Next 30 Days Cost"}),(0,a.jsxs)("p",{className:"text-xl font-semibold",children:["$",s.forecast.next_30_days_cost.toFixed(2)]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Daily Avg"}),(0,a.jsxs)("p",{className:"text-xl font-semibold",children:["$",s.forecast.daily_avg.toFixed(2)]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Trend"}),(0,a.jsx)("p",{className:"text-xl font-semibold capitalize",children:s.forecast.trend})]})]}),s.forecast.by_provider.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-medium mb-2",children:"By Provider"}),(0,a.jsx)("div",{className:"table-wrap",children:(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"Provider"}),(0,a.jsx)("th",{children:"Cost"}),(0,a.jsx)("th",{children:"%"})]})}),(0,a.jsx)("tbody",{children:s.forecast.by_provider.map(e=>(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"capitalize",children:e.provider}),(0,a.jsxs)("td",{className:"font-mono text-xs",children:["$",e.cost.toFixed(2)]}),(0,a.jsxs)("td",{className:"text-xs",children:[e.percentage.toFixed(1),"%"]})]},e.provider))})]})})]})]}):(0,a.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:s.message||"No forecast available."})]})]}):(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"page-header",children:[(0,a.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,a.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]}),(0,a.jsxs)("div",{className:"card text-center py-12",children:[(0,a.jsx)(c.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,a.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No analytics data available yet."})]})]})}},1837:function(e,t,s){"use strict";s.d(t,{KF:function(){return h},hi:function(){return x},jl:function(){return i},qz:function(){return n}});let a=s(257).env.NEXT_PUBLIC_API_BASE||"";function r(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function n(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function i(){return!!r()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=t.method||"GET",i=r(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===s&&!i){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let s=o.get(e);if(s)return s}let x=(async()=>{let r=await fetch("".concat(a).concat(e),{method:s,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return r;if(401===r.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw n(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!r.ok)throw Error((await r.json().catch(()=>({detail:r.statusText}))).detail||"HTTP ".concat(r.status));if(204===r.status)return;let c=await r.json();return"GET"!==s||i||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===s&&!i){o.set(e,x);try{return await x}finally{o.delete(e)}}return x}let x={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var s;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return s=a.access_token,localStorage.setItem("nexus_token",s),function(e,t,s){try{let s="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(s)}catch(e){}}("nexus_token",s,0),a},getMe:()=>d("/api/auth/me"),logout:()=>{n(),l.clear(),window.location.href="/login"}},h=async e=>{let t=r(),s=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!s.ok)throw Error("Failed to download");let n=await s.blob(),i=URL.createObjectURL(n),c=document.createElement("a");c.href=i,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=7880)}),_N_E=e.O()}]);
static/_next/static/chunks/app/analytics/page-a799d4a333cef333.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4109],{7880:function(e,t,s){Promise.resolve().then(s.bind(s,6351))},9205:function(e,t,s){"use strict";s.d(t,{Z:function(){return l}});var r=s(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return t.filter((e,t,s)=>!!e&&s.indexOf(e)===t).join(" ")};var n={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,r.forwardRef)((e,t)=>{let{color:s="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:l,className:o="",children:d,iconNode:x,...h}=e;return(0,r.createElement)("svg",{ref:t,...n,width:a,height:a,stroke:s,strokeWidth:l?24*Number(c)/Number(a):c,className:i("lucide",o),...h},[...x.map(e=>{let[t,s]=e;return(0,r.createElement)(t,s)}),...Array.isArray(d)?d:[d]])}),l=(e,t)=>{let s=(0,r.forwardRef)((s,n)=>{let{className:l,...o}=s;return(0,r.createElement)(c,{ref:n,iconNode:t,className:i("lucide-".concat(a(e)),l),...o})});return s.displayName="".concat(e),s}},6215:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});let r=(0,s(9205).Z)("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]])},9322:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});let r=(0,s(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},4001:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});let r=(0,s(9205).Z)("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]])},525:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});let r=(0,s(9205).Z)("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]])},257:function(e,t,s){"use strict";var r,a;e.exports=(null==(r=s.g.process)?void 0:r.env)&&"object"==typeof(null==(a=s.g.process)?void 0:a.env)?s.g.process:s(4227)},4227:function(e){!function(){var t={229:function(e){var t,s,r,a=e.exports={};function i(){throw Error("setTimeout has not been defined")}function n(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(s){try{return t.call(null,e,0)}catch(s){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{s="function"==typeof clearTimeout?clearTimeout:n}catch(e){s=n}}();var l=[],o=!1,d=-1;function x(){o&&r&&(o=!1,r.length?l=r.concat(l):d=-1,l.length&&h())}function h(){if(!o){var e=c(x);o=!0;for(var t=l.length;t;){for(r=l,l=[];++d<t;)r&&r[d].run();d=-1,t=l.length}r=null,o=!1,function(e){if(s===clearTimeout)return clearTimeout(e);if((s===n||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function u(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)t[s-1]=arguments[s];l.push(new m(e,t)),1!==l.length||o||c(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=u,a.addListener=u,a.once=u,a.off=u,a.removeListener=u,a.removeAllListeners=u,a.emit=u,a.prependListener=u,a.prependOnceListener=u,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},s={};function r(e){var a=s[e];if(void 0!==a)return a.exports;var i=s[e]={exports:{}},n=!0;try{t[e](i,i.exports,r),n=!1}finally{n&&delete s[e]}return i.exports}r.ab="//";var a=r(229);e.exports=a}()},6351:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return x}});var r=s(7437),a=s(2265),i=s(1837),n=s(9322),c=s(6215);let l=(0,s(9205).Z)("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);var o=s(4001),d=s(525);function x(){let[e,t]=(0,a.useState)(null),[s,x]=(0,a.useState)(null),[h,m]=(0,a.useState)(null),[u,j]=(0,a.useState)([]),[p,f]=(0,a.useState)([]),[v,N]=(0,a.useState)(!0),[g,y]=(0,a.useState)("");return((0,a.useEffect)(()=>{N(!0),Promise.all([i.hi.get("/api/stats/dashboard"),i.hi.get("/api/stats/forecast"),i.hi.get("/api/stats/today").catch(()=>null),i.hi.get("/api/stats/trending-models").catch(()=>[]),i.hi.get("/api/stats/keys").catch(()=>[])]).then(e=>{let[s,r,a,i,n]=e;t(s),x(r),m(a),j(i),f(n)}).catch(e=>y(e instanceof Error?e.message:"Failed to load analytics")).finally(()=>N(!1))},[]),g)?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,r.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]}),(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(n.Z,{size:32,className:"mx-auto mb-3 text-red-400"}),(0,r.jsx)("p",{className:"text-red-400",children:g})]})]}):v?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,r.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]}),(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-64 w-full"})})]}):e?(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"page-header",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,r.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]})}),(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Total Requests"}),(0,r.jsx)("p",{className:"text-2xl font-semibold",children:e.total_requests.toLocaleString()})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Total Cost"}),(0,r.jsxs)("p",{className:"text-2xl font-semibold",children:["$",e.total_cost.toFixed(2)]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Today"}),(0,r.jsxs)("p",{className:"text-2xl font-semibold",children:[e.requests_today.toLocaleString()," req / $",e.today_cost.toFixed(2)]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Avg Latency"}),(0,r.jsxs)("p",{className:"text-2xl font-semibold",children:[e.avg_latency_ms,"ms"]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Error Rate"}),(0,r.jsxs)("p",{className:"text-2xl font-semibold",children:[e.error_rate.toFixed(1),"%"]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Active Keys"}),(0,r.jsx)("p",{className:"text-2xl font-semibold",children:e.active_keys})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Cache Hit Rate"}),(0,r.jsxs)("p",{className:"text-2xl font-semibold",children:[e.cache_hit_rate.toFixed(1),"%"]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Providers"}),(0,r.jsx)("p",{className:"text-2xl font-semibold",children:Object.keys(e.requests_by_provider).length})]})]}),h&&(0,r.jsxs)("div",{className:"card mb-6",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-3",children:"Today"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Requests"}),(0,r.jsx)("p",{className:"text-xl font-semibold",children:h.requests.toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Cost"}),(0,r.jsxs)("p",{className:"text-xl font-semibold",children:["$",h.cost.toFixed(4)]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Tokens"}),(0,r.jsx)("p",{className:"text-xl font-semibold",children:h.tokens.toLocaleString()})]})]})]}),u.length>0&&(0,r.jsxs)("div",{className:"card mb-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)(l,{size:18,className:"text-[var(--accent)]"}),(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Trending Models (7d)"})]}),(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Requests"}),(0,r.jsx)("th",{children:"Avg Latency"}),(0,r.jsx)("th",{children:"Total Cost"})]})}),(0,r.jsx)("tbody",{children:u.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"font-medium text-sm max-w-[280px] truncate",title:e.model,children:e.model}),(0,r.jsx)("td",{children:e.requests.toLocaleString()}),(0,r.jsxs)("td",{className:"text-xs",children:[Math.round(e.avg_latency),"ms"]}),(0,r.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.total_cost).toFixed(4)]})]},e.model))})]})})]}),p.length>0&&(0,r.jsxs)("div",{className:"card mb-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)(o.Z,{size:18,className:"text-[var(--accent)]"}),(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Per-Key Statistics"})]}),(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Provider"}),(0,r.jsx)("th",{children:"Name"}),(0,r.jsx)("th",{children:"Requests"}),(0,r.jsx)("th",{children:"Tokens In"}),(0,r.jsx)("th",{children:"Tokens Out"}),(0,r.jsx)("th",{children:"Cost"}),(0,r.jsx)("th",{children:"Budget"}),(0,r.jsx)("th",{children:"Errors"})]})}),(0,r.jsx)("tbody",{children:p.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"capitalize text-sm",children:e.provider})}),(0,r.jsx)("td",{className:"text-sm",children:e.name}),(0,r.jsx)("td",{children:(e.total_requests||0).toLocaleString()}),(0,r.jsx)("td",{className:"text-xs",children:(e.total_tokens_in||0).toLocaleString()}),(0,r.jsx)("td",{className:"text-xs",children:(e.total_tokens_out||0).toLocaleString()}),(0,r.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.total_cost||0).toFixed(4)]}),(0,r.jsx)("td",{className:"text-xs font-mono",children:e.cost_budget?"$".concat(e.cost_budget):"∞"}),(0,r.jsx)("td",{className:"text-xs",children:e.error_count||0})]},"".concat(e.provider,"-").concat(e.name,"-").concat(t)))})]})})]}),(0,r.jsxs)("div",{className:"card mb-6",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-3",children:"Top Models"}),0===e.top_models.length?(0,r.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:"No model data yet."}):(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Requests"}),(0,r.jsx)("th",{children:"Avg Latency"}),(0,r.jsx)("th",{children:"Cost"}),(0,r.jsx)("th",{children:"Tokens"}),(0,r.jsx)("th",{children:"Error Rate"})]})}),(0,r.jsx)("tbody",{children:e.top_models.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"font-medium text-sm max-w-[200px] truncate",title:e.model,children:e.model}),(0,r.jsx)("td",{children:e.requests.toLocaleString()}),(0,r.jsxs)("td",{className:"text-xs",children:[e.avg_latency,"ms"]}),(0,r.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.cost).toFixed(4)]}),(0,r.jsx)("td",{className:"text-xs",children:e.tokens.toLocaleString()}),(0,r.jsxs)("td",{className:"text-xs",children:[e.error_rate.toFixed(1),"%"]})]},e.model))})]})})]}),s&&(0,r.jsxs)("div",{className:"card",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)(d.Z,{size:18,className:"text-[var(--accent)]"}),(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Forecast"})]}),s.insufficient_data?(0,r.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:s.message||"Insufficient data for forecast."}):s.forecast?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Next 30 Days Cost"}),(0,r.jsxs)("p",{className:"text-xl font-semibold",children:["$",s.forecast.next_30_days_cost.toFixed(2)]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Daily Avg"}),(0,r.jsxs)("p",{className:"text-xl font-semibold",children:["$",s.forecast.daily_avg.toFixed(2)]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Trend"}),(0,r.jsx)("p",{className:"text-xl font-semibold capitalize",children:s.forecast.trend})]})]}),s.forecast.by_provider.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-medium mb-2",children:"By Provider"}),(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Provider"}),(0,r.jsx)("th",{children:"Cost"}),(0,r.jsx)("th",{children:"%"})]})}),(0,r.jsx)("tbody",{children:s.forecast.by_provider.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"capitalize",children:e.provider}),(0,r.jsxs)("td",{className:"font-mono text-xs",children:["$",e.cost.toFixed(2)]}),(0,r.jsxs)("td",{className:"text-xs",children:[e.percentage.toFixed(1),"%"]})]},e.provider))})]})})]})]}):(0,r.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:s.message||"No forecast available."})]})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,r.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]}),(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(c.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No analytics data available yet."})]})]})}},1837:function(e,t,s){"use strict";s.d(t,{KF:function(){return h},hi:function(){return x},jl:function(){return n},qz:function(){return i}});let r=s(257).env.NEXT_PUBLIC_API_BASE||"";function a(){return localStorage.getItem("nexus_token")}function i(){localStorage.removeItem("nexus_token")}function n(){return!!a()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=t.method||"GET",n=a(),d={"Content-Type":"application/json",...t.headers};if(n&&(d.Authorization="Bearer ".concat(n)),"GET"===s&&!n){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let s=o.get(e);if(s)return s}let x=(async()=>{let a=await fetch("".concat(r).concat(e),{method:s,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&n&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let c=await a.json();return"GET"!==s||n||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===s&&!n){o.set(e,x);try{return await x}finally{o.delete(e)}}return x}let x={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var s;let r=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return s=r.access_token,localStorage.setItem("nexus_token",s),r},getMe:()=>d("/api/auth/me"),logout:()=>{i(),l.clear(),window.location.href="/login"}},h=async e=>{let t=a(),s=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!s.ok)throw Error("Failed to download");let i=await s.blob(),n=URL.createObjectURL(i),c=document.createElement("a");c.href=n,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(n)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=7880)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/analytics/page-d99b46621eeb72d0.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4109],{7880:function(e,t,s){Promise.resolve().then(s.bind(s,6351))},9205:function(e,t,s){"use strict";s.d(t,{Z:function(){return l}});var r=s(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return t.filter((e,t,s)=>!!e&&s.indexOf(e)===t).join(" ")};var n={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,r.forwardRef)((e,t)=>{let{color:s="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:l,className:o="",children:d,iconNode:x,...h}=e;return(0,r.createElement)("svg",{ref:t,...n,width:a,height:a,stroke:s,strokeWidth:l?24*Number(c)/Number(a):c,className:i("lucide",o),...h},[...x.map(e=>{let[t,s]=e;return(0,r.createElement)(t,s)}),...Array.isArray(d)?d:[d]])}),l=(e,t)=>{let s=(0,r.forwardRef)((s,n)=>{let{className:l,...o}=s;return(0,r.createElement)(c,{ref:n,iconNode:t,className:i("lucide-".concat(a(e)),l),...o})});return s.displayName="".concat(e),s}},6215:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});let r=(0,s(9205).Z)("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]])},9322:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});let r=(0,s(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},4001:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});let r=(0,s(9205).Z)("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]])},525:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});let r=(0,s(9205).Z)("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]])},257:function(e,t,s){"use strict";var r,a;e.exports=(null==(r=s.g.process)?void 0:r.env)&&"object"==typeof(null==(a=s.g.process)?void 0:a.env)?s.g.process:s(4227)},4227:function(e){!function(){var t={229:function(e){var t,s,r,a=e.exports={};function i(){throw Error("setTimeout has not been defined")}function n(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(s){try{return t.call(null,e,0)}catch(s){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{s="function"==typeof clearTimeout?clearTimeout:n}catch(e){s=n}}();var l=[],o=!1,d=-1;function x(){o&&r&&(o=!1,r.length?l=r.concat(l):d=-1,l.length&&h())}function h(){if(!o){var e=c(x);o=!0;for(var t=l.length;t;){for(r=l,l=[];++d<t;)r&&r[d].run();d=-1,t=l.length}r=null,o=!1,function(e){if(s===clearTimeout)return clearTimeout(e);if((s===n||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function u(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)t[s-1]=arguments[s];l.push(new m(e,t)),1!==l.length||o||c(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=u,a.addListener=u,a.once=u,a.off=u,a.removeListener=u,a.removeAllListeners=u,a.emit=u,a.prependListener=u,a.prependOnceListener=u,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},s={};function r(e){var a=s[e];if(void 0!==a)return a.exports;var i=s[e]={exports:{}},n=!0;try{t[e](i,i.exports,r),n=!1}finally{n&&delete s[e]}return i.exports}r.ab="//";var a=r(229);e.exports=a}()},6351:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return x}});var r=s(7437),a=s(2265),i=s(1837),n=s(9322),c=s(6215);let l=(0,s(9205).Z)("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);var o=s(4001),d=s(525);function x(){let[e,t]=(0,a.useState)(null),[s,x]=(0,a.useState)(null),[h,m]=(0,a.useState)(null),[u,j]=(0,a.useState)([]),[p,f]=(0,a.useState)([]),[v,N]=(0,a.useState)(!0),[g,y]=(0,a.useState)("");return((0,a.useEffect)(()=>{N(!0),Promise.all([i.hi.get("/api/stats/dashboard"),i.hi.get("/api/stats/forecast"),i.hi.get("/api/stats/today").catch(()=>null),i.hi.get("/api/stats/trending-models").catch(()=>[]),i.hi.get("/api/stats/keys").catch(()=>[])]).then(e=>{let[s,r,a,i,n]=e;t(s),x(r),m(a),j(i),f(n)}).catch(e=>y(e instanceof Error?e.message:"Failed to load analytics")).finally(()=>N(!1))},[]),g)?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,r.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]}),(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(n.Z,{size:32,className:"mx-auto mb-3 text-red-400"}),(0,r.jsx)("p",{className:"text-red-400",children:g})]})]}):v?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,r.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]}),(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-64 w-full"})})]}):e?(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"page-header",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,r.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]})}),(0,r.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Total Requests"}),(0,r.jsx)("p",{className:"text-2xl font-semibold",children:e.total_requests.toLocaleString()})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Total Cost"}),(0,r.jsxs)("p",{className:"text-2xl font-semibold",children:["$",e.total_cost.toFixed(2)]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Today"}),(0,r.jsxs)("p",{className:"text-2xl font-semibold",children:[e.requests_today.toLocaleString()," req / $",e.today_cost.toFixed(2)]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Avg Latency"}),(0,r.jsxs)("p",{className:"text-2xl font-semibold",children:[e.avg_latency_ms,"ms"]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Error Rate"}),(0,r.jsxs)("p",{className:"text-2xl font-semibold",children:[e.error_rate.toFixed(1),"%"]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Active Keys"}),(0,r.jsx)("p",{className:"text-2xl font-semibold",children:e.active_keys})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Cache Hit Rate"}),(0,r.jsxs)("p",{className:"text-2xl font-semibold",children:[e.cache_hit_rate.toFixed(1),"%"]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Providers"}),(0,r.jsx)("p",{className:"text-2xl font-semibold",children:Object.keys(e.requests_by_provider).length})]})]}),h&&(0,r.jsxs)("div",{className:"card mb-6",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-3",children:"Today"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Requests"}),(0,r.jsx)("p",{className:"text-xl font-semibold",children:h.requests.toLocaleString()})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Cost"}),(0,r.jsxs)("p",{className:"text-xl font-semibold",children:["$",h.cost.toFixed(4)]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Tokens"}),(0,r.jsx)("p",{className:"text-xl font-semibold",children:h.tokens.toLocaleString()})]})]})]}),u.length>0&&(0,r.jsxs)("div",{className:"card mb-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)(l,{size:18,className:"text-[var(--accent)]"}),(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Trending Models (7d)"})]}),(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Requests"}),(0,r.jsx)("th",{children:"Avg Latency"}),(0,r.jsx)("th",{children:"Total Cost"})]})}),(0,r.jsx)("tbody",{children:u.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"font-medium text-sm max-w-[280px] truncate",title:e.model,children:e.model}),(0,r.jsx)("td",{children:e.requests.toLocaleString()}),(0,r.jsxs)("td",{className:"text-xs",children:[Math.round(e.avg_latency),"ms"]}),(0,r.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.total_cost).toFixed(4)]})]},e.model))})]})})]}),p.length>0&&(0,r.jsxs)("div",{className:"card mb-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)(o.Z,{size:18,className:"text-[var(--accent)]"}),(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Per-Key Statistics"})]}),(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Provider"}),(0,r.jsx)("th",{children:"Name"}),(0,r.jsx)("th",{children:"Requests"}),(0,r.jsx)("th",{children:"Tokens In"}),(0,r.jsx)("th",{children:"Tokens Out"}),(0,r.jsx)("th",{children:"Cost"}),(0,r.jsx)("th",{children:"Budget"}),(0,r.jsx)("th",{children:"Errors"})]})}),(0,r.jsx)("tbody",{children:p.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"capitalize text-sm",children:e.provider})}),(0,r.jsx)("td",{className:"text-sm",children:e.name}),(0,r.jsx)("td",{children:(e.total_requests||0).toLocaleString()}),(0,r.jsx)("td",{className:"text-xs",children:(e.total_tokens_in||0).toLocaleString()}),(0,r.jsx)("td",{className:"text-xs",children:(e.total_tokens_out||0).toLocaleString()}),(0,r.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.total_cost||0).toFixed(4)]}),(0,r.jsx)("td",{className:"text-xs font-mono",children:e.cost_budget?"$".concat(e.cost_budget):"∞"}),(0,r.jsx)("td",{className:"text-xs",children:e.error_count||0})]},"".concat(e.provider,"-").concat(e.name,"-").concat(t)))})]})})]}),(0,r.jsxs)("div",{className:"card mb-6",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-3",children:"Top Models"}),0===e.top_models.length?(0,r.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:"No model data yet."}):(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Requests"}),(0,r.jsx)("th",{children:"Avg Latency"}),(0,r.jsx)("th",{children:"Cost"}),(0,r.jsx)("th",{children:"Tokens"}),(0,r.jsx)("th",{children:"Error Rate"})]})}),(0,r.jsx)("tbody",{children:e.top_models.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"font-medium text-sm max-w-[200px] truncate",title:e.model,children:e.model}),(0,r.jsx)("td",{children:e.requests.toLocaleString()}),(0,r.jsxs)("td",{className:"text-xs",children:[e.avg_latency,"ms"]}),(0,r.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.cost).toFixed(4)]}),(0,r.jsx)("td",{className:"text-xs",children:e.tokens.toLocaleString()}),(0,r.jsxs)("td",{className:"text-xs",children:[e.error_rate.toFixed(1),"%"]})]},e.model))})]})})]}),s&&(0,r.jsxs)("div",{className:"card",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)(d.Z,{size:18,className:"text-[var(--accent)]"}),(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Forecast"})]}),s.insufficient_data?(0,r.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:s.message||"Insufficient data for forecast."}):s.forecast?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Next 30 Days Cost"}),(0,r.jsxs)("p",{className:"text-xl font-semibold",children:["$",s.forecast.next_30_days_cost.toFixed(2)]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Daily Avg"}),(0,r.jsxs)("p",{className:"text-xl font-semibold",children:["$",s.forecast.daily_avg.toFixed(2)]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mb-1",children:"Trend"}),(0,r.jsx)("p",{className:"text-xl font-semibold capitalize",children:s.forecast.trend})]})]}),s.forecast.by_provider.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-medium mb-2",children:"By Provider"}),(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Provider"}),(0,r.jsx)("th",{children:"Cost"}),(0,r.jsx)("th",{children:"%"})]})}),(0,r.jsx)("tbody",{children:s.forecast.by_provider.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"capitalize",children:e.provider}),(0,r.jsxs)("td",{className:"font-mono text-xs",children:["$",e.cost.toFixed(2)]}),(0,r.jsxs)("td",{className:"text-xs",children:[e.percentage.toFixed(1),"%"]})]},e.provider))})]})})]})]}):(0,r.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:s.message||"No forecast available."})]})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsx)("h1",{className:"page-title",children:"Analytics"}),(0,r.jsx)("p",{className:"page-sub",children:"Usage statistics and projections"})]}),(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(c.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No analytics data available yet."})]})]})}},1837:function(e,t,s){"use strict";s.d(t,{KF:function(){return h},hi:function(){return x},jl:function(){return n},qz:function(){return i}});let r=s(257).env.NEXT_PUBLIC_API_BASE||"";function a(){return localStorage.getItem("nexus_token")}function i(){localStorage.removeItem("nexus_token")}function n(){return!!a()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=t.method||"GET",n=a(),d={"Content-Type":"application/json",...t.headers};if(n&&(d.Authorization="Bearer ".concat(n)),"GET"===s&&!n){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let s=o.get(e);if(s)return s}let x=(async()=>{let a=await fetch("".concat(r).concat(e),{method:s,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&n&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let c=await a.json();return"GET"!==s||n||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===s&&!n){o.set(e,x);try{return await x}finally{o.delete(e)}}return x}let x={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var s;let r=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return s=r.access_token,localStorage.setItem("nexus_token",s),r},getMe:()=>d("/api/auth/me"),logout:()=>{i(),l.clear(),window.location.href="/login"}},h=async e=>{let t=a(),s=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!s.ok)throw Error("Failed to download");let i=await s.blob(),n=URL.createObjectURL(i),c=document.createElement("a");c.href=n,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(n)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=7880)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/batch-api/page-93e9632550aa7e6c.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5668],{8305:function(e,t,n){Promise.resolve().then(n.bind(n,8273))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var r=n(2265);let i=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:i=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:l="",children:u,iconNode:d,...h}=e;return(0,r.createElement)("svg",{ref:t,...s,width:i,height:i,stroke:n,strokeWidth:o?24*Number(c)/Number(i):c,className:a("lucide",l),...h},[...d.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(u)?u:[u]])}),o=(e,t)=>{let n=(0,r.forwardRef)((n,s)=>{let{className:o,...l}=n;return(0,r.createElement)(c,{ref:s,iconNode:t,className:a("lucide-".concat(i(e)),o),...l})});return n.displayName="".concat(e),n}},1671:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},9388:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},1723:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},8124:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]])},9397:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},257:function(e,t,n){"use strict";var r,i;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(i=n.g.process)?void 0:i.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,i=e.exports={};function a(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var o=[],l=!1,u=-1;function d(){l&&r&&(l=!1,r.length?o=r.concat(o):u=-1,o.length&&h())}function h(){if(!l){var e=c(d);l=!0;for(var t=o.length;t;){for(r=o,o=[];++u<t;)r&&r[u].run();u=-1,t=o.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];o.push(new f(e,t)),1!==o.length||l||c(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw Error("process.chdir is not supported")},i.umask=function(){return 0}}},n={};function r(e){var i=n[e];if(void 0!==i)return i.exports;var a=n[e]={exports:{}},s=!0;try{t[e](a,a.exports,r),s=!1}finally{s&&delete n[e]}return a.exports}r.ab="//";var i=r(229);e.exports=i}()},8273:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return f}});var r=n(7437),i=n(2265),a=n(1837),s=n(1723),c=n(8124),o=n(1671),l=n(9388),u=n(9397);let d={pending:"badge-yellow",running:"badge-blue",completed:"badge-green",failed:"badge-red"},h={pending:(0,r.jsx)(s.Z,{size:12}),running:(0,r.jsx)(c.Z,{size:12}),completed:(0,r.jsx)(o.Z,{size:12}),failed:(0,r.jsx)(l.Z,{size:12})};function f(){let[e,t]=(0,i.useState)([]),[n,s]=(0,i.useState)(!0),[o,l]=(0,i.useState)(null),[f,m]=(0,i.useState)(!1),[p,x]=(0,i.useState)(""),[g,y]=(0,i.useState)("gpt-4o-mini"),[j,b]=(0,i.useState)(!1),v=async()=>{s(!0),l(null);try{let e=await a.hi.get("/api/batch/history");t(e)}catch(e){l(String(e))}finally{s(!1)}};(0,i.useEffect)(()=>{v()},[]);let w=async()=>{if(p.trim()&&g){b(!0);try{await a.hi.post("/api/batch",{jsonl:p,model:g}),m(!1),x(""),v()}catch(e){l(String(e))}finally{b(!1)}}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Batch API"}),(0,r.jsx)("p",{className:"page-sub",children:"Manage batch inference jobs"})]}),(0,r.jsxs)("button",{className:"btn-primary",onClick:()=>m(!0),children:[(0,r.jsx)(u.Z,{size:16})," New Batch"]})]}),f&&(0,r.jsxs)("div",{className:"card mb-6",children:[(0,r.jsx)("h2",{className:"text-sm font-semibold mb-3",children:"Create Batch Job"}),(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Model"}),(0,r.jsx)("input",{className:"input",value:g,onChange:e=>y(e.target.value),placeholder:"gpt-4o-mini"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"JSONL Input"}),(0,r.jsx)("textarea",{className:"input font-mono text-xs !min-h-[200px]",rows:8,value:p,onChange:e=>x(e.target.value),placeholder:'{"custom_id":"1","method":"POST","url":"/v1/chat/completions","body":{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}}'})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-primary",onClick:w,disabled:j||!p.trim()||!g,children:j?"Creating...":"Create Batch"}),(0,r.jsx)("button",{className:"btn-secondary",onClick:()=>{m(!1),x("")},children:"Cancel"})]})]})]}),n&&(0,r.jsxs)("div",{className:"text-center py-16 text-[var(--text-tertiary)]",children:[(0,r.jsx)(c.Z,{size:40,className:"mx-auto mb-4 opacity-40"}),(0,r.jsx)("p",{children:"Loading batch jobs..."})]}),o&&(0,r.jsxs)("div",{className:"card border border-red-500/30",children:[(0,r.jsx)("p",{className:"text-red-400 text-sm",children:o}),(0,r.jsx)("button",{className:"btn-ghost btn-xs mt-2",onClick:v,children:"Retry"})]}),!n&&!o&&0===e.length&&(0,r.jsxs)("div",{className:"text-center py-16 text-[var(--text-tertiary)]",children:[(0,r.jsx)(c.Z,{size:40,className:"mx-auto mb-4 opacity-40"}),(0,r.jsx)("p",{children:"No batch jobs yet"}),(0,r.jsxs)("button",{className:"btn-primary mt-4",onClick:()=>m(!0),children:[(0,r.jsx)(u.Z,{size:16})," Create your first batch"]})]}),!n&&!o&&e.length>0&&(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"ID"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Requests"}),(0,r.jsx)("th",{children:"Completed"}),(0,r.jsx)("th",{children:"Failed"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:"Created"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsxs)("td",{className:"font-mono text-xs",children:[e.id.slice(0,12),"..."]}),(0,r.jsx)("td",{children:e.model}),(0,r.jsx)("td",{children:e.request_count}),(0,r.jsx)("td",{children:e.completed_count}),(0,r.jsx)("td",{children:e.failed_count}),(0,r.jsx)("td",{children:(0,r.jsxs)("span",{className:"badge ".concat(d[e.status]||""),children:[h[e.status]," ",e.status]})}),(0,r.jsx)("td",{className:"text-xs text-[var(--text-secondary)]",children:new Date(e.created_at).toLocaleString()})]},e.id))})]})})})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return s},qz:function(){return a}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function i(){return localStorage.getItem("nexus_token")}function a(){localStorage.removeItem("nexus_token")}function s(){return!!i()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,l=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",s=i(),u={"Content-Type":"application/json",...t.headers};if(s&&(u.Authorization="Bearer ".concat(s)),"GET"===n&&!s){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=l.get(e);if(n)return n}let d=(async()=>{let i=await fetch("".concat(r).concat(e),{method:n,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return i;if(401===i.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw a(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!i.ok)throw Error((await i.json().catch(()=>({detail:i.statusText}))).detail||"HTTP ".concat(i.status));if(204===i.status)return;let c=await i.json();return"GET"!==n||s||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===n&&!s){l.set(e,d);try{return await d}finally{l.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),r},getMe:()=>u("/api/auth/me"),logout:()=>{a(),o.clear(),window.location.href="/login"}},h=async e=>{let t=i(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let a=await n.blob(),s=URL.createObjectURL(a),c=document.createElement("a");c.href=s,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=8305)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/batch-api/{page-77c5fb2136ff3a1a.js → page-efde9eb1301afc84.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5668],{8305:function(e,t,n){Promise.resolve().then(n.bind(n,8273))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var r=n(2265);let i=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:i=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:l="",children:u,iconNode:d,...h}=e;return(0,r.createElement)("svg",{ref:t,...s,width:i,height:i,stroke:n,strokeWidth:o?24*Number(c)/Number(i):c,className:a("lucide",l),...h},[...d.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(u)?u:[u]])}),o=(e,t)=>{let n=(0,r.forwardRef)((n,s)=>{let{className:o,...l}=n;return(0,r.createElement)(c,{ref:s,iconNode:t,className:a("lucide-".concat(i(e)),o),...l})});return n.displayName="".concat(e),n}},1671:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},9388:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},1723:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},8124:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]])},9397:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},257:function(e,t,n){"use strict";var r,i;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(i=n.g.process)?void 0:i.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,i=e.exports={};function a(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var o=[],l=!1,u=-1;function d(){l&&r&&(l=!1,r.length?o=r.concat(o):u=-1,o.length&&h())}function h(){if(!l){var e=c(d);l=!0;for(var t=o.length;t;){for(r=o,o=[];++u<t;)r&&r[u].run();u=-1,t=o.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];o.push(new f(e,t)),1!==o.length||l||c(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw Error("process.chdir is not supported")},i.umask=function(){return 0}}},n={};function r(e){var i=n[e];if(void 0!==i)return i.exports;var a=n[e]={exports:{}},s=!0;try{t[e](a,a.exports,r),s=!1}finally{s&&delete n[e]}return a.exports}r.ab="//";var i=r(229);e.exports=i}()},8273:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return f}});var r=n(7437),i=n(2265),a=n(1837),s=n(1723),c=n(8124),o=n(1671),l=n(9388),u=n(9397);let d={pending:"badge-yellow",running:"badge-blue",completed:"badge-green",failed:"badge-red"},h={pending:(0,r.jsx)(s.Z,{size:12}),running:(0,r.jsx)(c.Z,{size:12}),completed:(0,r.jsx)(o.Z,{size:12}),failed:(0,r.jsx)(l.Z,{size:12})};function f(){let[e,t]=(0,i.useState)([]),[n,s]=(0,i.useState)(!0),[o,l]=(0,i.useState)(null),[f,m]=(0,i.useState)(!1),[p,x]=(0,i.useState)(""),[g,y]=(0,i.useState)("gpt-4o-mini"),[j,b]=(0,i.useState)(!1),v=async()=>{s(!0),l(null);try{let e=await a.hi.get("/api/batch/history");t(e)}catch(e){l(String(e))}finally{s(!1)}};(0,i.useEffect)(()=>{v()},[]);let w=async()=>{if(p.trim()&&g){b(!0);try{await a.hi.post("/api/batch",{jsonl:p,model:g}),m(!1),x(""),v()}catch(e){l(String(e))}finally{b(!1)}}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Batch API"}),(0,r.jsx)("p",{className:"page-sub",children:"Manage batch inference jobs"})]}),(0,r.jsxs)("button",{className:"btn-primary",onClick:()=>m(!0),children:[(0,r.jsx)(u.Z,{size:16})," New Batch"]})]}),f&&(0,r.jsxs)("div",{className:"card mb-6",children:[(0,r.jsx)("h2",{className:"text-sm font-semibold mb-3",children:"Create Batch Job"}),(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Model"}),(0,r.jsx)("input",{className:"input",value:g,onChange:e=>y(e.target.value),placeholder:"gpt-4o-mini"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"JSONL Input"}),(0,r.jsx)("textarea",{className:"input font-mono text-xs !min-h-[200px]",rows:8,value:p,onChange:e=>x(e.target.value),placeholder:'{"custom_id":"1","method":"POST","url":"/v1/chat/completions","body":{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}}'})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-primary",onClick:w,disabled:j||!p.trim()||!g,children:j?"Creating...":"Create Batch"}),(0,r.jsx)("button",{className:"btn-secondary",onClick:()=>{m(!1),x("")},children:"Cancel"})]})]})]}),n&&(0,r.jsxs)("div",{className:"text-center py-16 text-[var(--text-tertiary)]",children:[(0,r.jsx)(c.Z,{size:40,className:"mx-auto mb-4 opacity-40"}),(0,r.jsx)("p",{children:"Loading batch jobs..."})]}),o&&(0,r.jsxs)("div",{className:"card border border-red-500/30",children:[(0,r.jsx)("p",{className:"text-red-400 text-sm",children:o}),(0,r.jsx)("button",{className:"btn-ghost btn-xs mt-2",onClick:v,children:"Retry"})]}),!n&&!o&&0===e.length&&(0,r.jsxs)("div",{className:"text-center py-16 text-[var(--text-tertiary)]",children:[(0,r.jsx)(c.Z,{size:40,className:"mx-auto mb-4 opacity-40"}),(0,r.jsx)("p",{children:"No batch jobs yet"}),(0,r.jsxs)("button",{className:"btn-primary mt-4",onClick:()=>m(!0),children:[(0,r.jsx)(u.Z,{size:16})," Create your first batch"]})]}),!n&&!o&&e.length>0&&(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"ID"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Requests"}),(0,r.jsx)("th",{children:"Completed"}),(0,r.jsx)("th",{children:"Failed"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:"Created"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsxs)("td",{className:"font-mono text-xs",children:[e.id.slice(0,12),"..."]}),(0,r.jsx)("td",{children:e.model}),(0,r.jsx)("td",{children:e.request_count}),(0,r.jsx)("td",{children:e.completed_count}),(0,r.jsx)("td",{children:e.failed_count}),(0,r.jsx)("td",{children:(0,r.jsxs)("span",{className:"badge ".concat(d[e.status]||""),children:[h[e.status]," ",e.status]})}),(0,r.jsx)("td",{className:"text-xs text-[var(--text-secondary)]",children:new Date(e.created_at).toLocaleString()})]},e.id))})]})})})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return s},qz:function(){return a}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function i(){return localStorage.getItem("nexus_token")}function a(){localStorage.removeItem("nexus_token")}function s(){return!!i()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,l=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",s=i(),u={"Content-Type":"application/json",...t.headers};if(s&&(u.Authorization="Bearer ".concat(s)),"GET"===n&&!s){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=l.get(e);if(n)return n}let d=(async()=>{let i=await fetch("".concat(r).concat(e),{method:n,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return i;if(401===i.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw a(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!i.ok)throw Error((await i.json().catch(()=>({detail:i.statusText}))).detail||"HTTP ".concat(i.status));if(204===i.status)return;let c=await i.json();return"GET"!==n||s||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===n&&!s){l.set(e,d);try{return await d}finally{l.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),r},getMe:()=>u("/api/auth/me"),logout:()=>{a(),o.clear(),window.location.href="/login"}},h=async e=>{let t=i(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let a=await n.blob(),s=URL.createObjectURL(a),c=document.createElement("a");c.href=s,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=8305)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5668],{8305:function(e,t,n){Promise.resolve().then(n.bind(n,8273))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var r=n(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:l="",children:u,iconNode:d,...h}=e;return(0,r.createElement)("svg",{ref:t,...s,width:a,height:a,stroke:n,strokeWidth:o?24*Number(c)/Number(a):c,className:i("lucide",l),...h},[...d.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(u)?u:[u]])}),o=(e,t)=>{let n=(0,r.forwardRef)((n,s)=>{let{className:o,...l}=n;return(0,r.createElement)(c,{ref:s,iconNode:t,className:i("lucide-".concat(a(e)),o),...l})});return n.displayName="".concat(e),n}},1671:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},9388:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},1723:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},8124:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]])},9397:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},257:function(e,t,n){"use strict";var r,a;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(a=n.g.process)?void 0:a.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,a=e.exports={};function i(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var o=[],l=!1,u=-1;function d(){l&&r&&(l=!1,r.length?o=r.concat(o):u=-1,o.length&&h())}function h(){if(!l){var e=c(d);l=!0;for(var t=o.length;t;){for(r=o,o=[];++u<t;)r&&r[u].run();u=-1,t=o.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function m(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];o.push(new f(e,t)),1!==o.length||l||c(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=m,a.addListener=m,a.once=m,a.off=m,a.removeListener=m,a.removeAllListeners=m,a.emit=m,a.prependListener=m,a.prependOnceListener=m,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var i=n[e]={exports:{}},s=!0;try{t[e](i,i.exports,r),s=!1}finally{s&&delete n[e]}return i.exports}r.ab="//";var a=r(229);e.exports=a}()},8273:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return f}});var r=n(7437),a=n(2265),i=n(1837),s=n(1723),c=n(8124),o=n(1671),l=n(9388),u=n(9397);let d={pending:"badge-yellow",running:"badge-blue",completed:"badge-green",failed:"badge-red"},h={pending:(0,r.jsx)(s.Z,{size:12}),running:(0,r.jsx)(c.Z,{size:12}),completed:(0,r.jsx)(o.Z,{size:12}),failed:(0,r.jsx)(l.Z,{size:12})};function f(){let[e,t]=(0,a.useState)([]),[n,s]=(0,a.useState)(!0),[o,l]=(0,a.useState)(null),[f,m]=(0,a.useState)(!1),[p,x]=(0,a.useState)(""),[g,y]=(0,a.useState)("gpt-4o-mini"),[j,b]=(0,a.useState)(!1),v=async()=>{s(!0),l(null);try{let e=await i.hi.get("/api/batch/history");t(e)}catch(e){l(String(e))}finally{s(!1)}};(0,a.useEffect)(()=>{v()},[]);let w=async()=>{if(p.trim()&&g){b(!0);try{await i.hi.post("/api/batch",{jsonl:p,model:g}),m(!1),x(""),v()}catch(e){l(String(e))}finally{b(!1)}}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Batch API"}),(0,r.jsx)("p",{className:"page-sub",children:"Manage batch inference jobs"})]}),(0,r.jsxs)("button",{className:"btn-primary",onClick:()=>m(!0),children:[(0,r.jsx)(u.Z,{size:16})," New Batch"]})]}),f&&(0,r.jsxs)("div",{className:"card mb-6",children:[(0,r.jsx)("h2",{className:"text-sm font-semibold mb-3",children:"Create Batch Job"}),(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Model"}),(0,r.jsx)("input",{className:"input",value:g,onChange:e=>y(e.target.value),placeholder:"gpt-4o-mini"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"JSONL Input"}),(0,r.jsx)("textarea",{className:"input font-mono text-xs !min-h-[200px]",rows:8,value:p,onChange:e=>x(e.target.value),placeholder:'{"custom_id":"1","method":"POST","url":"/v1/chat/completions","body":{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}}'})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-primary",onClick:w,disabled:j||!p.trim()||!g,children:j?"Creating...":"Create Batch"}),(0,r.jsx)("button",{className:"btn-secondary",onClick:()=>{m(!1),x("")},children:"Cancel"})]})]})]}),n&&(0,r.jsxs)("div",{className:"text-center py-16 text-[var(--text-tertiary)]",children:[(0,r.jsx)(c.Z,{size:40,className:"mx-auto mb-4 opacity-40"}),(0,r.jsx)("p",{children:"Loading batch jobs..."})]}),o&&(0,r.jsxs)("div",{className:"card border border-red-500/30",children:[(0,r.jsx)("p",{className:"text-red-400 text-sm",children:o}),(0,r.jsx)("button",{className:"btn-ghost btn-xs mt-2",onClick:v,children:"Retry"})]}),!n&&!o&&0===e.length&&(0,r.jsxs)("div",{className:"text-center py-16 text-[var(--text-tertiary)]",children:[(0,r.jsx)(c.Z,{size:40,className:"mx-auto mb-4 opacity-40"}),(0,r.jsx)("p",{children:"No batch jobs yet"}),(0,r.jsxs)("button",{className:"btn-primary mt-4",onClick:()=>m(!0),children:[(0,r.jsx)(u.Z,{size:16})," Create your first batch"]})]}),!n&&!o&&e.length>0&&(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"ID"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Requests"}),(0,r.jsx)("th",{children:"Completed"}),(0,r.jsx)("th",{children:"Failed"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{children:"Created"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsxs)("td",{className:"font-mono text-xs",children:[e.id.slice(0,12),"..."]}),(0,r.jsx)("td",{children:e.model}),(0,r.jsx)("td",{children:e.request_count}),(0,r.jsx)("td",{children:e.completed_count}),(0,r.jsx)("td",{children:e.failed_count}),(0,r.jsx)("td",{children:(0,r.jsxs)("span",{className:"badge ".concat(d[e.status]||""),children:[h[e.status]," ",e.status]})}),(0,r.jsx)("td",{className:"text-xs text-[var(--text-secondary)]",children:new Date(e.created_at).toLocaleString()})]},e.id))})]})})})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return s},qz:function(){return i}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function a(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function i(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function s(){return!!a()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,l=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",s=a(),u={"Content-Type":"application/json",...t.headers};if(s&&(u.Authorization="Bearer ".concat(s)),"GET"===n&&!s){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=l.get(e);if(n)return n}let d=(async()=>{let a=await fetch("".concat(r).concat(e),{method:n,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let c=await a.json();return"GET"!==n||s||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===n&&!s){l.set(e,d);try{return await d}finally{l.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),function(e,t,n){try{let n="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(n)}catch(e){}}("nexus_token",n,0),r},getMe:()=>u("/api/auth/me"),logout:()=>{i(),o.clear(),window.location.href="/login"}},h=async e=>{let t=a(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let i=await n.blob(),s=URL.createObjectURL(i),c=document.createElement("a");c.href=s,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=8305)}),_N_E=e.O()}]);
static/_next/static/chunks/app/benchmarks/{page-af8fe334210c6570.js → page-2971e504ea962b1e.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1821],{5910:function(e,t,r){Promise.resolve().then(r.bind(r,4202))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return c}});var n=r(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:s=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...h}=e;return(0,n.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:r,strokeWidth:c?24*Number(l)/Number(s):l,className:a("lucide",o),...h},[...u.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let r=(0,n.forwardRef)((r,i)=>{let{className:c,...o}=r;return(0,n.createElement)(l,{ref:i,iconNode:t,className:a("lucide-".concat(s(e)),c),...o})});return r.displayName="".concat(e),r}},9322:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},8220:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]])},5621:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},3276:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},8930:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1239:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]])},257:function(e,t,r){"use strict";var n,s;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(s=r.g.process)?void 0:s.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,s=e.exports={};function a(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var c=[],o=!1,d=-1;function u(){o&&n&&(o=!1,n.length?c=n.concat(c):d=-1,c.length&&h())}function h(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(n=c,c=[];++d<t;)n&&n[d].run();d=-1,t=c.length}n=null,o=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function x(e,t){this.fun=e,this.array=t}function m(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new x(e,t)),1!==c.length||o||l(h)},x.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},r={};function n(e){var s=r[e];if(void 0!==s)return s.exports;var a=r[e]={exports:{}},i=!0;try{t[e](a,a.exports,n),i=!1}finally{i&&delete r[e]}return a.exports}n.ab="//";var s=n(229);e.exports=s}()},4202:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return h}});var n=r(7437),s=r(2265),a=r(1837),i=r(3276),l=r(8930),c=r(8220),o=r(1239),d=r(5621),u=r(9322);function h(){let[e,t]=(0,s.useState)("Reply: OK"),[r,h]=(0,s.useState)(5),[x,m]=(0,s.useState)(null),[f,p]=(0,s.useState)(!1),[y,v]=(0,s.useState)([]),[j,g]=(0,s.useState)(!0),[b,N]=(0,s.useState)(""),[k,w]=(0,s.useState)(!1),T=()=>{g(!0),N(""),a.hi.get("/api/benchmark/history").then(e=>{v(Array.isArray(e)?e:e.history||[])}).catch(e=>N(e instanceof Error?e.message:"Failed to load history")).finally(()=>g(!1))};(0,s.useEffect)(()=>{T()},[]);let E=async()=>{p(!0);try{let t=await a.hi.post("/api/benchmark/run",{test_prompt:e,max_tokens:r});m(t.results),T()}catch(e){m([])}finally{p(!1)}},Z=async()=>{if(confirm("Clear all benchmark history? This cannot be undone.")){w(!0);try{await a.hi.delete("/api/benchmark/history"),v([])}catch(e){N(e instanceof Error?e.message:"Failed to clear history")}finally{w(!1)}}};return(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"page-header",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Benchmarks"}),(0,n.jsx)("p",{className:"page-sub",children:"Run test prompts across all configured providers and models"})]})}),(0,n.jsx)("div",{className:"card mb-6",children:(0,n.jsxs)("div",{className:"flex flex-wrap gap-4 items-end",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-[300px]",children:[(0,n.jsx)("label",{className:"label",children:"Test Prompt"}),(0,n.jsx)("textarea",{className:"input font-mono text-sm resize-none h-20",value:e,onChange:e=>t(e.target.value)})]}),(0,n.jsxs)("div",{className:"w-24",children:[(0,n.jsx)("label",{className:"label",children:"Max Tokens"}),(0,n.jsx)("input",{className:"input",type:"number",min:1,max:4096,value:r,onChange:e=>h(parseInt(e.target.value)||5)})]}),(0,n.jsxs)("div",{className:"flex gap-2 pb-1",children:[(0,n.jsxs)("button",{className:"btn-primary",onClick:E,disabled:f,children:[f?(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,n.jsx)(i.Z,{size:16}),"Run Benchmark"]}),x&&x.length>0&&(0,n.jsx)("button",{className:"btn-ghost btn-sm",onClick:()=>m(null),title:"Clear results",children:(0,n.jsx)(l.Z,{size:16})})]})]})}),f?(0,n.jsx)("div",{className:"card",children:(0,n.jsx)("div",{className:"skeleton h-48 w-full"})}):x?0===x.length?(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(o.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"Benchmark completed but returned no results."})]}):(0,n.jsxs)("div",{className:"card p-0",children:[(0,n.jsx)("div",{className:"table-wrap",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"Key Name"}),(0,n.jsx)("th",{children:"Provider"}),(0,n.jsx)("th",{children:"Model"}),(0,n.jsx)("th",{children:"Status"}),(0,n.jsx)("th",{children:"Latency"}),(0,n.jsx)("th",{children:"Cost"}),(0,n.jsx)("th",{children:"Error"})]})}),(0,n.jsx)("tbody",{children:x.map((e,t)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"text-sm max-w-[160px] truncate",title:e.key_name,children:e.key_name}),(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"text-sm capitalize",children:e.provider})}),(0,n.jsx)("td",{className:"text-sm max-w-[200px] truncate",title:e.model,children:e.model}),(0,n.jsx)("td",{children:e.success?(0,n.jsxs)("span",{className:"badge-green",children:[(0,n.jsx)(o.Z,{size:12})," Success"]}):(0,n.jsx)("span",{className:"badge-red",children:"Fail"})}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:[e.latency_ms,"ms"]}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.cost).toFixed(6)]}),(0,n.jsx)("td",{className:"text-xs text-red-400 max-w-[200px] truncate",title:e.error||"",children:e.error||(0,n.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"—"})})]},t))})]})}),(0,n.jsxs)("div",{className:"px-4 py-2 text-xs text-[var(--text-tertiary)] border-t border-[var(--border)]",children:[x.length," result",1!==x.length?"s":""]})]}):(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(c.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No benchmarks run yet. Configure a prompt and click Run."})]}),(0,n.jsxs)("div",{className:"card mt-6",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(d.Z,{size:18,className:"text-[var(--text-tertiary)]"}),(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"Benchmark History"})]}),y.length>0&&(0,n.jsxs)("button",{className:"btn-danger btn-sm",onClick:Z,disabled:k,children:[(0,n.jsx)(l.Z,{size:14}),k?"Clearing...":"Clear History"]})]}),b?(0,n.jsxs)("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[(0,n.jsx)(u.Z,{size:14})," ",b]}):j?(0,n.jsx)("div",{className:"skeleton h-24 w-full"}):0===y.length?(0,n.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:"No benchmark history yet. Run a benchmark to see results here."}):(0,n.jsx)("div",{className:"table-wrap",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"Run At"}),(0,n.jsx)("th",{children:"Prompt"}),(0,n.jsx)("th",{children:"Max Tokens"}),(0,n.jsx)("th",{children:"Total"}),(0,n.jsx)("th",{children:"Success"}),(0,n.jsx)("th",{children:"Avg Latency"}),(0,n.jsx)("th",{children:"Avg Cost"})]})}),(0,n.jsx)("tbody",{children:y.map(e=>{var t,r,s,a;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"text-xs text-[var(--text-tertiary)] whitespace-nowrap",children:e.run_at}),(0,n.jsx)("td",{className:"text-xs max-w-[200px] truncate",title:e.prompt,children:e.prompt}),(0,n.jsx)("td",{className:"text-xs",children:e.max_tokens}),(0,n.jsx)("td",{className:"text-xs",children:null!==(s=null===(t=e.summary)||void 0===t?void 0:t.total)&&void 0!==s?s:0}),(0,n.jsx)("td",{className:"text-xs",children:null!==(a=null===(r=e.summary)||void 0===r?void 0:r.success)&&void 0!==a?a:0}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:[e.summary?Math.round(e.summary.avg_latency):0,"ms"]}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:["$",e.summary?e.summary.avg_cost.toFixed(6):"0.000000"]})]},e.id)})})]})})]})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return i},qz:function(){return a}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function s(){return localStorage.getItem("nexus_token")}function a(){localStorage.removeItem("nexus_token")}function i(){return!!s()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",i=s(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===r&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=o.get(e);if(r)return r}let u=(async()=>{let s=await fetch("".concat(n).concat(e),{method:r,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw a(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let l=await s.json();return"GET"!==r||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===r&&!i){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),n},getMe:()=>d("/api/auth/me"),logout:()=>{a(),c.clear(),window.location.href="/login"}},h=async e=>{let t=s(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let a=await r.blob(),i=URL.createObjectURL(a),l=document.createElement("a");l.href=i,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=5910)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1821],{5910:function(e,t,r){Promise.resolve().then(r.bind(r,4202))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return l}});var n=r(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:s=24,strokeWidth:c=2,absoluteStrokeWidth:l,className:o="",children:d,iconNode:u,...h}=e;return(0,n.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:r,strokeWidth:l?24*Number(c)/Number(s):c,className:a("lucide",o),...h},[...u.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),l=(e,t)=>{let r=(0,n.forwardRef)((r,i)=>{let{className:l,...o}=r;return(0,n.createElement)(c,{ref:i,iconNode:t,className:a("lucide-".concat(s(e)),l),...o})});return r.displayName="".concat(e),r}},9322:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},8220:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]])},5621:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},3276:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},8930:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1239:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]])},257:function(e,t,r){"use strict";var n,s;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(s=r.g.process)?void 0:s.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,s=e.exports={};function a(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var l=[],o=!1,d=-1;function u(){o&&n&&(o=!1,n.length?l=n.concat(l):d=-1,l.length&&h())}function h(){if(!o){var e=c(u);o=!0;for(var t=l.length;t;){for(n=l,l=[];++d<t;)n&&n[d].run();d=-1,t=l.length}n=null,o=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function x(e,t){this.fun=e,this.array=t}function m(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new x(e,t)),1!==l.length||o||c(h)},x.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},r={};function n(e){var s=r[e];if(void 0!==s)return s.exports;var a=r[e]={exports:{}},i=!0;try{t[e](a,a.exports,n),i=!1}finally{i&&delete r[e]}return a.exports}n.ab="//";var s=n(229);e.exports=s}()},4202:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return h}});var n=r(7437),s=r(2265),a=r(1837),i=r(3276),c=r(8930),l=r(8220),o=r(1239),d=r(5621),u=r(9322);function h(){let[e,t]=(0,s.useState)("Reply: OK"),[r,h]=(0,s.useState)(5),[x,m]=(0,s.useState)(null),[p,f]=(0,s.useState)(!1),[y,v]=(0,s.useState)([]),[j,g]=(0,s.useState)(!0),[b,k]=(0,s.useState)(""),[w,N]=(0,s.useState)(!1),T=()=>{g(!0),k(""),a.hi.get("/api/benchmark/history").then(e=>{v(Array.isArray(e)?e:e.history||[])}).catch(e=>k(e instanceof Error?e.message:"Failed to load history")).finally(()=>g(!1))};(0,s.useEffect)(()=>{T()},[]);let E=async()=>{f(!0);try{let t=await a.hi.post("/api/benchmark/run",{test_prompt:e,max_tokens:r});m(t.results),T()}catch(e){m([])}finally{f(!1)}},_=async()=>{if(confirm("Clear all benchmark history? This cannot be undone.")){N(!0);try{await a.hi.delete("/api/benchmark/history"),v([])}catch(e){k(e instanceof Error?e.message:"Failed to clear history")}finally{N(!1)}}};return(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"page-header",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Benchmarks"}),(0,n.jsx)("p",{className:"page-sub",children:"Run test prompts across all configured providers and models"})]})}),(0,n.jsx)("div",{className:"card mb-6",children:(0,n.jsxs)("div",{className:"flex flex-wrap gap-4 items-end",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-[300px]",children:[(0,n.jsx)("label",{className:"label",children:"Test Prompt"}),(0,n.jsx)("textarea",{className:"input font-mono text-sm resize-none h-20",value:e,onChange:e=>t(e.target.value)})]}),(0,n.jsxs)("div",{className:"w-24",children:[(0,n.jsx)("label",{className:"label",children:"Max Tokens"}),(0,n.jsx)("input",{className:"input",type:"number",min:1,max:4096,value:r,onChange:e=>h(parseInt(e.target.value)||5)})]}),(0,n.jsxs)("div",{className:"flex gap-2 pb-1",children:[(0,n.jsxs)("button",{className:"btn-primary",onClick:E,disabled:p,children:[p?(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,n.jsx)(i.Z,{size:16}),"Run Benchmark"]}),x&&x.length>0&&(0,n.jsx)("button",{className:"btn-ghost btn-sm",onClick:()=>m(null),title:"Clear results",children:(0,n.jsx)(c.Z,{size:16})})]})]})}),p?(0,n.jsx)("div",{className:"card",children:(0,n.jsx)("div",{className:"skeleton h-48 w-full"})}):x?0===x.length?(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(o.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"Benchmark completed but returned no results."})]}):(0,n.jsxs)("div",{className:"card p-0",children:[(0,n.jsx)("div",{className:"table-wrap",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"Key Name"}),(0,n.jsx)("th",{children:"Provider"}),(0,n.jsx)("th",{children:"Model"}),(0,n.jsx)("th",{children:"Status"}),(0,n.jsx)("th",{children:"Latency"}),(0,n.jsx)("th",{children:"Cost"}),(0,n.jsx)("th",{children:"Error"})]})}),(0,n.jsx)("tbody",{children:x.map((e,t)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"text-sm max-w-[160px] truncate",title:e.key_name,children:e.key_name}),(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"text-sm capitalize",children:e.provider})}),(0,n.jsx)("td",{className:"text-sm max-w-[200px] truncate",title:e.model,children:e.model}),(0,n.jsx)("td",{children:e.success?(0,n.jsxs)("span",{className:"badge-green",children:[(0,n.jsx)(o.Z,{size:12})," Success"]}):(0,n.jsx)("span",{className:"badge-red",children:"Fail"})}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:[e.latency_ms,"ms"]}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.cost).toFixed(6)]}),(0,n.jsx)("td",{className:"text-xs text-red-400 max-w-[200px] truncate",title:e.error||"",children:e.error||(0,n.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"—"})})]},t))})]})}),(0,n.jsxs)("div",{className:"px-4 py-2 text-xs text-[var(--text-tertiary)] border-t border-[var(--border)]",children:[x.length," result",1!==x.length?"s":""]})]}):(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No benchmarks run yet. Configure a prompt and click Run."})]}),(0,n.jsxs)("div",{className:"card mt-6",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(d.Z,{size:18,className:"text-[var(--text-tertiary)]"}),(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"Benchmark History"})]}),y.length>0&&(0,n.jsxs)("button",{className:"btn-danger btn-sm",onClick:_,disabled:w,children:[(0,n.jsx)(c.Z,{size:14}),w?"Clearing...":"Clear History"]})]}),b?(0,n.jsxs)("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[(0,n.jsx)(u.Z,{size:14})," ",b]}):j?(0,n.jsx)("div",{className:"skeleton h-24 w-full"}):0===y.length?(0,n.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:"No benchmark history yet. Run a benchmark to see results here."}):(0,n.jsx)("div",{className:"table-wrap",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"Run At"}),(0,n.jsx)("th",{children:"Prompt"}),(0,n.jsx)("th",{children:"Max Tokens"}),(0,n.jsx)("th",{children:"Total"}),(0,n.jsx)("th",{children:"Success"}),(0,n.jsx)("th",{children:"Avg Latency"}),(0,n.jsx)("th",{children:"Avg Cost"})]})}),(0,n.jsx)("tbody",{children:y.map(e=>{var t,r,s,a;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"text-xs text-[var(--text-tertiary)] whitespace-nowrap",children:e.run_at}),(0,n.jsx)("td",{className:"text-xs max-w-[200px] truncate",title:e.prompt,children:e.prompt}),(0,n.jsx)("td",{className:"text-xs",children:e.max_tokens}),(0,n.jsx)("td",{className:"text-xs",children:null!==(s=null===(t=e.summary)||void 0===t?void 0:t.total)&&void 0!==s?s:0}),(0,n.jsx)("td",{className:"text-xs",children:null!==(a=null===(r=e.summary)||void 0===r?void 0:r.success)&&void 0!==a?a:0}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:[e.summary?Math.round(e.summary.avg_latency):0,"ms"]}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:["$",e.summary?e.summary.avg_cost.toFixed(6):"0.000000"]})]},e.id)})})]})})]})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return i},qz:function(){return a}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function s(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function a(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function i(){return!!s()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",i=s(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===r&&!i){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=o.get(e);if(r)return r}let u=(async()=>{let s=await fetch("".concat(n).concat(e),{method:r,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw a(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let c=await s.json();return"GET"!==r||i||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===r&&!i){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),function(e,t,r){try{let r="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(r)}catch(e){}}("nexus_token",r,0),n},getMe:()=>d("/api/auth/me"),logout:()=>{a(),l.clear(),window.location.href="/login"}},h=async e=>{let t=s(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let a=await r.blob(),i=URL.createObjectURL(a),c=document.createElement("a");c.href=i,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=5910)}),_N_E=e.O()}]);
static/_next/static/chunks/app/benchmarks/page-d6e2b98299937e6a.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1821],{5910:function(e,t,r){Promise.resolve().then(r.bind(r,4202))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return c}});var n=r(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:s=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...h}=e;return(0,n.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:r,strokeWidth:c?24*Number(l)/Number(s):l,className:a("lucide",o),...h},[...u.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let r=(0,n.forwardRef)((r,i)=>{let{className:c,...o}=r;return(0,n.createElement)(l,{ref:i,iconNode:t,className:a("lucide-".concat(s(e)),c),...o})});return r.displayName="".concat(e),r}},9322:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},8220:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]])},5621:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]])},3276:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},8930:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1239:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]])},257:function(e,t,r){"use strict";var n,s;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(s=r.g.process)?void 0:s.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,s=e.exports={};function a(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var c=[],o=!1,d=-1;function u(){o&&n&&(o=!1,n.length?c=n.concat(c):d=-1,c.length&&h())}function h(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(n=c,c=[];++d<t;)n&&n[d].run();d=-1,t=c.length}n=null,o=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function x(e,t){this.fun=e,this.array=t}function m(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new x(e,t)),1!==c.length||o||l(h)},x.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},r={};function n(e){var s=r[e];if(void 0!==s)return s.exports;var a=r[e]={exports:{}},i=!0;try{t[e](a,a.exports,n),i=!1}finally{i&&delete r[e]}return a.exports}n.ab="//";var s=n(229);e.exports=s}()},4202:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return h}});var n=r(7437),s=r(2265),a=r(1837),i=r(3276),l=r(8930),c=r(8220),o=r(1239),d=r(5621),u=r(9322);function h(){let[e,t]=(0,s.useState)("Reply: OK"),[r,h]=(0,s.useState)(5),[x,m]=(0,s.useState)(null),[f,p]=(0,s.useState)(!1),[y,v]=(0,s.useState)([]),[j,g]=(0,s.useState)(!0),[b,N]=(0,s.useState)(""),[k,w]=(0,s.useState)(!1),T=()=>{g(!0),N(""),a.hi.get("/api/benchmark/history").then(e=>{v(Array.isArray(e)?e:e.history||[])}).catch(e=>N(e instanceof Error?e.message:"Failed to load history")).finally(()=>g(!1))};(0,s.useEffect)(()=>{T()},[]);let E=async()=>{p(!0);try{let t=await a.hi.post("/api/benchmark/run",{test_prompt:e,max_tokens:r});m(t.results),T()}catch(e){m([])}finally{p(!1)}},Z=async()=>{if(confirm("Clear all benchmark history? This cannot be undone.")){w(!0);try{await a.hi.delete("/api/benchmark/history"),v([])}catch(e){N(e instanceof Error?e.message:"Failed to clear history")}finally{w(!1)}}};return(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"page-header",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Benchmarks"}),(0,n.jsx)("p",{className:"page-sub",children:"Run test prompts across all configured providers and models"})]})}),(0,n.jsx)("div",{className:"card mb-6",children:(0,n.jsxs)("div",{className:"flex flex-wrap gap-4 items-end",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-[300px]",children:[(0,n.jsx)("label",{className:"label",children:"Test Prompt"}),(0,n.jsx)("textarea",{className:"input font-mono text-sm resize-none h-20",value:e,onChange:e=>t(e.target.value)})]}),(0,n.jsxs)("div",{className:"w-24",children:[(0,n.jsx)("label",{className:"label",children:"Max Tokens"}),(0,n.jsx)("input",{className:"input",type:"number",min:1,max:4096,value:r,onChange:e=>h(parseInt(e.target.value)||5)})]}),(0,n.jsxs)("div",{className:"flex gap-2 pb-1",children:[(0,n.jsxs)("button",{className:"btn-primary",onClick:E,disabled:f,children:[f?(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,n.jsx)(i.Z,{size:16}),"Run Benchmark"]}),x&&x.length>0&&(0,n.jsx)("button",{className:"btn-ghost btn-sm",onClick:()=>m(null),title:"Clear results",children:(0,n.jsx)(l.Z,{size:16})})]})]})}),f?(0,n.jsx)("div",{className:"card",children:(0,n.jsx)("div",{className:"skeleton h-48 w-full"})}):x?0===x.length?(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(o.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"Benchmark completed but returned no results."})]}):(0,n.jsxs)("div",{className:"card p-0",children:[(0,n.jsx)("div",{className:"table-wrap",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"Key Name"}),(0,n.jsx)("th",{children:"Provider"}),(0,n.jsx)("th",{children:"Model"}),(0,n.jsx)("th",{children:"Status"}),(0,n.jsx)("th",{children:"Latency"}),(0,n.jsx)("th",{children:"Cost"}),(0,n.jsx)("th",{children:"Error"})]})}),(0,n.jsx)("tbody",{children:x.map((e,t)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"text-sm max-w-[160px] truncate",title:e.key_name,children:e.key_name}),(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"text-sm capitalize",children:e.provider})}),(0,n.jsx)("td",{className:"text-sm max-w-[200px] truncate",title:e.model,children:e.model}),(0,n.jsx)("td",{children:e.success?(0,n.jsxs)("span",{className:"badge-green",children:[(0,n.jsx)(o.Z,{size:12})," Success"]}):(0,n.jsx)("span",{className:"badge-red",children:"Fail"})}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:[e.latency_ms,"ms"]}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:["$",Number(e.cost).toFixed(6)]}),(0,n.jsx)("td",{className:"text-xs text-red-400 max-w-[200px] truncate",title:e.error||"",children:e.error||(0,n.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"—"})})]},t))})]})}),(0,n.jsxs)("div",{className:"px-4 py-2 text-xs text-[var(--text-tertiary)] border-t border-[var(--border)]",children:[x.length," result",1!==x.length?"s":""]})]}):(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(c.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No benchmarks run yet. Configure a prompt and click Run."})]}),(0,n.jsxs)("div",{className:"card mt-6",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(d.Z,{size:18,className:"text-[var(--text-tertiary)]"}),(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"Benchmark History"})]}),y.length>0&&(0,n.jsxs)("button",{className:"btn-danger btn-sm",onClick:Z,disabled:k,children:[(0,n.jsx)(l.Z,{size:14}),k?"Clearing...":"Clear History"]})]}),b?(0,n.jsxs)("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[(0,n.jsx)(u.Z,{size:14})," ",b]}):j?(0,n.jsx)("div",{className:"skeleton h-24 w-full"}):0===y.length?(0,n.jsx)("p",{className:"text-sm text-[var(--text-tertiary)]",children:"No benchmark history yet. Run a benchmark to see results here."}):(0,n.jsx)("div",{className:"table-wrap",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"Run At"}),(0,n.jsx)("th",{children:"Prompt"}),(0,n.jsx)("th",{children:"Max Tokens"}),(0,n.jsx)("th",{children:"Total"}),(0,n.jsx)("th",{children:"Success"}),(0,n.jsx)("th",{children:"Avg Latency"}),(0,n.jsx)("th",{children:"Avg Cost"})]})}),(0,n.jsx)("tbody",{children:y.map(e=>{var t,r,s,a;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"text-xs text-[var(--text-tertiary)] whitespace-nowrap",children:e.run_at}),(0,n.jsx)("td",{className:"text-xs max-w-[200px] truncate",title:e.prompt,children:e.prompt}),(0,n.jsx)("td",{className:"text-xs",children:e.max_tokens}),(0,n.jsx)("td",{className:"text-xs",children:null!==(s=null===(t=e.summary)||void 0===t?void 0:t.total)&&void 0!==s?s:0}),(0,n.jsx)("td",{className:"text-xs",children:null!==(a=null===(r=e.summary)||void 0===r?void 0:r.success)&&void 0!==a?a:0}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:[e.summary?Math.round(e.summary.avg_latency):0,"ms"]}),(0,n.jsxs)("td",{className:"text-xs font-mono",children:["$",e.summary?e.summary.avg_cost.toFixed(6):"0.000000"]})]},e.id)})})]})})]})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return i},qz:function(){return a}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function s(){return localStorage.getItem("nexus_token")}function a(){localStorage.removeItem("nexus_token")}function i(){return!!s()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",i=s(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===r&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=o.get(e);if(r)return r}let u=(async()=>{let s=await fetch("".concat(n).concat(e),{method:r,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw a(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let l=await s.json();return"GET"!==r||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===r&&!i){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),n},getMe:()=>d("/api/auth/me"),logout:()=>{a(),c.clear(),window.location.href="/login"}},h=async e=>{let t=s(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let a=await r.blob(),i=URL.createObjectURL(a),l=document.createElement("a");l.href=i,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=5910)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/cache/{page-02c4a057138aaaad.js → page-16bf5ae5f751e0ae.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4231],{6977:function(e,t,r){Promise.resolve().then(r.bind(r,6593))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return l}});var a=r(2265);let n=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,a.forwardRef)((e,t)=>{let{color:r="currentColor",size:n=24,strokeWidth:c=2,absoluteStrokeWidth:l,className:o="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...s,width:n,height:n,stroke:r,strokeWidth:l?24*Number(c)/Number(n):c,className:i("lucide",o),...h},[...u.map(e=>{let[t,r]=e;return(0,a.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),l=(e,t)=>{let r=(0,a.forwardRef)((r,s)=>{let{className:l,...o}=r;return(0,a.createElement)(c,{ref:s,iconNode:t,className:i("lucide-".concat(n(e)),l),...o})});return r.displayName="".concat(e),r}},91:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},7168:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},8930:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1239:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]])},257:function(e,t,r){"use strict";var a,n;e.exports=(null==(a=r.g.process)?void 0:a.env)&&"object"==typeof(null==(n=r.g.process)?void 0:n.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,a,n=e.exports={};function i(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var l=[],o=!1,d=-1;function u(){o&&a&&(o=!1,a.length?l=a.concat(l):d=-1,l.length&&h())}function h(){if(!o){var e=c(u);o=!0;for(var t=l.length;t;){for(a=l,l=[];++d<t;)a&&a[d].run();d=-1,t=l.length}a=null,o=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function x(e,t){this.fun=e,this.array=t}function f(){}n.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new x(e,t)),1!==l.length||o||c(h)},x.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=f,n.addListener=f,n.once=f,n.off=f,n.removeListener=f,n.removeAllListeners=f,n.emit=f,n.prependListener=f,n.prependOnceListener=f,n.listeners=function(e){return[]},n.binding=function(e){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw Error("process.chdir is not supported")},n.umask=function(){return 0}}},r={};function a(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}},s=!0;try{t[e](i,i.exports,a),s=!1}finally{s&&delete r[e]}return i.exports}a.ab="//";var n=a(229);e.exports=n}()},6593:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return h}});var a=r(7437),n=r(2265),i=r(1837),s=r(7168),c=r(91),l=r(1239);let o=(0,r(9205).Z)("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);var d=r(8930);function u(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024));return"".concat((e/Math.pow(1024,t)).toFixed(1)," ").concat(["B","KB","MB","GB"][t])}function h(){let[e,t]=(0,n.useState)(null),[r,h]=(0,n.useState)(!0),[x,f]=(0,n.useState)(""),[m,p]=(0,n.useState)(null),v=async()=>{h(!0),f("");try{let e=await i.hi.get("/api/cache/stats");t(e)}catch(e){f(e instanceof Error?e.message:"Failed to load cache stats")}finally{h(!1)}};(0,n.useEffect)(()=>{v()},[]);let y=async(e,t,r)=>{if(window.confirm("Are you sure you want to clear the ".concat(t,"?"))){p(e);try{await i.hi.delete(r),await v()}catch(e){f(e instanceof Error?e.message:"Failed to clear ".concat(t))}finally{p(null)}}};return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("div",{className:"page-header",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"page-title",children:"Cache Management"}),(0,a.jsx)("p",{className:"page-sub",children:"View and manage BYOK AI Gateway cache entries"})]}),(0,a.jsxs)("button",{className:"btn-secondary",onClick:v,disabled:r,children:[(0,a.jsx)(s.Z,{size:16,className:r?"animate-spin":""}),"Refresh"]})]}),x&&(0,a.jsx)("div",{className:"card border border-red-500/30 bg-red-500/10 p-4 text-red-400 text-sm",children:x}),r&&!e?(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[1,2,3,4].map(e=>(0,a.jsxs)("div",{className:"card animate-pulse p-6",children:[(0,a.jsx)("div",{className:"h-4 w-24 bg-[var(--surface-100)] rounded mb-3"}),(0,a.jsx)("div",{className:"h-8 w-16 bg-[var(--surface-100)] rounded mb-2"}),(0,a.jsx)("div",{className:"h-3 w-32 bg-[var(--surface-100)] rounded"})]},e))}):e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(c.Z,{size:16}),(0,a.jsx)("span",{children:"Exact Cache"})]}),(0,a.jsx)("div",{className:"text-2xl font-bold text-white mb-1",children:e.exact_count}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:u(e.exact_size_bytes)})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(l.Z,{size:16}),(0,a.jsx)("span",{children:"Semantic Cache"})]}),(0,a.jsx)("div",{className:"text-2xl font-bold text-white mb-1",children:e.semantic_count}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:u(e.semantic_size_bytes)})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(o,{size:16}),(0,a.jsx)("span",{children:"Hit Rate"})]}),(0,a.jsxs)("div",{className:"text-2xl font-bold text-white mb-1",children:[(100*e.hit_rate).toFixed(1),"%"]}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:"Cache efficiency"})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(s.Z,{size:16}),(0,a.jsx)("span",{children:"TTL"})]}),(0,a.jsxs)("div",{className:"text-2xl font-bold text-white mb-1",children:[e.ttl,"s"]}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:"Cache expiry"})]})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-white mb-4",children:"Clear Cache"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,a.jsxs)("button",{className:"btn-secondary",onClick:()=>y("exact","Exact Cache","/api/cache/exact"),disabled:null!==m,children:[(0,a.jsx)(d.Z,{size:16}),"exact"===m?"Clearing...":"Clear Exact Cache"]}),(0,a.jsxs)("button",{className:"btn-secondary",onClick:()=>y("semantic","Semantic Cache","/api/cache/semantic"),disabled:null!==m,children:[(0,a.jsx)(d.Z,{size:16}),"semantic"===m?"Clearing...":"Clear Semantic Cache"]}),(0,a.jsxs)("button",{className:"btn-danger",onClick:()=>y("all","All Cache","/api/cache/clear"),disabled:null!==m,children:[(0,a.jsx)(d.Z,{size:16}),"all"===m?"Clearing...":"Clear All Cache"]})]})]})]}):null]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return s},qz:function(){return i}});let a=r(257).env.NEXT_PUBLIC_API_BASE||"";function n(){return localStorage.getItem("nexus_token")}function i(){localStorage.removeItem("nexus_token")}function s(){return!!n()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",s=n(),d={"Content-Type":"application/json",...t.headers};if(s&&(d.Authorization="Bearer ".concat(s)),"GET"===r&&!s){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=o.get(e);if(r)return r}let u=(async()=>{let n=await fetch("".concat(a).concat(e),{method:r,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return n;if(401===n.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!n.ok)throw Error((await n.json().catch(()=>({detail:n.statusText}))).detail||"HTTP ".concat(n.status));if(204===n.status)return;let c=await n.json();return"GET"!==r||s||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===r&&!s){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var r;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=a.access_token,localStorage.setItem("nexus_token",r),a},getMe:()=>d("/api/auth/me"),logout:()=>{i(),l.clear(),window.location.href="/login"}},h=async e=>{let t=n(),r=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let i=await r.blob(),s=URL.createObjectURL(i),c=document.createElement("a");c.href=s,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=6977)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4231],{6977:function(e,t,n){Promise.resolve().then(n.bind(n,6593))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var a=n(2265);let r=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),c=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let s=(0,a.forwardRef)((e,t)=>{let{color:n="currentColor",size:r=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:l="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...i,width:r,height:r,stroke:n,strokeWidth:o?24*Number(s)/Number(r):s,className:c("lucide",l),...h},[...u.map(e=>{let[t,n]=e;return(0,a.createElement)(t,n)}),...Array.isArray(d)?d:[d]])}),o=(e,t)=>{let n=(0,a.forwardRef)((n,i)=>{let{className:o,...l}=n;return(0,a.createElement)(s,{ref:i,iconNode:t,className:c("lucide-".concat(r(e)),o),...l})});return n.displayName="".concat(e),n}},91:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},7168:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},8930:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1239:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]])},257:function(e,t,n){"use strict";var a,r;e.exports=(null==(a=n.g.process)?void 0:a.env)&&"object"==typeof(null==(r=n.g.process)?void 0:r.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,a,r=e.exports={};function c(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===c||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:c}catch(e){t=c}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var o=[],l=!1,d=-1;function u(){l&&a&&(l=!1,a.length?o=a.concat(o):d=-1,o.length&&h())}function h(){if(!l){var e=s(u);l=!0;for(var t=o.length;t;){for(a=o,o=[];++d<t;)a&&a[d].run();d=-1,t=o.length}a=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function x(e,t){this.fun=e,this.array=t}function f(){}r.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];o.push(new x(e,t)),1!==o.length||l||s(h)},x.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=f,r.addListener=f,r.once=f,r.off=f,r.removeListener=f,r.removeAllListeners=f,r.emit=f,r.prependListener=f,r.prependOnceListener=f,r.listeners=function(e){return[]},r.binding=function(e){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw Error("process.chdir is not supported")},r.umask=function(){return 0}}},n={};function a(e){var r=n[e];if(void 0!==r)return r.exports;var c=n[e]={exports:{}},i=!0;try{t[e](c,c.exports,a),i=!1}finally{i&&delete n[e]}return c.exports}a.ab="//";var r=a(229);e.exports=r}()},6593:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return h}});var a=n(7437),r=n(2265),c=n(1837),i=n(7168),s=n(91),o=n(1239);let l=(0,n(9205).Z)("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);var d=n(8930);function u(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024));return"".concat((e/Math.pow(1024,t)).toFixed(1)," ").concat(["B","KB","MB","GB"][t])}function h(){let[e,t]=(0,r.useState)(null),[n,h]=(0,r.useState)(!0),[x,f]=(0,r.useState)(""),[m,p]=(0,r.useState)(null),v=async()=>{h(!0),f("");try{let e=await c.hi.get("/api/cache/stats");t(e)}catch(e){f(e instanceof Error?e.message:"Failed to load cache stats")}finally{h(!1)}};(0,r.useEffect)(()=>{v()},[]);let y=async(e,t,n)=>{if(window.confirm("Are you sure you want to clear the ".concat(t,"?"))){p(e);try{await c.hi.delete(n),await v()}catch(e){f(e instanceof Error?e.message:"Failed to clear ".concat(t))}finally{p(null)}}};return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("div",{className:"page-header",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"page-title",children:"Cache Management"}),(0,a.jsx)("p",{className:"page-sub",children:"View and manage BYOK AI Gateway cache entries"})]}),(0,a.jsxs)("button",{className:"btn-secondary",onClick:v,disabled:n,children:[(0,a.jsx)(i.Z,{size:16,className:n?"animate-spin":""}),"Refresh"]})]}),x&&(0,a.jsx)("div",{className:"card border border-red-500/30 bg-red-500/10 p-4 text-red-400 text-sm",children:x}),n&&!e?(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[1,2,3,4].map(e=>(0,a.jsxs)("div",{className:"card animate-pulse p-6",children:[(0,a.jsx)("div",{className:"h-4 w-24 bg-[var(--surface-100)] rounded mb-3"}),(0,a.jsx)("div",{className:"h-8 w-16 bg-[var(--surface-100)] rounded mb-2"}),(0,a.jsx)("div",{className:"h-3 w-32 bg-[var(--surface-100)] rounded"})]},e))}):e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(s.Z,{size:16}),(0,a.jsx)("span",{children:"Exact Cache"})]}),(0,a.jsx)("div",{className:"text-2xl font-bold text-white mb-1",children:e.exact_count}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:u(e.exact_size_bytes)})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(o.Z,{size:16}),(0,a.jsx)("span",{children:"Semantic Cache"})]}),(0,a.jsx)("div",{className:"text-2xl font-bold text-white mb-1",children:e.semantic_count}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:u(e.semantic_size_bytes)})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(l,{size:16}),(0,a.jsx)("span",{children:"Hit Rate"})]}),(0,a.jsxs)("div",{className:"text-2xl font-bold text-white mb-1",children:[(100*e.hit_rate).toFixed(1),"%"]}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:"Cache efficiency"})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(i.Z,{size:16}),(0,a.jsx)("span",{children:"TTL"})]}),(0,a.jsxs)("div",{className:"text-2xl font-bold text-white mb-1",children:[e.ttl,"s"]}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:"Cache expiry"})]})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-white mb-4",children:"Clear Cache"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,a.jsxs)("button",{className:"btn-secondary",onClick:()=>y("exact","Exact Cache","/api/cache/exact"),disabled:null!==m,children:[(0,a.jsx)(d.Z,{size:16}),"exact"===m?"Clearing...":"Clear Exact Cache"]}),(0,a.jsxs)("button",{className:"btn-secondary",onClick:()=>y("semantic","Semantic Cache","/api/cache/semantic"),disabled:null!==m,children:[(0,a.jsx)(d.Z,{size:16}),"semantic"===m?"Clearing...":"Clear Semantic Cache"]}),(0,a.jsxs)("button",{className:"btn-danger",onClick:()=>y("all","All Cache","/api/cache/clear"),disabled:null!==m,children:[(0,a.jsx)(d.Z,{size:16}),"all"===m?"Clearing...":"Clear All Cache"]})]})]})]}):null]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return i},qz:function(){return c}});let a=n(257).env.NEXT_PUBLIC_API_BASE||"";function r(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function c(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function i(){return!!r()}let s={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,l=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",i=r(),d={"Content-Type":"application/json",...t.headers};if(i&&(d.Authorization="Bearer ".concat(i)),"GET"===n&&!i){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in s)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return s[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=l.get(e);if(n)return n}let u=(async()=>{let r=await fetch("".concat(a).concat(e),{method:n,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return r;if(401===r.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw c(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!r.ok)throw Error((await r.json().catch(()=>({detail:r.statusText}))).detail||"HTTP ".concat(r.status));if(204===r.status)return;let s=await r.json();return"GET"!==n||i||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,s),s})();if("GET"===n&&!i){l.set(e,u);try{return await u}finally{l.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var n;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=a.access_token,localStorage.setItem("nexus_token",n),function(e,t,n){try{let n="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(n)}catch(e){}}("nexus_token",n,0),a},getMe:()=>d("/api/auth/me"),logout:()=>{c(),o.clear(),window.location.href="/login"}},h=async e=>{let t=r(),n=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let c=await n.blob(),i=URL.createObjectURL(c),s=document.createElement("a");s.href=i,s.download=e.split("/").pop()||"export.csv",s.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=6977)}),_N_E=e.O()}]);
static/_next/static/chunks/app/cache/page-1dceb2a7e680cdb2.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4231],{6977:function(e,t,r){Promise.resolve().then(r.bind(r,6593))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return l}});var a=r(2265);let n=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,a.forwardRef)((e,t)=>{let{color:r="currentColor",size:n=24,strokeWidth:c=2,absoluteStrokeWidth:l,className:o="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...s,width:n,height:n,stroke:r,strokeWidth:l?24*Number(c)/Number(n):c,className:i("lucide",o),...h},[...u.map(e=>{let[t,r]=e;return(0,a.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),l=(e,t)=>{let r=(0,a.forwardRef)((r,s)=>{let{className:l,...o}=r;return(0,a.createElement)(c,{ref:s,iconNode:t,className:i("lucide-".concat(n(e)),l),...o})});return r.displayName="".concat(e),r}},91:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},7168:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},8930:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},1239:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=(0,r(9205).Z)("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]])},257:function(e,t,r){"use strict";var a,n;e.exports=(null==(a=r.g.process)?void 0:a.env)&&"object"==typeof(null==(n=r.g.process)?void 0:n.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,a,n=e.exports={};function i(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var l=[],o=!1,d=-1;function u(){o&&a&&(o=!1,a.length?l=a.concat(l):d=-1,l.length&&h())}function h(){if(!o){var e=c(u);o=!0;for(var t=l.length;t;){for(a=l,l=[];++d<t;)a&&a[d].run();d=-1,t=l.length}a=null,o=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function x(e,t){this.fun=e,this.array=t}function f(){}n.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new x(e,t)),1!==l.length||o||c(h)},x.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=f,n.addListener=f,n.once=f,n.off=f,n.removeListener=f,n.removeAllListeners=f,n.emit=f,n.prependListener=f,n.prependOnceListener=f,n.listeners=function(e){return[]},n.binding=function(e){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw Error("process.chdir is not supported")},n.umask=function(){return 0}}},r={};function a(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}},s=!0;try{t[e](i,i.exports,a),s=!1}finally{s&&delete r[e]}return i.exports}a.ab="//";var n=a(229);e.exports=n}()},6593:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return h}});var a=r(7437),n=r(2265),i=r(1837),s=r(7168),c=r(91),l=r(1239);let o=(0,r(9205).Z)("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);var d=r(8930);function u(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024));return"".concat((e/Math.pow(1024,t)).toFixed(1)," ").concat(["B","KB","MB","GB"][t])}function h(){let[e,t]=(0,n.useState)(null),[r,h]=(0,n.useState)(!0),[x,f]=(0,n.useState)(""),[m,p]=(0,n.useState)(null),v=async()=>{h(!0),f("");try{let e=await i.hi.get("/api/cache/stats");t(e)}catch(e){f(e instanceof Error?e.message:"Failed to load cache stats")}finally{h(!1)}};(0,n.useEffect)(()=>{v()},[]);let y=async(e,t,r)=>{if(window.confirm("Are you sure you want to clear the ".concat(t,"?"))){p(e);try{await i.hi.delete(r),await v()}catch(e){f(e instanceof Error?e.message:"Failed to clear ".concat(t))}finally{p(null)}}};return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("div",{className:"page-header",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"page-title",children:"Cache Management"}),(0,a.jsx)("p",{className:"page-sub",children:"View and manage BYOK AI Gateway cache entries"})]}),(0,a.jsxs)("button",{className:"btn-secondary",onClick:v,disabled:r,children:[(0,a.jsx)(s.Z,{size:16,className:r?"animate-spin":""}),"Refresh"]})]}),x&&(0,a.jsx)("div",{className:"card border border-red-500/30 bg-red-500/10 p-4 text-red-400 text-sm",children:x}),r&&!e?(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[1,2,3,4].map(e=>(0,a.jsxs)("div",{className:"card animate-pulse p-6",children:[(0,a.jsx)("div",{className:"h-4 w-24 bg-[var(--surface-100)] rounded mb-3"}),(0,a.jsx)("div",{className:"h-8 w-16 bg-[var(--surface-100)] rounded mb-2"}),(0,a.jsx)("div",{className:"h-3 w-32 bg-[var(--surface-100)] rounded"})]},e))}):e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(c.Z,{size:16}),(0,a.jsx)("span",{children:"Exact Cache"})]}),(0,a.jsx)("div",{className:"text-2xl font-bold text-white mb-1",children:e.exact_count}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:u(e.exact_size_bytes)})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(l.Z,{size:16}),(0,a.jsx)("span",{children:"Semantic Cache"})]}),(0,a.jsx)("div",{className:"text-2xl font-bold text-white mb-1",children:e.semantic_count}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:u(e.semantic_size_bytes)})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(o,{size:16}),(0,a.jsx)("span",{children:"Hit Rate"})]}),(0,a.jsxs)("div",{className:"text-2xl font-bold text-white mb-1",children:[(100*e.hit_rate).toFixed(1),"%"]}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:"Cache efficiency"})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-sm mb-3",children:[(0,a.jsx)(s.Z,{size:16}),(0,a.jsx)("span",{children:"TTL"})]}),(0,a.jsxs)("div",{className:"text-2xl font-bold text-white mb-1",children:[e.ttl,"s"]}),(0,a.jsx)("div",{className:"text-xs text-[var(--text-tertiary)]",children:"Cache expiry"})]})]}),(0,a.jsxs)("div",{className:"card p-6",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-white mb-4",children:"Clear Cache"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,a.jsxs)("button",{className:"btn-secondary",onClick:()=>y("exact","Exact Cache","/api/cache/exact"),disabled:null!==m,children:[(0,a.jsx)(d.Z,{size:16}),"exact"===m?"Clearing...":"Clear Exact Cache"]}),(0,a.jsxs)("button",{className:"btn-secondary",onClick:()=>y("semantic","Semantic Cache","/api/cache/semantic"),disabled:null!==m,children:[(0,a.jsx)(d.Z,{size:16}),"semantic"===m?"Clearing...":"Clear Semantic Cache"]}),(0,a.jsxs)("button",{className:"btn-danger",onClick:()=>y("all","All Cache","/api/cache/clear"),disabled:null!==m,children:[(0,a.jsx)(d.Z,{size:16}),"all"===m?"Clearing...":"Clear All Cache"]})]})]})]}):null]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return s},qz:function(){return i}});let a=r(257).env.NEXT_PUBLIC_API_BASE||"";function n(){return localStorage.getItem("nexus_token")}function i(){localStorage.removeItem("nexus_token")}function s(){return!!n()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",s=n(),d={"Content-Type":"application/json",...t.headers};if(s&&(d.Authorization="Bearer ".concat(s)),"GET"===r&&!s){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=o.get(e);if(r)return r}let u=(async()=>{let n=await fetch("".concat(a).concat(e),{method:r,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return n;if(401===n.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!n.ok)throw Error((await n.json().catch(()=>({detail:n.statusText}))).detail||"HTTP ".concat(n.status));if(204===n.status)return;let c=await n.json();return"GET"!==r||s||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===r&&!s){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var r;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=a.access_token,localStorage.setItem("nexus_token",r),a},getMe:()=>d("/api/auth/me"),logout:()=>{i(),l.clear(),window.location.href="/login"}},h=async e=>{let t=n(),r=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let i=await r.blob(),s=URL.createObjectURL(i),c=document.createElement("a");c.href=s,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=6977)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/chat/page-eccb2a38589380fd.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1929],{2468:function(e,t,n){Promise.resolve().then(n.bind(n,628))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var a=n(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),r=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var l={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,a.forwardRef)((e,t)=>{let{color:n="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:o,className:c="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...l,width:s,height:s,stroke:n,strokeWidth:o?24*Number(i)/Number(s):i,className:r("lucide",c),...h},[...u.map(e=>{let[t,n]=e;return(0,a.createElement)(t,n)}),...Array.isArray(d)?d:[d]])}),o=(e,t)=>{let n=(0,a.forwardRef)((n,l)=>{let{className:o,...c}=n;return(0,a.createElement)(i,{ref:l,iconNode:t,className:r("lucide-".concat(s(e)),o),...c})});return n.displayName="".concat(e),n}},4743:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},8930:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,n){"use strict";var a,s;e.exports=(null==(a=n.g.process)?void 0:a.env)&&"object"==typeof(null==(s=n.g.process)?void 0:s.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,a,s=e.exports={};function r(){throw Error("setTimeout has not been defined")}function l(){throw Error("clearTimeout has not been defined")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===r||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:r}catch(e){t=r}try{n="function"==typeof clearTimeout?clearTimeout:l}catch(e){n=l}}();var o=[],c=!1,d=-1;function u(){c&&a&&(c=!1,a.length?o=a.concat(o):d=-1,o.length&&h())}function h(){if(!c){var e=i(u);c=!0;for(var t=o.length;t;){for(a=o,o=[];++d<t;)a&&a[d].run();d=-1,t=o.length}a=null,c=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===l||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];o.push(new m(e,t)),1!==o.length||c||i(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=p,s.addListener=p,s.once=p,s.off=p,s.removeListener=p,s.removeAllListeners=p,s.emit=p,s.prependListener=p,s.prependOnceListener=p,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},n={};function a(e){var s=n[e];if(void 0!==s)return s.exports;var r=n[e]={exports:{}},l=!0;try{t[e](r,r.exports,a),l=!1}finally{l&&delete n[e]}return r.exports}a.ab="//";var s=a(229);e.exports=s}()},628:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return o}});var a=n(7437),s=n(2265),r=n(1837),l=n(4743),i=n(8930);function o(){let[e,t]=(0,s.useState)("chat"),[n,o]=(0,s.useState)("gpt-4o"),[c,d]=(0,s.useState)(""),[u,h]=(0,s.useState)(""),[m,p]=(0,s.useState)("Hello! Respond in exactly 2 sentences."),[x,f]=(0,s.useState)(256),[v,g]=(0,s.useState)(.7),[b,y]=(0,s.useState)('{"model":"claude-3-haiku-20240307","max_tokens":256,"messages":[{"role":"user","content":"Say hello."}]}'),[j,w]=(0,s.useState)("text-embedding-3-small"),[N,k]=(0,s.useState)("NexusAI Gateway is amazing!"),[S,T]=(0,s.useState)("openai"),[C,_]=(0,s.useState)([]),[E,O]=(0,s.useState)(""),[A,L]=(0,s.useState)(null),[P,z]=(0,s.useState)(!1),[D,M]=(0,s.useState)(!1),[R,I]=(0,s.useState)([]),J=(0,s.useRef)(null);(0,s.useEffect)(()=>{r.hi.get("/v1/models").then(e=>{let t=e.data.map(e=>e.id).sort();_(t),t.length>0&&!n&&o(t[0])}).catch(()=>{}),r.hi.get("/api/providers").then(e=>I(Object.keys(e))).catch(()=>{})},[]),(0,s.useEffect)(()=>{var e;null===(e=J.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[E]);let F=()=>localStorage.getItem("nexus_token"),Z=async()=>{let e=m.trim();if(!n||!e)return;M(!0),O(""),L(null),z(!1);let t=[];u.trim()&&t.push({role:"system",content:u.trim()}),t.push({role:"user",content:e});let a={model:n,messages:t,max_tokens:x,temperature:v};c&&(a.provider=c);let s=F(),r=Date.now();try{var l,i,o,d,h;let e=await fetch("/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",...s?{Authorization:"Bearer ".concat(s)}:{}},body:JSON.stringify(a)}),t=Date.now()-r;if(L(t),z(!e.ok),!e.ok){let t=await e.text();try{let e=JSON.parse(t);O(JSON.stringify(e,null,2))}catch(e){O(t)}return}let c=await e.json(),u=(null===(o=c.choices)||void 0===o?void 0:null===(i=o[0])||void 0===i?void 0:null===(l=i.message)||void 0===l?void 0:l.content)||"(no content)",m=c.x_nexus||{};O("Provider: ".concat(m.provider||"?","\n")+"Model Used: ".concat(m.model_used||n,"\n")+"Key: ".concat(m.key_name||"?","\n")+"Tokens: ".concat((null===(d=c.usage)||void 0===d?void 0:d.prompt_tokens)||0," in / ").concat((null===(h=c.usage)||void 0===h?void 0:h.completion_tokens)||0," out\n")+"Cost: $".concat(m.cost_usd?Number(m.cost_usd).toFixed(6):"0.000000","\n")+"Latency: ".concat(m.latency_ms||t,"ms\n")+"Fallbacks: ".concat(m.fallback_count||0,"\n")+"Injection: ".concat(m.injection_flagged?"FLAGGED":"clean","\n")+"".concat(m.ab_test_id?"A/B: #".concat(m.ab_test_id," Variant ").concat(m.ab_variant):"","\n")+"".concat("-".repeat(40),"\n")+"".concat(u))}catch(e){L(Date.now()-r),z(!0),O(String(e))}finally{M(!1)}},B=async()=>{let e;M(!0),O(""),L(null),z(!1);try{e=JSON.parse(b)}catch(e){O("Invalid JSON"),M(!1);return}let t=F(),n=Date.now();try{let a=await fetch("/v1/messages",{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:"Bearer ".concat(t)}:{}},body:JSON.stringify(e)}),s=Date.now()-n;L(s),z(!a.ok);let r=await a.json();O(JSON.stringify(r,null,2))}catch(e){L(Date.now()-n),z(!0),O(String(e))}finally{M(!1)}},U=async()=>{M(!0),O(""),L(null),z(!1);let e=F(),t=Date.now();try{var n;let a=await fetch("/v1/embeddings",{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:"Bearer ".concat(e)}:{}},body:JSON.stringify({model:j,input:N,provider:S})}),s=Date.now()-t;L(s),z(!a.ok);let r=await a.json();if(null===(n=r.data)||void 0===n?void 0:n[0]){let e=r.data[0].embedding;O("Embedding received!\nDimensions: ".concat(e.length,"\nFirst 5: [").concat(e.slice(0,5).map(e=>e.toFixed(6)).join(", "),"]\nModel: ").concat(r.model))}else O(JSON.stringify(r,null,2))}catch(e){L(Date.now()-t),z(!0),O(String(e))}finally{M(!1)}};return(0,a.jsxs)("div",{className:"flex flex-col h-[calc(100vh-6rem)]",children:[(0,a.jsx)("div",{className:"page-header flex-shrink-0",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"page-title",children:"Proxy Test"}),(0,a.jsx)("p",{className:"page-sub",children:"Live endpoint testing with model autocomplete"})]})}),(0,a.jsxs)("div",{className:"flex gap-1 bg-[var(--surface-100)] p-1 rounded-lg w-fit mb-4",children:[(0,a.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium transition-all ".concat("chat"===e?"bg-[var(--surface)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-white"),onClick:()=>t("chat"),children:"Chat"}),(0,a.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium transition-all ".concat("native"===e?"bg-[var(--surface)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-white"),onClick:()=>t("native"),children:"Anthropic"}),(0,a.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium transition-all ".concat("embed"===e?"bg-[var(--surface)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-white"),onClick:()=>t("embed"),children:"Embeddings"})]}),(0,a.jsxs)("div",{className:"flex-1 flex gap-4 min-h-0",children:[(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-4 overflow-y-auto",children:["chat"===e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("label",{className:"label !mb-0",children:"Model"}),(0,a.jsx)("button",{className:"btn-ghost btn-xs",onClick:()=>{r.hi.get("/v1/models").then(e=>{_(e.data.map(e=>e.id).sort())}).catch(()=>{})},children:"Refresh Models"})]}),(0,a.jsx)("input",{className:"input",list:"model-datalist",value:n,onChange:e=>o(e.target.value),placeholder:"gpt-4o, claude-sonnet-4-6, ..."}),(0,a.jsx)("datalist",{id:"model-datalist",children:C.map(e=>(0,a.jsx)("option",{value:e},e))})]}),(0,a.jsx)("div",{className:"card",children:(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Provider Override"}),(0,a.jsxs)("select",{className:"select",value:c,onChange:e=>d(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Auto-detect"}),R.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Max Tokens"}),(0,a.jsx)("input",{className:"input",type:"number",value:x,onChange:e=>f(parseInt(e.target.value)||256)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Temperature"}),(0,a.jsx)("input",{className:"input",type:"number",step:"0.1",value:v,onChange:e=>g(parseFloat(e.target.value)||.7)})]})]})]})}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"System Prompt"}),(0,a.jsx)("textarea",{className:"input !min-h-[60px]",rows:2,value:u,onChange:e=>h(e.target.value),placeholder:"Optional"})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"User Message"}),(0,a.jsx)("textarea",{className:"input !min-h-[80px]",rows:3,value:m,onChange:e=>p(e.target.value)})]}),(0,a.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:Z,disabled:D||!n||!m.trim(),children:[D?(0,a.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(l.Z,{size:16}),D?" Sending...":" Send"]})]}),"native"===e&&(0,a.jsxs)("div",{className:"card flex flex-col gap-4",children:[(0,a.jsx)("label",{className:"label",children:"Request JSON"}),(0,a.jsx)("textarea",{className:"input font-mono text-xs !min-h-[300px]",rows:12,value:b,onChange:e=>y(e.target.value)}),(0,a.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:B,disabled:D,children:[D?(0,a.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(l.Z,{size:16}),D?" Sending...":" Send"]})]}),"embed"===e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"Model"}),(0,a.jsx)("input",{className:"input",value:j,onChange:e=>w(e.target.value)})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"Input"}),(0,a.jsx)("textarea",{className:"input !min-h-[80px]",rows:3,value:N,onChange:e=>k(e.target.value)})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"Provider"}),(0,a.jsxs)("select",{className:"select",value:S,onChange:e=>T(e.target.value),children:[R.map(e=>(0,a.jsx)("option",{value:e,children:e},e)),0===R.length&&(0,a.jsx)("option",{value:"openai",children:"openai"})]})]}),(0,a.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:U,disabled:D,children:[D?(0,a.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(l.Z,{size:16}),D?" Sending...":" Send"]})]})]}),(0,a.jsx)("div",{className:"w-[480px] flex flex-col",children:(0,a.jsxs)("div",{className:"card flex-1 flex flex-col",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsx)("span",{className:"text-sm font-semibold",children:"Response"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[null!==A&&(0,a.jsxs)("span",{className:"badge ".concat(P?"badge-red":"badge-green"),children:[P?"ERR":"OK"," ",A,"ms"]}),(0,a.jsx)("button",{className:"btn-ghost btn-xs",onClick:()=>{O(""),L(null),z(!1)},children:(0,a.jsx)(i.Z,{size:14})})]})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto font-mono text-xs whitespace-pre-wrap text-[var(--text-secondary)] leading-relaxed",children:E||(0,a.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"Send a request to see the response"})})]})})]}),(0,a.jsx)("div",{ref:J})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return l},qz:function(){return r}});let a=n(257).env.NEXT_PUBLIC_API_BASE||"";function s(){return localStorage.getItem("nexus_token")}function r(){localStorage.removeItem("nexus_token")}function l(){return!!s()}let i={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,c=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",l=s(),d={"Content-Type":"application/json",...t.headers};if(l&&(d.Authorization="Bearer ".concat(l)),"GET"===n&&!l){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in i)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return i[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=c.get(e);if(n)return n}let u=(async()=>{let s=await fetch("".concat(a).concat(e),{method:n,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&l&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw r(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let i=await s.json();return"GET"!==n||l||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,i),i})();if("GET"===n&&!l){c.set(e,u);try{return await u}finally{c.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var n;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=a.access_token,localStorage.setItem("nexus_token",n),a},getMe:()=>d("/api/auth/me"),logout:()=>{r(),o.clear(),window.location.href="/login"}},h=async e=>{let t=s(),n=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let r=await n.blob(),l=URL.createObjectURL(r),i=document.createElement("a");i.href=l,i.download=e.split("/").pop()||"export.csv",i.click(),URL.revokeObjectURL(l)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=2468)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/chat/{page-ba53668baba0967f.js → page-fd7d09a808f0f08f.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1929],{2468:function(e,t,n){Promise.resolve().then(n.bind(n,628))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var a=n(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),r=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var l={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,a.forwardRef)((e,t)=>{let{color:n="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:o,className:c="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...l,width:s,height:s,stroke:n,strokeWidth:o?24*Number(i)/Number(s):i,className:r("lucide",c),...h},[...u.map(e=>{let[t,n]=e;return(0,a.createElement)(t,n)}),...Array.isArray(d)?d:[d]])}),o=(e,t)=>{let n=(0,a.forwardRef)((n,l)=>{let{className:o,...c}=n;return(0,a.createElement)(i,{ref:l,iconNode:t,className:r("lucide-".concat(s(e)),o),...c})});return n.displayName="".concat(e),n}},4743:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},8930:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,n){"use strict";var a,s;e.exports=(null==(a=n.g.process)?void 0:a.env)&&"object"==typeof(null==(s=n.g.process)?void 0:s.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,a,s=e.exports={};function r(){throw Error("setTimeout has not been defined")}function l(){throw Error("clearTimeout has not been defined")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===r||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:r}catch(e){t=r}try{n="function"==typeof clearTimeout?clearTimeout:l}catch(e){n=l}}();var o=[],c=!1,d=-1;function u(){c&&a&&(c=!1,a.length?o=a.concat(o):d=-1,o.length&&h())}function h(){if(!c){var e=i(u);c=!0;for(var t=o.length;t;){for(a=o,o=[];++d<t;)a&&a[d].run();d=-1,t=o.length}a=null,c=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===l||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];o.push(new m(e,t)),1!==o.length||c||i(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=p,s.addListener=p,s.once=p,s.off=p,s.removeListener=p,s.removeAllListeners=p,s.emit=p,s.prependListener=p,s.prependOnceListener=p,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},n={};function a(e){var s=n[e];if(void 0!==s)return s.exports;var r=n[e]={exports:{}},l=!0;try{t[e](r,r.exports,a),l=!1}finally{l&&delete n[e]}return r.exports}a.ab="//";var s=a(229);e.exports=s}()},628:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return o}});var a=n(7437),s=n(2265),r=n(1837),l=n(4743),i=n(8930);function o(){let[e,t]=(0,s.useState)("chat"),[n,o]=(0,s.useState)("gpt-4o"),[c,d]=(0,s.useState)(""),[u,h]=(0,s.useState)(""),[m,p]=(0,s.useState)("Hello! Respond in exactly 2 sentences."),[x,f]=(0,s.useState)(256),[v,g]=(0,s.useState)(.7),[b,y]=(0,s.useState)('{"model":"claude-3-haiku-20240307","max_tokens":256,"messages":[{"role":"user","content":"Say hello."}]}'),[j,w]=(0,s.useState)("text-embedding-3-small"),[N,k]=(0,s.useState)("NexusAI Gateway is amazing!"),[S,T]=(0,s.useState)("openai"),[C,_]=(0,s.useState)([]),[E,O]=(0,s.useState)(""),[A,L]=(0,s.useState)(null),[P,z]=(0,s.useState)(!1),[D,M]=(0,s.useState)(!1),[R,I]=(0,s.useState)([]),J=(0,s.useRef)(null);(0,s.useEffect)(()=>{r.hi.get("/v1/models").then(e=>{let t=e.data.map(e=>e.id).sort();_(t),t.length>0&&!n&&o(t[0])}).catch(()=>{}),r.hi.get("/api/providers").then(e=>I(Object.keys(e))).catch(()=>{})},[]),(0,s.useEffect)(()=>{var e;null===(e=J.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[E]);let F=()=>localStorage.getItem("nexus_token"),Z=async()=>{let e=m.trim();if(!n||!e)return;M(!0),O(""),L(null),z(!1);let t=[];u.trim()&&t.push({role:"system",content:u.trim()}),t.push({role:"user",content:e});let a={model:n,messages:t,max_tokens:x,temperature:v};c&&(a.provider=c);let s=F(),r=Date.now();try{var l,i,o,d,h;let e=await fetch("/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",...s?{Authorization:"Bearer ".concat(s)}:{}},body:JSON.stringify(a)}),t=Date.now()-r;if(L(t),z(!e.ok),!e.ok){let t=await e.text();try{let e=JSON.parse(t);O(JSON.stringify(e,null,2))}catch(e){O(t)}return}let c=await e.json(),u=(null===(o=c.choices)||void 0===o?void 0:null===(i=o[0])||void 0===i?void 0:null===(l=i.message)||void 0===l?void 0:l.content)||"(no content)",m=c.x_nexus||{};O("Provider: ".concat(m.provider||"?","\n")+"Model Used: ".concat(m.model_used||n,"\n")+"Key: ".concat(m.key_name||"?","\n")+"Tokens: ".concat((null===(d=c.usage)||void 0===d?void 0:d.prompt_tokens)||0," in / ").concat((null===(h=c.usage)||void 0===h?void 0:h.completion_tokens)||0," out\n")+"Cost: $".concat(m.cost_usd?Number(m.cost_usd).toFixed(6):"0.000000","\n")+"Latency: ".concat(m.latency_ms||t,"ms\n")+"Fallbacks: ".concat(m.fallback_count||0,"\n")+"Injection: ".concat(m.injection_flagged?"FLAGGED":"clean","\n")+"".concat(m.ab_test_id?"A/B: #".concat(m.ab_test_id," Variant ").concat(m.ab_variant):"","\n")+"".concat("-".repeat(40),"\n")+"".concat(u))}catch(e){L(Date.now()-r),z(!0),O(String(e))}finally{M(!1)}},B=async()=>{let e;M(!0),O(""),L(null),z(!1);try{e=JSON.parse(b)}catch(e){O("Invalid JSON"),M(!1);return}let t=F(),n=Date.now();try{let a=await fetch("/v1/messages",{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:"Bearer ".concat(t)}:{}},body:JSON.stringify(e)}),s=Date.now()-n;L(s),z(!a.ok);let r=await a.json();O(JSON.stringify(r,null,2))}catch(e){L(Date.now()-n),z(!0),O(String(e))}finally{M(!1)}},U=async()=>{M(!0),O(""),L(null),z(!1);let e=F(),t=Date.now();try{var n;let a=await fetch("/v1/embeddings",{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:"Bearer ".concat(e)}:{}},body:JSON.stringify({model:j,input:N,provider:S})}),s=Date.now()-t;L(s),z(!a.ok);let r=await a.json();if(null===(n=r.data)||void 0===n?void 0:n[0]){let e=r.data[0].embedding;O("Embedding received!\nDimensions: ".concat(e.length,"\nFirst 5: [").concat(e.slice(0,5).map(e=>e.toFixed(6)).join(", "),"]\nModel: ").concat(r.model))}else O(JSON.stringify(r,null,2))}catch(e){L(Date.now()-t),z(!0),O(String(e))}finally{M(!1)}};return(0,a.jsxs)("div",{className:"flex flex-col h-[calc(100vh-6rem)]",children:[(0,a.jsx)("div",{className:"page-header flex-shrink-0",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"page-title",children:"Proxy Test"}),(0,a.jsx)("p",{className:"page-sub",children:"Live endpoint testing with model autocomplete"})]})}),(0,a.jsxs)("div",{className:"flex gap-1 bg-[var(--surface-100)] p-1 rounded-lg w-fit mb-4",children:[(0,a.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium transition-all ".concat("chat"===e?"bg-[var(--surface)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-white"),onClick:()=>t("chat"),children:"Chat"}),(0,a.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium transition-all ".concat("native"===e?"bg-[var(--surface)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-white"),onClick:()=>t("native"),children:"Anthropic"}),(0,a.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium transition-all ".concat("embed"===e?"bg-[var(--surface)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-white"),onClick:()=>t("embed"),children:"Embeddings"})]}),(0,a.jsxs)("div",{className:"flex-1 flex gap-4 min-h-0",children:[(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-4 overflow-y-auto",children:["chat"===e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("label",{className:"label !mb-0",children:"Model"}),(0,a.jsx)("button",{className:"btn-ghost btn-xs",onClick:()=>{r.hi.get("/v1/models").then(e=>{_(e.data.map(e=>e.id).sort())}).catch(()=>{})},children:"Refresh Models"})]}),(0,a.jsx)("input",{className:"input",list:"model-datalist",value:n,onChange:e=>o(e.target.value),placeholder:"gpt-4o, claude-sonnet-4-6, ..."}),(0,a.jsx)("datalist",{id:"model-datalist",children:C.map(e=>(0,a.jsx)("option",{value:e},e))})]}),(0,a.jsx)("div",{className:"card",children:(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Provider Override"}),(0,a.jsxs)("select",{className:"select",value:c,onChange:e=>d(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Auto-detect"}),R.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Max Tokens"}),(0,a.jsx)("input",{className:"input",type:"number",value:x,onChange:e=>f(parseInt(e.target.value)||256)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Temperature"}),(0,a.jsx)("input",{className:"input",type:"number",step:"0.1",value:v,onChange:e=>g(parseFloat(e.target.value)||.7)})]})]})]})}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"System Prompt"}),(0,a.jsx)("textarea",{className:"input !min-h-[60px]",rows:2,value:u,onChange:e=>h(e.target.value),placeholder:"Optional"})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"User Message"}),(0,a.jsx)("textarea",{className:"input !min-h-[80px]",rows:3,value:m,onChange:e=>p(e.target.value)})]}),(0,a.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:Z,disabled:D||!n||!m.trim(),children:[D?(0,a.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(l.Z,{size:16}),D?" Sending...":" Send"]})]}),"native"===e&&(0,a.jsxs)("div",{className:"card flex flex-col gap-4",children:[(0,a.jsx)("label",{className:"label",children:"Request JSON"}),(0,a.jsx)("textarea",{className:"input font-mono text-xs !min-h-[300px]",rows:12,value:b,onChange:e=>y(e.target.value)}),(0,a.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:B,disabled:D,children:[D?(0,a.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(l.Z,{size:16}),D?" Sending...":" Send"]})]}),"embed"===e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"Model"}),(0,a.jsx)("input",{className:"input",value:j,onChange:e=>w(e.target.value)})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"Input"}),(0,a.jsx)("textarea",{className:"input !min-h-[80px]",rows:3,value:N,onChange:e=>k(e.target.value)})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"Provider"}),(0,a.jsxs)("select",{className:"select",value:S,onChange:e=>T(e.target.value),children:[R.map(e=>(0,a.jsx)("option",{value:e,children:e},e)),0===R.length&&(0,a.jsx)("option",{value:"openai",children:"openai"})]})]}),(0,a.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:U,disabled:D,children:[D?(0,a.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(l.Z,{size:16}),D?" Sending...":" Send"]})]})]}),(0,a.jsx)("div",{className:"w-[480px] flex flex-col",children:(0,a.jsxs)("div",{className:"card flex-1 flex flex-col",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsx)("span",{className:"text-sm font-semibold",children:"Response"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[null!==A&&(0,a.jsxs)("span",{className:"badge ".concat(P?"badge-red":"badge-green"),children:[P?"ERR":"OK"," ",A,"ms"]}),(0,a.jsx)("button",{className:"btn-ghost btn-xs",onClick:()=>{O(""),L(null),z(!1)},children:(0,a.jsx)(i.Z,{size:14})})]})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto font-mono text-xs whitespace-pre-wrap text-[var(--text-secondary)] leading-relaxed",children:E||(0,a.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"Send a request to see the response"})})]})})]}),(0,a.jsx)("div",{ref:J})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return l},qz:function(){return r}});let a=n(257).env.NEXT_PUBLIC_API_BASE||"";function s(){return localStorage.getItem("nexus_token")}function r(){localStorage.removeItem("nexus_token")}function l(){return!!s()}let i={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,c=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",l=s(),d={"Content-Type":"application/json",...t.headers};if(l&&(d.Authorization="Bearer ".concat(l)),"GET"===n&&!l){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in i)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return i[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=c.get(e);if(n)return n}let u=(async()=>{let s=await fetch("".concat(a).concat(e),{method:n,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&l&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw r(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let i=await s.json();return"GET"!==n||l||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,i),i})();if("GET"===n&&!l){c.set(e,u);try{return await u}finally{c.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var n;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=a.access_token,localStorage.setItem("nexus_token",n),a},getMe:()=>d("/api/auth/me"),logout:()=>{r(),o.clear(),window.location.href="/login"}},h=async e=>{let t=s(),n=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let r=await n.blob(),l=URL.createObjectURL(r),i=document.createElement("a");i.href=l,i.download=e.split("/").pop()||"export.csv",i.click(),URL.revokeObjectURL(l)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=2468)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1929],{2468:function(e,t,n){Promise.resolve().then(n.bind(n,628))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var a=n(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),r=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var o={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,a.forwardRef)((e,t)=>{let{color:n="currentColor",size:s=24,strokeWidth:l=2,absoluteStrokeWidth:i,className:c="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...o,width:s,height:s,stroke:n,strokeWidth:i?24*Number(l)/Number(s):l,className:r("lucide",c),...h},[...u.map(e=>{let[t,n]=e;return(0,a.createElement)(t,n)}),...Array.isArray(d)?d:[d]])}),i=(e,t)=>{let n=(0,a.forwardRef)((n,o)=>{let{className:i,...c}=n;return(0,a.createElement)(l,{ref:o,iconNode:t,className:r("lucide-".concat(s(e)),i),...c})});return n.displayName="".concat(e),n}},4743:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},8930:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,n){"use strict";var a,s;e.exports=(null==(a=n.g.process)?void 0:a.env)&&"object"==typeof(null==(s=n.g.process)?void 0:s.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,a,s=e.exports={};function r(){throw Error("setTimeout has not been defined")}function o(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===r||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:r}catch(e){t=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(e){n=o}}();var i=[],c=!1,d=-1;function u(){c&&a&&(c=!1,a.length?i=a.concat(i):d=-1,i.length&&h())}function h(){if(!c){var e=l(u);c=!0;for(var t=i.length;t;){for(a=i,i=[];++d<t;)a&&a[d].run();d=-1,t=i.length}a=null,c=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];i.push(new m(e,t)),1!==i.length||c||l(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=p,s.addListener=p,s.once=p,s.off=p,s.removeListener=p,s.removeAllListeners=p,s.emit=p,s.prependListener=p,s.prependOnceListener=p,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},n={};function a(e){var s=n[e];if(void 0!==s)return s.exports;var r=n[e]={exports:{}},o=!0;try{t[e](r,r.exports,a),o=!1}finally{o&&delete n[e]}return r.exports}a.ab="//";var s=a(229);e.exports=s}()},628:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return i}});var a=n(7437),s=n(2265),r=n(1837),o=n(4743),l=n(8930);function i(){let[e,t]=(0,s.useState)("chat"),[n,i]=(0,s.useState)("gpt-4o"),[c,d]=(0,s.useState)(""),[u,h]=(0,s.useState)(""),[m,p]=(0,s.useState)("Hello! Respond in exactly 2 sentences."),[x,f]=(0,s.useState)(256),[v,g]=(0,s.useState)(.7),[y,b]=(0,s.useState)('{"model":"claude-3-haiku-20240307","max_tokens":256,"messages":[{"role":"user","content":"Say hello."}]}'),[j,w]=(0,s.useState)("text-embedding-3-small"),[N,k]=(0,s.useState)("NexusAI Gateway is amazing!"),[S,T]=(0,s.useState)("openai"),[_,C]=(0,s.useState)([]),[E,O]=(0,s.useState)(""),[A,L]=(0,s.useState)(null),[P,R]=(0,s.useState)(!1),[z,D]=(0,s.useState)(!1),[I,M]=(0,s.useState)([]),J=(0,s.useRef)(null);(0,s.useEffect)(()=>{r.hi.get("/v1/models").then(e=>{let t=e.data.map(e=>e.id).sort();C(t),t.length>0&&!n&&i(t[0])}).catch(()=>{}),r.hi.get("/api/providers").then(e=>M(Object.keys(e))).catch(()=>{})},[]),(0,s.useEffect)(()=>{var e;null===(e=J.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[E]);let F=()=>localStorage.getItem("nexus_token"),U=async()=>{let e=m.trim();if(!n||!e)return;D(!0),O(""),L(null),R(!1);let t=[];u.trim()&&t.push({role:"system",content:u.trim()}),t.push({role:"user",content:e});let a={model:n,messages:t,max_tokens:x,temperature:v};c&&(a.provider=c);let s=F(),r=Date.now();try{var o,l,i,d,h;let e=await fetch("/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",...s?{Authorization:"Bearer ".concat(s)}:{}},body:JSON.stringify(a)}),t=Date.now()-r;if(L(t),R(!e.ok),!e.ok){let t=await e.text();try{let e=JSON.parse(t);O(JSON.stringify(e,null,2))}catch(e){O(t)}return}let c=await e.json(),u=(null===(i=c.choices)||void 0===i?void 0:null===(l=i[0])||void 0===l?void 0:null===(o=l.message)||void 0===o?void 0:o.content)||"(no content)",m=c.x_nexus||{};O("Provider: ".concat(m.provider||"?","\n")+"Model Used: ".concat(m.model_used||n,"\n")+"Key: ".concat(m.key_name||"?","\n")+"Tokens: ".concat((null===(d=c.usage)||void 0===d?void 0:d.prompt_tokens)||0," in / ").concat((null===(h=c.usage)||void 0===h?void 0:h.completion_tokens)||0," out\n")+"Cost: $".concat(m.cost_usd?Number(m.cost_usd).toFixed(6):"0.000000","\n")+"Latency: ".concat(m.latency_ms||t,"ms\n")+"Fallbacks: ".concat(m.fallback_count||0,"\n")+"Injection: ".concat(m.injection_flagged?"FLAGGED":"clean","\n")+"".concat(m.ab_test_id?"A/B: #".concat(m.ab_test_id," Variant ").concat(m.ab_variant):"","\n")+"".concat("-".repeat(40),"\n")+"".concat(u))}catch(e){L(Date.now()-r),R(!0),O(String(e))}finally{D(!1)}},Z=async()=>{let e;D(!0),O(""),L(null),R(!1);try{e=JSON.parse(y)}catch(e){O("Invalid JSON"),D(!1);return}let t=F(),n=Date.now();try{let a=await fetch("/v1/messages",{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:"Bearer ".concat(t)}:{}},body:JSON.stringify(e)}),s=Date.now()-n;L(s),R(!a.ok);let r=await a.json();O(JSON.stringify(r,null,2))}catch(e){L(Date.now()-n),R(!0),O(String(e))}finally{D(!1)}},B=async()=>{D(!0),O(""),L(null),R(!1);let e=F(),t=Date.now();try{var n;let a=await fetch("/v1/embeddings",{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:"Bearer ".concat(e)}:{}},body:JSON.stringify({model:j,input:N,provider:S})}),s=Date.now()-t;L(s),R(!a.ok);let r=await a.json();if(null===(n=r.data)||void 0===n?void 0:n[0]){let e=r.data[0].embedding;O("Embedding received!\nDimensions: ".concat(e.length,"\nFirst 5: [").concat(e.slice(0,5).map(e=>e.toFixed(6)).join(", "),"]\nModel: ").concat(r.model))}else O(JSON.stringify(r,null,2))}catch(e){L(Date.now()-t),R(!0),O(String(e))}finally{D(!1)}};return(0,a.jsxs)("div",{className:"flex flex-col h-[calc(100vh-6rem)]",children:[(0,a.jsx)("div",{className:"page-header flex-shrink-0",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"page-title",children:"Proxy Test"}),(0,a.jsx)("p",{className:"page-sub",children:"Live endpoint testing with model autocomplete"})]})}),(0,a.jsxs)("div",{className:"flex gap-1 bg-[var(--surface-100)] p-1 rounded-lg w-fit mb-4",children:[(0,a.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium transition-all ".concat("chat"===e?"bg-[var(--surface)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-white"),onClick:()=>t("chat"),children:"Chat"}),(0,a.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium transition-all ".concat("native"===e?"bg-[var(--surface)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-white"),onClick:()=>t("native"),children:"Anthropic"}),(0,a.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium transition-all ".concat("embed"===e?"bg-[var(--surface)] text-white shadow-sm":"text-[var(--text-secondary)] hover:text-white"),onClick:()=>t("embed"),children:"Embeddings"})]}),(0,a.jsxs)("div",{className:"flex-1 flex gap-4 min-h-0",children:[(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-4 overflow-y-auto",children:["chat"===e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("label",{className:"label !mb-0",children:"Model"}),(0,a.jsx)("button",{className:"btn-ghost btn-xs",onClick:()=>{r.hi.get("/v1/models").then(e=>{C(e.data.map(e=>e.id).sort())}).catch(()=>{})},children:"Refresh Models"})]}),(0,a.jsx)("input",{className:"input",list:"model-datalist",value:n,onChange:e=>i(e.target.value),placeholder:"gpt-4o, claude-sonnet-4-6, ..."}),(0,a.jsx)("datalist",{id:"model-datalist",children:_.map(e=>(0,a.jsx)("option",{value:e},e))})]}),(0,a.jsx)("div",{className:"card",children:(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Provider Override"}),(0,a.jsxs)("select",{className:"select",value:c,onChange:e=>d(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Auto-detect"}),I.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Max Tokens"}),(0,a.jsx)("input",{className:"input",type:"number",value:x,onChange:e=>f(parseInt(e.target.value)||256)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Temperature"}),(0,a.jsx)("input",{className:"input",type:"number",step:"0.1",value:v,onChange:e=>g(parseFloat(e.target.value)||.7)})]})]})]})}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"System Prompt"}),(0,a.jsx)("textarea",{className:"input !min-h-[60px]",rows:2,value:u,onChange:e=>h(e.target.value),placeholder:"Optional"})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"User Message"}),(0,a.jsx)("textarea",{className:"input !min-h-[80px]",rows:3,value:m,onChange:e=>p(e.target.value)})]}),(0,a.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:U,disabled:z||!n||!m.trim(),children:[z?(0,a.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(o.Z,{size:16}),z?" Sending...":" Send"]})]}),"native"===e&&(0,a.jsxs)("div",{className:"card flex flex-col gap-4",children:[(0,a.jsx)("label",{className:"label",children:"Request JSON"}),(0,a.jsx)("textarea",{className:"input font-mono text-xs !min-h-[300px]",rows:12,value:y,onChange:e=>b(e.target.value)}),(0,a.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:Z,disabled:z,children:[z?(0,a.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(o.Z,{size:16}),z?" Sending...":" Send"]})]}),"embed"===e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"Model"}),(0,a.jsx)("input",{className:"input",value:j,onChange:e=>w(e.target.value)})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"Input"}),(0,a.jsx)("textarea",{className:"input !min-h-[80px]",rows:3,value:N,onChange:e=>k(e.target.value)})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsx)("label",{className:"label",children:"Provider"}),(0,a.jsxs)("select",{className:"select",value:S,onChange:e=>T(e.target.value),children:[I.map(e=>(0,a.jsx)("option",{value:e,children:e},e)),0===I.length&&(0,a.jsx)("option",{value:"openai",children:"openai"})]})]}),(0,a.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:B,disabled:z,children:[z?(0,a.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(o.Z,{size:16}),z?" Sending...":" Send"]})]})]}),(0,a.jsx)("div",{className:"w-[480px] flex flex-col",children:(0,a.jsxs)("div",{className:"card flex-1 flex flex-col",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsx)("span",{className:"text-sm font-semibold",children:"Response"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[null!==A&&(0,a.jsxs)("span",{className:"badge ".concat(P?"badge-red":"badge-green"),children:[P?"ERR":"OK"," ",A,"ms"]}),(0,a.jsx)("button",{className:"btn-ghost btn-xs",onClick:()=>{O(""),L(null),R(!1)},children:(0,a.jsx)(l.Z,{size:14})})]})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto font-mono text-xs whitespace-pre-wrap text-[var(--text-secondary)] leading-relaxed",children:E||(0,a.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"Send a request to see the response"})})]})})]}),(0,a.jsx)("div",{ref:J})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return o},qz:function(){return r}});let a=n(257).env.NEXT_PUBLIC_API_BASE||"";function s(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function r(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function o(){return!!s()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},i=new Map,c=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",o=s(),d={"Content-Type":"application/json",...t.headers};if(o&&(d.Authorization="Bearer ".concat(o)),"GET"===n&&!o){let t=function(e){let t=i.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){i.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=c.get(e);if(n)return n}let u=(async()=>{let s=await fetch("".concat(a).concat(e),{method:n,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&o&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw r(),i.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let l=await s.json();return"GET"!==n||o||function(e,t){if(i.size>=200){let e=i.keys().next().value;void 0!==e&&i.delete(e)}i.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===n&&!o){c.set(e,u);try{return await u}finally{c.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var n;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=a.access_token,localStorage.setItem("nexus_token",n),function(e,t,n){try{let n="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(n)}catch(e){}}("nexus_token",n,0),a},getMe:()=>d("/api/auth/me"),logout:()=>{r(),i.clear(),window.location.href="/login"}},h=async e=>{let t=s(),n=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let r=await n.blob(),o=URL.createObjectURL(r),l=document.createElement("a");l.href=o,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(o)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=2468)}),_N_E=e.O()}]);
static/_next/static/chunks/app/code-interpreter/page-2365e842d504748d.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5866],{9671:function(e,t,r){Promise.resolve().then(r.bind(r,2763))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return l}});var n=r(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=24,strokeWidth:o=2,absoluteStrokeWidth:l,className:c="",children:u,iconNode:d,...f}=e;return(0,n.createElement)("svg",{ref:t,...i,width:a,height:a,stroke:r,strokeWidth:l?24*Number(o)/Number(a):o,className:s("lucide",c),...f},[...d.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(u)?u:[u]])}),l=(e,t)=>{let r=(0,n.forwardRef)((r,i)=>{let{className:l,...c}=r;return(0,n.createElement)(o,{ref:i,iconNode:t,className:s("lucide-".concat(a(e)),l),...c})});return r.displayName="".concat(e),r}},3276:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},7168:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},221:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]])},257:function(e,t,r){"use strict";var n,a;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(a=r.g.process)?void 0:a.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,a=e.exports={};function s(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var l=[],c=!1,u=-1;function d(){c&&n&&(c=!1,n.length?l=n.concat(l):u=-1,l.length&&f())}function f(){if(!c){var e=o(d);c=!0;for(var t=l.length;t;){for(n=l,l=[];++u<t;)n&&n[u].run();u=-1,t=l.length}n=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function p(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new h(e,t)),1!==l.length||c||o(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=p,a.addListener=p,a.once=p,a.off=p,a.removeListener=p,a.removeAllListeners=p,a.emit=p,a.prependListener=p,a.prependOnceListener=p,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var s=r[e]={exports:{}},i=!0;try{t[e](s,s.exports,n),i=!1}finally{i&&delete r[e]}return s.exports}n.ab="//";var a=n(229);e.exports=a}()},2763:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return u}});var n=r(7437),a=r(2265),s=r(1837),i=r(221),o=r(7168),l=r(3276);let c={ready:{label:"Ready",className:"badge-green"},error:{label:"Error",className:"badge-red"},starting:{label:"Starting",className:"badge-yellow"}};function u(){let[e,t]=(0,a.useState)(null),[r,u]=(0,a.useState)('# Enter your Python code here\nprint("Hello from NexusAI!")'),[d,f]=(0,a.useState)(null),[h,p]=(0,a.useState)(!0),[m,x]=(0,a.useState)(!1),[y,v]=(0,a.useState)(!1),[g,w]=(0,a.useState)(null),b=async()=>{p(!0),w(null);try{let e=await s.hi.get("/api/code-interpreter/status");t(e)}catch(e){w(String(e))}finally{p(!1)}};(0,a.useEffect)(()=>{b()},[]);let j=async()=>{x(!0),w(null);try{let e=await s.hi.post("/api/code-interpreter/restart");t(e)}catch(e){w(String(e))}finally{x(!1)}},N=async()=>{if(r.trim()){v(!0),f(null),w(null);try{let e=await s.hi.post("/api/code-interpreter/execute",{code:r});f(e)}catch(e){w(String(e))}finally{v(!1)}}},k=e?c[e.status]:null;return(0,n.jsxs)("div",{className:"flex flex-col h-[calc(100vh-6rem)]",children:[(0,n.jsx)("div",{className:"page-header flex-shrink-0",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Code Interpreter"}),(0,n.jsx)("p",{className:"page-sub",children:"Execute Python code in an isolated Jupyter kernel"})]})}),(0,n.jsxs)("div",{className:"flex-1 flex gap-4 min-h-0",children:[(0,n.jsxs)("div",{className:"flex-1 flex flex-col gap-4 overflow-y-auto",children:[(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(i.Z,{size:18}),(0,n.jsx)("span",{className:"text-sm font-semibold",children:"Kernel Status"}),h?(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):k?(0,n.jsx)("span",{className:"badge ".concat(k.className),children:k.label}):(0,n.jsx)("span",{className:"badge badge-red",children:"Offline"})]}),(0,n.jsxs)("button",{className:"btn-secondary btn-sm",onClick:j,disabled:m,children:[(0,n.jsx)(o.Z,{size:14,className:m?"animate-spin":""}),m?" Restarting...":" Restart Kernel"]})]}),e&&(0,n.jsxs)("div",{className:"text-xs text-[var(--text-secondary)] space-y-1",children:[e.kernel_id&&(0,n.jsxs)("p",{children:["Kernel: ",(0,n.jsx)("span",{className:"font-mono",children:e.kernel_id})]}),void 0!==e.uptime&&(0,n.jsxs)("p",{children:["Uptime: ",e.uptime,"s"]})]})]}),(0,n.jsxs)("div",{className:"card",children:[(0,n.jsx)("label",{className:"label",children:"Python Code"}),(0,n.jsx)("textarea",{className:"input font-mono text-xs !min-h-[200px]",rows:10,value:r,onChange:e=>u(e.target.value),placeholder:"Enter Python code here..."})]}),(0,n.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:N,disabled:y||!r.trim(),children:[y?(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,n.jsx)(l.Z,{size:16}),y?" Running...":" Run"]}),g&&(0,n.jsx)("div",{className:"card border border-red-500/30",children:(0,n.jsx)("p",{className:"text-red-400 text-sm font-mono whitespace-pre-wrap",children:g})})]}),(0,n.jsx)("div",{className:"w-[480px] flex flex-col",children:(0,n.jsxs)("div",{className:"card flex-1 flex flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,n.jsx)("span",{className:"text-sm font-semibold",children:"Output"}),(null==d?void 0:d.execution_time)!==void 0&&(0,n.jsxs)("span",{className:"badge badge-green",children:[d.execution_time,"ms"]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:d?(0,n.jsxs)("pre",{className:"font-mono text-xs whitespace-pre-wrap text-[var(--text-secondary)] leading-relaxed",children:[(0,n.jsx)("code",{children:d.output||""}),d.error&&(0,n.jsx)("code",{className:"text-red-400",children:d.error}),!d.output&&!d.error&&(0,n.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"(no output)"})]}):(0,n.jsx)("span",{className:"text-[var(--text-tertiary)] text-xs",children:"Run code to see output"})})]})})]})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return f},hi:function(){return d},jl:function(){return i},qz:function(){return s}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function a(){return localStorage.getItem("nexus_token")}function s(){localStorage.removeItem("nexus_token")}function i(){return!!a()}let o={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,c=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",i=a(),u={"Content-Type":"application/json",...t.headers};if(i&&(u.Authorization="Bearer ".concat(i)),"GET"===r&&!i){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in o)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return o[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=c.get(e);if(r)return r}let d=(async()=>{let a=await fetch("".concat(n).concat(e),{method:r,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let o=await a.json();return"GET"!==r||i||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,o),o})();if("GET"===r&&!i){c.set(e,d);try{return await d}finally{c.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),n},getMe:()=>u("/api/auth/me"),logout:()=>{s(),l.clear(),window.location.href="/login"}},f=async e=>{let t=a(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let s=await r.blob(),i=URL.createObjectURL(s),o=document.createElement("a");o.href=i,o.download=e.split("/").pop()||"export.csv",o.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=9671)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/code-interpreter/page-616c2499443c23ee.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5866],{9671:function(e,t,r){Promise.resolve().then(r.bind(r,2763))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return l}});var n=r(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=24,strokeWidth:o=2,absoluteStrokeWidth:l,className:c="",children:u,iconNode:d,...f}=e;return(0,n.createElement)("svg",{ref:t,...i,width:a,height:a,stroke:r,strokeWidth:l?24*Number(o)/Number(a):o,className:s("lucide",c),...f},[...d.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(u)?u:[u]])}),l=(e,t)=>{let r=(0,n.forwardRef)((r,i)=>{let{className:l,...c}=r;return(0,n.createElement)(o,{ref:i,iconNode:t,className:s("lucide-".concat(a(e)),l),...c})});return r.displayName="".concat(e),r}},3276:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},7168:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},221:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]])},257:function(e,t,r){"use strict";var n,a;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(a=r.g.process)?void 0:a.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,a=e.exports={};function s(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var l=[],c=!1,u=-1;function d(){c&&n&&(c=!1,n.length?l=n.concat(l):u=-1,l.length&&f())}function f(){if(!c){var e=o(d);c=!0;for(var t=l.length;t;){for(n=l,l=[];++u<t;)n&&n[u].run();u=-1,t=l.length}n=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function p(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new h(e,t)),1!==l.length||c||o(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=p,a.addListener=p,a.once=p,a.off=p,a.removeListener=p,a.removeAllListeners=p,a.emit=p,a.prependListener=p,a.prependOnceListener=p,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var s=r[e]={exports:{}},i=!0;try{t[e](s,s.exports,n),i=!1}finally{i&&delete r[e]}return s.exports}n.ab="//";var a=n(229);e.exports=a}()},2763:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return u}});var n=r(7437),a=r(2265),s=r(1837),i=r(221),o=r(7168),l=r(3276);let c={ready:{label:"Ready",className:"badge-green"},error:{label:"Error",className:"badge-red"},starting:{label:"Starting",className:"badge-yellow"}};function u(){let[e,t]=(0,a.useState)(null),[r,u]=(0,a.useState)('# Enter your Python code here\nprint("Hello from NexusAI!")'),[d,f]=(0,a.useState)(null),[h,p]=(0,a.useState)(!0),[m,x]=(0,a.useState)(!1),[y,v]=(0,a.useState)(!1),[g,w]=(0,a.useState)(null),b=async()=>{p(!0),w(null);try{let e=await s.hi.get("/api/code-interpreter/status");t(e)}catch(e){w(String(e))}finally{p(!1)}};(0,a.useEffect)(()=>{b()},[]);let j=async()=>{x(!0),w(null);try{let e=await s.hi.post("/api/code-interpreter/restart");t(e)}catch(e){w(String(e))}finally{x(!1)}},N=async()=>{if(r.trim()){v(!0),f(null),w(null);try{let e=await s.hi.post("/api/code-interpreter/execute",{code:r});f(e)}catch(e){w(String(e))}finally{v(!1)}}},k=e?c[e.status]:null;return(0,n.jsxs)("div",{className:"flex flex-col h-[calc(100vh-6rem)]",children:[(0,n.jsx)("div",{className:"page-header flex-shrink-0",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Code Interpreter"}),(0,n.jsx)("p",{className:"page-sub",children:"Execute Python code in an isolated Jupyter kernel"})]})}),(0,n.jsxs)("div",{className:"flex-1 flex gap-4 min-h-0",children:[(0,n.jsxs)("div",{className:"flex-1 flex flex-col gap-4 overflow-y-auto",children:[(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(i.Z,{size:18}),(0,n.jsx)("span",{className:"text-sm font-semibold",children:"Kernel Status"}),h?(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):k?(0,n.jsx)("span",{className:"badge ".concat(k.className),children:k.label}):(0,n.jsx)("span",{className:"badge badge-red",children:"Offline"})]}),(0,n.jsxs)("button",{className:"btn-secondary btn-sm",onClick:j,disabled:m,children:[(0,n.jsx)(o.Z,{size:14,className:m?"animate-spin":""}),m?" Restarting...":" Restart Kernel"]})]}),e&&(0,n.jsxs)("div",{className:"text-xs text-[var(--text-secondary)] space-y-1",children:[e.kernel_id&&(0,n.jsxs)("p",{children:["Kernel: ",(0,n.jsx)("span",{className:"font-mono",children:e.kernel_id})]}),void 0!==e.uptime&&(0,n.jsxs)("p",{children:["Uptime: ",e.uptime,"s"]})]})]}),(0,n.jsxs)("div",{className:"card",children:[(0,n.jsx)("label",{className:"label",children:"Python Code"}),(0,n.jsx)("textarea",{className:"input font-mono text-xs !min-h-[200px]",rows:10,value:r,onChange:e=>u(e.target.value),placeholder:"Enter Python code here..."})]}),(0,n.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:N,disabled:y||!r.trim(),children:[y?(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,n.jsx)(l.Z,{size:16}),y?" Running...":" Run"]}),g&&(0,n.jsx)("div",{className:"card border border-red-500/30",children:(0,n.jsx)("p",{className:"text-red-400 text-sm font-mono whitespace-pre-wrap",children:g})})]}),(0,n.jsx)("div",{className:"w-[480px] flex flex-col",children:(0,n.jsxs)("div",{className:"card flex-1 flex flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,n.jsx)("span",{className:"text-sm font-semibold",children:"Output"}),(null==d?void 0:d.execution_time)!==void 0&&(0,n.jsxs)("span",{className:"badge badge-green",children:[d.execution_time,"ms"]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:d?(0,n.jsxs)("pre",{className:"font-mono text-xs whitespace-pre-wrap text-[var(--text-secondary)] leading-relaxed",children:[(0,n.jsx)("code",{children:d.output||""}),d.error&&(0,n.jsx)("code",{className:"text-red-400",children:d.error}),!d.output&&!d.error&&(0,n.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"(no output)"})]}):(0,n.jsx)("span",{className:"text-[var(--text-tertiary)] text-xs",children:"Run code to see output"})})]})})]})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return f},hi:function(){return d},jl:function(){return i},qz:function(){return s}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function a(){return localStorage.getItem("nexus_token")}function s(){localStorage.removeItem("nexus_token")}function i(){return!!a()}let o={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,c=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",i=a(),u={"Content-Type":"application/json",...t.headers};if(i&&(u.Authorization="Bearer ".concat(i)),"GET"===r&&!i){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in o)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return o[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=c.get(e);if(r)return r}let d=(async()=>{let a=await fetch("".concat(n).concat(e),{method:r,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let o=await a.json();return"GET"!==r||i||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,o),o})();if("GET"===r&&!i){c.set(e,d);try{return await d}finally{c.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),n},getMe:()=>u("/api/auth/me"),logout:()=>{s(),l.clear(),window.location.href="/login"}},f=async e=>{let t=a(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let s=await r.blob(),i=URL.createObjectURL(s),o=document.createElement("a");o.href=i,o.download=e.split("/").pop()||"export.csv",o.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=9671)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/code-interpreter/page-6263999561ce9799.js ADDED
@@ -0,0 +1 @@
 
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5866],{9671:function(e,t,n){Promise.resolve().then(n.bind(n,2763))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),o=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:a=24,strokeWidth:i=2,absoluteStrokeWidth:l,className:c="",children:u,iconNode:d,...h}=e;return(0,r.createElement)("svg",{ref:t,...s,width:a,height:a,stroke:n,strokeWidth:l?24*Number(i)/Number(a):i,className:o("lucide",c),...h},[...d.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(u)?u:[u]])}),l=(e,t)=>{let n=(0,r.forwardRef)((n,s)=>{let{className:l,...c}=n;return(0,r.createElement)(i,{ref:s,iconNode:t,className:o("lucide-".concat(a(e)),l),...c})});return n.displayName="".concat(e),n}},3276:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])},7168:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},221:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]])},257:function(e,t,n){"use strict";var r,a;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(a=n.g.process)?void 0:a.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,a=e.exports={};function o(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var l=[],c=!1,u=-1;function d(){c&&r&&(c=!1,r.length?l=r.concat(l):u=-1,l.length&&h())}function h(){if(!c){var e=i(d);c=!0;for(var t=l.length;t;){for(r=l,l=[];++u<t;)r&&r[u].run();u=-1,t=l.length}r=null,c=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function p(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new f(e,t)),1!==l.length||c||i(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=p,a.addListener=p,a.once=p,a.off=p,a.removeListener=p,a.removeAllListeners=p,a.emit=p,a.prependListener=p,a.prependOnceListener=p,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var o=n[e]={exports:{}},s=!0;try{t[e](o,o.exports,r),s=!1}finally{s&&delete n[e]}return o.exports}r.ab="//";var a=r(229);e.exports=a}()},2763:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return u}});var r=n(7437),a=n(2265),o=n(1837),s=n(221),i=n(7168),l=n(3276);let c={ready:{label:"Ready",className:"badge-green"},error:{label:"Error",className:"badge-red"},starting:{label:"Starting",className:"badge-yellow"}};function u(){let[e,t]=(0,a.useState)(null),[n,u]=(0,a.useState)('# Enter your Python code here\nprint("Hello from NexusAI!")'),[d,h]=(0,a.useState)(null),[f,p]=(0,a.useState)(!0),[m,x]=(0,a.useState)(!1),[y,g]=(0,a.useState)(!1),[v,w]=(0,a.useState)(null),b=async()=>{p(!0),w(null);try{let e=await o.hi.get("/api/code-interpreter/status");t(e)}catch(e){w(String(e))}finally{p(!1)}};(0,a.useEffect)(()=>{b()},[]);let j=async()=>{x(!0),w(null);try{let e=await o.hi.post("/api/code-interpreter/restart");t(e)}catch(e){w(String(e))}finally{x(!1)}},N=async()=>{if(n.trim()){g(!0),h(null),w(null);try{let e=await o.hi.post("/api/code-interpreter/execute",{code:n});h(e)}catch(e){w(String(e))}finally{g(!1)}}},k=e?c[e.status]:null;return(0,r.jsxs)("div",{className:"flex flex-col h-[calc(100vh-6rem)]",children:[(0,r.jsx)("div",{className:"page-header flex-shrink-0",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Code Interpreter"}),(0,r.jsx)("p",{className:"page-sub",children:"Execute Python code in an isolated Jupyter kernel"})]})}),(0,r.jsxs)("div",{className:"flex-1 flex gap-4 min-h-0",children:[(0,r.jsxs)("div",{className:"flex-1 flex flex-col gap-4 overflow-y-auto",children:[(0,r.jsxs)("div",{className:"card",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(s.Z,{size:18}),(0,r.jsx)("span",{className:"text-sm font-semibold",children:"Kernel Status"}),f?(0,r.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):k?(0,r.jsx)("span",{className:"badge ".concat(k.className),children:k.label}):(0,r.jsx)("span",{className:"badge badge-red",children:"Offline"})]}),(0,r.jsxs)("button",{className:"btn-secondary btn-sm",onClick:j,disabled:m,children:[(0,r.jsx)(i.Z,{size:14,className:m?"animate-spin":""}),m?" Restarting...":" Restart Kernel"]})]}),e&&(0,r.jsxs)("div",{className:"text-xs text-[var(--text-secondary)] space-y-1",children:[e.kernel_id&&(0,r.jsxs)("p",{children:["Kernel: ",(0,r.jsx)("span",{className:"font-mono",children:e.kernel_id})]}),void 0!==e.uptime&&(0,r.jsxs)("p",{children:["Uptime: ",e.uptime,"s"]})]})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsx)("label",{className:"label",children:"Python Code"}),(0,r.jsx)("textarea",{className:"input font-mono text-xs !min-h-[200px]",rows:10,value:n,onChange:e=>u(e.target.value),placeholder:"Enter Python code here..."})]}),(0,r.jsxs)("button",{className:"btn-primary justify-center py-2.5",onClick:N,disabled:y||!n.trim(),children:[y?(0,r.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,r.jsx)(l.Z,{size:16}),y?" Running...":" Run"]}),v&&(0,r.jsx)("div",{className:"card border border-red-500/30",children:(0,r.jsx)("p",{className:"text-red-400 text-sm font-mono whitespace-pre-wrap",children:v})})]}),(0,r.jsx)("div",{className:"w-[480px] flex flex-col",children:(0,r.jsxs)("div",{className:"card flex-1 flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsx)("span",{className:"text-sm font-semibold",children:"Output"}),(null==d?void 0:d.execution_time)!==void 0&&(0,r.jsxs)("span",{className:"badge badge-green",children:[d.execution_time,"ms"]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:d?(0,r.jsxs)("pre",{className:"font-mono text-xs whitespace-pre-wrap text-[var(--text-secondary)] leading-relaxed",children:[(0,r.jsx)("code",{children:d.output||""}),d.error&&(0,r.jsx)("code",{className:"text-red-400",children:d.error}),!d.output&&!d.error&&(0,r.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"(no output)"})]}):(0,r.jsx)("span",{className:"text-[var(--text-tertiary)] text-xs",children:"Run code to see output"})})]})})]})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return s},qz:function(){return o}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function a(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function o(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function s(){return!!a()}let i={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,c=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",s=a(),u={"Content-Type":"application/json",...t.headers};if(s&&(u.Authorization="Bearer ".concat(s)),"GET"===n&&!s){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in i)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return i[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=c.get(e);if(n)return n}let d=(async()=>{let a=await fetch("".concat(r).concat(e),{method:n,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw o(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let i=await a.json();return"GET"!==n||s||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,i),i})();if("GET"===n&&!s){c.set(e,d);try{return await d}finally{c.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),function(e,t,n){try{let n="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(n)}catch(e){}}("nexus_token",n,0),r},getMe:()=>u("/api/auth/me"),logout:()=>{o(),l.clear(),window.location.href="/login"}},h=async e=>{let t=a(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let o=await n.blob(),s=URL.createObjectURL(o),i=document.createElement("a");i.href=s,i.download=e.split("/").pop()||"export.csv",i.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=9671)}),_N_E=e.O()}]);
static/_next/static/chunks/app/config-backup/{page-7792b5bc4dc19a5f.js → page-3da24ba3742904fe.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2378],{6434:function(e,t,r){Promise.resolve().then(r.bind(r,9928))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return l}});var n=r(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=24,strokeWidth:o=2,absoluteStrokeWidth:l,className:c="",children:u,iconNode:d,...f}=e;return(0,n.createElement)("svg",{ref:t,...s,width:a,height:a,stroke:r,strokeWidth:l?24*Number(o)/Number(a):o,className:i("lucide",c),...f},[...d.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(u)?u:[u]])}),l=(e,t)=>{let r=(0,n.forwardRef)((r,s)=>{let{className:l,...c}=r;return(0,n.createElement)(o,{ref:s,iconNode:t,className:i("lucide-".concat(a(e)),l),...c})});return r.displayName="".concat(e),r}},1671:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},8867:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},2735:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},6865:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},7689:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]])},257:function(e,t,r){"use strict";var n,a;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(a=r.g.process)?void 0:a.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,a=e.exports={};function i(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var l=[],c=!1,u=-1;function d(){c&&n&&(c=!1,n.length?l=n.concat(l):u=-1,l.length&&f())}function f(){if(!c){var e=o(d);c=!0;for(var t=l.length;t;){for(n=l,l=[];++u<t;)n&&n[u].run();u=-1,t=l.length}n=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function m(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new h(e,t)),1!==l.length||c||o(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=m,a.addListener=m,a.once=m,a.off=m,a.removeListener=m,a.removeAllListeners=m,a.emit=m,a.prependListener=m,a.prependOnceListener=m,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}},s=!0;try{t[e](i,i.exports,n),s=!1}finally{s&&delete r[e]}return i.exports}n.ab="//";var a=n(229);e.exports=a}()},9928:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return f}});var n=r(7437),a=r(2265),i=r(1837);let s=(0,r(9205).Z)("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);var o=r(6865),l=r(2735),c=r(8867),u=r(7689),d=r(1671);function f(){let[e,t]=(0,a.useState)(null),[r,f]=(0,a.useState)(!0),[h,m]=(0,a.useState)(""),[p,x]=(0,a.useState)(!1),[g,y]=(0,a.useState)(null),[v,b]=(0,a.useState)(null),[j,w]=(0,a.useState)(!1),k=(0,a.useRef)(null);(0,a.useEffect)(()=>{N()},[]);let N=async()=>{f(!0),m("");try{let e=await i.hi.get("/api/config/export");t(e)}catch(e){m(e instanceof Error?e.message:"Failed to export configuration")}finally{f(!1)}},T=async()=>{if(e)try{await navigator.clipboard.writeText(JSON.stringify(e,null,2))}catch(e){}},E=async()=>{if(v){x(!0),y(null),w(!1);try{let e=await v.text(),t=JSON.parse(e);await i.hi.post("/api/config/import",t),y({ok:!0,message:"Configuration restored successfully."}),await N(),b(null),k.current&&(k.current.value="")}catch(e){y({ok:!1,message:e instanceof Error?e.message:"Import failed"})}finally{x(!1)}}};return(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"page-header",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Configuration Backup & Restore"}),(0,n.jsx)("p",{className:"page-sub",children:"Export or import your full gateway configuration"})]})}),(0,n.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,n.jsx)(s,{size:18}),(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"Export Configuration"})]}),(0,n.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:"Download a JSON file containing all current configuration settings."}),r&&(0,n.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,n.jsx)("span",{className:"w-5 h-5 border-2 border-[var(--accent)] border-t-transparent rounded-full animate-spin"})}),h&&(0,n.jsxs)("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-red-500/10 text-red-400 mb-4",children:[(0,n.jsx)(o.Z,{size:16,className:"mt-0.5 shrink-0"}),(0,n.jsx)("span",{className:"text-sm",children:h})]}),!r&&!h&&e&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("pre",{className:"bg-[var(--surface-100)] rounded-lg p-4 overflow-x-auto text-xs font-mono leading-relaxed max-h-80 mb-4 text-[var(--text-secondary)]",children:(0,n.jsx)("code",{children:JSON.stringify(e,null,2)})}),(0,n.jsxs)("div",{className:"flex gap-3",children:[(0,n.jsxs)("button",{className:"btn-primary",onClick:()=>{if(!e)return;let t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download="nexus-config-backup.json",n.click(),URL.revokeObjectURL(r)},disabled:!e,children:[(0,n.jsx)(l.Z,{size:16}),"Download Config"]}),(0,n.jsxs)("button",{className:"btn-secondary",onClick:T,children:[(0,n.jsx)(c.Z,{size:16}),"Copy to Clipboard"]})]})]}),!r&&!h&&!e&&(0,n.jsx)("div",{className:"text-center py-12 text-[var(--text-tertiary)]",children:(0,n.jsx)("p",{className:"text-sm",children:"No configuration data available."})})]}),(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,n.jsx)(u.Z,{size:18}),(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"Import Configuration"})]}),(0,n.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:"Upload a previously exported JSON file to restore configuration."}),(0,n.jsxs)("div",{className:"border-2 border-dashed border-[var(--border)] rounded-lg p-8 text-center cursor-pointer hover:border-[var(--accent)] transition-colors",onClick:()=>{var e;return null===(e=k.current)||void 0===e?void 0:e.click()},children:[(0,n.jsx)(u.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-1",children:v?v.name:"Click to select a JSON file"}),(0,n.jsx)("p",{className:"text-xs text-[var(--text-tertiary)]",children:".json files only"}),(0,n.jsx)("input",{ref:k,type:"file",accept:".json",className:"hidden",onChange:e=>{var t;b((null===(t=e.target.files)||void 0===t?void 0:t[0])||null),y(null)}})]}),v&&!j&&(0,n.jsx)("div",{className:"mt-4",children:(0,n.jsx)("button",{className:"btn-danger w-full justify-center",onClick:()=>w(!0),disabled:p,children:p?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Importing..."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(u.Z,{size:16}),"Restore from ",v.name]})})}),j&&(0,n.jsxs)("div",{className:"mt-4 p-4 rounded-lg bg-yellow-500/10 border border-yellow-500/20",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,n.jsx)(o.Z,{size:18,className:"text-yellow-400 mt-0.5 shrink-0"}),(0,n.jsx)("p",{className:"text-sm text-yellow-300",children:"This will overwrite current configuration. Continue?"})]}),(0,n.jsxs)("div",{className:"flex gap-3",children:[(0,n.jsx)("button",{className:"btn-danger",onClick:E,disabled:p,children:"Yes, Restore"}),(0,n.jsx)("button",{className:"btn-secondary",onClick:()=>w(!1),disabled:p,children:"Cancel"})]})]}),g&&(0,n.jsxs)("div",{className:"mt-4 flex items-start gap-3 p-3 rounded-lg ".concat(g.ok?"bg-emerald-500/10 text-emerald-400":"bg-red-500/10 text-red-400"),children:[g.ok?(0,n.jsx)(d.Z,{size:16,className:"mt-0.5 shrink-0"}):(0,n.jsx)(o.Z,{size:16,className:"mt-0.5 shrink-0"}),(0,n.jsx)("span",{className:"text-sm",children:g.message})]})]})]})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return f},hi:function(){return d},jl:function(){return s},qz:function(){return i}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function a(){return localStorage.getItem("nexus_token")}function i(){localStorage.removeItem("nexus_token")}function s(){return!!a()}let o={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,c=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",s=a(),u={"Content-Type":"application/json",...t.headers};if(s&&(u.Authorization="Bearer ".concat(s)),"GET"===r&&!s){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in o)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return o[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=c.get(e);if(r)return r}let d=(async()=>{let a=await fetch("".concat(n).concat(e),{method:r,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let o=await a.json();return"GET"!==r||s||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,o),o})();if("GET"===r&&!s){c.set(e,d);try{return await d}finally{c.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),n},getMe:()=>u("/api/auth/me"),logout:()=>{i(),l.clear(),window.location.href="/login"}},f=async e=>{let t=a(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let i=await r.blob(),s=URL.createObjectURL(i),o=document.createElement("a");o.href=s,o.download=e.split("/").pop()||"export.csv",o.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=6434)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2378],{6434:function(e,t,n){Promise.resolve().then(n.bind(n,9928))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var o={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let s=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:a=24,strokeWidth:s=2,absoluteStrokeWidth:c,className:l="",children:u,iconNode:d,...f}=e;return(0,r.createElement)("svg",{ref:t,...o,width:a,height:a,stroke:n,strokeWidth:c?24*Number(s)/Number(a):s,className:i("lucide",l),...f},[...d.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(u)?u:[u]])}),c=(e,t)=>{let n=(0,r.forwardRef)((n,o)=>{let{className:c,...l}=n;return(0,r.createElement)(s,{ref:o,iconNode:t,className:i("lucide-".concat(a(e)),c),...l})});return n.displayName="".concat(e),n}},1671:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},8867:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},2735:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},6865:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},7689:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]])},257:function(e,t,n){"use strict";var r,a;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(a=n.g.process)?void 0:a.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,a=e.exports={};function i(){throw Error("setTimeout has not been defined")}function o(){throw Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(e){n=o}}();var c=[],l=!1,u=-1;function d(){l&&r&&(l=!1,r.length?c=r.concat(c):u=-1,c.length&&f())}function f(){if(!l){var e=s(d);l=!0;for(var t=c.length;t;){for(r=c,c=[];++u<t;)r&&r[u].run();u=-1,t=c.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function m(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new h(e,t)),1!==c.length||l||s(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=m,a.addListener=m,a.once=m,a.off=m,a.removeListener=m,a.removeAllListeners=m,a.emit=m,a.prependListener=m,a.prependOnceListener=m,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var i=n[e]={exports:{}},o=!0;try{t[e](i,i.exports,r),o=!1}finally{o&&delete n[e]}return i.exports}r.ab="//";var a=r(229);e.exports=a}()},9928:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return f}});var r=n(7437),a=n(2265),i=n(1837);let o=(0,n(9205).Z)("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);var s=n(6865),c=n(2735),l=n(8867),u=n(7689),d=n(1671);function f(){let[e,t]=(0,a.useState)(null),[n,f]=(0,a.useState)(!0),[h,m]=(0,a.useState)(""),[p,x]=(0,a.useState)(!1),[g,y]=(0,a.useState)(null),[v,b]=(0,a.useState)(null),[j,w]=(0,a.useState)(!1),k=(0,a.useRef)(null);(0,a.useEffect)(()=>{N()},[]);let N=async()=>{f(!0),m("");try{let e=await i.hi.get("/api/config/export");t(e)}catch(e){m(e instanceof Error?e.message:"Failed to export configuration")}finally{f(!1)}},T=async()=>{if(e)try{await navigator.clipboard.writeText(JSON.stringify(e,null,2))}catch(e){}},C=async()=>{if(v){x(!0),y(null),w(!1);try{let e=await v.text(),t=JSON.parse(e);await i.hi.post("/api/config/import",t),y({ok:!0,message:"Configuration restored successfully."}),await N(),b(null),k.current&&(k.current.value="")}catch(e){y({ok:!1,message:e instanceof Error?e.message:"Import failed"})}finally{x(!1)}}};return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"page-header",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Configuration Backup & Restore"}),(0,r.jsx)("p",{className:"page-sub",children:"Export or import your full gateway configuration"})]})}),(0,r.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,r.jsxs)("div",{className:"card",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,r.jsx)(o,{size:18}),(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Export Configuration"})]}),(0,r.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:"Download a JSON file containing all current configuration settings."}),n&&(0,r.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,r.jsx)("span",{className:"w-5 h-5 border-2 border-[var(--accent)] border-t-transparent rounded-full animate-spin"})}),h&&(0,r.jsxs)("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-red-500/10 text-red-400 mb-4",children:[(0,r.jsx)(s.Z,{size:16,className:"mt-0.5 shrink-0"}),(0,r.jsx)("span",{className:"text-sm",children:h})]}),!n&&!h&&e&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("pre",{className:"bg-[var(--surface-100)] rounded-lg p-4 overflow-x-auto text-xs font-mono leading-relaxed max-h-80 mb-4 text-[var(--text-secondary)]",children:(0,r.jsx)("code",{children:JSON.stringify(e,null,2)})}),(0,r.jsxs)("div",{className:"flex gap-3",children:[(0,r.jsxs)("button",{className:"btn-primary",onClick:()=>{if(!e)return;let t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download="nexus-config-backup.json",r.click(),URL.revokeObjectURL(n)},disabled:!e,children:[(0,r.jsx)(c.Z,{size:16}),"Download Config"]}),(0,r.jsxs)("button",{className:"btn-secondary",onClick:T,children:[(0,r.jsx)(l.Z,{size:16}),"Copy to Clipboard"]})]})]}),!n&&!h&&!e&&(0,r.jsx)("div",{className:"text-center py-12 text-[var(--text-tertiary)]",children:(0,r.jsx)("p",{className:"text-sm",children:"No configuration data available."})})]}),(0,r.jsxs)("div",{className:"card",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,r.jsx)(u.Z,{size:18}),(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Import Configuration"})]}),(0,r.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:"Upload a previously exported JSON file to restore configuration."}),(0,r.jsxs)("div",{className:"border-2 border-dashed border-[var(--border)] rounded-lg p-8 text-center cursor-pointer hover:border-[var(--accent)] transition-colors",onClick:()=>{var e;return null===(e=k.current)||void 0===e?void 0:e.click()},children:[(0,r.jsx)(u.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-1",children:v?v.name:"Click to select a JSON file"}),(0,r.jsx)("p",{className:"text-xs text-[var(--text-tertiary)]",children:".json files only"}),(0,r.jsx)("input",{ref:k,type:"file",accept:".json",className:"hidden",onChange:e=>{var t;b((null===(t=e.target.files)||void 0===t?void 0:t[0])||null),y(null)}})]}),v&&!j&&(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsx)("button",{className:"btn-danger w-full justify-center",onClick:()=>w(!0),disabled:p,children:p?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Importing..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.Z,{size:16}),"Restore from ",v.name]})})}),j&&(0,r.jsxs)("div",{className:"mt-4 p-4 rounded-lg bg-yellow-500/10 border border-yellow-500/20",children:[(0,r.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,r.jsx)(s.Z,{size:18,className:"text-yellow-400 mt-0.5 shrink-0"}),(0,r.jsx)("p",{className:"text-sm text-yellow-300",children:"This will overwrite current configuration. Continue?"})]}),(0,r.jsxs)("div",{className:"flex gap-3",children:[(0,r.jsx)("button",{className:"btn-danger",onClick:C,disabled:p,children:"Yes, Restore"}),(0,r.jsx)("button",{className:"btn-secondary",onClick:()=>w(!1),disabled:p,children:"Cancel"})]})]}),g&&(0,r.jsxs)("div",{className:"mt-4 flex items-start gap-3 p-3 rounded-lg ".concat(g.ok?"bg-emerald-500/10 text-emerald-400":"bg-red-500/10 text-red-400"),children:[g.ok?(0,r.jsx)(d.Z,{size:16,className:"mt-0.5 shrink-0"}):(0,r.jsx)(s.Z,{size:16,className:"mt-0.5 shrink-0"}),(0,r.jsx)("span",{className:"text-sm",children:g.message})]})]})]})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return f},hi:function(){return d},jl:function(){return o},qz:function(){return i}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function a(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function i(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function o(){return!!a()}let s={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,l=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",o=a(),u={"Content-Type":"application/json",...t.headers};if(o&&(u.Authorization="Bearer ".concat(o)),"GET"===n&&!o){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in s)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return s[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=l.get(e);if(n)return n}let d=(async()=>{let a=await fetch("".concat(r).concat(e),{method:n,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&o&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let s=await a.json();return"GET"!==n||o||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,s),s})();if("GET"===n&&!o){l.set(e,d);try{return await d}finally{l.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),function(e,t,n){try{let n="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(n)}catch(e){}}("nexus_token",n,0),r},getMe:()=>u("/api/auth/me"),logout:()=>{i(),c.clear(),window.location.href="/login"}},f=async e=>{let t=a(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let i=await n.blob(),o=URL.createObjectURL(i),s=document.createElement("a");s.href=o,s.download=e.split("/").pop()||"export.csv",s.click(),URL.revokeObjectURL(o)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=6434)}),_N_E=e.O()}]);
static/_next/static/chunks/app/config-backup/page-f8aede07552f28f7.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2378],{6434:function(e,t,r){Promise.resolve().then(r.bind(r,9928))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return l}});var n=r(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=24,strokeWidth:o=2,absoluteStrokeWidth:l,className:c="",children:u,iconNode:d,...f}=e;return(0,n.createElement)("svg",{ref:t,...s,width:a,height:a,stroke:r,strokeWidth:l?24*Number(o)/Number(a):o,className:i("lucide",c),...f},[...d.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(u)?u:[u]])}),l=(e,t)=>{let r=(0,n.forwardRef)((r,s)=>{let{className:l,...c}=r;return(0,n.createElement)(o,{ref:s,iconNode:t,className:i("lucide-".concat(a(e)),l),...c})});return r.displayName="".concat(e),r}},1671:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},8867:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},2735:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},6865:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},7689:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]])},257:function(e,t,r){"use strict";var n,a;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(a=r.g.process)?void 0:a.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,a=e.exports={};function i(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var l=[],c=!1,u=-1;function d(){c&&n&&(c=!1,n.length?l=n.concat(l):u=-1,l.length&&f())}function f(){if(!c){var e=o(d);c=!0;for(var t=l.length;t;){for(n=l,l=[];++u<t;)n&&n[u].run();u=-1,t=l.length}n=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function m(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new h(e,t)),1!==l.length||c||o(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=m,a.addListener=m,a.once=m,a.off=m,a.removeListener=m,a.removeAllListeners=m,a.emit=m,a.prependListener=m,a.prependOnceListener=m,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}},s=!0;try{t[e](i,i.exports,n),s=!1}finally{s&&delete r[e]}return i.exports}n.ab="//";var a=n(229);e.exports=a}()},9928:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return f}});var n=r(7437),a=r(2265),i=r(1837);let s=(0,r(9205).Z)("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);var o=r(6865),l=r(2735),c=r(8867),u=r(7689),d=r(1671);function f(){let[e,t]=(0,a.useState)(null),[r,f]=(0,a.useState)(!0),[h,m]=(0,a.useState)(""),[p,x]=(0,a.useState)(!1),[g,y]=(0,a.useState)(null),[v,b]=(0,a.useState)(null),[j,w]=(0,a.useState)(!1),k=(0,a.useRef)(null);(0,a.useEffect)(()=>{N()},[]);let N=async()=>{f(!0),m("");try{let e=await i.hi.get("/api/config/export");t(e)}catch(e){m(e instanceof Error?e.message:"Failed to export configuration")}finally{f(!1)}},T=async()=>{if(e)try{await navigator.clipboard.writeText(JSON.stringify(e,null,2))}catch(e){}},E=async()=>{if(v){x(!0),y(null),w(!1);try{let e=await v.text(),t=JSON.parse(e);await i.hi.post("/api/config/import",t),y({ok:!0,message:"Configuration restored successfully."}),await N(),b(null),k.current&&(k.current.value="")}catch(e){y({ok:!1,message:e instanceof Error?e.message:"Import failed"})}finally{x(!1)}}};return(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"page-header",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Configuration Backup & Restore"}),(0,n.jsx)("p",{className:"page-sub",children:"Export or import your full gateway configuration"})]})}),(0,n.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,n.jsx)(s,{size:18}),(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"Export Configuration"})]}),(0,n.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:"Download a JSON file containing all current configuration settings."}),r&&(0,n.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,n.jsx)("span",{className:"w-5 h-5 border-2 border-[var(--accent)] border-t-transparent rounded-full animate-spin"})}),h&&(0,n.jsxs)("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-red-500/10 text-red-400 mb-4",children:[(0,n.jsx)(o.Z,{size:16,className:"mt-0.5 shrink-0"}),(0,n.jsx)("span",{className:"text-sm",children:h})]}),!r&&!h&&e&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("pre",{className:"bg-[var(--surface-100)] rounded-lg p-4 overflow-x-auto text-xs font-mono leading-relaxed max-h-80 mb-4 text-[var(--text-secondary)]",children:(0,n.jsx)("code",{children:JSON.stringify(e,null,2)})}),(0,n.jsxs)("div",{className:"flex gap-3",children:[(0,n.jsxs)("button",{className:"btn-primary",onClick:()=>{if(!e)return;let t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download="nexus-config-backup.json",n.click(),URL.revokeObjectURL(r)},disabled:!e,children:[(0,n.jsx)(l.Z,{size:16}),"Download Config"]}),(0,n.jsxs)("button",{className:"btn-secondary",onClick:T,children:[(0,n.jsx)(c.Z,{size:16}),"Copy to Clipboard"]})]})]}),!r&&!h&&!e&&(0,n.jsx)("div",{className:"text-center py-12 text-[var(--text-tertiary)]",children:(0,n.jsx)("p",{className:"text-sm",children:"No configuration data available."})})]}),(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,n.jsx)(u.Z,{size:18}),(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"Import Configuration"})]}),(0,n.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:"Upload a previously exported JSON file to restore configuration."}),(0,n.jsxs)("div",{className:"border-2 border-dashed border-[var(--border)] rounded-lg p-8 text-center cursor-pointer hover:border-[var(--accent)] transition-colors",onClick:()=>{var e;return null===(e=k.current)||void 0===e?void 0:e.click()},children:[(0,n.jsx)(u.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-1",children:v?v.name:"Click to select a JSON file"}),(0,n.jsx)("p",{className:"text-xs text-[var(--text-tertiary)]",children:".json files only"}),(0,n.jsx)("input",{ref:k,type:"file",accept:".json",className:"hidden",onChange:e=>{var t;b((null===(t=e.target.files)||void 0===t?void 0:t[0])||null),y(null)}})]}),v&&!j&&(0,n.jsx)("div",{className:"mt-4",children:(0,n.jsx)("button",{className:"btn-danger w-full justify-center",onClick:()=>w(!0),disabled:p,children:p?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Importing..."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(u.Z,{size:16}),"Restore from ",v.name]})})}),j&&(0,n.jsxs)("div",{className:"mt-4 p-4 rounded-lg bg-yellow-500/10 border border-yellow-500/20",children:[(0,n.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,n.jsx)(o.Z,{size:18,className:"text-yellow-400 mt-0.5 shrink-0"}),(0,n.jsx)("p",{className:"text-sm text-yellow-300",children:"This will overwrite current configuration. Continue?"})]}),(0,n.jsxs)("div",{className:"flex gap-3",children:[(0,n.jsx)("button",{className:"btn-danger",onClick:E,disabled:p,children:"Yes, Restore"}),(0,n.jsx)("button",{className:"btn-secondary",onClick:()=>w(!1),disabled:p,children:"Cancel"})]})]}),g&&(0,n.jsxs)("div",{className:"mt-4 flex items-start gap-3 p-3 rounded-lg ".concat(g.ok?"bg-emerald-500/10 text-emerald-400":"bg-red-500/10 text-red-400"),children:[g.ok?(0,n.jsx)(d.Z,{size:16,className:"mt-0.5 shrink-0"}):(0,n.jsx)(o.Z,{size:16,className:"mt-0.5 shrink-0"}),(0,n.jsx)("span",{className:"text-sm",children:g.message})]})]})]})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return f},hi:function(){return d},jl:function(){return s},qz:function(){return i}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function a(){return localStorage.getItem("nexus_token")}function i(){localStorage.removeItem("nexus_token")}function s(){return!!a()}let o={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,c=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",s=a(),u={"Content-Type":"application/json",...t.headers};if(s&&(u.Authorization="Bearer ".concat(s)),"GET"===r&&!s){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in o)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return o[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=c.get(e);if(r)return r}let d=(async()=>{let a=await fetch("".concat(n).concat(e),{method:r,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let o=await a.json();return"GET"!==r||s||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,o),o})();if("GET"===r&&!s){c.set(e,d);try{return await d}finally{c.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),n},getMe:()=>u("/api/auth/me"),logout:()=>{i(),l.clear(),window.location.href="/login"}},f=async e=>{let t=a(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let i=await r.blob(),s=URL.createObjectURL(i),o=document.createElement("a");o.href=s,o.download=e.split("/").pop()||"export.csv",o.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=6434)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/conversations/{page-832c737bd9527622.js → page-c7a6b871b4413f88.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5195],{4714:function(e,t,n){Promise.resolve().then(n.bind(n,5683))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:s=24,strokeWidth:o=2,absoluteStrokeWidth:c,className:l="",children:u,iconNode:d,...h}=e;return(0,r.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:n,strokeWidth:c?24*Number(o)/Number(s):o,className:a("lucide",l),...h},[...d.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(u)?u:[u]])}),c=(e,t)=>{let n=(0,r.forwardRef)((n,i)=>{let{className:c,...l}=n;return(0,r.createElement)(o,{ref:i,iconNode:t,className:a("lucide-".concat(s(e)),c),...l})});return n.displayName="".concat(e),n}},1723:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2208:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},3417:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},8930:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,n){"use strict";var r,s;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(s=n.g.process)?void 0:s.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,s=e.exports={};function a(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var c=[],l=!1,u=-1;function d(){l&&r&&(l=!1,r.length?c=r.concat(c):u=-1,c.length&&h())}function h(){if(!l){var e=o(d);l=!0;for(var t=c.length;t;){for(r=c,c=[];++u<t;)r&&r[u].run();u=-1,t=c.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function x(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||l||o(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=x,s.addListener=x,s.once=x,s.off=x,s.removeListener=x,s.removeAllListeners=x,s.emit=x,s.prependListener=x,s.prependOnceListener=x,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},n={};function r(e){var s=n[e];if(void 0!==s)return s.exports;var a=n[e]={exports:{}},i=!0;try{t[e](a,a.exports,r),i=!1}finally{i&&delete n[e]}return a.exports}r.ab="//";var s=r(229);e.exports=s}()},5683:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return u}});var r=n(7437),s=n(2265),a=n(1837),i=n(3417),o=n(1723),c=n(2208),l=n(8930);function u(){let[e,t]=(0,s.useState)([]),[n,u]=(0,s.useState)(!0),[d,h]=(0,s.useState)(""),[f,x]=(0,s.useState)(null),[m,p]=(0,s.useState)(null),[v,g]=(0,s.useState)(!1),[y,j]=(0,s.useState)("");(0,s.useEffect)(()=>{a.hi.get("/api/conversations").then(t).catch(e=>h(e.message)).finally(()=>u(!1))},[]);let w=async e=>{x(e),g(!0),j(""),p(null);try{let t=await a.hi.get("/api/conversations/".concat(e));p(t)}catch(e){j(e instanceof Error?e.message:"Failed to load conversation")}finally{g(!1)}},N=async e=>{try{await a.hi.delete("/api/conversations/".concat(e)),t(t=>t.filter(t=>t.id!==e)),f===e&&(x(null),p(null))}catch(e){h(e instanceof Error?e.message:"Failed to delete")}},b=e=>new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"});return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"page-header",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Conversations"}),(0,r.jsx)("p",{className:"page-sub",children:"View and manage your conversation history"})]})}),d&&(0,r.jsx)("div",{className:"card mb-4 text-red-400 border-red-500/20",children:d}),n?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"flex flex-col gap-3",children:[1,2,3,4,5].map(e=>(0,r.jsx)("div",{className:"skeleton h-8 w-full"},e))})}):0===e.length?(0,r.jsxs)("div",{className:"card flex flex-col items-center justify-center py-12 gap-3",children:[(0,r.jsx)(i.Z,{size:40,className:"text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No conversations yet"})]}):(0,r.jsx)("div",{className:"card !p-0 overflow-hidden",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Title"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Messages"}),(0,r.jsx)("th",{children:"Created"}),(0,r.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>(0,r.jsxs)("tr",{className:"cursor-pointer",onClick:()=>w(e.id),children:[(0,r.jsx)("td",{className:"font-medium",children:e.title||"Untitled"}),(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"badge badge-blue",children:e.model})}),(0,r.jsx)("td",{children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(i.Z,{size:14,className:"text-[var(--text-tertiary)]"}),e.message_count]})}),(0,r.jsx)("td",{children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-[var(--text-secondary)]",children:[(0,r.jsx)(o.Z,{size:14}),b(e.created_at)]})}),(0,r.jsx)("td",{className:"text-right",children:(0,r.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,r.jsx)("button",{className:"btn-ghost btn-xs",onClick:t=>{t.stopPropagation(),w(e.id)},children:(0,r.jsx)(c.Z,{size:14})}),(0,r.jsx)("button",{className:"btn-danger btn-xs",onClick:t=>{t.stopPropagation(),N(e.id)},children:(0,r.jsx)(l.Z,{size:14})})]})})]},e.id))})]})})}),f&&(0,r.jsx)("div",{className:"modal-overlay",onClick:()=>{x(null),p(null)},children:(0,r.jsxs)("div",{className:"modal max-w-2xl max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Conversation Messages"}),(0,r.jsx)("button",{className:"btn-ghost btn-xs",onClick:()=>{x(null),p(null)},children:"✕"})]}),v?(0,r.jsx)("div",{className:"flex flex-col gap-3",children:[1,2,3].map(e=>(0,r.jsx)("div",{className:"skeleton h-16 w-full"},e))}):y?(0,r.jsx)("p",{className:"text-red-400",children:y}):m?(0,r.jsx)("div",{className:"flex-1 overflow-y-auto space-y-3",children:0===m.messages.length?(0,r.jsx)("p",{className:"text-[var(--text-tertiary)] text-center py-8",children:"No messages in this conversation"}):m.messages.map((e,t)=>(0,r.jsxs)("div",{className:"card !p-3 ".concat("user"===e.role?"border-nexus-500/20":""),children:[(0,r.jsx)("div",{className:"text-xs font-medium uppercase tracking-wider text-[var(--text-tertiary)] mb-1",children:e.role}),(0,r.jsx)("div",{className:"text-sm whitespace-pre-wrap text-[var(--text-secondary)]",children:e.content})]},t))}):null]})})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return i},qz:function(){return a}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function s(){return localStorage.getItem("nexus_token")}function a(){localStorage.removeItem("nexus_token")}function i(){return!!s()}let o={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,l=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",i=s(),u={"Content-Type":"application/json",...t.headers};if(i&&(u.Authorization="Bearer ".concat(i)),"GET"===n&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in o)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return o[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=l.get(e);if(n)return n}let d=(async()=>{let s=await fetch("".concat(r).concat(e),{method:n,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw a(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let o=await s.json();return"GET"!==n||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,o),o})();if("GET"===n&&!i){l.set(e,d);try{return await d}finally{l.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),r},getMe:()=>u("/api/auth/me"),logout:()=>{a(),c.clear(),window.location.href="/login"}},h=async e=>{let t=s(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let a=await n.blob(),i=URL.createObjectURL(a),o=document.createElement("a");o.href=i,o.download=e.split("/").pop()||"export.csv",o.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=4714)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5195],{4714:function(e,t,n){Promise.resolve().then(n.bind(n,5683))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:a=24,strokeWidth:o=2,absoluteStrokeWidth:c,className:l="",children:u,iconNode:d,...h}=e;return(0,r.createElement)("svg",{ref:t,...i,width:a,height:a,stroke:n,strokeWidth:c?24*Number(o)/Number(a):o,className:s("lucide",l),...h},[...d.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(u)?u:[u]])}),c=(e,t)=>{let n=(0,r.forwardRef)((n,i)=>{let{className:c,...l}=n;return(0,r.createElement)(o,{ref:i,iconNode:t,className:s("lucide-".concat(a(e)),c),...l})});return n.displayName="".concat(e),n}},1723:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2208:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},3417:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},8930:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,n){"use strict";var r,a;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(a=n.g.process)?void 0:a.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,a=e.exports={};function s(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var c=[],l=!1,u=-1;function d(){l&&r&&(l=!1,r.length?c=r.concat(c):u=-1,c.length&&h())}function h(){if(!l){var e=o(d);l=!0;for(var t=c.length;t;){for(r=c,c=[];++u<t;)r&&r[u].run();u=-1,t=c.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function m(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||l||o(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=m,a.addListener=m,a.once=m,a.off=m,a.removeListener=m,a.removeAllListeners=m,a.emit=m,a.prependListener=m,a.prependOnceListener=m,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var s=n[e]={exports:{}},i=!0;try{t[e](s,s.exports,r),i=!1}finally{i&&delete n[e]}return s.exports}r.ab="//";var a=r(229);e.exports=a}()},5683:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return u}});var r=n(7437),a=n(2265),s=n(1837),i=n(3417),o=n(1723),c=n(2208),l=n(8930);function u(){let[e,t]=(0,a.useState)([]),[n,u]=(0,a.useState)(!0),[d,h]=(0,a.useState)(""),[f,m]=(0,a.useState)(null),[x,p]=(0,a.useState)(null),[g,v]=(0,a.useState)(!1),[y,j]=(0,a.useState)("");(0,a.useEffect)(()=>{s.hi.get("/api/conversations").then(t).catch(e=>h(e.message)).finally(()=>u(!1))},[]);let w=async e=>{m(e),v(!0),j(""),p(null);try{let t=await s.hi.get("/api/conversations/".concat(e));p(t)}catch(e){j(e instanceof Error?e.message:"Failed to load conversation")}finally{v(!1)}},k=async e=>{try{await s.hi.delete("/api/conversations/".concat(e)),t(t=>t.filter(t=>t.id!==e)),f===e&&(m(null),p(null))}catch(e){h(e instanceof Error?e.message:"Failed to delete")}},N=e=>new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"});return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"page-header",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Conversations"}),(0,r.jsx)("p",{className:"page-sub",children:"View and manage your conversation history"})]})}),d&&(0,r.jsx)("div",{className:"card mb-4 text-red-400 border-red-500/20",children:d}),n?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"flex flex-col gap-3",children:[1,2,3,4,5].map(e=>(0,r.jsx)("div",{className:"skeleton h-8 w-full"},e))})}):0===e.length?(0,r.jsxs)("div",{className:"card flex flex-col items-center justify-center py-12 gap-3",children:[(0,r.jsx)(i.Z,{size:40,className:"text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No conversations yet"})]}):(0,r.jsx)("div",{className:"card !p-0 overflow-hidden",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Title"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Messages"}),(0,r.jsx)("th",{children:"Created"}),(0,r.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>(0,r.jsxs)("tr",{className:"cursor-pointer",onClick:()=>w(e.id),children:[(0,r.jsx)("td",{className:"font-medium",children:e.title||"Untitled"}),(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"badge badge-blue",children:e.model})}),(0,r.jsx)("td",{children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(i.Z,{size:14,className:"text-[var(--text-tertiary)]"}),e.message_count]})}),(0,r.jsx)("td",{children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-[var(--text-secondary)]",children:[(0,r.jsx)(o.Z,{size:14}),N(e.created_at)]})}),(0,r.jsx)("td",{className:"text-right",children:(0,r.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,r.jsx)("button",{className:"btn-ghost btn-xs",onClick:t=>{t.stopPropagation(),w(e.id)},children:(0,r.jsx)(c.Z,{size:14})}),(0,r.jsx)("button",{className:"btn-danger btn-xs",onClick:t=>{t.stopPropagation(),k(e.id)},children:(0,r.jsx)(l.Z,{size:14})})]})})]},e.id))})]})})}),f&&(0,r.jsx)("div",{className:"modal-overlay",onClick:()=>{m(null),p(null)},children:(0,r.jsxs)("div",{className:"modal max-w-2xl max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Conversation Messages"}),(0,r.jsx)("button",{className:"btn-ghost btn-xs",onClick:()=>{m(null),p(null)},children:"✕"})]}),g?(0,r.jsx)("div",{className:"flex flex-col gap-3",children:[1,2,3].map(e=>(0,r.jsx)("div",{className:"skeleton h-16 w-full"},e))}):y?(0,r.jsx)("p",{className:"text-red-400",children:y}):x?(0,r.jsx)("div",{className:"flex-1 overflow-y-auto space-y-3",children:0===x.messages.length?(0,r.jsx)("p",{className:"text-[var(--text-tertiary)] text-center py-8",children:"No messages in this conversation"}):x.messages.map((e,t)=>(0,r.jsxs)("div",{className:"card !p-3 ".concat("user"===e.role?"border-nexus-500/20":""),children:[(0,r.jsx)("div",{className:"text-xs font-medium uppercase tracking-wider text-[var(--text-tertiary)] mb-1",children:e.role}),(0,r.jsx)("div",{className:"text-sm whitespace-pre-wrap text-[var(--text-secondary)]",children:e.content})]},t))}):null]})})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return i},qz:function(){return s}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function a(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function s(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function i(){return!!a()}let o={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,l=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",i=a(),u={"Content-Type":"application/json",...t.headers};if(i&&(u.Authorization="Bearer ".concat(i)),"GET"===n&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in o)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return o[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=l.get(e);if(n)return n}let d=(async()=>{let a=await fetch("".concat(r).concat(e),{method:n,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let o=await a.json();return"GET"!==n||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,o),o})();if("GET"===n&&!i){l.set(e,d);try{return await d}finally{l.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),function(e,t,n){try{let n="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(n)}catch(e){}}("nexus_token",n,0),r},getMe:()=>u("/api/auth/me"),logout:()=>{s(),c.clear(),window.location.href="/login"}},h=async e=>{let t=a(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let s=await n.blob(),i=URL.createObjectURL(s),o=document.createElement("a");o.href=i,o.download=e.split("/").pop()||"export.csv",o.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=4714)}),_N_E=e.O()}]);
static/_next/static/chunks/app/conversations/page-d1e1c668033ca84e.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5195],{4714:function(e,t,n){Promise.resolve().then(n.bind(n,5683))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(2265);let s=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let o=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:s=24,strokeWidth:o=2,absoluteStrokeWidth:c,className:l="",children:u,iconNode:d,...h}=e;return(0,r.createElement)("svg",{ref:t,...i,width:s,height:s,stroke:n,strokeWidth:c?24*Number(o)/Number(s):o,className:a("lucide",l),...h},[...d.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(u)?u:[u]])}),c=(e,t)=>{let n=(0,r.forwardRef)((n,i)=>{let{className:c,...l}=n;return(0,r.createElement)(o,{ref:i,iconNode:t,className:a("lucide-".concat(s(e)),c),...l})});return n.displayName="".concat(e),n}},1723:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2208:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},3417:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},8930:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,n){"use strict";var r,s;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(s=n.g.process)?void 0:s.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,s=e.exports={};function a(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===a||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:a}catch(e){t=a}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var c=[],l=!1,u=-1;function d(){l&&r&&(l=!1,r.length?c=r.concat(c):u=-1,c.length&&h())}function h(){if(!l){var e=o(d);l=!0;for(var t=c.length;t;){for(r=c,c=[];++u<t;)r&&r[u].run();u=-1,t=c.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function x(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||l||o(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=x,s.addListener=x,s.once=x,s.off=x,s.removeListener=x,s.removeAllListeners=x,s.emit=x,s.prependListener=x,s.prependOnceListener=x,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},n={};function r(e){var s=n[e];if(void 0!==s)return s.exports;var a=n[e]={exports:{}},i=!0;try{t[e](a,a.exports,r),i=!1}finally{i&&delete n[e]}return a.exports}r.ab="//";var s=r(229);e.exports=s}()},5683:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return u}});var r=n(7437),s=n(2265),a=n(1837),i=n(3417),o=n(1723),c=n(2208),l=n(8930);function u(){let[e,t]=(0,s.useState)([]),[n,u]=(0,s.useState)(!0),[d,h]=(0,s.useState)(""),[f,x]=(0,s.useState)(null),[m,p]=(0,s.useState)(null),[v,g]=(0,s.useState)(!1),[y,j]=(0,s.useState)("");(0,s.useEffect)(()=>{a.hi.get("/api/conversations").then(t).catch(e=>h(e.message)).finally(()=>u(!1))},[]);let w=async e=>{x(e),g(!0),j(""),p(null);try{let t=await a.hi.get("/api/conversations/".concat(e));p(t)}catch(e){j(e instanceof Error?e.message:"Failed to load conversation")}finally{g(!1)}},N=async e=>{try{await a.hi.delete("/api/conversations/".concat(e)),t(t=>t.filter(t=>t.id!==e)),f===e&&(x(null),p(null))}catch(e){h(e instanceof Error?e.message:"Failed to delete")}},b=e=>new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"});return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"page-header",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Conversations"}),(0,r.jsx)("p",{className:"page-sub",children:"View and manage your conversation history"})]})}),d&&(0,r.jsx)("div",{className:"card mb-4 text-red-400 border-red-500/20",children:d}),n?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"flex flex-col gap-3",children:[1,2,3,4,5].map(e=>(0,r.jsx)("div",{className:"skeleton h-8 w-full"},e))})}):0===e.length?(0,r.jsxs)("div",{className:"card flex flex-col items-center justify-center py-12 gap-3",children:[(0,r.jsx)(i.Z,{size:40,className:"text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No conversations yet"})]}):(0,r.jsx)("div",{className:"card !p-0 overflow-hidden",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Title"}),(0,r.jsx)("th",{children:"Model"}),(0,r.jsx)("th",{children:"Messages"}),(0,r.jsx)("th",{children:"Created"}),(0,r.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>(0,r.jsxs)("tr",{className:"cursor-pointer",onClick:()=>w(e.id),children:[(0,r.jsx)("td",{className:"font-medium",children:e.title||"Untitled"}),(0,r.jsx)("td",{children:(0,r.jsx)("span",{className:"badge badge-blue",children:e.model})}),(0,r.jsx)("td",{children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(i.Z,{size:14,className:"text-[var(--text-tertiary)]"}),e.message_count]})}),(0,r.jsx)("td",{children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-[var(--text-secondary)]",children:[(0,r.jsx)(o.Z,{size:14}),b(e.created_at)]})}),(0,r.jsx)("td",{className:"text-right",children:(0,r.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,r.jsx)("button",{className:"btn-ghost btn-xs",onClick:t=>{t.stopPropagation(),w(e.id)},children:(0,r.jsx)(c.Z,{size:14})}),(0,r.jsx)("button",{className:"btn-danger btn-xs",onClick:t=>{t.stopPropagation(),N(e.id)},children:(0,r.jsx)(l.Z,{size:14})})]})})]},e.id))})]})})}),f&&(0,r.jsx)("div",{className:"modal-overlay",onClick:()=>{x(null),p(null)},children:(0,r.jsxs)("div",{className:"modal max-w-2xl max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Conversation Messages"}),(0,r.jsx)("button",{className:"btn-ghost btn-xs",onClick:()=>{x(null),p(null)},children:"✕"})]}),v?(0,r.jsx)("div",{className:"flex flex-col gap-3",children:[1,2,3].map(e=>(0,r.jsx)("div",{className:"skeleton h-16 w-full"},e))}):y?(0,r.jsx)("p",{className:"text-red-400",children:y}):m?(0,r.jsx)("div",{className:"flex-1 overflow-y-auto space-y-3",children:0===m.messages.length?(0,r.jsx)("p",{className:"text-[var(--text-tertiary)] text-center py-8",children:"No messages in this conversation"}):m.messages.map((e,t)=>(0,r.jsxs)("div",{className:"card !p-3 ".concat("user"===e.role?"border-nexus-500/20":""),children:[(0,r.jsx)("div",{className:"text-xs font-medium uppercase tracking-wider text-[var(--text-tertiary)] mb-1",children:e.role}),(0,r.jsx)("div",{className:"text-sm whitespace-pre-wrap text-[var(--text-secondary)]",children:e.content})]},t))}):null]})})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return i},qz:function(){return a}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function s(){return localStorage.getItem("nexus_token")}function a(){localStorage.removeItem("nexus_token")}function i(){return!!s()}let o={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,l=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",i=s(),u={"Content-Type":"application/json",...t.headers};if(i&&(u.Authorization="Bearer ".concat(i)),"GET"===n&&!i){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in o)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return o[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=l.get(e);if(n)return n}let d=(async()=>{let s=await fetch("".concat(r).concat(e),{method:n,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return s;if(401===s.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw a(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!s.ok)throw Error((await s.json().catch(()=>({detail:s.statusText}))).detail||"HTTP ".concat(s.status));if(204===s.status)return;let o=await s.json();return"GET"!==n||i||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,o),o})();if("GET"===n&&!i){l.set(e,d);try{return await d}finally{l.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),r},getMe:()=>u("/api/auth/me"),logout:()=>{a(),c.clear(),window.location.href="/login"}},h=async e=>{let t=s(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let a=await n.blob(),i=URL.createObjectURL(a),o=document.createElement("a");o.href=i,o.download=e.split("/").pop()||"export.csv",o.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=4714)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/custom-providers/{page-138528cda1a2fab8.js → page-4fc98b07b6fcfdb0.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8587],{4295:function(e,t,a){Promise.resolve().then(a.bind(a,3946))},9205:function(e,t,a){"use strict";a.d(t,{Z:function(){return o}});var r=a(2265);let n=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&a.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,r.forwardRef)((e,t)=>{let{color:a="currentColor",size:n=24,strokeWidth:l=2,absoluteStrokeWidth:o,className:c="",children:u,iconNode:d,...h}=e;return(0,r.createElement)("svg",{ref:t,...i,width:n,height:n,stroke:a,strokeWidth:o?24*Number(l)/Number(n):l,className:s("lucide",c),...h},[...d.map(e=>{let[t,a]=e;return(0,r.createElement)(t,a)}),...Array.isArray(u)?u:[u]])}),o=(e,t)=>{let a=(0,r.forwardRef)((a,i)=>{let{className:o,...c}=a;return(0,r.createElement)(l,{ref:i,iconNode:t,className:s("lucide-".concat(n(e)),o),...c})});return a.displayName="".concat(e),a}},9397:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},6137:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},8930:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,a){"use strict";var r,n;e.exports=(null==(r=a.g.process)?void 0:r.env)&&"object"==typeof(null==(n=a.g.process)?void 0:n.env)?a.g.process:a(4227)},4227:function(e){!function(){var t={229:function(e){var t,a,r,n=e.exports={};function s(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{a="function"==typeof clearTimeout?clearTimeout:i}catch(e){a=i}}();var o=[],c=!1,u=-1;function d(){c&&r&&(c=!1,r.length?o=r.concat(o):u=-1,o.length&&h())}function h(){if(!c){var e=l(d);c=!0;for(var t=o.length;t;){for(r=o,o=[];++u<t;)r&&r[u].run();u=-1,t=o.length}r=null,c=!1,function(e){if(a===clearTimeout)return clearTimeout(e);if((a===i||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}n.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)t[a-1]=arguments[a];o.push(new m(e,t)),1!==o.length||c||l(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(e){return[]},n.binding=function(e){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw Error("process.chdir is not supported")},n.umask=function(){return 0}}},a={};function r(e){var n=a[e];if(void 0!==n)return n.exports;var s=a[e]={exports:{}},i=!0;try{t[e](s,s.exports,r),i=!1}finally{i&&delete a[e]}return s.exports}r.ab="//";var n=r(229);e.exports=n}()},3946:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return u}});var r=a(7437),n=a(2265),s=a(1837),i=a(9397),l=a(6137),o=a(8930);let c={name:"",display_name:"",base_url:"",auth_header:"",auth_prefix:"",custom_headers:"",models:"",notes:""};function u(){let[e,t]=(0,n.useState)([]),[a,u]=(0,n.useState)(!0),[d,h]=(0,n.useState)(!1),[m,p]=(0,n.useState)(null),[x,f]=(0,n.useState)(c),[v,y]=(0,n.useState)(!1),[g,j]=(0,n.useState)(""),b=()=>{u(!0),s.hi.get("/api/custom-providers").then(t).finally(()=>u(!1))};(0,n.useEffect)(()=>{b()},[]),n.useEffect(()=>{if(g){let e=setTimeout(()=>j(""),3e3);return()=>clearTimeout(e)}},[g]);let N=e=>{var t;p(e),f({name:e.name,display_name:e.display_name,base_url:e.base_url,auth_header:e.auth_header,auth_prefix:e.auth_prefix,custom_headers:e.custom_headers,models:(null===(t=e.models)||void 0===t?void 0:t.join(", "))||"",notes:e.notes}),h(!0)},w=async()=>{if(x.name.trim()&&x.display_name.trim()&&x.base_url.trim()){y(!0);try{let e={name:x.name,display_name:x.display_name,base_url:x.base_url};x.auth_header&&(e.auth_header=x.auth_header),x.auth_prefix&&(e.auth_prefix=x.auth_prefix),x.custom_headers&&(e.custom_headers=x.custom_headers),x.models.trim()&&(e.models=x.models.split(",").map(e=>e.trim()).filter(Boolean)),x.notes&&(e.notes=x.notes),m?(await s.hi.put("/api/custom-providers/".concat(m.id),e),j("Provider updated")):(await s.hi.post("/api/custom-providers",e),j("Provider created")),h(!1),b()}catch(e){j(e instanceof Error?e.message:"Failed to save")}finally{y(!1)}}},_=async e=>{await s.hi.patch("/api/custom-providers/".concat(e,"/toggle")),b()},k=async e=>{confirm("Delete this custom provider?")&&(await s.hi.delete("/api/custom-providers/".concat(e)),b(),j("Provider deleted"))};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Custom Providers"}),(0,r.jsx)("p",{className:"page-sub",children:"Manage custom API provider integrations"})]}),(0,r.jsxs)("button",{className:"btn-primary",onClick:()=>{p(null),f(c),h(!0)},children:[(0,r.jsx)(i.Z,{size:16})," Add Provider"]})]}),d&&(0,r.jsx)("div",{className:"modal-overlay",onClick:()=>h(!1),children:(0,r.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-4",children:m?"Edit Provider":"New Custom Provider"}),(0,r.jsxs)("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Name *"}),(0,r.jsx)("input",{className:"input",value:x.name,onChange:e=>f(t=>({...t,name:e.target.value})),placeholder:"my-provider",autoFocus:!0})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Display Name *"}),(0,r.jsx)("input",{className:"input",value:x.display_name,onChange:e=>f(t=>({...t,display_name:e.target.value})),placeholder:"My Provider"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Base URL *"}),(0,r.jsx)("input",{className:"input",value:x.base_url,onChange:e=>f(t=>({...t,base_url:e.target.value})),placeholder:"https://api.example.com"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Auth Header"}),(0,r.jsx)("input",{className:"input",value:x.auth_header,onChange:e=>f(t=>({...t,auth_header:e.target.value})),placeholder:"Authorization"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Auth Prefix"}),(0,r.jsx)("input",{className:"input",value:x.auth_prefix,onChange:e=>f(t=>({...t,auth_prefix:e.target.value})),placeholder:"Bearer"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Custom Headers (JSON)"}),(0,r.jsx)("input",{className:"input",value:x.custom_headers,onChange:e=>f(t=>({...t,custom_headers:e.target.value})),placeholder:'{"X-API-Key": "..."}'})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Models (comma-separated)"}),(0,r.jsx)("input",{className:"input",value:x.models,onChange:e=>f(t=>({...t,models:e.target.value})),placeholder:"model-1, model-2"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Notes"}),(0,r.jsx)("input",{className:"input",value:x.notes,onChange:e=>f(t=>({...t,notes:e.target.value})),placeholder:"Optional notes"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:w,disabled:v,children:v?"Saving...":"Save"}),(0,r.jsx)("button",{className:"btn-ghost",onClick:()=>h(!1),children:"Cancel"})]})]})]})}),a?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-32 w-full"})}):0===e.length?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No custom providers yet. Add one to integrate external APIs."})]}):(0,r.jsx)("div",{className:"card p-0",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Name"}),(0,r.jsx)("th",{children:"Display Name"}),(0,r.jsx)("th",{children:"Base URL"}),(0,r.jsx)("th",{children:"Models"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>{var t,a;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"font-medium",children:e.name}),(0,r.jsx)("td",{className:"text-sm",children:e.display_name}),(0,r.jsx)("td",{className:"text-xs max-w-[200px] truncate font-mono",title:e.base_url,children:e.base_url}),(0,r.jsxs)("td",{className:"text-xs max-w-[160px] truncate",title:null===(t=e.models)||void 0===t?void 0:t.join(", "),children:[(null===(a=e.models)||void 0===a?void 0:a.length)||0," models"]}),(0,r.jsx)("td",{children:(0,r.jsx)("button",{onClick:()=>_(e.id),className:e.is_active?"badge-green cursor-pointer":"badge-red cursor-pointer",children:e.is_active?"Active":"Disabled"})}),(0,r.jsx)("td",{className:"text-right",children:(0,r.jsxs)("div",{className:"flex gap-1 justify-end",children:[(0,r.jsx)("button",{onClick:()=>N(e),className:"btn-ghost btn-xs",children:"Edit"}),(0,r.jsx)("button",{onClick:()=>k(e.id),className:"btn-danger btn-xs",children:(0,r.jsx)(o.Z,{size:14})})]})})]},e.id)})})]})})}),g&&(0,r.jsx)("div",{className:"toast",children:g})]})}},1837:function(e,t,a){"use strict";a.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return i},qz:function(){return s}});let r=a(257).env.NEXT_PUBLIC_API_BASE||"";function n(){return localStorage.getItem("nexus_token")}function s(){localStorage.removeItem("nexus_token")}function i(){return!!n()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,c=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.method||"GET",i=n(),u={"Content-Type":"application/json",...t.headers};if(i&&(u.Authorization="Bearer ".concat(i)),"GET"===a&&!i){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let a=c.get(e);if(a)return a}let d=(async()=>{let n=await fetch("".concat(r).concat(e),{method:a,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return n;if(401===n.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!n.ok)throw Error((await n.json().catch(()=>({detail:n.statusText}))).detail||"HTTP ".concat(n.status));if(204===n.status)return;let l=await n.json();return"GET"!==a||i||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===a&&!i){c.set(e,d);try{return await d}finally{c.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var a;let r=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return a=r.access_token,localStorage.setItem("nexus_token",a),r},getMe:()=>u("/api/auth/me"),logout:()=>{s(),o.clear(),window.location.href="/login"}},h=async e=>{let t=n(),a=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!a.ok)throw Error("Failed to download");let s=await a.blob(),i=URL.createObjectURL(s),l=document.createElement("a");l.href=i,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=4295)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8587],{4295:function(e,t,a){Promise.resolve().then(a.bind(a,3946))},9205:function(e,t,a){"use strict";a.d(t,{Z:function(){return o}});var n=a(2265);let r=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&a.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,n.forwardRef)((e,t)=>{let{color:a="currentColor",size:r=24,strokeWidth:l=2,absoluteStrokeWidth:o,className:c="",children:u,iconNode:d,...h}=e;return(0,n.createElement)("svg",{ref:t,...i,width:r,height:r,stroke:a,strokeWidth:o?24*Number(l)/Number(r):l,className:s("lucide",c),...h},[...d.map(e=>{let[t,a]=e;return(0,n.createElement)(t,a)}),...Array.isArray(u)?u:[u]])}),o=(e,t)=>{let a=(0,n.forwardRef)((a,i)=>{let{className:o,...c}=a;return(0,n.createElement)(l,{ref:i,iconNode:t,className:s("lucide-".concat(r(e)),o),...c})});return a.displayName="".concat(e),a}},9397:function(e,t,a){"use strict";a.d(t,{Z:function(){return n}});let n=(0,a(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},6137:function(e,t,a){"use strict";a.d(t,{Z:function(){return n}});let n=(0,a(9205).Z)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},8930:function(e,t,a){"use strict";a.d(t,{Z:function(){return n}});let n=(0,a(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,a){"use strict";var n,r;e.exports=(null==(n=a.g.process)?void 0:n.env)&&"object"==typeof(null==(r=a.g.process)?void 0:r.env)?a.g.process:a(4227)},4227:function(e){!function(){var t={229:function(e){var t,a,n,r=e.exports={};function s(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{a="function"==typeof clearTimeout?clearTimeout:i}catch(e){a=i}}();var o=[],c=!1,u=-1;function d(){c&&n&&(c=!1,n.length?o=n.concat(o):u=-1,o.length&&h())}function h(){if(!c){var e=l(d);c=!0;for(var t=o.length;t;){for(n=o,o=[];++u<t;)n&&n[u].run();u=-1,t=o.length}n=null,c=!1,function(e){if(a===clearTimeout)return clearTimeout(e);if((a===i||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}r.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)t[a-1]=arguments[a];o.push(new m(e,t)),1!==o.length||c||l(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=p,r.addListener=p,r.once=p,r.off=p,r.removeListener=p,r.removeAllListeners=p,r.emit=p,r.prependListener=p,r.prependOnceListener=p,r.listeners=function(e){return[]},r.binding=function(e){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw Error("process.chdir is not supported")},r.umask=function(){return 0}}},a={};function n(e){var r=a[e];if(void 0!==r)return r.exports;var s=a[e]={exports:{}},i=!0;try{t[e](s,s.exports,n),i=!1}finally{i&&delete a[e]}return s.exports}n.ab="//";var r=n(229);e.exports=r}()},3946:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return u}});var n=a(7437),r=a(2265),s=a(1837),i=a(9397),l=a(6137),o=a(8930);let c={name:"",display_name:"",base_url:"",auth_header:"",auth_prefix:"",custom_headers:"",models:"",notes:""};function u(){let[e,t]=(0,r.useState)([]),[a,u]=(0,r.useState)(!0),[d,h]=(0,r.useState)(!1),[m,p]=(0,r.useState)(null),[x,f]=(0,r.useState)(c),[v,y]=(0,r.useState)(!1),[g,j]=(0,r.useState)(""),b=()=>{u(!0),s.hi.get("/api/custom-providers").then(t).finally(()=>u(!1))};(0,r.useEffect)(()=>{b()},[]),r.useEffect(()=>{if(g){let e=setTimeout(()=>j(""),3e3);return()=>clearTimeout(e)}},[g]);let N=e=>{var t;p(e),f({name:e.name,display_name:e.display_name,base_url:e.base_url,auth_header:e.auth_header,auth_prefix:e.auth_prefix,custom_headers:e.custom_headers,models:(null===(t=e.models)||void 0===t?void 0:t.join(", "))||"",notes:e.notes}),h(!0)},_=async()=>{if(x.name.trim()&&x.display_name.trim()&&x.base_url.trim()){y(!0);try{let e={name:x.name,display_name:x.display_name,base_url:x.base_url};x.auth_header&&(e.auth_header=x.auth_header),x.auth_prefix&&(e.auth_prefix=x.auth_prefix),x.custom_headers&&(e.custom_headers=x.custom_headers),x.models.trim()&&(e.models=x.models.split(",").map(e=>e.trim()).filter(Boolean)),x.notes&&(e.notes=x.notes),m?(await s.hi.put("/api/custom-providers/".concat(m.id),e),j("Provider updated")):(await s.hi.post("/api/custom-providers",e),j("Provider created")),h(!1),b()}catch(e){j(e instanceof Error?e.message:"Failed to save")}finally{y(!1)}}},w=async e=>{await s.hi.patch("/api/custom-providers/".concat(e,"/toggle")),b()},k=async e=>{confirm("Delete this custom provider?")&&(await s.hi.delete("/api/custom-providers/".concat(e)),b(),j("Provider deleted"))};return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"page-header",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Custom Providers"}),(0,n.jsx)("p",{className:"page-sub",children:"Manage custom API provider integrations"})]}),(0,n.jsxs)("button",{className:"btn-primary",onClick:()=>{p(null),f(c),h(!0)},children:[(0,n.jsx)(i.Z,{size:16})," Add Provider"]})]}),d&&(0,n.jsx)("div",{className:"modal-overlay",onClick:()=>h(!1),children:(0,n.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{className:"text-lg font-semibold mb-4",children:m?"Edit Provider":"New Custom Provider"}),(0,n.jsxs)("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Name *"}),(0,n.jsx)("input",{className:"input",value:x.name,onChange:e=>f(t=>({...t,name:e.target.value})),placeholder:"my-provider",autoFocus:!0})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Display Name *"}),(0,n.jsx)("input",{className:"input",value:x.display_name,onChange:e=>f(t=>({...t,display_name:e.target.value})),placeholder:"My Provider"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Base URL *"}),(0,n.jsx)("input",{className:"input",value:x.base_url,onChange:e=>f(t=>({...t,base_url:e.target.value})),placeholder:"https://api.example.com"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Auth Header"}),(0,n.jsx)("input",{className:"input",value:x.auth_header,onChange:e=>f(t=>({...t,auth_header:e.target.value})),placeholder:"Authorization"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Auth Prefix"}),(0,n.jsx)("input",{className:"input",value:x.auth_prefix,onChange:e=>f(t=>({...t,auth_prefix:e.target.value})),placeholder:"Bearer"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Custom Headers (JSON)"}),(0,n.jsx)("input",{className:"input",value:x.custom_headers,onChange:e=>f(t=>({...t,custom_headers:e.target.value})),placeholder:'{"X-API-Key": "..."}'})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Models (comma-separated)"}),(0,n.jsx)("input",{className:"input",value:x.models,onChange:e=>f(t=>({...t,models:e.target.value})),placeholder:"model-1, model-2"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Notes"}),(0,n.jsx)("input",{className:"input",value:x.notes,onChange:e=>f(t=>({...t,notes:e.target.value})),placeholder:"Optional notes"})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:_,disabled:v,children:v?"Saving...":"Save"}),(0,n.jsx)("button",{className:"btn-ghost",onClick:()=>h(!1),children:"Cancel"})]})]})]})}),a?(0,n.jsx)("div",{className:"card",children:(0,n.jsx)("div",{className:"skeleton h-32 w-full"})}):0===e.length?(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No custom providers yet. Add one to integrate external APIs."})]}):(0,n.jsx)("div",{className:"card p-0",children:(0,n.jsx)("div",{className:"table-wrap",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"Name"}),(0,n.jsx)("th",{children:"Display Name"}),(0,n.jsx)("th",{children:"Base URL"}),(0,n.jsx)("th",{children:"Models"}),(0,n.jsx)("th",{children:"Status"}),(0,n.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,n.jsx)("tbody",{children:e.map(e=>{var t,a;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"font-medium",children:e.name}),(0,n.jsx)("td",{className:"text-sm",children:e.display_name}),(0,n.jsx)("td",{className:"text-xs max-w-[200px] truncate font-mono",title:e.base_url,children:e.base_url}),(0,n.jsxs)("td",{className:"text-xs max-w-[160px] truncate",title:null===(t=e.models)||void 0===t?void 0:t.join(", "),children:[(null===(a=e.models)||void 0===a?void 0:a.length)||0," models"]}),(0,n.jsx)("td",{children:(0,n.jsx)("button",{onClick:()=>w(e.id),className:e.is_active?"badge-green cursor-pointer":"badge-red cursor-pointer",children:e.is_active?"Active":"Disabled"})}),(0,n.jsx)("td",{className:"text-right",children:(0,n.jsxs)("div",{className:"flex gap-1 justify-end",children:[(0,n.jsx)("button",{onClick:()=>N(e),className:"btn-ghost btn-xs",children:"Edit"}),(0,n.jsx)("button",{onClick:()=>k(e.id),className:"btn-danger btn-xs",children:(0,n.jsx)(o.Z,{size:14})})]})})]},e.id)})})]})})}),g&&(0,n.jsx)("div",{className:"toast",children:g})]})}},1837:function(e,t,a){"use strict";a.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return i},qz:function(){return s}});let n=a(257).env.NEXT_PUBLIC_API_BASE||"";function r(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function s(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function i(){return!!r()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,c=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.method||"GET",i=r(),u={"Content-Type":"application/json",...t.headers};if(i&&(u.Authorization="Bearer ".concat(i)),"GET"===a&&!i){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let a=c.get(e);if(a)return a}let d=(async()=>{let r=await fetch("".concat(n).concat(e),{method:a,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return r;if(401===r.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!r.ok)throw Error((await r.json().catch(()=>({detail:r.statusText}))).detail||"HTTP ".concat(r.status));if(204===r.status)return;let l=await r.json();return"GET"!==a||i||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===a&&!i){c.set(e,d);try{return await d}finally{c.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var a;let n=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return a=n.access_token,localStorage.setItem("nexus_token",a),function(e,t,a){try{let a="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(a)}catch(e){}}("nexus_token",a,0),n},getMe:()=>u("/api/auth/me"),logout:()=>{s(),o.clear(),window.location.href="/login"}},h=async e=>{let t=r(),a=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!a.ok)throw Error("Failed to download");let s=await a.blob(),i=URL.createObjectURL(s),l=document.createElement("a");l.href=i,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=4295)}),_N_E=e.O()}]);
static/_next/static/chunks/app/custom-providers/page-a35369052b2e039b.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8587],{4295:function(e,t,a){Promise.resolve().then(a.bind(a,3946))},9205:function(e,t,a){"use strict";a.d(t,{Z:function(){return o}});var r=a(2265);let n=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&a.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,r.forwardRef)((e,t)=>{let{color:a="currentColor",size:n=24,strokeWidth:l=2,absoluteStrokeWidth:o,className:c="",children:u,iconNode:d,...h}=e;return(0,r.createElement)("svg",{ref:t,...i,width:n,height:n,stroke:a,strokeWidth:o?24*Number(l)/Number(n):l,className:s("lucide",c),...h},[...d.map(e=>{let[t,a]=e;return(0,r.createElement)(t,a)}),...Array.isArray(u)?u:[u]])}),o=(e,t)=>{let a=(0,r.forwardRef)((a,i)=>{let{className:o,...c}=a;return(0,r.createElement)(l,{ref:i,iconNode:t,className:s("lucide-".concat(n(e)),o),...c})});return a.displayName="".concat(e),a}},9397:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},6137:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},8930:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});let r=(0,a(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,a){"use strict";var r,n;e.exports=(null==(r=a.g.process)?void 0:r.env)&&"object"==typeof(null==(n=a.g.process)?void 0:n.env)?a.g.process:a(4227)},4227:function(e){!function(){var t={229:function(e){var t,a,r,n=e.exports={};function s(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(a){try{return t.call(null,e,0)}catch(a){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{a="function"==typeof clearTimeout?clearTimeout:i}catch(e){a=i}}();var o=[],c=!1,u=-1;function d(){c&&r&&(c=!1,r.length?o=r.concat(o):u=-1,o.length&&h())}function h(){if(!c){var e=l(d);c=!0;for(var t=o.length;t;){for(r=o,o=[];++u<t;)r&&r[u].run();u=-1,t=o.length}r=null,c=!1,function(e){if(a===clearTimeout)return clearTimeout(e);if((a===i||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}n.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)t[a-1]=arguments[a];o.push(new m(e,t)),1!==o.length||c||l(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(e){return[]},n.binding=function(e){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw Error("process.chdir is not supported")},n.umask=function(){return 0}}},a={};function r(e){var n=a[e];if(void 0!==n)return n.exports;var s=a[e]={exports:{}},i=!0;try{t[e](s,s.exports,r),i=!1}finally{i&&delete a[e]}return s.exports}r.ab="//";var n=r(229);e.exports=n}()},3946:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return u}});var r=a(7437),n=a(2265),s=a(1837),i=a(9397),l=a(6137),o=a(8930);let c={name:"",display_name:"",base_url:"",auth_header:"",auth_prefix:"",custom_headers:"",models:"",notes:""};function u(){let[e,t]=(0,n.useState)([]),[a,u]=(0,n.useState)(!0),[d,h]=(0,n.useState)(!1),[m,p]=(0,n.useState)(null),[x,f]=(0,n.useState)(c),[v,y]=(0,n.useState)(!1),[g,j]=(0,n.useState)(""),b=()=>{u(!0),s.hi.get("/api/custom-providers").then(t).finally(()=>u(!1))};(0,n.useEffect)(()=>{b()},[]),n.useEffect(()=>{if(g){let e=setTimeout(()=>j(""),3e3);return()=>clearTimeout(e)}},[g]);let N=e=>{var t;p(e),f({name:e.name,display_name:e.display_name,base_url:e.base_url,auth_header:e.auth_header,auth_prefix:e.auth_prefix,custom_headers:e.custom_headers,models:(null===(t=e.models)||void 0===t?void 0:t.join(", "))||"",notes:e.notes}),h(!0)},w=async()=>{if(x.name.trim()&&x.display_name.trim()&&x.base_url.trim()){y(!0);try{let e={name:x.name,display_name:x.display_name,base_url:x.base_url};x.auth_header&&(e.auth_header=x.auth_header),x.auth_prefix&&(e.auth_prefix=x.auth_prefix),x.custom_headers&&(e.custom_headers=x.custom_headers),x.models.trim()&&(e.models=x.models.split(",").map(e=>e.trim()).filter(Boolean)),x.notes&&(e.notes=x.notes),m?(await s.hi.put("/api/custom-providers/".concat(m.id),e),j("Provider updated")):(await s.hi.post("/api/custom-providers",e),j("Provider created")),h(!1),b()}catch(e){j(e instanceof Error?e.message:"Failed to save")}finally{y(!1)}}},_=async e=>{await s.hi.patch("/api/custom-providers/".concat(e,"/toggle")),b()},k=async e=>{confirm("Delete this custom provider?")&&(await s.hi.delete("/api/custom-providers/".concat(e)),b(),j("Provider deleted"))};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Custom Providers"}),(0,r.jsx)("p",{className:"page-sub",children:"Manage custom API provider integrations"})]}),(0,r.jsxs)("button",{className:"btn-primary",onClick:()=>{p(null),f(c),h(!0)},children:[(0,r.jsx)(i.Z,{size:16})," Add Provider"]})]}),d&&(0,r.jsx)("div",{className:"modal-overlay",onClick:()=>h(!1),children:(0,r.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-4",children:m?"Edit Provider":"New Custom Provider"}),(0,r.jsxs)("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Name *"}),(0,r.jsx)("input",{className:"input",value:x.name,onChange:e=>f(t=>({...t,name:e.target.value})),placeholder:"my-provider",autoFocus:!0})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Display Name *"}),(0,r.jsx)("input",{className:"input",value:x.display_name,onChange:e=>f(t=>({...t,display_name:e.target.value})),placeholder:"My Provider"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Base URL *"}),(0,r.jsx)("input",{className:"input",value:x.base_url,onChange:e=>f(t=>({...t,base_url:e.target.value})),placeholder:"https://api.example.com"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Auth Header"}),(0,r.jsx)("input",{className:"input",value:x.auth_header,onChange:e=>f(t=>({...t,auth_header:e.target.value})),placeholder:"Authorization"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Auth Prefix"}),(0,r.jsx)("input",{className:"input",value:x.auth_prefix,onChange:e=>f(t=>({...t,auth_prefix:e.target.value})),placeholder:"Bearer"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Custom Headers (JSON)"}),(0,r.jsx)("input",{className:"input",value:x.custom_headers,onChange:e=>f(t=>({...t,custom_headers:e.target.value})),placeholder:'{"X-API-Key": "..."}'})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Models (comma-separated)"}),(0,r.jsx)("input",{className:"input",value:x.models,onChange:e=>f(t=>({...t,models:e.target.value})),placeholder:"model-1, model-2"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Notes"}),(0,r.jsx)("input",{className:"input",value:x.notes,onChange:e=>f(t=>({...t,notes:e.target.value})),placeholder:"Optional notes"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:w,disabled:v,children:v?"Saving...":"Save"}),(0,r.jsx)("button",{className:"btn-ghost",onClick:()=>h(!1),children:"Cancel"})]})]})]})}),a?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-32 w-full"})}):0===e.length?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No custom providers yet. Add one to integrate external APIs."})]}):(0,r.jsx)("div",{className:"card p-0",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"Name"}),(0,r.jsx)("th",{children:"Display Name"}),(0,r.jsx)("th",{children:"Base URL"}),(0,r.jsx)("th",{children:"Models"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>{var t,a;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"font-medium",children:e.name}),(0,r.jsx)("td",{className:"text-sm",children:e.display_name}),(0,r.jsx)("td",{className:"text-xs max-w-[200px] truncate font-mono",title:e.base_url,children:e.base_url}),(0,r.jsxs)("td",{className:"text-xs max-w-[160px] truncate",title:null===(t=e.models)||void 0===t?void 0:t.join(", "),children:[(null===(a=e.models)||void 0===a?void 0:a.length)||0," models"]}),(0,r.jsx)("td",{children:(0,r.jsx)("button",{onClick:()=>_(e.id),className:e.is_active?"badge-green cursor-pointer":"badge-red cursor-pointer",children:e.is_active?"Active":"Disabled"})}),(0,r.jsx)("td",{className:"text-right",children:(0,r.jsxs)("div",{className:"flex gap-1 justify-end",children:[(0,r.jsx)("button",{onClick:()=>N(e),className:"btn-ghost btn-xs",children:"Edit"}),(0,r.jsx)("button",{onClick:()=>k(e.id),className:"btn-danger btn-xs",children:(0,r.jsx)(o.Z,{size:14})})]})})]},e.id)})})]})})}),g&&(0,r.jsx)("div",{className:"toast",children:g})]})}},1837:function(e,t,a){"use strict";a.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return i},qz:function(){return s}});let r=a(257).env.NEXT_PUBLIC_API_BASE||"";function n(){return localStorage.getItem("nexus_token")}function s(){localStorage.removeItem("nexus_token")}function i(){return!!n()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,c=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.method||"GET",i=n(),u={"Content-Type":"application/json",...t.headers};if(i&&(u.Authorization="Bearer ".concat(i)),"GET"===a&&!i){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let a=c.get(e);if(a)return a}let d=(async()=>{let n=await fetch("".concat(r).concat(e),{method:a,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return n;if(401===n.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!n.ok)throw Error((await n.json().catch(()=>({detail:n.statusText}))).detail||"HTTP ".concat(n.status));if(204===n.status)return;let l=await n.json();return"GET"!==a||i||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===a&&!i){c.set(e,d);try{return await d}finally{c.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var a;let r=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return a=r.access_token,localStorage.setItem("nexus_token",a),r},getMe:()=>u("/api/auth/me"),logout:()=>{s(),o.clear(),window.location.href="/login"}},h=async e=>{let t=n(),a=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!a.ok)throw Error("Failed to download");let s=await a.blob(),i=URL.createObjectURL(s),l=document.createElement("a");l.href=i,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=4295)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/docs/page-097f3b9b394516d9.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2726],{9321:function(e,t,s){Promise.resolve().then(s.bind(s,3532))},3532:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return i}});var n=s(7437),a=s(2265);let o=[{title:"Getting Started",items:[{label:"Quick Start",content:"NexusAI Gateway is a self-hosted AI API gateway. Deploy it on your server or HuggingFace Spaces. Default login: admin / nexus1234."},{label:"Authentication",content:"Use the login page to access the dashboard. Hub API keys (nxs-... prefix) are used for external access. Create them in the Keys page."}]},{title:"API Reference",items:[{label:"Chat Completions",content:"POST /v1/chat/completions — OpenAI-compatible chat endpoint. Supports all formats (OpenAI, Anthropic, Gemini, Cohere). Auto-detects input format and converts to canonical format."},{label:"Messages",content:"POST /v1/messages — Anthropic Messages API compatibility layer. Supports streaming."},{label:"Responses",content:"POST /v1/responses — API Responses endpoint. Accepts OpenAI-like response format."},{label:"Models",content:"GET /v1/models — List available models. Returns OpenAI-compatible model list."}]},{title:"Format Adapter",items:[{label:"Auto-Detection",content:"NexusAI auto-detects input format from the request body structure. No format headers needed. Supported: OpenAI Chat, OpenAI Responses, Anthropic Messages, Google Gemini, Cohere Chat, Generic."},{label:"Manual Override",content:"Set X-NexusAI-Input-Format and X-NexusAI-Output-Format headers to force a specific format conversion."}]},{title:"Routing",items:[{label:"Auto-Select",content:"When no explicit routing rule matches, NexusAI auto-selects the best provider based on model name, key availability, and provider capabilities."},{label:"Routing Rules",content:"Create patterns (e.g., gpt-4*) to route specific models to specific providers. Rules are checked in priority order."},{label:"Latency-Aware Routing",content:'Use the "lowest_latency" strategy to route to the fastest provider based on recent health check results.'}]},{title:"Rate Limiting",items:[{label:"RPM/TPM Enforcement",content:"Set rate limits on provider keys. Keys exceeding RPM (requests per minute) or TPM (tokens per minute) limits within a 60s window are excluded from selection."},{label:"Token Bucket",content:"In-memory token bucket for burst protection. Prevents upstream providers from being overwhelmed by sudden traffic spikes."}]},{title:"Providers",items:[{label:"Supported Providers",content:"OpenAI, Anthropic, Google Gemini, AWS Bedrock, Azure OpenAI, xAI Grok, GitHub Models, Replicate, HuggingFace Inference, AI21 Labs, Ollama, vLLM, LM Studio, TGI, LocalAI, Cohere, Mistral, Perplexity, Together, DeepSeek, Groq, Fireworks, OpenRouter, Novita, Lepton, Anyscale, Sambanova, Cloudflare Workers AI (28 total)."}]}];function i(){let[e,t]=a.useState("Getting Started");return(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"page-header",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Documentation"}),(0,n.jsx)("p",{className:"page-sub",children:"Everything you need to use NexusAI Gateway"})]})}),(0,n.jsx)("div",{className:"space-y-4",children:o.map(s=>(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("button",{className:"flex items-center justify-between w-full text-left",onClick:()=>t(e===s.title?null:s.title),children:[(0,n.jsx)("h2",{className:"text-sm font-semibold",children:s.title}),(0,n.jsx)("span",{className:"transition-transform ".concat(e===s.title?"rotate-180":""),children:"▼"})]}),e===s.title&&(0,n.jsx)("div",{className:"mt-4 space-y-4",children:s.items.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-nexus-400 mb-1",children:e.label}),(0,n.jsx)("p",{className:"text-sm text-[var(--text-secondary)] leading-relaxed",children:e.content})]},e.label))})]},s.title))})]})}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=9321)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/error-6f447ef91b6f7d27.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7601],{3228:function(e,r,n){Promise.resolve().then(n.bind(n,376))},376:function(e,r,n){"use strict";n.r(r),n.d(r,{default:function(){return o}});var t=n(7437);function o(e){let{error:r,reset:n}=e;return(0,t.jsx)("div",{style:{minHeight:"60vh",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:(0,t.jsxs)("div",{style:{maxWidth:480,width:"100%",background:"var(--surface)",border:"1px solid var(--border)",borderRadius:12,padding:32,textAlign:"center"},children:[(0,t.jsxs)("svg",{width:48,height:48,style:{color:"var(--red)",margin:"0 auto 16px"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,t.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,t.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),(0,t.jsx)("h1",{style:{fontSize:20,fontWeight:600,margin:"0 0 8px"},children:"Something went wrong"}),(0,t.jsx)("p",{style:{color:"var(--text-secondary)",fontSize:14,margin:"0 0 8px",wordBreak:"break-word"},children:(null==r?void 0:r.message)||"An unexpected error occurred"}),(null==r?void 0:r.digest)&&(0,t.jsxs)("p",{style:{color:"var(--text-tertiary)",fontSize:11,fontFamily:"ui-monospace, monospace",margin:"0 0 24px"},children:["Error ID: ",r.digest]}),(0,t.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[(0,t.jsx)("button",{onClick:n,style:{background:"var(--accent)",color:"#fff",border:"none",padding:"10px 20px",borderRadius:8,fontSize:14,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:"Try again"}),(0,t.jsx)("button",{onClick:()=>{window.location.href="/"},style:{background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border)",padding:"10px 20px",borderRadius:8,fontSize:14,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:"Go home"})]})]})})}n(2265)}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=3228)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/fallback-chains/{page-8e5925e44323ee69.js → page-85fd52fb5eae847a.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1265],{9728:function(e,t,r){Promise.resolve().then(r.bind(r,4069))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return c}});var n=r(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...h}=e;return(0,n.createElement)("svg",{ref:t,...s,width:a,height:a,stroke:r,strokeWidth:c?24*Number(l)/Number(a):l,className:i("lucide",o),...h},[...u.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let r=(0,n.forwardRef)((r,s)=>{let{className:c,...o}=r;return(0,n.createElement)(l,{ref:s,iconNode:t,className:i("lucide-".concat(a(e)),c),...o})});return r.displayName="".concat(e),r}},3781:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]])},9397:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},8930:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,r){"use strict";var n,a;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(a=r.g.process)?void 0:a.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,a=e.exports={};function i(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c=[],o=!1,d=-1;function u(){o&&n&&(o=!1,n.length?c=n.concat(c):d=-1,c.length&&h())}function h(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(n=c,c=[];++d<t;)n&&n[d].run();d=-1,t=c.length}n=null,o=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function f(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new m(e,t)),1!==c.length||o||l(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=f,a.addListener=f,a.once=f,a.off=f,a.removeListener=f,a.removeAllListeners=f,a.emit=f,a.prependListener=f,a.prependOnceListener=f,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}},s=!0;try{t[e](i,i.exports,n),s=!1}finally{s&&delete r[e]}return i.exports}n.ab="//";var a=n(229);e.exports=a}()},4069:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return o}});var n=r(7437),a=r(2265),i=r(1837),s=r(9397),l=r(3781),c=r(8930);function o(){let[e,t]=(0,a.useState)([]),[r,o]=(0,a.useState)(!0),[d,u]=(0,a.useState)(""),[h,m]=(0,a.useState)(!1),[f,x]=(0,a.useState)({name:"",description:"",trigger_models:"",chain:""}),[p,g]=(0,a.useState)(null),v=()=>{o(!0),i.hi.get("/api/fallback-chains").then(t).catch(()=>t([])).finally(()=>o(!1))};(0,a.useEffect)(()=>{v()},[]),(0,a.useEffect)(()=>{if(d){let e=setTimeout(()=>u(""),3e3);return()=>clearTimeout(e)}},[d]);let y=async e=>{try{await i.hi.patch("/api/fallback-chains/".concat(e,"/toggle")),t(t=>t.map(t=>t.id===e?{...t,is_active:!t.is_active}:t))}catch(e){u("Failed to toggle")}},j=async e=>{try{await i.hi.delete("/api/fallback-chains/".concat(e)),t(t=>t.filter(t=>t.id!==e)),g(null),u("Chain deleted")}catch(e){u("Failed to delete")}},b=e=>{try{let t=JSON.parse(e);if(!Array.isArray(t))throw Error();return t.map(e=>{if("object"!=typeof e||null===e||!("provider"in e)||!("model"in e))throw Error();return{provider:String(e.provider),model:String(e.model)}})}catch(e){throw Error("Chain must be a JSON array of {provider, model} objects")}},N=async()=>{let e;if(!f.name){u("Name is required");return}if(f.chain.trim())try{e=b(f.chain)}catch(e){u(e instanceof Error?e.message:"Invalid chain format");return}let t=f.trigger_models.trim()?f.trigger_models.split(",").map(e=>e.trim()).filter(Boolean):void 0;try{await i.hi.post("/api/fallback-chains",{name:f.name,description:f.description||void 0,trigger_models:t,chain:e}),m(!1),x({name:"",description:"",trigger_models:"",chain:""}),v(),u("Chain created")}catch(e){u(e instanceof Error?e.message:"Failed")}};return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"page-header",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Fallback Chains"}),(0,n.jsx)("p",{className:"page-sub",children:"Model fallback and retry chain configuration"})]}),(0,n.jsxs)("button",{className:"btn-primary",onClick:()=>m(!0),children:[(0,n.jsx)(s.Z,{size:16})," New Chain"]})]}),h&&(0,n.jsx)("div",{className:"modal-overlay",onClick:()=>m(!1),children:(0,n.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"New Fallback Chain"}),(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Name"}),(0,n.jsx)("input",{className:"input",value:f.name,onChange:e=>x(t=>({...t,name:e.target.value})),autoFocus:!0})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Description"}),(0,n.jsx)("input",{className:"input",value:f.description,onChange:e=>x(t=>({...t,description:e.target.value}))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Trigger Models (comma-separated)"}),(0,n.jsx)("input",{className:"input",value:f.trigger_models,onChange:e=>x(t=>({...t,trigger_models:e.target.value})),placeholder:"gpt-4, claude-3-opus"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Fallback Chain (JSON array)"}),(0,n.jsx)("textarea",{className:"input font-mono text-xs min-h-[80px] resize-y",value:f.chain,onChange:e=>x(t=>({...t,chain:e.target.value})),placeholder:'[{"provider": "openai", "model": "gpt-3.5-turbo"}, {"provider": "anthropic", "model": "claude-3-haiku"}]'})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:N,children:"Create"}),(0,n.jsx)("button",{className:"btn-ghost",onClick:()=>m(!1),children:"Cancel"})]})]})]})}),null!==p&&(0,n.jsx)("div",{className:"modal-overlay",onClick:()=>g(null),children:(0,n.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Delete Chain"}),(0,n.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:"Are you sure you want to delete this fallback chain? This action cannot be undone."}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{className:"btn-danger flex-1 justify-center",onClick:()=>j(p),children:"Delete"}),(0,n.jsx)("button",{className:"btn-ghost",onClick:()=>g(null),children:"Cancel"})]})]})}),r?(0,n.jsx)("div",{className:"card",children:(0,n.jsx)("div",{className:"skeleton h-32 w-full"})}):0===e.length?(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No fallback chains configured."})]}):(0,n.jsx)("div",{className:"card p-0",children:(0,n.jsx)("div",{className:"table-wrap",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"ID"}),(0,n.jsx)("th",{children:"Name"}),(0,n.jsx)("th",{children:"Trigger Models"}),(0,n.jsx)("th",{children:"Chain Steps"}),(0,n.jsx)("th",{children:"Times Triggered"}),(0,n.jsx)("th",{children:"Status"}),(0,n.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,n.jsx)("tbody",{children:e.map(e=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"text-xs font-mono text-[var(--text-tertiary)]",children:e.id}),(0,n.jsx)("td",{className:"font-medium",children:e.name}),(0,n.jsx)("td",{children:e.trigger_models.length>0?(0,n.jsx)("div",{className:"flex gap-1 flex-wrap",children:e.trigger_models.map(e=>(0,n.jsx)("span",{className:"badge-purple text-xs",children:e},e))}):(0,n.jsx)("span",{className:"text-xs text-[var(--text-tertiary)]",children:"Any"})}),(0,n.jsx)("td",{children:(0,n.jsx)("div",{className:"flex flex-col gap-0.5",children:e.chain.map((e,t)=>(0,n.jsxs)("span",{className:"text-xs text-[var(--text-secondary)]",children:[t>0&&(0,n.jsx)("span",{className:"text-[var(--text-tertiary)] mr-1",children:"→"}),(0,n.jsx)("span",{className:"font-medium",children:e.provider}),"/",e.model]},t))})}),(0,n.jsx)("td",{className:"font-mono text-sm",children:e.times_triggered}),(0,n.jsx)("td",{children:(0,n.jsx)("button",{onClick:()=>y(e.id),className:e.is_active?"badge-green cursor-pointer":"badge-red cursor-pointer",children:e.is_active?"Active":"Disabled"})}),(0,n.jsx)("td",{className:"text-right",children:(0,n.jsx)("button",{onClick:()=>g(e.id),className:"btn-ghost btn-xs text-[var(--text-tertiary)] hover:text-red-400",title:"Delete",children:(0,n.jsx)(c.Z,{size:14})})})]},e.id))})]})})}),d&&(0,n.jsx)("div",{className:"toast",children:d})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return s},qz:function(){return i}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function a(){return localStorage.getItem("nexus_token")}function i(){localStorage.removeItem("nexus_token")}function s(){return!!a()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",s=a(),d={"Content-Type":"application/json",...t.headers};if(s&&(d.Authorization="Bearer ".concat(s)),"GET"===r&&!s){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=o.get(e);if(r)return r}let u=(async()=>{let a=await fetch("".concat(n).concat(e),{method:r,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let l=await a.json();return"GET"!==r||s||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===r&&!s){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),n},getMe:()=>d("/api/auth/me"),logout:()=>{i(),c.clear(),window.location.href="/login"}},h=async e=>{let t=a(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let i=await r.blob(),s=URL.createObjectURL(i),l=document.createElement("a");l.href=s,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=9728)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1265],{9728:function(e,t,n){Promise.resolve().then(n.bind(n,4069))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,r.forwardRef)((e,t)=>{let{color:n="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:l,className:o="",children:d,iconNode:u,...h}=e;return(0,r.createElement)("svg",{ref:t,...s,width:a,height:a,stroke:n,strokeWidth:l?24*Number(c)/Number(a):c,className:i("lucide",o),...h},[...u.map(e=>{let[t,n]=e;return(0,r.createElement)(t,n)}),...Array.isArray(d)?d:[d]])}),l=(e,t)=>{let n=(0,r.forwardRef)((n,s)=>{let{className:l,...o}=n;return(0,r.createElement)(c,{ref:s,iconNode:t,className:i("lucide-".concat(a(e)),l),...o})});return n.displayName="".concat(e),n}},3781:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]])},9397:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},8930:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});let r=(0,n(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,n){"use strict";var r,a;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(a=n.g.process)?void 0:a.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,r,a=e.exports={};function i(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var l=[],o=!1,d=-1;function u(){o&&r&&(o=!1,r.length?l=r.concat(l):d=-1,l.length&&h())}function h(){if(!o){var e=c(u);o=!0;for(var t=l.length;t;){for(r=l,l=[];++d<t;)r&&r[d].run();d=-1,t=l.length}r=null,o=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function f(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new m(e,t)),1!==l.length||o||c(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=f,a.addListener=f,a.once=f,a.off=f,a.removeListener=f,a.removeAllListeners=f,a.emit=f,a.prependListener=f,a.prependOnceListener=f,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var i=n[e]={exports:{}},s=!0;try{t[e](i,i.exports,r),s=!1}finally{s&&delete n[e]}return i.exports}r.ab="//";var a=r(229);e.exports=a}()},4069:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return o}});var r=n(7437),a=n(2265),i=n(1837),s=n(9397),c=n(3781),l=n(8930);function o(){let[e,t]=(0,a.useState)([]),[n,o]=(0,a.useState)(!0),[d,u]=(0,a.useState)(""),[h,m]=(0,a.useState)(!1),[f,x]=(0,a.useState)({name:"",description:"",trigger_models:"",chain:""}),[p,g]=(0,a.useState)(null),v=()=>{o(!0),i.hi.get("/api/fallback-chains").then(t).catch(()=>t([])).finally(()=>o(!1))};(0,a.useEffect)(()=>{v()},[]),(0,a.useEffect)(()=>{if(d){let e=setTimeout(()=>u(""),3e3);return()=>clearTimeout(e)}},[d]);let y=async e=>{try{await i.hi.patch("/api/fallback-chains/".concat(e,"/toggle")),t(t=>t.map(t=>t.id===e?{...t,is_active:!t.is_active}:t))}catch(e){u("Failed to toggle")}},j=async e=>{try{await i.hi.delete("/api/fallback-chains/".concat(e)),t(t=>t.filter(t=>t.id!==e)),g(null),u("Chain deleted")}catch(e){u("Failed to delete")}},b=e=>{try{let t=JSON.parse(e);if(!Array.isArray(t))throw Error();return t.map(e=>{if("object"!=typeof e||null===e||!("provider"in e)||!("model"in e))throw Error();return{provider:String(e.provider),model:String(e.model)}})}catch(e){throw Error("Chain must be a JSON array of {provider, model} objects")}},N=async()=>{let e;if(!f.name){u("Name is required");return}if(f.chain.trim())try{e=b(f.chain)}catch(e){u(e instanceof Error?e.message:"Invalid chain format");return}let t=f.trigger_models.trim()?f.trigger_models.split(",").map(e=>e.trim()).filter(Boolean):void 0;try{await i.hi.post("/api/fallback-chains",{name:f.name,description:f.description||void 0,trigger_models:t,chain:e}),m(!1),x({name:"",description:"",trigger_models:"",chain:""}),v(),u("Chain created")}catch(e){u(e instanceof Error?e.message:"Failed")}};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"page-header",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"page-title",children:"Fallback Chains"}),(0,r.jsx)("p",{className:"page-sub",children:"Model fallback and retry chain configuration"})]}),(0,r.jsxs)("button",{className:"btn-primary",onClick:()=>m(!0),children:[(0,r.jsx)(s.Z,{size:16})," New Chain"]})]}),h&&(0,r.jsx)("div",{className:"modal-overlay",onClick:()=>m(!1),children:(0,r.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"New Fallback Chain"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Name"}),(0,r.jsx)("input",{className:"input",value:f.name,onChange:e=>x(t=>({...t,name:e.target.value})),autoFocus:!0})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Description"}),(0,r.jsx)("input",{className:"input",value:f.description,onChange:e=>x(t=>({...t,description:e.target.value}))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Trigger Models (comma-separated)"}),(0,r.jsx)("input",{className:"input",value:f.trigger_models,onChange:e=>x(t=>({...t,trigger_models:e.target.value})),placeholder:"gpt-4, claude-3-opus"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"label",children:"Fallback Chain (JSON array)"}),(0,r.jsx)("textarea",{className:"input font-mono text-xs min-h-[80px] resize-y",value:f.chain,onChange:e=>x(t=>({...t,chain:e.target.value})),placeholder:'[{"provider": "openai", "model": "gpt-3.5-turbo"}, {"provider": "anthropic", "model": "claude-3-haiku"}]'})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:N,children:"Create"}),(0,r.jsx)("button",{className:"btn-ghost",onClick:()=>m(!1),children:"Cancel"})]})]})]})}),null!==p&&(0,r.jsx)("div",{className:"modal-overlay",onClick:()=>g(null),children:(0,r.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Delete Chain"}),(0,r.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:"Are you sure you want to delete this fallback chain? This action cannot be undone."}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"btn-danger flex-1 justify-center",onClick:()=>j(p),children:"Delete"}),(0,r.jsx)("button",{className:"btn-ghost",onClick:()=>g(null),children:"Cancel"})]})]})}),n?(0,r.jsx)("div",{className:"card",children:(0,r.jsx)("div",{className:"skeleton h-32 w-full"})}):0===e.length?(0,r.jsxs)("div",{className:"card text-center py-12",children:[(0,r.jsx)(c.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,r.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No fallback chains configured."})]}):(0,r.jsx)("div",{className:"card p-0",children:(0,r.jsx)("div",{className:"table-wrap",children:(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:"ID"}),(0,r.jsx)("th",{children:"Name"}),(0,r.jsx)("th",{children:"Trigger Models"}),(0,r.jsx)("th",{children:"Chain Steps"}),(0,r.jsx)("th",{children:"Times Triggered"}),(0,r.jsx)("th",{children:"Status"}),(0,r.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:e.map(e=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"text-xs font-mono text-[var(--text-tertiary)]",children:e.id}),(0,r.jsx)("td",{className:"font-medium",children:e.name}),(0,r.jsx)("td",{children:e.trigger_models.length>0?(0,r.jsx)("div",{className:"flex gap-1 flex-wrap",children:e.trigger_models.map(e=>(0,r.jsx)("span",{className:"badge-purple text-xs",children:e},e))}):(0,r.jsx)("span",{className:"text-xs text-[var(--text-tertiary)]",children:"Any"})}),(0,r.jsx)("td",{children:(0,r.jsx)("div",{className:"flex flex-col gap-0.5",children:e.chain.map((e,t)=>(0,r.jsxs)("span",{className:"text-xs text-[var(--text-secondary)]",children:[t>0&&(0,r.jsx)("span",{className:"text-[var(--text-tertiary)] mr-1",children:"→"}),(0,r.jsx)("span",{className:"font-medium",children:e.provider}),"/",e.model]},t))})}),(0,r.jsx)("td",{className:"font-mono text-sm",children:e.times_triggered}),(0,r.jsx)("td",{children:(0,r.jsx)("button",{onClick:()=>y(e.id),className:e.is_active?"badge-green cursor-pointer":"badge-red cursor-pointer",children:e.is_active?"Active":"Disabled"})}),(0,r.jsx)("td",{className:"text-right",children:(0,r.jsx)("button",{onClick:()=>g(e.id),className:"btn-ghost btn-xs text-[var(--text-tertiary)] hover:text-red-400",title:"Delete",children:(0,r.jsx)(l.Z,{size:14})})})]},e.id))})]})})}),d&&(0,r.jsx)("div",{className:"toast",children:d})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return s},qz:function(){return i}});let r=n(257).env.NEXT_PUBLIC_API_BASE||"";function a(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function i(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function s(){return!!a()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},l=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",s=a(),d={"Content-Type":"application/json",...t.headers};if(s&&(d.Authorization="Bearer ".concat(s)),"GET"===n&&!s){let t=function(e){let t=l.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){l.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=o.get(e);if(n)return n}let u=(async()=>{let a=await fetch("".concat(r).concat(e),{method:n,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),l.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let c=await a.json();return"GET"!==n||s||function(e,t){if(l.size>=200){let e=l.keys().next().value;void 0!==e&&l.delete(e)}l.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===n&&!s){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var n;let r=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=r.access_token,localStorage.setItem("nexus_token",n),function(e,t,n){try{let n="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(n)}catch(e){}}("nexus_token",n,0),r},getMe:()=>d("/api/auth/me"),logout:()=>{i(),l.clear(),window.location.href="/login"}},h=async e=>{let t=a(),n=await fetch("".concat(r).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let i=await n.blob(),s=URL.createObjectURL(i),c=document.createElement("a");c.href=s,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=9728)}),_N_E=e.O()}]);
static/_next/static/chunks/app/fallback-chains/page-9e30e5f90985c3e3.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1265],{9728:function(e,t,r){Promise.resolve().then(r.bind(r,4069))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return c}});var n=r(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var s={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...h}=e;return(0,n.createElement)("svg",{ref:t,...s,width:a,height:a,stroke:r,strokeWidth:c?24*Number(l)/Number(a):l,className:i("lucide",o),...h},[...u.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let r=(0,n.forwardRef)((r,s)=>{let{className:c,...o}=r;return(0,n.createElement)(l,{ref:s,iconNode:t,className:i("lucide-".concat(a(e)),c),...o})});return r.displayName="".concat(e),r}},3781:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]])},9397:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},8930:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},257:function(e,t,r){"use strict";var n,a;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(a=r.g.process)?void 0:a.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,a=e.exports={};function i(){throw Error("setTimeout has not been defined")}function s(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c=[],o=!1,d=-1;function u(){o&&n&&(o=!1,n.length?c=n.concat(c):d=-1,c.length&&h())}function h(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(n=c,c=[];++d<t;)n&&n[d].run();d=-1,t=c.length}n=null,o=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function f(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new m(e,t)),1!==c.length||o||l(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=f,a.addListener=f,a.once=f,a.off=f,a.removeListener=f,a.removeAllListeners=f,a.emit=f,a.prependListener=f,a.prependOnceListener=f,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}},s=!0;try{t[e](i,i.exports,n),s=!1}finally{s&&delete r[e]}return i.exports}n.ab="//";var a=n(229);e.exports=a}()},4069:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return o}});var n=r(7437),a=r(2265),i=r(1837),s=r(9397),l=r(3781),c=r(8930);function o(){let[e,t]=(0,a.useState)([]),[r,o]=(0,a.useState)(!0),[d,u]=(0,a.useState)(""),[h,m]=(0,a.useState)(!1),[f,x]=(0,a.useState)({name:"",description:"",trigger_models:"",chain:""}),[p,g]=(0,a.useState)(null),v=()=>{o(!0),i.hi.get("/api/fallback-chains").then(t).catch(()=>t([])).finally(()=>o(!1))};(0,a.useEffect)(()=>{v()},[]),(0,a.useEffect)(()=>{if(d){let e=setTimeout(()=>u(""),3e3);return()=>clearTimeout(e)}},[d]);let y=async e=>{try{await i.hi.patch("/api/fallback-chains/".concat(e,"/toggle")),t(t=>t.map(t=>t.id===e?{...t,is_active:!t.is_active}:t))}catch(e){u("Failed to toggle")}},j=async e=>{try{await i.hi.delete("/api/fallback-chains/".concat(e)),t(t=>t.filter(t=>t.id!==e)),g(null),u("Chain deleted")}catch(e){u("Failed to delete")}},b=e=>{try{let t=JSON.parse(e);if(!Array.isArray(t))throw Error();return t.map(e=>{if("object"!=typeof e||null===e||!("provider"in e)||!("model"in e))throw Error();return{provider:String(e.provider),model:String(e.model)}})}catch(e){throw Error("Chain must be a JSON array of {provider, model} objects")}},N=async()=>{let e;if(!f.name){u("Name is required");return}if(f.chain.trim())try{e=b(f.chain)}catch(e){u(e instanceof Error?e.message:"Invalid chain format");return}let t=f.trigger_models.trim()?f.trigger_models.split(",").map(e=>e.trim()).filter(Boolean):void 0;try{await i.hi.post("/api/fallback-chains",{name:f.name,description:f.description||void 0,trigger_models:t,chain:e}),m(!1),x({name:"",description:"",trigger_models:"",chain:""}),v(),u("Chain created")}catch(e){u(e instanceof Error?e.message:"Failed")}};return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"page-header",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Fallback Chains"}),(0,n.jsx)("p",{className:"page-sub",children:"Model fallback and retry chain configuration"})]}),(0,n.jsxs)("button",{className:"btn-primary",onClick:()=>m(!0),children:[(0,n.jsx)(s.Z,{size:16})," New Chain"]})]}),h&&(0,n.jsx)("div",{className:"modal-overlay",onClick:()=>m(!1),children:(0,n.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"New Fallback Chain"}),(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Name"}),(0,n.jsx)("input",{className:"input",value:f.name,onChange:e=>x(t=>({...t,name:e.target.value})),autoFocus:!0})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Description"}),(0,n.jsx)("input",{className:"input",value:f.description,onChange:e=>x(t=>({...t,description:e.target.value}))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Trigger Models (comma-separated)"}),(0,n.jsx)("input",{className:"input",value:f.trigger_models,onChange:e=>x(t=>({...t,trigger_models:e.target.value})),placeholder:"gpt-4, claude-3-opus"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"label",children:"Fallback Chain (JSON array)"}),(0,n.jsx)("textarea",{className:"input font-mono text-xs min-h-[80px] resize-y",value:f.chain,onChange:e=>x(t=>({...t,chain:e.target.value})),placeholder:'[{"provider": "openai", "model": "gpt-3.5-turbo"}, {"provider": "anthropic", "model": "claude-3-haiku"}]'})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:N,children:"Create"}),(0,n.jsx)("button",{className:"btn-ghost",onClick:()=>m(!1),children:"Cancel"})]})]})]})}),null!==p&&(0,n.jsx)("div",{className:"modal-overlay",onClick:()=>g(null),children:(0,n.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Delete Chain"}),(0,n.jsx)("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:"Are you sure you want to delete this fallback chain? This action cannot be undone."}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{className:"btn-danger flex-1 justify-center",onClick:()=>j(p),children:"Delete"}),(0,n.jsx)("button",{className:"btn-ghost",onClick:()=>g(null),children:"Cancel"})]})]})}),r?(0,n.jsx)("div",{className:"card",children:(0,n.jsx)("div",{className:"skeleton h-32 w-full"})}):0===e.length?(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(l.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No fallback chains configured."})]}):(0,n.jsx)("div",{className:"card p-0",children:(0,n.jsx)("div",{className:"table-wrap",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"ID"}),(0,n.jsx)("th",{children:"Name"}),(0,n.jsx)("th",{children:"Trigger Models"}),(0,n.jsx)("th",{children:"Chain Steps"}),(0,n.jsx)("th",{children:"Times Triggered"}),(0,n.jsx)("th",{children:"Status"}),(0,n.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,n.jsx)("tbody",{children:e.map(e=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"text-xs font-mono text-[var(--text-tertiary)]",children:e.id}),(0,n.jsx)("td",{className:"font-medium",children:e.name}),(0,n.jsx)("td",{children:e.trigger_models.length>0?(0,n.jsx)("div",{className:"flex gap-1 flex-wrap",children:e.trigger_models.map(e=>(0,n.jsx)("span",{className:"badge-purple text-xs",children:e},e))}):(0,n.jsx)("span",{className:"text-xs text-[var(--text-tertiary)]",children:"Any"})}),(0,n.jsx)("td",{children:(0,n.jsx)("div",{className:"flex flex-col gap-0.5",children:e.chain.map((e,t)=>(0,n.jsxs)("span",{className:"text-xs text-[var(--text-secondary)]",children:[t>0&&(0,n.jsx)("span",{className:"text-[var(--text-tertiary)] mr-1",children:"→"}),(0,n.jsx)("span",{className:"font-medium",children:e.provider}),"/",e.model]},t))})}),(0,n.jsx)("td",{className:"font-mono text-sm",children:e.times_triggered}),(0,n.jsx)("td",{children:(0,n.jsx)("button",{onClick:()=>y(e.id),className:e.is_active?"badge-green cursor-pointer":"badge-red cursor-pointer",children:e.is_active?"Active":"Disabled"})}),(0,n.jsx)("td",{className:"text-right",children:(0,n.jsx)("button",{onClick:()=>g(e.id),className:"btn-ghost btn-xs text-[var(--text-tertiary)] hover:text-red-400",title:"Delete",children:(0,n.jsx)(c.Z,{size:14})})})]},e.id))})]})})}),d&&(0,n.jsx)("div",{className:"toast",children:d})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return s},qz:function(){return i}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function a(){return localStorage.getItem("nexus_token")}function i(){localStorage.removeItem("nexus_token")}function s(){return!!a()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",s=a(),d={"Content-Type":"application/json",...t.headers};if(s&&(d.Authorization="Bearer ".concat(s)),"GET"===r&&!s){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=o.get(e);if(r)return r}let u=(async()=>{let a=await fetch("".concat(n).concat(e),{method:r,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&s&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw i(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let l=await a.json();return"GET"!==r||s||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===r&&!s){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),n},getMe:()=>d("/api/auth/me"),logout:()=>{i(),c.clear(),window.location.href="/login"}},h=async e=>{let t=a(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let i=await r.blob(),s=URL.createObjectURL(i),l=document.createElement("a");l.href=s,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(s)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=9728)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/fine-tuning/{page-9b95c51fc01eb318.js → page-0f5de87c7b897ed1.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8919],{3461:function(e,t,n){Promise.resolve().then(n.bind(n,3396))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var a=n(2265);let i=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var r={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,a.forwardRef)((e,t)=>{let{color:n="currentColor",size:i=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...r,width:i,height:i,stroke:n,strokeWidth:c?24*Number(l)/Number(i):l,className:s("lucide",o),...h},[...u.map(e=>{let[t,n]=e;return(0,a.createElement)(t,n)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let n=(0,a.forwardRef)((n,r)=>{let{className:c,...o}=n;return(0,a.createElement)(l,{ref:r,iconNode:t,className:s("lucide-".concat(i(e)),c),...o})});return n.displayName="".concat(e),n}},4972:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]])},9322:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},1671:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},9388:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},1723:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},9397:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7689:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]])},2489:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},257:function(e,t,n){"use strict";var a,i;e.exports=(null==(a=n.g.process)?void 0:a.env)&&"object"==typeof(null==(i=n.g.process)?void 0:i.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,a,i=e.exports={};function s(){throw Error("setTimeout has not been defined")}function r(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{n="function"==typeof clearTimeout?clearTimeout:r}catch(e){n=r}}();var c=[],o=!1,d=-1;function u(){o&&a&&(o=!1,a.length?c=a.concat(c):d=-1,c.length&&h())}function h(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(a=c,c=[];++d<t;)a&&a[d].run();d=-1,t=c.length}a=null,o=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===r||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||o||l(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw Error("process.chdir is not supported")},i.umask=function(){return 0}}},n={};function a(e){var i=n[e];if(void 0!==i)return i.exports;var s=n[e]={exports:{}},r=!0;try{t[e](s,s.exports,a),r=!1}finally{r&&delete n[e]}return s.exports}a.ab="//";var i=a(229);e.exports=i}()},3396:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return y}});var a=n(7437),i=n(2265),s=n(1837),r=n(1723),l=n(1671),c=n(9388),o=n(9322),d=n(7689),u=n(9397),h=n(4972);let f=(0,n(9205).Z)("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);var m=n(2489);let x={validating:"badge-yellow",queued:"badge-blue",running:"badge-cyan",succeeded:"badge-green",failed:"badge-red",cancelled:"badge-gray"},p={validating:(0,a.jsx)(r.Z,{size:14}),queued:(0,a.jsx)(r.Z,{size:14}),running:(0,a.jsx)(r.Z,{size:14}),succeeded:(0,a.jsx)(l.Z,{size:14}),failed:(0,a.jsx)(c.Z,{size:14}),cancelled:(0,a.jsx)(o.Z,{size:14})},g=["validating","queued","running"];function y(){let[e,t]=(0,i.useState)([]),[n,r]=(0,i.useState)(!0),[l,c]=(0,i.useState)(""),[y,j]=(0,i.useState)(!1),[v,b]=(0,i.useState)(!1),[N,k]=(0,i.useState)([]),[w,T]=(0,i.useState)([]),[C,S]=(0,i.useState)(""),[Z,E]=(0,i.useState)(""),[z,_]=(0,i.useState)(3),[M,A]=(0,i.useState)(1),[L,U]=(0,i.useState)(1),[F,P]=(0,i.useState)(!1),[O,q]=(0,i.useState)(""),[B,R]=(0,i.useState)(null),[I,J]=(0,i.useState)(null),[D,G]=(0,i.useState)(!1),[H,W]=(0,i.useState)(""),X=(0,i.useRef)(null),K=()=>{r(!0),c(""),s.hi.get("/v1/fine_tuning/jobs").then(e=>t(e.data||[])).catch(e=>c(e instanceof Error?e.message:"Failed to load jobs")).finally(()=>r(!1))},$=()=>{s.hi.get("/v1/models").then(e=>{let t=e.data.map(e=>e.id).sort();k(t),t.length>0&&!C&&S(t[0])}).catch(()=>{})},Q=()=>{s.hi.get("/v1/files").then(e=>{T(e.data||[]),(e.data||[]).length>0&&E(e.data[0].id)}).catch(()=>{})};(0,i.useEffect)(()=>{K()},[]),(0,i.useEffect)(()=>{if(O){let e=setTimeout(()=>q(""),3e3);return()=>clearTimeout(e)}},[O]);let V=async()=>{if(C.trim()&&Z.trim()){P(!0);try{await s.hi.post("/v1/fine_tuning/jobs",{model:C,training_file:Z,hyperparameters:{n_epochs:z,batch_size:M,learning_rate_multiplier:L}}),j(!1),E(""),_(3),A(1),U(1),q("Fine-tuning job created"),K()}catch(e){q(e instanceof Error?e.message:"Failed to create job")}finally{P(!1)}}},Y=async e=>{if(confirm("Cancel this fine-tuning job? This action cannot be undone.")){R(e);try{await s.hi.post("/v1/fine_tuning/jobs/".concat(e,"/cancel"),{}),q("Job cancelled"),K()}catch(e){q(e instanceof Error?e.message:"Failed to cancel job")}finally{R(null)}}},ee=async()=>{if(I){G(!0),W("Uploading...");try{let e=await I.text(),t=localStorage.getItem("nexus_token"),n=await fetch("/v1/files",{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:"Bearer ".concat(t)}:{}},body:JSON.stringify({file:e,purpose:"fine-tune"})});if(!n.ok){let e=await n.json().catch(()=>({detail:n.statusText}));throw Error(e.detail||"HTTP ".concat(n.status))}let a=await n.json();q("Uploaded: ".concat(a.filename||a.id||"file")),b(!1),J(null),X.current&&(X.current.value=""),Q()}catch(e){W(e instanceof Error?e.message:"Upload failed")}finally{G(!1)}}},et=e=>new Date(1e3*e).toLocaleString();return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"page-header",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"page-title",children:"Fine-Tuning"}),(0,a.jsx)("p",{className:"page-sub",children:"Manage fine-tuning jobs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("button",{className:"btn-secondary",onClick:()=>b(!0),children:[(0,a.jsx)(d.Z,{size:16})," Upload File"]}),(0,a.jsxs)("button",{className:"btn-primary",onClick:()=>{$(),Q(),j(!0)},children:[(0,a.jsx)(u.Z,{size:16})," Create Job"]})]})]}),y&&(0,a.jsx)("div",{className:"modal-overlay",onClick:()=>j(!1),children:(0,a.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Create Fine-Tuning Job"}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Model"}),(0,a.jsxs)("select",{className:"select",value:C,onChange:e=>S(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Select model"}),N.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Training File"}),(0,a.jsxs)("select",{className:"select",value:Z,onChange:e=>E(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Select file"}),w.map(e=>(0,a.jsxs)("option",{value:e.id,children:[e.filename," (",e.id,")"]},e.id))]}),0===w.length&&(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:'No files uploaded yet. Use "Upload File" first.'})]}),(0,a.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Epochs"}),(0,a.jsx)("input",{className:"input",type:"number",min:1,value:z,onChange:e=>_(Number(e.target.value))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Batch Size"}),(0,a.jsx)("input",{className:"input",type:"number",min:1,value:M,onChange:e=>A(Number(e.target.value))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Learning Rate"}),(0,a.jsx)("input",{className:"input",type:"number",step:"0.1",min:.1,value:L,onChange:e=>U(Number(e.target.value))})]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:V,disabled:F||!C||!Z,children:F?"Creating...":"Create"}),(0,a.jsx)("button",{className:"btn-ghost",onClick:()=>j(!1),children:"Cancel"})]})]})]})}),n?(0,a.jsx)("div",{className:"card",children:(0,a.jsx)("div",{className:"skeleton h-32 w-full"})}):l?(0,a.jsxs)("div",{className:"card text-center py-12",children:[(0,a.jsx)(o.Z,{size:32,className:"mx-auto mb-3 text-red-400"}),(0,a.jsx)("p",{className:"text-red-400",children:l})]}):0===e.length?(0,a.jsxs)("div",{className:"card text-center py-12",children:[(0,a.jsx)(h.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,a.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No fine-tuning jobs yet."})]}):(0,a.jsx)("div",{className:"card p-0",children:(0,a.jsx)("div",{className:"table-wrap",children:(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"ID"}),(0,a.jsx)("th",{children:"Model"}),(0,a.jsx)("th",{children:"Status"}),(0,a.jsx)("th",{children:"Created"}),(0,a.jsx)("th",{children:"Trained Tokens"}),(0,a.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,a.jsx)("tbody",{children:e.map(e=>{var t;return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"font-mono text-xs",children:e.id}),(0,a.jsx)("td",{className:"font-medium",children:e.model}),(0,a.jsx)("td",{children:(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 ".concat(x[e.status]||"badge-gray"),children:[p[e.status]||null,e.status]})}),(0,a.jsx)("td",{className:"text-xs text-[var(--text-tertiary)]",children:et(e.created_at)}),(0,a.jsx)("td",{children:(null===(t=e.trained_tokens)||void 0===t?void 0:t.toLocaleString())||"-"}),(0,a.jsx)("td",{className:"text-right",children:g.includes(e.status)&&(0,a.jsx)("button",{onClick:()=>Y(e.id),disabled:B===e.id,className:"btn-danger btn-xs",title:"Cancel job",children:B===e.id?(0,a.jsx)("span",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(f,{size:14})})})]},e.id)})})]})})}),v&&(0,a.jsx)("div",{className:"modal-overlay",onClick:()=>!D&&b(!1),children:(0,a.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Upload Training File"}),(0,a.jsx)("button",{onClick:()=>!D&&b(!1),className:"btn-ghost btn-xs",children:(0,a.jsx)(m.Z,{size:14})})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"File (JSONL)"}),(0,a.jsx)("input",{ref:X,type:"file",className:"input",accept:".jsonl,.json,.txt",onChange:e=>{var t;return J((null===(t=e.target.files)||void 0===t?void 0:t[0])||null)},disabled:D}),I&&(0,a.jsxs)("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:["Selected: ",I.name," (",(I.size/1024).toFixed(1)," KB)"]})]}),H&&(0,a.jsx)("p",{className:"text-sm text-[var(--text-secondary)]",children:H}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:ee,disabled:!I||D,children:D?"Uploading...":"Upload"}),(0,a.jsx)("button",{className:"btn-ghost",onClick:()=>!D&&b(!1),disabled:D,children:"Cancel"})]})]})]})}),O&&(0,a.jsx)("div",{className:"toast",children:O})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return r},qz:function(){return s}});let a=n(257).env.NEXT_PUBLIC_API_BASE||"";function i(){return localStorage.getItem("nexus_token")}function s(){localStorage.removeItem("nexus_token")}function r(){return!!i()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",r=i(),d={"Content-Type":"application/json",...t.headers};if(r&&(d.Authorization="Bearer ".concat(r)),"GET"===n&&!r){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=o.get(e);if(n)return n}let u=(async()=>{let i=await fetch("".concat(a).concat(e),{method:n,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return i;if(401===i.status&&r&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!i.ok)throw Error((await i.json().catch(()=>({detail:i.statusText}))).detail||"HTTP ".concat(i.status));if(204===i.status)return;let l=await i.json();return"GET"!==n||r||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===n&&!r){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var n;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=a.access_token,localStorage.setItem("nexus_token",n),a},getMe:()=>d("/api/auth/me"),logout:()=>{s(),c.clear(),window.location.href="/login"}},h=async e=>{let t=i(),n=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let s=await n.blob(),r=URL.createObjectURL(s),l=document.createElement("a");l.href=r,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(r)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=3461)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8919],{3461:function(e,t,n){Promise.resolve().then(n.bind(n,3396))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var a=n(2265);let i=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var r={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,a.forwardRef)((e,t)=>{let{color:n="currentColor",size:i=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...r,width:i,height:i,stroke:n,strokeWidth:c?24*Number(l)/Number(i):l,className:s("lucide",o),...h},[...u.map(e=>{let[t,n]=e;return(0,a.createElement)(t,n)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let n=(0,a.forwardRef)((n,r)=>{let{className:c,...o}=n;return(0,a.createElement)(l,{ref:r,iconNode:t,className:s("lucide-".concat(i(e)),c),...o})});return n.displayName="".concat(e),n}},4972:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]])},9322:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},1671:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},9388:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},1723:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},9397:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7689:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]])},2489:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},257:function(e,t,n){"use strict";var a,i;e.exports=(null==(a=n.g.process)?void 0:a.env)&&"object"==typeof(null==(i=n.g.process)?void 0:i.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,a,i=e.exports={};function s(){throw Error("setTimeout has not been defined")}function r(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{n="function"==typeof clearTimeout?clearTimeout:r}catch(e){n=r}}();var c=[],o=!1,d=-1;function u(){o&&a&&(o=!1,a.length?c=a.concat(c):d=-1,c.length&&h())}function h(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(a=c,c=[];++d<t;)a&&a[d].run();d=-1,t=c.length}a=null,o=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===r||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||o||l(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw Error("process.chdir is not supported")},i.umask=function(){return 0}}},n={};function a(e){var i=n[e];if(void 0!==i)return i.exports;var s=n[e]={exports:{}},r=!0;try{t[e](s,s.exports,a),r=!1}finally{r&&delete n[e]}return s.exports}a.ab="//";var i=a(229);e.exports=i}()},3396:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return y}});var a=n(7437),i=n(2265),s=n(1837),r=n(1723),l=n(1671),c=n(9388),o=n(9322),d=n(7689),u=n(9397),h=n(4972);let f=(0,n(9205).Z)("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);var m=n(2489);let x={validating:"badge-yellow",queued:"badge-blue",running:"badge-cyan",succeeded:"badge-green",failed:"badge-red",cancelled:"badge-gray"},p={validating:(0,a.jsx)(r.Z,{size:14}),queued:(0,a.jsx)(r.Z,{size:14}),running:(0,a.jsx)(r.Z,{size:14}),succeeded:(0,a.jsx)(l.Z,{size:14}),failed:(0,a.jsx)(c.Z,{size:14}),cancelled:(0,a.jsx)(o.Z,{size:14})},g=["validating","queued","running"];function y(){let[e,t]=(0,i.useState)([]),[n,r]=(0,i.useState)(!0),[l,c]=(0,i.useState)(""),[y,j]=(0,i.useState)(!1),[v,b]=(0,i.useState)(!1),[k,N]=(0,i.useState)([]),[w,T]=(0,i.useState)([]),[C,S]=(0,i.useState)(""),[Z,E]=(0,i.useState)(""),[_,z]=(0,i.useState)(3),[L,M]=(0,i.useState)(1),[A,U]=(0,i.useState)(1),[F,P]=(0,i.useState)(!1),[O,q]=(0,i.useState)(""),[B,R]=(0,i.useState)(null),[I,J]=(0,i.useState)(null),[D,G]=(0,i.useState)(!1),[H,W]=(0,i.useState)(""),X=(0,i.useRef)(null),K=()=>{r(!0),c(""),s.hi.get("/v1/fine_tuning/jobs").then(e=>t(e.data||[])).catch(e=>c(e instanceof Error?e.message:"Failed to load jobs")).finally(()=>r(!1))},$=()=>{s.hi.get("/v1/models").then(e=>{let t=e.data.map(e=>e.id).sort();N(t),t.length>0&&!C&&S(t[0])}).catch(()=>{})},Q=()=>{s.hi.get("/v1/files").then(e=>{T(e.data||[]),(e.data||[]).length>0&&E(e.data[0].id)}).catch(()=>{})};(0,i.useEffect)(()=>{K()},[]),(0,i.useEffect)(()=>{if(O){let e=setTimeout(()=>q(""),3e3);return()=>clearTimeout(e)}},[O]);let V=async()=>{if(C.trim()&&Z.trim()){P(!0);try{await s.hi.post("/v1/fine_tuning/jobs",{model:C,training_file:Z,hyperparameters:{n_epochs:_,batch_size:L,learning_rate_multiplier:A}}),j(!1),E(""),z(3),M(1),U(1),q("Fine-tuning job created"),K()}catch(e){q(e instanceof Error?e.message:"Failed to create job")}finally{P(!1)}}},Y=async e=>{if(confirm("Cancel this fine-tuning job? This action cannot be undone.")){R(e);try{await s.hi.post("/v1/fine_tuning/jobs/".concat(e,"/cancel"),{}),q("Job cancelled"),K()}catch(e){q(e instanceof Error?e.message:"Failed to cancel job")}finally{R(null)}}},ee=async()=>{if(I){G(!0),W("Uploading...");try{let e=await I.text(),t=localStorage.getItem("nexus_token"),n=await fetch("/v1/files",{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:"Bearer ".concat(t)}:{}},body:JSON.stringify({file:e,purpose:"fine-tune"})});if(!n.ok){let e=await n.json().catch(()=>({detail:n.statusText}));throw Error(e.detail||"HTTP ".concat(n.status))}let a=await n.json();q("Uploaded: ".concat(a.filename||a.id||"file")),b(!1),J(null),X.current&&(X.current.value=""),Q()}catch(e){W(e instanceof Error?e.message:"Upload failed")}finally{G(!1)}}},et=e=>new Date(1e3*e).toLocaleString();return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"page-header",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"page-title",children:"Fine-Tuning"}),(0,a.jsx)("p",{className:"page-sub",children:"Manage fine-tuning jobs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("button",{className:"btn-secondary",onClick:()=>b(!0),children:[(0,a.jsx)(d.Z,{size:16})," Upload File"]}),(0,a.jsxs)("button",{className:"btn-primary",onClick:()=>{$(),Q(),j(!0)},children:[(0,a.jsx)(u.Z,{size:16})," Create Job"]})]})]}),y&&(0,a.jsx)("div",{className:"modal-overlay",onClick:()=>j(!1),children:(0,a.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Create Fine-Tuning Job"}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Model"}),(0,a.jsxs)("select",{className:"select",value:C,onChange:e=>S(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Select model"}),k.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Training File"}),(0,a.jsxs)("select",{className:"select",value:Z,onChange:e=>E(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Select file"}),w.map(e=>(0,a.jsxs)("option",{value:e.id,children:[e.filename," (",e.id,")"]},e.id))]}),0===w.length&&(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:'No files uploaded yet. Use "Upload File" first.'})]}),(0,a.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Epochs"}),(0,a.jsx)("input",{className:"input",type:"number",min:1,value:_,onChange:e=>z(Number(e.target.value))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Batch Size"}),(0,a.jsx)("input",{className:"input",type:"number",min:1,value:L,onChange:e=>M(Number(e.target.value))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Learning Rate"}),(0,a.jsx)("input",{className:"input",type:"number",step:"0.1",min:.1,value:A,onChange:e=>U(Number(e.target.value))})]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:V,disabled:F||!C||!Z,children:F?"Creating...":"Create"}),(0,a.jsx)("button",{className:"btn-ghost",onClick:()=>j(!1),children:"Cancel"})]})]})]})}),n?(0,a.jsx)("div",{className:"card",children:(0,a.jsx)("div",{className:"skeleton h-32 w-full"})}):l?(0,a.jsxs)("div",{className:"card text-center py-12",children:[(0,a.jsx)(o.Z,{size:32,className:"mx-auto mb-3 text-red-400"}),(0,a.jsx)("p",{className:"text-red-400",children:l})]}):0===e.length?(0,a.jsxs)("div",{className:"card text-center py-12",children:[(0,a.jsx)(h.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,a.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No fine-tuning jobs yet."})]}):(0,a.jsx)("div",{className:"card p-0",children:(0,a.jsx)("div",{className:"table-wrap",children:(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"ID"}),(0,a.jsx)("th",{children:"Model"}),(0,a.jsx)("th",{children:"Status"}),(0,a.jsx)("th",{children:"Created"}),(0,a.jsx)("th",{children:"Trained Tokens"}),(0,a.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,a.jsx)("tbody",{children:e.map(e=>{var t;return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"font-mono text-xs",children:e.id}),(0,a.jsx)("td",{className:"font-medium",children:e.model}),(0,a.jsx)("td",{children:(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 ".concat(x[e.status]||"badge-gray"),children:[p[e.status]||null,e.status]})}),(0,a.jsx)("td",{className:"text-xs text-[var(--text-tertiary)]",children:et(e.created_at)}),(0,a.jsx)("td",{children:(null===(t=e.trained_tokens)||void 0===t?void 0:t.toLocaleString())||"-"}),(0,a.jsx)("td",{className:"text-right",children:g.includes(e.status)&&(0,a.jsx)("button",{onClick:()=>Y(e.id),disabled:B===e.id,className:"btn-danger btn-xs",title:"Cancel job",children:B===e.id?(0,a.jsx)("span",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(f,{size:14})})})]},e.id)})})]})})}),v&&(0,a.jsx)("div",{className:"modal-overlay",onClick:()=>!D&&b(!1),children:(0,a.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Upload Training File"}),(0,a.jsx)("button",{onClick:()=>!D&&b(!1),className:"btn-ghost btn-xs",children:(0,a.jsx)(m.Z,{size:14})})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"File (JSONL)"}),(0,a.jsx)("input",{ref:X,type:"file",className:"input",accept:".jsonl,.json,.txt",onChange:e=>{var t;return J((null===(t=e.target.files)||void 0===t?void 0:t[0])||null)},disabled:D}),I&&(0,a.jsxs)("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:["Selected: ",I.name," (",(I.size/1024).toFixed(1)," KB)"]})]}),H&&(0,a.jsx)("p",{className:"text-sm text-[var(--text-secondary)]",children:H}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:ee,disabled:!I||D,children:D?"Uploading...":"Upload"}),(0,a.jsx)("button",{className:"btn-ghost",onClick:()=>!D&&b(!1),disabled:D,children:"Cancel"})]})]})]})}),O&&(0,a.jsx)("div",{className:"toast",children:O})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return r},qz:function(){return s}});let a=n(257).env.NEXT_PUBLIC_API_BASE||"";function i(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function s(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function r(){return!!i()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",r=i(),d={"Content-Type":"application/json",...t.headers};if(r&&(d.Authorization="Bearer ".concat(r)),"GET"===n&&!r){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=o.get(e);if(n)return n}let u=(async()=>{let i=await fetch("".concat(a).concat(e),{method:n,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return i;if(401===i.status&&r&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!i.ok)throw Error((await i.json().catch(()=>({detail:i.statusText}))).detail||"HTTP ".concat(i.status));if(204===i.status)return;let l=await i.json();return"GET"!==n||r||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===n&&!r){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var n;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=a.access_token,localStorage.setItem("nexus_token",n),function(e,t,n){try{let n="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(n)}catch(e){}}("nexus_token",n,0),a},getMe:()=>d("/api/auth/me"),logout:()=>{s(),c.clear(),window.location.href="/login"}},h=async e=>{let t=i(),n=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let s=await n.blob(),r=URL.createObjectURL(s),l=document.createElement("a");l.href=r,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(r)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=3461)}),_N_E=e.O()}]);
static/_next/static/chunks/app/fine-tuning/page-ecbefa6299ef7516.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8919],{3461:function(e,t,n){Promise.resolve().then(n.bind(n,3396))},9205:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var a=n(2265);let i=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(" ")};var r={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,a.forwardRef)((e,t)=>{let{color:n="currentColor",size:i=24,strokeWidth:l=2,absoluteStrokeWidth:c,className:o="",children:d,iconNode:u,...h}=e;return(0,a.createElement)("svg",{ref:t,...r,width:i,height:i,stroke:n,strokeWidth:c?24*Number(l)/Number(i):l,className:s("lucide",o),...h},[...u.map(e=>{let[t,n]=e;return(0,a.createElement)(t,n)}),...Array.isArray(d)?d:[d]])}),c=(e,t)=>{let n=(0,a.forwardRef)((n,r)=>{let{className:c,...o}=n;return(0,a.createElement)(l,{ref:r,iconNode:t,className:s("lucide-".concat(i(e)),c),...o})});return n.displayName="".concat(e),n}},4972:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]])},9322:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]])},1671:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},9388:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},1723:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},9397:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7689:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]])},2489:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});let a=(0,n(9205).Z)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},257:function(e,t,n){"use strict";var a,i;e.exports=(null==(a=n.g.process)?void 0:a.env)&&"object"==typeof(null==(i=n.g.process)?void 0:i.env)?n.g.process:n(4227)},4227:function(e){!function(){var t={229:function(e){var t,n,a,i=e.exports={};function s(){throw Error("setTimeout has not been defined")}function r(){throw Error("clearTimeout has not been defined")}function l(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{n="function"==typeof clearTimeout?clearTimeout:r}catch(e){n=r}}();var c=[],o=!1,d=-1;function u(){o&&a&&(o=!1,a.length?c=a.concat(c):d=-1,c.length&&h())}function h(){if(!o){var e=l(u);o=!0;for(var t=c.length;t;){for(a=c,c=[];++d<t;)a&&a[d].run();d=-1,t=c.length}a=null,o=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===r||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||o||l(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw Error("process.chdir is not supported")},i.umask=function(){return 0}}},n={};function a(e){var i=n[e];if(void 0!==i)return i.exports;var s=n[e]={exports:{}},r=!0;try{t[e](s,s.exports,a),r=!1}finally{r&&delete n[e]}return s.exports}a.ab="//";var i=a(229);e.exports=i}()},3396:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return y}});var a=n(7437),i=n(2265),s=n(1837),r=n(1723),l=n(1671),c=n(9388),o=n(9322),d=n(7689),u=n(9397),h=n(4972);let f=(0,n(9205).Z)("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);var m=n(2489);let x={validating:"badge-yellow",queued:"badge-blue",running:"badge-cyan",succeeded:"badge-green",failed:"badge-red",cancelled:"badge-gray"},p={validating:(0,a.jsx)(r.Z,{size:14}),queued:(0,a.jsx)(r.Z,{size:14}),running:(0,a.jsx)(r.Z,{size:14}),succeeded:(0,a.jsx)(l.Z,{size:14}),failed:(0,a.jsx)(c.Z,{size:14}),cancelled:(0,a.jsx)(o.Z,{size:14})},g=["validating","queued","running"];function y(){let[e,t]=(0,i.useState)([]),[n,r]=(0,i.useState)(!0),[l,c]=(0,i.useState)(""),[y,j]=(0,i.useState)(!1),[v,b]=(0,i.useState)(!1),[N,k]=(0,i.useState)([]),[w,T]=(0,i.useState)([]),[C,S]=(0,i.useState)(""),[Z,E]=(0,i.useState)(""),[z,_]=(0,i.useState)(3),[M,A]=(0,i.useState)(1),[L,U]=(0,i.useState)(1),[F,P]=(0,i.useState)(!1),[O,q]=(0,i.useState)(""),[B,R]=(0,i.useState)(null),[I,J]=(0,i.useState)(null),[D,G]=(0,i.useState)(!1),[H,W]=(0,i.useState)(""),X=(0,i.useRef)(null),K=()=>{r(!0),c(""),s.hi.get("/v1/fine_tuning/jobs").then(e=>t(e.data||[])).catch(e=>c(e instanceof Error?e.message:"Failed to load jobs")).finally(()=>r(!1))},$=()=>{s.hi.get("/v1/models").then(e=>{let t=e.data.map(e=>e.id).sort();k(t),t.length>0&&!C&&S(t[0])}).catch(()=>{})},Q=()=>{s.hi.get("/v1/files").then(e=>{T(e.data||[]),(e.data||[]).length>0&&E(e.data[0].id)}).catch(()=>{})};(0,i.useEffect)(()=>{K()},[]),(0,i.useEffect)(()=>{if(O){let e=setTimeout(()=>q(""),3e3);return()=>clearTimeout(e)}},[O]);let V=async()=>{if(C.trim()&&Z.trim()){P(!0);try{await s.hi.post("/v1/fine_tuning/jobs",{model:C,training_file:Z,hyperparameters:{n_epochs:z,batch_size:M,learning_rate_multiplier:L}}),j(!1),E(""),_(3),A(1),U(1),q("Fine-tuning job created"),K()}catch(e){q(e instanceof Error?e.message:"Failed to create job")}finally{P(!1)}}},Y=async e=>{if(confirm("Cancel this fine-tuning job? This action cannot be undone.")){R(e);try{await s.hi.post("/v1/fine_tuning/jobs/".concat(e,"/cancel"),{}),q("Job cancelled"),K()}catch(e){q(e instanceof Error?e.message:"Failed to cancel job")}finally{R(null)}}},ee=async()=>{if(I){G(!0),W("Uploading...");try{let e=await I.text(),t=localStorage.getItem("nexus_token"),n=await fetch("/v1/files",{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:"Bearer ".concat(t)}:{}},body:JSON.stringify({file:e,purpose:"fine-tune"})});if(!n.ok){let e=await n.json().catch(()=>({detail:n.statusText}));throw Error(e.detail||"HTTP ".concat(n.status))}let a=await n.json();q("Uploaded: ".concat(a.filename||a.id||"file")),b(!1),J(null),X.current&&(X.current.value=""),Q()}catch(e){W(e instanceof Error?e.message:"Upload failed")}finally{G(!1)}}},et=e=>new Date(1e3*e).toLocaleString();return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"page-header",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"page-title",children:"Fine-Tuning"}),(0,a.jsx)("p",{className:"page-sub",children:"Manage fine-tuning jobs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("button",{className:"btn-secondary",onClick:()=>b(!0),children:[(0,a.jsx)(d.Z,{size:16})," Upload File"]}),(0,a.jsxs)("button",{className:"btn-primary",onClick:()=>{$(),Q(),j(!0)},children:[(0,a.jsx)(u.Z,{size:16})," Create Job"]})]})]}),y&&(0,a.jsx)("div",{className:"modal-overlay",onClick:()=>j(!1),children:(0,a.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Create Fine-Tuning Job"}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Model"}),(0,a.jsxs)("select",{className:"select",value:C,onChange:e=>S(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Select model"}),N.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Training File"}),(0,a.jsxs)("select",{className:"select",value:Z,onChange:e=>E(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"Select file"}),w.map(e=>(0,a.jsxs)("option",{value:e.id,children:[e.filename," (",e.id,")"]},e.id))]}),0===w.length&&(0,a.jsx)("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:'No files uploaded yet. Use "Upload File" first.'})]}),(0,a.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Epochs"}),(0,a.jsx)("input",{className:"input",type:"number",min:1,value:z,onChange:e=>_(Number(e.target.value))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Batch Size"}),(0,a.jsx)("input",{className:"input",type:"number",min:1,value:M,onChange:e=>A(Number(e.target.value))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Learning Rate"}),(0,a.jsx)("input",{className:"input",type:"number",step:"0.1",min:.1,value:L,onChange:e=>U(Number(e.target.value))})]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:V,disabled:F||!C||!Z,children:F?"Creating...":"Create"}),(0,a.jsx)("button",{className:"btn-ghost",onClick:()=>j(!1),children:"Cancel"})]})]})]})}),n?(0,a.jsx)("div",{className:"card",children:(0,a.jsx)("div",{className:"skeleton h-32 w-full"})}):l?(0,a.jsxs)("div",{className:"card text-center py-12",children:[(0,a.jsx)(o.Z,{size:32,className:"mx-auto mb-3 text-red-400"}),(0,a.jsx)("p",{className:"text-red-400",children:l})]}):0===e.length?(0,a.jsxs)("div",{className:"card text-center py-12",children:[(0,a.jsx)(h.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,a.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No fine-tuning jobs yet."})]}):(0,a.jsx)("div",{className:"card p-0",children:(0,a.jsx)("div",{className:"table-wrap",children:(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{children:"ID"}),(0,a.jsx)("th",{children:"Model"}),(0,a.jsx)("th",{children:"Status"}),(0,a.jsx)("th",{children:"Created"}),(0,a.jsx)("th",{children:"Trained Tokens"}),(0,a.jsx)("th",{className:"text-right",children:"Actions"})]})}),(0,a.jsx)("tbody",{children:e.map(e=>{var t;return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"font-mono text-xs",children:e.id}),(0,a.jsx)("td",{className:"font-medium",children:e.model}),(0,a.jsx)("td",{children:(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 ".concat(x[e.status]||"badge-gray"),children:[p[e.status]||null,e.status]})}),(0,a.jsx)("td",{className:"text-xs text-[var(--text-tertiary)]",children:et(e.created_at)}),(0,a.jsx)("td",{children:(null===(t=e.trained_tokens)||void 0===t?void 0:t.toLocaleString())||"-"}),(0,a.jsx)("td",{className:"text-right",children:g.includes(e.status)&&(0,a.jsx)("button",{onClick:()=>Y(e.id),disabled:B===e.id,className:"btn-danger btn-xs",title:"Cancel job",children:B===e.id?(0,a.jsx)("span",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,a.jsx)(f,{size:14})})})]},e.id)})})]})})}),v&&(0,a.jsx)("div",{className:"modal-overlay",onClick:()=>!D&&b(!1),children:(0,a.jsxs)("div",{className:"modal",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Upload Training File"}),(0,a.jsx)("button",{onClick:()=>!D&&b(!1),className:"btn-ghost btn-xs",children:(0,a.jsx)(m.Z,{size:14})})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"File (JSONL)"}),(0,a.jsx)("input",{ref:X,type:"file",className:"input",accept:".jsonl,.json,.txt",onChange:e=>{var t;return J((null===(t=e.target.files)||void 0===t?void 0:t[0])||null)},disabled:D}),I&&(0,a.jsxs)("p",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:["Selected: ",I.name," (",(I.size/1024).toFixed(1)," KB)"]})]}),H&&(0,a.jsx)("p",{className:"text-sm text-[var(--text-secondary)]",children:H}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{className:"btn-primary flex-1 justify-center",onClick:ee,disabled:!I||D,children:D?"Uploading...":"Upload"}),(0,a.jsx)("button",{className:"btn-ghost",onClick:()=>!D&&b(!1),disabled:D,children:"Cancel"})]})]})]})}),O&&(0,a.jsx)("div",{className:"toast",children:O})]})}},1837:function(e,t,n){"use strict";n.d(t,{KF:function(){return h},hi:function(){return u},jl:function(){return r},qz:function(){return s}});let a=n(257).env.NEXT_PUBLIC_API_BASE||"";function i(){return localStorage.getItem("nexus_token")}function s(){localStorage.removeItem("nexus_token")}function r(){return!!i()}let l={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},c=new Map,o=new Map;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method||"GET",r=i(),d={"Content-Type":"application/json",...t.headers};if(r&&(d.Authorization="Bearer ".concat(r)),"GET"===n&&!r){let t=function(e){let t=c.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in l)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return l[t];return 5e3}(e)){c.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let n=o.get(e);if(n)return n}let u=(async()=>{let i=await fetch("".concat(a).concat(e),{method:n,headers:d,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return i;if(401===i.status&&r&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),c.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!i.ok)throw Error((await i.json().catch(()=>({detail:i.statusText}))).detail||"HTTP ".concat(i.status));if(204===i.status)return;let l=await i.json();return"GET"!==n||r||function(e,t){if(c.size>=200){let e=c.keys().next().value;void 0!==e&&c.delete(e)}c.set(e,{ts:Date.now(),data:t})}(e,l),l})();if("GET"===n&&!r){o.set(e,u);try{return await u}finally{o.delete(e)}}return u}let u={get:e=>d(e),post:(e,t)=>d(e,{method:"POST",body:t}),put:(e,t)=>d(e,{method:"PUT",body:t}),patch:(e,t)=>d(e,{method:"PATCH",body:t}),delete:e=>d(e,{method:"DELETE"}),login:async(e,t)=>{var n;let a=await d("/api/auth/login",{method:"POST",body:{username:e,password:t}});return n=a.access_token,localStorage.setItem("nexus_token",n),a},getMe:()=>d("/api/auth/me"),logout:()=>{s(),c.clear(),window.location.href="/login"}},h=async e=>{let t=i(),n=await fetch("".concat(a).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Failed to download");let s=await n.blob(),r=URL.createObjectURL(s),l=document.createElement("a");l.href=r,l.download=e.split("/").pop()||"export.csv",l.click(),URL.revokeObjectURL(r)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=3461)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/global-error-cbe2d3ac15285c84.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6470],{4855:function(e,r,n){Promise.resolve().then(n.bind(n,1667))},1667:function(e,r,n){"use strict";n.r(r),n.d(r,{default:function(){return t}});var i=n(7437);function t(e){let{error:r,reset:n}=e;return(0,i.jsxs)("html",{lang:"en",children:[(0,i.jsxs)("head",{children:[(0,i.jsx)("title",{children:"NexusAI Gateway — Error"}),(0,i.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),(0,i.jsx)("style",{dangerouslySetInnerHTML:{__html:"html,body{margin:0;padding:0;background:#0a0a0a;color:#fff;font-family:Inter,system-ui,-apple-system,sans-serif;min-height:100vh}*{box-sizing:border-box}.err-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px}.err-card{max-width:480px;width:100%;background:#111;border:1px solid rgba(255,255,255,.07);border-radius:12px;padding:32px;text-align:center}.err-icon{width:48px;height:48px;margin:0 auto 16px;color:#ef4444}.err-title{font-size:20px;font-weight:600;margin:0 0 8px}.err-msg{color:#a1a1a1;font-size:14px;margin:0 0 8px;word-break:break-word}.err-digest{color:#6b6b6b;font-size:11px;font-family:ui-monospace,monospace;margin:0 0 24px}.err-btn{background:#f97316;color:#fff;border:none;padding:10px 20px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer;font-family:inherit}.err-btn:hover{background:#ea580c}.err-btn:active{background:#c2410c}"}})]}),(0,i.jsx)("body",{children:(0,i.jsx)("div",{className:"err-wrap",children:(0,i.jsxs)("div",{className:"err-card",children:[(0,i.jsxs)("svg",{className:"err-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,i.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),(0,i.jsx)("h1",{className:"err-title",children:"Something went wrong"}),(0,i.jsx)("p",{className:"err-msg",children:(null==r?void 0:r.message)||"An unexpected error occurred"}),(null==r?void 0:r.digest)&&(0,i.jsxs)("p",{className:"err-digest",children:["Error ID: ",r.digest]}),(0,i.jsx)("button",{className:"err-btn",onClick:n,children:"Try again"})]})})})]})}n(2265)}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=4855)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/health/page-afe3b6f5c87fbc55.js DELETED
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1613],{1697:function(e,t,r){Promise.resolve().then(r.bind(r,4523))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return o}});var n=r(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:l="",children:u,iconNode:d,...h}=e;return(0,n.createElement)("svg",{ref:t,...i,width:a,height:a,stroke:r,strokeWidth:o?24*Number(c)/Number(a):c,className:s("lucide",l),...h},[...d.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(u)?u:[u]])}),o=(e,t)=>{let r=(0,n.forwardRef)((r,i)=>{let{className:o,...l}=r;return(0,n.createElement)(c,{ref:i,iconNode:t,className:s("lucide-".concat(a(e)),o),...l})});return r.displayName="".concat(e),r}},4401:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]])},1671:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},9388:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},8997:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]])},7168:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},6865:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},257:function(e,t,r){"use strict";var n,a;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(a=r.g.process)?void 0:a.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,a=e.exports={};function s(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var o=[],l=!1,u=-1;function d(){l&&n&&(l=!1,n.length?o=n.concat(o):u=-1,o.length&&h())}function h(){if(!l){var e=c(d);l=!0;for(var t=o.length;t;){for(n=o,o=[];++u<t;)n&&n[u].run();u=-1,t=o.length}n=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function p(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];o.push(new f(e,t)),1!==o.length||l||c(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=p,a.addListener=p,a.once=p,a.off=p,a.removeListener=p,a.removeAllListeners=p,a.emit=p,a.prependListener=p,a.prependOnceListener=p,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var s=r[e]={exports:{}},i=!0;try{t[e](s,s.exports,n),i=!1}finally{i&&delete r[e]}return s.exports}n.ab="//";var a=n(229);e.exports=a}()},4523:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return h}});var n=r(7437),a=r(2265),s=r(1837),i=r(1671),c=r(6865),o=r(9388),l=r(7168),u=r(8997),d=r(4401);function h(){let[e,t]=(0,a.useState)([]),[r,h]=(0,a.useState)(!0),[f,p]=(0,a.useState)(!1),[m,x]=(0,a.useState)(null),[g,v]=(0,a.useState)(""),[y,w]=(0,a.useState)(!1),k=(0,a.useCallback)(async()=>{try{let e=await s.hi.get("/api/health-check");t(e),v("")}catch(e){v(e instanceof Error?e.message:"Failed to fetch health status")}finally{h(!1)}},[]);(0,a.useEffect)(()=>{k()},[k]),(0,a.useEffect)(()=>{if(!y)return;let e=setInterval(k,15e3);return()=>clearInterval(e)},[y,k]);let b=async()=>{p(!0),v("");try{let e=await s.hi.post("/api/health-check");t(e)}catch(e){v(e instanceof Error?e.message:"Check all failed")}finally{p(!1)}},j=async e=>{x(e),v("");try{let r=await s.hi.post("/api/health-check/".concat(e));t(t=>t.map(t=>t.provider===e?r:t))}catch(t){v(t instanceof Error?t.message:"Check failed for ".concat(e))}finally{x(null)}},N=e=>{switch(e){case"ok":return(0,n.jsx)(i.Z,{size:16,className:"text-green-400"});case"timeout":return(0,n.jsx)(c.Z,{size:16,className:"text-yellow-400"});default:return(0,n.jsx)(o.Z,{size:16,className:"text-red-400"})}},T=e=>{switch(e){case"ok":return(0,n.jsx)("span",{className:"badge badge-green",children:e});case"timeout":return(0,n.jsx)("span",{className:"badge badge-yellow",children:e});default:return(0,n.jsx)("span",{className:"badge badge-red",children:e})}};return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"page-header",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Health Check"}),(0,n.jsx)("p",{className:"page-sub",children:"Provider connectivity testing"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:y,onChange:e=>w(e.target.checked),className:"accent-[var(--blue)]"}),"Auto-refresh"]}),(0,n.jsxs)("button",{className:"btn-primary",onClick:b,disabled:f,children:[f?(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,n.jsx)(l.Z,{size:16}),"Check All"]})]})]}),g&&(0,n.jsx)("div",{className:"card mb-4 border border-red-500/30 bg-red-500/5",children:(0,n.jsxs)("p",{className:"text-sm text-red-400 flex items-center gap-2",children:[(0,n.jsx)(o.Z,{size:14}),g]})}),r?(0,n.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:Array.from({length:6}).map((e,t)=>(0,n.jsx)("div",{className:"card",children:(0,n.jsx)("div",{className:"skeleton h-32 w-full"})},t))}):0===e.length?(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(u.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No health data yet. Run a check to see provider status."})]}):(0,n.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:e.map(e=>(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[N(e.status),(0,n.jsx)("span",{className:"font-semibold capitalize",children:e.provider})]}),T(e.status)]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-xs mb-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"Latency"}),(0,n.jsx)("p",{className:"font-medium mt-0.5",children:null!==e.latency_ms?"".concat(e.latency_ms,"ms"):"N/A"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"Last Checked"}),(0,n.jsx)("p",{className:"font-medium mt-0.5",children:e.last_checked?new Date(e.last_checked).toLocaleString():"N/A"})]})]}),e.error_message&&(0,n.jsx)("p",{className:"text-xs text-red-400 mb-3 p-2 bg-red-500/10 rounded",children:e.error_message}),(0,n.jsxs)("button",{className:"btn-secondary w-full justify-center text-xs py-1.5",onClick:()=>j(e.provider),disabled:m===e.provider,children:[m===e.provider?(0,n.jsx)("span",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,n.jsx)(d.Z,{size:12}),"Check Provider"]})]},e.provider))})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return i},qz:function(){return s}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function a(){return localStorage.getItem("nexus_token")}function s(){localStorage.removeItem("nexus_token")}function i(){return!!a()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,l=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",i=a(),u={"Content-Type":"application/json",...t.headers};if(i&&(u.Authorization="Bearer ".concat(i)),"GET"===r&&!i){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=l.get(e);if(r)return r}let d=(async()=>{let a=await fetch("".concat(n).concat(e),{method:r,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let c=await a.json();return"GET"!==r||i||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===r&&!i){l.set(e,d);try{return await d}finally{l.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),n},getMe:()=>u("/api/auth/me"),logout:()=>{s(),o.clear(),window.location.href="/login"}},h=async e=>{let t=a(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let s=await r.blob(),i=URL.createObjectURL(s),c=document.createElement("a");c.href=i,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=1697)}),_N_E=e.O()}]);
 
 
static/_next/static/chunks/app/health/{page-0076cc8e10197b14.js → page-f9a55c9d3c1965a7.js} RENAMED
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1613],{1697:function(e,t,r){Promise.resolve().then(r.bind(r,4523))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return o}});var n=r(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:l="",children:u,iconNode:d,...h}=e;return(0,n.createElement)("svg",{ref:t,...i,width:a,height:a,stroke:r,strokeWidth:o?24*Number(c)/Number(a):c,className:s("lucide",l),...h},[...d.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(u)?u:[u]])}),o=(e,t)=>{let r=(0,n.forwardRef)((r,i)=>{let{className:o,...l}=r;return(0,n.createElement)(c,{ref:i,iconNode:t,className:s("lucide-".concat(a(e)),o),...l})});return r.displayName="".concat(e),r}},4401:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]])},1671:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},9388:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},8997:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]])},7168:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},6865:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},257:function(e,t,r){"use strict";var n,a;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(a=r.g.process)?void 0:a.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,a=e.exports={};function s(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function c(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var o=[],l=!1,u=-1;function d(){l&&n&&(l=!1,n.length?o=n.concat(o):u=-1,o.length&&h())}function h(){if(!l){var e=c(d);l=!0;for(var t=o.length;t;){for(n=o,o=[];++u<t;)n&&n[u].run();u=-1,t=o.length}n=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function p(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];o.push(new f(e,t)),1!==o.length||l||c(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=p,a.addListener=p,a.once=p,a.off=p,a.removeListener=p,a.removeAllListeners=p,a.emit=p,a.prependListener=p,a.prependOnceListener=p,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var s=r[e]={exports:{}},i=!0;try{t[e](s,s.exports,n),i=!1}finally{i&&delete r[e]}return s.exports}n.ab="//";var a=n(229);e.exports=a}()},4523:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return h}});var n=r(7437),a=r(2265),s=r(1837),i=r(1671),c=r(6865),o=r(9388),l=r(7168),u=r(8997),d=r(4401);function h(){let[e,t]=(0,a.useState)([]),[r,h]=(0,a.useState)(!0),[f,p]=(0,a.useState)(!1),[m,x]=(0,a.useState)(null),[g,v]=(0,a.useState)(""),[y,w]=(0,a.useState)(!1),k=(0,a.useCallback)(async()=>{try{let e=await s.hi.get("/api/health-check");t(e),v("")}catch(e){v(e instanceof Error?e.message:"Failed to fetch health status")}finally{h(!1)}},[]);(0,a.useEffect)(()=>{k()},[k]),(0,a.useEffect)(()=>{if(!y)return;let e=setInterval(k,15e3);return()=>clearInterval(e)},[y,k]);let b=async()=>{p(!0),v("");try{let e=await s.hi.post("/api/health-check");t(e)}catch(e){v(e instanceof Error?e.message:"Check all failed")}finally{p(!1)}},j=async e=>{x(e),v("");try{let r=await s.hi.post("/api/health-check/".concat(e));t(t=>t.map(t=>t.provider===e?r:t))}catch(t){v(t instanceof Error?t.message:"Check failed for ".concat(e))}finally{x(null)}},N=e=>{switch(e){case"ok":return(0,n.jsx)(i.Z,{size:16,className:"text-green-400"});case"timeout":return(0,n.jsx)(c.Z,{size:16,className:"text-yellow-400"});default:return(0,n.jsx)(o.Z,{size:16,className:"text-red-400"})}},T=e=>{switch(e){case"ok":return(0,n.jsx)("span",{className:"badge badge-green",children:e});case"timeout":return(0,n.jsx)("span",{className:"badge badge-yellow",children:e});default:return(0,n.jsx)("span",{className:"badge badge-red",children:e})}};return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"page-header",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Health Check"}),(0,n.jsx)("p",{className:"page-sub",children:"Provider connectivity testing"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:y,onChange:e=>w(e.target.checked),className:"accent-[var(--blue)]"}),"Auto-refresh"]}),(0,n.jsxs)("button",{className:"btn-primary",onClick:b,disabled:f,children:[f?(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,n.jsx)(l.Z,{size:16}),"Check All"]})]})]}),g&&(0,n.jsx)("div",{className:"card mb-4 border border-red-500/30 bg-red-500/5",children:(0,n.jsxs)("p",{className:"text-sm text-red-400 flex items-center gap-2",children:[(0,n.jsx)(o.Z,{size:14}),g]})}),r?(0,n.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:Array.from({length:6}).map((e,t)=>(0,n.jsx)("div",{className:"card",children:(0,n.jsx)("div",{className:"skeleton h-32 w-full"})},t))}):0===e.length?(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(u.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No health data yet. Run a check to see provider status."})]}):(0,n.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:e.map(e=>(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[N(e.status),(0,n.jsx)("span",{className:"font-semibold capitalize",children:e.provider})]}),T(e.status)]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-xs mb-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"Latency"}),(0,n.jsx)("p",{className:"font-medium mt-0.5",children:null!==e.latency_ms?"".concat(e.latency_ms,"ms"):"N/A"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"Last Checked"}),(0,n.jsx)("p",{className:"font-medium mt-0.5",children:e.last_checked?new Date(e.last_checked).toLocaleString():"N/A"})]})]}),e.error_message&&(0,n.jsx)("p",{className:"text-xs text-red-400 mb-3 p-2 bg-red-500/10 rounded",children:e.error_message}),(0,n.jsxs)("button",{className:"btn-secondary w-full justify-center text-xs py-1.5",onClick:()=>j(e.provider),disabled:m===e.provider,children:[m===e.provider?(0,n.jsx)("span",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,n.jsx)(d.Z,{size:12}),"Check Provider"]})]},e.provider))})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return i},qz:function(){return s}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function a(){return localStorage.getItem("nexus_token")}function s(){localStorage.removeItem("nexus_token")}function i(){return!!a()}let c={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,l=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",i=a(),u={"Content-Type":"application/json",...t.headers};if(i&&(u.Authorization="Bearer ".concat(i)),"GET"===r&&!i){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in c)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return c[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=l.get(e);if(r)return r}let d=(async()=>{let a=await fetch("".concat(n).concat(e),{method:r,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&i&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let c=await a.json();return"GET"!==r||i||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,c),c})();if("GET"===r&&!i){l.set(e,d);try{return await d}finally{l.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),n},getMe:()=>u("/api/auth/me"),logout:()=>{s(),o.clear(),window.location.href="/login"}},h=async e=>{let t=a(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let s=await r.blob(),i=URL.createObjectURL(s),c=document.createElement("a");c.href=i,c.download=e.split("/").pop()||"export.csv",c.click(),URL.revokeObjectURL(i)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=1697)}),_N_E=e.O()}]);
 
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1613],{1697:function(e,t,r){Promise.resolve().then(r.bind(r,4523))},9205:function(e,t,r){"use strict";r.d(t,{Z:function(){return o}});var n=r(2265);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),s=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&r.indexOf(e)===t).join(" ")};var c={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=24,strokeWidth:i=2,absoluteStrokeWidth:o,className:l="",children:u,iconNode:d,...h}=e;return(0,n.createElement)("svg",{ref:t,...c,width:a,height:a,stroke:r,strokeWidth:o?24*Number(i)/Number(a):i,className:s("lucide",l),...h},[...d.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(u)?u:[u]])}),o=(e,t)=>{let r=(0,n.forwardRef)((r,c)=>{let{className:o,...l}=r;return(0,n.createElement)(i,{ref:c,iconNode:t,className:s("lucide-".concat(a(e)),o),...l})});return r.displayName="".concat(e),r}},4401:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]])},1671:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},9388:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},8997:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]])},7168:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},6865:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(9205).Z)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},257:function(e,t,r){"use strict";var n,a;e.exports=(null==(n=r.g.process)?void 0:n.env)&&"object"==typeof(null==(a=r.g.process)?void 0:a.env)?r.g.process:r(4227)},4227:function(e){!function(){var t={229:function(e){var t,r,n,a=e.exports={};function s(){throw Error("setTimeout has not been defined")}function c(){throw Error("clearTimeout has not been defined")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{r="function"==typeof clearTimeout?clearTimeout:c}catch(e){r=c}}();var o=[],l=!1,u=-1;function d(){l&&n&&(l=!1,n.length?o=n.concat(o):u=-1,o.length&&h())}function h(){if(!l){var e=i(d);l=!0;for(var t=o.length;t;){for(n=o,o=[];++u<t;)n&&n[u].run();u=-1,t=o.length}n=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===c||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function m(){}a.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];o.push(new f(e,t)),1!==o.length||l||i(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=m,a.addListener=m,a.once=m,a.off=m,a.removeListener=m,a.removeAllListeners=m,a.emit=m,a.prependListener=m,a.prependOnceListener=m,a.listeners=function(e){return[]},a.binding=function(e){throw Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw Error("process.chdir is not supported")},a.umask=function(){return 0}}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var s=r[e]={exports:{}},c=!0;try{t[e](s,s.exports,n),c=!1}finally{c&&delete r[e]}return s.exports}n.ab="//";var a=n(229);e.exports=a}()},4523:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return h}});var n=r(7437),a=r(2265),s=r(1837),c=r(1671),i=r(6865),o=r(9388),l=r(7168),u=r(8997),d=r(4401);function h(){let[e,t]=(0,a.useState)([]),[r,h]=(0,a.useState)(!0),[f,m]=(0,a.useState)(!1),[p,x]=(0,a.useState)(null),[g,y]=(0,a.useState)(""),[v,k]=(0,a.useState)(!1),w=(0,a.useCallback)(async()=>{try{let e=await s.hi.get("/api/health-check");t(e),y("")}catch(e){y(e instanceof Error?e.message:"Failed to fetch health status")}finally{h(!1)}},[]);(0,a.useEffect)(()=>{w()},[w]),(0,a.useEffect)(()=>{if(!v)return;let e=setInterval(w,15e3);return()=>clearInterval(e)},[v,w]);let b=async()=>{m(!0),y("");try{let e=await s.hi.post("/api/health-check");t(e)}catch(e){y(e instanceof Error?e.message:"Check all failed")}finally{m(!1)}},j=async e=>{x(e),y("");try{let r=await s.hi.post("/api/health-check/".concat(e));t(t=>t.map(t=>t.provider===e?r:t))}catch(t){y(t instanceof Error?t.message:"Check failed for ".concat(e))}finally{x(null)}},N=e=>{switch(e){case"ok":return(0,n.jsx)(c.Z,{size:16,className:"text-green-400"});case"timeout":return(0,n.jsx)(i.Z,{size:16,className:"text-yellow-400"});default:return(0,n.jsx)(o.Z,{size:16,className:"text-red-400"})}},T=e=>{switch(e){case"ok":return(0,n.jsx)("span",{className:"badge badge-green",children:e});case"timeout":return(0,n.jsx)("span",{className:"badge badge-yellow",children:e});default:return(0,n.jsx)("span",{className:"badge badge-red",children:e})}};return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"page-header",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"page-title",children:"Health Check"}),(0,n.jsx)("p",{className:"page-sub",children:"Provider connectivity testing"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:v,onChange:e=>k(e.target.checked),className:"accent-[var(--blue)]"}),"Auto-refresh"]}),(0,n.jsxs)("button",{className:"btn-primary",onClick:b,disabled:f,children:[f?(0,n.jsx)("span",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}):(0,n.jsx)(l.Z,{size:16}),"Check All"]})]})]}),g&&(0,n.jsx)("div",{className:"card mb-4 border border-red-500/30 bg-red-500/5",children:(0,n.jsxs)("p",{className:"text-sm text-red-400 flex items-center gap-2",children:[(0,n.jsx)(o.Z,{size:14}),g]})}),r?(0,n.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:Array.from({length:6}).map((e,t)=>(0,n.jsx)("div",{className:"card",children:(0,n.jsx)("div",{className:"skeleton h-32 w-full"})},t))}):0===e.length?(0,n.jsxs)("div",{className:"card text-center py-12",children:[(0,n.jsx)(u.Z,{size:32,className:"mx-auto mb-3 text-[var(--text-tertiary)]"}),(0,n.jsx)("p",{className:"text-[var(--text-secondary)]",children:"No health data yet. Run a check to see provider status."})]}):(0,n.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:e.map(e=>(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[N(e.status),(0,n.jsx)("span",{className:"font-semibold capitalize",children:e.provider})]}),T(e.status)]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-xs mb-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"Latency"}),(0,n.jsx)("p",{className:"font-medium mt-0.5",children:null!==e.latency_ms?"".concat(e.latency_ms,"ms"):"N/A"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"text-[var(--text-tertiary)]",children:"Last Checked"}),(0,n.jsx)("p",{className:"font-medium mt-0.5",children:e.last_checked?new Date(e.last_checked).toLocaleString():"N/A"})]})]}),e.error_message&&(0,n.jsx)("p",{className:"text-xs text-red-400 mb-3 p-2 bg-red-500/10 rounded",children:e.error_message}),(0,n.jsxs)("button",{className:"btn-secondary w-full justify-center text-xs py-1.5",onClick:()=>j(e.provider),disabled:p===e.provider,children:[p===e.provider?(0,n.jsx)("span",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):(0,n.jsx)(d.Z,{size:12}),"Check Provider"]})]},e.provider))})]})}},1837:function(e,t,r){"use strict";r.d(t,{KF:function(){return h},hi:function(){return d},jl:function(){return c},qz:function(){return s}});let n=r(257).env.NEXT_PUBLIC_API_BASE||"";function a(){let e=localStorage.getItem("nexus_token");if(e)return e;try{let e=document.cookie.match(/(?:^|;\s*)nexus_token=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return null}function s(){localStorage.removeItem("nexus_token"),function(e){try{document.cookie="".concat(e,"=;path=/;max-age=0")}catch(e){}}("nexus_token")}function c(){return!!a()}let i={"/api/stats":5e3,"/api/catalog":3e4,"/api/pricing":6e4},o=new Map,l=new Map;async function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.method||"GET",c=a(),u={"Content-Type":"application/json",...t.headers};if(c&&(u.Authorization="Bearer ".concat(c)),"GET"===r&&!c){let t=function(e){let t=o.get(e);if(t){if(Date.now()-t.ts>function(e){for(let t in i)if(e===t||e.startsWith(t+"/")||e.startsWith(t+"?"))return i[t];return 5e3}(e)){o.delete(e);return}return t.data}}(e);if(void 0!==t)return t;let r=l.get(e);if(r)return r}let d=(async()=>{let a=await fetch("".concat(n).concat(e),{method:r,headers:u,body:t.body?JSON.stringify(t.body):void 0});if(t.raw)return a;if(401===a.status&&c&&"/api/auth/login"!==e&&"/api/auth/me"!==e)throw s(),o.clear(),"/login"!==window.location.pathname&&(window.location.href="/login?expired=1"),Error("Session expired. Please sign in again.");if(!a.ok)throw Error((await a.json().catch(()=>({detail:a.statusText}))).detail||"HTTP ".concat(a.status));if(204===a.status)return;let i=await a.json();return"GET"!==r||c||function(e,t){if(o.size>=200){let e=o.keys().next().value;void 0!==e&&o.delete(e)}o.set(e,{ts:Date.now(),data:t})}(e,i),i})();if("GET"===r&&!c){l.set(e,d);try{return await d}finally{l.delete(e)}}return d}let d={get:e=>u(e),post:(e,t)=>u(e,{method:"POST",body:t}),put:(e,t)=>u(e,{method:"PUT",body:t}),patch:(e,t)=>u(e,{method:"PATCH",body:t}),delete:e=>u(e,{method:"DELETE"}),login:async(e,t)=>{var r;let n=await u("/api/auth/login",{method:"POST",body:{username:e,password:t}});return r=n.access_token,localStorage.setItem("nexus_token",r),function(e,t,r){try{let r="https:"===window.location.protocol?";Secure":"";document.cookie="".concat(e,"=").concat(encodeURIComponent(t),";path=/;max-age=").concat(604800,";SameSite=Lax").concat(r)}catch(e){}}("nexus_token",r,0),n},getMe:()=>u("/api/auth/me"),logout:()=>{s(),o.clear(),window.location.href="/login"}},h=async e=>{let t=a(),r=await fetch("".concat(n).concat(e),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!r.ok)throw Error("Failed to download");let s=await r.blob(),c=URL.createObjectURL(s),i=document.createElement("a");i.href=c,i.download=e.split("/").pop()||"export.csv",i.click(),URL.revokeObjectURL(c)}}},function(e){e.O(0,[2971,2117,1744],function(){return e(e.s=1697)}),_N_E=e.O()}]);