@chenpu17/cc-gw 0.8.6 → 0.8.7

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 (31) hide show
  1. package/package.json +5 -5
  2. package/src/web/dist/assets/{About-DI7ipumV.js → About-CQlf3ZPj.js} +1 -1
  3. package/src/web/dist/assets/{ApiKeys-p_HrxRk7.js → ApiKeys-DOKqJCMB.js} +1 -1
  4. package/src/web/dist/assets/{ConfirmDialog-8iSYQ7NE.js → ConfirmDialog-C68Yivng.js} +1 -1
  5. package/src/web/dist/assets/{Dashboard-CjMh6Cr5.js → Dashboard-Dl6lEQC0.js} +1 -1
  6. package/src/web/dist/assets/{DialogShell-CygWjkEa.js → DialogShell-BYqoLSIE.js} +1 -1
  7. package/src/web/dist/assets/{Events-BtwqpvkH.js → Events-iNPooxgH.js} +1 -1
  8. package/src/web/dist/assets/{Help-Ch8s4btZ.js → Help-CWv7e8bp.js} +1 -1
  9. package/src/web/dist/assets/{Login-D8OeR4Ya.js → Login-BwGD9nii.js} +1 -1
  10. package/src/web/dist/assets/{Logs-seICabmw.js → Logs-CjLydDgS.js} +1 -1
  11. package/src/web/dist/assets/{ModelManagement-bbVLSR-e.js → ModelManagement-Cnb6daD7.js} +1 -1
  12. package/src/web/dist/assets/{PageHeader-DKkO-Kdm.js → PageHeader-JpvzJlDR.js} +1 -1
  13. package/src/web/dist/assets/{PageSection-D9se25qM.js → PageSection-D_3fkKC5.js} +1 -1
  14. package/src/web/dist/assets/{PageState-DSoiwsKr.js → PageState-rxsd1pfX.js} +1 -1
  15. package/src/web/dist/assets/{Profiler-Brnhx0iq.js → Profiler-D2Zh-Nwi.js} +1 -1
  16. package/src/web/dist/assets/{RoutingManagement-B5xsDNPf.js → RoutingManagement-DYrbEWZ_.js} +1 -1
  17. package/src/web/dist/assets/{Settings-CjMhqGQf.js → Settings-C2Zf8aEk.js} +1 -1
  18. package/src/web/dist/assets/{Skeleton-C7Qi01SG.js → Skeleton-pk8SE4WU.js} +1 -1
  19. package/src/web/dist/assets/{badge-CkaH3uCO.js → badge-Ci0LPkhW.js} +1 -1
  20. package/src/web/dist/assets/{card-Bem3kP2L.js → card-hwtf3yu-.js} +1 -1
  21. package/src/web/dist/assets/{gateway-DrmzHCwu.js → gateway-CgHqiqY9.js} +1 -1
  22. package/src/web/dist/assets/{index-OvGsIZkZ.js → index-DTypJ2Bg.js} +3 -3
  23. package/src/web/dist/assets/{input-DCNoHAkn.js → input-nzbrZT8r.js} +1 -1
  24. package/src/web/dist/assets/{label-9kbpUKaR.js → label-jdLnQwgX.js} +1 -1
  25. package/src/web/dist/assets/{popover-BGkrY50i.js → popover-j12PlF5c.js} +1 -1
  26. package/src/web/dist/assets/{select-DS37xdev.js → select-CCOTVWXq.js} +1 -1
  27. package/src/web/dist/assets/{switch-DVok_beq.js → switch-CmcsdQWq.js} +1 -1
  28. package/src/web/dist/assets/{useApiQuery-3ZHohr5l.js → useApiQuery-CDL54hs8.js} +1 -1
  29. package/src/web/dist/assets/{useAppMutation-C2rsFjm5.js → useAppMutation-Br__hMJO.js} +1 -1
  30. package/src/web/dist/assets/{useModelManagementState-Irif8Gdi.js → useModelManagementState-CABs4ftK.js} +1 -1
  31. package/src/web/dist/index.html +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenpu17/cc-gw",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
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.6",
29
- "@chenpu17/cc-gw-linux-arm64": "0.8.6",
30
- "@chenpu17/cc-gw-linux-x64": "0.8.6",
31
- "@chenpu17/cc-gw-win32-x64": "0.8.6"
28
+ "@chenpu17/cc-gw-darwin-arm64": "0.8.7",
29
+ "@chenpu17/cc-gw-linux-arm64": "0.8.7",
30
+ "@chenpu17/cc-gw-linux-x64": "0.8.7",
31
+ "@chenpu17/cc-gw-win32-x64": "0.8.7"
32
32
  },
33
33
  "dependencies": {
34
34
  "colorette": "^2.0.20",
@@ -1 +1 @@
1
- import{r as n,j as e,ac as V,aD as B,aE as p,am as R,$ as q}from"./vendor-DfnQOGOQ.js";import{P as D}from"./PageHeader-DKkO-Kdm.js";import{P as x}from"./PageSection-D9se25qM.js";import{P as F,a as E}from"./PageState-DSoiwsKr.js";import{u as G}from"./useAppMutation-C2rsFjm5.js";import{u as I}from"./useApiQuery-3ZHohr5l.js";import{u as M,B as b,r as $}from"./index-OvGsIZkZ.js";import{q as z}from"./queryKeys-BMvyDTQS.js";import{B as d}from"./badge-CkaH3uCO.js";import{C as c,a as u}from"./card-Bem3kP2L.js";import{u as J}from"./i18n-dgCQR_PB.js";import"./query-Db16w3tH.js";import"./router-BURlSZbt.js";import"./radix-D08JKSgz.js";const Q="0.8.6",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-02T12:38:45.493Z",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:H(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 H(t){return`mr-2 h-4 w-4${t?" animate-spin":""}`}export{le as default};
1
+ import{r as n,j as e,ac as V,aD as B,aE as p,am as R,$ as q}from"./vendor-DfnQOGOQ.js";import{P as D}from"./PageHeader-JpvzJlDR.js";import{P as x}from"./PageSection-D_3fkKC5.js";import{P as F,a as E}from"./PageState-rxsd1pfX.js";import{u as G}from"./useAppMutation-Br__hMJO.js";import{u as I}from"./useApiQuery-CDL54hs8.js";import{u as M,B as b,r as $}from"./index-DTypJ2Bg.js";import{q as z}from"./queryKeys-BMvyDTQS.js";import{B as d}from"./badge-Ci0LPkhW.js";import{C as c,a as u}from"./card-hwtf3yu-.js";import{u as J}from"./i18n-dgCQR_PB.js";import"./query-Db16w3tH.js";import"./router-BURlSZbt.js";import"./radix-D08JKSgz.js";const Q="0.8.7",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-03T04:25:18.413Z",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:H(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 H(t){return`mr-2 h-4 w-4${t?" animate-spin":""}`}export{le as default};
@@ -1 +1 @@
1
- import{r as c,j as e,a3 as Ze,ax as ve,X as Ke,ay as Ne,az as we,aA as es,aB as ss,aw as as}from"./vendor-DfnQOGOQ.js";import{c as se,r as ts,h as G,b as U,B as K,u as rs,a as _,s as J,L as ns}from"./index-OvGsIZkZ.js";import{P as is}from"./PageHeader-DKkO-Kdm.js";import{C as ls}from"./ConfirmDialog-8iSYQ7NE.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-CygWjkEa.js";import{I as $}from"./input-DCNoHAkn.js";import{L as O}from"./label-9kbpUKaR.js";import{u as H}from"./useApiQuery-3ZHohr5l.js";import{q as v}from"./queryKeys-BMvyDTQS.js";import{u as N}from"./i18n-dgCQR_PB.js";import{E as os}from"./EChart-B2VLuu4H.js";import{P as oe}from"./PageSection-D9se25qM.js";import{B as C}from"./badge-CkaH3uCO.js";import{C as de,a as ce}from"./card-Bem3kP2L.js";import{e as ds}from"./charts-core-D_rRW-0W.js";import{u as z}from"./useAppMutation-C2rsFjm5.js";import{c as cs}from"./clipboard-CALi6bTW.js";import"./query-Db16w3tH.js";import"./router-BURlSZbt.js";import"./radix-D08JKSgz.js";import"./charts-react-t97X9Vfc.js";import"./charts-engine-BXnGh0aE.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=>G(U.post("/api/keys",s)),update:async(s,a)=>{await G(U.patch(`/api/keys/${s}`,a))},delete:async s=>{await G(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("")},[]),B=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),B(!1)}catch{}},[he,B,g,o,y,l,a,s]),Ve=c.useCallback(async(r,d)=>{try{await I.mutateAsync({id:r,enabled:!d})}catch{}},[I]),Be=c.useCallback(async()=>{if(w){T(w.id);try{await ge.mutateAsync({id:w.id}),q(null)}catch{}finally{T(null)}}},[w,ge]),Ge=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:B,handleCreateKey:Qe,handleDeleteKey:Be,handleHideKey:Ue,handleOpenEditEndpoints:Je,handleRevealKey:Ge,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
+ import{r as c,j as e,a3 as Ze,ax as ve,X as Ke,ay as Ne,az as we,aA as es,aB as ss,aw as as}from"./vendor-DfnQOGOQ.js";import{c as se,r as ts,h as G,b as U,B as K,u as rs,a as _,s as J,L as ns}from"./index-DTypJ2Bg.js";import{P as is}from"./PageHeader-JpvzJlDR.js";import{C as ls}from"./ConfirmDialog-C68Yivng.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-BYqoLSIE.js";import{I as $}from"./input-nzbrZT8r.js";import{L as O}from"./label-jdLnQwgX.js";import{u as H}from"./useApiQuery-CDL54hs8.js";import{q as v}from"./queryKeys-BMvyDTQS.js";import{u as N}from"./i18n-dgCQR_PB.js";import{E as os}from"./EChart-B2VLuu4H.js";import{P as oe}from"./PageSection-D_3fkKC5.js";import{B as C}from"./badge-Ci0LPkhW.js";import{C as de,a as ce}from"./card-hwtf3yu-.js";import{e as ds}from"./charts-core-D_rRW-0W.js";import{u as z}from"./useAppMutation-Br__hMJO.js";import{c as cs}from"./clipboard-CALi6bTW.js";import"./query-Db16w3tH.js";import"./router-BURlSZbt.js";import"./radix-D08JKSgz.js";import"./charts-react-t97X9Vfc.js";import"./charts-engine-BXnGh0aE.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=>G(U.post("/api/keys",s)),update:async(s,a)=>{await G(U.patch(`/api/keys/${s}`,a))},delete:async s=>{await G(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("")},[]),B=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),B(!1)}catch{}},[he,B,g,o,y,l,a,s]),Ve=c.useCallback(async(r,d)=>{try{await I.mutateAsync({id:r,enabled:!d})}catch{}},[I]),Be=c.useCallback(async()=>{if(w){T(w.id);try{await ge.mutateAsync({id:w.id}),q(null)}catch{}finally{T(null)}}},[w,ge]),Ge=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:B,handleCreateKey:Qe,handleDeleteKey:Be,handleHideKey:Ue,handleOpenEditEndpoints:Je,handleRevealKey:Ge,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-DfnQOGOQ.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-CygWjkEa.js";import{B as o}from"./index-OvGsIZkZ.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-DfnQOGOQ.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-BYqoLSIE.js";import{B as o}from"./index-DTypJ2Bg.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 +1 @@
1
- import{r as c,j as e,ac as me,ad as Me,Y,ae as he,af as Ae,ag as De,ah as _e,ai as ue,aj as Be,ak as Fe,S as G,al as Oe,am as $e,W as Ge}from"./vendor-DfnQOGOQ.js";import{P as He}from"./PageHeader-DKkO-Kdm.js";import{P as Z,a as H}from"./PageState-DSoiwsKr.js";import{c as x,u as ze,a as Qe,b as Ue,t as Ve,s as Ke,B as U}from"./index-OvGsIZkZ.js";import{S as Ye,a as Ze,b as We,c as Je,d as B}from"./select-DS37xdev.js";import{E as Xe}from"./EChart-B2VLuu4H.js";import{P as pe}from"./PageSection-D9se25qM.js";import{S as ea,C as aa,T as ta}from"./Skeleton-C7Qi01SG.js";import{B as k}from"./badge-CkaH3uCO.js";import{C as z,a as Q}from"./card-Bem3kP2L.js";import{g as le}from"./utils-BHook6QN.js";import{u as C}from"./i18n-dgCQR_PB.js";import{e as sa}from"./charts-core-D_rRW-0W.js";import{u as I}from"./useApiQuery-3ZHohr5l.js";import{q as L}from"./queryKeys-BMvyDTQS.js";import"./query-Db16w3tH.js";import"./router-BURlSZbt.js";import"./radix-D08JKSgz.js";import"./charts-react-t97X9Vfc.js";import"./charts-engine-BXnGh0aE.js";const W=c.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:"relative w-full overflow-auto rounded-lg border border-border bg-background",children:e.jsx("table",{ref:s,className:x("w-full caption-bottom border-collapse text-sm",a),...t})}));W.displayName="Table";const J=c.forwardRef(({className:a,...t},s)=>e.jsx("thead",{ref:s,className:x("bg-muted/35 [&_tr]:border-b [&_tr]:border-border/60",a),...t}));J.displayName="TableHeader";const X=c.forwardRef(({className:a,...t},s)=>e.jsx("tbody",{ref:s,className:x("[&_tr:last-child]:border-0",a),...t}));X.displayName="TableBody";const ra=c.forwardRef(({className:a,...t},s)=>e.jsx("tfoot",{ref:s,className:x("border-t bg-muted/45 font-medium [&>tr]:last:border-b-0",a),...t}));ra.displayName="TableFooter";const _=c.forwardRef(({className:a,...t},s)=>e.jsx("tr",{ref:s,className:x("border-b border-border/50 transition-all duration-150","hover:bg-primary/5 data-[state=selected]:bg-primary/10","group",a),...t}));_.displayName="TableRow";const g=c.forwardRef(({className:a,...t},s)=>e.jsx("th",{ref:s,className:x("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",a),...t}));g.displayName="TableHead";const f=c.forwardRef(({className:a,...t},s)=>e.jsx("td",{ref:s,className:x("px-4 py-3.5 align-middle text-sm","[&:has([role=checkbox])]:pr-0","group-hover:text-foreground transition-colors",a),...t}));f.displayName="TableCell";const oa=c.forwardRef(({className:a,...t},s)=>e.jsx("caption",{ref:s,className:x("mt-4 text-sm text-muted-foreground",a),...t}));oa.displayName="TableCaption";const F=15e3,V=6e4,S={requests:"#2563eb",input:"#059669",output:"#ea580c",cacheRead:"#7c3aed",cacheCreation:"#e11d48",latency:"#0891b2"};function D(a,t,s){return a==null?"-":`${a.toLocaleString(void 0,s)} ${t}`}function K(a){if(a==null)return"-";if(a<1024)return`${a} B`;const t=["KB","MB","GB","TB"];let s=a/1024,r=0;for(;s>=1024&&r<t.length-1;)s/=1024,r+=1;return`${s.toFixed(s>=100?0:s>=10?1:2)} ${t[r]}`}function ce(a){if(a==null)return"-";const t=a<1?0:a;return t<1024?`${t.toLocaleString(void 0,{maximumFractionDigits:t>=100?0:t>=10?1:2})} B/s`:`${K(t)}/s`}function na(a){return a==null?"-":`${a.toLocaleString(void 0,{maximumFractionDigits:a>=10?0:1})}%`}function ia(){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((a,t)=>e.jsx(ea,{},t))}),e.jsx("div",{className:"grid gap-6 lg:grid-cols-2",children:Array.from({length:4}).map((a,t)=>e.jsx(aa,{},t))}),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((a,t)=>e.jsx(ta,{columns:6},t))})})})]})}function da({dbSizeDisplay:a,memoryDisplay:t,selectedEndpointLabel:s,status:r,todayRequests:d}){const{t:n}=C();return e.jsx(z,{className:"overflow-hidden border-primary/15 bg-[linear-gradient(145deg,hsl(var(--card))_0%,hsl(var(--accent)/0.55)_100%)]",children:e.jsxs(Q,{className:"relative overflow-hidden pt-6",children:[e.jsx("div",{className:"pointer-events-none absolute -right-14 top-0 h-40 w-40 rounded-full bg-primary/10 blur-3xl"}),e.jsx("div",{className:"pointer-events-none absolute bottom-0 left-0 h-32 w-32 rounded-full bg-emerald-500/10 blur-3xl"}),e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(360px,0.94fr)_minmax(0,1.06fr)] xl:items-start",children:[e.jsxs("div",{className:"flex h-full flex-col justify-between rounded-[28px] border border-border/70 bg-background/30 p-5 shadow-[0_20px_48px_-36px_rgba(15,23,42,0.6)] backdrop-blur-sm","data-testid":"dashboard-overview-panel",children:[e.jsxs("div",{className:"space-y-5",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-2",children:[e.jsx("h2",{className:"text-[clamp(1.85rem,1.55rem+1vw,2.75rem)] font-semibold tracking-tight text-foreground",children:s}),e.jsx("p",{className:"max-w-xl text-sm leading-6 text-muted-foreground",children:n("dashboard.description")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:n("dashboard.status.listeningLabel")}),e.jsxs("p",{className:"text-[clamp(1.2rem,1rem+0.8vw,1.9rem)] font-semibold leading-tight text-foreground","data-testid":"dashboard-runtime-address",children:[(r==null?void 0:r.host)??"0.0.0.0",":",(r==null?void 0:r.port)??"-"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{variant:"outline",className:"border-[hsl(var(--success)/0.3)] bg-[hsl(var(--success-bg))] text-[hsl(var(--success)/1)]",children:n("dashboard.status.listeningLabel")}),e.jsx(k,{variant:"secondary",children:s}),e.jsxs(k,{variant:"outline",children:[n("dashboard.labels.todayRequests"),": ",d.toLocaleString()]})]})]}),e.jsxs("div",{className:"mt-6 grid gap-3 sm:grid-cols-2",children:[e.jsx(A,{label:n("dashboard.labels.providers"),value:((r==null?void 0:r.providers)??0).toLocaleString()}),e.jsx(A,{label:n("dashboard.labels.activeClientAddresses"),value:((r==null?void 0:r.activeClientAddresses)??0).toLocaleString()}),e.jsx(A,{label:n("dashboard.labels.activeClientSessions"),value:((r==null?void 0:r.activeClientSessions)??0).toLocaleString()}),e.jsx(A,{label:n("dashboard.labels.uniqueClientAddressesLastHour"),value:((r==null?void 0:r.uniqueClientAddressesLastHour)??0).toLocaleString()}),e.jsx(A,{label:n("dashboard.labels.uniqueClientSessionsLastHour"),value:((r==null?void 0:r.uniqueClientSessionsLastHour)??0).toLocaleString()})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4 xl:auto-rows-[minmax(168px,auto)]","data-testid":"dashboard-spotlight-grid",children:[e.jsx(E,{icon:e.jsx(Me,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.activeRequests"),value:((r==null?void 0:r.activeRequests)??0).toLocaleString(),valueTestId:"dashboard-spotlight-value-active"}),e.jsx(E,{icon:e.jsx(Y,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.requestsPerMinute"),value:((r==null?void 0:r.requestsPerMinute)??0).toLocaleString(),valueTestId:"dashboard-spotlight-value-rpm"}),e.jsx(E,{icon:e.jsx(he,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.outputTokensPerMinute"),value:((r==null?void 0:r.outputTokensPerMinute)??0).toLocaleString(),valueTestId:"dashboard-spotlight-value-tpm"}),e.jsx(E,{icon:e.jsx(Ae,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.cpu"),value:na(r==null?void 0:r.cpuUsagePercent),valueTestId:"dashboard-spotlight-value-cpu"}),e.jsx(E,{icon:e.jsx(De,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.networkIngress"),value:ce(r==null?void 0:r.networkIngressBytesPerSecond),valueTestId:"dashboard-spotlight-value-ingress"}),e.jsx(E,{icon:e.jsx(_e,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.networkEgress"),value:ce(r==null?void 0:r.networkEgressBytesPerSecond),valueTestId:"dashboard-spotlight-value-egress"}),e.jsx(E,{icon:e.jsx(ue,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.database"),value:a,valueTestId:"dashboard-spotlight-value-database"}),e.jsx(E,{icon:e.jsx(Be,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.memory"),value:t,valueTestId:"dashboard-spotlight-value-memory"})]})]})})]})})}function la({overview:a}){const{t}=C();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:t("dashboard.cards.todayRequests"),value:(a==null?void 0:a.today.requests)??0,suffix:t("common.units.request"),iconClass:"bg-blue-50 text-blue-600 dark:bg-blue-950 dark:text-blue-400"}),e.jsx(q,{icon:e.jsx(Fe,{className:"h-5 w-5"}),title:t("dashboard.cards.todayInput"),value:(a==null?void 0:a.today.inputTokens)??0,suffix:t("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:t("dashboard.cards.todayCacheRead"),value:(a==null?void 0:a.today.cacheReadTokens)??0,suffix:t("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:t("dashboard.cards.todayCacheCreation"),value:(a==null?void 0:a.today.cacheCreationTokens)??0,suffix:t("common.units.token"),iconClass:"bg-rose-50 text-rose-600 dark:bg-rose-950 dark:text-rose-400"}),e.jsx(q,{icon:e.jsx(G,{className:"h-5 w-5"}),title:t("dashboard.cards.todayOutput"),value:(a==null?void 0:a.today.outputTokens)??0,suffix:t("common.units.token"),iconClass:"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-400"}),e.jsx(q,{icon:e.jsx(Oe,{className:"h-5 w-5"}),title:t("dashboard.cards.avgLatency"),value:(a==null?void 0:a.today.avgLatencyMs)??0,suffix:t("common.units.ms"),iconClass:"bg-cyan-50 text-cyan-600 dark:bg-cyan-950 dark:text-cyan-400"})]})}function ca({busiestDay:a,fastestTtftModel:t,topModel:s,totalRequestsInRange:r}){const{t:d}=C();return e.jsxs("div",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsx(O,{label:d("dashboard.insights.totalRequests"),value:r.toLocaleString(),hint:d("dashboard.insights.totalRequestsHint")}),e.jsx(O,{label:d("dashboard.insights.busiestDay"),value:a?a.date:"-",hint:a?d("dashboard.insights.busiestDayHint",{value:a.requestCount.toLocaleString()}):d("common.noData")}),e.jsx(O,{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(O,{label:d("dashboard.insights.fastestTtft"),value:t?`${t.provider}/${t.model}`:"-",hint:t?D(t.avgTtftMs,d("common.units.ms")):d("common.noData")})]})}function ma({dailyEmpty:a,dailyOption:t,dailyPending:s,models:r,modelRequestsOption:d,modelUsagePending:n,ttftOption:m,tpotOption:o}){const{t:l}=C();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx($,{title:l("dashboard.charts.requestsTitle"),description:l("dashboard.charts.requestsDesc"),loading:s,option:t,empty:a,emptyText:l("dashboard.charts.empty")}),e.jsx($,{title:l("dashboard.charts.modelTitle"),description:l("dashboard.charts.modelDesc"),loading:n,option:d,empty:!r.length,emptyText:l("dashboard.charts.empty")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx($,{title:l("dashboard.charts.ttftTitle"),description:l("dashboard.charts.ttftDesc"),loading:n,option:m,empty:!r.some(h=>h.avgTtftMs!=null&&h.avgTtftMs>0),emptyText:l("dashboard.charts.ttftEmpty")}),e.jsx($,{title:l("dashboard.charts.tpotTitle"),description:l("dashboard.charts.tpotDesc"),loading:n,option:o,empty:!r.some(h=>h.avgTpotMs!=null&&h.avgTpotMs>0),emptyText:l("dashboard.charts.tpotEmpty")})]})]})}function ha({models:a,loading:t}){const{t:s}=C();return e.jsx(pe,{title:s("dashboard.modelTable.title"),description:s("dashboard.modelTable.description"),children:t?e.jsx(Z,{compact:!0,label:s("common.loadingShort")}):a.length===0?e.jsx(H,{compact:!0,icon:e.jsx(G,{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(W,{children:[e.jsx(J,{children:e.jsxs(_,{children:[e.jsx(g,{children:s("dashboard.modelTable.columns.model")}),e.jsx(g,{className:"text-right",children:s("dashboard.modelTable.columns.requests")}),e.jsx(g,{className:"text-right",children:s("dashboard.modelTable.columns.latency")}),e.jsx(g,{className:"text-right",children:s("dashboard.modelTable.columns.ttft")}),e.jsx(g,{className:"text-right",children:s("dashboard.modelTable.columns.tpot")})]})}),e.jsx(X,{children:a.map(r=>e.jsxs(_,{children:[e.jsx(f,{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(f,{className:"text-right font-medium",children:r.requests.toLocaleString()}),e.jsx(f,{className:"text-right",children:D(r.avgLatencyMs,s("common.units.ms"))}),e.jsx(f,{className:"text-right",children:D(r.avgTtftMs,s("common.units.ms"))}),e.jsx(f,{className:"text-right",children:D(r.avgTpotMs,s("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${r.provider}/${r.model}`))})]})})})}function ua({records:a,loading:t}){const{t:s}=C(),r=a.map(o=>le(o,s)),d=r.filter(o=>o.tone==="success").length,n=r.filter(o=>o.tone==="error").length,m=r.filter(o=>o.tone==="pending").length;return e.jsx(pe,{title:s("dashboard.recent.title"),description:s("dashboard.recent.subtitle",{count:5}),actions:a.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{variant:"secondary",children:a.length}),e.jsxs(k,{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(k,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[s("common.status.error"),": ",n]}),m>0?e.jsxs(k,{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:t?e.jsx(Z,{compact:!0,label:s("dashboard.recent.loading")}):a.length===0?e.jsx(H,{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(W,{children:[e.jsx(J,{children:e.jsxs(_,{children:[e.jsx(g,{children:s("dashboard.recent.columns.time")}),e.jsx(g,{children:s("dashboard.recent.columns.endpoint")}),e.jsx(g,{children:s("dashboard.recent.columns.provider")}),e.jsx(g,{children:s("dashboard.recent.columns.route")}),e.jsx(g,{className:"text-right",children:s("dashboard.recent.columns.latency")}),e.jsx(g,{children:s("dashboard.recent.columns.status")})]})}),e.jsx(X,{children:a.map(o=>{const l=le(o,s);return e.jsxs(_,{children:[e.jsx(f,{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(f,{children:e.jsx(k,{variant:"outline",className:"text-[11px]",children:o.endpoint==="anthropic"?s("logs.endpointAnthropic"):o.endpoint==="openai"?s("logs.endpointOpenAI"):o.endpoint})}),e.jsx(f,{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(f,{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(f,{className:"text-right font-medium",children:D(o.latency_ms,s("common.units.ms"))}),e.jsx(f,{children:e.jsx(k,{variant:l.variant,className:"min-w-14 justify-center",children:l.label})})]},o.id)})})]})})})}function E({icon:a,label:t,value:s,valueTestId:r}){const d=xa(s);return e.jsxs("div",{className:"flex min-h-[168px] min-w-0 flex-col rounded-2xl border border-border/80 bg-background/78 px-4 py-4 shadow-[0_14px_32px_-26px_rgba(15,23,42,0.5)] backdrop-blur",children:[e.jsxs("div",{className:"min-w-0 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:a}),e.jsx("span",{className:"min-w-0 break-words",children:t})]}),e.jsx("div",{className:"mt-auto pt-6",children:e.jsx(pa,{parts:d,testId:r,compact:!1})})]})}function pa({parts:a,testId:t,compact:s}){return a.unit?e.jsxs("div",{className:x("mt-2 flex min-w-0 flex-wrap items-end gap-x-1.5 gap-y-1 text-foreground [overflow-wrap:anywhere]",s?"min-h-[2.5rem]":"min-h-[2.75rem]"),"data-testid":t,children:[e.jsx("span",{className:x("min-w-0 overflow-hidden font-semibold leading-none [overflow-wrap:anywhere]",s?"text-[clamp(1rem,0.9rem+0.45vw,1.2rem)]":"text-[clamp(1.5rem,1.1rem+1vw,2rem)]"),children:a.primary}),e.jsx("span",{className:x("shrink-0 whitespace-nowrap text-muted-foreground",s?"text-xs":"pb-0.5 text-sm"),children:a.unit})]}):e.jsx("p",{className:x("mt-2 overflow-hidden font-semibold leading-tight text-foreground [overflow-wrap:anywhere]",s?"text-[clamp(1rem,0.9rem+0.45vw,1.2rem)]":"text-[clamp(1.5rem,1.1rem+1vw,2rem)]"),"data-testid":t,children:a.primary})}function xa(a){if(a==="-")return{primary:a,unit:""};const t=a.match(/^(.+?)\s+([A-Za-z]+(?:\/[A-Za-z]+)?)$/);if(t)return{primary:t[1],unit:t[2]};const s=a.match(/^(.+?)(%)$/);return s?{primary:s[1],unit:s[2]}:{primary:a,unit:""}}function A({label:a,value:t}){return e.jsxs("div",{className:"rounded-2xl border border-border/65 bg-background/58 px-3.5 py-3 shadow-[0_12px_28px_-28px_rgba(15,23,42,0.55)]",children:[e.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:a}),e.jsx("p",{className:"mt-1.5 text-base font-semibold leading-tight text-foreground",children:t})]})}function q({icon:a,iconClass:t,suffix:s,title:r,value:d}){return e.jsx(z,{children:e.jsxs(Q,{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}),a?e.jsx("div",{className:x("flex h-9 w-9 items-center justify-center rounded-lg",t),children:a}):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 O({label:a,value:t,hint:s}){return e.jsx(z,{children:e.jsxs(Q,{className:"pt-4",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"mt-2 line-clamp-1 text-sm font-semibold text-foreground",children:t}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]})})}function $({description:a,empty:t,emptyText:s,loading:r,option:d,title:n}){const{t:m}=C();return e.jsx(z,{children:e.jsxs(Q,{className:"space-y-4 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:n}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:a})]}),r?e.jsx(Z,{compact:!0,className:"min-h-[320px]",label:m("common.loadingShort")}):t?e.jsx(H,{compact:!0,className:"min-h-[320px]",icon:e.jsx(G,{className:"h-5 w-5","aria-hidden":"true"}),title:s??m("dashboard.charts.empty")}):e.jsx(Xe,{echarts:sa,option:d,className:"h-[40vh] min-h-[280px] max-h-[420px]",notMerge:!0,lazyUpdate:!0})]})})}function ba(){var ee,ae,te,se,re,oe,ne,ie;const{t:a}=C(),{pushToast:t}=ze(),[s,r]=Qe(Ke.dashboard.endpointFilter,"all"),[d,n]=c.useState(!1),m=s==="all"?void 0:s,o=I(L.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:V,refetchIntervalInBackground:!0}),l=I(L.stats.overview(s),{url:"/api/stats/overview",method:"GET",params:m?{endpoint:m}:void 0},{refetchInterval:F,refetchIntervalInBackground:!0}),h=I(L.stats.daily(14,s),{url:"/api/stats/daily",method:"GET",params:{days:14,...m?{endpoint:m}:{}}},{refetchInterval:V,refetchIntervalInBackground:!0}),N=I(L.stats.model(7,6,s),{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...m?{endpoint:m}:{}}},{refetchInterval:V,refetchIntervalInBackground:!0}),j=I(L.status.byEndpoint(s),{url:"/api/status",method:"GET",params:m?{endpoint:m}:void 0},{refetchInterval:F,refetchIntervalInBackground:!0}),b=I(L.db.info(),{url:"/api/db/info",method:"GET"},{refetchInterval:F,refetchIntervalInBackground:!0}),T=I(L.logs.recent(s),{url:"/api/logs",method:"GET",params:{limit:5,...m?{endpoint:m}:{}}},{refetchInterval:F,refetchIntervalInBackground:!0});c.useEffect(()=>{l.isError&&l.error&&t({title:a("dashboard.toast.overviewError"),description:l.error.message,variant:"error"})},[l.error,l.isError,t,a]),c.useEffect(()=>{h.isError&&h.error&&t({title:a("dashboard.toast.dailyError"),description:h.error.message,variant:"error"})},[h.error,h.isError,t,a]),c.useEffect(()=>{N.isError&&N.error&&t({title:a("dashboard.toast.modelError"),description:N.error.message,variant:"error"})},[N.error,N.isError,t,a]),c.useEffect(()=>{j.isError&&j.error&&t({title:a("dashboard.toast.statusError"),description:j.error.message,variant:"error"})},[j.error,j.isError,t,a]),c.useEffect(()=>{b.isError&&b.error&&t({title:a("dashboard.toast.dbError"),description:b.error.message,variant:"error"})},[b.error,b.isError,t,a]),c.useEffect(()=>{T.isError&&T.error&&t({title:a("dashboard.toast.recentError"),description:T.error.message,variant:"error"})},[T.error,T.isError,t,a]);const xe=c.useCallback(async()=>{await Promise.all([o.refetch(),l.refetch(),h.refetch(),N.refetch(),j.refetch(),b.refetch(),T.refetch()])},[o,b,h,T,N,l,j]),be=c.useCallback(async()=>{if(!d){n(!0);try{await Ue.post("/api/db/compact"),await b.refetch(),t({title:a("dashboard.toast.compactSuccess.title"),description:a("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(i){const u=Ve(i);t({title:a("dashboard.toast.compactError.title"),description:u.message,variant:"error"})}finally{n(!1)}}},[d,b,t,a]),ge=l.data,w=h.data??[],p=N.data??[],fe=j.data,R=b.data,je=((ee=T.data)==null?void 0:ee.items)??[],ye=s==="all"?a("dashboard.filters.endpointAll"):s==="anthropic"?a("dashboard.filters.endpointAnthropic"):s==="openai"?a("dashboard.filters.endpointOpenAI"):((se=(te=(ae=o.data)==null?void 0:ae.endpoints)==null?void 0:te.find(i=>i.id===s))==null?void 0:se.label)||s,ve=w.reduce((i,u)=>i+u.requestCount,0),Ne=w.reduce((i,u)=>!i||u.requestCount>i.requestCount?u:i,null),Te=p[0],we=p.filter(i=>i.avgTtftMs!=null&&i.avgTtftMs>0).sort((i,u)=>(i.avgTtftMs??Number.POSITIVE_INFINITY)-(u.avgTtftMs??Number.POSITIVE_INFINITY))[0],Se=o.isFetching||l.isFetching||h.isFetching||N.isFetching||j.isFetching||b.isFetching||T.isFetching,ke=l.isPending||j.isPending||b.isPending,Ce=((re=l.error)==null?void 0:re.message)??((oe=j.error)==null?void 0:oe.message)??((ne=b.error)==null?void 0:ne.message)??null,Ee=R?K(R.totalBytes??R.sizeBytes):"-",Re=K(R==null?void 0:R.memoryRssBytes),Ie=c.useMemo(()=>{const i=w.map(v=>v.date),u=a("dashboard.charts.barRequests"),P=a("dashboard.charts.lineInput"),M=a("dashboard.charts.lineOutput"),y=a("dashboard.charts.lineCacheRead"),de=a("dashboard.charts.lineCacheCreation");return{tooltip:{trigger:"axis"},legend:{data:[u,P,M,y,de]},grid:{left:56,right:28,top:56,bottom:54},xAxis:{type:"category",data:i},yAxis:{type:"value"},series:[{name:u,type:"bar",data:w.map(v=>v.requestCount),itemStyle:{color:S.requests,borderRadius:[6,6,0,0]}},{name:P,type:"line",smooth:!0,data:w.map(v=>v.inputTokens),itemStyle:{color:S.input},lineStyle:{width:2}},{name:M,type:"line",smooth:!0,data:w.map(v=>v.outputTokens),itemStyle:{color:S.output},lineStyle:{width:2}},{name:y,type:"line",smooth:!0,data:w.map(v=>v.cacheReadTokens),itemStyle:{color:S.cacheRead},lineStyle:{width:2}},{name:de,type:"line",smooth:!0,data:w.map(v=>v.cacheCreationTokens),itemStyle:{color:S.cacheCreation},lineStyle:{width:2}}]}},[w,a]),Le=c.useMemo(()=>{const i=p.map(y=>`${y.provider}/${y.model}`),u=a("dashboard.charts.barRequests"),P=a("dashboard.charts.lineInput"),M=a("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis"},legend:{data:[u,P,M]},grid:{left:72,right:52,top:56,bottom:96},xAxis:{type:"category",data:i,axisLabel:{rotate:28}},yAxis:[{type:"value",name:u},{type:"value",name:a("dashboard.charts.axisTokens"),position:"right"}],series:[{name:u,type:"bar",data:p.map(y=>y.requests),itemStyle:{color:S.requests,borderRadius:[6,6,0,0]}},{name:P,type:"line",yAxisIndex:1,smooth:!0,data:p.map(y=>y.inputTokens??0),itemStyle:{color:S.input}},{name:M,type:"line",yAxisIndex:1,smooth:!0,data:p.map(y=>y.outputTokens??0),itemStyle:{color:S.output}}]}},[p,a]),qe=c.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:p.map(i=>`${i.provider}/${i.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:a("dashboard.charts.ttftAxis")},series:[{name:a("dashboard.charts.ttftLabel"),type:"bar",data:p.map(i=>i.avgTtftMs??0),itemStyle:{color:S.latency,borderRadius:[6,6,0,0]}}]}),[p,a]),Pe=c.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:p.map(i=>`${i.provider}/${i.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:a("dashboard.charts.tpotAxis")},series:[{name:a("dashboard.charts.tpotLabel"),type:"bar",data:p.map(i=>i.avgTpotMs??0),itemStyle:{color:S.output,borderRadius:[6,6,0,0]}}]}),[p,a]);return{compacting:d,customEndpoints:((ie=o.data)==null?void 0:ie.endpoints)??[],daily:w,dailyOption:Ie,dailyPending:h.isPending,dbInfo:R,dbSizeDisplay:Ee,endpointFilter:s,fastestTtftModel:we,handleCompact:be,handleRefresh:xe,bootstrapError:Ce,isBootstrapping:ke,isRefreshing:Se,latestLogsPending:T.isPending,memoryDisplay:Re,modelRequestsOption:Le,modelUsagePending:N.isPending,models:p,overview:ge,recentLogs:je,selectedEndpointLabel:ye,setEndpointFilter:r,status:fe,topModel:Te,totalRequestsInRange:ve,busiestDay:Ne,ttftOption:qe,tpotOption:Pe}}function _a(){var s;const{t:a}=C(),t=ba();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(He,{icon:e.jsx(G,{className:"h-5 w-5","aria-hidden":"true"}),title:a("nav.dashboard"),description:a("dashboard.description"),badge:t.selectedEndpointLabel,eyebrow:"Operations",breadcrumb:"Gateway / Dashboard",helper:a("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:[a("dashboard.filters.endpoint")," · ",t.selectedEndpointLabel]}),e.jsxs(Ye,{value:t.endpointFilter,onValueChange:t.setEndpointFilter,children:[e.jsx(Ze,{className:"w-full sm:w-[168px]",children:e.jsx(We,{})}),e.jsxs(Je,{children:[e.jsx(B,{value:"all",children:a("dashboard.filters.endpointAll")}),e.jsx(B,{value:"anthropic",children:a("dashboard.filters.endpointAnthropic")}),e.jsx(B,{value:"openai",children:a("dashboard.filters.endpointOpenAI")}),t.customEndpoints.map(r=>e.jsx(B,{value:r.id,children:r.label||r.id},r.id))]})]}),e.jsxs(U,{variant:"outline",size:"sm",onClick:()=>void t.handleRefresh(),disabled:t.isRefreshing,className:"w-full sm:w-auto",children:[e.jsx($e,{className:x("mr-2 h-4 w-4",t.isRefreshing&&"animate-spin"),"aria-hidden":"true"}),t.isRefreshing?a("common.actions.refreshing"):a("common.actions.refresh")]}),e.jsxs(U,{variant:"outline",size:"sm",onClick:()=>void t.handleCompact(),disabled:t.compacting,className:"w-full sm:w-auto",children:[e.jsx(ue,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),t.compacting?a("dashboard.actions.compacting"):a("dashboard.actions.compact")]})]})}),t.isBootstrapping?e.jsx(ia,{}):t.bootstrapError?e.jsx(H,{icon:e.jsx(Ge,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:a("common.status.error"),description:t.bootstrapError,action:e.jsx(U,{variant:"outline",onClick:()=>void t.handleRefresh(),children:a("common.actions.refresh")})}):e.jsxs(e.Fragment,{children:[e.jsx(da,{dbSizeDisplay:t.dbSizeDisplay,memoryDisplay:t.memoryDisplay,selectedEndpointLabel:t.selectedEndpointLabel,status:t.status,todayRequests:((s=t.overview)==null?void 0:s.today.requests)??0}),e.jsx(la,{overview:t.overview}),e.jsx(ca,{busiestDay:t.busiestDay,fastestTtftModel:t.fastestTtftModel,topModel:t.topModel,totalRequestsInRange:t.totalRequestsInRange}),e.jsx(ma,{dailyEmpty:!t.daily.length,dailyOption:t.dailyOption,dailyPending:t.dailyPending,models:t.models,modelRequestsOption:t.modelRequestsOption,modelUsagePending:t.modelUsagePending,ttftOption:t.ttftOption,tpotOption:t.tpotOption}),e.jsx(ha,{models:t.models,loading:t.modelUsagePending}),e.jsx(ua,{records:t.recentLogs,loading:t.latestLogsPending})]})]})}export{_a as default};
1
+ import{r as c,j as e,ac as me,ad as Me,Y,ae as he,af as Ae,ag as De,ah as _e,ai as ue,aj as Be,ak as Fe,S as G,al as Oe,am as $e,W as Ge}from"./vendor-DfnQOGOQ.js";import{P as He}from"./PageHeader-JpvzJlDR.js";import{P as Z,a as H}from"./PageState-rxsd1pfX.js";import{c as x,u as ze,a as Qe,b as Ue,t as Ve,s as Ke,B as U}from"./index-DTypJ2Bg.js";import{S as Ye,a as Ze,b as We,c as Je,d as B}from"./select-CCOTVWXq.js";import{E as Xe}from"./EChart-B2VLuu4H.js";import{P as pe}from"./PageSection-D_3fkKC5.js";import{S as ea,C as aa,T as ta}from"./Skeleton-pk8SE4WU.js";import{B as k}from"./badge-Ci0LPkhW.js";import{C as z,a as Q}from"./card-hwtf3yu-.js";import{g as le}from"./utils-BHook6QN.js";import{u as C}from"./i18n-dgCQR_PB.js";import{e as sa}from"./charts-core-D_rRW-0W.js";import{u as I}from"./useApiQuery-CDL54hs8.js";import{q as L}from"./queryKeys-BMvyDTQS.js";import"./query-Db16w3tH.js";import"./router-BURlSZbt.js";import"./radix-D08JKSgz.js";import"./charts-react-t97X9Vfc.js";import"./charts-engine-BXnGh0aE.js";const W=c.forwardRef(({className:a,...t},s)=>e.jsx("div",{className:"relative w-full overflow-auto rounded-lg border border-border bg-background",children:e.jsx("table",{ref:s,className:x("w-full caption-bottom border-collapse text-sm",a),...t})}));W.displayName="Table";const J=c.forwardRef(({className:a,...t},s)=>e.jsx("thead",{ref:s,className:x("bg-muted/35 [&_tr]:border-b [&_tr]:border-border/60",a),...t}));J.displayName="TableHeader";const X=c.forwardRef(({className:a,...t},s)=>e.jsx("tbody",{ref:s,className:x("[&_tr:last-child]:border-0",a),...t}));X.displayName="TableBody";const ra=c.forwardRef(({className:a,...t},s)=>e.jsx("tfoot",{ref:s,className:x("border-t bg-muted/45 font-medium [&>tr]:last:border-b-0",a),...t}));ra.displayName="TableFooter";const _=c.forwardRef(({className:a,...t},s)=>e.jsx("tr",{ref:s,className:x("border-b border-border/50 transition-all duration-150","hover:bg-primary/5 data-[state=selected]:bg-primary/10","group",a),...t}));_.displayName="TableRow";const g=c.forwardRef(({className:a,...t},s)=>e.jsx("th",{ref:s,className:x("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",a),...t}));g.displayName="TableHead";const f=c.forwardRef(({className:a,...t},s)=>e.jsx("td",{ref:s,className:x("px-4 py-3.5 align-middle text-sm","[&:has([role=checkbox])]:pr-0","group-hover:text-foreground transition-colors",a),...t}));f.displayName="TableCell";const oa=c.forwardRef(({className:a,...t},s)=>e.jsx("caption",{ref:s,className:x("mt-4 text-sm text-muted-foreground",a),...t}));oa.displayName="TableCaption";const F=15e3,V=6e4,S={requests:"#2563eb",input:"#059669",output:"#ea580c",cacheRead:"#7c3aed",cacheCreation:"#e11d48",latency:"#0891b2"};function D(a,t,s){return a==null?"-":`${a.toLocaleString(void 0,s)} ${t}`}function K(a){if(a==null)return"-";if(a<1024)return`${a} B`;const t=["KB","MB","GB","TB"];let s=a/1024,r=0;for(;s>=1024&&r<t.length-1;)s/=1024,r+=1;return`${s.toFixed(s>=100?0:s>=10?1:2)} ${t[r]}`}function ce(a){if(a==null)return"-";const t=a<1?0:a;return t<1024?`${t.toLocaleString(void 0,{maximumFractionDigits:t>=100?0:t>=10?1:2})} B/s`:`${K(t)}/s`}function na(a){return a==null?"-":`${a.toLocaleString(void 0,{maximumFractionDigits:a>=10?0:1})}%`}function ia(){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((a,t)=>e.jsx(ea,{},t))}),e.jsx("div",{className:"grid gap-6 lg:grid-cols-2",children:Array.from({length:4}).map((a,t)=>e.jsx(aa,{},t))}),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((a,t)=>e.jsx(ta,{columns:6},t))})})})]})}function da({dbSizeDisplay:a,memoryDisplay:t,selectedEndpointLabel:s,status:r,todayRequests:d}){const{t:n}=C();return e.jsx(z,{className:"overflow-hidden border-primary/15 bg-[linear-gradient(145deg,hsl(var(--card))_0%,hsl(var(--accent)/0.55)_100%)]",children:e.jsxs(Q,{className:"relative overflow-hidden pt-6",children:[e.jsx("div",{className:"pointer-events-none absolute -right-14 top-0 h-40 w-40 rounded-full bg-primary/10 blur-3xl"}),e.jsx("div",{className:"pointer-events-none absolute bottom-0 left-0 h-32 w-32 rounded-full bg-emerald-500/10 blur-3xl"}),e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(360px,0.94fr)_minmax(0,1.06fr)] xl:items-start",children:[e.jsxs("div",{className:"flex h-full flex-col justify-between rounded-[28px] border border-border/70 bg-background/30 p-5 shadow-[0_20px_48px_-36px_rgba(15,23,42,0.6)] backdrop-blur-sm","data-testid":"dashboard-overview-panel",children:[e.jsxs("div",{className:"space-y-5",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-2",children:[e.jsx("h2",{className:"text-[clamp(1.85rem,1.55rem+1vw,2.75rem)] font-semibold tracking-tight text-foreground",children:s}),e.jsx("p",{className:"max-w-xl text-sm leading-6 text-muted-foreground",children:n("dashboard.description")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:n("dashboard.status.listeningLabel")}),e.jsxs("p",{className:"text-[clamp(1.2rem,1rem+0.8vw,1.9rem)] font-semibold leading-tight text-foreground","data-testid":"dashboard-runtime-address",children:[(r==null?void 0:r.host)??"0.0.0.0",":",(r==null?void 0:r.port)??"-"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{variant:"outline",className:"border-[hsl(var(--success)/0.3)] bg-[hsl(var(--success-bg))] text-[hsl(var(--success)/1)]",children:n("dashboard.status.listeningLabel")}),e.jsx(k,{variant:"secondary",children:s}),e.jsxs(k,{variant:"outline",children:[n("dashboard.labels.todayRequests"),": ",d.toLocaleString()]})]})]}),e.jsxs("div",{className:"mt-6 grid gap-3 sm:grid-cols-2",children:[e.jsx(A,{label:n("dashboard.labels.providers"),value:((r==null?void 0:r.providers)??0).toLocaleString()}),e.jsx(A,{label:n("dashboard.labels.activeClientAddresses"),value:((r==null?void 0:r.activeClientAddresses)??0).toLocaleString()}),e.jsx(A,{label:n("dashboard.labels.activeClientSessions"),value:((r==null?void 0:r.activeClientSessions)??0).toLocaleString()}),e.jsx(A,{label:n("dashboard.labels.uniqueClientAddressesLastHour"),value:((r==null?void 0:r.uniqueClientAddressesLastHour)??0).toLocaleString()}),e.jsx(A,{label:n("dashboard.labels.uniqueClientSessionsLastHour"),value:((r==null?void 0:r.uniqueClientSessionsLastHour)??0).toLocaleString()})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4 xl:auto-rows-[minmax(168px,auto)]","data-testid":"dashboard-spotlight-grid",children:[e.jsx(E,{icon:e.jsx(Me,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.activeRequests"),value:((r==null?void 0:r.activeRequests)??0).toLocaleString(),valueTestId:"dashboard-spotlight-value-active"}),e.jsx(E,{icon:e.jsx(Y,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.requestsPerMinute"),value:((r==null?void 0:r.requestsPerMinute)??0).toLocaleString(),valueTestId:"dashboard-spotlight-value-rpm"}),e.jsx(E,{icon:e.jsx(he,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.outputTokensPerMinute"),value:((r==null?void 0:r.outputTokensPerMinute)??0).toLocaleString(),valueTestId:"dashboard-spotlight-value-tpm"}),e.jsx(E,{icon:e.jsx(Ae,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.cpu"),value:na(r==null?void 0:r.cpuUsagePercent),valueTestId:"dashboard-spotlight-value-cpu"}),e.jsx(E,{icon:e.jsx(De,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.networkIngress"),value:ce(r==null?void 0:r.networkIngressBytesPerSecond),valueTestId:"dashboard-spotlight-value-ingress"}),e.jsx(E,{icon:e.jsx(_e,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.networkEgress"),value:ce(r==null?void 0:r.networkEgressBytesPerSecond),valueTestId:"dashboard-spotlight-value-egress"}),e.jsx(E,{icon:e.jsx(ue,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.database"),value:a,valueTestId:"dashboard-spotlight-value-database"}),e.jsx(E,{icon:e.jsx(Be,{className:"h-4 w-4","aria-hidden":"true"}),label:n("dashboard.labels.memory"),value:t,valueTestId:"dashboard-spotlight-value-memory"})]})]})})]})})}function la({overview:a}){const{t}=C();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:t("dashboard.cards.todayRequests"),value:(a==null?void 0:a.today.requests)??0,suffix:t("common.units.request"),iconClass:"bg-blue-50 text-blue-600 dark:bg-blue-950 dark:text-blue-400"}),e.jsx(q,{icon:e.jsx(Fe,{className:"h-5 w-5"}),title:t("dashboard.cards.todayInput"),value:(a==null?void 0:a.today.inputTokens)??0,suffix:t("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:t("dashboard.cards.todayCacheRead"),value:(a==null?void 0:a.today.cacheReadTokens)??0,suffix:t("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:t("dashboard.cards.todayCacheCreation"),value:(a==null?void 0:a.today.cacheCreationTokens)??0,suffix:t("common.units.token"),iconClass:"bg-rose-50 text-rose-600 dark:bg-rose-950 dark:text-rose-400"}),e.jsx(q,{icon:e.jsx(G,{className:"h-5 w-5"}),title:t("dashboard.cards.todayOutput"),value:(a==null?void 0:a.today.outputTokens)??0,suffix:t("common.units.token"),iconClass:"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-400"}),e.jsx(q,{icon:e.jsx(Oe,{className:"h-5 w-5"}),title:t("dashboard.cards.avgLatency"),value:(a==null?void 0:a.today.avgLatencyMs)??0,suffix:t("common.units.ms"),iconClass:"bg-cyan-50 text-cyan-600 dark:bg-cyan-950 dark:text-cyan-400"})]})}function ca({busiestDay:a,fastestTtftModel:t,topModel:s,totalRequestsInRange:r}){const{t:d}=C();return e.jsxs("div",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsx(O,{label:d("dashboard.insights.totalRequests"),value:r.toLocaleString(),hint:d("dashboard.insights.totalRequestsHint")}),e.jsx(O,{label:d("dashboard.insights.busiestDay"),value:a?a.date:"-",hint:a?d("dashboard.insights.busiestDayHint",{value:a.requestCount.toLocaleString()}):d("common.noData")}),e.jsx(O,{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(O,{label:d("dashboard.insights.fastestTtft"),value:t?`${t.provider}/${t.model}`:"-",hint:t?D(t.avgTtftMs,d("common.units.ms")):d("common.noData")})]})}function ma({dailyEmpty:a,dailyOption:t,dailyPending:s,models:r,modelRequestsOption:d,modelUsagePending:n,ttftOption:m,tpotOption:o}){const{t:l}=C();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx($,{title:l("dashboard.charts.requestsTitle"),description:l("dashboard.charts.requestsDesc"),loading:s,option:t,empty:a,emptyText:l("dashboard.charts.empty")}),e.jsx($,{title:l("dashboard.charts.modelTitle"),description:l("dashboard.charts.modelDesc"),loading:n,option:d,empty:!r.length,emptyText:l("dashboard.charts.empty")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx($,{title:l("dashboard.charts.ttftTitle"),description:l("dashboard.charts.ttftDesc"),loading:n,option:m,empty:!r.some(h=>h.avgTtftMs!=null&&h.avgTtftMs>0),emptyText:l("dashboard.charts.ttftEmpty")}),e.jsx($,{title:l("dashboard.charts.tpotTitle"),description:l("dashboard.charts.tpotDesc"),loading:n,option:o,empty:!r.some(h=>h.avgTpotMs!=null&&h.avgTpotMs>0),emptyText:l("dashboard.charts.tpotEmpty")})]})]})}function ha({models:a,loading:t}){const{t:s}=C();return e.jsx(pe,{title:s("dashboard.modelTable.title"),description:s("dashboard.modelTable.description"),children:t?e.jsx(Z,{compact:!0,label:s("common.loadingShort")}):a.length===0?e.jsx(H,{compact:!0,icon:e.jsx(G,{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(W,{children:[e.jsx(J,{children:e.jsxs(_,{children:[e.jsx(g,{children:s("dashboard.modelTable.columns.model")}),e.jsx(g,{className:"text-right",children:s("dashboard.modelTable.columns.requests")}),e.jsx(g,{className:"text-right",children:s("dashboard.modelTable.columns.latency")}),e.jsx(g,{className:"text-right",children:s("dashboard.modelTable.columns.ttft")}),e.jsx(g,{className:"text-right",children:s("dashboard.modelTable.columns.tpot")})]})}),e.jsx(X,{children:a.map(r=>e.jsxs(_,{children:[e.jsx(f,{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(f,{className:"text-right font-medium",children:r.requests.toLocaleString()}),e.jsx(f,{className:"text-right",children:D(r.avgLatencyMs,s("common.units.ms"))}),e.jsx(f,{className:"text-right",children:D(r.avgTtftMs,s("common.units.ms"))}),e.jsx(f,{className:"text-right",children:D(r.avgTpotMs,s("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${r.provider}/${r.model}`))})]})})})}function ua({records:a,loading:t}){const{t:s}=C(),r=a.map(o=>le(o,s)),d=r.filter(o=>o.tone==="success").length,n=r.filter(o=>o.tone==="error").length,m=r.filter(o=>o.tone==="pending").length;return e.jsx(pe,{title:s("dashboard.recent.title"),description:s("dashboard.recent.subtitle",{count:5}),actions:a.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{variant:"secondary",children:a.length}),e.jsxs(k,{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(k,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[s("common.status.error"),": ",n]}),m>0?e.jsxs(k,{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:t?e.jsx(Z,{compact:!0,label:s("dashboard.recent.loading")}):a.length===0?e.jsx(H,{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(W,{children:[e.jsx(J,{children:e.jsxs(_,{children:[e.jsx(g,{children:s("dashboard.recent.columns.time")}),e.jsx(g,{children:s("dashboard.recent.columns.endpoint")}),e.jsx(g,{children:s("dashboard.recent.columns.provider")}),e.jsx(g,{children:s("dashboard.recent.columns.route")}),e.jsx(g,{className:"text-right",children:s("dashboard.recent.columns.latency")}),e.jsx(g,{children:s("dashboard.recent.columns.status")})]})}),e.jsx(X,{children:a.map(o=>{const l=le(o,s);return e.jsxs(_,{children:[e.jsx(f,{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(f,{children:e.jsx(k,{variant:"outline",className:"text-[11px]",children:o.endpoint==="anthropic"?s("logs.endpointAnthropic"):o.endpoint==="openai"?s("logs.endpointOpenAI"):o.endpoint})}),e.jsx(f,{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(f,{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(f,{className:"text-right font-medium",children:D(o.latency_ms,s("common.units.ms"))}),e.jsx(f,{children:e.jsx(k,{variant:l.variant,className:"min-w-14 justify-center",children:l.label})})]},o.id)})})]})})})}function E({icon:a,label:t,value:s,valueTestId:r}){const d=xa(s);return e.jsxs("div",{className:"flex min-h-[168px] min-w-0 flex-col rounded-2xl border border-border/80 bg-background/78 px-4 py-4 shadow-[0_14px_32px_-26px_rgba(15,23,42,0.5)] backdrop-blur",children:[e.jsxs("div",{className:"min-w-0 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:a}),e.jsx("span",{className:"min-w-0 break-words",children:t})]}),e.jsx("div",{className:"mt-auto pt-6",children:e.jsx(pa,{parts:d,testId:r,compact:!1})})]})}function pa({parts:a,testId:t,compact:s}){return a.unit?e.jsxs("div",{className:x("mt-2 flex min-w-0 flex-wrap items-end gap-x-1.5 gap-y-1 text-foreground [overflow-wrap:anywhere]",s?"min-h-[2.5rem]":"min-h-[2.75rem]"),"data-testid":t,children:[e.jsx("span",{className:x("min-w-0 overflow-hidden font-semibold leading-none [overflow-wrap:anywhere]",s?"text-[clamp(1rem,0.9rem+0.45vw,1.2rem)]":"text-[clamp(1.5rem,1.1rem+1vw,2rem)]"),children:a.primary}),e.jsx("span",{className:x("shrink-0 whitespace-nowrap text-muted-foreground",s?"text-xs":"pb-0.5 text-sm"),children:a.unit})]}):e.jsx("p",{className:x("mt-2 overflow-hidden font-semibold leading-tight text-foreground [overflow-wrap:anywhere]",s?"text-[clamp(1rem,0.9rem+0.45vw,1.2rem)]":"text-[clamp(1.5rem,1.1rem+1vw,2rem)]"),"data-testid":t,children:a.primary})}function xa(a){if(a==="-")return{primary:a,unit:""};const t=a.match(/^(.+?)\s+([A-Za-z]+(?:\/[A-Za-z]+)?)$/);if(t)return{primary:t[1],unit:t[2]};const s=a.match(/^(.+?)(%)$/);return s?{primary:s[1],unit:s[2]}:{primary:a,unit:""}}function A({label:a,value:t}){return e.jsxs("div",{className:"rounded-2xl border border-border/65 bg-background/58 px-3.5 py-3 shadow-[0_12px_28px_-28px_rgba(15,23,42,0.55)]",children:[e.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:a}),e.jsx("p",{className:"mt-1.5 text-base font-semibold leading-tight text-foreground",children:t})]})}function q({icon:a,iconClass:t,suffix:s,title:r,value:d}){return e.jsx(z,{children:e.jsxs(Q,{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}),a?e.jsx("div",{className:x("flex h-9 w-9 items-center justify-center rounded-lg",t),children:a}):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 O({label:a,value:t,hint:s}){return e.jsx(z,{children:e.jsxs(Q,{className:"pt-4",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"mt-2 line-clamp-1 text-sm font-semibold text-foreground",children:t}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]})})}function $({description:a,empty:t,emptyText:s,loading:r,option:d,title:n}){const{t:m}=C();return e.jsx(z,{children:e.jsxs(Q,{className:"space-y-4 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:n}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:a})]}),r?e.jsx(Z,{compact:!0,className:"min-h-[320px]",label:m("common.loadingShort")}):t?e.jsx(H,{compact:!0,className:"min-h-[320px]",icon:e.jsx(G,{className:"h-5 w-5","aria-hidden":"true"}),title:s??m("dashboard.charts.empty")}):e.jsx(Xe,{echarts:sa,option:d,className:"h-[40vh] min-h-[280px] max-h-[420px]",notMerge:!0,lazyUpdate:!0})]})})}function ba(){var ee,ae,te,se,re,oe,ne,ie;const{t:a}=C(),{pushToast:t}=ze(),[s,r]=Qe(Ke.dashboard.endpointFilter,"all"),[d,n]=c.useState(!1),m=s==="all"?void 0:s,o=I(L.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:V,refetchIntervalInBackground:!0}),l=I(L.stats.overview(s),{url:"/api/stats/overview",method:"GET",params:m?{endpoint:m}:void 0},{refetchInterval:F,refetchIntervalInBackground:!0}),h=I(L.stats.daily(14,s),{url:"/api/stats/daily",method:"GET",params:{days:14,...m?{endpoint:m}:{}}},{refetchInterval:V,refetchIntervalInBackground:!0}),N=I(L.stats.model(7,6,s),{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...m?{endpoint:m}:{}}},{refetchInterval:V,refetchIntervalInBackground:!0}),j=I(L.status.byEndpoint(s),{url:"/api/status",method:"GET",params:m?{endpoint:m}:void 0},{refetchInterval:F,refetchIntervalInBackground:!0}),b=I(L.db.info(),{url:"/api/db/info",method:"GET"},{refetchInterval:F,refetchIntervalInBackground:!0}),T=I(L.logs.recent(s),{url:"/api/logs",method:"GET",params:{limit:5,...m?{endpoint:m}:{}}},{refetchInterval:F,refetchIntervalInBackground:!0});c.useEffect(()=>{l.isError&&l.error&&t({title:a("dashboard.toast.overviewError"),description:l.error.message,variant:"error"})},[l.error,l.isError,t,a]),c.useEffect(()=>{h.isError&&h.error&&t({title:a("dashboard.toast.dailyError"),description:h.error.message,variant:"error"})},[h.error,h.isError,t,a]),c.useEffect(()=>{N.isError&&N.error&&t({title:a("dashboard.toast.modelError"),description:N.error.message,variant:"error"})},[N.error,N.isError,t,a]),c.useEffect(()=>{j.isError&&j.error&&t({title:a("dashboard.toast.statusError"),description:j.error.message,variant:"error"})},[j.error,j.isError,t,a]),c.useEffect(()=>{b.isError&&b.error&&t({title:a("dashboard.toast.dbError"),description:b.error.message,variant:"error"})},[b.error,b.isError,t,a]),c.useEffect(()=>{T.isError&&T.error&&t({title:a("dashboard.toast.recentError"),description:T.error.message,variant:"error"})},[T.error,T.isError,t,a]);const xe=c.useCallback(async()=>{await Promise.all([o.refetch(),l.refetch(),h.refetch(),N.refetch(),j.refetch(),b.refetch(),T.refetch()])},[o,b,h,T,N,l,j]),be=c.useCallback(async()=>{if(!d){n(!0);try{await Ue.post("/api/db/compact"),await b.refetch(),t({title:a("dashboard.toast.compactSuccess.title"),description:a("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(i){const u=Ve(i);t({title:a("dashboard.toast.compactError.title"),description:u.message,variant:"error"})}finally{n(!1)}}},[d,b,t,a]),ge=l.data,w=h.data??[],p=N.data??[],fe=j.data,R=b.data,je=((ee=T.data)==null?void 0:ee.items)??[],ye=s==="all"?a("dashboard.filters.endpointAll"):s==="anthropic"?a("dashboard.filters.endpointAnthropic"):s==="openai"?a("dashboard.filters.endpointOpenAI"):((se=(te=(ae=o.data)==null?void 0:ae.endpoints)==null?void 0:te.find(i=>i.id===s))==null?void 0:se.label)||s,ve=w.reduce((i,u)=>i+u.requestCount,0),Ne=w.reduce((i,u)=>!i||u.requestCount>i.requestCount?u:i,null),Te=p[0],we=p.filter(i=>i.avgTtftMs!=null&&i.avgTtftMs>0).sort((i,u)=>(i.avgTtftMs??Number.POSITIVE_INFINITY)-(u.avgTtftMs??Number.POSITIVE_INFINITY))[0],Se=o.isFetching||l.isFetching||h.isFetching||N.isFetching||j.isFetching||b.isFetching||T.isFetching,ke=l.isPending||j.isPending||b.isPending,Ce=((re=l.error)==null?void 0:re.message)??((oe=j.error)==null?void 0:oe.message)??((ne=b.error)==null?void 0:ne.message)??null,Ee=R?K(R.totalBytes??R.sizeBytes):"-",Re=K(R==null?void 0:R.memoryRssBytes),Ie=c.useMemo(()=>{const i=w.map(v=>v.date),u=a("dashboard.charts.barRequests"),P=a("dashboard.charts.lineInput"),M=a("dashboard.charts.lineOutput"),y=a("dashboard.charts.lineCacheRead"),de=a("dashboard.charts.lineCacheCreation");return{tooltip:{trigger:"axis"},legend:{data:[u,P,M,y,de]},grid:{left:56,right:28,top:56,bottom:54},xAxis:{type:"category",data:i},yAxis:{type:"value"},series:[{name:u,type:"bar",data:w.map(v=>v.requestCount),itemStyle:{color:S.requests,borderRadius:[6,6,0,0]}},{name:P,type:"line",smooth:!0,data:w.map(v=>v.inputTokens),itemStyle:{color:S.input},lineStyle:{width:2}},{name:M,type:"line",smooth:!0,data:w.map(v=>v.outputTokens),itemStyle:{color:S.output},lineStyle:{width:2}},{name:y,type:"line",smooth:!0,data:w.map(v=>v.cacheReadTokens),itemStyle:{color:S.cacheRead},lineStyle:{width:2}},{name:de,type:"line",smooth:!0,data:w.map(v=>v.cacheCreationTokens),itemStyle:{color:S.cacheCreation},lineStyle:{width:2}}]}},[w,a]),Le=c.useMemo(()=>{const i=p.map(y=>`${y.provider}/${y.model}`),u=a("dashboard.charts.barRequests"),P=a("dashboard.charts.lineInput"),M=a("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis"},legend:{data:[u,P,M]},grid:{left:72,right:52,top:56,bottom:96},xAxis:{type:"category",data:i,axisLabel:{rotate:28}},yAxis:[{type:"value",name:u},{type:"value",name:a("dashboard.charts.axisTokens"),position:"right"}],series:[{name:u,type:"bar",data:p.map(y=>y.requests),itemStyle:{color:S.requests,borderRadius:[6,6,0,0]}},{name:P,type:"line",yAxisIndex:1,smooth:!0,data:p.map(y=>y.inputTokens??0),itemStyle:{color:S.input}},{name:M,type:"line",yAxisIndex:1,smooth:!0,data:p.map(y=>y.outputTokens??0),itemStyle:{color:S.output}}]}},[p,a]),qe=c.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:p.map(i=>`${i.provider}/${i.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:a("dashboard.charts.ttftAxis")},series:[{name:a("dashboard.charts.ttftLabel"),type:"bar",data:p.map(i=>i.avgTtftMs??0),itemStyle:{color:S.latency,borderRadius:[6,6,0,0]}}]}),[p,a]),Pe=c.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:p.map(i=>`${i.provider}/${i.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:a("dashboard.charts.tpotAxis")},series:[{name:a("dashboard.charts.tpotLabel"),type:"bar",data:p.map(i=>i.avgTpotMs??0),itemStyle:{color:S.output,borderRadius:[6,6,0,0]}}]}),[p,a]);return{compacting:d,customEndpoints:((ie=o.data)==null?void 0:ie.endpoints)??[],daily:w,dailyOption:Ie,dailyPending:h.isPending,dbInfo:R,dbSizeDisplay:Ee,endpointFilter:s,fastestTtftModel:we,handleCompact:be,handleRefresh:xe,bootstrapError:Ce,isBootstrapping:ke,isRefreshing:Se,latestLogsPending:T.isPending,memoryDisplay:Re,modelRequestsOption:Le,modelUsagePending:N.isPending,models:p,overview:ge,recentLogs:je,selectedEndpointLabel:ye,setEndpointFilter:r,status:fe,topModel:Te,totalRequestsInRange:ve,busiestDay:Ne,ttftOption:qe,tpotOption:Pe}}function _a(){var s;const{t:a}=C(),t=ba();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(He,{icon:e.jsx(G,{className:"h-5 w-5","aria-hidden":"true"}),title:a("nav.dashboard"),description:a("dashboard.description"),badge:t.selectedEndpointLabel,eyebrow:"Operations",breadcrumb:"Gateway / Dashboard",helper:a("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:[a("dashboard.filters.endpoint")," · ",t.selectedEndpointLabel]}),e.jsxs(Ye,{value:t.endpointFilter,onValueChange:t.setEndpointFilter,children:[e.jsx(Ze,{className:"w-full sm:w-[168px]",children:e.jsx(We,{})}),e.jsxs(Je,{children:[e.jsx(B,{value:"all",children:a("dashboard.filters.endpointAll")}),e.jsx(B,{value:"anthropic",children:a("dashboard.filters.endpointAnthropic")}),e.jsx(B,{value:"openai",children:a("dashboard.filters.endpointOpenAI")}),t.customEndpoints.map(r=>e.jsx(B,{value:r.id,children:r.label||r.id},r.id))]})]}),e.jsxs(U,{variant:"outline",size:"sm",onClick:()=>void t.handleRefresh(),disabled:t.isRefreshing,className:"w-full sm:w-auto",children:[e.jsx($e,{className:x("mr-2 h-4 w-4",t.isRefreshing&&"animate-spin"),"aria-hidden":"true"}),t.isRefreshing?a("common.actions.refreshing"):a("common.actions.refresh")]}),e.jsxs(U,{variant:"outline",size:"sm",onClick:()=>void t.handleCompact(),disabled:t.compacting,className:"w-full sm:w-auto",children:[e.jsx(ue,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),t.compacting?a("dashboard.actions.compacting"):a("dashboard.actions.compact")]})]})}),t.isBootstrapping?e.jsx(ia,{}):t.bootstrapError?e.jsx(H,{icon:e.jsx(Ge,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:a("common.status.error"),description:t.bootstrapError,action:e.jsx(U,{variant:"outline",onClick:()=>void t.handleRefresh(),children:a("common.actions.refresh")})}):e.jsxs(e.Fragment,{children:[e.jsx(da,{dbSizeDisplay:t.dbSizeDisplay,memoryDisplay:t.memoryDisplay,selectedEndpointLabel:t.selectedEndpointLabel,status:t.status,todayRequests:((s=t.overview)==null?void 0:s.today.requests)??0}),e.jsx(la,{overview:t.overview}),e.jsx(ca,{busiestDay:t.busiestDay,fastestTtftModel:t.fastestTtftModel,topModel:t.topModel,totalRequestsInRange:t.totalRequestsInRange}),e.jsx(ma,{dailyEmpty:!t.daily.length,dailyOption:t.dailyOption,dailyPending:t.dailyPending,models:t.models,modelRequestsOption:t.modelRequestsOption,modelUsagePending:t.modelUsagePending,ttftOption:t.ttftOption,tpotOption:t.tpotOption}),e.jsx(ha,{models:t.models,loading:t.modelUsagePending}),e.jsx(ua,{records:t.recentLogs,loading:t.latestLogsPending})]})]})}export{_a as default};
@@ -1 +1 @@
1
- import{r,j as t,a9 as g}from"./vendor-DfnQOGOQ.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-D08JKSgz.js";import{c as o}from"./index-OvGsIZkZ.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,a9 as g}from"./vendor-DfnQOGOQ.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-D08JKSgz.js";import{c as o}from"./index-DTypJ2Bg.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 +1 @@
1
- import{r as f,j as e,am as R,aq as M,ar as I,W as T,as as q,at as B,au as V,a2 as D}from"./vendor-DfnQOGOQ.js";import{P as K}from"./PageHeader-DKkO-Kdm.js";import{P as G}from"./PageSection-D9se25qM.js";import{P as Q,a as $}from"./PageState-DSoiwsKr.js";import{u as H}from"./useApiQuery-3ZHohr5l.js";import{u as J,B as x,c as p}from"./index-OvGsIZkZ.js";import{q as O}from"./queryKeys-BMvyDTQS.js";import{B as c}from"./badge-CkaH3uCO.js";import{C as N,a as y}from"./card-Bem3kP2L.js";import{I as U}from"./input-DCNoHAkn.js";import{S as W,a as _,b as X,c as Y,d as g}from"./select-DS37xdev.js";import{u as z}from"./i18n-dgCQR_PB.js";import"./query-Db16w3tH.js";import"./router-BURlSZbt.js";import"./radix-D08JKSgz.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(q,{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(B,{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(V,{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(W,{value:t.level,onValueChange:r=>{n(null),m(b=>({...b,level:r==="all"?"":r}))},children:[e.jsx(_,{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,am as R,aq as M,ar as I,W as T,as as q,at as B,au as V,a2 as D}from"./vendor-DfnQOGOQ.js";import{P as K}from"./PageHeader-JpvzJlDR.js";import{P as G}from"./PageSection-D_3fkKC5.js";import{P as Q,a as $}from"./PageState-rxsd1pfX.js";import{u as H}from"./useApiQuery-CDL54hs8.js";import{u as J,B as x,c as p}from"./index-DTypJ2Bg.js";import{q as O}from"./queryKeys-BMvyDTQS.js";import{B as c}from"./badge-Ci0LPkhW.js";import{C as N,a as y}from"./card-hwtf3yu-.js";import{I as U}from"./input-nzbrZT8r.js";import{S as W,a as _,b as X,c as Y,d as g}from"./select-CCOTVWXq.js";import{u as z}from"./i18n-dgCQR_PB.js";import"./query-Db16w3tH.js";import"./router-BURlSZbt.js";import"./radix-D08JKSgz.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(q,{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(B,{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(V,{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(W,{value:t.level,onValueChange:r=>{n(null),m(b=>({...b,level:r==="all"?"":r}))},children:[e.jsx(_,{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,4 +1,4 @@
1
- import{r as u,j as e,aG as b,aD as N,aH as v,aI as y}from"./vendor-DfnQOGOQ.js";import{P as w}from"./PageHeader-DKkO-Kdm.js";import{P as a}from"./PageSection-D9se25qM.js";import{c as h}from"./clipboard-CALi6bTW.js";import{C as p,a as j}from"./card-Bem3kP2L.js";import{B as f}from"./index-OvGsIZkZ.js";import{u as x}from"./i18n-dgCQR_PB.js";import"./badge-CkaH3uCO.js";import"./query-Db16w3tH.js";import"./router-BURlSZbt.js";import"./radix-D08JKSgz.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(`
1
+ import{r as u,j as e,aG as b,aD as N,aH as v,aI as y}from"./vendor-DfnQOGOQ.js";import{P as w}from"./PageHeader-JpvzJlDR.js";import{P as a}from"./PageSection-D_3fkKC5.js";import{c as h}from"./clipboard-CALi6bTW.js";import{C as p,a as j}from"./card-hwtf3yu-.js";import{B as f}from"./index-DTypJ2Bg.js";import{u as x}from"./i18n-dgCQR_PB.js";import"./badge-Ci0LPkhW.js";import"./query-Db16w3tH.js";import"./router-BURlSZbt.js";import"./radix-D08JKSgz.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(`
@@ -1 +1 @@
1
- import{r as n,j as e,ar as S,aJ as E}from"./vendor-DfnQOGOQ.js";import{i as k,L as F,B as L}from"./index-OvGsIZkZ.js";import{C as j,a as b,b as P,c as T,d as A,e as B}from"./card-Bem3kP2L.js";import{I as N}from"./input-DCNoHAkn.js";import{L as y}from"./label-9kbpUKaR.js";import{u as D}from"./i18n-dgCQR_PB.js";import{c as G,u as I}from"./router-BURlSZbt.js";import"./query-Db16w3tH.js";import"./radix-D08JKSgz.js";function O(){const{t:s}=D(),a=G(),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(P,{className:"pb-4 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground",children:"GW"}),e.jsx(T,{className:"text-xl",children:s("login.title")}),e.jsx(A,{children:s("login.description")})]}),e.jsx(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(B,{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,ar as S,aJ as E}from"./vendor-DfnQOGOQ.js";import{i as k,L as F,B as L}from"./index-DTypJ2Bg.js";import{C as j,a as b,b as P,c as T,d as A,e as B}from"./card-hwtf3yu-.js";import{I as N}from"./input-nzbrZT8r.js";import{L as y}from"./label-jdLnQwgX.js";import{u as D}from"./i18n-dgCQR_PB.js";import{c as G,u as I}from"./router-BURlSZbt.js";import"./query-Db16w3tH.js";import"./radix-D08JKSgz.js";function O(){const{t:s}=D(),a=G(),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(P,{className:"pb-4 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground",children:"GW"}),e.jsx(T,{className:"text-xl",children:s("login.title")}),e.jsx(A,{children:s("login.description")})]}),e.jsx(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(B,{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};