@chenpu17/cc-gw 0.8.30 → 0.9.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/package.json +8 -8
  2. package/src/web/dist/assets/About-DY21fypB.js +1 -0
  3. package/src/web/dist/assets/ApiKeys-FWkRLPTy.js +1 -0
  4. package/src/web/dist/assets/{ConfirmDialog-VrbumD7j.js → ConfirmDialog-CyTpXZeT.js} +1 -1
  5. package/src/web/dist/assets/Dashboard-FKM-9UNt.js +1 -0
  6. package/src/web/dist/assets/DialogShell-CM92wXHo.js +1 -0
  7. package/src/web/dist/assets/Events-x_fSf1mz.js +1 -0
  8. package/src/web/dist/assets/{Help-BiuR792b.js → Help-BMgllYJq.js} +1 -1
  9. package/src/web/dist/assets/Login-DrtDFqbk.js +1 -0
  10. package/src/web/dist/assets/Logs-18flgbiW.js +1 -0
  11. package/src/web/dist/assets/{PageSection-D1vbxAKK.js → PageSection-N34Nu8NO.js} +1 -1
  12. package/src/web/dist/assets/PageState-CFLrRswm.js +1 -0
  13. package/src/web/dist/assets/{PageToolbar-DzpjQ7SY.js → PageToolbar-CWw40AFL.js} +1 -1
  14. package/src/web/dist/assets/ProvidersWorkbench-aHO5-ApY.js +1 -0
  15. package/src/web/dist/assets/Settings-iEjCAGgm.js +1 -0
  16. package/src/web/dist/assets/Setup-B1j2zExa.js +2 -0
  17. package/src/web/dist/assets/{apiKeys-Dl_vgy_U.js → apiKeys-k1jIJuDa.js} +1 -1
  18. package/src/web/dist/assets/app-Citq5KW4.js +61 -0
  19. package/src/web/dist/assets/badge-DpUlf_NW.js +1 -0
  20. package/src/web/dist/assets/{card-DS9KKz-k.js → card-D4YOc5eB.js} +1 -1
  21. package/src/web/dist/assets/{charts-core-CAVUzIcU.js → charts-core-BTTtAoo-.js} +1 -1
  22. package/src/web/dist/assets/{charts-engine-BRCKiVl4.js → charts-engine-CFhx8nba.js} +1 -1
  23. package/src/web/dist/assets/{charts-react-B-D6Gq0w.js → charts-react-BQP6-BFp.js} +1 -1
  24. package/src/web/dist/assets/{disclosure-CqU8C-ET.js → disclosure-l5qsWhr7.js} +1 -1
  25. package/src/web/dist/assets/{gateway-Bt6lPuXq.js → gateway-i49olSPp.js} +1 -1
  26. package/src/web/dist/assets/{global-zt8jbW7F.js → global-BCehxTGJ.js} +1 -1
  27. package/src/web/dist/assets/global-CIVH6GQV.css +1 -0
  28. package/src/web/dist/assets/{i18n-DWfLgqoF.js → i18n-PeX9kBVO.js} +1 -1
  29. package/src/web/dist/assets/{label-CWq3wWgE.js → label-DSVzZIex.js} +1 -1
  30. package/src/web/dist/assets/landing-W4f2Nx8j.js +17 -0
  31. package/src/web/dist/assets/metric-card-G1bbpbiR.js +1 -0
  32. package/src/web/dist/assets/package-B2CgmdJ7.js +1 -0
  33. package/src/web/dist/assets/popover-QZXvcPr8.js +1 -0
  34. package/src/web/dist/assets/{query-CZuclkQv.js → query-DZF7K6hv.js} +1 -1
  35. package/src/web/dist/assets/radix-Bux_1C5J.js +5 -0
  36. package/src/web/dist/assets/{router-C1-ppOz7.js → router-BoBrmro7.js} +2 -2
  37. package/src/web/dist/assets/segmented-control-13KTib6k.js +1 -0
  38. package/src/web/dist/assets/{select-CxIEo3DN.js → select-sOwKYsgI.js} +1 -1
  39. package/src/web/dist/assets/shared-Cuakym23.js +1 -0
  40. package/src/web/dist/assets/switch-7PH_rDz6.js +1 -0
  41. package/src/web/dist/assets/table-CVuTTP1s.js +1 -0
  42. package/src/web/dist/assets/{tabs-BOjStrRw.js → tabs-UWyz9J_W.js} +1 -1
  43. package/src/web/dist/assets/types-DYz12j32.js +1 -0
  44. package/src/web/dist/assets/useAppMutation-CEN5Oa4S.js +1 -0
  45. package/src/web/dist/assets/{useEventStream-DeEWwZq0.js → useEventStream-BYg6oKvQ.js} +1 -1
  46. package/src/web/dist/assets/useProviderForm-DZEYuRhD.js +1 -0
  47. package/src/web/dist/assets/utils-B_Q3Hhgb.js +3 -0
  48. package/src/web/dist/assets/vendor-CITafuNQ.js +409 -0
  49. package/src/web/dist/index.html +15 -9
  50. package/src/web/dist/landing.html +5 -5
  51. package/src/web/dist/assets/About-CGQXnQXw.js +0 -1
  52. package/src/web/dist/assets/ApiKeys-Cse0CWpH.js +0 -1
  53. package/src/web/dist/assets/Dashboard-CtOgjfmM.js +0 -1
  54. package/src/web/dist/assets/DialogShell-TRFN3c58.js +0 -1
  55. package/src/web/dist/assets/EChart-CZqGiync.js +0 -1
  56. package/src/web/dist/assets/Events-C14a-qPg.js +0 -1
  57. package/src/web/dist/assets/Login-B-xiAusP.js +0 -1
  58. package/src/web/dist/assets/Logs-oNopHEDO.js +0 -1
  59. package/src/web/dist/assets/PageState-CPKqNFG7.js +0 -1
  60. package/src/web/dist/assets/ProvidersWorkbench-B5g4UvTf.js +0 -1
  61. package/src/web/dist/assets/Settings-CPpQt_UL.js +0 -1
  62. package/src/web/dist/assets/Setup-DNJ1W4sK.js +0 -2
  63. package/src/web/dist/assets/app-CeLCVbqy.js +0 -61
  64. package/src/web/dist/assets/global-B1Xg1dWA.css +0 -1
  65. package/src/web/dist/assets/landing-D6Ek28oa.js +0 -17
  66. package/src/web/dist/assets/metric-card-CueQ0u3Z.js +0 -1
  67. package/src/web/dist/assets/package-CdOrNWtP.js +0 -1
  68. package/src/web/dist/assets/popover-0fHMO-3Y.js +0 -1
  69. package/src/web/dist/assets/queryKeys-BlGm18Nk.js +0 -1
  70. package/src/web/dist/assets/radix-OaJStcH-.js +0 -5
  71. package/src/web/dist/assets/segmented-control-do2mQidJ.js +0 -1
  72. package/src/web/dist/assets/shared-fOyVvn5H.js +0 -1
  73. package/src/web/dist/assets/switch-B2cQk2bS.js +0 -1
  74. package/src/web/dist/assets/table-BxCEZcKF.js +0 -1
  75. package/src/web/dist/assets/useAppMutation-DY1JJByx.js +0 -1
  76. package/src/web/dist/assets/useProviderForm-DlALMLaD.js +0 -1
  77. package/src/web/dist/assets/utils-DrKJJFzS.js +0 -3
  78. package/src/web/dist/assets/vendor-m8O77Czp.js +0 -390
@@ -7,17 +7,23 @@
7
7
  <link rel="icon" type="image/svg+xml" href="/cc-gw-mark.svg" />
8
8
  <link rel="apple-touch-icon" href="/cc-gw-mark.svg" />
9
9
  <link rel="manifest" href="/site.webmanifest" />
10
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
11
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
12
+ <link
13
+ href="https://fonts.googleapis.com/css2?family=Archivo:wght@400;600;800&family=Noto+Sans+SC:wght@400;500;700;900&display=swap"
14
+ rel="stylesheet"
15
+ />
10
16
  <title>cc-gw 控制台</title>
11
- <script type="module" crossorigin src="/assets/app-CeLCVbqy.js"></script>
12
- <link rel="modulepreload" crossorigin href="/assets/vendor-m8O77Czp.js">
13
- <link rel="modulepreload" crossorigin href="/assets/global-zt8jbW7F.js">
14
- <link rel="modulepreload" crossorigin href="/assets/query-CZuclkQv.js">
15
- <link rel="modulepreload" crossorigin href="/assets/i18n-DWfLgqoF.js">
16
- <link rel="modulepreload" crossorigin href="/assets/router-C1-ppOz7.js">
17
- <link rel="modulepreload" crossorigin href="/assets/radix-OaJStcH-.js">
18
- <link rel="stylesheet" crossorigin href="/assets/global-B1Xg1dWA.css">
17
+ <script type="module" crossorigin src="/assets/app-Citq5KW4.js"></script>
18
+ <link rel="modulepreload" crossorigin href="/assets/vendor-CITafuNQ.js">
19
+ <link rel="modulepreload" crossorigin href="/assets/global-BCehxTGJ.js">
20
+ <link rel="modulepreload" crossorigin href="/assets/query-DZF7K6hv.js">
21
+ <link rel="modulepreload" crossorigin href="/assets/i18n-PeX9kBVO.js">
22
+ <link rel="modulepreload" crossorigin href="/assets/router-BoBrmro7.js">
23
+ <link rel="modulepreload" crossorigin href="/assets/radix-Bux_1C5J.js">
24
+ <link rel="stylesheet" crossorigin href="/assets/global-CIVH6GQV.css">
19
25
  </head>
20
- <body class="bg-slate-50 text-slate-900 dark:bg-slate-900 dark:text-slate-50">
26
+ <body class="bg-background text-foreground">
21
27
  <div id="root"></div>
22
28
  </body>
23
29
  </html>
@@ -42,12 +42,12 @@
42
42
  }
43
43
  </script>
44
44
  <title>cc-gw | 你的 API Key 不该躺在 30 个 .env 里 · local-first AI gateway</title>
45
- <script type="module" crossorigin src="/assets/landing-D6Ek28oa.js"></script>
46
- <link rel="modulepreload" crossorigin href="/assets/vendor-m8O77Czp.js">
47
- <link rel="modulepreload" crossorigin href="/assets/global-zt8jbW7F.js">
45
+ <script type="module" crossorigin src="/assets/landing-W4f2Nx8j.js"></script>
46
+ <link rel="modulepreload" crossorigin href="/assets/vendor-CITafuNQ.js">
47
+ <link rel="modulepreload" crossorigin href="/assets/global-BCehxTGJ.js">
48
48
  <link rel="modulepreload" crossorigin href="/assets/clipboard-BnAnBk_-.js">
49
- <link rel="modulepreload" crossorigin href="/assets/package-CdOrNWtP.js">
50
- <link rel="stylesheet" crossorigin href="/assets/global-B1Xg1dWA.css">
49
+ <link rel="modulepreload" crossorigin href="/assets/package-B2CgmdJ7.js">
50
+ <link rel="stylesheet" crossorigin href="/assets/global-CIVH6GQV.css">
51
51
  </head>
52
52
  <body class="bg-slate-50 text-slate-900">
53
53
  <div id="landing-root"></div>
@@ -1 +0,0 @@
1
- import{r as n,j as e,aH as B,aI as m,ao as R,W as q}from"./vendor-m8O77Czp.js";import{P as F}from"./PageToolbar-DzpjQ7SY.js";import{P as p}from"./PageSection-D1vbxAKK.js";import{P as I,a as C}from"./PageState-CPKqNFG7.js";import{u as M}from"./useAppMutation-DY1JJByx.js";import{u as z,B as P,q as D}from"./queryKeys-BlGm18Nk.js";import{a as G,B as x,r as $}from"./app-CeLCVbqy.js";import{C as d,a as c}from"./card-DS9KKz-k.js";import{p as J}from"./package-CdOrNWtP.js";import{u as Q}from"./i18n-DWfLgqoF.js";import"./global-zt8jbW7F.js";import"./query-CZuclkQv.js";import"./router-C1-ppOz7.js";import"./radix-OaJStcH-.js";function oe(){var h,f,g,v,j,N,y,w,k,S;const{t}=Q(),{pushToast:r}=G(),[i,A]=n.useState(null),a=z(D.status.gateway(),{url:"/api/status",method:"GET"},{staleTime:6e4});n.useEffect(()=>{a.isError&&a.error&&r({title:t("about.toast.statusError.title"),description:a.error.message,variant:"error"})},[r,a.error,a.isError,t]);const o=M({mutationFn:async()=>$({url:"/api/version/check",method:"GET"}),successToast:s=>s.updateAvailable?{title:t("about.toast.updateAvailable.title",{version:s.latestVersion}),description:t("about.toast.updateAvailable.description",{packageName:s.packageName})}:{title:t("about.toast.upToDate.title",{version:s.currentVersion}),description:t("about.toast.upToDate.description")},errorToast:s=>({title:t("about.toast.updateError.title"),description:s.message}),onSuccess:async s=>{A(s)}}),l=J.version,u="2026-07-25T00:51:24.596Z",V=n.useMemo(()=>{var s,T;return[{label:t("about.app.labels.name"),value:e.jsx("span",{className:"font-mono",children:"cc-gw"})},{label:t("about.app.labels.version"),value:e.jsxs("span",{"data-visual-volatile":"true",className:"font-mono text-primary",children:["v",l]})},{label:t("about.app.labels.buildTime"),value:e.jsx("span",{"data-visual-volatile":"true",children:u}),hint:t("about.app.hint.buildTime")},{label:t("about.app.labels.runtime"),value:e.jsx("span",{className:"font-mono",children:((s=a.data)==null?void 0:s.runtime)??"rust"})},{label:t("about.app.labels.backendVersion"),value:e.jsx("span",{"data-visual-volatile":"true",className:"font-mono",children:((T=a.data)==null?void 0:T.backendVersion)??"-"})}]},[l,u,(h=a.data)==null?void 0:h.backendVersion,(f=a.data)==null?void 0:f.runtime,t]),b=n.useMemo(()=>{var s;return a.data?[{label:t("about.status.labels.host"),value:a.data.host??"127.0.0.1"},{label:t("about.status.labels.port"),value:e.jsx("span",{"data-visual-volatile":"true",children:a.data.port.toLocaleString()})},{label:t("about.status.labels.providers"),value:a.data.providers.toLocaleString()},{label:t("about.status.labels.active"),value:(a.data.activeRequests??0).toLocaleString(),hint:t("about.status.hint.active")},{label:t("about.status.labels.platform"),value:a.data.platform??"-"},{label:t("about.status.labels.pid"),value:e.jsx("span",{"data-visual-volatile":"true",children:((s=a.data.pid)==null?void 0:s.toLocaleString())??"-"})}]:[]},[a.data,t]);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(F,{info:e.jsxs("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground","data-visual-volatile":"true",children:["v",l]}),status:e.jsx("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:"manual refresh only"}),actions:e.jsxs(x,{onClick:()=>o.mutate(),disabled:o.isPending,size:"sm",children:[e.jsx(B,{className:`mr-2 h-4 w-4${o.isPending?" animate-spin":""}`,"aria-hidden":"true"}),o.isPending?t("about.support.actions.checkingUpdates"):t("about.support.actions.checkUpdates")]})}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(320px,0.85fr)]",children:[e.jsx(d,{className:"overflow-hidden",children:e.jsx(c,{className:"p-5",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-secondary px-3 py-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[e.jsx(m,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Runtime snapshot"]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"metric-number truncate text-4xl font-semibold tracking-tight text-foreground",children:[((g=a.data)==null?void 0:g.host)??"127.0.0.1",":",((v=a.data)==null?void 0:v.port)??"-"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("about.description")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs sm:w-56",children:[e.jsx(L,{label:t("about.status.labels.providers"),value:((N=(j=a.data)==null?void 0:j.providers)==null?void 0:N.toLocaleString())??"-"}),e.jsx(L,{label:t("about.status.labels.active"),value:(((y=a.data)==null?void 0:y.activeRequests)??0).toLocaleString()})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(P,{variant:"outline",children:((w=a.data)==null?void 0:w.runtime)??"rust"}),e.jsx(P,{variant:"outline",children:((k=a.data)==null?void 0:k.platform)??"-"})]})]})})}),e.jsx(d,{className:"overflow-hidden",children:e.jsx(c,{className:"p-5",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Build"}),e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"font-mono text-xl font-semibold text-primary",children:["v",l]}),e.jsx("p",{"data-visual-volatile":"true",className:"text-xs text-muted-foreground",children:u})]}),i?e.jsxs("div",{className:"rounded-lg bg-secondary px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:i.updateAvailable?t("about.update.available",{version:i.latestVersion}):t("about.update.current",{version:i.currentVersion})}),e.jsxs("p",{className:"mt-1",children:[t("about.update.channel",{channel:i.channel}),i.publishedAt?` · ${new Date(i.publishedAt).toLocaleString()}`:""]})]}):null,e.jsx("div",{className:"rounded-lg bg-secondary px-3.5 py-3 text-sm text-muted-foreground",children:t("about.support.tip")})]})})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(p,{title:t("about.app.title"),description:t("about.app.subtitle"),children:e.jsx(E,{items:V})}),e.jsx(p,{title:t("about.status.title"),description:t("about.status.subtitle"),actions:e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),disabled:a.isFetching,children:[e.jsx(R,{className:U(a.isFetching),"aria-hidden":"true"}),a.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")]}),children:a.isLoading?e.jsx(I,{compact:!0,label:t("about.status.loading")}):a.isError?e.jsx(C,{compact:!0,tone:"danger",icon:e.jsx(m,{className:"h-5 w-5","aria-hidden":"true"}),title:t("common.status.error"),description:((S=a.error)==null?void 0:S.message)??t("common.unknownError"),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:t("common.actions.refresh")})}):b.length>0?e.jsx(E,{items:b}):e.jsx(C,{compact:!0,tone:"primary",icon:e.jsx(m,{className:"h-5 w-5","aria-hidden":"true"}),title:t("about.status.empty"),description:t("common.actions.refresh")})})]}),e.jsx(p,{title:t("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-medium text-primary",children:t("about.support.subtitle")}),e.jsx("span",{children:t("about.support.description")})]}),children:e.jsx(d,{className:"rounded-xl bg-card shadow-[var(--surface-shadow)]",children:e.jsxs(c,{className:"flex flex-col gap-4 pt-5 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 rounded-lg bg-secondary p-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-primary/10 text-primary",children:e.jsx(q,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:t("about.support.tip")})]}),e.jsx("code",{className:"inline-flex self-start rounded-lg bg-secondary px-3 py-2 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}function E({items:t}){return t.length===0?null:e.jsx("dl",{className:"grid gap-3 sm:grid-cols-2",children:t.map(r=>e.jsx(d,{className:"rounded-xl border border-border bg-secondary shadow-none",children:e.jsxs(c,{className:"p-4",children:[e.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:r.label}),e.jsx("dd",{className:"metric-number mt-2 text-sm font-semibold text-foreground",children:r.value}),r.hint?e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r.hint}):null]})},r.label))})}function L({label:t,value:r}){return e.jsxs("div",{className:"rounded-lg bg-secondary px-3 py-2 text-right",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:t}),e.jsx("p",{className:"metric-number mt-1 text-sm font-semibold text-foreground",children:r})]})}function U(t){return`mr-2 h-4 w-4${t?" animate-spin":""}`}export{oe as default};
@@ -1 +0,0 @@
1
- import{r as o,j as e,$ as xs,ai as te,U as Ce,az as $,aA as ie,aq as us,aB as ve,aC as ms,aD as Ee,ax as De,au as hs}from"./vendor-m8O77Czp.js";import{a as ae,P as ys}from"./PageState-CPKqNFG7.js";import{P as gs}from"./PageToolbar-DzpjQ7SY.js";import{B as u,a as js,b as L,s as O}from"./app-CeLCVbqy.js";import{T as bs,a as vs,b as fe,c as Ke}from"./tabs-BOjStrRw.js";import{C as fs}from"./ConfirmDialog-VrbumD7j.js";import{D as ne,A as le,a as re,b as ce,c as Te,d as oe,e as de}from"./DialogShell-TRFN3c58.js";import{L as P,I as B}from"./label-CWq3wWgE.js";import{c as ke}from"./global-zt8jbW7F.js";import{E as Ae,R as Me,u as Ks}from"./shared-fOyVvn5H.js";import{u as w}from"./i18n-DWfLgqoF.js";import{L as Ns}from"./router-C1-ppOz7.js";import{E as ws}from"./EChart-CZqGiync.js";import{P as ze}from"./PageSection-D1vbxAKK.js";import{B as A,u as Y,q as N}from"./queryKeys-BlGm18Nk.js";import{C as S,a as We}from"./card-DS9KKz-k.js";import{M as Z}from"./metric-card-CueQ0u3Z.js";import{S as qe}from"./segmented-control-do2mQidJ.js";import{T as Cs,a as Es,b as Ne,c as z,d as Ds,e as W}from"./table-BxCEZcKF.js";import{e as Ts}from"./charts-core-CAVUzIcU.js";import{u as U}from"./useAppMutation-DY1JJByx.js";import{a as q}from"./apiKeys-Dl_vgy_U.js";import{c as ks}from"./clipboard-BnAnBk_-.js";import"./query-CZuclkQv.js";import"./radix-OaJStcH-.js";import"./charts-react-B-D6Gq0w.js";import"./charts-engine-BRCKiVl4.js";const Fe=o.forwardRef(({className:a,...s},p)=>e.jsx("textarea",{className:ke("flex min-h-[80px] w-full rounded-xl border border-border bg-card px-3 py-2.5 text-sm text-foreground ring-offset-background placeholder:text-muted-foreground/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:p,...s}));Fe.displayName="Textarea";function As({availableEndpoints:a,isOpen:s,keyDescription:p,keyName:i,maxConcurrency:r,onDescriptionChange:m,onEndpointsChange:g,onKeyNameChange:v,onMaxConcurrencyChange:x,onOpenChange:d,onSubmit:y,selectedEndpoints:n}){const{t:l}=w();return e.jsx(ne,{open:s,onOpenChange:d,children:e.jsxs(le,{className:"max-w-2xl",children:[e.jsxs(re,{children:[e.jsx(ce,{children:l("apiKeys.createNew")}),e.jsx(Te,{children:l("apiKeys.createDescription")})]}),e.jsxs(oe,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border border-primary/20 bg-accent px-4 py-3 text-xs text-primary",children:l("apiKeys.selectEndpoints")}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-3 text-xs text-primary",children:[e.jsx("p",{className:"font-semibold",children:"Restricted"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Select explicit endpoints before saving."})]}),e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-3 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-200",children:[e.jsx("p",{className:"font-semibold",children:"Unrestricted"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Leave endpoint selection empty for broad access."})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-3 text-xs text-destructive",children:[e.jsx("p",{className:"font-semibold",children:"Wildcard"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Special-case key with the highest blast radius."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(P,{htmlFor:"keyName",children:[l("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(B,{id:"keyName",value:i,onChange:h=>v(h.target.value),placeholder:l("apiKeys.keyNamePlaceholder"),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),y())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"keyDescription",children:l("apiKeys.descriptionLabel")}),e.jsx(Fe,{id:"keyDescription",value:p,onChange:h=>m(h.target.value),placeholder:l("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:l("apiKeys.allowedEndpoints")}),e.jsx(Ae,{available:a,selected:n,onChange:g,hint:l("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"maxConcurrency",children:l("apiKeys.maxConcurrency")}),e.jsx(B,{id:"maxConcurrency",type:"number",min:"0",value:r,onChange:h=>x(h.target.value),placeholder:l("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(de,{children:[e.jsx(u,{variant:"outline",onClick:()=>d(!1),children:l("common.actions.cancel")}),e.jsx(u,{onClick:y,children:l("apiKeys.createAction")})]})]})})}function Ms({createdKey:a,onClose:s,onCopy:p}){const{t:i}=w();return e.jsx(ne,{open:!!a,onOpenChange:r=>{r||s()},children:e.jsxs(le,{className:"max-w-xl",children:[e.jsx(re,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-600",children:e.jsx(xs,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(ce,{children:i("apiKeys.keyCreated")})]})}),e.jsxs(oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:i("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 font-mono text-sm",children:a==null?void 0:a.key}),a!=null&&a.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:a.description}):null]}),e.jsxs(de,{children:[e.jsxs(u,{onClick:()=>p((a==null?void 0:a.key)??""),children:[e.jsx(te,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),i("common.actions.copy")]}),e.jsx(u,{variant:"outline",onClick:s,children:i("common.actions.close")})]})]})})}function zs({apiKey:a,availableEndpoints:s,maxConcurrency:p,onClose:i,onEndpointsChange:r,onMaxConcurrencyChange:m,onSave:g,selectedEndpoints:v}){const{t:x}=w();return e.jsx(ne,{open:!!a,onOpenChange:d=>{d||i()},children:e.jsxs(le,{className:"max-w-2xl",children:[e.jsxs(re,{children:[e.jsx(ce,{children:x("apiKeys.editEndpoints")}),e.jsx(Te,{children:a==null?void 0:a.name})]}),e.jsxs(oe,{className:"space-y-4",children:[!(a!=null&&a.isWildcard)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-200",children:x("apiKeys.allEndpoints")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-xs text-muted-foreground",children:"Empty selection means unrestricted access. Only explicit selections create a restricted key scope."}),e.jsx(Ae,{available:s,selected:v,onChange:r,hint:x("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"editMaxConcurrency",children:x("apiKeys.maxConcurrency")}),e.jsx(B,{id:"editMaxConcurrency",type:"number",min:"0",value:p,onChange:d=>m(d.target.value),placeholder:x("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(de,{children:[e.jsx(u,{variant:"outline",onClick:i,children:x("common.actions.cancel")}),e.jsx(u,{onClick:g,children:x("common.save")})]})]})})}function Ws({deleteTarget:a,isDeleting:s,onConfirm:p,onOpenChange:i}){const{t:r}=w();return e.jsx(fs,{open:!!a,onOpenChange:i,title:r("apiKeys.deleteDialogTitle"),description:r("apiKeys.confirmDelete"),confirmLabel:a&&s===a.id?r("common.actions.loading"):r("apiKeys.actions.delete"),cancelLabel:r("common.actions.cancel"),loading:a?s===a.id:!1,onConfirm:p,children:a?e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 font-mono text-xs text-foreground",children:a.name}):null})}function qs({onDismiss:a}){const{t:s}=w();return e.jsxs(S,{className:"relative p-3 sm:p-3.5",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"max-w-md space-y-1 pr-8",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-primary/75",children:"Recommended"}),e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:s("apiKeys.quickStart.title")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:s("apiKeys.quickStart.description")})]}),e.jsx("div",{className:"-mx-1 overflow-x-auto pb-1 lg:mx-0 lg:overflow-visible lg:pb-0",children:e.jsxs("div",{className:"flex gap-2 px-1 md:grid md:grid-cols-3 md:px-0 lg:max-w-3xl",children:[e.jsx(ee,{icon:e.jsx(Ce,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.create.title"),description:s("apiKeys.quickStart.create.description")}),e.jsx(ee,{icon:e.jsx($,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.restrict.title"),description:s("apiKeys.quickStart.restrict.description")}),e.jsx(ee,{icon:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.wildcard.title"),description:s("apiKeys.quickStart.wildcard.description")})]})})]}),a?e.jsx(u,{variant:"ghost",size:"icon",className:"absolute right-1.5 top-1.5 h-7 w-7 text-muted-foreground hover:bg-secondary hover:text-foreground",onClick:a,"aria-label":s("common.actions.close"),children:e.jsx(us,{className:"h-4 w-4","aria-hidden":"true"})}):null]})}function Fs({activeKeysValue:a,enabledKeysValue:s,loading:p,onRangeChange:i,rangeDays:r,requestsChartOption:m,totalKeysValue:g,tokensChartOption:v,usageLength:x}){const{t:d}=w();return e.jsx(ze,{title:d("apiKeys.analytics.title"),description:d("apiKeys.analytics.description",{days:r}),actions:e.jsx(qe,{className:"w-full overflow-x-auto sm:w-auto",value:r,onChange:i,options:Me.map(y=>({value:y.value,label:d(y.labelKey)}))}),children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(Z,{label:d("apiKeys.analytics.cards.total"),value:g,size:"sm"}),e.jsx(Z,{label:d("apiKeys.analytics.cards.enabled"),value:s,size:"sm"}),e.jsx(Z,{label:d("apiKeys.analytics.cards.active",{days:r}),value:a,size:"sm"})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(we,{title:d("apiKeys.analytics.charts.requests"),loading:p,empty:x===0,emptyText:d("apiKeys.analytics.empty"),option:m}),e.jsx(we,{title:d("apiKeys.analytics.charts.tokens"),loading:p,empty:x===0,emptyText:d("apiKeys.analytics.empty"),option:v})]})]})})}function Ls({filteredKeys:a,formatDate:s,hasWildcard:p,isDeleting:i,isRevealing:r,keys:m,onCopy:g,onDelete:v,onEditEndpoints:x,onFilterChange:d,onHide:y,onReveal:n,onStatusFilterChange:l,onToggleEnabled:h,revealedKeys:E,search:C,statusFilter:K,viewMode:T,onViewModeChange:j,onCreateKey:G}){const{t:b}=w();return e.jsx(ze,{title:b("apiKeys.list.title"),description:p?b("apiKeys.wildcardHint"):void 0,actions:e.jsxs("div",{className:"flex w-full flex-wrap items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[e.jsx(qe,{value:T,onChange:j,options:[{value:"cards",label:b("apiKeys.views.cards"),icon:e.jsx(ve,{className:"h-3.5 w-3.5","aria-hidden":"true"})},{value:"compact",label:b("apiKeys.views.compact"),icon:e.jsx(ms,{className:"h-3.5 w-3.5","aria-hidden":"true"})}]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.jsx(A,{variant:"outline",children:`${a.length}/${m.length}`})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 rounded-xl bg-secondary p-4 sm:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx(B,{value:C,onChange:f=>d(f.target.value),placeholder:b("apiKeys.filters.searchPlaceholder")}),e.jsx("div",{className:"flex min-w-max items-center gap-1 overflow-x-auto rounded-full bg-background p-1 sm:justify-self-end",children:["all","enabled","disabled"].map(f=>e.jsx("button",{type:"button",onClick:()=>l(f),className:ke("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",K===f?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:b(`apiKeys.filters.${f}`)},f))})]}),m.length===0?e.jsx(ae,{compact:!0,tone:"primary",className:"rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(Ce,{className:"h-5 w-5","aria-hidden":"true"}),title:b("apiKeys.list.emptyTitle"),description:b("apiKeys.list.empty"),action:e.jsx(u,{size:"sm",onClick:G,children:b("apiKeys.createNew")})}):a.length===0?e.jsx(ae,{compact:!0,tone:"primary",className:"rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(ve,{className:"h-5 w-5","aria-hidden":"true"}),title:b("apiKeys.list.emptyFilteredTitle"),description:b("apiKeys.list.emptyFiltered"),action:e.jsx(u,{variant:"outline",size:"sm",onClick:()=>{d(""),l("all")},children:b("common.actions.reset")})}):T==="compact"?e.jsx(Os,{filteredKeys:a,formatDate:s,isDeleting:i,isRevealing:r,onCopy:g,onDelete:v,onEditEndpoints:x,onHide:y,onReveal:n,onToggleEnabled:h,revealedKeys:E}):e.jsx("div",{className:"grid gap-4",children:a.map(f=>e.jsx(Rs,{formatDate:s,isDeleting:i===f.id,isRevealing:r===f.id,keySummary:f,onCopy:g,onDelete:v,onEditEndpoints:x,onHide:y,onReveal:n,onToggleEnabled:h,revealedValue:E.get(f.id)},f.id))})]})})}function Os({filteredKeys:a,formatDate:s,isDeleting:p,isRevealing:i,onCopy:r,onDelete:m,onEditEndpoints:g,onHide:v,onReveal:x,onToggleEnabled:d,revealedKeys:y}){const{t:n}=w();return e.jsx(S,{className:"overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Cs,{className:"min-w-[980px]",children:[e.jsx(Es,{children:e.jsxs(Ne,{className:"bg-secondary/45 hover:bg-secondary/45",children:[e.jsx(z,{children:n("apiKeys.table.name")}),e.jsx(z,{children:n("apiKeys.table.access")}),e.jsx(z,{className:"text-right",children:n("apiKeys.requestCount")}),e.jsx(z,{className:"text-right",children:n("apiKeys.totalTokens")}),e.jsx(z,{className:"text-right",children:n("apiKeys.maxConcurrency")}),e.jsx(z,{children:n("apiKeys.lastUsed")}),e.jsx(z,{className:"w-[132px] text-right",children:n("apiKeys.table.actions")})]})}),e.jsx(Ds,{children:a.map(l=>{var K,T,j;const h=y.get(l.id),E=(l.totalInputTokens+l.totalOutputTokens).toLocaleString(),C=l.isWildcard?n("apiKeys.wildcard"):(((K=l.allowedEndpoints)==null?void 0:K.length)??0)>0?(T=l.allowedEndpoints)==null?void 0:T.join(", "):n("apiKeys.allEndpoints");return e.jsxs(Ne,{children:[e.jsx(W,{className:"py-3",children:e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-foreground",children:l.name}),l.isWildcard?e.jsx(A,{variant:"secondary",className:"text-[11px]",children:n("apiKeys.wildcard")}):null,e.jsx(A,{variant:l.enabled?"default":"outline",className:"text-[11px]",children:l.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")})]}),l.isWildcard?null:e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("code",{className:"max-w-[220px] truncate rounded-md bg-secondary px-2 py-1 font-mono text-xs",children:h??l.maskedKey??"********"}),h?e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>r(h),"aria-label":n("common.actions.copy"),children:e.jsx(te,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(l.id),"aria-label":n("apiKeys.actions.hide"),children:e.jsx(ie,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>x(l.id),disabled:i===l.id,"aria-label":n("apiKeys.actions.reveal"),children:i===l.id?e.jsx("div",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Ee,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})}),e.jsx(W,{className:"py-3",children:e.jsxs("div",{className:"max-w-[180px]",children:[e.jsx("div",{className:"truncate text-sm text-foreground",title:C,children:C}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:l.isWildcard?n("apiKeys.table.accessWildcard"):(((j=l.allowedEndpoints)==null?void 0:j.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.table.accessOpen")})]})}),e.jsx(W,{className:"py-3 text-right font-medium",children:l.requestCount.toLocaleString()}),e.jsx(W,{className:"py-3 text-right font-medium",children:E}),e.jsx(W,{className:"py-3 text-right font-medium",children:l.maxConcurrency?String(l.maxConcurrency):"—"}),e.jsxs(W,{className:"py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:s(l.lastUsedAt)}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s(l.createdAt)})]}),e.jsx(W,{className:"py-3",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(u,{variant:"outline",size:"icon",onClick:()=>g(l),className:"h-8 w-8","aria-label":l.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints"),title:l.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints"),children:e.jsx($,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(u,{variant:l.enabled?"outline":"default",size:"sm",onClick:()=>d(l.id,l.enabled),className:"h-8 px-2.5 text-xs",children:l.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),l.isWildcard?null:e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>m(l),disabled:p===l.id,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(De,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})})]},l.id)})})]})})})}function ee({description:a,icon:s,title:p}){return e.jsxs("div",{className:"w-[220px] shrink-0 rounded-xl border border-border bg-secondary p-3 md:w-auto",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-background text-primary sm:h-8 sm:w-8 sm:rounded-lg",children:s}),e.jsx("p",{className:"mt-2 text-[12px] font-semibold leading-5 text-foreground sm:mt-2.5 sm:text-[13px]",children:p}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-4.5 text-muted-foreground sm:text-xs sm:leading-5",children:a})]})}function Rs({formatDate:a,isDeleting:s,isRevealing:p,keySummary:i,onCopy:r,onDelete:m,onEditEndpoints:g,onHide:v,onReveal:x,onToggleEnabled:d,revealedValue:y}){var h,E,C;const{t:n}=w(),l=(i.totalInputTokens+i.totalOutputTokens).toLocaleString();return e.jsx(S,{"data-testid":"api-key-card",className:"overflow-hidden",children:e.jsx(We,{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold",children:i.name}),i.isWildcard?e.jsx(A,{variant:"secondary",children:n("apiKeys.wildcard")}):null,e.jsx(A,{variant:i.enabled?"default":"outline",children:i.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")}),i.isWildcard?null:e.jsx(A,{variant:"outline",className:"text-xs",children:(((h=i.allowedEndpoints)==null?void 0:h.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.allEndpoints")}),!i.isWildcard&&i.allowedEndpoints&&i.allowedEndpoints.length>0?i.allowedEndpoints.map(K=>e.jsx(A,{variant:"outline",className:"text-xs",children:K},K)):i.isWildcard?null:e.jsx(A,{variant:"secondary",className:"text-xs opacity-60",children:n("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx(se,{label:n("apiKeys.requestCount"),value:i.requestCount.toLocaleString()}),e.jsx(se,{label:n("apiKeys.totalTokens"),value:l}),e.jsx(se,{label:n("apiKeys.maxConcurrency"),value:i.maxConcurrency?String(i.maxConcurrency):n("apiKeys.maxConcurrencyPlaceholder")})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("code",{className:"block max-w-full break-all rounded-lg bg-secondary px-3 py-1.5 font-mono text-sm",children:i.isWildcard?n("apiKeys.wildcard"):y??i.maskedKey??"********"}),i.isWildcard?null:e.jsx("div",{className:"flex items-center gap-1 self-start",children:y?e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>r(y),"aria-label":n("common.actions.copy"),title:n("common.actions.copy"),children:e.jsx(te,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>v(i.id),"aria-label":n("apiKeys.actions.hide"),title:n("apiKeys.actions.hide"),children:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>x(i.id),disabled:p,"aria-label":n("apiKeys.actions.reveal"),title:n("apiKeys.actions.reveal"),children:p?e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Ee,{className:"h-4 w-4","aria-hidden":"true"})})})]}),i.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:n("apiKeys.wildcardHint")}):i.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:i.description}):null,i.isWildcard?null:e.jsx("div",{className:"rounded-lg bg-secondary px-3 py-2 text-xs text-muted-foreground",children:(((E=i.allowedEndpoints)==null?void 0:E.length)??0)>0?`${n("apiKeys.allowedEndpoints")}: ${(C=i.allowedEndpoints)==null?void 0:C.join(", ")}`:n("apiKeys.allEndpoints")}),e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:a(i.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:a(i.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:flex lg:flex-wrap lg:justify-end",children:[e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>g(i),className:"w-full lg:w-auto",children:[e.jsx($,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),i.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints")]}),e.jsx(u,{variant:i.enabled?"outline":"default",size:"sm",onClick:()=>d(i.id,i.enabled),className:"w-full lg:w-auto",children:i.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),i.isWildcard?null:e.jsx(u,{variant:"ghost",size:"icon",className:"h-9 w-full text-destructive hover:bg-destructive/10 hover:text-destructive sm:w-9",onClick:()=>m(i),disabled:s,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(De,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})})}function se({label:a,value:s}){return e.jsxs("div",{className:"rounded-lg bg-secondary px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:s})]})}function we({empty:a,emptyText:s,loading:p,option:i,title:r}){const{t:m}=w();return e.jsx(S,{children:e.jsxs(We,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:r}),p?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:m("common.loadingShort")})}):a?e.jsx(ae,{compact:!0,className:"min-h-[280px] rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx($,{className:"h-5 w-5","aria-hidden":"true"}),title:s,description:m("apiKeys.analytics.emptyHint"),action:e.jsx(u,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(Ns,{to:"/logs",children:m("apiKeys.analytics.actions.logs")})})}):e.jsx(ws,{echarts:Ts,option:i,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}function Ps(){const{t:a}=w(),{pushToast:s}=js(),[p,i]=o.useState(!1),[r,m]=o.useState(""),[g,v]=o.useState(""),[x,d]=o.useState([]),[y,n]=o.useState(""),[l,h]=o.useState(null),[E,C]=o.useState(null),[K,T]=o.useState(null),[j,G]=L(O.apiKeys.rangeDays,7,{serialize:t=>String(t),deserialize:t=>{const c=Number(t);return Me.some(D=>D.value===c)?c:7}}),[b,f]=o.useState(new Map),[Le,pe]=o.useState(null),[R,_]=o.useState(null),[V,xe]=o.useState([]),[Q,ue]=o.useState(""),[X,Oe]=L(O.apiKeys.search,""),[H,Re]=L(O.apiKeys.statusFilter,"all",{serialize:t=>t,deserialize:t=>t==="enabled"||t==="disabled"?t:"all"}),[Pe,Ve]=L(O.apiKeys.viewMode,"compact",{serialize:t=>t,deserialize:t=>t==="cards"?"cards":"compact"}),[Qe,He]=L(O.apiKeys.activeTab,"inventory",{serialize:t=>t,deserialize:t=>t==="analytics"?"analytics":"inventory"}),[Ie,Ue]=L(O.apiKeys.quickStartDismissed,!1),Be=Ks(),me=Y(N.apiKeys.all(),q.listRequest()),$e=Y(N.apiKeys.overview(j),q.overviewRequest(j)),he=Y(N.apiKeys.usage(j),q.usageRequest(j)),ye=U({mutationFn:q.create,invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyCreated")}),errorToast:t=>({title:a("apiKeys.toast.createFailure",{message:t.message})})}),I=U({mutationFn:({id:t,...c})=>q.update(t,c),invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyUpdated")}),errorToast:t=>({title:a("apiKeys.toast.updateFailure",{message:t.message})})}),ge=U({mutationFn:({id:t})=>q.delete(t),invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyDeleted")}),errorToast:t=>({title:a("apiKeys.toast.deleteFailure",{message:t.message})})}),je=U({mutationFn:({id:t})=>q.reveal(t),errorToast:t=>({title:a("apiKeys.toast.revealFailure"),description:t.message})}),M=me.data??[],F=$e.data,k=he.data??[],Se=M.some(t=>t.isWildcard),Ge=M.filter(t=>t.isWildcard).length,_e=M.filter(t=>{var c;return!t.isWildcard&&(((c=t.allowedEndpoints)==null?void 0:c.length)??0)>0}).length,Xe=M.filter(t=>{var c;return!t.isWildcard&&(((c=t.allowedEndpoints)==null?void 0:c.length)??0)===0}).length,Je=F?F.totalKeys.toLocaleString():"-",Ye=F?F.enabledKeys.toLocaleString():"-",Ze=F?F.activeKeys.toLocaleString():"-",es=o.useMemo(()=>M.filter(t=>{if(!(H==="all"||(H==="enabled"?t.enabled:!t.enabled)))return!1;const D=X.trim().toLowerCase();return D?[t.name,t.description??"",t.maskedKey??"",...t.allowedEndpoints??[]].join(" ").toLowerCase().includes(D):!0}),[M,X,H]),ss=o.useMemo(()=>{const t=k.map(c=>c.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:t,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.requestsSeries"),type:"bar",data:k.map(c=>c.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[a,k]),as=o.useMemo(()=>{const t=k.map(c=>c.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[a("apiKeys.analytics.tokens.input"),a("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:t,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:k.map(c=>c.inputTokens)},{name:a("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:k.map(c=>c.outputTokens)}]}},[a,k]),be=o.useCallback(()=>{m(""),v(""),d([]),n("")},[]),J=o.useCallback(t=>{i(t),t||be()},[be]),ts=o.useCallback(async()=>{if(!r.trim()){s({title:a("apiKeys.errors.nameRequired"),variant:"error"});return}try{const t=await ye.mutateAsync({name:r.trim(),description:g.trim()||void 0,allowedEndpoints:x.length>0?x:void 0,maxConcurrency:y?Number(y):null});h(t),J(!1)}catch{}},[ye,J,g,x,y,r,s,a]),is=o.useCallback(async(t,c)=>{try{await I.mutateAsync({id:t,enabled:!c})}catch{}},[I]),ns=o.useCallback(async()=>{if(K){C(K.id);try{await ge.mutateAsync({id:K.id}),T(null)}catch{}finally{C(null)}}},[K,ge]),ls=o.useCallback(async t=>{if(!b.has(t)){pe(t);try{const c=await je.mutateAsync({id:t});f(D=>new Map(D).set(t,c.key))}catch{}finally{pe(null)}}},[je,b]),rs=o.useCallback(t=>{f(c=>{const D=new Map(c);return D.delete(t),D})},[]),cs=o.useCallback(async t=>{try{await ks(t),s({title:a("apiKeys.toast.keyCopied"),variant:"success"})}catch(c){s({title:a("apiKeys.toast.copyFailure"),description:c instanceof Error?c.message:a("common.unknownError"),variant:"error"})}},[s,a]),os=o.useCallback(t=>{_(t),xe(t.allowedEndpoints??[]),ue(t.maxConcurrency?String(t.maxConcurrency):"")},[]),ds=o.useCallback(async()=>{if(R)try{await I.mutateAsync({id:R.id,...R.isWildcard?{}:{allowedEndpoints:V.length>0?V:null},maxConcurrency:Q?Number(Q):null}),_(null)}catch{}},[R,V,Q,I]),ps=o.useCallback(t=>t?new Date(t).toLocaleString():a("common.noData"),[a]);return{activeKeysValue:Ze,activeTab:Qe,availableEndpoints:Be,deleteTarget:K,editEndpointsKey:R,editEndpointsSelection:V,editMaxConcurrency:Q,enabledKeysValue:Ye,filteredKeys:es,formatDate:ps,handleCopyKey:cs,handleCreateDialogChange:J,handleCreateKey:ts,handleDeleteKey:ns,handleHideKey:rs,handleOpenEditEndpoints:os,handleRevealKey:ls,handleSaveEndpoints:ds,handleToggleEnabled:is,hasWildcard:Se,isCreateDialogOpen:p,isDeleting:E,isRevealing:Le,keys:M,keysQuery:me,newKeyDescription:g,newKeyEndpoints:x,newKeyMaxConcurrency:y,newKeyName:r,newlyCreatedKey:l,quickStartDismissed:Ie,rangeDays:j,requestsChartOption:ss,restrictedCount:_e,revealedKeys:b,search:X,setQuickStartDismissed:Ue,setActiveTab:He,setDeleteTarget:T,setEditEndpointsKey:_,setEditEndpointsSelection:xe,setEditMaxConcurrency:ue,setNewKeyDescription:v,setNewKeyEndpoints:d,setNewKeyMaxConcurrency:n,setNewKeyName:m,setNewlyCreatedKey:h,setRangeDays:G,setSearch:Oe,setStatusFilter:Re,statusFilter:H,tokensChartOption:as,totalKeysValue:Je,unrestrictedCount:Xe,usage:k,usageQuery:he,viewMode:Pe,wildcardCount:Ge,setViewMode:Ve}}function ua(){const{t:a}=w(),s=Ps();if(s.keysQuery.isLoading)return e.jsx(ys,{label:a("common.loading")});const i=s.keys.filter(r=>!r.isWildcard).length===0&&!s.quickStartDismissed;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(gs,{status:e.jsxs("span",{className:"text-xs text-muted-foreground",children:[a("apiKeys.summary.wildcard",{count:s.wildcardCount})," / ",a("apiKeys.summary.restricted",{count:s.restrictedCount})," / ",a("apiKeys.summary.unrestricted",{count:s.unrestrictedCount})]}),actions:e.jsxs(u,{size:"sm",onClick:()=>s.handleCreateDialogChange(!0),children:[e.jsx(hs,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("apiKeys.createNew")]})}),i?e.jsx(qs,{onDismiss:()=>s.setQuickStartDismissed(!0)}):null,e.jsxs(bs,{value:s.activeTab,onValueChange:r=>s.setActiveTab(r),children:[e.jsxs(vs,{children:[e.jsx(fe,{value:"inventory",children:a("apiKeys.tabs.inventory")}),e.jsx(fe,{value:"analytics",children:a("apiKeys.tabs.analytics")})]}),e.jsx(Ke,{value:"inventory",className:"mt-4",children:e.jsx(Ls,{filteredKeys:s.filteredKeys,formatDate:s.formatDate,hasWildcard:s.hasWildcard,isDeleting:s.isDeleting,isRevealing:s.isRevealing,keys:s.keys,onCopy:r=>void s.handleCopyKey(r),onDelete:s.setDeleteTarget,onEditEndpoints:s.handleOpenEditEndpoints,onFilterChange:s.setSearch,onHide:s.handleHideKey,onReveal:r=>void s.handleRevealKey(r),onStatusFilterChange:s.setStatusFilter,onToggleEnabled:(r,m)=>void s.handleToggleEnabled(r,m),revealedKeys:s.revealedKeys,search:s.search,statusFilter:s.statusFilter,viewMode:s.viewMode,onViewModeChange:s.setViewMode,onCreateKey:()=>s.handleCreateDialogChange(!0)})}),e.jsx(Ke,{value:"analytics",className:"mt-4",children:e.jsx(Fs,{activeKeysValue:s.activeKeysValue,enabledKeysValue:s.enabledKeysValue,loading:s.usageQuery.isLoading,onRangeChange:s.setRangeDays,rangeDays:s.rangeDays,requestsChartOption:s.requestsChartOption,totalKeysValue:s.totalKeysValue,tokensChartOption:s.tokensChartOption,usageLength:s.usage.length})})]}),e.jsx(As,{availableEndpoints:s.availableEndpoints,isOpen:s.isCreateDialogOpen,keyDescription:s.newKeyDescription,keyName:s.newKeyName,maxConcurrency:s.newKeyMaxConcurrency,onDescriptionChange:s.setNewKeyDescription,onEndpointsChange:s.setNewKeyEndpoints,onKeyNameChange:s.setNewKeyName,onMaxConcurrencyChange:s.setNewKeyMaxConcurrency,onOpenChange:s.handleCreateDialogChange,onSubmit:()=>void s.handleCreateKey(),selectedEndpoints:s.newKeyEndpoints}),e.jsx(Ms,{createdKey:s.newlyCreatedKey,onClose:()=>s.setNewlyCreatedKey(null),onCopy:r=>void s.handleCopyKey(r)}),e.jsx(zs,{apiKey:s.editEndpointsKey,availableEndpoints:s.availableEndpoints,maxConcurrency:s.editMaxConcurrency,onClose:()=>s.setEditEndpointsKey(null),onEndpointsChange:s.setEditEndpointsSelection,onMaxConcurrencyChange:s.setEditMaxConcurrency,onSave:()=>void s.handleSaveEndpoints(),selectedEndpoints:s.editEndpointsSelection}),e.jsx(Ws,{deleteTarget:s.deleteTarget,isDeleting:s.isDeleting,onConfirm:()=>void s.handleDeleteKey(),onOpenChange:r=>{!r&&s.isDeleting===null&&s.setDeleteTarget(null)}})]})}export{ua as default};
@@ -1 +0,0 @@
1
- import{j as e,al as Ce,am as Le,an as te,aa as Ee,O as z,r as p,ao as Re,T as Me}from"./vendor-m8O77Czp.js";import{P as Ie}from"./PageToolbar-DzpjQ7SY.js";import{P as $,a as L}from"./PageState-CPKqNFG7.js";import{B as S,u as Ae,a as Pe,b as De,c as ke,t as Be,s as qe}from"./app-CeLCVbqy.js";import{S as Fe,a as Oe,b as ze,c as $e,d as A}from"./select-CxIEo3DN.js";import{c as _e}from"./global-zt8jbW7F.js";import{L as C}from"./router-C1-ppOz7.js";import{E as se}from"./EChart-CZqGiync.js";import{P as _}from"./PageSection-D1vbxAKK.js";import{S as Ve,C as Ke,T as He,g as Z}from"./utils-DrKJJFzS.js";import{B as y,u as P,q as D}from"./queryKeys-BlGm18Nk.js";import{C as ae,a as re}from"./card-DS9KKz-k.js";import{D as oe}from"./disclosure-CqU8C-ET.js";import{M as N}from"./metric-card-CueQ0u3Z.js";import{T as ne,a as ie,b as B,c as g,d as le,e as j}from"./table-BxCEZcKF.js";import{u as x}from"./i18n-DWfLgqoF.js";import{e as de}from"./charts-core-CAVUzIcU.js";import{u as Qe}from"./useEventStream-DeEWwZq0.js";import{a as Ge}from"./apiKeys-Dl_vgy_U.js";import{g as Ue}from"./gateway-Bt6lPuXq.js";import"./query-CZuclkQv.js";import"./radix-OaJStcH-.js";import"./charts-react-B-D6Gq0w.js";import"./charts-engine-BRCKiVl4.js";const We=15e3,Ye=6e4;function k(t,a,s){return t==null?"-":`${t.toLocaleString(void 0,s)} ${a}`}function O(t){if(t==null)return"-";if(t<1024)return`${t} B`;const a=["KB","MB","GB","TB"];let s=t/1024,r=0;for(;s>=1024&&r<a.length-1;)s/=1024,r+=1;return`${s.toFixed(s>=100?0:s>=10?1:2)} ${a[r]}`}function ee(t){if(t==null)return"-";const a=t<1?0:t;return a<1024?`${a.toLocaleString(void 0,{maximumFractionDigits:a>=100?0:a>=10?1:2})} B/s`:`${O(a)}/s`}function Je(t){return t==null?"-":`${t.toLocaleString(void 0,{maximumFractionDigits:t>=10?0:1})}%`}function Xe(){return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:Array.from({length:4}).map((t,a)=>e.jsx(Ve,{},a))}),e.jsx(Ke,{}),e.jsx("div",{className:"rounded-xl bg-card shadow-[var(--surface-shadow)]",children:e.jsx("table",{className:"w-full",children:e.jsx("tbody",{children:Array.from({length:5}).map((t,a)=>e.jsx(He,{columns:6},a))})})})]})}function Ze({status:t}){const{t:a}=x();return e.jsxs("div",{className:"space-y-3","data-testid":"dashboard-spotlight-grid",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm","data-testid":"dashboard-overview-panel",children:[e.jsx("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-success-bg px-1.5 py-0.5 text-[11px] font-medium text-success before:h-1.5 before:w-1.5 before:rounded-full before:bg-success",children:a("dashboard.status.listeningLabel")}),e.jsxs("span",{"data-testid":"dashboard-runtime-address",className:"metric-number text-sm font-semibold tracking-tight text-foreground",children:[(t==null?void 0:t.host)??"0.0.0.0",":",(t==null?void 0:t.port)??"-"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a("dashboard.status.providers",{value:(t==null?void 0:t.providers)??0})})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(N,{size:"md",label:a("dashboard.labels.activeRequests"),value:((t==null?void 0:t.activeRequests)??0).toLocaleString(),rawValue:(t==null?void 0:t.activeRequests)??0,valueTestId:"dashboard-spotlight-value-active"}),e.jsx(N,{size:"md",label:a("dashboard.labels.requestsPerMinute"),value:((t==null?void 0:t.requestsPerMinute)??0).toLocaleString(),rawValue:(t==null?void 0:t.requestsPerMinute)??0,valueTestId:"dashboard-spotlight-value-rpm"}),e.jsx(N,{size:"md",label:a("dashboard.labels.uniqueClientAddressesLastHour"),value:((t==null?void 0:t.uniqueClientAddressesLastHour)??0).toLocaleString(),rawValue:(t==null?void 0:t.uniqueClientAddressesLastHour)??0}),e.jsx(N,{size:"md",label:a("dashboard.labels.cpu"),value:Je(t==null?void 0:t.cpuUsagePercent),valueTestId:"dashboard-spotlight-value-cpu"})]})]})}function et(t){switch(t){case"error":return e.jsx(y,{variant:"destructive",children:"error"});case"warn":return e.jsx(y,{variant:"warning",children:"warn"});default:return e.jsx(y,{variant:"secondary",children:"info"})}}function tt({connected:t,failed:a,events:s}){const{t:r}=x();return s.length===0?null:e.jsx(_,{title:r("dashboard.attention.title"),description:r("dashboard.attention.subtitle"),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:a?"inline-flex items-center gap-1 text-[11px] font-medium text-destructive before:h-1.5 before:w-1.5 before:rounded-full before:bg-destructive":t?"inline-flex items-center gap-1 text-[11px] font-medium text-success before:h-1.5 before:w-1.5 before:rounded-full before:bg-success":"inline-flex items-center gap-1 text-[11px] font-medium text-warning before:h-1.5 before:w-1.5 before:rounded-full before:bg-warning",children:r(a?"dashboard.attention.failed":t?"dashboard.attention.live":"dashboard.attention.reconnecting")}),e.jsx(S,{asChild:!0,variant:"ghost",size:"sm",className:"h-7",children:e.jsx(C,{to:"/events",children:r("dashboard.attention.viewAll")})})]}),children:e.jsx("ul",{className:"divide-y divide-border",children:e.jsx(Le,{initial:!1,children:s.map(o=>e.jsxs(te.li,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:.18},className:"flex items-start gap-3 py-2.5 first:pt-0 last:pb-0",children:[e.jsx("div",{className:"pt-0.5",children:et(o.level)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.title??o.type}),o.message?e.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:o.message}):null]}),e.jsx("span",{className:"shrink-0 pt-0.5 text-[11px] tabular-nums text-muted-foreground/70",children:new Date(o.createdAt).toLocaleTimeString()})]},o.id))})})})}function st({connected:t,failed:a}){const{t:s}=x();return e.jsxs(te.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},transition:{duration:.18},"data-testid":"dashboard-all-clear",className:"flex h-8 flex-wrap items-center gap-x-2 gap-y-1 rounded-full bg-success-bg px-3 text-xs text-success",children:[e.jsx(Ee,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium",children:s("dashboard.attention.allClear")}),e.jsx("span",{className:a?"ml-auto inline-flex items-center gap-1.5 text-[11px] font-medium text-destructive before:h-1.5 before:w-1.5 before:rounded-full before:bg-destructive":t?"ml-auto inline-flex items-center gap-1.5 text-[11px] font-medium before:h-1.5 before:w-1.5 before:rounded-full before:bg-success":"ml-auto inline-flex items-center gap-1.5 text-[11px] font-medium text-warning before:h-1.5 before:w-1.5 before:rounded-full before:bg-warning",children:s(a?"dashboard.attention.failed":t?"dashboard.attention.live":"dashboard.attention.reconnecting")}),e.jsx(C,{to:"/events",className:"shrink-0 underline-offset-2 hover:underline",children:s("dashboard.attention.viewAll")})]})}function at({empty:t,loading:a,option:s}){const{t:r}=x();return e.jsx(ct,{title:r("dashboard.charts.trendTitle"),description:r("dashboard.charts.trendDesc"),loading:a,option:s,empty:t,emptyText:r("dashboard.charts.empty")})}function rt({modelRequestsOption:t,models:a,ttftOption:s,tpotOption:r}){const{t:o}=x();return e.jsxs(oe,{variant:"card",summaryClassName:"px-4 py-3",contentClassName:"border-t border-border px-4 py-4",summary:e.jsx("span",{className:"text-sm font-medium text-foreground",children:o("dashboard.sections.performance")}),children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsx(F,{title:o("dashboard.charts.modelTitle"),option:t,empty:!a.length}),e.jsx(F,{title:o("dashboard.charts.ttftTitle"),option:s,empty:!a.some(n=>n.avgTtftMs!=null&&n.avgTtftMs>0)}),e.jsx(F,{title:o("dashboard.charts.tpotTitle"),option:r,empty:!a.some(n=>n.avgTpotMs!=null&&n.avgTpotMs>0)})]}),e.jsx("div",{className:"mt-4",children:e.jsx(lt,{models:a,embedded:!0})})]})}function ot({compacting:t,dbInfo:a,dbSizeDisplay:s,memoryDisplay:r,onCompact:o,status:n}){const{t:c}=x();return e.jsxs(oe,{variant:"card",summaryClassName:"px-4 py-3",contentClassName:"border-t border-border px-4 py-4",summary:e.jsx("span",{className:"text-sm font-medium text-foreground",children:c("dashboard.cards.systemResources")}),badge:e.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[s," · ",r]}),children:[e.jsxs("div",{className:"grid gap-2.5 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(N,{size:"sm",label:c("dashboard.labels.networkIngress"),value:ee(n==null?void 0:n.networkIngressBytesPerSecond),valueTestId:"dashboard-spotlight-value-ingress"}),e.jsx(N,{size:"sm",label:c("dashboard.labels.networkEgress"),value:ee(n==null?void 0:n.networkEgressBytesPerSecond),valueTestId:"dashboard-spotlight-value-egress"}),e.jsx(N,{size:"sm",label:c("dashboard.labels.database"),value:s,valueTestId:"dashboard-spotlight-value-database"}),e.jsx(N,{size:"sm",label:c("dashboard.labels.memory"),value:r,valueTestId:"dashboard-spotlight-value-memory"})]}),e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(S,{variant:"outline",size:"sm",onClick:o,disabled:t,children:c(t?"dashboard.actions.compacting":"dashboard.actions.compact")})})]})}function nt({doneCount:t,total:a}){const{t:s}=x(),r=Math.min(100,Math.round(t/a*100));return e.jsxs("div",{"data-testid":"dashboard-setup-progress",className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-full bg-secondary/60 px-4 py-2",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:s("dashboard.setupProgress.label",{done:t,total:a})}),e.jsx("div",{className:"h-1.5 min-w-24 flex-1 overflow-hidden rounded-full bg-border/60",children:e.jsx("div",{className:"h-1.5 rounded-full bg-primary transition-all",style:{width:`${r}%`}})}),e.jsx(C,{to:"/setup",className:"shrink-0 text-xs font-medium text-primary underline-offset-2 hover:underline",children:s("dashboard.setupProgress.cta")})]})}function it({endpointCount:t,providerCount:a}){const{t:s}=x(),r=[{title:s("dashboard.guide.step1Title"),description:a>0?s("dashboard.guide.step1DescDone",{count:a}):s("dashboard.guide.step1Desc"),href:"/providers",cta:s("dashboard.guide.step1Cta")},{title:s("dashboard.guide.step2Title"),description:t>0?s("dashboard.guide.step2DescDone",{count:t}):s("dashboard.guide.step2Desc"),href:"/providers",cta:s("dashboard.guide.step2Cta")},{title:s("dashboard.guide.step3Title"),description:s("dashboard.guide.step3Desc"),href:"/api-keys",cta:s("dashboard.guide.step3Cta")}];return e.jsx(ae,{className:"relative overflow-hidden",children:e.jsxs(re,{className:"space-y-5 pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:s("dashboard.guide.title")}),e.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:s("dashboard.guide.subtitle")})]}),e.jsx(S,{asChild:!0,size:"sm",children:e.jsx(C,{to:"/setup",children:s("dashboard.guide.startWizard")})})]}),e.jsx("ol",{className:"grid gap-3 lg:grid-cols-3",children:r.map((o,n)=>e.jsxs("li",{className:"rounded-lg border border-border p-4",children:[e.jsx("span",{className:"metric-number text-xs font-semibold text-muted-foreground",children:String(n+1).padStart(2,"0")}),e.jsx("h4",{className:"mt-2 text-sm font-semibold text-foreground",children:o.title}),e.jsx("p",{className:"mt-1.5 text-xs leading-6 text-muted-foreground",children:o.description}),e.jsx(S,{asChild:!0,variant:"ghost",size:"sm",className:"mt-2 h-8 px-0 text-primary hover:bg-transparent hover:text-primary/80",children:e.jsx(C,{to:o.href,children:o.cta})})]},o.title))})]})})}function lt({models:t,loading:a,embedded:s}){const{t:r}=x(),o=a?e.jsx($,{compact:!0,label:r("common.loadingShort")}):t.length===0?e.jsx(L,{compact:!0,icon:e.jsx(z,{className:"h-5 w-5","aria-hidden":"true"}),title:r("dashboard.modelTable.empty")}):e.jsx("div",{className:"overflow-auto",children:e.jsxs(ne,{children:[e.jsx(ie,{children:e.jsxs(B,{children:[e.jsx(g,{children:r("dashboard.modelTable.columns.model")}),e.jsx(g,{className:"text-right",children:r("dashboard.modelTable.columns.requests")}),e.jsx(g,{className:"text-right",children:r("dashboard.modelTable.columns.latency")}),e.jsx(g,{className:"text-right",children:r("dashboard.modelTable.columns.ttft")}),e.jsx(g,{className:"text-right",children:r("dashboard.modelTable.columns.tpot")})]})}),e.jsx(le,{children:t.map(n=>e.jsxs(B,{children:[e.jsx(j,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:n.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n.model})]})}),e.jsx(j,{className:"text-right font-medium",children:n.requests.toLocaleString()}),e.jsx(j,{className:"text-right",children:k(n.avgLatencyMs,r("common.units.ms"))}),e.jsx(j,{className:"text-right",children:k(n.avgTtftMs,r("common.units.ms"))}),e.jsx(j,{className:"text-right",children:k(n.avgTpotMs,r("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${n.provider}/${n.model}`))})]})});return s?o:e.jsx(_,{title:r("dashboard.modelTable.title"),description:r("dashboard.modelTable.description"),children:o})}function dt({records:t,loading:a}){const{t:s}=x(),r=t.map(i=>Z(i,s)),o=r.filter(i=>i.tone==="success").length,n=r.filter(i=>i.tone==="error").length,c=r.filter(i=>i.tone==="pending").length;return e.jsx(_,{title:s("dashboard.recent.title"),description:s("dashboard.recent.subtitle",{count:5}),actions:t.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(y,{variant:"secondary",children:t.length}),e.jsxs(y,{variant:"success",children:[s("common.status.success"),": ",o]}),e.jsxs(y,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[s("common.status.error"),": ",n]}),c>0?e.jsxs(y,{variant:"warning",children:[s("common.status.pending"),": ",c]}):null]}):null,children:a?e.jsx($,{compact:!0,label:s("dashboard.recent.loading")}):t.length===0?e.jsx(L,{compact:!0,icon:e.jsx(Ce,{className:"h-5 w-5","aria-hidden":"true"}),title:s("dashboard.recent.empty")}):e.jsx("div",{className:"overflow-auto",children:e.jsxs(ne,{children:[e.jsx(ie,{children:e.jsxs(B,{children:[e.jsx(g,{children:s("dashboard.recent.columns.time")}),e.jsx(g,{children:s("dashboard.recent.columns.endpoint")}),e.jsx(g,{children:s("dashboard.recent.columns.provider")}),e.jsx(g,{children:s("dashboard.recent.columns.route")}),e.jsx(g,{className:"text-right",children:s("dashboard.recent.columns.latency")}),e.jsx(g,{children:s("dashboard.recent.columns.status")})]})}),e.jsx(le,{children:t.map(i=>{const m=Z(i,s);return e.jsxs(B,{children:[e.jsx(j,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium",children:new Date(i.timestamp).toLocaleString()}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["#",i.id]})]})}),e.jsx(j,{children:e.jsx(y,{variant:"outline",className:"text-[11px]",children:i.endpoint==="anthropic"?s("logs.endpointAnthropic"):i.endpoint==="openai"?s("logs.endpointOpenAI"):i.endpoint})}),e.jsx(j,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:i.provider}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:i.stream?"stream":"sync"})]})}),e.jsx(j,{children:e.jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx("span",{children:i.client_model??s("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"->"}),e.jsx("span",{className:"font-medium text-foreground",children:i.model})]}),i.error?e.jsx("span",{className:"truncate text-destructive",children:i.error}):null]})}),e.jsx(j,{className:"text-right font-medium",children:k(i.latency_ms,s("common.units.ms"))}),e.jsx(j,{children:e.jsx(y,{variant:m.variant,className:"min-w-14 justify-center",children:m.label})})]},i.id)})})]})})})}function F({empty:t,option:a,title:s}){const{t:r}=x();return e.jsxs("div",{className:"rounded-lg border border-border p-3",children:[e.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:s}),t?e.jsx(L,{compact:!0,className:"min-h-[160px]",icon:e.jsx(z,{className:"h-4 w-4","aria-hidden":"true"}),title:r("dashboard.charts.empty")}):e.jsx(se,{echarts:de,option:a,className:"h-[220px]",notMerge:!0,lazyUpdate:!0})]})}function ct({description:t,empty:a,emptyText:s,loading:r,option:o,title:n}){const{t:c}=x();return e.jsx(ae,{children:e.jsxs(re,{className:"space-y-4 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:n}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground/70",children:t})]}),r?e.jsx($,{compact:!0,className:"min-h-[220px]",label:c("common.loadingShort")}):a?e.jsx(L,{compact:!0,className:"min-h-[188px] rounded-xl border border-dashed border-border/45 bg-muted",icon:e.jsx(z,{className:"h-5 w-5","aria-hidden":"true"}),title:s??c("dashboard.charts.empty"),description:t}):e.jsx("div",{className:"pt-2",children:e.jsx(se,{echarts:de,option:o,className:"h-[36vh] min-h-[260px] max-h-[400px]",notMerge:!0,lazyUpdate:!0})})]})})}function mt(t){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(t).trim()}function b(t,a){const s=mt(t);return s?`hsl(${s.split(" ").join(" ")})`:a}function ht(){const{resolved:t}=Ae();return p.useMemo(()=>{const a=b("--foreground","#09090B"),s=b("--muted-foreground","#6B7280"),r=b("--border","#E5E7EB"),o=b("--card","#FFFFFF");return{palette:[b("--chart-1","#4338CA"),b("--chart-2","#15803D"),b("--chart-3","#D97706"),b("--chart-4","#DC2626"),b("--chart-5","#7C3AED")],success:b("--success","#15803D"),warning:b("--warning","#D97706"),error:b("--error","#DC2626"),axis:s,splitLine:r,base:{textStyle:{color:s,fontSize:11},grid:{left:8,right:8,top:32,bottom:4,containLabel:!0},tooltip:{backgroundColor:o,borderColor:r,textStyle:{color:a,fontSize:12}},legend:{textStyle:{color:s,fontSize:11}}}}},[t])}const ut=4;function pt(t){var s;if(!t)return 0;let a=Object.keys(t.modelRoutes??{}).length;for(const r of Object.values(t.endpointRouting??{}))a+=Object.keys((r==null?void 0:r.modelRoutes)??{}).length;for(const r of t.customEndpoints??[])a+=Object.keys(((s=r.routing)==null?void 0:s.modelRoutes)??{}).length;return a}function xt(){var G,U,W,Y,J,X;const{t}=x(),{pushToast:a}=Pe(),s=ht(),[r,o]=De(qe.dashboard.endpointFilter,"all"),[n,c]=p.useState(!1),i=r==="all"?void 0:r,m=P(D.dashboard.summary(r),{url:"/api/dashboard/summary",method:"GET",params:i?{endpoint:i}:void 0},{refetchInterval:We}),w=P(D.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:Ye}),E=Qe({level:"warn,error",maxEvents:20});p.useEffect(()=>{m.isError&&m.error&&a({title:t("dashboard.toast.overviewError"),description:m.error.message,variant:"error"})},[m.error,m.isError,a,t]);const ce=p.useCallback(async()=>{await Promise.all([m.refetch(),w.refetch()])},[m,w]),me=p.useCallback(async()=>{if(!n){c(!0);try{await ke.post("/api/db/compact"),await m.refetch(),a({title:t("dashboard.toast.compactSuccess.title"),description:t("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(l){const h=Be(l);a({title:t("dashboard.toast.compactError.title"),description:h.message,variant:"error"})}finally{c(!1)}}},[n,m,a,t]),d=m.data,he=d==null?void 0:d.overview,T=p.useMemo(()=>(d==null?void 0:d.daily)??[],[d]),v=p.useMemo(()=>(d==null?void 0:d.modelStats)??[],[d]),R=d==null?void 0:d.status,ue=d==null?void 0:d.dbInfo,V=(d==null?void 0:d.recentRequests.items)??[],M=((R==null?void 0:R.providers)??0)>0,K=V.length>0,H=P(D.config.full(),Ue.configRequest(),{enabled:M}),q=p.useMemo(()=>pt(H.data),[H.data])>0,Q=(((G=P(D.apiKeys.all(),Ge.listRequest(),{enabled:M&&q}).data)==null?void 0:G.length)??0)>0,pe=M&&q&&Q&&K,xe=[M,q,Q,K].filter(Boolean).length,be=p.useMemo(()=>{const l=(d==null?void 0:d.recentErrors)??[],h=new Set;return[...E.events,...l].filter(u=>h.has(u.id)?!1:(h.add(u.id),!0)).slice(0,10)},[E.events,d]),fe=r==="all"?t("dashboard.filters.endpointAll"):r==="anthropic"?t("dashboard.filters.endpointAnthropic"):r==="openai"?t("dashboard.filters.endpointOpenAI"):((Y=(W=(U=w.data)==null?void 0:U.endpoints)==null?void 0:W.find(l=>l.id===r))==null?void 0:Y.label)||r,ge=v.filter(l=>l.avgTtftMs!=null&&l.avgTtftMs>0).sort((l,h)=>(l.avgTtftMs??Number.POSITIVE_INFINITY)-(h.avgTtftMs??Number.POSITIVE_INFINITY))[0],je=m.isFetching||w.isFetching,ve=m.isPending,ye=((J=m.error)==null?void 0:J.message)??null,Ne=p.useMemo(()=>{const l=t("dashboard.charts.barRequests"),h=t("dashboard.charts.latencyLabel");return{...s.base,color:s.palette,tooltip:{trigger:"axis",...s.base.tooltip},legend:{data:[l,h],...s.base.legend},grid:s.base.grid,xAxis:{type:"category",data:T.map(f=>f.date.slice(5)),axisLabel:{color:s.axis},axisLine:{lineStyle:{color:s.splitLine}}},yAxis:[{type:"value",name:l,nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{lineStyle:{color:s.splitLine}}},{type:"value",name:h,nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{show:!1}}],series:[{name:l,type:"bar",data:T.map(f=>f.requestCount),itemStyle:{color:s.palette[0],borderRadius:[4,4,0,0]},barMaxWidth:24},{name:h,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:T.map(f=>Math.round(f.avgLatencyMs)),itemStyle:{color:s.palette[3]},lineStyle:{width:2}}]}},[T,s,t]),I=p.useCallback((l,h,f)=>({...s.base,tooltip:{trigger:"axis",...s.base.tooltip},grid:{...s.base.grid,bottom:24},xAxis:{type:"category",data:v.map(u=>`${u.provider}/${u.model}`),axisLabel:{color:s.axis,rotate:28},axisLine:{lineStyle:{color:s.splitLine}}},yAxis:{type:"value",name:l,nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{lineStyle:{color:s.splitLine}}},series:[{name:l,type:"bar",data:v.map(h),itemStyle:{color:f,borderRadius:[4,4,0,0]},barMaxWidth:32}]}),[v,s]),Se=p.useMemo(()=>I(t("dashboard.charts.ttftAxis"),l=>l.avgTtftMs??0,s.palette[2]),[I,s,t]),we=p.useMemo(()=>I(t("dashboard.charts.tpotAxis"),l=>l.avgTpotMs??0,s.palette[4]),[I,s,t]),Te=p.useMemo(()=>{const l=t("dashboard.charts.barRequests"),h=t("dashboard.charts.lineInput"),f=t("dashboard.charts.lineOutput");return{...s.base,color:s.palette,tooltip:{trigger:"axis",...s.base.tooltip},legend:{data:[l,h,f],...s.base.legend},grid:{...s.base.grid,bottom:24},xAxis:{type:"category",data:v.map(u=>`${u.provider}/${u.model}`),axisLabel:{color:s.axis,rotate:28},axisLine:{lineStyle:{color:s.splitLine}}},yAxis:[{type:"value",name:l,nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{lineStyle:{color:s.splitLine}}},{type:"value",name:t("dashboard.charts.axisTokens"),position:"right",nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{show:!1}}],series:[{name:l,type:"bar",data:v.map(u=>u.requests),itemStyle:{color:s.palette[0],borderRadius:[4,4,0,0]},barMaxWidth:24},{name:h,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:v.map(u=>u.inputTokens??0),itemStyle:{color:s.palette[1]},lineStyle:{width:2}},{name:f,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:v.map(u=>u.outputTokens??0),itemStyle:{color:s.palette[2]},lineStyle:{width:2}}]}},[v,s,t]);return{attentionEvents:be,compacting:n,customEndpoints:((X=w.data)==null?void 0:X.endpoints)??[],daily:T,dbInfo:ue,endpointFilter:r,fastestTtftModel:ge,handleCompact:me,handleRefresh:ce,bootstrapError:ye,isBootstrapping:ve,isRefreshing:je,liveConnected:E.connected,liveFailed:E.failed,modelRequestsOption:Te,models:v,overview:he,recentLogs:V,selectedEndpointLabel:fe,setEndpointFilter:o,setupComplete:pe,setupDoneCount:xe,status:R,summaryPending:m.isPending,trendOption:Ne,ttftOption:Se,tpotOption:we}}function _t(){var o,n;const{t}=x(),a=xt(),s=a.dbInfo?O(a.dbInfo.totalBytes??a.dbInfo.sizeBytes):"-",r=O((o=a.dbInfo)==null?void 0:o.memoryRssBytes);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Ie,{actions:e.jsxs(e.Fragment,{children:[e.jsxs(Fe,{value:a.endpointFilter,onValueChange:a.setEndpointFilter,children:[e.jsx(Oe,{className:"h-8 w-[168px]",children:e.jsx(ze,{})}),e.jsxs($e,{children:[e.jsx(A,{value:"all",children:t("dashboard.filters.endpointAll")}),e.jsx(A,{value:"anthropic",children:t("dashboard.filters.endpointAnthropic")}),e.jsx(A,{value:"openai",children:t("dashboard.filters.endpointOpenAI")}),a.customEndpoints.map(c=>e.jsx(A,{value:c.id,children:c.label||c.id},c.id))]})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>void a.handleRefresh(),disabled:a.isRefreshing,children:[e.jsx(Re,{className:_e("mr-2 h-4 w-4",a.isRefreshing&&"animate-spin"),"aria-hidden":"true"}),a.isRefreshing?t("common.actions.refreshing"):t("common.actions.refresh")]})]})}),a.isBootstrapping?e.jsx(Xe,{}):a.bootstrapError?e.jsx(L,{icon:e.jsx(Me,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:t("common.status.error"),description:a.bootstrapError,action:e.jsx(S,{variant:"outline",onClick:()=>void a.handleRefresh(),children:t("common.actions.refresh")})}):e.jsxs(e.Fragment,{children:[a.setupComplete?null:e.jsx(it,{endpointCount:a.customEndpoints.length,providerCount:((n=a.status)==null?void 0:n.providers)??0}),e.jsx(Ze,{status:a.status}),a.setupComplete?null:e.jsx(nt,{doneCount:a.setupDoneCount,total:ut}),e.jsx(at,{empty:!a.daily.length,loading:a.summaryPending,option:a.trendOption}),e.jsx(rt,{modelRequestsOption:a.modelRequestsOption,models:a.models,ttftOption:a.ttftOption,tpotOption:a.tpotOption}),e.jsx(ot,{compacting:a.compacting,dbInfo:a.dbInfo,dbSizeDisplay:s,memoryDisplay:r,onCompact:()=>void a.handleCompact(),status:a.status}),e.jsx(dt,{records:a.recentLogs,loading:a.summaryPending}),a.attentionEvents.length>0?e.jsx(tt,{connected:a.liveConnected,failed:a.liveFailed,events:a.attentionEvents}):e.jsx(st,{connected:a.liveConnected,failed:a.liveFailed})]})]})}export{_t as default};
@@ -1 +0,0 @@
1
- import{r,j as s,aq as u}from"./vendor-m8O77Czp.js";import{t as g,u as d,D as n,v as y,w as l,x as b,O as i}from"./radix-OaJStcH-.js";import{c as o}from"./global-zt8jbW7F.js";const k=g,N=y,c=r.forwardRef(({className:a,...e},t)=>s.jsx(i,{ref:t,className:o("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...e}));c.displayName=i.displayName;const p=r.forwardRef(({className:a,children:e,...t},x)=>s.jsxs(N,{children:[s.jsx(c,{}),s.jsxs(l,{ref:x,className:o("fixed left-[50%] top-[50%] z-50 flex max-h-[85vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-xl border border-border bg-background p-6 shadow-[var(--surface-shadow-lg)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",a),...t,children:[e,s.jsxs(b,{className:"absolute right-4 top-4 rounded-md p-1.5 text-muted-foreground opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(u,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));p.displayName=l.displayName;const m=({className:a,...e})=>s.jsx("div",{className:o("flex shrink-0 flex-col space-y-1.5 text-center sm:text-left",a),...e});m.displayName="DialogHeader";const f=({className:a,...e})=>s.jsx("div",{className:o("flex shrink-0 flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...e});f.displayName="DialogFooter";const j=r.forwardRef(({className:a,...e},t)=>s.jsx(d,{ref:t,className:o("text-lg font-semibold leading-none tracking-[-0.02em]",a),...e}));j.displayName=d.displayName;const D=r.forwardRef(({className:a,...e},t)=>s.jsx(n,{ref:t,className:o("text-sm leading-6 text-muted-foreground",a),...e}));D.displayName=n.displayName;function R({children:a,className:e,...t}){return s.jsx(p,{className:o("gap-0 overflow-hidden p-0",e),...t,children:a})}function A({children:a,className:e}){return s.jsx("div",{className:o("border-b border-border bg-secondary/40 px-6 py-5",e),children:s.jsx(m,{children:a})})}function C({children:a,className:e}){return s.jsx("div",{className:o("min-h-0 overflow-y-auto px-6 py-5",e),children:a})}function z({children:a,className:e}){return s.jsx(f,{className:o("border-t border-border bg-secondary/40 px-6 py-4",e),children:a})}export{R as A,k as D,A as a,j as b,D as c,C as d,z as e};
@@ -1 +0,0 @@
1
- import{_ as a}from"./charts-react-B-D6Gq0w.js";import{u as s,i as l,a as t,b as i,c as n,d as o,f as r,g as $}from"./charts-core-CAVUzIcU.js";s([l,t,i,n,o,r,$]);const e=a;export{e as E};
@@ -1 +0,0 @@
1
- import{r as m,j as e,as as D,Z as F,T as R,at as B,am as I,an as q}from"./vendor-m8O77Czp.js";import{L as K}from"./router-C1-ppOz7.js";import{P as O}from"./PageToolbar-DzpjQ7SY.js";import{P as Q}from"./PageSection-D1vbxAKK.js";import{P as G,a as P}from"./PageState-CPKqNFG7.js";import{u as J,B as y,q as U}from"./queryKeys-BlGm18Nk.js";import{u as Z}from"./useEventStream-DeEWwZq0.js";import{c as b}from"./global-zt8jbW7F.js";import{a as _,B as x}from"./app-CeLCVbqy.js";import{C as H,a as W}from"./card-DS9KKz-k.js";import{D as X}from"./disclosure-CqU8C-ET.js";import{M as w}from"./metric-card-CueQ0u3Z.js";import{S as Y}from"./segmented-control-do2mQidJ.js";import{S as ee,a as se,b as te,c as ae,d as k}from"./select-CxIEo3DN.js";import{u as z}from"./i18n-DWfLgqoF.js";import"./query-CZuclkQv.js";import"./radix-OaJStcH-.js";function re(s){const a=Date.now()-s,n=Math.abs(a),i=60*1e3,f=60*i,d=24*f;if(n<i){const o=Math.max(Math.round(n/1e3),1);return a>=0?`${o}s ago`:`in ${o}s`}if(n<f){const o=Math.round(n/i);return a>=0?`${o}m ago`:`in ${o}m`}if(n<d){const o=Math.round(n/f);return a>=0?`${o}h ago`:`in ${o}h`}const h=Math.round(n/d);return a>=0?`${h}d ago`:`in ${h}d`}function ne(s){return new Date(s).toLocaleString()}const le={info:"secondary",warn:"outline",error:"destructive"};function Se(){var M,L,A;const{t:s}=z(),{pushToast:r}=_(),[a,n]=m.useState(null),[i,f]=m.useState(""),[d,h]=m.useState(""),o=m.useMemo(()=>({limit:50,cursor:a??void 0,level:i||void 0,type:d||void 0}),[a,i,d]),l=J(U.events.list(o),{url:"/api/events",method:"GET",params:o}),c=Z({level:i||void 0,type:d||void 0,maxEvents:50,enabled:a===null});m.useEffect(()=>{l.isError&&l.error&&r({title:s("events.toast.loadFailure",{message:l.error.message}),variant:"error"})},[l.error,l.isError,r,s]);const N=()=>{n(null),f(""),h("")},v=((M=l.data)==null?void 0:M.events)??[],C=((L=l.data)==null?void 0:L.nextCursor)??null,$=l.isLoading,u=m.useMemo(()=>{if(a!==null)return v;const t=new Set;return[...c.events,...v].filter(p=>t.has(p.id)?!1:(t.add(p.id),!0)).slice(0,50)},[a,c.events,v]),V=m.useMemo(()=>{const t=new Set;return v.forEach(p=>t.add(p.type)),c.events.forEach(p=>t.add(p.type)),Array.from(t).sort()},[v,c.events]),g=m.useMemo(()=>{const t=[];return i&&t.push(s(`events.levels.${i}`)),d&&t.push(d),t},[i,d,s]),S=u.filter(t=>t.level==="info").length,E=u.filter(t=>t.level==="warn").length,T=u.filter(t=>t.level==="error").length;return e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(O,{info:u.length>0?e.jsxs("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:[u.length," events"]}):null,status:a===null?e.jsxs("span",{className:b("inline-flex items-center gap-1.5 text-xs font-medium",c.connected?"text-success":c.failed?"text-destructive":"text-warning"),children:[e.jsx("span",{className:b("h-1.5 w-1.5 rounded-full",c.connected?"bg-success":c.failed?"bg-destructive":"bg-warning")}),c.connected?s("events.live"):c.failed?s("events.failed"):s("events.reconnecting")]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:s("events.actions.older")}),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[!c.connected&&a===null?e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),children:s("common.actions.refresh")}):null,e.jsxs(x,{variant:"outline",size:"sm",disabled:!a,onClick:()=>n(null),children:[e.jsx(D,{className:"mr-1 h-4 w-4","aria-hidden":"true"}),s("events.actions.newest")]}),e.jsxs(x,{variant:"outline",size:"sm",disabled:!C,onClick:()=>n(C),children:[s("events.actions.older"),e.jsx(F,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]})]})}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsx(w,{size:"sm",label:s("events.levels.info"),value:S.toLocaleString(),rawValue:S}),e.jsx(w,{size:"sm",label:s("events.levels.warn"),value:E.toLocaleString(),rawValue:E}),e.jsx(w,{size:"sm",label:s("events.levels.error"),value:T.toLocaleString(),rawValue:T})]}),e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:flex-wrap md:items-center","data-testid":"events-filters-card",children:[e.jsx(Y,{value:i,onChange:t=>{n(null),f(t)},options:[{value:"",label:s("events.filters.allLevels")},{value:"info",label:s("events.levels.info")},{value:"warn",label:s("events.levels.warn")},{value:"error",label:s("events.levels.error")}],"aria-label":s("events.filters.title")}),e.jsxs(ee,{value:d||"all",onValueChange:t=>{n(null),h(t==="all"?"":t)},children:[e.jsx(se,{className:"h-8 w-full md:w-[200px]",children:e.jsx(te,{})}),e.jsxs(ae,{children:[e.jsx(k,{value:"all",children:s("events.filters.allTypes")}),V.map(t=>e.jsx(k,{value:t,children:t},t))]})]}),g.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:g.map(t=>e.jsx(y,{variant:"secondary",children:t},t))}),e.jsx(x,{variant:"ghost",size:"sm",onClick:N,className:"h-8 px-3 text-xs",children:s("common.actions.reset")})]}):null]}),e.jsx(Q,{title:s("events.title"),description:s(a?"events.actions.older":"events.actions.newest"),children:$?e.jsx(G,{label:s("common.loading")}):l.isError?e.jsx(P,{icon:e.jsx(R,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:s("events.toast.loadFailure",{message:((A=l.error)==null?void 0:A.message)??s("common.unknownError")}),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),children:s("common.actions.refresh")})}):u.length===0?e.jsx(P,{icon:e.jsx(B,{className:"h-5 w-5","aria-hidden":"true"}),tone:"primary",title:g.length>0?s("events.empty.filteredTitle"):s("events.empty.title"),description:g.length>0?s("events.empty.filteredSubtitle"):s("events.empty.subtitle"),action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[g.length>0?e.jsx(x,{variant:"outline",size:"sm",onClick:N,children:s("common.actions.reset")}):null,e.jsx(x,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(K,{to:"/logs",children:s("events.empty.actions.logs")})})]})}):e.jsx("div",{className:"grid gap-3",children:e.jsx(I,{initial:!1,children:u.map(t=>e.jsx(q.div,{layout:!0,initial:{opacity:0,y:-12},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:.18},children:e.jsx(ie,{event:t})},t.id))})})})]})}function ie({event:s}){const{t:r}=z(),a=s.level==="error"?"border-l-error":s.level==="warn"?"border-l-warning":"border-l-success";return e.jsx(H,{className:b("overflow-hidden border-l-2 hover:bg-muted/30",a),children:e.jsxs(W,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(y,{variant:le[s.level]||"secondary",className:"rounded-full text-[10px]",children:r(`events.levels.${s.level}`)}),e.jsxs(y,{variant:"outline",className:"rounded-full text-[10px]",children:["#",s.id]}),s.mode?e.jsx(y,{variant:"secondary",className:"rounded-full text-[10px]",children:s.mode}):null,s.endpoint?e.jsx(y,{variant:"outline",className:"rounded-full text-[10px]",children:s.endpoint}):null]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-[-0.01em]",children:s.title||r("events.defaultTitle")}),e.jsx("p",{className:"mt-1 line-clamp-2 text-sm leading-5 text-muted-foreground",children:s.message||r("events.defaultMessage")})]})]}),e.jsxs("div",{className:"shrink-0 space-y-0.5 text-xs text-muted-foreground lg:text-right",children:[e.jsx("p",{children:ne(s.createdAt)}),e.jsx("p",{children:re(s.createdAt)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm",children:[e.jsx(j,{label:"Type",value:s.type}),e.jsx(j,{label:"Source",value:s.source}),e.jsx(j,{label:"IP",value:s.ipAddress}),e.jsx(j,{label:"API Key",value:s.apiKeyName}),e.jsx(j,{label:"User Agent",value:s.userAgent})]}),s.details?e.jsx(X,{summary:r("events.details"),className:"rounded-lg bg-secondary px-3 py-2 text-sm",summaryClassName:"px-0 py-0 text-xs font-medium text-primary hover:text-primary",contentClassName:"mt-2.5",children:e.jsx("pre",{className:"overflow-x-auto rounded-lg bg-secondary p-3 text-xs leading-6",children:JSON.stringify(s.details,null,2)})}):null]})})}function j({label:s,value:r}){return r?e.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border/60 bg-secondary/55 px-2.5 py-1 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"font-medium",children:[s,":"]}),e.jsx("span",{className:"truncate text-foreground",title:r,children:r})]}):null}export{Se as default};
@@ -1 +0,0 @@
1
- import{r as n,j as e,aK as S,aL as E}from"./vendor-m8O77Czp.js";import{i as L,L as k,B as F}from"./app-CeLCVbqy.js";import{C as j,a as N,b as P,d as T,e as A,f as B}from"./card-DS9KKz-k.js";import{L as b,I as y}from"./label-CWq3wWgE.js";import{u as D}from"./i18n-DWfLgqoF.js";import{d as G,u as I}from"./router-C1-ppOz7.js";import"./global-zt8jbW7F.js";import"./query-CZuclkQv.js";import"./radix-OaJStcH-.js";function O(){const{t:s}=D(),a=G(),l=I(),{authEnabled:o,isAuthenticated:u,loading:d,login:v,error:x}=L(),[i,p]=n.useState({username:"",password:""}),[h,m]=n.useState(null),[f,g]=n.useState(!1),c=n.useMemo(()=>{var r;const t=l.state;return((r=t==null?void 0:t.from)==null?void 0:r.pathname)??"/"},[l.state]);n.useEffect(()=>{if(!o&&!d){a(c,{replace:!0});return}o&&u&&!d&&a(c,{replace:!0})},[o,c,u,d,a]);const C=async t=>{if(t.preventDefault(),m(null),!i.username.trim()||!i.password){m(s("login.validation.required"));return}g(!0);try{await v(i.username.trim(),i.password),a(c,{replace:!0})}catch(r){m(r instanceof Error?r.message:s("login.validation.failed"))}finally{g(!1)}};return d?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsx(j,{className:"w-full max-w-md",children:e.jsx(N,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(k,{})})})}):o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4 py-10",children:e.jsxs("div",{className:"mx-auto grid w-full max-w-5xl items-center gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(400px,0.8fr)]",children:[e.jsx("div",{className:"hidden lg:block",children:e.jsxs("div",{className:"max-w-lg space-y-6",children:[e.jsx("div",{className:"inline-flex items-center gap-1.5 rounded-full bg-primary/10 px-3 py-1 text-xs font-semibold text-primary",children:"Secure Gateway Control"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-foreground",children:s("login.title")}),e.jsx("p",{className:"max-w-md text-base leading-7 text-muted-foreground",children:s("login.description")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(w,{icon:e.jsx(S,{className:"h-5 w-5","aria-hidden":"true"}),title:s("login.hint"),description:s("about.support.tip")}),e.jsx(w,{icon:e.jsx(E,{className:"h-5 w-5","aria-hidden":"true"}),title:"Session protected",description:s("help.note")})]})]})}),e.jsxs(j,{className:"w-full",children:[e.jsxs(P,{className:"pb-4 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground",children:"GW"}),e.jsx(T,{className:"text-xl",children:s("login.title")}),e.jsx(A,{children:s("login.description")})]}),e.jsx(N,{children:e.jsxs("form",{className:"space-y-4",onSubmit:C,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(y,{id:"username",value:i.username,autoComplete:"username",autoFocus:!0,onChange:t=>p(r=>({...r,username:t.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(y,{id:"password",type:"password",value:i.password,autoComplete:"current-password",onChange:t=>p(r=>({...r,password:t.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),h||x?e.jsx("div",{className:"rounded-lg bg-destructive/10 px-4 py-3 text-sm text-destructive",children:h||x}):null,e.jsx(F,{type:"submit",className:"w-full",disabled:f,children:s(f?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(B,{className:"justify-center pt-2",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})]})}):null}function w({description:s,icon:a,title:l}){return e.jsxs("div",{className:"rounded-lg bg-card px-4 py-4 shadow-[var(--surface-shadow)]",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:a}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-foreground",children:l}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s})]})}export{O as default};
@@ -1 +0,0 @@
1
- import{r as p,j as e,o as Ze,ap as et,ah as tt,aq as st,ai as lt,ar as De,ao as at,T as rt,P as ot}from"./vendor-m8O77Czp.js";import{P as nt}from"./PageToolbar-DzpjQ7SY.js";import{c as D}from"./global-zt8jbW7F.js";import{B as _,c as it,a as ge,s as P,t as dt,b as O}from"./app-CeLCVbqy.js";import{B as I,u as W,q as U}from"./queryKeys-BlGm18Nk.js";import{C as _e,a as Fe}from"./card-DS9KKz-k.js";import{L as H,I as pe}from"./label-CWq3wWgE.js";import{S as te,a as se,b as le,c as ae,d as z}from"./select-CxIEo3DN.js";import{u as q}from"./i18n-DWfLgqoF.js";import{D as ct,A as mt,a as ut,b as pt,c as xt,d as gt}from"./DialogShell-TRFN3c58.js";import{P as ft,a as oe}from"./PageState-CPKqNFG7.js";import{T as ht,a as yt,b as bt,c as jt}from"./tabs-BOjStrRw.js";import{c as vt}from"./clipboard-BnAnBk_-.js";import{a as wt,g as fe,b as Nt,f as Q,c as he,d as kt,e as A,h as Re,T as St,i as Ct}from"./utils-DrKJJFzS.js";import{P as Et,a as Lt,b as Dt}from"./popover-0fHMO-3Y.js";import{S as _t}from"./segmented-control-do2mQidJ.js";import{L as Ft}from"./router-C1-ppOz7.js";import{u as Rt}from"./query-CZuclkQv.js";import{g as Ee}from"./gateway-Bt6lPuXq.js";import"./radix-OaJStcH-.js";function Tt({apiKeys:t,selected:l,onChange:m,disabled:r,className:d}){const{t:s}=q(),a=p.useId(),[n,N]=p.useState(!1),[u,w]=p.useState(null),c=p.useRef(null),y=p.useRef(null),x=p.useRef(null),f=()=>{const h=y.current;if(!h)return;const b=h.getBoundingClientRect(),k=Math.max(b.width,256),j=window.innerWidth-12;w({left:Math.min(b.left,j-k),top:b.bottom+8,width:k})};p.useEffect(()=>{if(!n)return;const h=k=>{var R,E;const j=k.target;!((R=c.current)!=null&&R.contains(j))&&!((E=x.current)!=null&&E.contains(j))&&N(!1)},b=k=>{var j;k.key==="Escape"&&(N(!1),(j=y.current)==null||j.focus())};return window.addEventListener("mousedown",h),window.addEventListener("keydown",b),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",b)}},[n]),p.useEffect(()=>{if(n)return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[n]);const o=p.useMemo(()=>{if(l.length===0)return[];const h=new Map;for(const b of t)h.set(b.id,b);return l.map(b=>{const k=h.get(b);return k?k.isWildcard?s("apiKeys.wildcard"):k.name:null}).filter(b=>!!b)},[t,l,s]),g=l.length===0?s("logs.filters.apiKeyAll"):s("logs.filters.apiKeySelected",{count:l.length}),L=h=>{l.includes(h)?m(l.filter(b=>b!==h)):m([...l,h])};return e.jsxs("div",{className:D("relative space-y-2",d),ref:c,children:[e.jsx(H,{htmlFor:a,children:s("logs.filters.apiKey")}),e.jsxs("button",{ref:y,id:a,type:"button",onClick:()=>{f(),N(h=>!h)},disabled:r||t.length===0,title:s("logs.filters.apiKeyHint"),className:D("flex h-10 w-full items-center justify-between rounded-lg border border-input bg-background px-3 text-sm ring-offset-background transition-all focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",l.length>0&&"border-primary",n&&"ring-2 ring-ring ring-offset-2"),children:[e.jsxs("span",{className:"truncate",children:[g,o.length>0&&e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:o.join(", ")})]}),e.jsx("svg",{className:D("h-4 w-4 opacity-50 transition-transform",n&&"rotate-180"),viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 10.94l3.71-3.71a.75.75 0 111.06 1.06l-4.24 4.25a.75.75 0 01-1.06 0L5.21 8.29a.75.75 0 01.02-1.08z",clipRule:"evenodd"})})]}),n&&u&&Ze.createPortal(e.jsxs("div",{ref:x,className:"fixed z-50 rounded-lg border bg-popover p-2 shadow-[var(--surface-shadow-lg)]",style:u,children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-secondary px-3 py-2 text-xs",children:[e.jsx("span",{children:g}),e.jsx("button",{type:"button",onClick:()=>m([]),disabled:l.length===0,className:"text-primary hover:underline disabled:opacity-40",children:s("common.actions.reset")})]}),e.jsxs("div",{className:"max-h-56 overflow-y-auto py-2",children:[t.map(h=>{const b=h.isWildcard?s("apiKeys.wildcard"):h.name,k=l.includes(h.id);return e.jsxs("label",{className:D("flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2 text-sm transition hover:bg-primary/5",k&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-border",checked:k,onChange:()=>L(h.id)}),e.jsx("span",{className:"truncate",children:b})]},h.id)}),t.length===0&&e.jsx("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:s("logs.filters.apiKeyAll")})]})]}),document.body)]})}function Kt(t){const{t:l}=q(),{activeFilters:m,filtersExpanded:r,setFiltersExpanded:d,handleResetFilters:s,activeQuickView:a,applyQuickView:n,providerFilter:N,setProviderFilter:u,endpointFilter:w,setEndpointFilter:c,selectedApiKeys:y,setSelectedApiKeys:x,modelFilter:f,setModelFilter:o,statusFilter:g,setStatusFilter:L,fromDate:h,setFromDate:b,toDate:k,setToDate:j,providerOptions:R,apiKeys:E,apiKeysLoading:C,customEndpoints:F}=t;return e.jsx(_e,{"data-testid":"logs-filters-card",className:"overflow-hidden",children:e.jsxs(Fe,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:l("logs.filtersTitle")}),m.length>0&&e.jsx(I,{variant:"outline",className:"rounded-full border-transparent bg-primary/10 px-2.5 py-0.5 text-[11px] font-semibold text-primary",children:l("common.filters.activeCount",{count:m.length})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("logs.filtersDescription")})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[m.length>0&&e.jsx(_,{variant:"ghost",size:"sm",onClick:s,className:"h-8 rounded-full px-3 text-xs",children:l("common.actions.reset")}),e.jsx(_,{variant:"ghost",size:"sm",onClick:()=>d(v=>!v),className:"h-8 rounded-full px-3 text-xs",children:r?e.jsxs(e.Fragment,{children:[l("common.filters.collapse"),e.jsx(et,{className:"ml-1 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:[l("common.filters.expand"),e.jsx(tt,{className:"ml-1 h-4 w-4"})]})})]})]}),e.jsxs("div",{className:"grid gap-2 lg:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx("div",{className:"flex min-h-10 items-center rounded-lg bg-secondary px-3 py-2",children:m.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:m.map(v=>e.jsxs(I,{variant:"outline",role:"button",tabIndex:0,className:"flex cursor-pointer items-center gap-1 rounded-full border border-border bg-card px-2.5 py-1 text-[11px] font-semibold text-foreground/90 transition hover:bg-secondary",onClick:v.onRemove,onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&(X.preventDefault(),v.onRemove())},children:[v.label,e.jsx(st,{className:"h-3 w-3","aria-hidden":"true"})]},v.key))}):e.jsx("span",{className:"text-xs text-muted-foreground",children:l("common.filters.allRequests")})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 lg:justify-end",children:[e.jsx(xe,{label:l("logs.filters.apiKey"),value:y.length.toString()}),e.jsx(xe,{label:l("logs.filters.provider"),value:N==="all"?"0":"1"}),e.jsx(xe,{label:l("logs.filters.endpoint"),value:w==="all"?"0":"1"})]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 rounded-lg bg-secondary px-2 py-1.5",children:["all","errors","today","anthropic","openai"].map(v=>e.jsx(_,{variant:"ghost",size:"sm",className:D("h-7 rounded-full px-3 text-[11px] font-semibold transition-colors",a===v?"bg-card text-foreground shadow-[var(--surface-shadow)]":"text-muted-foreground"),onClick:()=>n(v),children:l(`logs.quickViews.${v}`)},v))})]}),r&&e.jsxs("div",{className:"mt-3 grid gap-3 rounded-xl bg-secondary p-3 md:grid-cols-2 xl:grid-cols-4 animate-in fade-in slide-in-from-top-2 duration-200",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:l("logs.filters.provider")}),e.jsxs(te,{value:N,onValueChange:u,children:[e.jsx(se,{children:e.jsx(le,{})}),e.jsxs(ae,{children:[e.jsx(z,{value:"all",children:l("logs.filters.providerAll")}),R.map(v=>e.jsx(z,{value:v.id,children:v.label??v.id},v.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:l("logs.filters.endpoint")}),e.jsxs(te,{value:w,onValueChange:c,children:[e.jsx(se,{children:e.jsx(le,{})}),e.jsxs(ae,{children:[e.jsx(z,{value:"all",children:l("logs.filters.endpointAll")}),e.jsx(z,{value:"anthropic",children:l("logs.filters.endpointAnthropic")}),e.jsx(z,{value:"openai",children:l("logs.filters.endpointOpenAI")}),F==null?void 0:F.map(v=>e.jsx(z,{value:v.id,children:v.label||v.id},v.id))]})]})]}),e.jsx(Tt,{className:"md:col-span-2",apiKeys:E,selected:y,disabled:C,onChange:x}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:l("logs.filters.modelId")}),e.jsx(pe,{value:f,onChange:v=>o(v.target.value),placeholder:l("logs.filters.modelPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:l("logs.filters.status")}),e.jsxs(te,{value:g,onValueChange:v=>L(v),children:[e.jsx(se,{children:e.jsx(le,{})}),e.jsxs(ae,{children:[e.jsx(z,{value:"all",children:l("logs.filters.statusAll")}),e.jsx(z,{value:"success",children:l("logs.filters.statusSuccess")}),e.jsx(z,{value:"error",children:l("logs.filters.statusError")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:l("logs.filters.startDate")}),e.jsx(pe,{type:"date",value:h,onChange:v=>b(v.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:l("logs.filters.endDate")}),e.jsx(pe,{type:"date",value:k,onChange:v=>j(v.target.value)})]})]})]})})}function xe({label:t,value:l}){return e.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-border/60 bg-card px-2.5 py-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:t}),e.jsx("span",{className:"metric-number font-semibold text-foreground",children:l})]})}const ye={listRequest(t){return{url:"/api/logs",method:"GET",params:t}},detailRequest(t){return{url:t===null?"":`/api/logs/${t}`,method:"GET"}},async exportArchive(t,l){const m=await it.post("/api/logs/export",t,{responseType:"blob",timeout:l});return new Blob([m.data],{type:"application/zip"})}};function Mt({apiKeyMap:t,logId:l,open:m,providerLabelMap:r}){var f;const{t:d}=q(),{pushToast:s}=ge(),a=W(U.logs.detail(l),ye.detailRequest(l),{enabled:m&&l!==null,staleTime:3e4,gcTime:15e3,placeholderData:void 0});p.useEffect(()=>{!a.isError||!a.error||s({title:d("logs.detail.loadError"),description:a.error.message,variant:"error"})},[a.error,a.isError,s,d]);const n=p.useCallback(async(o,g,L)=>{if(!g){s({title:d("logs.detail.copy.empty",{label:o}),variant:"info"});return}try{await vt(g),s({title:d(L),variant:"success"})}catch(h){s({title:d("logs.detail.copy.failure"),description:h instanceof Error?h.message:d("logs.detail.copy.failureFallback"),variant:"error"})}},[s,d]),N=p.useCallback((o,g)=>{if(!g){s({title:d("logs.detail.copy.empty",{label:o}),variant:"info"});return}const L=new Blob([g],{type:"application/json;charset=utf-8"}),h=URL.createObjectURL(L),b=document.createElement("a"),k=new Date().toISOString().replace(/[:.]/g,"-"),j=o.trim().toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]+/gi,"-").replace(/^-+|-+$/g,"")||"payload";b.href=h,b.download=`cc-gw-log-${l??"payload"}-${j}-${k}.json`,document.body.appendChild(b),b.click(),document.body.removeChild(b),URL.revokeObjectURL(h)},[l,s,d]),u=a.data,w=u?r.get(u.provider)??u.provider:"",c=u&&u.api_key_id!=null?t.get(u.api_key_id):void 0,y=u?wt(u,d):null,x=u?fe(u,d):null;return{apiKeyMeta:c,errorSourceMeta:y,errorMessage:a.isError?((f=a.error)==null?void 0:f.message)??null:null,handleCopy:n,handleDownloadPayload:N,isError:a.isError,isPending:a.isPending,providerLabel:w,refetch:a.refetch,record:u,statusMeta:x}}function Pt({open:t,logId:l,onClose:m,providerLabelMap:r,apiKeyMap:d}){var h,b,k;const{t:s}=q(),{apiKeyMeta:a,errorSourceMeta:n,errorMessage:N,handleCopy:u,handleDownloadPayload:w,isError:c,isPending:y,providerLabel:x,refetch:f,record:o,statusMeta:g}=Mt({apiKeyMap:d,logId:l,open:t,providerLabelMap:r}),L=p.useMemo(()=>{var R,E,C,F;return o?[{key:"client-request",title:s("logs.detail.payload.clientRequest"),value:((R=o.payload)==null?void 0:R.client_request)??null,emptyLabel:s("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"},...(E=o.payload)!=null&&E.upstream_request?[{key:"upstream-request",title:s("logs.detail.payload.upstreamRequest"),value:o.payload.upstream_request,emptyLabel:s("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"}]:[],...(C=o.payload)!=null&&C.upstream_response?[{key:"upstream-response",title:s("logs.detail.payload.upstreamResponse"),value:o.payload.upstream_response,emptyLabel:s("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}]:[],{key:"client-response",title:s("logs.detail.payload.clientResponse"),value:((F=o.payload)==null?void 0:F.client_response)??null,emptyLabel:s("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}].map(v=>({...v,display:Nt(v.value,v.emptyLabel)})):[]},[o,s]);return e.jsx(ct,{open:t,onOpenChange:j=>{j||m()},children:e.jsxs(mt,{className:"w-[min(96vw,1200px)] max-w-[1200px]",children:[e.jsxs(ut,{className:"pr-14",children:[e.jsx(pt,{children:s("logs.detail.title")}),e.jsx(xt,{children:o?s("logs.detail.id",{id:o.id}):s("logs.detail.loadError")})]}),e.jsx(gt,{className:"max-h-[78vh]",children:y?e.jsx(ft,{compact:!0,className:"min-h-[240px]",label:s("common.loading")}):c?e.jsx(oe,{compact:!0,className:"min-h-[240px]",tone:"danger",title:s("logs.detail.loadError"),description:N??s("common.unknownError"),action:e.jsx(_,{variant:"outline",onClick:()=>void f(),children:s("common.actions.refresh")})}):o?e.jsxs("div",{className:"space-y-6 text-sm",children:[e.jsxs("section",{className:"space-y-4 rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("logs.detail.infoSection")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border bg-secondary p-3 text-xs",children:[e.jsx("span",{className:"font-medium",children:s("logs.detail.summary.route",{from:o.client_model??s("logs.detail.info.noRequestedModel"),to:o.model})}),e.jsx("span",{className:"text-muted-foreground",children:s("logs.detail.summary.latency",{value:Q(o.latency_ms,s("common.units.ms"))})}),o.ttft_ms!==null?e.jsxs("span",{className:"text-muted-foreground",children:["TTFT: ",Q(o.ttft_ms,s("common.units.ms"))]}):null]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(I,{variant:g==null?void 0:g.variant,children:(g==null?void 0:g.label)??"-"}),e.jsx(I,{variant:"outline",children:o.stream?s("logs.stream.streaming"):s("logs.stream.single")})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-5",children:[e.jsx($,{label:s("logs.detail.info.latency"),value:Q(o.latency_ms,s("common.units.ms"))}),e.jsx($,{label:s("logs.detail.info.ttft"),value:Q(o.ttft_ms,s("common.units.ms"))}),e.jsx($,{label:s("logs.detail.info.tpot"),value:Q(o.tpot_ms,s("common.units.msPerToken"))}),e.jsx($,{label:s("logs.detail.info.status"),value:(g==null?void 0:g.label)??"-"}),e.jsx($,{label:s("logs.detail.info.errorSource"),value:(n==null?void 0:n.label)??"-"})]}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsx(K,{label:s("logs.detail.info.time"),value:he(o.timestamp)}),e.jsx(K,{label:s("logs.detail.info.sessionId"),value:o.session_id??"-"}),e.jsx(K,{label:s("logs.detail.info.endpoint"),value:o.endpoint||"-"}),e.jsx(K,{label:s("logs.detail.info.provider"),value:x}),e.jsx(K,{label:s("logs.detail.info.requestedModel"),value:o.client_model??s("logs.detail.info.noRequestedModel")}),e.jsx(K,{label:s("logs.detail.info.model"),value:o.model}),e.jsx(K,{label:s("logs.detail.info.stream"),value:kt(o.stream)}),e.jsx(K,{label:s("logs.detail.info.status"),value:(g==null?void 0:g.label)??"-"}),e.jsx(K,{label:s("logs.detail.info.errorSource"),value:(n==null?void 0:n.label)??"-"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx($,{label:s("logs.detail.info.inputTokens"),value:A(o.input_tokens)}),e.jsx($,{label:s("logs.detail.info.cacheReadTokens"),value:A(o.cache_read_tokens)}),e.jsx($,{label:s("logs.detail.info.cacheCreationTokens"),value:A(o.cache_creation_tokens)}),e.jsx($,{label:s("logs.detail.info.outputTokens"),value:A(o.output_tokens)})]}),o.error?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("logs.detail.info.error")}),e.jsx("p",{className:"rounded-xl border border-destructive/50 bg-destructive/10 p-3 text-xs text-destructive",children:o.error})]}):null]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs("section",{className:"space-y-3 rounded-lg border bg-card p-4",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("logs.detail.apiKey.title")}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 sm:grid-cols-2",children:[e.jsx(K,{label:s("logs.detail.apiKey.name"),value:o.api_key_id==null&&!o.api_key_name?s("logs.detail.apiKey.missing"):a!=null&&a.isWildcard?s("apiKeys.wildcard"):(a==null?void 0:a.name)??o.api_key_name??s("logs.detail.apiKey.missing")}),e.jsx(K,{label:s("logs.detail.apiKey.identifier"),value:o.api_key_id??s("common.noData")}),e.jsx(K,{label:s("logs.detail.apiKey.masked"),value:a!=null&&a.isWildcard?s("apiKeys.wildcard"):(a==null?void 0:a.maskedKey)??o.api_key_name??s("logs.detail.apiKey.maskedUnavailable")}),e.jsx(K,{label:s("logs.detail.apiKey.lastUsed"),value:a!=null&&a.lastUsedAt?new Date(a.lastUsedAt).toLocaleString():s("common.noData")})]}),e.jsxs("div",{className:"rounded-lg border bg-secondary p-3 text-xs",children:[e.jsx("p",{className:"font-medium",children:s("logs.detail.apiKey.rawMasked")}),e.jsx("p",{className:"mt-1 break-all font-mono",children:o.api_key_value_available?o.api_key_value_masked??s("logs.detail.apiKey.rawUnavailable"):s("logs.detail.apiKey.rawUnavailable")}),e.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:s("logs.detail.apiKey.rawMaskedHint")})]})]}),e.jsxs("section",{className:"space-y-4 rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("logs.detail.payload.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(h=o.payload)!=null&&h.upstream_request||(b=o.payload)!=null&&b.upstream_response?s("logs.detail.payload.helperWithUpstream"):s("logs.detail.payload.helperClientOnly")})]}),e.jsxs(ht,{defaultValue:(k=L[0])==null?void 0:k.key,children:[e.jsx(yt,{className:"w-full justify-start overflow-x-auto",children:L.map(j=>e.jsx(bt,{value:j.key,children:j.title},j.key))}),L.map(j=>e.jsx(jt,{value:j.key,children:e.jsx(zt,{title:j.title,display:j.display,onCopy:()=>u(j.title,j.value,j.copyToast),onDownload:()=>w(j.title,j.value),panelKey:j.key,t:s})},j.key))]})]})]})]}):e.jsx(oe,{compact:!0,className:"min-h-[240px]",title:s("logs.detail.loadError"),description:s("common.noData")})})]})})}function $({label:t,value:l}){return e.jsxs("div",{className:"min-w-0 rounded-lg border bg-secondary px-3 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:t}),e.jsx("p",{className:"mt-2 break-all text-sm font-semibold leading-6",children:l})]})}function K({label:t,value:l}){return e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t}),e.jsx("dd",{className:"min-w-0 break-all whitespace-pre-wrap text-sm font-medium leading-6 text-foreground",children:l??"-"})]})}function zt({display:t,onCopy:l,onDownload:m,panelKey:r,title:d,t:s}){return e.jsxs("div",{className:"space-y-3 rounded-lg border bg-secondary/40 p-4","data-testid":`log-payload-${r}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_,{variant:"outline",size:"sm",onClick:l,children:[e.jsx(lt,{className:"mr-2 h-3.5 w-3.5"}),s("common.actions.copy")]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:m,children:[e.jsx(De,{className:"mr-2 h-3.5 w-3.5"}),s("common.actions.download")]})]})]}),t.isTruncated?e.jsx("p",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-200",children:s("logs.detail.payload.truncated",{shown:t.displayedLength.toLocaleString(),total:t.originalLength.toLocaleString()})}):null,e.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre rounded-lg border bg-secondary p-3 text-xs",children:t.text})]})}const J=[20,50,100],G=["endpoint","provider","requestedModel","routedModel","apiKey","tokens","duration","status","error"],re=["endpoint","provider","requestedModel","routedModel","apiKey","tokens","duration","status","error"];function Ot(){return typeof window>"u"?"comfortable":window.localStorage.getItem(P.logs.density)==="compact"?"compact":"comfortable"}function At(){if(typeof window>"u")return J[0];const t=window.localStorage.getItem(P.logs.pageSize),l=Number(t);return J.includes(l)?l:J[0]}function Le(t,l=!1){if(!t)return;const m=l?`${t}T23:59:59.999`:`${t}T00:00:00.000`,r=Date.parse(m);return Number.isFinite(r)?r:void 0}function qt(t,l,m){return t===m&&l===m}function $t({columnOptions:t,exporting:l,onExport:m,onRefresh:r,onResetColumns:d,onSetDensity:s,onToggleColumn:a,refreshing:n,rowDensity:N,visibleColumns:u,visibleColumnSet:w}){const{t:c}=q(),y=JSON.stringify(u)===JSON.stringify(G);return e.jsxs("div",{className:"flex w-full flex-col gap-3 xl:w-auto xl:flex-row xl:items-center",children:[e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center xl:w-auto xl:flex-nowrap",children:[e.jsx(_t,{block:!0,className:"w-full overflow-x-auto sm:w-auto",value:N,onChange:s,options:[{value:"comfortable",label:c("logs.table.density.comfortable")},{value:"compact",label:c("logs.table.density.compact")}]}),e.jsxs(Et,{children:[e.jsx(Lt,{asChild:!0,children:e.jsx(_,{variant:"outline",size:"sm",className:"w-full sm:w-auto",children:c("logs.actions.columns")})}),e.jsxs(Dt,{align:"end",className:"w-64 p-3",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:c("logs.actions.columns")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c("logs.actions.visibleCount",{count:u.length})})]}),e.jsx(_,{variant:"ghost",size:"sm",onClick:d,disabled:y,children:c("common.actions.reset")})]}),e.jsx("div",{className:"grid gap-1.5",children:t.map(x=>{const f=w.has(x.id);return e.jsxs("label",{className:D("flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2 text-sm transition hover:bg-accent",f&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",checked:f,onChange:()=>a(x.id),className:"h-4 w-4 rounded border-border"}),e.jsx("span",{children:x.label})]},x.id)})})]})]}),e.jsxs(_,{onClick:m,disabled:l,className:"w-full sm:w-auto",children:[e.jsx(De,{className:"mr-2 h-4 w-4"}),c(l?"logs.actions.exporting":"logs.actions.export")]})]}),e.jsx("div",{className:"flex w-full items-center xl:w-auto",children:e.jsxs(_,{variant:"outline",size:"sm",onClick:r,disabled:n,className:"shrink-0",children:[e.jsx(at,{className:D("mr-2 h-4 w-4",n&&"animate-spin")}),c(n?"common.actions.refreshing":"logs.actions.manualRefresh")]})})]})}function Qt({record:t,providerLabelMap:l,onSelect:m}){const{t:r}=q(),d=fe(t,r),s=l.get(t.provider)??t.provider,a=Re(t.session_id),n=a==null?void 0:a.accentStyle;return e.jsxs("button",{type:"button","data-session-id":a==null?void 0:a.sessionId,"data-session-color":a==null?void 0:a.colorKey,style:n,onClick:()=>m(t.id),className:"w-full space-y-2 border-b border-border/50 px-4 py-3 text-left transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:he(t.timestamp)}),e.jsx(I,{variant:d.variant,className:"text-xs",children:d.label})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[e.jsx("span",{className:"min-w-0 truncate font-medium",title:s,children:s}),e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",title:t.model,children:t.model})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs tabular-nums text-muted-foreground",children:[e.jsx("span",{children:Q(t.latency_ms,r("common.units.ms"))}),t.ttft_ms!=null?e.jsxs("span",{children:[r("logs.table.columns.latencyTtft")," ",A(t.ttft_ms)]}):null]})]})}function It({record:t,providerLabelMap:l,apiKeyMap:m,onSelect:r,isEven:d,density:s,visibleColumnSet:a}){const{t:n}=q(),N=l.get(t.provider)??t.provider,u=t.endpoint||"-",w=fe(t,n),c=t.client_model??n("logs.table.requestedModelFallback"),y=t.api_key_id!=null?m.get(t.api_key_id):void 0,x=t.api_key_id==null?n("logs.table.apiKeyUnknown"):y!=null&&y.isWildcard?n("apiKeys.wildcard"):y!=null&&y.name?y.name:t.api_key_name?t.api_key_name:n("logs.table.apiKeyUnknown"),f=s==="compact"?"px-3 py-1.5":"px-3 py-2",o=d?"bg-muted/30":"bg-background",g=Re(t.session_id),L=g==null?void 0:g.accentStyle;return e.jsxs("tr",{"data-session-id":g==null?void 0:g.sessionId,"data-session-color":g==null?void 0:g.colorKey,className:D("transition-colors duration-160 ease-surface",d?"bg-muted/30":"","hover:bg-muted/50"),children:[e.jsx("td",{className:D("sticky left-0 z-10 text-xs",f,o),style:L,children:he(t.timestamp)}),a.has("endpoint")&&e.jsx("td",{className:D(f,"text-xs"),children:u}),a.has("provider")&&e.jsx("td",{className:D(f,"text-xs"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:N,children:N})}),a.has("requestedModel")&&e.jsx("td",{className:D(f,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:c,children:c})}),a.has("routedModel")&&e.jsx("td",{className:D(f,"text-xs"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:t.model,children:t.model})}),a.has("apiKey")&&e.jsx("td",{className:D(f,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[90px] truncate",title:x,children:x})}),a.has("tokens")&&e.jsx("td",{className:D(f,"text-right text-xs tabular-nums align-top"),children:e.jsxs("span",{className:"inline-flex flex-col items-end gap-0.5",children:[e.jsxs("span",{className:"whitespace-nowrap",children:[n("logs.table.columns.tokenIn")," ",A(t.input_tokens),e.jsx("span",{className:"mx-1 text-muted-foreground/50",children:"·"}),n("logs.table.columns.tokenOut")," ",A(t.output_tokens)]}),(()=>{const h=(t.cache_read_tokens??0)+(t.cache_creation_tokens??0);return h>0?e.jsxs("span",{className:"whitespace-nowrap text-[11px] text-muted-foreground/70",children:[n("logs.table.columns.tokenCache")," ",A(h)]}):null})()]})}),a.has("duration")&&e.jsx("td",{className:D(f,"text-right text-xs tabular-nums align-top"),children:e.jsxs("span",{className:"inline-flex flex-col items-end gap-0.5",children:[e.jsx("span",{className:"whitespace-nowrap",children:Q(t.latency_ms,"ms")}),(t.ttft_ms!=null||t.tpot_ms!=null)&&e.jsxs("span",{className:"whitespace-nowrap text-[11px] text-muted-foreground/70",title:`${n("logs.table.columns.latencyTtft")} ${Q(t.ttft_ms,"ms")} · ${n("logs.table.columns.latencyTpot")} ${Q(t.tpot_ms,"ms/tk")}`,children:[n("logs.table.columns.latencyTtft")," ",A(t.ttft_ms),e.jsx("span",{className:"mx-1 text-muted-foreground/50",children:"·"}),n("logs.table.columns.latencyTpot")," ",A(t.tpot_ms)]})]})}),a.has("status")&&e.jsx("td",{className:D(f,"text-center"),children:e.jsx(I,{variant:w.variant,className:"text-xs",children:w.label})}),a.has("error")&&e.jsx("td",{className:D(f,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:t.error??"",children:t.error?t.error:"-"})}),e.jsx("td",{className:D("sticky right-0 z-10 text-center",f,o),children:e.jsx(_,{variant:"outline",size:"sm",onClick:()=>r(t.id),children:n("logs.actions.detail")})})]})}function Vt(t){const{t:l}=q(),{tableScrollRef:m,visibleColumnSet:r,visibleColumnCount:d,logsError:s,logsPending:a,items:n,activeFiltersCount:N,total:u,handleResetFilters:w,handleRetry:c,providerLabelMap:y,apiKeyMap:x,handleOpenDetail:f,rowDensity:o,showScrollHint:g,pageSize:L,setPageSize:h,page:b,totalPages:k,setPage:j}=t,R=e.jsx(oe,{compact:!0,tone:"danger",icon:e.jsx(rt,{className:"h-5 w-5","aria-hidden":"true"}),title:l("logs.toast.listError.title"),description:s,action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:c,children:l("common.actions.refresh")}),N>0?e.jsx(_,{variant:"ghost",size:"sm",onClick:w,children:l("common.actions.reset")}):null]})}),E=e.jsx(oe,{compact:!0,tone:"primary",icon:e.jsx(ot,{className:"h-5 w-5","aria-hidden":"true"}),title:N>0?l("logs.empty.filteredTitle"):l("logs.empty.title"),description:N>0?l("logs.empty.filteredSubtitle"):l("logs.empty.subtitle"),action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[N>0?e.jsx(_,{variant:"outline",size:"sm",onClick:w,children:l("logs.empty.actions.reset")}):null,e.jsx(_,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(Ft,{to:"/api-keys",children:l("logs.empty.actions.apiKeys")})})]})});return e.jsx(_e,{className:"overflow-hidden bg-card shadow-[var(--surface-shadow)]",children:e.jsxs(Fe,{className:"p-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 bg-secondary/50 px-4 py-3 border-b border-border",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:l("logs.title")}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"metric-number",children:l("logs.summary.total",{value:u.toLocaleString()})}),e.jsx("span",{className:"mx-1.5 text-muted-foreground/50",children:"·"}),l("logs.actions.visibleCount",{count:d-2})]})]}),e.jsxs("div",{className:"hidden md:flex flex-wrap items-center gap-2",children:[e.jsx(I,{variant:"secondary",children:"Wide Table"}),e.jsx(I,{variant:"outline",className:"bg-background",children:l(o==="compact"?"logs.table.density.compact":"logs.table.density.comfortable")}),g?e.jsx(I,{variant:"warning",children:"Scroll for more"}):null]})]}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{ref:m,className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[1180px] text-sm",children:[e.jsx("thead",{className:"border-b border-border/50 bg-secondary/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 z-20 bg-secondary px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.time")}),r.has("endpoint")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.endpoint")}),r.has("provider")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.provider")}),r.has("requestedModel")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.requestedModel")}),r.has("routedModel")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.routedModel")}),r.has("apiKey")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.apiKey")}),r.has("tokens")&&e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.tokens")}),r.has("duration")&&e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.duration")}),r.has("status")&&e.jsx("th",{className:"px-3 py-2.5 text-center text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.status")}),r.has("error")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.error")}),e.jsx("th",{className:"sticky right-0 z-20 bg-secondary px-3 py-2.5 text-center text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-border/50",children:a?Array.from({length:8}).map((C,F)=>e.jsx(St,{columns:d},F)):s&&n.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:d,className:"px-3 py-6",children:R})}):n.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:d,className:"px-3 py-8 text-center text-sm text-muted-foreground",children:E})}):n.map((C,F)=>e.jsx(It,{record:C,providerLabelMap:y,apiKeyMap:x,onSelect:f,isEven:F%2===0,density:o,visibleColumnSet:r},C.id))})]})}),g&&e.jsx("div",{className:"table-scroll-hint"})]}),e.jsx("div",{className:"md:hidden",children:a?e.jsx("div",{className:"space-y-3 p-4",children:Array.from({length:5}).map((C,F)=>e.jsx(Ct,{className:"h-20 w-full"},F))}):s&&n.length===0?e.jsx("div",{className:"px-3 py-6",children:R}):n.length===0?e.jsx("div",{className:"px-3 py-8",children:E}):n.map(C=>e.jsx(Qt,{record:C,providerLabelMap:y,onSelect:f},C.id))}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 bg-secondary/50 p-4 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-secondary px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:l("logs.table.pagination.perPage")}),e.jsxs(te,{value:L.toString(),onValueChange:C=>h(Number(C)),children:[e.jsx(se,{className:"h-8 w-[80px] bg-background",children:e.jsx(le,{})}),e.jsx(ae,{children:J.map(C=>e.jsx(z,{value:C.toString(),children:C},C))})]})]}),e.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-secondary px-2 py-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>j(C=>Math.max(C-1,1)),disabled:b<=1,children:l("logs.table.pagination.previous")}),e.jsx("span",{className:"metric-number px-1 text-sm text-muted-foreground",children:l("logs.table.pagination.pageLabel",{page:k===0?0:b,total:k})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>j(C=>k===0?C:Math.min(C+1,k)),disabled:k===0||b>=k,children:l("logs.table.pagination.next")})]})]})]})})}function Ut({exportTimeoutMs:t,queryParams:l,total:m}){const{t:r}=q(),{pushToast:d}=ge(),[s,a]=p.useState(!1),n=p.useCallback(async()=>{if(!s){a(!0);try{const N=m>0?Math.min(m,5e3):1e3,u={...l,limit:N,offset:0},w=await ye.exportArchive(u,t),c=new Date().toISOString().replace(/[:.]/g,"-"),y=URL.createObjectURL(w),x=document.createElement("a");x.href=y,x.download=`cc-gw-logs-${c}.zip`,document.body.appendChild(x),x.click(),x.remove(),URL.revokeObjectURL(y),d({title:r("logs.toast.exportSuccess.title"),description:r("logs.toast.exportSuccess.desc"),variant:"success"})}catch(N){const u=dt(N);d({title:r("logs.toast.exportError.title"),description:r("logs.toast.exportError.desc",{message:u.message}),variant:"error"})}finally{a(!1)}}},[t,s,d,l,r,m]);return{exporting:s,handleExport:n}}function Ht(){const t=p.useRef(null),[l,m]=p.useState(!1),r=p.useCallback(()=>{const d=t.current;if(!d)return;const s=d.scrollWidth-d.scrollLeft-d.clientWidth>1;m(s)},[]);return p.useEffect(()=>{const d=t.current;if(!d)return;r(),d.addEventListener("scroll",r,{passive:!0});const s=new ResizeObserver(r);return s.observe(d),()=>{d.removeEventListener("scroll",r),s.disconnect()}},[r]),{scrollRef:t,showScrollHint:l,updateScrollHint:r}}function Bt(){const[t,l]=O(P.logs.density,Ot,{serialize:w=>w,deserialize:w=>w==="compact"?"compact":"comfortable"}),[m,r]=O(P.logs.visibleColumns,G,{serialize:JSON.stringify,deserialize:w=>{try{const c=JSON.parse(w);if(!Array.isArray(c))return G;const y=c.filter(x=>re.includes(x));return y.length>0?y:G}catch{return G}}}),{scrollRef:d,showScrollHint:s}=Ht(),a=p.useMemo(()=>new Set(m),[m]),n=m.length+2,N=p.useCallback(w=>{r(c=>{if(c.includes(w))return c.length===1?c:c.filter(x=>x!==w);const y=[...c,w];return y.sort((x,f)=>re.indexOf(x)-re.indexOf(f)),y})},[]);return{resetVisibleColumns:p.useCallback(()=>{r(G)},[]),rowDensity:t,setRowDensity:l,showScrollHint:s,tableScrollRef:d,toggleColumn:N,visibleColumnCount:n,visibleColumns:m,visibleColumnSet:a}}function Wt(){var we,Ne,ke,Se,Ce;const{t}=q(),{pushToast:l}=ge(),m=Rt(),[r,d]=O(P.logs.providerFilter,"all"),[s,a]=O(P.logs.endpointFilter,"all"),[n,N]=O(P.logs.modelFilter,""),[u,w]=O(P.logs.statusFilter,"all"),[c,y]=O(P.logs.fromDate,""),[x,f]=O(P.logs.toDate,""),[o,g]=p.useState(1),[L,h]=O(P.logs.pageSize,At,{serialize:i=>String(i),deserialize:i=>{const S=Number(i);return J.includes(S)?S:J[0]}}),[b,k]=p.useState(null),[j,R]=p.useState(!1),[E,C]=O(P.logs.selectedApiKeys,[],{serialize:JSON.stringify,deserialize:i=>{try{const S=JSON.parse(i);return Array.isArray(S)?S.map(M=>Number(M)).filter(M=>Number.isInteger(M)&&M>0):[]}catch{return[]}}}),[F,v]=p.useState(!0),{resetVisibleColumns:X,rowDensity:Te,setRowDensity:Ke,showScrollHint:Me,tableScrollRef:Pe,toggleColumn:ze,visibleColumnCount:Oe,visibleColumns:Ae,visibleColumnSet:qe}=Bt(),$e=p.useDeferredValue(n),T=n===""?"":$e;p.useEffect(()=>{g(1)},[r,s,T,u,c,x,L,E]);const ne=p.useMemo(()=>{const i={limit:L,offset:(o-1)*L};r!=="all"&&(i.provider=r),s!=="all"&&(i.endpoint=s),T.trim().length>0&&(i.model=T.trim()),u!=="all"&&(i.status=u);const S=Le(c),M=Le(x,!0);return S!==void 0&&(i.from=S),M!==void 0&&(i.to=M),E.length>0&&(i.apiKeys=E.join(",")),i},[T,s,c,o,L,r,E,u,x]),V=W(U.logs.list(ne),ye.listRequest(ne),{gcTime:6e4}),B=W(U.providers.all(),Ee.providersRequest()),be=W(U.apiKeys.all(),{url:"/api/keys",method:"GET"}),ie=W(U.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"}),je=W(U.config.exportTimeout(),Ee.configRequest());p.useEffect(()=>{!V.isError||!V.error||l({title:t("logs.toast.listError.title"),description:t("logs.toast.listError.desc",{message:V.error.message}),variant:"error"})},[V.error,V.isError,l,t]),p.useEffect(()=>{!B.isError||!B.error||l({title:t("logs.toast.providerError.title"),description:t("logs.toast.providerError.desc",{message:B.error.message}),variant:"error"})},[B.error,B.isError,l,t]);const ee=((we=V.data)==null?void 0:we.total)??0,Y=ee>0?Math.ceil(ee/L):0,Qe=((Ne=V.data)==null?void 0:Ne.items)??[],Ie=p.useMemo(()=>{var S;const i=(S=je.data)==null?void 0:S.logExportTimeoutSeconds;return typeof i=="number"&&Number.isFinite(i)?Math.min(Math.max(Math.round(i),5),600)*1e3:6e4},[(ke=je.data)==null?void 0:ke.logExportTimeoutSeconds]);p.useEffect(()=>{Y>0&&o>Y&&g(Y)},[o,Y]);const de=B.data??[],ce=p.useMemo(()=>{const i=new Map;for(const S of de)S.id&&i.set(S.id,S.label??S.id);return i},[de]),ve=p.useMemo(()=>{var S;const i=new Map;i.set("anthropic",t("logs.filters.endpointAnthropic")),i.set("openai",t("logs.filters.endpointOpenAI"));for(const M of((S=ie.data)==null?void 0:S.endpoints)??[])i.set(M.id,M.label||M.id);return i},[(Se=ie.data)==null?void 0:Se.endpoints,t]),Ve=p.useMemo(()=>{const i=[];if(r!=="all"){const S=ce.get(r)??r;i.push({key:"provider",label:`${t("logs.filters.provider")}: ${S}`,onRemove:()=>d("all")})}if(s!=="all"){const S=ve.get(s)??s;i.push({key:"endpoint",label:`${t("logs.filters.endpoint")}: ${S}`,onRemove:()=>a("all")})}if(T.trim()&&i.push({key:"model",label:`${t("logs.filters.modelId")}: ${T.trim()}`,onRemove:()=>N("")}),u!=="all"){const S=t(u==="success"?"logs.filters.statusSuccess":"logs.filters.statusError");i.push({key:"status",label:`${t("logs.filters.status")}: ${S}`,onRemove:()=>w("all")})}return c&&i.push({key:"from",label:`${t("logs.filters.startDate")}: ${c}`,onRemove:()=>y("")}),x&&i.push({key:"to",label:`${t("logs.filters.endDate")}: ${x}`,onRemove:()=>f("")}),E.length>0&&i.push({key:"apiKeys",label:t("logs.filters.apiKeySelected",{count:E.length}),onRemove:()=>C([])}),i},[T,s,ve,c,r,ce,E.length,u,t,x]),me=be.data??[],Ue=p.useMemo(()=>{const i=new Map;for(const S of me)i.set(S.id,S);return i},[me]),He=p.useMemo(()=>re.map(i=>({id:i,label:t(`logs.table.columns.${i}`)})),[t]),Z=p.useMemo(()=>{const i=new Date;return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`},[]),Be=p.useMemo(()=>r==="all"&&s==="all"&&T.trim()===""&&u==="all"&&c===""&&x===""&&E.length===0?"all":u==="error"&&s==="all"&&r==="all"&&T.trim()===""&&c===""&&x===""&&E.length===0?"errors":qt(c,x,Z)&&s==="all"&&r==="all"&&T.trim()===""&&u==="all"&&E.length===0?"today":s==="anthropic"&&r==="all"&&T.trim()===""&&u==="all"&&c===""&&x===""&&E.length===0?"anthropic":s==="openai"&&r==="all"&&T.trim()===""&&u==="all"&&c===""&&x===""&&E.length===0?"openai":null,[T,s,c,r,E.length,u,x,Z]),ue=p.useCallback(()=>{d("all"),N(""),a("all"),w("all"),y(""),f(""),C([])},[]),We=p.useCallback(i=>{if(g(1),ue(),i!=="all"){if(i==="errors"){w("error");return}if(i==="today"){y(Z),f(Z);return}if(i==="anthropic"){a("anthropic");return}i==="openai"&&a("openai")}},[ue,Z]),{exporting:Ge,handleExport:Je}=Ut({exportTimeoutMs:Ie,queryParams:ne,total:ee}),Xe=p.useCallback(i=>{m.removeQueries({queryKey:["logs","detail"],type:"inactive"}),k(i),R(!0)},[m]),Ye=p.useCallback(()=>{R(!1)},[]);return p.useEffect(()=>{j||b===null||(m.removeQueries({queryKey:U.logs.detail(b),exact:!0}),k(null))},[j,m,b]),{activeFilters:Ve,activeQuickView:Be,apiKeyMap:Ue,apiKeys:me,apiKeysQuery:be,applyQuickView:We,columnOptions:He,customEndpoints:(Ce=ie.data)==null?void 0:Ce.endpoints,endpointFilter:s,exporting:Ge,filtersExpanded:F,fromDate:c,handleCloseDetail:Ye,handleExport:Je,handleOpenDetail:Xe,handleResetFilters:ue,isDetailOpen:j,items:Qe,logsQuery:V,modelFilter:n,page:o,pageSize:L,providerFilter:r,providerLabelMap:ce,providerOptions:de,rowDensity:Te,resetVisibleColumns:X,selectedApiKeys:E,selectedLogId:b,setEndpointFilter:a,setFiltersExpanded:v,setFromDate:y,setModelFilter:N,setPage:g,setPageSize:h,setProviderFilter:d,setRowDensity:Ke,setSelectedApiKeys:C,setStatusFilter:w,setToDate:f,showScrollHint:Me,statusFilter:u,tableScrollRef:Pe,toDate:x,toggleColumn:ze,total:ee,totalPages:Y,visibleColumnCount:Oe,visibleColumns:Ae,visibleColumnSet:qe}}function gs(){var l;const t=Wt();return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(nt,{actions:e.jsx($t,{columnOptions:t.columnOptions,exporting:t.exporting,onExport:()=>void t.handleExport(),onRefresh:()=>void t.logsQuery.refetch(),onResetColumns:t.resetVisibleColumns,onSetDensity:t.setRowDensity,onToggleColumn:t.toggleColumn,refreshing:t.logsQuery.isFetching,rowDensity:t.rowDensity,visibleColumns:t.visibleColumns,visibleColumnSet:t.visibleColumnSet})}),e.jsx(Kt,{activeFilters:t.activeFilters,filtersExpanded:t.filtersExpanded,setFiltersExpanded:t.setFiltersExpanded,handleResetFilters:t.handleResetFilters,activeQuickView:t.activeQuickView,applyQuickView:t.applyQuickView,providerFilter:t.providerFilter,setProviderFilter:t.setProviderFilter,endpointFilter:t.endpointFilter,setEndpointFilter:t.setEndpointFilter,selectedApiKeys:t.selectedApiKeys,setSelectedApiKeys:t.setSelectedApiKeys,modelFilter:t.modelFilter,setModelFilter:t.setModelFilter,statusFilter:t.statusFilter,setStatusFilter:t.setStatusFilter,fromDate:t.fromDate,setFromDate:t.setFromDate,toDate:t.toDate,setToDate:t.setToDate,providerOptions:t.providerOptions,apiKeys:t.apiKeys,apiKeysLoading:t.apiKeysQuery.isLoading,customEndpoints:t.customEndpoints}),e.jsx(Vt,{tableScrollRef:t.tableScrollRef,visibleColumnSet:t.visibleColumnSet,visibleColumnCount:t.visibleColumnCount,logsError:t.logsQuery.isError?((l=t.logsQuery.error)==null?void 0:l.message)??null:null,logsPending:t.logsQuery.isPending,items:t.items,activeFiltersCount:t.activeFilters.length,total:t.total,handleResetFilters:t.handleResetFilters,handleRetry:()=>void t.logsQuery.refetch(),providerLabelMap:t.providerLabelMap,apiKeyMap:t.apiKeyMap,handleOpenDetail:t.handleOpenDetail,rowDensity:t.rowDensity,showScrollHint:t.showScrollHint,pageSize:t.pageSize,setPageSize:t.setPageSize,page:t.page,totalPages:t.totalPages,setPage:t.setPage}),e.jsx(Pt,{open:t.isDetailOpen,logId:t.selectedLogId,onClose:t.handleCloseDetail,providerLabelMap:t.providerLabelMap,apiKeyMap:t.apiKeyMap})]})}export{gs as default};
@@ -1 +0,0 @@
1
- import{j as e,N as c}from"./vendor-m8O77Czp.js";import{c as i}from"./global-zt8jbW7F.js";const m={default:"border-border/30 bg-card shadow-sm",primary:"border-primary/10 bg-card shadow-sm",danger:"border-destructive/15 bg-card shadow-sm"},o={default:"bg-secondary text-primary",primary:"bg-primary/10 text-primary",danger:"bg-destructive/10 text-destructive"};function x({icon:r,title:a,description:s,action:t,className:n,compact:l=!1,tone:d="default"}){return e.jsxs("div",{className:i("flex flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 text-center",l?"min-h-[180px] py-8":"min-h-[260px] py-12",m[d],n),children:[r?e.jsx("div",{className:i("mb-4 flex h-12 w-12 items-center justify-center rounded-2xl",o[d]),children:r}):null,e.jsxs("div",{className:"max-w-xl space-y-1.5",children:[e.jsx("div",{className:"text-base font-semibold tracking-[-0.01em]",children:a}),s?e.jsx("div",{className:"text-sm text-muted-foreground",children:s}):null]}),t?e.jsx("div",{className:"mt-5 flex flex-wrap items-center justify-center gap-2",children:t}):null]})}function p({label:r,className:a,compact:s=!1}){return e.jsx(x,{className:a,compact:s,tone:"primary",icon:e.jsx(c,{className:"h-5 w-5 animate-spin","aria-hidden":"true"}),title:r})}export{p as P,x as a};