@chenpu17/cc-gw 0.8.3 → 0.8.4

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 (49) hide show
  1. package/README.md +3 -3
  2. package/package.json +5 -5
  3. package/src/web/dist/assets/{About-CTbbI3Xf.js → About-C_aKibBC.js} +1 -1
  4. package/src/web/dist/assets/ApiKeys-DsAyIbwB.js +1 -0
  5. package/src/web/dist/assets/{ConfirmDialog-DW7jBfm1.js → ConfirmDialog-z8FIBVOS.js} +1 -1
  6. package/src/web/dist/assets/Dashboard-DVP7GTtz.js +1 -0
  7. package/src/web/dist/assets/{DialogShell-BqzUE3vU.js → DialogShell-Cdf4kRdb.js} +1 -1
  8. package/src/web/dist/assets/EChart-BlZFJiWb.js +1 -0
  9. package/src/web/dist/assets/{Events-19qjsHJf.js → Events-D8BFNMmT.js} +1 -1
  10. package/src/web/dist/assets/{Help-FrXAXPhx.js → Help-CLnzpKCo.js} +2 -2
  11. package/src/web/dist/assets/{Login-BYpsX-S8.js → Login-DaukwolD.js} +1 -1
  12. package/src/web/dist/assets/Logs-CxWTzBAj.js +1 -0
  13. package/src/web/dist/assets/ModelManagement-D5SFzd2o.js +1 -0
  14. package/src/web/dist/assets/{PageHeader-DDxjKW4B.js → PageHeader-bBBkQNPI.js} +1 -1
  15. package/src/web/dist/assets/{PageSection-DRyQEnmK.js → PageSection-Bkk2okl7.js} +1 -1
  16. package/src/web/dist/assets/{PageState-DA98vXl7.js → PageState-QEhNwS9Q.js} +1 -1
  17. package/src/web/dist/assets/{Profiler-D5P7FF0I.js → Profiler-LHVe6wwO.js} +1 -1
  18. package/src/web/dist/assets/{Settings-D8Xgk7cH.js → Settings-D7qUYpBC.js} +1 -1
  19. package/src/web/dist/assets/{Skeleton-D_opZxQ7.js → Skeleton-CCQlvfTP.js} +1 -1
  20. package/src/web/dist/assets/{badge-B-TfGxGB.js → badge-dFhP0Qyo.js} +1 -1
  21. package/src/web/dist/assets/{card-I07afQF2.js → card-BeBgk27f.js} +1 -1
  22. package/src/web/dist/assets/{charts-core-C-3-Lo7l.js → charts-core-B4zLPEwd.js} +1 -1
  23. package/src/web/dist/assets/{charts-engine-BI1CmRJo.js → charts-engine-CmnAuZWT.js} +1 -1
  24. package/src/web/dist/assets/{charts-react-DJ_0LNAP.js → charts-react-C9hy6r5j.js} +1 -1
  25. package/src/web/dist/assets/{gateway-CkqHb_VE.js → gateway-DWOrDCuI.js} +1 -1
  26. package/src/web/dist/assets/{i18n-C7VVFIdN.js → i18n-DJXLExhE.js} +1 -1
  27. package/src/web/dist/assets/index-CXBZSNMv.css +1 -0
  28. package/src/web/dist/assets/index-wrD5MdRi.js +61 -0
  29. package/src/web/dist/assets/{input-DZMeIHxj.js → input-BTCXiXUM.js} +1 -1
  30. package/src/web/dist/assets/{label-DZr7itdg.js → label-DjpX-mjh.js} +1 -1
  31. package/src/web/dist/assets/{popover-_LyL4tgU.js → popover-Brp8rADW.js} +1 -1
  32. package/src/web/dist/assets/{query-DxhDvnDC.js → query-CR1zzqi0.js} +1 -1
  33. package/src/web/dist/assets/{radix-CmyU-WBH.js → radix-BMe0_WA0.js} +1 -1
  34. package/src/web/dist/assets/{router-D8u_RlVh.js → router-cKa0BaP7.js} +1 -1
  35. package/src/web/dist/assets/{select-BUvJR07s.js → select-C3RskPYc.js} +1 -1
  36. package/src/web/dist/assets/{switch-BpfcwR9i.js → switch-n7tI2AqZ.js} +1 -1
  37. package/src/web/dist/assets/{useApiQuery-BzbOtl4s.js → useApiQuery-olO5q8vr.js} +1 -1
  38. package/src/web/dist/assets/{useAppMutation-D8Mjcv9t.js → useAppMutation-BJbRpdNF.js} +1 -1
  39. package/src/web/dist/assets/utils-BHook6QN.js +1 -0
  40. package/src/web/dist/assets/{vendor-5iCEqDpV.js → vendor-CseyjbPR.js} +73 -63
  41. package/src/web/dist/index.html +7 -7
  42. package/src/web/dist/assets/ApiKeys-Dca6MyO2.js +0 -1
  43. package/src/web/dist/assets/Dashboard-DMo-YHgS.js +0 -1
  44. package/src/web/dist/assets/EChart-VRAvk6sX.js +0 -1
  45. package/src/web/dist/assets/Logs-ynLMNHgv.js +0 -1
  46. package/src/web/dist/assets/ModelManagement-DrE_4kky.js +0 -1
  47. package/src/web/dist/assets/index-8bCfrPhk.css +0 -1
  48. package/src/web/dist/assets/index-CYeQpt9d.js +0 -61
  49. package/src/web/dist/assets/utils-DQfq7gRo.js +0 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@ GitHub 仓库:[chenpu17/cc-gw2](https://github.com/chenpu17/cc-gw2)
4
4
 
5
5
  `cc-gw` 是一个本地网关项目,使用 Rust 重写原先的 Node.js 后端,同时保留现有 Web UI、CLI 使用方式、配置文件和 SQLite 数据格式的兼容性。
6
6
 
7
- 当前主线已收敛到 `v0.8.3` 正式版,核心收益是后端完成 Rust 化之后,在相同常驻场景下内存占用实测可降至旧 Node.js 实现的约 `1/20`,同时继续保持对既有 CLI、Web UI、配置目录与 SQLite 数据的兼容。
7
+ 当前主线已收敛到 `v0.8.4` 正式版,核心收益是后端完成 Rust 化之后,在相同常驻场景下内存占用实测可降至旧 Node.js 实现的约 `1/20`,同时继续保持对既有 CLI、Web UI、配置目录与 SQLite 数据的兼容。
8
8
 
9
9
  说明:
10
10
 
@@ -142,8 +142,8 @@ Linux 版本使用 `musl`,Windows 版本使用静态 CRT,目标是让用户
142
142
  ```bash
143
143
  pnpm pack:dry-run
144
144
  pnpm --dir packages/native/darwin-arm64 pack --pack-destination ../../../.pack/native
145
- npm install -g ./.pack/native/chenpu17-cc-gw-darwin-arm64-0.8.3.tgz
146
- npm install -g ./.pack/chenpu17-cc-gw-0.8.3.tgz
145
+ npm install -g ./.pack/native/chenpu17-cc-gw-darwin-arm64-0.8.4.tgz
146
+ npm install -g ./.pack/chenpu17-cc-gw-0.8.4.tgz
147
147
  ```
148
148
 
149
149
  当前发布目标:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenpu17/cc-gw",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Rust-backed local Claude Code compatible gateway with web console and CLI daemon.",
@@ -25,10 +25,10 @@
25
25
  "README.md"
26
26
  ],
27
27
  "optionalDependencies": {
28
- "@chenpu17/cc-gw-darwin-arm64": "0.8.3",
29
- "@chenpu17/cc-gw-linux-arm64": "0.8.3",
30
- "@chenpu17/cc-gw-linux-x64": "0.8.3",
31
- "@chenpu17/cc-gw-win32-x64": "0.8.3"
28
+ "@chenpu17/cc-gw-darwin-arm64": "0.8.4",
29
+ "@chenpu17/cc-gw-linux-arm64": "0.8.4",
30
+ "@chenpu17/cc-gw-linux-x64": "0.8.4",
31
+ "@chenpu17/cc-gw-win32-x64": "0.8.4"
32
32
  },
33
33
  "dependencies": {
34
34
  "colorette": "^2.0.20",
@@ -1 +1 @@
1
- import{r as n,j as e,ab as V,aA as B,aB as p,aj as R,Z as q}from"./vendor-5iCEqDpV.js";import{P as F}from"./PageHeader-DDxjKW4B.js";import{P as x}from"./PageSection-DRyQEnmK.js";import{P as G,a as A}from"./PageState-DA98vXl7.js";import{u as I}from"./useAppMutation-D8Mjcv9t.js";import{u as M}from"./useApiQuery-BzbOtl4s.js";import{u as D,B as b,r as $}from"./index-CYeQpt9d.js";import{q as z}from"./queryKeys-BMvyDTQS.js";import{B as d}from"./badge-B-TfGxGB.js";import{C as c,a as u}from"./card-I07afQF2.js";import{u as J}from"./i18n-C7VVFIdN.js";import"./query-DxhDvnDC.js";import"./router-D8u_RlVh.js";import"./radix-CmyU-WBH.js";const Q="0.8.3",U={version:Q};function le(){var f,v,g,j,N,y,w,k,S,T;const{t}=J(),{pushToast:r}=D(),[i,P]=n.useState(null),a=M(z.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=I({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=>{P(s)}}),l=U.version,m="2026-03-30T07:21:21.618Z",L=n.useMemo(()=>{var s,C;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:m}),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:((C=a.data)==null?void 0:C.backendVersion)??"-"})}]},[l,m,(f=a.data)==null?void 0:f.backendVersion,(v=a.data)==null?void 0:v.runtime,t]),h=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,{icon:e.jsx(B,{className:"h-5 w-5","aria-hidden":"true"}),title:t("about.title"),description:t("about.description"),badge:e.jsxs("span",{"data-visual-volatile":"true",children:["v",l]}),eyebrow:"Runtime",breadcrumb:"Gateway / About",helper:t("about.support.description"),actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:"manual refresh only"}),e.jsxs(b,{onClick:()=>o.mutate(),disabled:o.isPending,className:"w-full sm:w-auto",children:[e.jsx(V,{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.3fr)_minmax(320px,0.9fr)]",children:[e.jsx(c,{className:"overflow-hidden",children:e.jsx(u,{className:"pt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-primary/20 bg-accent px-3 py-1 text-xs font-semibold uppercase tracking-wider text-primary",children:[e.jsx(p,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Runtime snapshot"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"text-3xl font-semibold tracking-tight text-foreground",children:[((g=a.data)==null?void 0:g.host)??"127.0.0.1",":",((j=a.data)==null?void 0:j.port)??"-"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("about.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(d,{variant:"outline",children:((N=a.data)==null?void 0:N.runtime)??"rust"}),e.jsx(d,{variant:"outline",children:((y=a.data)==null?void 0:y.platform)??"-"}),e.jsxs(d,{variant:"secondary",children:[t("about.status.labels.providers"),": ",((k=(w=a.data)==null?void 0:w.providers)==null?void 0:k.toLocaleString())??"-"]}),e.jsxs(d,{variant:"secondary",children:[t("about.status.labels.active"),": ",(((S=a.data)==null?void 0:S.activeRequests)??0).toLocaleString()]})]})]})})}),e.jsx(c,{className:"overflow-hidden",children:e.jsx(u,{className:"pt-6",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("p",{"data-visual-volatile":"true",className:"font-mono text-lg text-primary",children:["v",l]}),e.jsx("p",{"data-visual-volatile":"true",className:"text-sm text-muted-foreground",children:m}),i?e.jsxs("div",{className:"rounded-lg border border-border 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 border border-border bg-secondary px-4 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(x,{title:t("about.app.title"),description:t("about.app.subtitle"),children:e.jsx(E,{items:L})}),e.jsx(x,{title:t("about.status.title"),description:t("about.status.subtitle"),actions:e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),disabled:a.isFetching,children:[e.jsx(R,{className:Z(a.isFetching),"aria-hidden":"true"}),a.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")]}),children:a.isLoading?e.jsx(G,{compact:!0,label:t("about.status.loading")}):a.isError?e.jsx(A,{compact:!0,tone:"danger",icon:e.jsx(p,{className:"h-5 w-5","aria-hidden":"true"}),title:t("common.status.error"),description:((T=a.error)==null?void 0:T.message)??t("common.unknownError"),action:e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:t("common.actions.refresh")})}):h.length>0?e.jsx(E,{items:h}):e.jsx(A,{compact:!0,tone:"primary",icon:e.jsx(p,{className:"h-5 w-5","aria-hidden":"true"}),title:t("about.status.empty"),description:t("common.actions.refresh")})})]}),e.jsx(x,{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(c,{children:e.jsxs(u,{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",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-2xl 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 border border-border 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-4 sm:grid-cols-2",children:t.map(r=>e.jsx(c,{children:e.jsxs(u,{className:"pt-5",children:[e.jsx("dt",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:r.label}),e.jsx("dd",{className:"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 Z(t){return`mr-2 h-4 w-4${t?" animate-spin":""}`}export{le as default};
1
+ import{r as n,j as e,ab as V,aC as B,aD as p,al as R,Z as q}from"./vendor-CseyjbPR.js";import{P as D}from"./PageHeader-bBBkQNPI.js";import{P as x}from"./PageSection-Bkk2okl7.js";import{P as F,a as E}from"./PageState-QEhNwS9Q.js";import{u as G}from"./useAppMutation-BJbRpdNF.js";import{u as I}from"./useApiQuery-olO5q8vr.js";import{u as M,B as b,r as $}from"./index-wrD5MdRi.js";import{q as z}from"./queryKeys-BMvyDTQS.js";import{B as d}from"./badge-dFhP0Qyo.js";import{C as c,a as u}from"./card-BeBgk27f.js";import{u as J}from"./i18n-DJXLExhE.js";import"./query-CR1zzqi0.js";import"./router-cKa0BaP7.js";import"./radix-BMe0_WA0.js";const Q="0.8.4",U={version:Q};function le(){var f,v,g,j,N,y,w,k,S,T;const{t}=J(),{pushToast:r}=M(),[i,A]=n.useState(null),a=I(z.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=G({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=U.version,m="2026-04-01T00:13:14.333Z",L=n.useMemo(()=>{var s,C;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:m}),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:((C=a.data)==null?void 0:C.backendVersion)??"-"})}]},[l,m,(f=a.data)==null?void 0:f.backendVersion,(v=a.data)==null?void 0:v.runtime,t]),h=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(D,{icon:e.jsx(B,{className:"h-5 w-5","aria-hidden":"true"}),title:t("about.title"),description:t("about.description"),badge:e.jsxs("span",{"data-visual-volatile":"true",children:["v",l]}),eyebrow:"Runtime",breadcrumb:"Gateway / About",helper:t("about.support.description"),actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:"manual refresh only"}),e.jsxs(b,{onClick:()=>o.mutate(),disabled:o.isPending,className:"w-full sm:w-auto",children:[e.jsx(V,{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.3fr)_minmax(320px,0.9fr)]",children:[e.jsx(c,{className:"overflow-hidden",children:e.jsx(u,{className:"pt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-primary/20 bg-accent px-3 py-1 text-xs font-semibold uppercase tracking-wider text-primary",children:[e.jsx(p,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Runtime snapshot"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"text-3xl font-semibold tracking-tight text-foreground",children:[((g=a.data)==null?void 0:g.host)??"127.0.0.1",":",((j=a.data)==null?void 0:j.port)??"-"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("about.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(d,{variant:"outline",children:((N=a.data)==null?void 0:N.runtime)??"rust"}),e.jsx(d,{variant:"outline",children:((y=a.data)==null?void 0:y.platform)??"-"}),e.jsxs(d,{variant:"secondary",children:[t("about.status.labels.providers"),": ",((k=(w=a.data)==null?void 0:w.providers)==null?void 0:k.toLocaleString())??"-"]}),e.jsxs(d,{variant:"secondary",children:[t("about.status.labels.active"),": ",(((S=a.data)==null?void 0:S.activeRequests)??0).toLocaleString()]})]})]})})}),e.jsx(c,{className:"overflow-hidden",children:e.jsx(u,{className:"pt-6",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("p",{"data-visual-volatile":"true",className:"font-mono text-lg text-primary",children:["v",l]}),e.jsx("p",{"data-visual-volatile":"true",className:"text-sm text-muted-foreground",children:m}),i?e.jsxs("div",{className:"rounded-lg border border-border 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 border border-border bg-secondary px-4 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(x,{title:t("about.app.title"),description:t("about.app.subtitle"),children:e.jsx(P,{items:L})}),e.jsx(x,{title:t("about.status.title"),description:t("about.status.subtitle"),actions:e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),disabled:a.isFetching,children:[e.jsx(R,{className:Z(a.isFetching),"aria-hidden":"true"}),a.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")]}),children:a.isLoading?e.jsx(F,{compact:!0,label:t("about.status.loading")}):a.isError?e.jsx(E,{compact:!0,tone:"danger",icon:e.jsx(p,{className:"h-5 w-5","aria-hidden":"true"}),title:t("common.status.error"),description:((T=a.error)==null?void 0:T.message)??t("common.unknownError"),action:e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:t("common.actions.refresh")})}):h.length>0?e.jsx(P,{items:h}):e.jsx(E,{compact:!0,tone:"primary",icon:e.jsx(p,{className:"h-5 w-5","aria-hidden":"true"}),title:t("about.status.empty"),description:t("common.actions.refresh")})})]}),e.jsx(x,{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(c,{children:e.jsxs(u,{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",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-2xl 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 border border-border bg-secondary px-3 py-2 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}function P({items:t}){return t.length===0?null:e.jsx("dl",{className:"grid gap-4 sm:grid-cols-2",children:t.map(r=>e.jsx(c,{children:e.jsxs(u,{className:"pt-5",children:[e.jsx("dt",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:r.label}),e.jsx("dd",{className:"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 Z(t){return`mr-2 h-4 w-4${t?" animate-spin":""}`}export{le as default};
@@ -0,0 +1 @@
1
+ import{r as c,j as e,a2 as Ze,aw as ve,W as Ke,ax as Ne,ay as we,az as es,aA as ss,au as as}from"./vendor-CseyjbPR.js";import{c as se,r as ts,h as B,b as U,B as K,u as rs,a as _,s as J,L as ns}from"./index-wrD5MdRi.js";import{P as is}from"./PageHeader-bBBkQNPI.js";import{C as ls}from"./ConfirmDialog-z8FIBVOS.js";import{D as ae,A as te,a as re,b as ne,c as Ce,d as ie,e as le}from"./DialogShell-Cdf4kRdb.js";import{I as $}from"./input-BTCXiXUM.js";import{L as O}from"./label-DjpX-mjh.js";import{u as H}from"./useApiQuery-olO5q8vr.js";import{q as v}from"./queryKeys-BMvyDTQS.js";import{u as N}from"./i18n-DJXLExhE.js";import{E as os}from"./EChart-BlZFJiWb.js";import{P as oe}from"./PageSection-Bkk2okl7.js";import{B as C}from"./badge-dFhP0Qyo.js";import{C as de,a as ce}from"./card-BeBgk27f.js";import{e as ds}from"./charts-core-B4zLPEwd.js";import{u as z}from"./useAppMutation-BJbRpdNF.js";import{c as cs}from"./clipboard-CALi6bTW.js";import"./query-CR1zzqi0.js";import"./router-cKa0BaP7.js";import"./radix-BMe0_WA0.js";import"./charts-react-C9hy6r5j.js";import"./charts-engine-CmnAuZWT.js";const Ee=c.forwardRef(({className:s,...a},i)=>e.jsx("textarea",{className:se("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:i,...a}));Ee.displayName="Textarea";const A={listRequest(){return{url:"/api/keys",method:"GET"}},overviewRequest(s){return{url:"/api/stats/api-keys/overview",method:"GET",params:{days:s}}},usageRequest(s,a=10){return{url:"/api/stats/api-keys/usage",method:"GET",params:{days:s,limit:a}}},customEndpointOptionsRequest(){return{url:"/api/custom-endpoints",method:"GET"}},create:async s=>B(U.post("/api/keys",s)),update:async(s,a)=>{await B(U.patch(`/api/keys/${s}`,a))},delete:async s=>{await B(U.delete(`/api/keys/${s}`))},reveal:async s=>ts({url:`/api/keys/${s}/reveal`,method:"GET"})},ke=[{value:1,labelKey:"apiKeys.analytics.range.today"},{value:7,labelKey:"apiKeys.analytics.range.week"},{value:30,labelKey:"apiKeys.analytics.range.month"}];function ps(){var i;const s=[{id:"anthropic",label:"Anthropic"},{id:"openai",label:"OpenAI"}],a=H(v.customEndpoints.all(),A.customEndpointOptionsRequest());return c.useMemo(()=>{var l;const t=(((l=a.data)==null?void 0:l.endpoints)??[]).map(u=>({id:u.id,label:u.label||u.id}));return[...s,...t]},[(i=a.data)==null?void 0:i.endpoints])}function De({available:s,hint:a,onChange:i,selected:t}){const{t:l}=N(),u=t.length===0,g=()=>{i([])},j=o=>{if(t.includes(o)){i(t.filter(p=>p!==o));return}i([...t,o])};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-3 text-xs text-muted-foreground",children:a}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-lg border border-border bg-card px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-accent/50",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:g,className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm font-medium",children:l("apiKeys.allEndpoints")})]}),e.jsx("div",{className:"grid max-h-40 gap-1 overflow-y-auto",children:s.map(o=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-lg border border-border bg-card px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-accent/50",children:[e.jsx("input",{type:"checkbox",checked:!u&&t.includes(o.id),onChange:()=>j(o.id),className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm",children:o.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",o.id,")"]})]},o.id))})]})}function us({availableEndpoints:s,isOpen:a,keyDescription:i,keyName:t,maxConcurrency:l,onDescriptionChange:u,onEndpointsChange:g,onKeyNameChange:j,onMaxConcurrencyChange:o,onOpenChange:p,onSubmit:y,selectedEndpoints:n}){const{t:x}=N();return e.jsx(ae,{open:a,onOpenChange:p,children:e.jsxs(te,{className:"max-w-2xl",children:[e.jsxs(re,{children:[e.jsx(ne,{children:x("apiKeys.createNew")}),e.jsx(Ce,{children:x("apiKeys.createDescription")})]}),e.jsxs(ie,{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:x("apiKeys.selectEndpoints")}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[1rem] border border-blue-200 bg-blue-50/70 px-3 py-3 text-xs text-blue-900 dark:border-blue-800 dark:bg-blue-950/30 dark:text-blue-100",children:[e.jsx("p",{className:"font-semibold",children:"Restricted"}),e.jsx("p",{className:"mt-1 text-blue-800/85 dark:text-blue-100/80",children:"Select explicit endpoints before saving."})]}),e.jsxs("div",{className:"rounded-[1rem] border border-amber-200 bg-amber-50/70 px-3 py-3 text-xs text-amber-900 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-100",children:[e.jsx("p",{className:"font-semibold",children:"Unrestricted"}),e.jsx("p",{className:"mt-1 text-amber-800/85 dark:text-amber-100/80",children:"Leave endpoint selection empty for broad access."})]}),e.jsxs("div",{className:"rounded-[1rem] border border-rose-200 bg-rose-50/70 px-3 py-3 text-xs text-rose-900 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-100",children:[e.jsx("p",{className:"font-semibold",children:"Wildcard"}),e.jsx("p",{className:"mt-1 text-rose-800/85 dark:text-rose-100/80",children:"Special-case key with the highest blast radius."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(O,{htmlFor:"keyName",children:[x("apiKeys.keyNamePlaceholder")," *"]}),e.jsx($,{id:"keyName",value:t,onChange:h=>j(h.target.value),placeholder:x("apiKeys.keyNamePlaceholder"),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),y())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"keyDescription",children:x("apiKeys.descriptionLabel")}),e.jsx(Ee,{id:"keyDescription",value:i,onChange:h=>u(h.target.value),placeholder:x("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:x("apiKeys.allowedEndpoints")}),e.jsx(De,{available:s,selected:n,onChange:g,hint:x("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"maxConcurrency",children:x("apiKeys.maxConcurrency")}),e.jsx($,{id:"maxConcurrency",type:"number",min:"0",value:l,onChange:h=>o(h.target.value),placeholder:x("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(le,{children:[e.jsx(K,{variant:"outline",onClick:()=>p(!1),children:x("common.actions.cancel")}),e.jsx(K,{onClick:y,children:x("apiKeys.createAction")})]})]})})}function xs({createdKey:s,onClose:a,onCopy:i}){const{t}=N();return e.jsx(ae,{open:!!s,onOpenChange:l=>{l||a()},children:e.jsxs(te,{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(Ze,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(ne,{children:t("apiKeys.keyCreated")})]})}),e.jsxs(ie,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:t("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 font-mono text-sm",children:s==null?void 0:s.key}),s!=null&&s.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:s.description}):null]}),e.jsxs(le,{children:[e.jsxs(K,{onClick:()=>i((s==null?void 0:s.key)??""),children:[e.jsx(ve,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),t("common.actions.copy")]}),e.jsx(K,{variant:"outline",onClick:a,children:t("common.actions.close")})]})]})})}function ms({apiKey:s,availableEndpoints:a,maxConcurrency:i,onClose:t,onEndpointsChange:l,onMaxConcurrencyChange:u,onSave:g,selectedEndpoints:j}){const{t:o}=N();return e.jsx(ae,{open:!!s,onOpenChange:p=>{p||t()},children:e.jsxs(te,{className:"max-w-2xl",children:[e.jsxs(re,{children:[e.jsx(ne,{children:o("apiKeys.editEndpoints")}),e.jsx(Ce,{children:s==null?void 0:s.name})]}),e.jsxs(ie,{className:"space-y-4",children:[!(s!=null&&s.isWildcard)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border border-[hsl(var(--warning)/0.3)] bg-[hsl(var(--warning-bg))] px-4 py-3 text-xs text-[hsl(var(--warning)/1)]",children:o("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(De,{available:a,selected:j,onChange:l,hint:o("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"editMaxConcurrency",children:o("apiKeys.maxConcurrency")}),e.jsx($,{id:"editMaxConcurrency",type:"number",min:"0",value:i,onChange:p=>u(p.target.value),placeholder:o("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(le,{children:[e.jsx(K,{variant:"outline",onClick:t,children:o("common.actions.cancel")}),e.jsx(K,{onClick:g,children:o("common.save")})]})]})})}function ys({deleteTarget:s,isDeleting:a,onConfirm:i,onOpenChange:t}){const{t:l}=N();return e.jsx(ls,{open:!!s,onOpenChange:t,title:l("apiKeys.deleteDialogTitle"),description:l("apiKeys.confirmDelete"),confirmLabel:s&&a===s.id?l("common.actions.loading"):l("apiKeys.actions.delete"),cancelLabel:l("common.actions.cancel"),loading:s?a===s.id:!1,onConfirm:i,children:s?e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 font-mono text-xs text-foreground",children:s.name}):null})}function hs(){const{t:s}=N();return e.jsx(oe,{eyebrow:"Recommended",title:s("apiKeys.quickStart.title"),description:s("apiKeys.quickStart.description"),contentClassName:"pt-5",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(X,{icon:e.jsx(Ke,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.create.title"),description:s("apiKeys.quickStart.create.description")}),e.jsx(X,{icon:e.jsx(Ne,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.restrict.title"),description:s("apiKeys.quickStart.restrict.description")}),e.jsx(X,{icon:e.jsx(we,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.wildcard.title"),description:s("apiKeys.quickStart.wildcard.description")})]})})}function gs({activeKeysValue:s,enabledKeysValue:a,loading:i,onRangeChange:t,rangeDays:l,requestsChartOption:u,totalKeysValue:g,tokensChartOption:j,usageLength:o}){const{t:p}=N();return e.jsx(oe,{eyebrow:"Usage",title:p("apiKeys.analytics.title"),description:p("apiKeys.analytics.description",{days:l}),actions:e.jsx("div",{className:"flex w-full items-center gap-1 overflow-x-auto rounded-full border border-border bg-secondary p-1 sm:w-auto",children:ke.map(y=>{const n=l===y.value;return e.jsx("button",{type:"button",onClick:()=>t(y.value),className:se("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",n?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:p(y.labelKey)},y.value)})}),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(Y,{label:p("apiKeys.analytics.cards.total"),value:g}),e.jsx(Y,{label:p("apiKeys.analytics.cards.enabled"),value:a}),e.jsx(Y,{label:p("apiKeys.analytics.cards.active",{days:l}),value:s})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(fe,{title:p("apiKeys.analytics.charts.requests"),loading:i,empty:o===0,emptyText:p("apiKeys.analytics.empty"),option:u}),e.jsx(fe,{title:p("apiKeys.analytics.charts.tokens"),loading:i,empty:o===0,emptyText:p("apiKeys.analytics.empty"),option:j})]})]})})}function bs({filteredKeys:s,formatDate:a,hasWildcard:i,isDeleting:t,isRevealing:l,keys:u,onCopy:g,onDelete:j,onEditEndpoints:o,onFilterChange:p,onHide:y,onReveal:n,onStatusFilterChange:x,onToggleEnabled:h,restrictedCount:E,revealedKeys:T,search:w,statusFilter:q,unrestrictedCount:f,wildcardCount:M}){const{t:m}=N();return e.jsx(oe,{eyebrow:"Inventory",title:m("apiKeys.list.title"),description:i?m("apiKeys.wildcardHint"):void 0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{variant:"outline",children:`${s.length}/${u.length}`}),e.jsx(C,{variant:"outline",children:m("apiKeys.summary.wildcard",{count:M})}),e.jsx(C,{variant:"outline",children:m("apiKeys.summary.restricted",{count:E})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(Z,{label:m("apiKeys.list.title"),value:`${s.length}/${u.length}`,helper:m("apiKeys.filters.searchPlaceholder")}),e.jsx(Z,{label:m("apiKeys.summary.wildcard",{count:M}),value:String(M),helper:m("apiKeys.wildcardHint")}),e.jsx(Z,{label:m("apiKeys.summary.restricted",{count:E}),value:String(E),helper:m("apiKeys.summary.unrestricted",{count:f})})]}),e.jsxs("div",{className:"grid gap-3 rounded-lg border border-border bg-secondary p-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,360px)] xl:grid-cols-[minmax(0,1fr)_180px_auto]",children:[e.jsx($,{value:w,onChange:b=>p(b.target.value),placeholder:m("apiKeys.filters.searchPlaceholder")}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto rounded-full border border-border bg-secondary p-1",children:["all","enabled","disabled"].map(b=>e.jsx("button",{type:"button",onClick:()=>x(b),className:se("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",q===b?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:m(`apiKeys.filters.${b}`)},b))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:col-span-2 xl:col-span-1",children:[e.jsx(C,{variant:"secondary",children:m("apiKeys.summary.wildcard",{count:M})}),e.jsx(C,{variant:"secondary",children:m("apiKeys.summary.restricted",{count:E})})]})]}),u.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed border-border",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:m("apiKeys.list.empty")})}):s.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed border-border",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:m("apiKeys.list.emptyFiltered")})}):e.jsx("div",{className:"grid gap-4",children:s.map(b=>e.jsx(js,{formatDate:a,isDeleting:t===b.id,isRevealing:l===b.id,keySummary:b,onCopy:g,onDelete:j,onEditEndpoints:o,onHide:y,onReveal:n,onToggleEnabled:h,revealedValue:T.get(b.id)},b.id))})]})})}function X({description:s,icon:a,title:i}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4",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:i}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s})]})}function js({formatDate:s,isDeleting:a,isRevealing:i,keySummary:t,onCopy:l,onDelete:u,onEditEndpoints:g,onHide:j,onReveal:o,onToggleEnabled:p,revealedValue:y}){var h,E,T,w;const{t:n}=N(),x=(t.totalInputTokens+t.totalOutputTokens).toLocaleString();return t.isWildcard||(((h=t.allowedEndpoints)==null?void 0:h.length)??0)>0,e.jsx(de,{"data-testid":"api-key-card",children:e.jsx(ce,{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:t.name}),t.isWildcard?e.jsx(C,{variant:"secondary",children:n("apiKeys.wildcard")}):null,e.jsx(C,{variant:t.enabled?"default":"outline",children:t.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")}),t.isWildcard?null:e.jsx(C,{variant:"outline",className:"text-xs",children:(((E=t.allowedEndpoints)==null?void 0:E.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.allEndpoints")}),!t.isWildcard&&t.allowedEndpoints&&t.allowedEndpoints.length>0?t.allowedEndpoints.map(q=>e.jsx(C,{variant:"outline",className:"text-xs",children:q},q)):t.isWildcard?null:e.jsx(C,{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(ee,{label:n("apiKeys.requestCount"),value:t.requestCount.toLocaleString()}),e.jsx(ee,{label:n("apiKeys.totalTokens"),value:x}),e.jsx(ee,{label:n("apiKeys.maxConcurrency"),value:t.maxConcurrency?String(t.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 border border-border bg-secondary px-3 py-1.5 font-mono text-sm",children:t.isWildcard?n("apiKeys.wildcard"):y??t.maskedKey??"********"}),t.isWildcard?null:e.jsx("div",{className:"flex items-center gap-1 self-start",children:y?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(y),"aria-label":n("common.actions.copy"),title:n("common.actions.copy"),children:e.jsx(ve,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(t.id),"aria-label":n("apiKeys.actions.hide"),title:n("apiKeys.actions.hide"),children:e.jsx(we,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(t.id),disabled:i,"aria-label":n("apiKeys.actions.reveal"),title:n("apiKeys.actions.reveal"),children:i?e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(es,{className:"h-4 w-4","aria-hidden":"true"})})})]}),t.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:n("apiKeys.wildcardHint")}):t.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:t.description}):null,t.isWildcard?null:e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:(((T=t.allowedEndpoints)==null?void 0:T.length)??0)>0?`${n("apiKeys.allowedEndpoints")}: ${(w=t.allowedEndpoints)==null?void 0:w.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:s(t.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:s(t.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:flex lg:flex-wrap lg:justify-end",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>g(t),className:"w-full lg:w-auto",children:[e.jsx(Ne,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),t.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints")]}),e.jsx(K,{variant:t.enabled?"outline":"default",size:"sm",onClick:()=>p(t.id,t.enabled),className:"w-full lg:w-auto",children:t.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),t.isWildcard?null:e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-full text-destructive hover:bg-destructive/10 hover:text-destructive sm:w-9",onClick:()=>u(t),disabled:a,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(ss,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})})}function Y({label:s,value:a}){return e.jsx(de,{children:e.jsxs(ce,{className:"pt-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:s}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-foreground",children:a})]})})}function Z({helper:s,label:a,value:i}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"mt-2 text-lg font-semibold text-foreground",children:i}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]})}function ee({label:s,value:a}){return e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:a})]})}function fe({empty:s,emptyText:a,loading:i,option:t,title:l}){const{t:u}=N();return e.jsx(de,{children:e.jsxs(ce,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:l}),i?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:u("common.loadingShort")})}):s?e.jsx("div",{className:"flex h-[280px] items-center justify-center rounded-lg border border-dashed border-border",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:a})}):e.jsx(os,{echarts:ds,option:t,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}function fs(){const{t:s}=N(),{pushToast:a}=rs(),[i,t]=c.useState(!1),[l,u]=c.useState(""),[g,j]=c.useState(""),[o,p]=c.useState([]),[y,n]=c.useState(""),[x,h]=c.useState(null),[E,T]=c.useState(null),[w,q]=c.useState(null),[f,M]=_(J.apiKeys.rangeDays,7,{serialize:r=>String(r),deserialize:r=>{const d=Number(r);return ke.some(k=>k.value===d)?d:7}}),[m,b]=c.useState(new Map),[Ae,pe]=c.useState(null),[F,Q]=c.useState(null),[W,ue]=c.useState([]),[L,xe]=c.useState(""),[V,Te]=_(J.apiKeys.search,""),[P,qe]=_(J.apiKeys.statusFilter,"all",{serialize:r=>r,deserialize:r=>r==="enabled"||r==="disabled"?r:"all"}),Se=ps(),me=H(v.apiKeys.all(),A.listRequest()),Me=H(v.apiKeys.overview(f),A.overviewRequest(f)),ye=H(v.apiKeys.usage(f),A.usageRequest(f)),he=z({mutationFn:A.create,invalidateKeys:[v.apiKeys.all(),v.apiKeys.overview(f),v.apiKeys.usage(f)],successToast:()=>({title:s("apiKeys.toast.keyCreated")}),errorToast:r=>({title:s("apiKeys.toast.createFailure",{message:r.message})})}),I=z({mutationFn:({id:r,...d})=>A.update(r,d),invalidateKeys:[v.apiKeys.all(),v.apiKeys.overview(f),v.apiKeys.usage(f)],successToast:()=>({title:s("apiKeys.toast.keyUpdated")}),errorToast:r=>({title:s("apiKeys.toast.updateFailure",{message:r.message})})}),ge=z({mutationFn:({id:r})=>A.delete(r),invalidateKeys:[v.apiKeys.all(),v.apiKeys.overview(f),v.apiKeys.usage(f)],successToast:()=>({title:s("apiKeys.toast.keyDeleted")}),errorToast:r=>({title:s("apiKeys.toast.deleteFailure",{message:r.message})})}),be=z({mutationFn:({id:r})=>A.reveal(r),errorToast:r=>({title:s("apiKeys.toast.revealFailure"),description:r.message})}),S=me.data??[],R=Me.data,D=ye.data??[],Re=S.some(r=>r.isWildcard),Fe=S.filter(r=>r.isWildcard).length,Oe=S.filter(r=>{var d;return!r.isWildcard&&(((d=r.allowedEndpoints)==null?void 0:d.length)??0)>0}).length,We=S.filter(r=>{var d;return!r.isWildcard&&(((d=r.allowedEndpoints)==null?void 0:d.length)??0)===0}).length,Le=R?R.totalKeys.toLocaleString():"-",Pe=R?R.enabledKeys.toLocaleString():"-",Ie=R?R.activeKeys.toLocaleString():"-",ze=c.useMemo(()=>S.filter(r=>{if(!(P==="all"||(P==="enabled"?r.enabled:!r.enabled)))return!1;const k=V.trim().toLowerCase();return k?[r.name,r.description??"",r.maskedKey??"",...r.allowedEndpoints??[]].join(" ").toLowerCase().includes(k):!0}),[S,V,P]),He=c.useMemo(()=>{const r=D.map(d=>d.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:r,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.requestsSeries"),type:"bar",data:D.map(d=>d.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[s,D]),$e=c.useMemo(()=>{const r=D.map(d=>d.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[s("apiKeys.analytics.tokens.input"),s("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:r,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:D.map(d=>d.inputTokens)},{name:s("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:D.map(d=>d.outputTokens)}]}},[s,D]),je=c.useCallback(()=>{u(""),j(""),p([]),n("")},[]),G=c.useCallback(r=>{t(r),r||je()},[je]),Qe=c.useCallback(async()=>{if(!l.trim()){a({title:s("apiKeys.errors.nameRequired"),variant:"error"});return}try{const r=await he.mutateAsync({name:l.trim(),description:g.trim()||void 0,allowedEndpoints:o.length>0?o:void 0,maxConcurrency:y?Number(y):null});h(r),G(!1)}catch{}},[he,G,g,o,y,l,a,s]),Ve=c.useCallback(async(r,d)=>{try{await I.mutateAsync({id:r,enabled:!d})}catch{}},[I]),Ge=c.useCallback(async()=>{if(w){T(w.id);try{await ge.mutateAsync({id:w.id}),q(null)}catch{}finally{T(null)}}},[w,ge]),Be=c.useCallback(async r=>{if(!m.has(r)){pe(r);try{const d=await be.mutateAsync({id:r});b(k=>new Map(k).set(r,d.key))}catch{}finally{pe(null)}}},[be,m]),Ue=c.useCallback(r=>{b(d=>{const k=new Map(d);return k.delete(r),k})},[]),_e=c.useCallback(async r=>{try{await cs(r),a({title:s("apiKeys.toast.keyCopied"),variant:"success"})}catch(d){a({title:s("apiKeys.toast.copyFailure"),description:d instanceof Error?d.message:s("common.unknownError"),variant:"error"})}},[a,s]),Je=c.useCallback(r=>{Q(r),ue(r.allowedEndpoints??[]),xe(r.maxConcurrency?String(r.maxConcurrency):"")},[]),Xe=c.useCallback(async()=>{if(F)try{await I.mutateAsync({id:F.id,...F.isWildcard?{}:{allowedEndpoints:W.length>0?W:null},maxConcurrency:L?Number(L):null}),Q(null)}catch{}},[F,W,L,I]),Ye=c.useCallback(r=>r?new Date(r).toLocaleString():s("common.noData"),[s]);return{activeKeysValue:Ie,availableEndpoints:Se,deleteTarget:w,editEndpointsKey:F,editEndpointsSelection:W,editMaxConcurrency:L,enabledKeysValue:Pe,filteredKeys:ze,formatDate:Ye,handleCopyKey:_e,handleCreateDialogChange:G,handleCreateKey:Qe,handleDeleteKey:Ge,handleHideKey:Ue,handleOpenEditEndpoints:Je,handleRevealKey:Be,handleSaveEndpoints:Xe,handleToggleEnabled:Ve,hasWildcard:Re,isCreateDialogOpen:i,isDeleting:E,isRevealing:Ae,keys:S,keysQuery:me,newKeyDescription:g,newKeyEndpoints:o,newKeyMaxConcurrency:y,newKeyName:l,newlyCreatedKey:x,rangeDays:f,requestsChartOption:He,restrictedCount:Oe,revealedKeys:m,search:V,setDeleteTarget:q,setEditEndpointsKey:Q,setEditEndpointsSelection:ue,setEditMaxConcurrency:xe,setNewKeyDescription:j,setNewKeyEndpoints:p,setNewKeyMaxConcurrency:n,setNewKeyName:u,setNewlyCreatedKey:h,setRangeDays:M,setSearch:Te,setStatusFilter:qe,statusFilter:P,tokensChartOption:$e,totalKeysValue:Le,unrestrictedCount:We,usage:D,usageQuery:ye,wildcardCount:Fe}}function $s(){const{t:s}=N(),a=fs(),i=s("apiKeys.summary.totalCount",{count:a.keys.length});return a.keysQuery.isLoading?e.jsx(ns,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(is,{icon:e.jsx(Ke,{className:"h-5 w-5","aria-hidden":"true"}),title:s("apiKeys.title"),description:s("apiKeys.description"),eyebrow:"Access Control",breadcrumb:"Gateway / API Keys",helper:s("apiKeys.helper"),badge:i,actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:[s("apiKeys.summary.wildcard",{count:a.wildcardCount})," / ",s("apiKeys.summary.restricted",{count:a.restrictedCount})," / ",s("apiKeys.summary.unrestricted",{count:a.unrestrictedCount})]}),e.jsxs(K,{onClick:()=>a.handleCreateDialogChange(!0),className:"w-full sm:w-auto",children:[e.jsx(as,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),s("apiKeys.createNew")]})]})}),e.jsx(hs,{}),e.jsx(gs,{activeKeysValue:a.activeKeysValue,enabledKeysValue:a.enabledKeysValue,loading:a.usageQuery.isLoading,onRangeChange:a.setRangeDays,rangeDays:a.rangeDays,requestsChartOption:a.requestsChartOption,totalKeysValue:a.totalKeysValue,tokensChartOption:a.tokensChartOption,usageLength:a.usage.length}),e.jsx(bs,{filteredKeys:a.filteredKeys,formatDate:a.formatDate,hasWildcard:a.hasWildcard,isDeleting:a.isDeleting,isRevealing:a.isRevealing,keys:a.keys,onCopy:t=>void a.handleCopyKey(t),onDelete:a.setDeleteTarget,onEditEndpoints:a.handleOpenEditEndpoints,onFilterChange:a.setSearch,onHide:a.handleHideKey,onReveal:t=>void a.handleRevealKey(t),onStatusFilterChange:a.setStatusFilter,onToggleEnabled:(t,l)=>void a.handleToggleEnabled(t,l),restrictedCount:a.restrictedCount,revealedKeys:a.revealedKeys,search:a.search,statusFilter:a.statusFilter,unrestrictedCount:a.unrestrictedCount,wildcardCount:a.wildcardCount}),e.jsx(us,{availableEndpoints:a.availableEndpoints,isOpen:a.isCreateDialogOpen,keyDescription:a.newKeyDescription,keyName:a.newKeyName,maxConcurrency:a.newKeyMaxConcurrency,onDescriptionChange:a.setNewKeyDescription,onEndpointsChange:a.setNewKeyEndpoints,onKeyNameChange:a.setNewKeyName,onMaxConcurrencyChange:a.setNewKeyMaxConcurrency,onOpenChange:a.handleCreateDialogChange,onSubmit:()=>void a.handleCreateKey(),selectedEndpoints:a.newKeyEndpoints}),e.jsx(xs,{createdKey:a.newlyCreatedKey,onClose:()=>a.setNewlyCreatedKey(null),onCopy:t=>void a.handleCopyKey(t)}),e.jsx(ms,{apiKey:a.editEndpointsKey,availableEndpoints:a.availableEndpoints,maxConcurrency:a.editMaxConcurrency,onClose:()=>a.setEditEndpointsKey(null),onEndpointsChange:a.setEditEndpointsSelection,onMaxConcurrencyChange:a.setEditMaxConcurrency,onSave:()=>void a.handleSaveEndpoints(),selectedEndpoints:a.editEndpointsSelection}),e.jsx(ys,{deleteTarget:a.deleteTarget,isDeleting:a.isDeleting,onConfirm:()=>void a.handleDeleteKey(),onOpenChange:t=>{!t&&a.isDeleting===null&&a.setDeleteTarget(null)}})]})}export{$s as default};
@@ -1 +1 @@
1
- import{j as s}from"./vendor-5iCEqDpV.js";import{D as m,A as p,a as j,b as u,c as D,d as f,e as g}from"./DialogShell-BqzUE3vU.js";import{B as o}from"./index-CYeQpt9d.js";function C({open:r,onOpenChange:a,title:t,description:i,confirmLabel:n,cancelLabel:d,onConfirm:c,loading:e=!1,confirmVariant:x="destructive",children:l}){return s.jsx(m,{open:r,onOpenChange:a,children:s.jsxs(p,{className:"max-w-md",children:[s.jsxs(j,{children:[s.jsx(u,{children:t}),i?s.jsx(D,{children:i}):null]}),s.jsx(f,{className:"space-y-4",children:l?s.jsx("div",{className:"text-sm text-muted-foreground",children:l}):null}),s.jsxs(g,{children:[s.jsx(o,{variant:"outline",onClick:()=>a(!1),disabled:e,children:d}),s.jsx(o,{variant:x,onClick:()=>void c(),disabled:e,children:n})]})]})})}export{C};
1
+ import{j as s}from"./vendor-CseyjbPR.js";import{D as m,A as p,a as j,b as u,c as D,d as f,e as g}from"./DialogShell-Cdf4kRdb.js";import{B as o}from"./index-wrD5MdRi.js";function C({open:r,onOpenChange:a,title:t,description:i,confirmLabel:n,cancelLabel:d,onConfirm:c,loading:e=!1,confirmVariant:x="destructive",children:l}){return s.jsx(m,{open:r,onOpenChange:a,children:s.jsxs(p,{className:"max-w-md",children:[s.jsxs(j,{children:[s.jsx(u,{children:t}),i?s.jsx(D,{children:i}):null]}),s.jsx(f,{className:"space-y-4",children:l?s.jsx("div",{className:"text-sm text-muted-foreground",children:l}):null}),s.jsxs(g,{children:[s.jsx(o,{variant:"outline",onClick:()=>a(!1),disabled:e,children:d}),s.jsx(o,{variant:x,onClick:()=>void c(),disabled:e,children:n})]})]})})}export{C};
@@ -0,0 +1 @@
1
+ import{r as c,j as e,ab as me,ac as Me,X as Y,ad as he,ae as Ae,af as De,ag as Be,ah as xe,ai as Fe,aj as Oe,S as z,ak as $e,al as _e,V as Ge}from"./vendor-CseyjbPR.js";import{P as He}from"./PageHeader-bBBkQNPI.js";import{P as X,a as Q}from"./PageState-QEhNwS9Q.js";import{c as C,u as ze,a as Qe,b as Ue,t as Ve,s as Ke,B as U}from"./index-wrD5MdRi.js";import{S as Ye,a as Xe,b as Ze,c as Je,d as $}from"./select-C3RskPYc.js";import{E as We}from"./EChart-BlZFJiWb.js";import{P as ue}from"./PageSection-Bkk2okl7.js";import{S as et,C as tt,T as at}from"./Skeleton-CCQlvfTP.js";import{B as E}from"./badge-dFhP0Qyo.js";import{C as B,a as F}from"./card-BeBgk27f.js";import{g as de}from"./utils-BHook6QN.js";import{u as w}from"./i18n-DJXLExhE.js";import{e as st}from"./charts-core-B4zLPEwd.js";import{u as L}from"./useApiQuery-olO5q8vr.js";import{q as I}from"./queryKeys-BMvyDTQS.js";import"./query-CR1zzqi0.js";import"./router-cKa0BaP7.js";import"./radix-BMe0_WA0.js";import"./charts-react-C9hy6r5j.js";import"./charts-engine-CmnAuZWT.js";const Z=c.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:"relative w-full overflow-auto rounded-lg border border-border bg-background",children:e.jsx("table",{ref:s,className:C("w-full caption-bottom border-collapse text-sm",t),...a})}));Z.displayName="Table";const J=c.forwardRef(({className:t,...a},s)=>e.jsx("thead",{ref:s,className:C("bg-muted/35 [&_tr]:border-b [&_tr]:border-border/60",t),...a}));J.displayName="TableHeader";const W=c.forwardRef(({className:t,...a},s)=>e.jsx("tbody",{ref:s,className:C("[&_tr:last-child]:border-0",t),...a}));W.displayName="TableBody";const rt=c.forwardRef(({className:t,...a},s)=>e.jsx("tfoot",{ref:s,className:C("border-t bg-muted/45 font-medium [&>tr]:last:border-b-0",t),...a}));rt.displayName="TableFooter";const O=c.forwardRef(({className:t,...a},s)=>e.jsx("tr",{ref:s,className:C("border-b border-border/50 transition-all duration-150","hover:bg-primary/5 data-[state=selected]:bg-primary/10","group",t),...a}));O.displayName="TableRow";const b=c.forwardRef(({className:t,...a},s)=>e.jsx("th",{ref:s,className:C("h-12 px-4 text-left align-middle text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/80","[&:has([role=checkbox])]:pr-0",t),...a}));b.displayName="TableHead";const g=c.forwardRef(({className:t,...a},s)=>e.jsx("td",{ref:s,className:C("px-4 py-3.5 align-middle text-sm","[&:has([role=checkbox])]:pr-0","group-hover:text-foreground transition-colors",t),...a}));g.displayName="TableCell";const ot=c.forwardRef(({className:t,...a},s)=>e.jsx("caption",{ref:s,className:C("mt-4 text-sm text-muted-foreground",t),...a}));ot.displayName="TableCaption";const _=15e3,V=6e4,S={requests:"#2563eb",input:"#059669",output:"#ea580c",cacheRead:"#7c3aed",cacheCreation:"#e11d48",latency:"#0891b2"};function D(t,a,s){return t==null?"-":`${t.toLocaleString(void 0,s)} ${a}`}function K(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 ce(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`:`${K(a)}/s`}function nt(t){return t==null?"-":`${t.toLocaleString(void 0,{maximumFractionDigits:t>=10?0:1})}%`}function it(){return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:Array.from({length:6}).map((t,a)=>e.jsx(et,{},a))}),e.jsx("div",{className:"grid gap-6 lg:grid-cols-2",children:Array.from({length:4}).map((t,a)=>e.jsx(tt,{},a))}),e.jsx("div",{className:"rounded-lg border border-border",children:e.jsx("table",{className:"w-full",children:e.jsx("tbody",{children:Array.from({length:5}).map((t,a)=>e.jsx(at,{columns:6},a))})})})]})}function lt({dbSizeDisplay:t,memoryDisplay:a,selectedEndpointLabel:s,status:r,todayRequests:d}){const{t:i}=w();return e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.4fr)_minmax(320px,0.9fr)]",children:[e.jsx(B,{children:e.jsx(F,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"max-w-2xl space-y-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-primary/20 bg-accent px-3 py-1 text-xs font-semibold text-primary",children:[e.jsx(me,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Live Gateway"]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:s}),e.jsx("p",{className:"max-w-xl text-sm text-muted-foreground",children:i("dashboard.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(E,{variant:"outline",className:"border-[hsl(var(--success)/0.3)] bg-[hsl(var(--success-bg))] text-[hsl(var(--success)/1)]",children:i("dashboard.status.listeningLabel")}),e.jsx(E,{variant:"secondary",children:s}),e.jsxs(E,{variant:"outline",children:[i("dashboard.labels.todayRequests"),": ",d.toLocaleString()]})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3 lg:min-w-[420px] lg:flex-1",children:[e.jsx(k,{icon:e.jsx(Me,{className:"h-4 w-4","aria-hidden":"true"}),label:i("dashboard.labels.activeRequests"),value:((r==null?void 0:r.activeRequests)??0).toLocaleString()}),e.jsx(k,{icon:e.jsx(Y,{className:"h-4 w-4","aria-hidden":"true"}),label:i("dashboard.labels.requestsPerMinute"),value:((r==null?void 0:r.requestsPerMinute)??0).toLocaleString()}),e.jsx(k,{icon:e.jsx(he,{className:"h-4 w-4","aria-hidden":"true"}),label:i("dashboard.labels.outputTokensPerMinute"),value:((r==null?void 0:r.outputTokensPerMinute)??0).toLocaleString()}),e.jsx(k,{icon:e.jsx(Ae,{className:"h-4 w-4","aria-hidden":"true"}),label:i("dashboard.labels.cpu"),value:nt(r==null?void 0:r.cpuUsagePercent)}),e.jsx(k,{icon:e.jsx(De,{className:"h-4 w-4","aria-hidden":"true"}),label:i("dashboard.labels.networkIngress"),value:ce(r==null?void 0:r.networkIngressBytesPerSecond)}),e.jsx(k,{icon:e.jsx(Be,{className:"h-4 w-4","aria-hidden":"true"}),label:i("dashboard.labels.networkEgress"),value:ce(r==null?void 0:r.networkEgressBytesPerSecond)}),e.jsx(k,{icon:e.jsx(xe,{className:"h-4 w-4","aria-hidden":"true"}),label:i("dashboard.labels.database"),value:t}),e.jsx(k,{icon:e.jsx(Fe,{className:"h-4 w-4","aria-hidden":"true"}),label:i("dashboard.labels.memory"),value:a})]})]})})}),e.jsx(B,{children:e.jsx(F,{className:"pt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Gateway runtime"}),e.jsxs("p",{className:"mt-1.5 text-xl font-semibold text-foreground",children:[(r==null?void 0:r.host)??"0.0.0.0",":",(r==null?void 0:r.port)??"-"]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(A,{label:i("dashboard.labels.providers"),value:((r==null?void 0:r.providers)??0).toLocaleString()}),e.jsx(A,{label:i("dashboard.labels.activeClientAddresses"),value:((r==null?void 0:r.activeClientAddresses)??0).toLocaleString()}),e.jsx(A,{label:i("dashboard.labels.activeClientSessions"),value:((r==null?void 0:r.activeClientSessions)??0).toLocaleString()}),e.jsx(A,{label:i("dashboard.labels.uniqueClientAddressesLastHour"),value:((r==null?void 0:r.uniqueClientAddressesLastHour)??0).toLocaleString()}),e.jsx(A,{label:i("dashboard.labels.uniqueClientSessionsLastHour"),value:((r==null?void 0:r.uniqueClientSessionsLastHour)??0).toLocaleString()})]})]})})})]})}function dt({overview:t}){const{t:a}=w();return e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(q,{icon:e.jsx(Y,{className:"h-5 w-5"}),title:a("dashboard.cards.todayRequests"),value:(t==null?void 0:t.today.requests)??0,suffix:a("common.units.request"),iconClass:"bg-blue-50 text-blue-600 dark:bg-blue-950 dark:text-blue-400"}),e.jsx(q,{icon:e.jsx(Oe,{className:"h-5 w-5"}),title:a("dashboard.cards.todayInput"),value:(t==null?void 0:t.today.inputTokens)??0,suffix:a("common.units.token"),iconClass:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400"}),e.jsx(q,{icon:e.jsx(he,{className:"h-5 w-5"}),title:a("dashboard.cards.todayCacheRead"),value:(t==null?void 0:t.today.cacheReadTokens)??0,suffix:a("common.units.token"),iconClass:"bg-violet-50 text-violet-600 dark:bg-violet-950 dark:text-violet-400"}),e.jsx(q,{icon:e.jsx(me,{className:"h-5 w-5"}),title:a("dashboard.cards.todayCacheCreation"),value:(t==null?void 0:t.today.cacheCreationTokens)??0,suffix:a("common.units.token"),iconClass:"bg-rose-50 text-rose-600 dark:bg-rose-950 dark:text-rose-400"}),e.jsx(q,{icon:e.jsx(z,{className:"h-5 w-5"}),title:a("dashboard.cards.todayOutput"),value:(t==null?void 0:t.today.outputTokens)??0,suffix:a("common.units.token"),iconClass:"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-400"}),e.jsx(q,{icon:e.jsx($e,{className:"h-5 w-5"}),title:a("dashboard.cards.avgLatency"),value:(t==null?void 0:t.today.avgLatencyMs)??0,suffix:a("common.units.ms"),iconClass:"bg-cyan-50 text-cyan-600 dark:bg-cyan-950 dark:text-cyan-400"})]})}function ct({busiestDay:t,fastestTtftModel:a,topModel:s,totalRequestsInRange:r}){const{t:d}=w();return e.jsxs("div",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsx(G,{label:d("dashboard.insights.totalRequests"),value:r.toLocaleString(),hint:d("dashboard.insights.totalRequestsHint")}),e.jsx(G,{label:d("dashboard.insights.busiestDay"),value:t?t.date:"-",hint:t?d("dashboard.insights.busiestDayHint",{value:t.requestCount.toLocaleString()}):d("common.noData")}),e.jsx(G,{label:d("dashboard.insights.topModel"),value:s?`${s.provider}/${s.model}`:"-",hint:s?d("dashboard.insights.topModelHint",{value:s.requests.toLocaleString()}):d("common.noData")}),e.jsx(G,{label:d("dashboard.insights.fastestTtft"),value:a?`${a.provider}/${a.model}`:"-",hint:a?D(a.avgTtftMs,d("common.units.ms")):d("common.noData")})]})}function mt({dailyEmpty:t,dailyOption:a,dailyPending:s,models:r,modelRequestsOption:d,modelUsagePending:i,ttftOption:m,tpotOption:o}){const{t:l}=w();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(H,{title:l("dashboard.charts.requestsTitle"),description:l("dashboard.charts.requestsDesc"),loading:s,option:a,empty:t,emptyText:l("dashboard.charts.empty")}),e.jsx(H,{title:l("dashboard.charts.modelTitle"),description:l("dashboard.charts.modelDesc"),loading:i,option:d,empty:!r.length,emptyText:l("dashboard.charts.empty")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(H,{title:l("dashboard.charts.ttftTitle"),description:l("dashboard.charts.ttftDesc"),loading:i,option:m,empty:!r.some(h=>h.avgTtftMs!=null&&h.avgTtftMs>0),emptyText:l("dashboard.charts.ttftEmpty")}),e.jsx(H,{title:l("dashboard.charts.tpotTitle"),description:l("dashboard.charts.tpotDesc"),loading:i,option:o,empty:!r.some(h=>h.avgTpotMs!=null&&h.avgTpotMs>0),emptyText:l("dashboard.charts.tpotEmpty")})]})]})}function ht({models:t,loading:a}){const{t:s}=w();return e.jsx(ue,{title:s("dashboard.modelTable.title"),description:s("dashboard.modelTable.description"),children:a?e.jsx(X,{compact:!0,label:s("common.loadingShort")}):t.length===0?e.jsx(Q,{compact:!0,icon:e.jsx(z,{className:"h-5 w-5","aria-hidden":"true"}),title:s("dashboard.modelTable.empty")}):e.jsx("div",{className:"overflow-auto rounded-lg border border-border",children:e.jsxs(Z,{children:[e.jsx(J,{children:e.jsxs(O,{children:[e.jsx(b,{children:s("dashboard.modelTable.columns.model")}),e.jsx(b,{className:"text-right",children:s("dashboard.modelTable.columns.requests")}),e.jsx(b,{className:"text-right",children:s("dashboard.modelTable.columns.latency")}),e.jsx(b,{className:"text-right",children:s("dashboard.modelTable.columns.ttft")}),e.jsx(b,{className:"text-right",children:s("dashboard.modelTable.columns.tpot")})]})}),e.jsx(W,{children:t.map(r=>e.jsxs(O,{children:[e.jsx(g,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:r.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:r.model})]})}),e.jsx(g,{className:"text-right font-medium",children:r.requests.toLocaleString()}),e.jsx(g,{className:"text-right",children:D(r.avgLatencyMs,s("common.units.ms"))}),e.jsx(g,{className:"text-right",children:D(r.avgTtftMs,s("common.units.ms"))}),e.jsx(g,{className:"text-right",children:D(r.avgTpotMs,s("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${r.provider}/${r.model}`))})]})})})}function xt({records:t,loading:a}){const{t:s}=w(),r=t.map(o=>de(o,s)),d=r.filter(o=>o.tone==="success").length,i=r.filter(o=>o.tone==="error").length,m=r.filter(o=>o.tone==="pending").length;return e.jsx(ue,{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(E,{variant:"secondary",children:t.length}),e.jsxs(E,{variant:"outline",className:"border-[hsl(var(--success)/0.3)] bg-[hsl(var(--success-bg))] text-[hsl(var(--success)/1)]",children:[s("common.status.success"),": ",d]}),e.jsxs(E,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[s("common.status.error"),": ",i]}),m>0?e.jsxs(E,{variant:"outline",className:"border-amber-300/60 bg-amber-50 text-amber-700 dark:border-amber-900 dark:bg-amber-950/60 dark:text-amber-300",children:[s("common.status.pending"),": ",m]}):null]}):null,children:a?e.jsx(X,{compact:!0,label:s("dashboard.recent.loading")}):t.length===0?e.jsx(Q,{compact:!0,icon:e.jsx(Y,{className:"h-5 w-5","aria-hidden":"true"}),title:s("dashboard.recent.empty")}):e.jsx("div",{className:"overflow-auto rounded-lg border border-border",children:e.jsxs(Z,{children:[e.jsx(J,{children:e.jsxs(O,{children:[e.jsx(b,{children:s("dashboard.recent.columns.time")}),e.jsx(b,{children:s("dashboard.recent.columns.endpoint")}),e.jsx(b,{children:s("dashboard.recent.columns.provider")}),e.jsx(b,{children:s("dashboard.recent.columns.route")}),e.jsx(b,{className:"text-right",children:s("dashboard.recent.columns.latency")}),e.jsx(b,{children:s("dashboard.recent.columns.status")})]})}),e.jsx(W,{children:t.map(o=>{const l=de(o,s);return e.jsxs(O,{children:[e.jsx(g,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium",children:new Date(o.timestamp).toLocaleString()}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["#",o.id]})]})}),e.jsx(g,{children:e.jsx(E,{variant:"outline",className:"text-[11px]",children:o.endpoint==="anthropic"?s("logs.endpointAnthropic"):o.endpoint==="openai"?s("logs.endpointOpenAI"):o.endpoint})}),e.jsx(g,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:o.provider}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:o.stream?"stream":"sync"})]})}),e.jsx(g,{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:o.client_model??s("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"->"}),e.jsx("span",{className:"font-medium text-foreground",children:o.model})]}),o.error?e.jsx("span",{className:"truncate text-destructive",children:o.error}):null]})}),e.jsx(g,{className:"text-right font-medium",children:D(o.latency_ms,s("common.units.ms"))}),e.jsx(g,{children:e.jsx(E,{variant:l.variant,className:"min-w-14 justify-center",children:l.label})})]},o.id)})})]})})})}function k({icon:t,label:a,value:s}){return e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-primary/10 text-primary",children:t}),a]}),e.jsx("p",{className:"mt-2 text-lg font-semibold text-foreground",children:s})]})}function A({label:t,value:a}){return e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2.5",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-foreground",children:a})]})}function q({icon:t,iconClass:a,suffix:s,title:r,value:d}){return e.jsx(B,{children:e.jsxs(F,{className:"pt-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:r}),t?e.jsx("div",{className:C("flex h-9 w-9 items-center justify-center rounded-lg",a),children:t}):null]}),e.jsxs("p",{className:"mt-3 text-2xl font-bold text-foreground",children:[d.toLocaleString(),s?e.jsx("span",{className:"ml-1.5 text-sm font-normal text-muted-foreground",children:s}):null]})]})})}function G({label:t,value:a,hint:s}){return e.jsx(B,{children:e.jsxs(F,{className:"pt-4",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:t}),e.jsx("p",{className:"mt-2 line-clamp-1 text-sm font-semibold text-foreground",children:a}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]})})}function H({description:t,empty:a,emptyText:s,loading:r,option:d,title:i}){const{t:m}=w();return e.jsx(B,{children:e.jsxs(F,{className:"space-y-4 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:i}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:t})]}),r?e.jsx(X,{compact:!0,className:"min-h-[320px]",label:m("common.loadingShort")}):a?e.jsx(Q,{compact:!0,className:"min-h-[320px]",icon:e.jsx(z,{className:"h-5 w-5","aria-hidden":"true"}),title:s??m("dashboard.charts.empty")}):e.jsx(We,{echarts:st,option:d,className:"h-[40vh] min-h-[280px] max-h-[420px]",notMerge:!0,lazyUpdate:!0})]})})}function ut(){var ee,te,ae,se,re,oe,ne,ie;const{t}=w(),{pushToast:a}=ze(),[s,r]=Qe(Ke.dashboard.endpointFilter,"all"),[d,i]=c.useState(!1),m=s==="all"?void 0:s,o=L(I.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:V,refetchIntervalInBackground:!0}),l=L(I.stats.overview(s),{url:"/api/stats/overview",method:"GET",params:m?{endpoint:m}:void 0},{refetchInterval:_,refetchIntervalInBackground:!0}),h=L(I.stats.daily(14,s),{url:"/api/stats/daily",method:"GET",params:{days:14,...m?{endpoint:m}:{}}},{refetchInterval:V,refetchIntervalInBackground:!0}),N=L(I.stats.model(7,6,s),{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...m?{endpoint:m}:{}}},{refetchInterval:V,refetchIntervalInBackground:!0}),f=L(I.status.byEndpoint(s),{url:"/api/status",method:"GET",params:m?{endpoint:m}:void 0},{refetchInterval:_,refetchIntervalInBackground:!0}),p=L(I.db.info(),{url:"/api/db/info",method:"GET"},{refetchInterval:_,refetchIntervalInBackground:!0}),v=L(I.logs.recent(s),{url:"/api/logs",method:"GET",params:{limit:5,...m?{endpoint:m}:{}}},{refetchInterval:_,refetchIntervalInBackground:!0});c.useEffect(()=>{l.isError&&l.error&&a({title:t("dashboard.toast.overviewError"),description:l.error.message,variant:"error"})},[l.error,l.isError,a,t]),c.useEffect(()=>{h.isError&&h.error&&a({title:t("dashboard.toast.dailyError"),description:h.error.message,variant:"error"})},[h.error,h.isError,a,t]),c.useEffect(()=>{N.isError&&N.error&&a({title:t("dashboard.toast.modelError"),description:N.error.message,variant:"error"})},[N.error,N.isError,a,t]),c.useEffect(()=>{f.isError&&f.error&&a({title:t("dashboard.toast.statusError"),description:f.error.message,variant:"error"})},[f.error,f.isError,a,t]),c.useEffect(()=>{p.isError&&p.error&&a({title:t("dashboard.toast.dbError"),description:p.error.message,variant:"error"})},[p.error,p.isError,a,t]),c.useEffect(()=>{v.isError&&v.error&&a({title:t("dashboard.toast.recentError"),description:v.error.message,variant:"error"})},[v.error,v.isError,a,t]);const pe=c.useCallback(async()=>{await Promise.all([o.refetch(),l.refetch(),h.refetch(),N.refetch(),f.refetch(),p.refetch(),v.refetch()])},[o,p,h,v,N,l,f]),be=c.useCallback(async()=>{if(!d){i(!0);try{await Ue.post("/api/db/compact"),await p.refetch(),a({title:t("dashboard.toast.compactSuccess.title"),description:t("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(n){const x=Ve(n);a({title:t("dashboard.toast.compactError.title"),description:x.message,variant:"error"})}finally{i(!1)}}},[d,p,a,t]),ge=l.data,T=h.data??[],u=N.data??[],fe=f.data,R=p.data,je=((ee=v.data)==null?void 0:ee.items)??[],ye=s==="all"?t("dashboard.filters.endpointAll"):s==="anthropic"?t("dashboard.filters.endpointAnthropic"):s==="openai"?t("dashboard.filters.endpointOpenAI"):((se=(ae=(te=o.data)==null?void 0:te.endpoints)==null?void 0:ae.find(n=>n.id===s))==null?void 0:se.label)||s,Ne=T.reduce((n,x)=>n+x.requestCount,0),ve=T.reduce((n,x)=>!n||x.requestCount>n.requestCount?x:n,null),Te=u[0],Se=u.filter(n=>n.avgTtftMs!=null&&n.avgTtftMs>0).sort((n,x)=>(n.avgTtftMs??Number.POSITIVE_INFINITY)-(x.avgTtftMs??Number.POSITIVE_INFINITY))[0],Ce=o.isFetching||l.isFetching||h.isFetching||N.isFetching||f.isFetching||p.isFetching||v.isFetching,Ee=l.isPending||f.isPending||p.isPending,we=((re=l.error)==null?void 0:re.message)??((oe=f.error)==null?void 0:oe.message)??((ne=p.error)==null?void 0:ne.message)??null,ke=R?K(R.totalBytes??R.sizeBytes):"-",Re=K(R==null?void 0:R.memoryRssBytes),Le=c.useMemo(()=>{const n=T.map(y=>y.date),x=t("dashboard.charts.barRequests"),P=t("dashboard.charts.lineInput"),M=t("dashboard.charts.lineOutput"),j=t("dashboard.charts.lineCacheRead"),le=t("dashboard.charts.lineCacheCreation");return{tooltip:{trigger:"axis"},legend:{data:[x,P,M,j,le]},grid:{left:56,right:28,top:56,bottom:54},xAxis:{type:"category",data:n},yAxis:{type:"value"},series:[{name:x,type:"bar",data:T.map(y=>y.requestCount),itemStyle:{color:S.requests,borderRadius:[6,6,0,0]}},{name:P,type:"line",smooth:!0,data:T.map(y=>y.inputTokens),itemStyle:{color:S.input},lineStyle:{width:2}},{name:M,type:"line",smooth:!0,data:T.map(y=>y.outputTokens),itemStyle:{color:S.output},lineStyle:{width:2}},{name:j,type:"line",smooth:!0,data:T.map(y=>y.cacheReadTokens),itemStyle:{color:S.cacheRead},lineStyle:{width:2}},{name:le,type:"line",smooth:!0,data:T.map(y=>y.cacheCreationTokens),itemStyle:{color:S.cacheCreation},lineStyle:{width:2}}]}},[T,t]),Ie=c.useMemo(()=>{const n=u.map(j=>`${j.provider}/${j.model}`),x=t("dashboard.charts.barRequests"),P=t("dashboard.charts.lineInput"),M=t("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis"},legend:{data:[x,P,M]},grid:{left:72,right:52,top:56,bottom:96},xAxis:{type:"category",data:n,axisLabel:{rotate:28}},yAxis:[{type:"value",name:x},{type:"value",name:t("dashboard.charts.axisTokens"),position:"right"}],series:[{name:x,type:"bar",data:u.map(j=>j.requests),itemStyle:{color:S.requests,borderRadius:[6,6,0,0]}},{name:P,type:"line",yAxisIndex:1,smooth:!0,data:u.map(j=>j.inputTokens??0),itemStyle:{color:S.input}},{name:M,type:"line",yAxisIndex:1,smooth:!0,data:u.map(j=>j.outputTokens??0),itemStyle:{color:S.output}}]}},[u,t]),qe=c.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:u.map(n=>`${n.provider}/${n.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:t("dashboard.charts.ttftAxis")},series:[{name:t("dashboard.charts.ttftLabel"),type:"bar",data:u.map(n=>n.avgTtftMs??0),itemStyle:{color:S.latency,borderRadius:[6,6,0,0]}}]}),[u,t]),Pe=c.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:u.map(n=>`${n.provider}/${n.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:t("dashboard.charts.tpotAxis")},series:[{name:t("dashboard.charts.tpotLabel"),type:"bar",data:u.map(n=>n.avgTpotMs??0),itemStyle:{color:S.output,borderRadius:[6,6,0,0]}}]}),[u,t]);return{compacting:d,customEndpoints:((ie=o.data)==null?void 0:ie.endpoints)??[],daily:T,dailyOption:Le,dailyPending:h.isPending,dbInfo:R,dbSizeDisplay:ke,endpointFilter:s,fastestTtftModel:Se,handleCompact:be,handleRefresh:pe,bootstrapError:we,isBootstrapping:Ee,isRefreshing:Ce,latestLogsPending:v.isPending,memoryDisplay:Re,modelRequestsOption:Ie,modelUsagePending:N.isPending,models:u,overview:ge,recentLogs:je,selectedEndpointLabel:ye,setEndpointFilter:r,status:fe,topModel:Te,totalRequestsInRange:Ne,busiestDay:ve,ttftOption:qe,tpotOption:Pe}}function At(){var s;const{t}=w(),a=ut();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(He,{icon:e.jsx(z,{className:"h-5 w-5","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description"),badge:a.selectedEndpointLabel,eyebrow:"Operations",breadcrumb:"Gateway / Dashboard",helper:t("dashboard.charts.requestsDesc"),actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:items-center sm:justify-end",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:[t("dashboard.filters.endpoint")," · ",a.selectedEndpointLabel]}),e.jsxs(Ye,{value:a.endpointFilter,onValueChange:a.setEndpointFilter,children:[e.jsx(Xe,{className:"w-full sm:w-[168px]",children:e.jsx(Ze,{})}),e.jsxs(Je,{children:[e.jsx($,{value:"all",children:t("dashboard.filters.endpointAll")}),e.jsx($,{value:"anthropic",children:t("dashboard.filters.endpointAnthropic")}),e.jsx($,{value:"openai",children:t("dashboard.filters.endpointOpenAI")}),a.customEndpoints.map(r=>e.jsx($,{value:r.id,children:r.label||r.id},r.id))]})]}),e.jsxs(U,{variant:"outline",size:"sm",onClick:()=>void a.handleRefresh(),disabled:a.isRefreshing,className:"w-full sm:w-auto",children:[e.jsx(_e,{className:C("mr-2 h-4 w-4",a.isRefreshing&&"animate-spin"),"aria-hidden":"true"}),a.isRefreshing?t("common.actions.refreshing"):t("common.actions.refresh")]}),e.jsxs(U,{variant:"outline",size:"sm",onClick:()=>void a.handleCompact(),disabled:a.compacting,className:"w-full sm:w-auto",children:[e.jsx(xe,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a.compacting?t("dashboard.actions.compacting"):t("dashboard.actions.compact")]})]})}),a.isBootstrapping?e.jsx(it,{}):a.bootstrapError?e.jsx(Q,{icon:e.jsx(Ge,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:t("common.status.error"),description:a.bootstrapError,action:e.jsx(U,{variant:"outline",onClick:()=>void a.handleRefresh(),children:t("common.actions.refresh")})}):e.jsxs(e.Fragment,{children:[e.jsx(lt,{dbSizeDisplay:a.dbSizeDisplay,memoryDisplay:a.memoryDisplay,selectedEndpointLabel:a.selectedEndpointLabel,status:a.status,todayRequests:((s=a.overview)==null?void 0:s.today.requests)??0}),e.jsx(dt,{overview:a.overview}),e.jsx(ct,{busiestDay:a.busiestDay,fastestTtftModel:a.fastestTtftModel,topModel:a.topModel,totalRequestsInRange:a.totalRequestsInRange}),e.jsx(mt,{dailyEmpty:!a.daily.length,dailyOption:a.dailyOption,dailyPending:a.dailyPending,models:a.models,modelRequestsOption:a.modelRequestsOption,modelUsagePending:a.modelUsagePending,ttftOption:a.ttftOption,tpotOption:a.tpotOption}),e.jsx(ht,{models:a.models,loading:a.modelUsagePending}),e.jsx(xt,{records:a.recentLogs,loading:a.latestLogsPending})]})]})}export{At as default};
@@ -1 +1 @@
1
- import{r,j as t,a8 as g}from"./vendor-5iCEqDpV.js";import{F as u,G as n,H as d,J as b,K as l,M as y,O as i}from"./radix-CmyU-WBH.js";import{c as o}from"./index-CYeQpt9d.js";const k=u,N=b,c=r.forwardRef(({className:a,...e},s)=>t.jsx(i,{ref:s,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,...s},x)=>t.jsxs(N,{children:[t.jsx(c,{}),t.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-lg border bg-background p-6 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),...s,children:[e,t.jsxs(y,{className:"absolute right-4 top-4 rounded-2xl border border-transparent p-2 opacity-70 ring-offset-background transition-all hover:border-border hover:bg-accent hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(g,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));p.displayName=l.displayName;const m=({className:a,...e})=>t.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})=>t.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},s)=>t.jsx(n,{ref:s,className:o("text-lg font-semibold leading-none tracking-[-0.02em]",a),...e}));j.displayName=n.displayName;const h=r.forwardRef(({className:a,...e},s)=>t.jsx(d,{ref:s,className:o("text-sm leading-6 text-muted-foreground",a),...e}));h.displayName=d.displayName;function R({children:a,className:e}){return t.jsx(p,{className:o("gap-0 overflow-hidden p-0",e),children:a})}function A({children:a,className:e}){return t.jsx("div",{className:o("border-b border-border bg-secondary px-6 py-5",e),children:t.jsx(m,{children:a})})}function C({children:a,className:e}){return t.jsx("div",{className:o("min-h-0 overflow-y-auto px-6 py-5",e),children:a})}function z({children:a,className:e}){return t.jsx(f,{className:o("border-t border-border bg-secondary px-6 py-4",e),children:a})}export{R as A,k as D,A as a,j as b,h as c,C as d,z as e};
1
+ import{r,j as t,a8 as g}from"./vendor-CseyjbPR.js";import{F as u,G as n,H as d,J as b,K as l,M as y,O as i}from"./radix-BMe0_WA0.js";import{c as o}from"./index-wrD5MdRi.js";const k=u,N=b,c=r.forwardRef(({className:a,...e},s)=>t.jsx(i,{ref:s,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,...s},x)=>t.jsxs(N,{children:[t.jsx(c,{}),t.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-lg border bg-background p-6 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),...s,children:[e,t.jsxs(y,{className:"absolute right-4 top-4 rounded-2xl border border-transparent p-2 opacity-70 ring-offset-background transition-all hover:border-border hover:bg-accent hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(g,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));p.displayName=l.displayName;const m=({className:a,...e})=>t.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})=>t.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},s)=>t.jsx(n,{ref:s,className:o("text-lg font-semibold leading-none tracking-[-0.02em]",a),...e}));j.displayName=n.displayName;const h=r.forwardRef(({className:a,...e},s)=>t.jsx(d,{ref:s,className:o("text-sm leading-6 text-muted-foreground",a),...e}));h.displayName=d.displayName;function R({children:a,className:e}){return t.jsx(p,{className:o("gap-0 overflow-hidden p-0",e),children:a})}function A({children:a,className:e}){return t.jsx("div",{className:o("border-b border-border bg-secondary px-6 py-5",e),children:t.jsx(m,{children:a})})}function C({children:a,className:e}){return t.jsx("div",{className:o("min-h-0 overflow-y-auto px-6 py-5",e),children:a})}function z({children:a,className:e}){return t.jsx(f,{className:o("border-t border-border bg-secondary px-6 py-4",e),children:a})}export{R as A,k as D,A as a,j as b,h as c,C as d,z as e};
@@ -0,0 +1 @@
1
+ import{_ as a}from"./charts-react-C9hy6r5j.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-B4zLPEwd.js";s([l,t,i,n,o,r,$]);const e=a;export{e as E};
@@ -1 +1 @@
1
- import{r as f,j as e,aj as R,an as M,ao as I,V as T,ap as V,aq as q,ar as B,a1 as D}from"./vendor-5iCEqDpV.js";import{P as K}from"./PageHeader-DDxjKW4B.js";import{P as G}from"./PageSection-DRyQEnmK.js";import{P as Q,a as $}from"./PageState-DA98vXl7.js";import{u as H}from"./useApiQuery-BzbOtl4s.js";import{u as J,B as x,c as p}from"./index-CYeQpt9d.js";import{q as O}from"./queryKeys-BMvyDTQS.js";import{B as c}from"./badge-B-TfGxGB.js";import{C as N,a as y}from"./card-I07afQF2.js";import{I as U}from"./input-DZMeIHxj.js";import{S as _,a as W,b as X,c as Y,d as g}from"./select-BUvJR07s.js";import{u as z}from"./i18n-C7VVFIdN.js";import"./query-DxhDvnDC.js";import"./router-D8u_RlVh.js";import"./radix-CmyU-WBH.js";function Z(s){const a=Date.now()-s,n=Math.abs(a),t=60*1e3,m=60*t,u=24*m;if(n<t){const o=Math.max(Math.round(n/1e3),1);return a>=0?`${o}s ago`:`in ${o}s`}if(n<m){const o=Math.round(n/t);return a>=0?`${o}m ago`:`in ${o}m`}if(n<u){const o=Math.round(n/m);return a>=0?`${o}h ago`:`in ${o}h`}const l=Math.round(n/u);return a>=0?`${l}d ago`:`in ${l}d`}function ee(s){return new Date(s).toLocaleString()}const se={info:"secondary",warn:"outline",error:"destructive"};function pe(){var L,A,P;const{t:s}=z(),{pushToast:i}=J(),[a,n]=f.useState(null),[t,m]=f.useState({level:"",type:""}),u=f.useMemo(()=>({limit:50,cursor:a??void 0,level:t.level||void 0,type:t.type.trim()||void 0}),[a,t.level,t.type]),l=H(O.events.list(u),{url:"/api/events",method:"GET",params:u});f.useEffect(()=>{l.isError&&l.error&&i({title:s("events.toast.loadFailure",{message:l.error.message}),variant:"error"})},[l.error,l.isError,i,s]);const o=()=>{n(null),m({level:"",type:""})},d=((L=l.data)==null?void 0:L.events)??[],k=((A=l.data)==null?void 0:A.nextCursor)??null,F=l.isLoading,j=l.isFetching&&!l.isLoading,h=f.useMemo(()=>{const r=[];return t.level&&r.push(s(`events.levels.${t.level}`)),t.type.trim()&&r.push(t.type.trim()),r},[t.level,t.type,s]),C=d.filter(r=>r.level==="info").length,S=d.filter(r=>r.level==="warn").length,E=d.filter(r=>r.level==="error").length;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(K,{icon:e.jsx(M,{className:"h-5 w-5","aria-hidden":"true"}),title:s("events.title"),description:s("events.description"),eyebrow:"Audit",breadcrumb:"Gateway / Events",helper:s("events.filters.title"),badge:d.length>0?`${d.length} events`:void 0,actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:s(a?"events.actions.older":"events.actions.newest")}),e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),disabled:j,className:"w-full sm:w-auto",children:[e.jsx(R,{className:p("mr-2 h-4 w-4",j&&"animate-spin"),"aria-hidden":"true"}),s(j?"common.actions.refreshing":"common.actions.refresh")]})]})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(w,{icon:e.jsx(I,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.info"),value:C.toLocaleString(),tone:"emerald"}),e.jsx(w,{icon:e.jsx(T,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.warn"),value:S.toLocaleString(),tone:"amber"}),e.jsx(w,{icon:e.jsx(V,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.error"),value:E.toLocaleString(),tone:"rose"})]}),e.jsx(N,{"data-testid":"events-filters-card",className:"overflow-hidden",children:e.jsx(y,{className:"pt-5",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[e.jsx(q,{className:"h-4 w-4 text-primary","aria-hidden":"true"}),s("events.filters.title"),e.jsx(c,{variant:"outline",children:d.length})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("events.description")})]}),e.jsxs("div",{className:"grid gap-2 sm:flex sm:flex-wrap sm:items-center",children:[h.length>0?e.jsx(x,{variant:"ghost",size:"sm",onClick:o,className:"w-full sm:w-auto",children:s("common.actions.reset")}):null,e.jsxs(x,{variant:"outline",size:"sm",disabled:!a,onClick:()=>n(null),className:"w-full sm:w-auto",children:[e.jsx(B,{className:"mr-1 h-4 w-4","aria-hidden":"true"}),s("events.actions.newest")]}),e.jsxs(x,{variant:"outline",size:"sm",disabled:!k,onClick:()=>n(k),className:"w-full sm:w-auto",children:[s("events.actions.older"),e.jsx(D,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:flex-wrap md:items-center",children:[e.jsxs(_,{value:t.level,onValueChange:r=>{n(null),m(b=>({...b,level:r==="all"?"":r}))},children:[e.jsx(W,{className:"w-full md:w-[160px]",children:e.jsx(X,{placeholder:s("events.filters.allLevels")})}),e.jsxs(Y,{children:[e.jsx(g,{value:"all",children:s("events.filters.allLevels")}),e.jsx(g,{value:"info",children:s("events.levels.info")}),e.jsx(g,{value:"warn",children:s("events.levels.warn")}),e.jsx(g,{value:"error",children:s("events.levels.error")})]})]}),e.jsx(U,{className:"w-full md:w-[220px]",placeholder:s("events.filters.typePlaceholder"),value:t.type,onChange:r=>{n(null),m(b=>({...b,type:r.target.value}))}}),e.jsx(x,{variant:"ghost",size:"sm",onClick:o,disabled:h.length===0,className:"w-full md:w-auto",children:s("common.actions.reset")})]}),h.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(r=>e.jsx(c,{variant:"secondary",children:r},r))}):null]})})}),e.jsx(G,{title:s("events.title"),description:s(a?"events.actions.older":"events.actions.newest"),actions:d.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(c,{variant:"outline",className:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-800 dark:bg-blue-950/30 dark:text-blue-300",children:[s("events.levels.info"),": ",C]}),e.jsxs(c,{variant:"outline",className:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:[s("events.levels.warn"),": ",S]}),e.jsxs(c,{variant:"outline",className:"border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-300",children:[s("events.levels.error"),": ",E]})]}):null,children:F?e.jsx(Q,{label:s("common.loading")}):l.isError?e.jsx($,{icon:e.jsx(T,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:s("events.toast.loadFailure",{message:((P=l.error)==null?void 0:P.message)??s("common.unknownError")}),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),children:s("common.actions.refresh")})}):d.length===0?e.jsx($,{icon:e.jsx(M,{className:"h-5 w-5","aria-hidden":"true"}),tone:"primary",title:s("events.empty.title"),description:s("events.empty.subtitle"),action:h.length>0?e.jsx(x,{variant:"outline",size:"sm",onClick:o,children:s("common.actions.reset")}):void 0}):e.jsx("div",{className:"grid gap-4",children:d.map(r=>e.jsx(re,{event:r},r.id))})})]})}function w({icon:s,title:i,tone:a,value:n}){const t={emerald:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400",amber:"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-400",rose:"bg-rose-50 text-rose-600 dark:bg-rose-950 dark:text-rose-400"}[a];return e.jsx(N,{children:e.jsxs(y,{className:"flex items-center justify-between gap-3 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:i}),e.jsx("p",{className:"mt-2 text-3xl font-bold tracking-tight text-foreground",children:n})]}),e.jsx("div",{className:p("flex h-11 w-11 items-center justify-center rounded-xl",t),children:s})]})})}function re({event:s}){const{t:i}=z(),a=s.level==="error"?"border-l-destructive":s.level==="warn"?"border-l-amber-500":"border-l-emerald-500";return e.jsx(N,{className:p("overflow-hidden border-l-4",a),children:e.jsxs(y,{className:"space-y-4 pt-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-start xl:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(c,{variant:se[s.level]||"secondary",children:i(`events.levels.${s.level}`)}),e.jsxs(c,{variant:"outline",children:["#",s.id]}),s.mode?e.jsx(c,{variant:"secondary",children:s.mode}):null,s.endpoint?e.jsx(c,{variant:"outline",children:s.endpoint}):null]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold tracking-[-0.01em]",children:s.title||i("events.defaultTitle")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.message||i("events.defaultMessage")})]})]}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground xl:text-right",children:[e.jsx("p",{children:ee(s.createdAt)}),e.jsx("p",{children:Z(s.createdAt)})]})]}),e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(v,{label:"Type",value:s.type}),e.jsx(v,{label:"Source",value:s.source}),e.jsx(v,{label:"IP",value:s.ipAddress}),e.jsx(v,{label:"API Key",value:s.apiKeyName}),e.jsx(v,{label:"User Agent",value:s.userAgent,wide:!0})]}),s.details?e.jsxs("details",{className:"rounded-lg border border-border bg-secondary p-3 text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-primary",children:i("events.details")}),e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-lg border border-border bg-card p-3 text-xs leading-6",children:JSON.stringify(s.details,null,2)})]}):null]})})}function v({label:s,value:i,wide:a=!1}){return i?e.jsxs("div",{className:p("rounded-lg border border-border bg-secondary px-3 py-3",a&&"sm:col-span-2 xl:col-span-2"),children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 break-all text-sm text-foreground",children:i})]}):null}export{pe as default};
1
+ import{r as f,j as e,al as R,ap as M,aq as I,V as T,ar as V,as as q,at as B,a1 as D}from"./vendor-CseyjbPR.js";import{P as K}from"./PageHeader-bBBkQNPI.js";import{P as G}from"./PageSection-Bkk2okl7.js";import{P as Q,a as $}from"./PageState-QEhNwS9Q.js";import{u as H}from"./useApiQuery-olO5q8vr.js";import{u as J,B as x,c as p}from"./index-wrD5MdRi.js";import{q as O}from"./queryKeys-BMvyDTQS.js";import{B as c}from"./badge-dFhP0Qyo.js";import{C as N,a as y}from"./card-BeBgk27f.js";import{I as U}from"./input-BTCXiXUM.js";import{S as _,a as W,b as X,c as Y,d as g}from"./select-C3RskPYc.js";import{u as z}from"./i18n-DJXLExhE.js";import"./query-CR1zzqi0.js";import"./router-cKa0BaP7.js";import"./radix-BMe0_WA0.js";function Z(s){const a=Date.now()-s,n=Math.abs(a),t=60*1e3,m=60*t,u=24*m;if(n<t){const o=Math.max(Math.round(n/1e3),1);return a>=0?`${o}s ago`:`in ${o}s`}if(n<m){const o=Math.round(n/t);return a>=0?`${o}m ago`:`in ${o}m`}if(n<u){const o=Math.round(n/m);return a>=0?`${o}h ago`:`in ${o}h`}const l=Math.round(n/u);return a>=0?`${l}d ago`:`in ${l}d`}function ee(s){return new Date(s).toLocaleString()}const se={info:"secondary",warn:"outline",error:"destructive"};function pe(){var L,A,P;const{t:s}=z(),{pushToast:i}=J(),[a,n]=f.useState(null),[t,m]=f.useState({level:"",type:""}),u=f.useMemo(()=>({limit:50,cursor:a??void 0,level:t.level||void 0,type:t.type.trim()||void 0}),[a,t.level,t.type]),l=H(O.events.list(u),{url:"/api/events",method:"GET",params:u});f.useEffect(()=>{l.isError&&l.error&&i({title:s("events.toast.loadFailure",{message:l.error.message}),variant:"error"})},[l.error,l.isError,i,s]);const o=()=>{n(null),m({level:"",type:""})},d=((L=l.data)==null?void 0:L.events)??[],k=((A=l.data)==null?void 0:A.nextCursor)??null,F=l.isLoading,j=l.isFetching&&!l.isLoading,h=f.useMemo(()=>{const r=[];return t.level&&r.push(s(`events.levels.${t.level}`)),t.type.trim()&&r.push(t.type.trim()),r},[t.level,t.type,s]),C=d.filter(r=>r.level==="info").length,S=d.filter(r=>r.level==="warn").length,E=d.filter(r=>r.level==="error").length;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(K,{icon:e.jsx(M,{className:"h-5 w-5","aria-hidden":"true"}),title:s("events.title"),description:s("events.description"),eyebrow:"Audit",breadcrumb:"Gateway / Events",helper:s("events.filters.title"),badge:d.length>0?`${d.length} events`:void 0,actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:s(a?"events.actions.older":"events.actions.newest")}),e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),disabled:j,className:"w-full sm:w-auto",children:[e.jsx(R,{className:p("mr-2 h-4 w-4",j&&"animate-spin"),"aria-hidden":"true"}),s(j?"common.actions.refreshing":"common.actions.refresh")]})]})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(w,{icon:e.jsx(I,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.info"),value:C.toLocaleString(),tone:"emerald"}),e.jsx(w,{icon:e.jsx(T,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.warn"),value:S.toLocaleString(),tone:"amber"}),e.jsx(w,{icon:e.jsx(V,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.error"),value:E.toLocaleString(),tone:"rose"})]}),e.jsx(N,{"data-testid":"events-filters-card",className:"overflow-hidden",children:e.jsx(y,{className:"pt-5",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[e.jsx(q,{className:"h-4 w-4 text-primary","aria-hidden":"true"}),s("events.filters.title"),e.jsx(c,{variant:"outline",children:d.length})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("events.description")})]}),e.jsxs("div",{className:"grid gap-2 sm:flex sm:flex-wrap sm:items-center",children:[h.length>0?e.jsx(x,{variant:"ghost",size:"sm",onClick:o,className:"w-full sm:w-auto",children:s("common.actions.reset")}):null,e.jsxs(x,{variant:"outline",size:"sm",disabled:!a,onClick:()=>n(null),className:"w-full sm:w-auto",children:[e.jsx(B,{className:"mr-1 h-4 w-4","aria-hidden":"true"}),s("events.actions.newest")]}),e.jsxs(x,{variant:"outline",size:"sm",disabled:!k,onClick:()=>n(k),className:"w-full sm:w-auto",children:[s("events.actions.older"),e.jsx(D,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:flex-wrap md:items-center",children:[e.jsxs(_,{value:t.level,onValueChange:r=>{n(null),m(b=>({...b,level:r==="all"?"":r}))},children:[e.jsx(W,{className:"w-full md:w-[160px]",children:e.jsx(X,{placeholder:s("events.filters.allLevels")})}),e.jsxs(Y,{children:[e.jsx(g,{value:"all",children:s("events.filters.allLevels")}),e.jsx(g,{value:"info",children:s("events.levels.info")}),e.jsx(g,{value:"warn",children:s("events.levels.warn")}),e.jsx(g,{value:"error",children:s("events.levels.error")})]})]}),e.jsx(U,{className:"w-full md:w-[220px]",placeholder:s("events.filters.typePlaceholder"),value:t.type,onChange:r=>{n(null),m(b=>({...b,type:r.target.value}))}}),e.jsx(x,{variant:"ghost",size:"sm",onClick:o,disabled:h.length===0,className:"w-full md:w-auto",children:s("common.actions.reset")})]}),h.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(r=>e.jsx(c,{variant:"secondary",children:r},r))}):null]})})}),e.jsx(G,{title:s("events.title"),description:s(a?"events.actions.older":"events.actions.newest"),actions:d.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(c,{variant:"outline",className:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-800 dark:bg-blue-950/30 dark:text-blue-300",children:[s("events.levels.info"),": ",C]}),e.jsxs(c,{variant:"outline",className:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:[s("events.levels.warn"),": ",S]}),e.jsxs(c,{variant:"outline",className:"border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-300",children:[s("events.levels.error"),": ",E]})]}):null,children:F?e.jsx(Q,{label:s("common.loading")}):l.isError?e.jsx($,{icon:e.jsx(T,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:s("events.toast.loadFailure",{message:((P=l.error)==null?void 0:P.message)??s("common.unknownError")}),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),children:s("common.actions.refresh")})}):d.length===0?e.jsx($,{icon:e.jsx(M,{className:"h-5 w-5","aria-hidden":"true"}),tone:"primary",title:s("events.empty.title"),description:s("events.empty.subtitle"),action:h.length>0?e.jsx(x,{variant:"outline",size:"sm",onClick:o,children:s("common.actions.reset")}):void 0}):e.jsx("div",{className:"grid gap-4",children:d.map(r=>e.jsx(re,{event:r},r.id))})})]})}function w({icon:s,title:i,tone:a,value:n}){const t={emerald:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400",amber:"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-400",rose:"bg-rose-50 text-rose-600 dark:bg-rose-950 dark:text-rose-400"}[a];return e.jsx(N,{children:e.jsxs(y,{className:"flex items-center justify-between gap-3 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:i}),e.jsx("p",{className:"mt-2 text-3xl font-bold tracking-tight text-foreground",children:n})]}),e.jsx("div",{className:p("flex h-11 w-11 items-center justify-center rounded-xl",t),children:s})]})})}function re({event:s}){const{t:i}=z(),a=s.level==="error"?"border-l-destructive":s.level==="warn"?"border-l-amber-500":"border-l-emerald-500";return e.jsx(N,{className:p("overflow-hidden border-l-4",a),children:e.jsxs(y,{className:"space-y-4 pt-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-start xl:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(c,{variant:se[s.level]||"secondary",children:i(`events.levels.${s.level}`)}),e.jsxs(c,{variant:"outline",children:["#",s.id]}),s.mode?e.jsx(c,{variant:"secondary",children:s.mode}):null,s.endpoint?e.jsx(c,{variant:"outline",children:s.endpoint}):null]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold tracking-[-0.01em]",children:s.title||i("events.defaultTitle")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.message||i("events.defaultMessage")})]})]}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground xl:text-right",children:[e.jsx("p",{children:ee(s.createdAt)}),e.jsx("p",{children:Z(s.createdAt)})]})]}),e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(v,{label:"Type",value:s.type}),e.jsx(v,{label:"Source",value:s.source}),e.jsx(v,{label:"IP",value:s.ipAddress}),e.jsx(v,{label:"API Key",value:s.apiKeyName}),e.jsx(v,{label:"User Agent",value:s.userAgent,wide:!0})]}),s.details?e.jsxs("details",{className:"rounded-lg border border-border bg-secondary p-3 text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-primary",children:i("events.details")}),e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-lg border border-border bg-card p-3 text-xs leading-6",children:JSON.stringify(s.details,null,2)})]}):null]})})}function v({label:s,value:i,wide:a=!1}){return i?e.jsxs("div",{className:p("rounded-lg border border-border bg-secondary px-3 py-3",a&&"sm:col-span-2 xl:col-span-2"),children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 break-all text-sm text-foreground",children:i})]}):null}export{pe as default};
@@ -1,8 +1,8 @@
1
- import{r as u,j as e,aD as b,aA as N,aE as v,aF as y}from"./vendor-5iCEqDpV.js";import{P as w}from"./PageHeader-DDxjKW4B.js";import{P as a}from"./PageSection-DRyQEnmK.js";import{c as h}from"./clipboard-CALi6bTW.js";import{C as p,a as j}from"./card-I07afQF2.js";import{B as f}from"./index-CYeQpt9d.js";import{u as x}from"./i18n-C7VVFIdN.js";import"./badge-B-TfGxGB.js";import"./query-DxhDvnDC.js";import"./router-D8u_RlVh.js";import"./radix-CmyU-WBH.js";function B(){const{t:s}=x(),t=u.useMemo(()=>{const i=s("help.sections.configuration.items",{returnObjects:!0}),n=s("help.sections.claudeCodeConfig.items",{returnObjects:!0}),c=s("help.sections.codexConfig.items",{returnObjects:!0}),d=s("help.sections.usage.items",{returnObjects:!0}),g=s("help.sections.tips.items",{returnObjects:!0});return[{title:s("help.sections.configuration.title"),items:i},{title:s("help.sections.claudeCodeConfig.title"),items:n},{title:s("help.sections.codexConfig.title"),items:c},{title:s("help.sections.usage.title"),items:d},{title:s("help.sections.tips.title"),items:g}]},[s]),r=s("help.faq.items",{returnObjects:!0}),l=u.useMemo(()=>[{id:"configuration",title:t[0].title,subtitle:t[0].items[0]??""},{id:"claude",title:t[1].title,subtitle:t[1].items[0]??""},{id:"codex",title:t[2].title,subtitle:t[2].items[0]??""},{id:"faq",title:s("help.faq.title"),subtitle:`${r.length} FAQ`}],[r.length,t,s]);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w,{icon:e.jsx(b,{className:"h-5 w-5","aria-hidden":"true"}),title:s("help.title"),description:s("help.intro"),eyebrow:"Guided Setup",breadcrumb:"Gateway / Help",helper:s("help.helper"),badge:`${t.length} guides`}),e.jsx(p,{children:e.jsxs(j,{className:"flex items-start gap-4 pt-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-accent text-primary",children:e.jsx(N,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.note")})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:l.map(i=>e.jsxs("a",{href:`#help-${i.id}`,className:"rounded-lg border border-border bg-card px-4 py-4 transition hover:bg-accent/50",children:[e.jsx("p",{className:"text-sm font-semibold",children:i.title}),e.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-muted-foreground",children:i.subtitle})]},i.id))}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{id:"help-configuration",children:e.jsx(a,{eyebrow:"01",title:t[0].title,children:e.jsx(o,{items:t[0].items})})}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold",children:s("help.clientConfig.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.clientConfig.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsxs(a,{eyebrow:"02",title:t[1].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-secondary p-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-primary-foreground",children:e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Claude Code"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"IDE / Desktop workflow"})]})]}),e.jsx(o,{items:t[1].items})]})}),e.jsx("div",{id:"help-codex",children:e.jsxs(a,{eyebrow:"03",title:t[2].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-secondary p-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-600 text-white",children:e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Codex CLI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Terminal workflow"})]})]}),e.jsx(o,{items:t[2].items})]})})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"mb-6 space-y-1 text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("help.advancedGuide.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.advancedGuide.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(a,{eyebrow:"04",title:t[3].title,children:e.jsx(o,{items:t[3].items})}),e.jsx(a,{eyebrow:"05",title:t[4].title,children:e.jsx(o,{items:t[4].items})})]})]})]}),e.jsx("div",{id:"help-faq",children:e.jsx(a,{eyebrow:"FAQ",title:s("help.faq.title"),children:e.jsx(q,{items:r})})})]})}function o({items:s}){return e.jsx("ol",{className:"flex flex-col gap-3",children:s.map((t,r)=>e.jsxs("li",{className:"flex gap-3 rounded-lg border border-border bg-card p-3",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-xl bg-primary text-xs font-medium text-primary-foreground",children:r+1}),e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:e.jsx(C,{content:t})})]},`${r}-${t}`))})}function C({content:s}){const{t}=x();if(s.includes("```")){const r=s.split("```");return e.jsx("div",{className:"space-y-2",children:r.map((l,i)=>{if(i%2===0)return l?e.jsx("div",{className:"whitespace-pre-line",children:m(l)},i):null;{const[n,...c]=l.split(`
1
+ import{r as u,j as e,aF as b,aC as N,aG as v,aH as y}from"./vendor-CseyjbPR.js";import{P as w}from"./PageHeader-bBBkQNPI.js";import{P as a}from"./PageSection-Bkk2okl7.js";import{c as h}from"./clipboard-CALi6bTW.js";import{C as p,a as j}from"./card-BeBgk27f.js";import{B as f}from"./index-wrD5MdRi.js";import{u as x}from"./i18n-DJXLExhE.js";import"./badge-dFhP0Qyo.js";import"./query-CR1zzqi0.js";import"./router-cKa0BaP7.js";import"./radix-BMe0_WA0.js";function A(){const{t:s}=x(),t=u.useMemo(()=>{const i=s("help.sections.configuration.items",{returnObjects:!0}),n=s("help.sections.claudeCodeConfig.items",{returnObjects:!0}),c=s("help.sections.codexConfig.items",{returnObjects:!0}),d=s("help.sections.usage.items",{returnObjects:!0}),g=s("help.sections.tips.items",{returnObjects:!0});return[{title:s("help.sections.configuration.title"),items:i},{title:s("help.sections.claudeCodeConfig.title"),items:n},{title:s("help.sections.codexConfig.title"),items:c},{title:s("help.sections.usage.title"),items:d},{title:s("help.sections.tips.title"),items:g}]},[s]),r=s("help.faq.items",{returnObjects:!0}),l=u.useMemo(()=>[{id:"configuration",title:t[0].title,subtitle:t[0].items[0]??""},{id:"claude",title:t[1].title,subtitle:t[1].items[0]??""},{id:"codex",title:t[2].title,subtitle:t[2].items[0]??""},{id:"faq",title:s("help.faq.title"),subtitle:`${r.length} FAQ`}],[r.length,t,s]);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w,{icon:e.jsx(b,{className:"h-5 w-5","aria-hidden":"true"}),title:s("help.title"),description:s("help.intro"),eyebrow:"Guided Setup",breadcrumb:"Gateway / Help",helper:s("help.helper"),badge:`${t.length} guides`}),e.jsx(p,{children:e.jsxs(j,{className:"flex items-start gap-4 pt-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-accent text-primary",children:e.jsx(N,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.note")})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:l.map(i=>e.jsxs("a",{href:`#help-${i.id}`,className:"rounded-lg border border-border bg-card px-4 py-4 transition hover:bg-accent/50",children:[e.jsx("p",{className:"text-sm font-semibold",children:i.title}),e.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-muted-foreground",children:i.subtitle})]},i.id))}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{id:"help-configuration",children:e.jsx(a,{eyebrow:"01",title:t[0].title,children:e.jsx(o,{items:t[0].items})})}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold",children:s("help.clientConfig.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.clientConfig.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsxs(a,{eyebrow:"02",title:t[1].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-secondary p-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-primary-foreground",children:e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Claude Code"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"IDE / Desktop workflow"})]})]}),e.jsx(o,{items:t[1].items})]})}),e.jsx("div",{id:"help-codex",children:e.jsxs(a,{eyebrow:"03",title:t[2].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-secondary p-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-600 text-white",children:e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Codex CLI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Terminal workflow"})]})]}),e.jsx(o,{items:t[2].items})]})})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"mb-6 space-y-1 text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("help.advancedGuide.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.advancedGuide.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(a,{eyebrow:"04",title:t[3].title,children:e.jsx(o,{items:t[3].items})}),e.jsx(a,{eyebrow:"05",title:t[4].title,children:e.jsx(o,{items:t[4].items})})]})]})]}),e.jsx("div",{id:"help-faq",children:e.jsx(a,{eyebrow:"FAQ",title:s("help.faq.title"),children:e.jsx(q,{items:r})})})]})}function o({items:s}){return e.jsx("ol",{className:"flex flex-col gap-3",children:s.map((t,r)=>e.jsxs("li",{className:"flex gap-3 rounded-lg border border-border bg-card p-3",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-xl bg-primary text-xs font-medium text-primary-foreground",children:r+1}),e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:e.jsx(C,{content:t})})]},`${r}-${t}`))})}function C({content:s}){const{t}=x();if(s.includes("```")){const r=s.split("```");return e.jsx("div",{className:"space-y-2",children:r.map((l,i)=>{if(i%2===0)return l?e.jsx("div",{className:"whitespace-pre-line",children:m(l)},i):null;{const[n,...c]=l.split(`
2
2
  `),d=c.join(`
3
3
  `);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n||"bash"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>h(d),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-lg border border-border bg-secondary p-3 text-xs",children:e.jsx("code",{children:d})})]},i)}})})}return s.includes(`
4
4
  `)?e.jsx("div",{className:"whitespace-pre-line",children:m(s)}):e.jsx("div",{children:m(s)})}function m(s){return s.split(/(\*\*[^*]+\*\*)/g).map((r,l)=>r.startsWith("**")&&r.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:r.slice(2,-2)},l):e.jsx("span",{children:r},l))}function q({items:s}){return s.length===0?null:e.jsx("dl",{className:"flex flex-col gap-3",children:s.map(t=>e.jsx(p,{children:e.jsxs(j,{className:"pt-4",children:[e.jsx("dt",{className:"text-sm font-medium",children:t.q}),e.jsx("dd",{className:"mt-2 text-sm text-muted-foreground",children:e.jsx(k,{content:t.a})})]})},t.q))})}function k({content:s}){const{t}=x();if(s.includes("1)")||s.includes("2)")){const r=s.split(`
5
5
  `).filter(i=>i.trim());if(r.some(i=>/^\d+\)/.test(i.trim())))return e.jsx("div",{className:"space-y-1",children:r.map((i,n)=>{const c=i.match(/^\d+\)\s*(.*)/);return c?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"•"}),e.jsx("span",{children:c[1]})]},n):e.jsx("div",{children:i},n)})})}if(s.includes("```")){const r=s.split("```");return e.jsx("div",{className:"space-y-2",children:r.map((l,i)=>{if(i%2===0)return l?e.jsx("div",{className:"whitespace-pre-line",children:l},i):null;{const[n,...c]=l.split(`
6
6
  `),d=c.join(`
7
7
  `);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n||"bash"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>h(d),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-lg border border-border bg-secondary p-3 text-xs",children:e.jsx("code",{children:d})})]},i)}})})}return s.includes(`
8
- `)?e.jsx("div",{className:"whitespace-pre-line",children:s}):e.jsx("div",{children:s})}export{B as default};
8
+ `)?e.jsx("div",{className:"whitespace-pre-line",children:s}):e.jsx("div",{children:s})}export{A as default};
@@ -1 +1 @@
1
- import{r as n,j as e,ao as S,aG as E}from"./vendor-5iCEqDpV.js";import{i as k,L as F,B as L}from"./index-CYeQpt9d.js";import{C as j,a as b,b as G,c as P,d as T,e as A}from"./card-I07afQF2.js";import{I as N}from"./input-DZMeIHxj.js";import{L as y}from"./label-DZr7itdg.js";import{u as B}from"./i18n-C7VVFIdN.js";import{c as D,u as I}from"./router-D8u_RlVh.js";import"./query-DxhDvnDC.js";import"./radix-CmyU-WBH.js";function O(){const{t:s}=B(),a=D(),l=I(),{authEnabled:o,isAuthenticated:u,loading:d,login:w,error:x}=k(),[i,p]=n.useState({username:"",password:""}),[h,m]=n.useState(null),[f,g]=n.useState(!1),c=n.useMemo(()=>{var t;const r=l.state;return((t=r==null?void 0:r.from)==null?void 0:t.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 r=>{if(r.preventDefault(),m(null),!i.username.trim()||!i.password){m(s("login.validation.required"));return}g(!0);try{await w(i.username.trim(),i.password),a(c,{replace:!0})}catch(t){m(t instanceof Error?t.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(b,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(F,{})})})}):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 border border-primary/20 bg-accent 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(v,{icon:e.jsx(S,{className:"h-5 w-5","aria-hidden":"true"}),title:s("login.hint"),description:s("about.support.tip")}),e.jsx(v,{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(G,{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(P,{className:"text-xl",children:s("login.title")}),e.jsx(T,{children:s("login.description")})]}),e.jsx(b,{children:e.jsxs("form",{className:"space-y-4",onSubmit:C,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(N,{id:"username",value:i.username,autoComplete:"username",autoFocus:!0,onChange:r=>p(t=>({...t,username:r.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(N,{id:"password",type:"password",value:i.password,autoComplete:"current-password",onChange:r=>p(t=>({...t,password:r.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),h||x?e.jsx("div",{className:"rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:h||x}):null,e.jsx(L,{type:"submit",className:"w-full",disabled:f,children:s(f?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(A,{className:"justify-center pt-2",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})]})}):null}function v({description:s,icon:a,title:l}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-4",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
+ import{r as n,j as e,aq as S,aI as E}from"./vendor-CseyjbPR.js";import{i as k,L as F,B as L}from"./index-wrD5MdRi.js";import{C as j,a as b,b as I,c as P,d as T,e as q}from"./card-BeBgk27f.js";import{I as N}from"./input-BTCXiXUM.js";import{L as y}from"./label-DjpX-mjh.js";import{u as A}from"./i18n-DJXLExhE.js";import{c as B,u as D}from"./router-cKa0BaP7.js";import"./query-CR1zzqi0.js";import"./radix-BMe0_WA0.js";function O(){const{t:s}=A(),a=B(),l=D(),{authEnabled:o,isAuthenticated:u,loading:d,login:w,error:x}=k(),[i,p]=n.useState({username:"",password:""}),[h,m]=n.useState(null),[f,g]=n.useState(!1),c=n.useMemo(()=>{var t;const r=l.state;return((t=r==null?void 0:r.from)==null?void 0:t.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 r=>{if(r.preventDefault(),m(null),!i.username.trim()||!i.password){m(s("login.validation.required"));return}g(!0);try{await w(i.username.trim(),i.password),a(c,{replace:!0})}catch(t){m(t instanceof Error?t.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(b,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(F,{})})})}):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 border border-primary/20 bg-accent 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(v,{icon:e.jsx(S,{className:"h-5 w-5","aria-hidden":"true"}),title:s("login.hint"),description:s("about.support.tip")}),e.jsx(v,{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(I,{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(P,{className:"text-xl",children:s("login.title")}),e.jsx(T,{children:s("login.description")})]}),e.jsx(b,{children:e.jsxs("form",{className:"space-y-4",onSubmit:C,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(N,{id:"username",value:i.username,autoComplete:"username",autoFocus:!0,onChange:r=>p(t=>({...t,username:r.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(N,{id:"password",type:"password",value:i.password,autoComplete:"current-password",onChange:r=>p(t=>({...t,password:r.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),h||x?e.jsx("div",{className:"rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:h||x}):null,e.jsx(L,{type:"submit",className:"w-full",disabled:f,children:s(f?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(q,{className:"justify-center pt-2",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})]})}):null}function v({description:s,icon:a,title:l}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-4",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};
@@ -0,0 +1 @@
1
+ import{r as f,j as e,am as We,an as Ge,a8 as Je,ao as Xe,al as Ze,V as Ye,T as et}from"./vendor-CseyjbPR.js";import{P as tt}from"./PageHeader-bBBkQNPI.js";import{c as v,B as E,b as st,u as ge,s as C,t as lt,a as T}from"./index-wrD5MdRi.js";import{B as M}from"./badge-dFhP0Qyo.js";import{C as Ee,a as _e}from"./card-BeBgk27f.js";import{I as ue}from"./input-BTCXiXUM.js";import{L as I}from"./label-DjpX-mjh.js";import{S as ee,a as te,b as se,c as le,d as L}from"./select-C3RskPYc.js";import{u as K}from"./i18n-DJXLExhE.js";import{D as at,A as rt,a as ot,b as it,c as nt,d as dt}from"./DialogShell-Cdf4kRdb.js";import{P as ct,a as xe}from"./PageState-QEhNwS9Q.js";import{c as mt}from"./clipboard-CALi6bTW.js";import{u as $}from"./useApiQuery-olO5q8vr.js";import{q as U}from"./queryKeys-BMvyDTQS.js";import{g as De,f as O,a as Fe,b as pt,c as z,d as ut,e as xt}from"./utils-BHook6QN.js";import{P as gt,a as ht,b as ft}from"./popover-Brp8rADW.js";import{T as bt}from"./Skeleton-CCQlvfTP.js";import{g as Se}from"./gateway-DWOrDCuI.js";import"./query-CR1zzqi0.js";import"./router-cKa0BaP7.js";import"./radix-BMe0_WA0.js";function yt({apiKeys:l,selected:t,onChange:i,disabled:n,className:c}){const{t:s}=K(),[r,h]=f.useState(!1),p=f.useRef(null);f.useEffect(()=>{if(!r)return;const o=a=>{var d;(d=p.current)!=null&&d.contains(a.target)||h(!1)};return window.addEventListener("mousedown",o),()=>window.removeEventListener("mousedown",o)},[r]);const j=f.useMemo(()=>{if(t.length===0)return[];const o=new Map;for(const a of l)o.set(a.id,a);return t.map(a=>{const d=o.get(a);return d?d.isWildcard?s("apiKeys.wildcard"):d.name:null}).filter(a=>!!a)},[l,t,s]),u=t.length===0?s("logs.filters.apiKeyAll"):s("logs.filters.apiKeySelected",{count:t.length}),y=o=>{t.includes(o)?i(t.filter(a=>a!==o)):i([...t,o])};return e.jsxs("div",{className:v("relative space-y-2",c),ref:p,children:[e.jsx(I,{children:s("logs.filters.apiKey")}),e.jsxs("button",{type:"button",onClick:()=>h(o=>!o),disabled:n||l.length===0,title:s("logs.filters.apiKeyHint"),className:v("flex h-10 w-full items-center justify-between rounded-md 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",t.length>0&&"border-primary",r&&"ring-2 ring-ring ring-offset-2"),children:[e.jsxs("span",{className:"truncate",children:[u,j.length>0&&e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:j.join(", ")})]}),e.jsx("svg",{className:v("h-4 w-4 opacity-50 transition-transform",r&&"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"})})]}),r&&e.jsxs("div",{className:"absolute left-0 top-full z-30 mt-2 w-64 rounded-md border bg-popover p-2 shadow-md",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-secondary px-3 py-2 text-xs",children:[e.jsx("span",{children:u}),e.jsx("button",{type:"button",onClick:()=>i([]),disabled:t.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:[l.map(o=>{const a=o.isWildcard?s("apiKeys.wildcard"):o.name,d=t.includes(o.id);return e.jsxs("label",{className:v("flex cursor-pointer items-center gap-2 rounded-xl px-3 py-2 text-sm transition hover:bg-primary/5",d&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-border",checked:d,onChange:()=>y(o.id)}),e.jsx("span",{className:"truncate",children:a})]},o.id)}),l.length===0&&e.jsx("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:s("logs.filters.apiKeyAll")})]})]})]})}function jt(l){const{t}=K(),{total:i,activeFilters:n,filtersExpanded:c,setFiltersExpanded:s,handleResetFilters:r,activeQuickView:h,applyQuickView:p,providerFilter:j,setProviderFilter:u,endpointFilter:y,setEndpointFilter:o,selectedApiKeys:a,setSelectedApiKeys:d,modelFilter:k,setModelFilter:x,statusFilter:R,setStatusFilter:D,fromDate:S,setFromDate:_,toDate:w,setToDate:b,providerOptions:B,apiKeys:re,apiKeysLoading:oe,customEndpoints:W}=l;return e.jsx(Ee,{"data-testid":"logs-filters-card",className:"overflow-hidden",children:e.jsxs(_e,{className:"pt-4",children:[e.jsxs("div",{className:"flex flex-col gap-4",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:t("logs.filtersTitle")}),e.jsx(M,{variant:"outline",children:t("logs.summary.total",{value:i.toLocaleString()})}),n.length>0&&e.jsx(M,{variant:"secondary",children:t("common.filters.activeCount",{count:n.length})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("logs.filtersDescription")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n.length>0&&e.jsx(E,{variant:"ghost",size:"sm",onClick:r,children:t("common.actions.reset")}),e.jsx(E,{variant:"ghost",size:"sm",onClick:()=>s(g=>!g),children:c?e.jsxs(e.Fragment,{children:[t("common.filters.collapse"),e.jsx(We,{className:"ml-1 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:[t("common.filters.expand"),e.jsx(Ge,{className:"ml-1 h-4 w-4"})]})})]})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx("div",{className:"flex min-h-[52px] items-center rounded-lg border border-border bg-secondary px-3 py-2",children:n.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.map(g=>e.jsxs(M,{variant:"secondary",role:"button",tabIndex:0,className:"cursor-pointer gap-1 border border-transparent bg-primary/10 text-primary hover:bg-destructive/10 hover:text-destructive",onClick:g.onRemove,onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),g.onRemove())},children:[g.label,e.jsx(Je,{className:"h-3 w-3","aria-hidden":"true"})]},g.key))}):e.jsx("span",{className:"text-sm text-muted-foreground",children:t("common.filters.allRequests")})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 lg:min-w-[360px]",children:[e.jsx(Y,{label:t("common.filters.activeCount",{count:n.length}),value:n.length.toString()}),e.jsx(Y,{label:t("logs.filters.apiKey"),value:a.length.toString()}),e.jsx(Y,{label:t("logs.filters.provider"),value:j==="all"?t("common.noData"):"1"}),e.jsx(Y,{label:t("logs.filters.endpoint"),value:y==="all"?t("common.noData"):"1"})]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-border bg-secondary p-2",children:["all","errors","today","anthropic","openai"].map(g=>e.jsx(E,{variant:h===g?"default":"outline",size:"sm",className:v("rounded-full border-transparent",h===g&&g==="all"&&"bg-foreground text-background hover:bg-foreground/90",h===g&&g==="errors"&&"bg-rose-500 text-white hover:bg-rose-500/90",h===g&&g==="today"&&"bg-emerald-500 text-white hover:bg-emerald-500/90",h===g&&(g==="anthropic"||g==="openai")&&"bg-amber-500 text-white hover:bg-amber-500/90"),onClick:()=>p(g),children:t(`logs.quickViews.${g}`)},g))})]}),c&&e.jsxs("div",{className:"mt-4 grid gap-4 rounded-lg border border-border bg-secondary p-4 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(I,{children:t("logs.filters.provider")}),e.jsxs(ee,{value:j,onValueChange:u,children:[e.jsx(te,{children:e.jsx(se,{})}),e.jsxs(le,{children:[e.jsx(L,{value:"all",children:t("logs.filters.providerAll")}),B.map(g=>e.jsx(L,{value:g.id,children:g.label??g.id},g.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:t("logs.filters.endpoint")}),e.jsxs(ee,{value:y,onValueChange:o,children:[e.jsx(te,{children:e.jsx(se,{})}),e.jsxs(le,{children:[e.jsx(L,{value:"all",children:t("logs.filters.endpointAll")}),e.jsx(L,{value:"anthropic",children:t("logs.filters.endpointAnthropic")}),e.jsx(L,{value:"openai",children:t("logs.filters.endpointOpenAI")}),W==null?void 0:W.map(g=>e.jsx(L,{value:g.id,children:g.label||g.id},g.id))]})]})]}),e.jsx(yt,{className:"md:col-span-2",apiKeys:re,selected:a,disabled:oe,onChange:d}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:t("logs.filters.modelId")}),e.jsx(ue,{value:k,onChange:g=>x(g.target.value),placeholder:t("logs.filters.modelPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:t("logs.filters.status")}),e.jsxs(ee,{value:R,onValueChange:g=>D(g),children:[e.jsx(te,{children:e.jsx(se,{})}),e.jsxs(le,{children:[e.jsx(L,{value:"all",children:t("logs.filters.statusAll")}),e.jsx(L,{value:"success",children:t("logs.filters.statusSuccess")}),e.jsx(L,{value:"error",children:t("logs.filters.statusError")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:t("logs.filters.startDate")}),e.jsx(ue,{type:"date",value:S,onChange:g=>_(g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{children:t("logs.filters.endDate")}),e.jsx(ue,{type:"date",value:w,onChange:g=>b(g.target.value)})]})]})]})})}function Y({label:l,value:t}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card px-3 py-2",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:l}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-foreground",children:t})]})}const he={listRequest(l){return{url:"/api/logs",method:"GET",params:l}},detailRequest(l){return{url:l===null?"":`/api/logs/${l}`,method:"GET"}},async exportArchive(l,t){const i=await st.post("/api/logs/export",l,{responseType:"blob",timeout:t});return new Blob([i.data],{type:"application/zip"})}};function vt({apiKeyMap:l,logId:t,open:i,providerLabelMap:n}){var o;const{t:c}=K(),{pushToast:s}=ge(),r=$(U.logs.detail(t),he.detailRequest(t),{enabled:i&&t!==null,staleTime:3e4});f.useEffect(()=>{!r.isError||!r.error||s({title:c("logs.detail.loadError"),description:r.error.message,variant:"error"})},[r.error,r.isError,s,c]);const h=f.useCallback(async(a,d,k)=>{if(!d){s({title:c("logs.detail.copy.empty",{label:a}),variant:"info"});return}try{await mt(d),s({title:c(k),variant:"success"})}catch(x){s({title:c("logs.detail.copy.failure"),description:x instanceof Error?x.message:c("logs.detail.copy.failureFallback"),variant:"error"})}},[s,c]),p=r.data,j=p?n.get(p.provider)??p.provider:"",u=p&&p.api_key_id!=null?l.get(p.api_key_id):void 0,y=p?De(p,c):null;return{apiKeyMeta:u,errorMessage:r.isError?((o=r.error)==null?void 0:o.message)??null:null,handleCopy:h,isError:r.isError,isPending:r.isPending,providerLabel:j,refetch:r.refetch,record:p,statusMeta:y}}function Nt({open:l,logId:t,onClose:i,providerLabelMap:n,apiKeyMap:c}){var x,R,D,S,_,w;const{t:s}=K(),{apiKeyMeta:r,errorMessage:h,handleCopy:p,isError:j,isPending:u,providerLabel:y,refetch:o,record:a,statusMeta:d}=vt({apiKeyMap:c,logId:t,open:l,providerLabelMap:n}),k=a?[{key:"client-request",title:s("logs.detail.payload.clientRequest"),value:((x=a.payload)==null?void 0:x.client_request)??null,emptyLabel:s("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"},...(R=a.payload)!=null&&R.upstream_request?[{key:"upstream-request",title:s("logs.detail.payload.upstreamRequest"),value:a.payload.upstream_request,emptyLabel:s("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"}]:[],...(D=a.payload)!=null&&D.upstream_response?[{key:"upstream-response",title:s("logs.detail.payload.upstreamResponse"),value:a.payload.upstream_response,emptyLabel:s("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}]:[],{key:"client-response",title:s("logs.detail.payload.clientResponse"),value:((S=a.payload)==null?void 0:S.client_response)??null,emptyLabel:s("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}]:[];return e.jsx(at,{open:l,onOpenChange:b=>{b||i()},children:e.jsxs(rt,{className:"w-[min(96vw,1200px)] max-w-[1200px]",children:[e.jsxs(ot,{className:"pr-14",children:[e.jsx(it,{children:s("logs.detail.title")}),e.jsx(nt,{children:a?s("logs.detail.id",{id:a.id}):s("logs.detail.loadError")})]}),e.jsx(dt,{className:"max-h-[78vh]",children:u?e.jsx(ct,{compact:!0,className:"min-h-[240px]",label:s("common.loading")}):j?e.jsx(xe,{compact:!0,className:"min-h-[240px]",tone:"danger",title:s("logs.detail.loadError"),description:h??s("common.unknownError"),action:e.jsx(E,{variant:"outline",onClick:()=>void o(),children:s("common.actions.refresh")})}):a?e.jsxs("div",{className:"space-y-6 text-sm",children:[e.jsxs("section",{className:"space-y-4 rounded-lg border border-border bg-card p-5",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 border-border bg-secondary p-3 text-xs",children:[e.jsx("span",{className:"font-medium",children:s("logs.detail.summary.route",{from:a.client_model??s("logs.detail.info.noRequestedModel"),to:a.model})}),e.jsx("span",{className:"text-muted-foreground",children:s("logs.detail.summary.latency",{value:O(a.latency_ms,s("common.units.ms"))})}),a.ttft_ms!==null?e.jsxs("span",{className:"text-muted-foreground",children:["TTFT: ",O(a.ttft_ms,s("common.units.ms"))]}):null]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(M,{variant:d==null?void 0:d.variant,children:(d==null?void 0:d.label)??"-"}),e.jsx(M,{variant:"outline",children:a.stream?s("logs.stream.streaming"):s("logs.stream.single")})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsx(A,{label:s("logs.detail.info.latency"),value:O(a.latency_ms,s("common.units.ms"))}),e.jsx(A,{label:s("logs.detail.info.ttft"),value:O(a.ttft_ms,s("common.units.ms"))}),e.jsx(A,{label:s("logs.detail.info.tpot"),value:O(a.tpot_ms,s("common.units.msPerToken"))}),e.jsx(A,{label:s("logs.detail.info.status"),value:(d==null?void 0:d.label)??"-"})]}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsx(F,{label:s("logs.detail.info.time"),value:Fe(a.timestamp)}),e.jsx(F,{label:s("logs.detail.info.sessionId"),value:a.session_id??"-"}),e.jsx(F,{label:s("logs.detail.info.endpoint"),value:a.endpoint||"-"}),e.jsx(F,{label:s("logs.detail.info.provider"),value:y}),e.jsx(F,{label:s("logs.detail.info.requestedModel"),value:a.client_model??s("logs.detail.info.noRequestedModel")}),e.jsx(F,{label:s("logs.detail.info.model"),value:a.model}),e.jsx(F,{label:s("logs.detail.info.stream"),value:pt(a.stream)}),e.jsx(F,{label:s("logs.detail.info.status"),value:(d==null?void 0:d.label)??"-"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(A,{label:s("logs.detail.info.inputTokens"),value:z(a.input_tokens)}),e.jsx(A,{label:s("logs.detail.info.cacheReadTokens"),value:z(a.cache_read_tokens)}),e.jsx(A,{label:s("logs.detail.info.cacheCreationTokens"),value:z(a.cache_creation_tokens)}),e.jsx(A,{label:s("logs.detail.info.outputTokens"),value:z(a.output_tokens)})]}),a.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-[1rem] border border-destructive/50 bg-destructive/10 p-3 text-xs text-destructive",children:a.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 border-border bg-card p-5",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(F,{label:s("logs.detail.apiKey.name"),value:a.api_key_id==null&&!a.api_key_name?s("logs.detail.apiKey.missing"):r!=null&&r.isWildcard?s("apiKeys.wildcard"):(r==null?void 0:r.name)??a.api_key_name??s("logs.detail.apiKey.missing")}),e.jsx(F,{label:s("logs.detail.apiKey.identifier"),value:a.api_key_id??s("common.noData")}),e.jsx(F,{label:s("logs.detail.apiKey.masked"),value:r!=null&&r.isWildcard?s("apiKeys.wildcard"):(r==null?void 0:r.maskedKey)??a.api_key_name??s("logs.detail.apiKey.maskedUnavailable")}),e.jsx(F,{label:s("logs.detail.apiKey.lastUsed"),value:r!=null&&r.lastUsedAt?new Date(r.lastUsedAt).toLocaleString():s("common.noData")})]}),e.jsxs("div",{className:"rounded-lg border border-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:a.api_key_value_available?a.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 border-border bg-card p-5",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:(_=a.payload)!=null&&_.upstream_request||(w=a.payload)!=null&&w.upstream_response?s("logs.detail.payload.helperWithUpstream"):s("logs.detail.payload.helperClientOnly")})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:k.map(b=>e.jsx(wt,{title:b.title,value:b.value,emptyLabel:b.emptyLabel,onCopy:()=>p(b.title,b.value,b.copyToast),t:s},b.key))})]})]})]}):e.jsx(xe,{compact:!0,className:"min-h-[240px]",title:s("logs.detail.loadError"),description:s("common.noData")})})]})})}function A({label:l,value:t}){return e.jsxs("div",{className:"min-w-0 rounded-lg border border-border bg-secondary px-3 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:l}),e.jsx("p",{className:"mt-2 break-all text-sm font-semibold leading-6",children:t})]})}function F({label:l,value:t}){return e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l}),e.jsx("dd",{className:"min-w-0 break-all whitespace-pre-wrap text-sm font-medium leading-6 text-foreground",children:t??"-"})]})}function wt({emptyLabel:l,onCopy:t,title:i,value:n,t:c}){return e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-secondary/40 p-4",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:i}),e.jsx(E,{variant:"outline",size:"sm",onClick:t,children:c("common.actions.copy")})]}),e.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap rounded-lg border border-border bg-secondary p-3 text-xs",children:ut(n,l)})]})}const H=[20,50,100],Q=["endpoint","provider","requestedModel","routedModel","apiKey","inputTokens","cacheReadTokens","cacheCreationTokens","outputTokens","latency","ttft","tpot","status","error"],ae=["endpoint","provider","requestedModel","routedModel","apiKey","inputTokens","cacheReadTokens","cacheCreationTokens","outputTokens","latency","ttft","tpot","status","error"];function kt(){if(typeof window>"u")return Q;try{const l=window.localStorage.getItem(C.logs.visibleColumns);if(!l)return Q;const t=JSON.parse(l);if(!Array.isArray(t))return Q;const i=t.filter(n=>ae.includes(n));return i.length>0?i:Q}catch{return Q}}function St(){return typeof window>"u"?"comfortable":window.localStorage.getItem(C.logs.density)==="compact"?"compact":"comfortable"}function Ct(){if(typeof window>"u")return H[0];const l=window.localStorage.getItem(C.logs.pageSize),t=Number(l);return H.includes(t)?t:H[0]}function Et(){if(typeof window>"u")return[];try{const l=window.localStorage.getItem(C.logs.selectedApiKeys);if(!l)return[];const t=JSON.parse(l);return Array.isArray(t)?t.map(i=>Number(i)).filter(i=>Number.isInteger(i)&&i>0):[]}catch{return[]}}function Ce(l,t=!1){if(!l)return;const i=t?`${l}T23:59:59.999`:`${l}T00:00:00.000`,n=Date.parse(i);return Number.isFinite(n)?n:void 0}function _t(l,t,i){return l===i&&t===i}function Dt({columnOptions:l,exporting:t,onExport:i,onRefresh:n,onResetColumns:c,onSetDensity:s,onToggleColumn:r,refreshing:h,rowDensity:p,total:j,visibleColumns:u,visibleColumnSet:y}){const{t:o}=K(),a=JSON.stringify(u)===JSON.stringify(Q);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.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto rounded-full border border-border bg-secondary p-1 sm:w-auto",children:[e.jsx("button",{type:"button",onClick:()=>s("comfortable"),className:v("inline-flex h-8 flex-1 items-center justify-center whitespace-nowrap rounded-full px-3.5 text-xs font-medium transition-all sm:flex-none",p==="comfortable"?"bg-primary text-primary-foreground shadow-[0_8px_18px_-14px_rgba(59,130,246,0.7)]":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:o("logs.table.density.comfortable")}),e.jsx("button",{type:"button",onClick:()=>s("compact"),className:v("inline-flex h-8 flex-1 items-center justify-center whitespace-nowrap rounded-full px-3.5 text-xs font-medium transition-all sm:flex-none",p==="compact"?"bg-primary text-primary-foreground shadow-[0_8px_18px_-14px_rgba(59,130,246,0.7)]":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:o("logs.table.density.compact")})]}),e.jsxs(gt,{children:[e.jsx(ht,{asChild:!0,children:e.jsx(E,{variant:"outline",size:"sm",className:"w-full sm:w-auto",children:o("logs.actions.columns")})}),e.jsxs(ft,{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:o("logs.actions.columns")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o("logs.actions.visibleCount",{count:u.length})})]}),e.jsx(E,{variant:"ghost",size:"sm",onClick:c,disabled:a,children:o("common.actions.reset")})]}),e.jsx("div",{className:"grid gap-1.5",children:l.map(d=>{const k=y.has(d.id);return e.jsxs("label",{className:v("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",checked:k,onChange:()=>r(d.id),className:"h-4 w-4 rounded border-border"}),e.jsx("span",{children:d.label})]},d.id)})})]})]}),e.jsxs(E,{onClick:i,disabled:t,className:"w-full sm:w-auto",children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),o(t?"logs.actions.exporting":"logs.actions.export")]})]}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-3 xl:w-auto xl:justify-start",children:[e.jsx("span",{className:"text-xs text-muted-foreground sm:text-sm",children:o("logs.summary.total",{value:j.toLocaleString()})}),e.jsxs(E,{variant:"outline",size:"sm",onClick:n,disabled:h,className:"shrink-0",children:[e.jsx(Ze,{className:v("mr-2 h-4 w-4",h&&"animate-spin")}),o(h?"common.actions.refreshing":"logs.actions.manualRefresh")]})]})]})}function Ft({record:l,providerLabelMap:t,apiKeyMap:i,onSelect:n,isEven:c,density:s,visibleColumnSet:r}){const{t:h}=K(),p=t.get(l.provider)??l.provider,j=l.endpoint||"-",u=De(l,h),y=l.client_model??h("logs.table.requestedModelFallback"),o=l.api_key_id!=null?i.get(l.api_key_id):void 0,a=l.api_key_id==null?h("logs.table.apiKeyUnknown"):o!=null&&o.isWildcard?h("apiKeys.wildcard"):o!=null&&o.name?o.name:l.api_key_name?l.api_key_name:h("logs.table.apiKeyUnknown"),d=s==="compact"?"px-3 py-1.5":"px-3 py-2",k=c?"bg-muted/30":"bg-background",x=xt(l.session_id),R=x==null?void 0:x.rowStyle,D=x==null?void 0:x.stickyStyle,S=x?{...x.stickyStyle,...x.accentStyle}:void 0;return e.jsxs("tr",{"data-session-id":x==null?void 0:x.sessionId,"data-session-color":x==null?void 0:x.colorKey,className:v("transition-colors",x?"":c?"bg-muted/30":"",x?"":"hover:bg-muted/50"),style:R,onMouseEnter:_=>{x&&Object.assign(_.currentTarget.style,x.hoverStyle)},onMouseLeave:_=>{x&&Object.assign(_.currentTarget.style,x.rowStyle)},children:[e.jsx("td",{className:v("sticky left-0 z-10 text-xs",d,x?"":k),style:S,children:Fe(l.timestamp)}),r.has("endpoint")&&e.jsx("td",{className:v(d,"text-xs"),children:j}),r.has("provider")&&e.jsx("td",{className:v(d,"text-xs"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:p,children:p})}),r.has("requestedModel")&&e.jsx("td",{className:v(d,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:y,children:y})}),r.has("routedModel")&&e.jsx("td",{className:v(d,"text-xs"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:l.model,children:l.model})}),r.has("apiKey")&&e.jsx("td",{className:v(d,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[90px] truncate",title:a,children:a})}),r.has("inputTokens")&&e.jsx("td",{className:v(d,"text-right text-xs tabular-nums"),children:z(l.input_tokens)}),r.has("cacheReadTokens")&&e.jsx("td",{className:v(d,"text-right text-xs tabular-nums"),children:z(l.cache_read_tokens)}),r.has("cacheCreationTokens")&&e.jsx("td",{className:v(d,"text-right text-xs tabular-nums"),children:z(l.cache_creation_tokens)}),r.has("outputTokens")&&e.jsx("td",{className:v(d,"text-right text-xs tabular-nums"),children:z(l.output_tokens)}),r.has("latency")&&e.jsx("td",{className:v(d,"text-right text-xs tabular-nums"),children:O(l.latency_ms,"ms")}),r.has("ttft")&&e.jsx("td",{className:v(d,"text-right text-xs tabular-nums"),children:O(l.ttft_ms,"ms")}),r.has("tpot")&&e.jsx("td",{className:v(d,"text-right text-xs tabular-nums"),children:O(l.tpot_ms,"ms/tk")}),r.has("status")&&e.jsx("td",{className:v(d,"text-center"),children:e.jsx(M,{variant:u.variant,className:"text-xs",children:u.label})}),r.has("error")&&e.jsx("td",{className:v(d,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:l.error??"",children:l.error?l.error:"-"})}),e.jsx("td",{className:v("sticky right-0 z-10 text-center",d,x?"":k),style:D,children:e.jsx(E,{variant:"outline",size:"sm",onClick:()=>n(l.id),children:h("logs.actions.detail")})})]})}function Tt(l){const{t}=K(),{tableScrollRef:i,visibleColumnSet:n,visibleColumnCount:c,logsError:s,logsPending:r,items:h,activeFiltersCount:p,handleResetFilters:j,handleRetry:u,providerLabelMap:y,apiKeyMap:o,handleOpenDetail:a,rowDensity:d,showScrollHint:k,pageSize:x,setPageSize:R,page:D,totalPages:S,setPage:_}=l;return e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs(_e,{className:"p-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-border bg-secondary px-4 py-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:t("logs.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("logs.actions.visibleCount",{count:c-2})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(M,{variant:"secondary",children:"Wide Table"}),e.jsx(M,{variant:"outline",children:t(d==="compact"?"logs.table.density.compact":"logs.table.density.comfortable")}),k?e.jsx(M,{variant:"outline",className:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:"Scroll for more"}):null]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{ref:i,className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[1480px] text-sm",children:[e.jsx("thead",{className:"border-b bg-muted/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 z-20 bg-muted/95 px-3 py-2 text-left text-xs font-medium backdrop-blur",children:t("logs.table.columns.time")}),n.has("endpoint")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.endpoint")}),n.has("provider")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.provider")}),n.has("requestedModel")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.requestedModel")}),n.has("routedModel")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.routedModel")}),n.has("apiKey")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.apiKey")}),n.has("inputTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.inputTokens")}),n.has("cacheReadTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.cacheReadTokens")}),n.has("cacheCreationTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.cacheCreationTokens")}),n.has("outputTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.outputTokens")}),n.has("latency")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.latency")}),n.has("ttft")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.ttft")}),n.has("tpot")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:t("logs.table.columns.tpot")}),n.has("status")&&e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium",children:t("logs.table.columns.status")}),n.has("error")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:t("logs.table.columns.error")}),e.jsx("th",{className:"sticky right-0 z-20 bg-muted/95 px-3 py-2 text-center text-xs font-medium backdrop-blur",children:t("logs.table.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y",children:r?Array.from({length:8}).map((w,b)=>e.jsx(bt,{columns:c},b)):s&&h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:c,className:"px-3 py-6",children:e.jsx(xe,{compact:!0,tone:"danger",icon:e.jsx(Ye,{className:"h-5 w-5","aria-hidden":"true"}),title:t("logs.toast.listError.title"),description:s,action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[e.jsx(E,{variant:"outline",size:"sm",onClick:u,children:t("common.actions.refresh")}),p>0?e.jsx(E,{variant:"ghost",size:"sm",onClick:j,children:t("common.actions.reset")}):null]})})})}):h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:c,className:"px-3 py-8 text-center text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 py-4",children:[e.jsx("span",{children:t("logs.table.empty")}),p>0&&e.jsx(E,{variant:"outline",size:"sm",onClick:j,children:t("common.actions.reset")})]})})}):h.map((w,b)=>e.jsx(Ft,{record:w,providerLabelMap:y,apiKeyMap:o,onSelect:a,isEven:b%2===0,density:d,visibleColumnSet:n},w.id))})]})}),k&&e.jsx("div",{className:"table-scroll-hint"})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-t p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:t("logs.table.pagination.perPage")}),e.jsxs(ee,{value:x.toString(),onValueChange:w=>R(Number(w)),children:[e.jsx(te,{className:"w-[80px]",children:e.jsx(se,{})}),e.jsx(le,{children:H.map(w=>e.jsx(L,{value:w.toString(),children:w},w))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{variant:"outline",size:"sm",onClick:()=>_(w=>Math.max(w-1,1)),disabled:D<=1,children:t("logs.table.pagination.previous")}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("logs.table.pagination.pageLabel",{page:S===0?0:D,total:S})}),e.jsx(E,{variant:"outline",size:"sm",onClick:()=>_(w=>S===0?w:Math.min(w+1,S)),disabled:S===0||D>=S,children:t("logs.table.pagination.next")})]})]})]})})}function Rt({exportTimeoutMs:l,queryParams:t,total:i}){const{t:n}=K(),{pushToast:c}=ge(),[s,r]=f.useState(!1),h=f.useCallback(async()=>{if(!s){r(!0);try{const p=i>0?Math.min(i,5e3):1e3,j={...t,limit:p,offset:0},u=await he.exportArchive(j,l),y=new Date().toISOString().replace(/[:.]/g,"-"),o=URL.createObjectURL(u),a=document.createElement("a");a.href=o,a.download=`cc-gw-logs-${y}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(o),c({title:n("logs.toast.exportSuccess.title"),description:n("logs.toast.exportSuccess.desc"),variant:"success"})}catch(p){const j=lt(p);c({title:n("logs.toast.exportError.title"),description:n("logs.toast.exportError.desc",{message:j.message}),variant:"error"})}finally{r(!1)}}},[l,s,c,t,n,i]);return{exporting:s,handleExport:h}}function Lt(){const l=f.useRef(null),[t,i]=f.useState(!1),n=f.useCallback(()=>{const c=l.current;if(!c)return;const s=c.scrollWidth-c.scrollLeft-c.clientWidth>1;i(s)},[]);return f.useEffect(()=>{const c=l.current;if(!c)return;n(),c.addEventListener("scroll",n,{passive:!0});const s=new ResizeObserver(n);return s.observe(c),()=>{c.removeEventListener("scroll",n),s.disconnect()}},[n]),{scrollRef:l,showScrollHint:t,updateScrollHint:n}}function Kt(){const[l,t]=T(C.logs.density,St,{serialize:u=>u,deserialize:u=>u==="compact"?"compact":"comfortable"}),[i,n]=T(C.logs.visibleColumns,kt),{scrollRef:c,showScrollHint:s}=Lt(),r=f.useMemo(()=>new Set(i),[i]),h=i.length+2,p=f.useCallback(u=>{n(y=>{if(y.includes(u))return y.length===1?y:y.filter(a=>a!==u);const o=[...y,u];return o.sort((a,d)=>ae.indexOf(a)-ae.indexOf(d)),o})},[]);return{resetVisibleColumns:f.useCallback(()=>{n(Q)},[]),rowDensity:l,setRowDensity:t,showScrollHint:s,tableScrollRef:c,toggleColumn:p,visibleColumnCount:h,visibleColumns:i,visibleColumnSet:r}}function Mt(){var je,ve,Ne,we,ke;const{t:l}=K(),{pushToast:t}=ge(),[i,n]=T(C.logs.providerFilter,"all"),[c,s]=T(C.logs.endpointFilter,"all"),[r,h]=T(C.logs.modelFilter,""),[p,j]=T(C.logs.statusFilter,"all"),[u,y]=T(C.logs.fromDate,""),[o,a]=T(C.logs.toDate,""),[d,k]=f.useState(1),[x,R]=T(C.logs.pageSize,Ct,{serialize:m=>String(m),deserialize:m=>{const N=Number(m);return H.includes(N)?N:H[0]}}),[D,S]=f.useState(null),[_,w]=f.useState(!1),[b,B]=T(C.logs.selectedApiKeys,Et),[re,oe]=T(C.logs.filtersExpanded,!1),{resetVisibleColumns:W,rowDensity:g,setRowDensity:G,showScrollHint:Te,tableScrollRef:Re,toggleColumn:Le,visibleColumnCount:Ke,visibleColumns:Me,visibleColumnSet:Pe}=Kt();f.useEffect(()=>{k(1)},[i,c,r,p,u,o,x,b]);const ie=f.useMemo(()=>{const m={limit:x,offset:(d-1)*x};i!=="all"&&(m.provider=i),c!=="all"&&(m.endpoint=c),r.trim().length>0&&(m.model=r.trim()),p!=="all"&&(m.status=p);const N=Ce(u),q=Ce(o,!0);return N!==void 0&&(m.from=N),q!==void 0&&(m.to=q),b.length>0&&(m.apiKeys=b.join(",")),m},[c,u,r,d,x,i,b,p,o]),P=$(U.logs.list(ie),he.listRequest(ie)),V=$(U.providers.all(),Se.providersRequest()),fe=$(U.apiKeys.all(),{url:"/api/keys",method:"GET"}),ne=$(U.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"}),be=$(U.config.exportTimeout(),Se.configRequest());f.useEffect(()=>{!P.isError||!P.error||t({title:l("logs.toast.listError.title"),description:l("logs.toast.listError.desc",{message:P.error.message}),variant:"error"})},[P.error,P.isError,t,l]),f.useEffect(()=>{!V.isError||!V.error||t({title:l("logs.toast.providerError.title"),description:l("logs.toast.providerError.desc",{message:V.error.message}),variant:"error"})},[V.error,V.isError,t,l]);const Z=((je=P.data)==null?void 0:je.total)??0,J=Z>0?Math.ceil(Z/x):0,Ae=((ve=P.data)==null?void 0:ve.items)??[],Oe=f.useMemo(()=>{var N;const m=(N=be.data)==null?void 0:N.logExportTimeoutSeconds;return typeof m=="number"&&Number.isFinite(m)?Math.min(Math.max(Math.round(m),5),600)*1e3:6e4},[(Ne=be.data)==null?void 0:Ne.logExportTimeoutSeconds]);f.useEffect(()=>{J>0&&d>J&&k(J)},[d,J]);const de=V.data??[],ce=f.useMemo(()=>{const m=new Map;for(const N of de)N.id&&m.set(N.id,N.label??N.id);return m},[de]),ye=f.useMemo(()=>{var N;const m=new Map;m.set("anthropic",l("logs.filters.endpointAnthropic")),m.set("openai",l("logs.filters.endpointOpenAI"));for(const q of((N=ne.data)==null?void 0:N.endpoints)??[])m.set(q.id,q.label||q.id);return m},[(we=ne.data)==null?void 0:we.endpoints,l]),ze=f.useMemo(()=>{const m=[];if(i!=="all"){const N=ce.get(i)??i;m.push({key:"provider",label:`${l("logs.filters.provider")}: ${N}`,onRemove:()=>n("all")})}if(c!=="all"){const N=ye.get(c)??c;m.push({key:"endpoint",label:`${l("logs.filters.endpoint")}: ${N}`,onRemove:()=>s("all")})}if(r.trim()&&m.push({key:"model",label:`${l("logs.filters.modelId")}: ${r.trim()}`,onRemove:()=>h("")}),p!=="all"){const N=l(p==="success"?"logs.filters.statusSuccess":"logs.filters.statusError");m.push({key:"status",label:`${l("logs.filters.status")}: ${N}`,onRemove:()=>j("all")})}return u&&m.push({key:"from",label:`${l("logs.filters.startDate")}: ${u}`,onRemove:()=>y("")}),o&&m.push({key:"to",label:`${l("logs.filters.endDate")}: ${o}`,onRemove:()=>a("")}),b.length>0&&m.push({key:"apiKeys",label:l("logs.filters.apiKeySelected",{count:b.length}),onRemove:()=>B([])}),m},[c,ye,u,r,i,ce,b.length,p,l,o]),me=fe.data??[],qe=f.useMemo(()=>{const m=new Map;for(const N of me)m.set(N.id,N);return m},[me]),Ie=f.useMemo(()=>ae.map(m=>({id:m,label:l(`logs.table.columns.${m}`)})),[l]),X=f.useMemo(()=>new Date().toISOString().slice(0,10),[]),Qe=f.useMemo(()=>i==="all"&&c==="all"&&r.trim()===""&&p==="all"&&u===""&&o===""&&b.length===0?"all":p==="error"&&c==="all"&&i==="all"&&r.trim()===""&&u===""&&o===""&&b.length===0?"errors":_t(u,o,X)&&c==="all"&&i==="all"&&r.trim()===""&&p==="all"&&b.length===0?"today":c==="anthropic"&&i==="all"&&r.trim()===""&&p==="all"&&u===""&&o===""&&b.length===0?"anthropic":c==="openai"&&i==="all"&&r.trim()===""&&p==="all"&&u===""&&o===""&&b.length===0?"openai":null,[c,u,r,i,b.length,p,o,X]),pe=f.useCallback(()=>{n("all"),h(""),s("all"),j("all"),y(""),a(""),B([])},[]),Ve=f.useCallback(m=>{if(k(1),pe(),m!=="all"){if(m==="errors"){j("error");return}if(m==="today"){y(X),a(X);return}if(m==="anthropic"){s("anthropic");return}m==="openai"&&s("openai")}},[pe,X]),{exporting:$e,handleExport:Ue}=Rt({exportTimeoutMs:Oe,queryParams:ie,total:Z}),He=f.useCallback(m=>{S(m),w(!0)},[]),Be=f.useCallback(()=>{w(!1),S(null)},[]);return{activeFilters:ze,activeQuickView:Qe,apiKeyMap:qe,apiKeys:me,apiKeysQuery:fe,applyQuickView:Ve,columnOptions:Ie,customEndpoints:(ke=ne.data)==null?void 0:ke.endpoints,endpointFilter:c,exporting:$e,filtersExpanded:re,fromDate:u,handleCloseDetail:Be,handleExport:Ue,handleOpenDetail:He,handleResetFilters:pe,isDetailOpen:_,items:Ae,logsQuery:P,modelFilter:r,page:d,pageSize:x,providerFilter:i,providerLabelMap:ce,providerOptions:de,rowDensity:g,resetVisibleColumns:W,selectedApiKeys:b,selectedLogId:D,setEndpointFilter:s,setFiltersExpanded:oe,setFromDate:y,setModelFilter:h,setPage:k,setPageSize:R,setProviderFilter:n,setRowDensity:G,setSelectedApiKeys:B,setStatusFilter:j,setToDate:a,showScrollHint:Te,statusFilter:p,tableScrollRef:Re,toDate:o,toggleColumn:Le,total:Z,totalPages:J,visibleColumnCount:Ke,visibleColumns:Me,visibleColumnSet:Pe}}function ls(){var i;const{t:l}=K(),t=Mt();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(tt,{icon:e.jsx(et,{className:"h-5 w-5","aria-hidden":"true"}),title:l("logs.title"),description:l("logs.description"),eyebrow:"Traffic Explorer",breadcrumb:"Gateway / Logs",helper:l("logs.filtersDescription"),badge:t.total>0?l("logs.summary.total",{value:t.total.toLocaleString()}):void 0,actions:e.jsx(Dt,{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,total:t.total,visibleColumns:t.visibleColumns,visibleColumnSet:t.visibleColumnSet})}),e.jsx(jt,{total:t.total,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(Tt,{tableScrollRef:t.tableScrollRef,visibleColumnSet:t.visibleColumnSet,visibleColumnCount:t.visibleColumnCount,logsError:t.logsQuery.isError?((i=t.logsQuery.error)==null?void 0:i.message)??null:null,logsPending:t.logsQuery.isPending,items:t.items,activeFiltersCount:t.activeFilters.length,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(Nt,{open:t.isDetailOpen,logId:t.selectedLogId,onClose:t.handleCloseDetail,providerLabelMap:t.providerLabelMap,apiKeyMap:t.apiKeyMap})]})}export{ls as default};